libresilient/lib/ipfs.js

117 wiersze
1.6 MiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

"use strict";(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Ipfs = factory()}(typeof self !== 'undefined' ? self : this, function () {
var Ipfs=(()=>{var nue=Object.create;var R3=Object.defineProperty;var iue=Object.getOwnPropertyDescriptor;var sue=Object.getOwnPropertyNames;var oue=Object.getPrototypeOf,aue=Object.prototype.hasOwnProperty;var Rd=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var wv=(r,e)=>()=>(r&&(e=r(r=0)),e);var R=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Kt=(r,e)=>{for(var t in e)R3(r,t,{get:e[t],enumerable:!0})},VD=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of sue(e))!aue.call(r,i)&&i!==t&&R3(r,i,{get:()=>e[i],enumerable:!(n=iue(e,i))||n.enumerable});return r};var E=(r,e,t)=>(t=r!=null?nue(oue(r)):{},VD(e||!r||!r.__esModule?R3(t,"default",{value:r,enumerable:!0}):t,r)),KD=r=>VD(R3({},"__esModule",{value:!0}),r);var $D=R(C3=>{"use strict";u();C3.byteLength=lue;C3.toByteArray=fue;C3.fromByteArray=pue;var Jo=[],vs=[],cue=typeof Uint8Array<"u"?Uint8Array:Array,Ev="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Sf=0,qD=Ev.length;Sf<qD;++Sf)Jo[Sf]=Ev[Sf],vs[Ev.charCodeAt(Sf)]=Sf;var Sf,qD;vs["-".charCodeAt(0)]=62;vs["_".charCodeAt(0)]=63;function zD(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function lue(r){var e=zD(r),t=e[0],n=e[1];return(t+n)*3/4-n}function uue(r,e,t){return(e+t)*3/4-t}function fue(r){var e,t=zD(r),n=t[0],i=t[1],s=new cue(uue(r,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=vs[r.charCodeAt(c)]<<18|vs[r.charCodeAt(c+1)]<<12|vs[r.charCodeAt(c+2)]<<6|vs[r.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=vs[r.charCodeAt(c)]<<2|vs[r.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=vs[r.charCodeAt(c)]<<10|vs[r.charCodeAt(c+1)]<<4|vs[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function hue(r){return Jo[r>>18&63]+Jo[r>>12&63]+Jo[r>>6&63]+Jo[r&63]}function due(r,e,t){for(var n,i=[],s=e;s<t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(hue(n));return i.join("")}function pue(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,a=t-n;o<a;o+=s)i.push(due(r,o,o+s>a?a:o+s));return n===1?(e=r[t-1],i.push(Jo[e>>2]+Jo[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(Jo[e>>10]+Jo[e>>4&63]+Jo[e<<2&63]+"=")),i.join("")}});var HD=R(bv=>{u();bv.read=function(r,e,t,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,f=-7,h=t?i-1:0,p=t?-1:1,d=r[e+h];for(h+=p,s=d&(1<<-f)-1,d>>=-f,f+=a;f>0;s=s*256+r[e+h],h+=p,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=o*256+r[e+h],h+=p,f-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(d?-1:1)*o*Math.pow(2,s-n)};bv.write=function(r,e,t,n,i,s){var o,a,c,l=s*8-i-1,f=(1<<l)-1,h=f>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,m=n?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=p/c:e+=p*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=f?(a=0,o=f):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;r[t+d]=a&255,d+=m,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;r[t+d]=o&255,d+=m,o/=256,l-=8);r[t+d-m]|=y*128}});var Tf=R(Od=>{"use strict";u();var vv=$D(),Pd=HD(),GD=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Od.Buffer=G;Od.SlowBuffer=bue;Od.INSPECT_MAX_BYTES=50;var P3=2147483647;Od.kMaxLength=P3;G.TYPED_ARRAY_SUPPORT=mue();!G.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function mue(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(G.prototype,"parent",{enumerable:!0,get:function(){if(!!G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(!!G.isBuffer(this))return this.byteOffset}});function ac(r){if(r>P3)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,G.prototype),e}function G(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Tv(r)}return QD(r,e,t)}G.poolSize=8192;function QD(r,e,t){if(typeof r=="string")return gue(r,e);if(ArrayBuffer.isView(r))return wue(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(ea(r,ArrayBuffer)||r&&ea(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ea(r,SharedArrayBuffer)||r&&ea(r.buffer,SharedArrayBuffer)))return Sv(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return G.from(n,e,t);let i=Eue(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return G.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}G.from=function(r,e,t){return QD(r,e,t)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function XD(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function yue(r,e,t){return XD(r),r<=0?ac(r):e!==void 0?typeof t=="string"?ac(r).fill(e,t):ac(r).fill(e):ac(r)}G.alloc=function(r,e,t){return yue(r,e,t)};function Tv(r){return XD(r),ac(r<0?0:Iv(r)|0)}G.allocUnsafe=function(r){return Tv(r)};G.allocUnsafeSlow=function(r){return Tv(r)};function gue(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!G.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ZD(r,e)|0,n=ac(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function _v(r){let e=r.length<0?0:Iv(r.length)|0,t=ac(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function wue(r){if(ea(r,Uint8Array)){let e=new Uint8Array(r);return Sv(e.buffer,e.byteOffset,e.byteLength)}return _v(r)}function Sv(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,G.prototype),n}function Eue(r){if(G.isBuffer(r)){let e=Iv(r.length)|0,t=ac(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Rv(r.length)?ac(0):_v(r);if(r.type==="Buffer"&&Array.isArray(r.data))return _v(r.data)}function Iv(r){if(r>=P3)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+P3.toString(16)+" bytes");return r|0}function bue(r){return+r!=r&&(r=0),G.alloc(+r)}G.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==G.prototype};G.compare=function(e,t){if(ea(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),ea(t,Uint8Array)&&(t=G.from(t,t.offset,t.byteLength)),!G.isBuffer(e)||!G.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==t[s]){n=e[s],i=t[s];break}return n<i?-1:i<n?1:0};G.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};G.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return G.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=G.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){let o=e[n];if(ea(o,Uint8Array))s+o.length>i.length?(G.isBuffer(o)||(o=G.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(G.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function ZD(r,e){if(G.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||ea(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return xv(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return aO(r).length;default:if(i)return n?-1:xv(r).length;e=(""+e).toLowerCase(),i=!0}}G.byteLength=ZD;function vue(r,e,t){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Due(this,e,t);case"utf8":case"utf-8":return eO(this,e,t);case"ascii":return Cue(this,e,t);case"latin1":case"binary":return Pue(this,e,t);case"base64":return Aue(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Oue(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function xf(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}G.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)xf(this,t,t+1);return this};G.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)xf(this,t,t+3),xf(this,t+1,t+2);return this};G.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)xf(this,t,t+7),xf(this,t+1,t+6),xf(this,t+2,t+5),xf(this,t+3,t+4);return this};G.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?eO(this,0,e):vue.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(e){if(!G.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:G.compare(this,e)===0};G.prototype.inspect=function(){let e="",t=Od.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};GD&&(G.prototype[GD]=G.prototype.inspect);G.prototype.compare=function(e,t,n,i,s){if(ea(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-t,c=Math.min(o,a),l=this.slice(i,s),f=e.slice(t,n);for(let h=0;h<c;++h)if(l[h]!==f[h]){o=l[h],a=f[h];break}return o<a?-1:a<o?1:0};function JD(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Rv(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=G.from(e,n)),G.isBuffer(e))return e.length===0?-1:jD(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):jD(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function jD(r,e,t,n,i){let s=1,o=r.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,a/=2,t/=2}function c(f,h){return s===1?f[h]:f.readUInt16BE(h*s)}let l;if(i){let f=-1;for(l=t;l<o;l++)if(c(r,l)===c(e,f===-1?0:l-f)){if(f===-1&&(f=l),l-f+1===a)return f*s}else f!==-1&&(l-=l-f),f=-1}else for(t+a>o&&(t=o-a),l=t;l>=0;l--){let f=!0;for(let h=0;h<a;h++)if(c(r,l+h)!==c(e,h)){f=!1;break}if(f)return l}return-1}G.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};G.prototype.indexOf=function(e,t,n){return JD(this,e,t,n,!0)};G.prototype.lastIndexOf=function(e,t,n){return JD(this,e,t,n,!1)};function _ue(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Rv(a))return o;r[t+o]=a}return o}function Sue(r,e,t,n){return D3(xv(e,r.length-t),r,t,n)}function xue(r,e,t,n){return D3(Bue(e),r,t,n)}function Tue(r,e,t,n){return D3(aO(e),r,t,n)}function Iue(r,e,t,n){return D3(Mue(e,r.length-t),r,t,n)}G.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return _ue(this,e,t,n);case"utf8":case"utf-8":return Sue(this,e,t,n);case"ascii":case"latin1":case"binary":return xue(this,e,t,n);case"base64":return Tue(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Iue(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Aue(r,e,t){return e===0&&t===r.length?vv.fromByteArray(r):vv.fromByteArray(r.slice(e,t))}function eO(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let s=r[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=t){let c,l,f,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=r[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=r[i+1],l=r[i+2],(c&192)===128&&(l&192)===128&&(h=(s&15)<<12|(c&63)<<6|l&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=r[i+1],l=r[i+2],f=r[i+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(h=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,h>65535&&h<1114112&&(o=h))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Rue(n)}var WD=4096;function Rue(r){let e=r.length;if(e<=WD)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=WD));return t}function Cue(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function Pue(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function Due(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let s=e;s<t;++s)i+=Uue[r[s]];return i}function Oue(r,e,t){let n=r.slice(e,t),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}G.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,G.prototype),i};function Sn(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}G.prototype.readUintLE=G.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||Sn(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||Sn(e,t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(e,t){return e=e>>>0,t||Sn(e,1,this.length),this[e]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||Sn(e,2,this.length),this[e]|this[e+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||Sn(e,2,this.length),this[e]<<8|this[e+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||Sn(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||Sn(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};G.prototype.readBigUInt64LE=Pl(function(e){e=e>>>0,Dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&D1(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});G.prototype.readBigUInt64BE=Pl(function(e){e=e>>>0,Dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&D1(e,this.length-8);let i=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});G.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||Sn(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*t)),i};G.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||Sn(e,t,this.length);let i=t,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};G.prototype.readInt8=function(e,t){return e=e>>>0,t||Sn(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};G.prototype.readInt16LE=function(e,t){e=e>>>0,t||Sn(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(e,t){e=e>>>0,t||Sn(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(e,t){return e=e>>>0,t||Sn(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};G.prototype.readInt32BE=function(e,t){return e=e>>>0,t||Sn(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};G.prototype.readBigInt64LE=Pl(function(e){e=e>>>0,Dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&D1(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});G.prototype.readBigInt64BE=Pl(function(e){e=e>>>0,Dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&D1(e,this.length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});G.prototype.readFloatLE=function(e,t){return e=e>>>0,t||Sn(e,4,this.length),Pd.read(this,e,!0,23,4)};G.prototype.readFloatBE=function(e,t){return e=e>>>0,t||Sn(e,4,this.length),Pd.read(this,e,!1,23,4)};G.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||Sn(e,8,this.length),Pd.read(this,e,!0,52,8)};G.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||Sn(e,8,this.length),Pd.read(this,e,!1,52,8)};function wi(r,e,t,n,i,s){if(!G.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(t+n>r.length)throw new RangeError("Index out of range")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;wi(this,e,t,n,a,0)}let s=1,o=0;for(this[t]=e&255;++o<n&&(s*=256);)this[t+o]=e/s&255;return t+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;wi(this,e,t,n,a,0)}let s=n-1,o=1;for(this[t+s]=e&255;--s>=0&&(o*=256);)this[t+s]=e/o&255;return t+n};G.prototype.writeUint8=G.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,1,255,0),this[t]=e&255,t+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function tO(r,e,t,n,i){oO(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,t}function rO(r,e,t,n,i){oO(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}G.prototype.writeBigUInt64LE=Pl(function(e,t=0){return tO(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=Pl(function(e,t=0){return rO(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);wi(this,e,t,n,c-1,-c)}let s=0,o=1,a=0;for(this[t]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[t+s-1]!==0&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n};G.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);wi(this,e,t,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[t+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[t+s+1]!==0&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n};G.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};G.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};G.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};G.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};G.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||wi(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};G.prototype.writeBigInt64LE=Pl(function(e,t=0){return tO(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=Pl(function(e,t=0){return rO(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function nO(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function iO(r,e,t,n,i){return e=+e,t=t>>>0,i||nO(r,e,t,4,34028234663852886e22,-34028234663852886e22),Pd.write(r,e,t,n,23,4),t+4}G.prototype.writeFloatLE=function(e,t,n){return iO(this,e,t,!0,n)};G.prototype.writeFloatBE=function(e,t,n){return iO(this,e,t,!1,n)};function sO(r,e,t,n,i){return e=+e,t=t>>>0,i||nO(r,e,t,8,17976931348623157e292,-17976931348623157e292),Pd.write(r,e,t,n,52,8),t+8}G.prototype.writeDoubleLE=function(e,t,n){return sO(this,e,t,!0,n)};G.prototype.writeDoubleBE=function(e,t,n){return sO(this,e,t,!1,n)};G.prototype.copy=function(e,t,n,i){if(!G.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),s};G.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!G.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s<n;++s)this[s]=e;else{let o=G.isBuffer(e)?e:G.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var Cd={};function Av(r,e,t){Cd[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Av("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Av("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Av("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=YD(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=YD(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function YD(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function kue(r,e,t){Dd(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&D1(e,r.length-(t+1))}function oO(r,e,t,n,i,s){if(r>t||r<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${t}${o}`,new Cd.ERR_OUT_OF_RANGE("value",a,r)}kue(n,i,s)}function Dd(r,e){if(typeof r!="number")throw new Cd.ERR_INVALID_ARG_TYPE(e,"number",r)}function D1(r,e,t){throw Math.floor(r)!==r?(Dd(r,t),new Cd.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Cd.ERR_BUFFER_OUT_OF_BOUNDS:new Cd.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Nue=/[^+/0-9A-Za-z-_]/g;function Lue(r){if(r=r.split("=")[0],r=r.trim().replace(Nue,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function xv(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Bue(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function Mue(r,e){let t,n,i,s=[];for(let o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),n=t>>8,i=t%256,s.push(i),s.push(n);return s}function aO(r){return vv.toByteArray(Lue(r))}function D3(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function ea(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Rv(r){return r!==r}var Uue=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function Pl(r){return typeof BigInt>"u"?Fue:r}function Fue(){throw new Error("BigInt not supported")}});var hO=R((ZIe,fO)=>{u();var $r=fO.exports={},ta,ra;function Cv(){throw new Error("setTimeout has not been defined")}function Pv(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ta=setTimeout:ta=Cv}catch{ta=Cv}try{typeof clearTimeout=="function"?ra=clearTimeout:ra=Pv}catch{ra=Pv}})();function cO(r){if(ta===setTimeout)return setTimeout(r,0);if((ta===Cv||!ta)&&setTimeout)return ta=setTimeout,setTimeout(r,0);try{return ta(r,0)}catch{try{return ta.call(null,r,0)}catch{return ta.call(this,r,0)}}}function Vue(r){if(ra===clearTimeout)return clearTimeout(r);if((ra===Pv||!ra)&&clearTimeout)return ra=clearTimeout,clearTimeout(r);try{return ra(r)}catch{try{return ra.call(null,r)}catch{return ra.call(this,r)}}}var cc=[],kd=!1,If,O3=-1;function Kue(){!kd||!If||(kd=!1,If.length?cc=If.concat(cc):O3=-1,cc.length&&lO())}function lO(){if(!kd){var r=cO(Kue);kd=!0;for(var e=cc.length;e;){for(If=cc,cc=[];++O3<e;)If&&If[O3].run();O3=-1,e=cc.length}If=null,kd=!1,Vue(r)}}$r.nextTick=function(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];cc.push(new uO(r,e)),cc.length===1&&!kd&&cO(lO)};function uO(r,e){this.fun=r,this.array=e}uO.prototype.run=function(){this.fun.apply(null,this.array)};$r.title="browser";$r.browser=!0;$r.env={};$r.argv=[];$r.version="";$r.versions={};function lc(){}$r.on=lc;$r.addListener=lc;$r.once=lc;$r.off=lc;$r.removeListener=lc;$r.removeAllListeners=lc;$r.emit=lc;$r.prependListener=lc;$r.prependOnceListener=lc;$r.listeners=function(r){return[]};$r.binding=function(r){throw new Error("process.binding is not supported")};$r.cwd=function(){return"/"};$r.chdir=function(r){throw new Error("process.chdir is not supported")};$r.umask=function(){return 0}});var Buffer,process,u=wv(()=>{({Buffer}=Tf()),process=hO()});var pO=R((eAe,dO)=>{"use strict";u();dO.exports=r=>{if(Object.prototype.toString.call(r)!=="[object Object]")return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}});var Ov=R((wO,EO)=>{"use strict";u();var k3=pO(),{hasOwnProperty:yO}=Object.prototype,{propertyIsEnumerable:que}=Object,Nd=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),zue=wO,mO={concatArrays:!1,ignoreUndefined:!1},N3=r=>{let e=[];for(let t in r)yO.call(r,t)&&e.push(t);if(Object.getOwnPropertySymbols){let t=Object.getOwnPropertySymbols(r);for(let n of t)que.call(r,n)&&e.push(n)}return e};function Ld(r){return Array.isArray(r)?$ue(r):k3(r)?Hue(r):r}function $ue(r){let e=r.slice(0,0);return N3(r).forEach(t=>{Nd(e,t,Ld(r[t]))}),e}function Hue(r){let e=Object.getPrototypeOf(r)===null?Object.create(null):{};return N3(r).forEach(t=>{Nd(e,t,Ld(r[t]))}),e}var gO=(r,e,t,n)=>(t.forEach(i=>{typeof e[i]>"u"&&n.ignoreUndefined||(i in r&&r[i]!==Object.getPrototypeOf(r)?Nd(r,i,Dv(r[i],e[i],n)):Nd(r,i,Ld(e[i])))}),r),Gue=(r,e,t)=>{let n=r.slice(0,0),i=0;return[r,e].forEach(s=>{let o=[];for(let a=0;a<s.length;a++)!yO.call(s,a)||(o.push(String(a)),s===r?Nd(n,i++,s[a]):Nd(n,i++,Ld(s[a])));n=gO(n,s,N3(s).filter(a=>!o.includes(a)),t)}),n};function Dv(r,e,t){return t.concatArrays&&Array.isArray(r)&&Array.isArray(e)?Gue(r,e,t):!k3(e)||!k3(r)?Ld(e):gO(r,e,N3(e),t)}EO.exports=function(...r){let e=Dv(Ld(mO),this!==zue&&this||{},mO),t={_:{}};for(let n of r)if(n!==void 0){if(!k3(n))throw new TypeError("`"+n+"` is not an Option Object");t=Dv(t,{_:n},e)}return t._}});var kv=R((rAe,vO)=>{u();function jue(){return typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&!!process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0}vO.exports=jue});var Nv=R((nAe,_O)=>{"use strict";u();var Wue=kv(),L3=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,O1=Wue(),Yue=L3&&!O1,Que=O1&&!L3,Xue=O1&&L3,Zue=typeof Rd=="function"&&typeof process<"u"&&typeof process.release<"u"&&process.release.name==="node"&&!O1,Jue=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,efe=typeof process<"u"&&typeof process.env<"u"&&!1,tfe=typeof navigator<"u"&&navigator.product==="ReactNative";_O.exports={isTest:efe,isElectron:O1,isElectronMain:Que,isElectronRenderer:Xue,isNode:Zue,isBrowser:Yue,isWebWorker:Jue,isEnvWithDom:L3,isReactNative:tfe}});var Lv=R((iAe,SO)=>{u();var Bd=1e3,Md=Bd*60,Ud=Md*60,Af=Ud*24,rfe=Af*7,nfe=Af*365.25;SO.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return ife(r);if(t==="number"&&isFinite(r))return e.long?ofe(r):sfe(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function ife(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!!e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*nfe;case"weeks":case"week":case"w":return t*rfe;case"days":case"day":case"d":return t*Af;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ud;case"minutes":case"minute":case"mins":case"min":case"m":return t*Md;case"seconds":case"second":case"secs":case"sec":case"s":return t*Bd;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function sfe(r){var e=Math.abs(r);return e>=Af?Math.round(r/Af)+"d":e>=Ud?Math.round(r/Ud)+"h":e>=Md?Math.round(r/Md)+"m":e>=Bd?Math.round(r/Bd)+"s":r+"ms"}function ofe(r){var e=Math.abs(r);return e>=Af?B3(r,e,Af,"day"):e>=Ud?B3(r,e,Ud,"hour"):e>=Md?B3(r,e,Md,"minute"):e>=Bd?B3(r,e,Bd,"second"):r+" ms"}function B3(r,e,t,n){var i=e>=t*1.5;return Math.round(r/t)+" "+n+(i?"s":"")}});var TO=R((sAe,xO)=>{u();function afe(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=i,t.enabled=o,t.humanize=Lv(),t.destroy=l,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let p=0;p<f.length;p++)h=(h<<5)-h+f.charCodeAt(p),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,p=null,d,m;function y(...g){if(!y.enabled)return;let w=y,b=Number(new Date),S=b-(h||b);w.diff=S,w.prev=h,w.curr=b,h=b,g[0]=t.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let _=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(T,x)=>{if(T==="%%")return"%";_++;let P=t.formatters[x];if(typeof P=="function"){let B=g[_];T=P.call(w,B),g.splice(_,1),_--}return T}),t.formatArgs.call(w,g),(w.log||t.log).apply(w,g)}return y.namespace=f,y.useColors=t.useColors(),y.color=t.selectColor(f),y.extend=n,y.destroy=t.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==t.namespaces&&(d=t.namespaces,m=t.enabled(f)),m),set:g=>{p=g}}),typeof t.init=="function"&&t.init(y),y}function n(f,h){let p=t(this.namespace+(typeof h>"u"?":":h)+f);return p.log=this.log,p}function i(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,p=(typeof f=="string"?f:"").split(/[\s,]+/),d=p.length;for(h=0;h<d;h++)!p[h]||(f=p[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,p;for(h=0,p=t.skips.length;h<p;h++)if(t.skips[h].test(f))return!1;for(h=0,p=t.names.length;h<p;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}xO.exports=afe});var Li=R((Ni,M3)=>{u();Ni.formatArgs=lfe;Ni.save=ufe;Ni.load=ffe;Ni.useColors=cfe;Ni.storage=hfe();Ni.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ni.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function cfe(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function lfe(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+M3.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(t++,i==="%c"&&(n=t))}),r.splice(n,0,e)}Ni.log=console.debug||console.log||(()=>{});function ufe(r){try{r?Ni.storage.setItem("debug",r):Ni.storage.removeItem("debug")}catch{}}function ffe(){let r;try{r=Ni.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function hfe(){try{return localStorage}catch{}}M3.exports=TO()(Ni);var{formatters:dfe}=M3.exports;dfe.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var V=R((gAe,PO)=>{"use strict";u();function CO(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Dfe(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return CO(r,t)}catch{t.message=r.message,t.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),CO(new i,t)}}PO.exports=Dfe});var U3=R((wAe,DO)=>{"use strict";u();DO.exports=Ofe;function Ofe(r,e){for(var t=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)t[n++]=arguments[i++];return new Promise(function(a,c){t[n]=function(f){if(s)if(s=!1,f)c(f);else{for(var h=new Array(arguments.length-1),p=0;p<h.length;)h[p++]=arguments[p];a.apply(null,h)}};try{r.apply(e||null,t)}catch(l){s&&(s=!1,c(l))}})}});var Wv=R(NO=>{"use strict";u();var F3=NO;F3.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&e.charAt(t)==="=";)++n;return Math.ceil(e.length*3)/4-n};var Kd=new Array(64),kO=new Array(123);for(io=0;io<64;)kO[Kd[io]=io<26?io+65:io<52?io+71:io<62?io-4:io-59|43]=io++;var io;F3.encode=function(e,t,n){for(var i=null,s=[],o=0,a=0,c;t<n;){var l=e[t++];switch(a){case 0:s[o++]=Kd[l>>2],c=(l&3)<<4,a=1;break;case 1:s[o++]=Kd[c|l>>4],c=(l&15)<<2,a=2;break;case 2:s[o++]=Kd[c|l>>6],s[o++]=Kd[l&63],a=0;break}o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),o=0)}return a&&(s[o++]=Kd[c],s[o++]=61,a===1&&(s[o++]=61)),i?(o&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))};var OO="invalid encoding";F3.decode=function(e,t,n){for(var i=n,s=0,o,a=0;a<e.length;){var c=e.charCodeAt(a++);if(c===61&&s>1)break;if((c=kO[c])===void 0)throw Error(OO);switch(s){case 0:o=c,s=1;break;case 1:t[n++]=o<<2|(c&48)>>4,o=c,s=2;break;case 2:t[n++]=(o&15)<<4|(c&60)>>2,o=c,s=3;break;case 3:t[n++]=(o&3)<<6|c,s=0;break}}if(s===1)throw Error(OO);return n-i};F3.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}});var Yv=R((bAe,LO)=>{"use strict";u();LO.exports=V3;function V3(){this._listeners={}}V3.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this};V3.prototype.off=function(e,t){if(e===void 0)this._listeners={};else if(t===void 0)this._listeners[e]=[];else for(var n=this._listeners[e],i=0;i<n.length;)n[i].fn===t?n.splice(i,1):++i;return this};V3.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<t.length;)t[i].fn.apply(t[i++].ctx,n)}return this}});var Qv=R((vAe,KO)=>{"use strict";u();KO.exports=BO(BO);function BO(r){return typeof Float32Array<"u"?function(){var e=new Float32Array([-0]),t=new Uint8Array(e.buffer),n=t[3]===128;function i(c,l,f){e[0]=c,l[f]=t[0],l[f+1]=t[1],l[f+2]=t[2],l[f+3]=t[3]}function s(c,l,f){e[0]=c,l[f]=t[3],l[f+1]=t[2],l[f+2]=t[1],l[f+3]=t[0]}r.writeFloatLE=n?i:s,r.writeFloatBE=n?s:i;function o(c,l){return t[0]=c[l],t[1]=c[l+1],t[2]=c[l+2],t[3]=c[l+3],e[0]}function a(c,l){return t[3]=c[l],t[2]=c[l+1],t[1]=c[l+2],t[0]=c[l+3],e[0]}r.readFloatLE=n?o:a,r.readFloatBE=n?a:o}():function(){function e(n,i,s,o){var a=i<0?1:0;if(a&&(i=-i),i===0)n(1/i>0?0:2147483648,s,o);else if(isNaN(i))n(2143289344,s,o);else if(i>34028234663852886e22)n((a<<31|2139095040)>>>0,s,o);else if(i<11754943508222875e-54)n((a<<31|Math.round(i/1401298464324817e-60))>>>0,s,o);else{var c=Math.floor(Math.log(i)/Math.LN2),l=Math.round(i*Math.pow(2,-c)*8388608)&8388607;n((a<<31|c+127<<23|l)>>>0,s,o)}}r.writeFloatLE=e.bind(null,MO),r.writeFloatBE=e.bind(null,UO);function t(n,i,s){var o=n(i,s),a=(o>>31)*2+1,c=o>>>23&255,l=o&8388607;return c===255?l?NaN:a*(1/0):c===0?a*1401298464324817e-60*l:a*Math.pow(2,c-150)*(l+8388608)}r.readFloatLE=t.bind(null,FO),r.readFloatBE=t.bind(null,VO)}(),typeof Float64Array<"u"?function(){var e=new Float64Array([-0]),t=new Uint8Array(e.buffer),n=t[7]===128;function i(c,l,f){e[0]=c,l[f]=t[0],l[f+1]=t[1],l[f+2]=t[2],l[f+3]=t[3],l[f+4]=t[4],l[f+5]=t[5],l[f+6]=t[6],l[f+7]=t[7]}function s(c,l,f){e[0]=c,l[f]=t[7],l[f+1]=t[6],l[f+2]=t[5],l[f+3]=t[4],l[f+4]=t[3],l[f+5]=t[2],l[f+6]=t[1],l[f+7]=t[0]}r.writeDoubleLE=n?i:s,r.writeDoubleBE=n?s:i;function o(c,l){return t[0]=c[l],t[1]=c[l+1],t[2]=c[l+2],t[3]=c[l+3],t[4]=c[l+4],t[5]=c[l+5],t[6]=c[l+6],t[7]=c[l+7],e[0]}function a(c,l){return t[7]=c[l],t[6]=c[l+1],t[5]=c[l+2],t[4]=c[l+3],t[3]=c[l+4],t[2]=c[l+5],t[1]=c[l+6],t[0]=c[l+7],e[0]}r.readDoubleLE=n?o:a,r.readDoubleBE=n?a:o}():function(){function e(n,i,s,o,a,c){var l=o<0?1:0;if(l&&(o=-o),o===0)n(0,a,c+i),n(1/o>0?0:2147483648,a,c+s);else if(isNaN(o))n(0,a,c+i),n(2146959360,a,c+s);else if(o>17976931348623157e292)n(0,a,c+i),n((l<<31|2146435072)>>>0,a,c+s);else{var f;if(o<22250738585072014e-324)f=o/5e-324,n(f>>>0,a,c+i),n((l<<31|f/4294967296)>>>0,a,c+s);else{var h=Math.floor(Math.log(o)/Math.LN2);h===1024&&(h=1023),f=o*Math.pow(2,-h),n(f*4503599627370496>>>0,a,c+i),n((l<<31|h+1023<<20|f*1048576&1048575)>>>0,a,c+s)}}}r.writeDoubleLE=e.bind(null,MO,0,4),r.writeDoubleBE=e.bind(null,UO,4,0);function t(n,i,s,o,a){var c=n(o,a+i),l=n(o,a+s),f=(l>>31)*2+1,h=l>>>20&2047,p=4294967296*(l&1048575)+c;return h===2047?p?NaN:f*(1/0):h===0?f*5e-324*p:f*Math.pow(2,h-1075)*(p+4503599627370496)}r.readDoubleLE=t.bind(null,FO,0,4),r.readDoubleBE=t.bind(null,VO,4,0)}(),r}function MO(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function UO(r,e,t){e[t]=r>>>24,e[t+1]=r>>>16&255,e[t+2]=r>>>8&255,e[t+3]=r&255}function FO(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0}function VO(r,e){return(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}});var K3=R((exports,module)=>{"use strict";u();module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var Zv=R(qO=>{"use strict";u();var Xv=qO;Xv.length=function(e){for(var t=0,n=0,i=0;i<e.length;++i)n=e.charCodeAt(i),n<128?t+=1:n<2048?t+=2:(n&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320?(++i,t+=4):t+=3;return t};Xv.read=function(e,t,n){var i=n-t;if(i<1)return"";for(var s=null,o=[],a=0,c;t<n;)c=e[t++],c<128?o[a++]=c:c>191&&c<224?o[a++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,o[a++]=55296+(c>>10),o[a++]=56320+(c&1023)):o[a++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0);return s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};Xv.write=function(e,t,n){for(var i=n,s,o,a=0;a<e.length;++a)s=e.charCodeAt(a),s<128?t[n++]=s:s<2048?(t[n++]=s>>6|192,t[n++]=s&63|128):(s&64512)===55296&&((o=e.charCodeAt(a+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++a,t[n++]=s>>18|240,t[n++]=s>>12&63|128,t[n++]=s>>6&63|128,t[n++]=s&63|128):(t[n++]=s>>12|224,t[n++]=s>>6&63|128,t[n++]=s&63|128);return n-i}});var Jv=R((SAe,zO)=>{"use strict";u();zO.exports=kfe;function kfe(r,e,t){var n=t||8192,i=n>>>1,s=null,o=n;return function(c){if(c<1||c>i)return r(c);o+c>n&&(s=r(n),o=0);var l=e.call(s,o,o+=c);return o&7&&(o=(o|7)+1),l}}});var HO=R((xAe,$O)=>{"use strict";u();$O.exports=xn;var k1=sa();function xn(r,e){this.lo=r>>>0,this.hi=e>>>0}var Rf=xn.zero=new xn(0,0);Rf.toNumber=function(){return 0};Rf.zzEncode=Rf.zzDecode=function(){return this};Rf.length=function(){return 1};var Nfe=xn.zeroHash="\0\0\0\0\0\0\0\0";xn.fromNumber=function(e){if(e===0)return Rf;var t=e<0;t&&(e=-e);var n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new xn(n,i)};xn.from=function(e){if(typeof e=="number")return xn.fromNumber(e);if(k1.isString(e))if(k1.Long)e=k1.Long.fromString(e);else return xn.fromNumber(parseInt(e,10));return e.low||e.high?new xn(e.low>>>0,e.high>>>0):Rf};xn.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=~this.lo+1>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296};xn.prototype.toLong=function(e){return k1.Long?new k1.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var kl=String.prototype.charCodeAt;xn.fromHash=function(e){return e===Nfe?Rf:new xn((kl.call(e,0)|kl.call(e,1)<<8|kl.call(e,2)<<16|kl.call(e,3)<<24)>>>0,(kl.call(e,4)|kl.call(e,5)<<8|kl.call(e,6)<<16|kl.call(e,7)<<24)>>>0)};xn.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};xn.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};xn.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};xn.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}});var sa=R(e_=>{"use strict";u();var ke=e_;ke.asPromise=U3();ke.base64=Wv();ke.EventEmitter=Yv();ke.float=Qv();ke.inquire=K3();ke.utf8=Zv();ke.pool=Jv();ke.LongBits=HO();ke.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);ke.global=ke.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||e_;ke.emptyArray=Object.freeze?Object.freeze([]):[];ke.emptyObject=Object.freeze?Object.freeze({}):{};ke.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};ke.isString=function(e){return typeof e=="string"||e instanceof String};ke.isObject=function(e){return e&&typeof e=="object"};ke.isset=ke.isSet=function(e,t){var n=e[t];return n!=null&&e.hasOwnProperty(t)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};ke.Buffer=function(){try{var r=ke.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();ke._Buffer_from=null;ke._Buffer_allocUnsafe=null;ke.newBuffer=function(e){return typeof e=="number"?ke.Buffer?ke._Buffer_allocUnsafe(e):new ke.Array(e):ke.Buffer?ke._Buffer_from(e):typeof Uint8Array>"u"?e:new Uint8Array(e)};ke.Array=typeof Uint8Array<"u"?Uint8Array:Array;ke.Long=ke.global.dcodeIO&&ke.global.dcodeIO.Long||ke.global.Long||ke.inquire("long");ke.key2Re=/^true|false|0|1$/;ke.key32Re=/^-?(?:0|[1-9][0-9]*)$/;ke.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;ke.longToHash=function(e){return e?ke.LongBits.from(e).toHash():ke.LongBits.zeroHash};ke.longFromHash=function(e,t){var n=ke.LongBits.fromHash(e);return ke.Long?ke.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))};function GO(r,e,t){for(var n=Object.keys(e),i=0;i<n.length;++i)(r[n[i]]===void 0||!t)&&(r[n[i]]=e[n[i]]);return r}ke.merge=GO;ke.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function jO(r){function e(t,n){if(!(this instanceof e))return new e(t,n);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&GO(this,n)}return e.prototype=Object.create(Error.prototype,{constructor:{value:e,writable:!0,enumerable:!1,configurable:!0},name:{get(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),e}ke.newError=jO;ke.ProtocolError=jO("ProtocolError");ke.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(t[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};ke.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}};ke.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};ke._configure=function(){var r=ke.Buffer;if(!r){ke._Buffer_from=ke._Buffer_allocUnsafe=null;return}ke._Buffer_from=r.from!==Uint8Array.from&&r.from||function(t,n){return new r(t,n)},ke._Buffer_allocUnsafe=r.allocUnsafe||function(t){return new r(t)}}});var z3=R((IAe,XO)=>{"use strict";u();XO.exports=Ot;var Ss=sa(),t_,q3=Ss.LongBits,WO=Ss.base64,YO=Ss.utf8;function N1(r,e,t){this.fn=r,this.len=e,this.next=void 0,this.val=t}function n_(){}function Lfe(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function Ot(){this.len=0,this.head=new N1(n_,0,0),this.tail=this.head,this.states=null}var QO=function(){return Ss.Buffer?function(){return(Ot.create=function(){return new t_})()}:function(){return new Ot}};Ot.create=QO();Ot.alloc=function(e){return new Ss.Array(e)};Ss.Array!==Array&&(Ot.alloc=Ss.pool(Ot.alloc,Ss.Array.prototype.subarray));Ot.prototype._push=function(e,t,n){return this.tail=this.tail.next=new N1(e,t,n),this.len+=t,this};function i_(r,e,t){e[t]=r&255}function Bfe(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}function s_(r,e){this.len=r,this.next=void 0,this.val=e}s_.prototype=Object.create(N1.prototype);s_.prototype.fn=Bfe;Ot.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new s_((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};Ot.prototype.int32=function(e){return e<0?this._push(o_,10,q3.fromNumber(e)):this.uint32(e)};Ot.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function o_(r,e,t){for(;r.hi;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}Ot.prototype.uint64=function(e){var t=q3.from(e);return this._push(o_,t.length(),t)};Ot.prototype.int64=Ot.prototype.uint64;Ot.prototype.sint64=function(e){var t=q3.from(e).zzEncode();return this._push(o_,t.length(),t)};Ot.prototype.bool=function(e){return this._push(i_,1,e?1:0)};function r_(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}Ot.prototype.fixed32=function(e){return this._push(r_,4,e>>>0)};Ot.prototype.sfixed32=Ot.prototype.fixed32;Ot.prototype.fixed64=function(e){var t=q3.from(e);return this._push(r_,4,t.lo)._push(r_,4,t.hi)};Ot.prototype.sfixed64=Ot.prototype.fixed64;Ot.prototype.float=function(e){return this._push(Ss.float.writeFloatLE,4,e)};Ot.prototype.double=function(e){return this._push(Ss.float.writeDoubleLE,8,e)};var Mfe=Ss.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var i=0;i<e.length;++i)t[n+i]=e[i]};Ot.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(i_,1,0);if(Ss.isString(e)){var n=Ot.alloc(t=WO.length(e));WO.decode(e,n,0),e=n}return this.uint32(t)._push(Mfe,t,e)};Ot.prototype.string=function(e){var t=YO.length(e);return t?this.uint32(t)._push(YO.write,t,e):this._push(i_,1,0)};Ot.prototype.fork=function(){return this.states=new Lfe(this),this.head=this.tail=new N1(n_,0,0),this.len=0,this};Ot.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 N1(n_,0,0),this.len=0),this};Ot.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this};Ot.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t};Ot._configure=function(r){t_=r,Ot.create=QO(),t_._configure()}});var ek=R((AAe,JO)=>{"use strict";u();JO.exports=oa;var ZO=z3();(oa.prototype=Object.create(ZO.prototype)).constructor=oa;var Nl=sa();function oa(){ZO.call(this)}oa._configure=function(){oa.alloc=Nl._Buffer_allocUnsafe,oa.writeBytesBuffer=Nl.Buffer&&Nl.Buffer.prototype instanceof Uint8Array&&Nl.Buffer.prototype.set.name==="set"?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var i=0;i<e.length;)t[n++]=e[i++]}};oa.prototype.bytes=function(e){Nl.isString(e)&&(e=Nl._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(oa.writeBytesBuffer,t,e),this};function Ufe(r,e,t){r.length<40?Nl.utf8.write(r,e,t):e.utf8Write?e.utf8Write(r,t):e.write(r,t)}oa.prototype.string=function(e){var t=Nl.Buffer.byteLength(e);return this.uint32(t),t&&this._push(Ufe,t,e),this};oa._configure()});var H3=R((RAe,sk)=>{"use strict";u();sk.exports=Hr;var aa=sa(),c_,nk=aa.LongBits,Ffe=aa.utf8;function so(r,e){return RangeError("index out of range: "+r.pos+" + "+(e||1)+" > "+r.len)}function Hr(r){this.buf=r,this.pos=0,this.len=r.length}var tk=typeof Uint8Array<"u"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new Hr(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new Hr(e);throw Error("illegal buffer")},ik=function(){return aa.Buffer?function(t){return(Hr.create=function(i){return aa.Buffer.isBuffer(i)?new c_(i):tk(i)})(t)}:tk};Hr.create=ik();Hr.prototype._slice=aa.Array.prototype.subarray||aa.Array.prototype.slice;Hr.prototype.uint32=function(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,so(this,10);return e}}();Hr.prototype.int32=function(){return this.uint32()|0};Hr.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function a_(){var r=new nk(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw so(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,r}if(this.len-this.pos>4){for(;e<5;++e)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;e<5;++e){if(this.pos>=this.len)throw so(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}Hr.prototype.bool=function(){return this.uint32()!==0};function $3(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}Hr.prototype.fixed32=function(){if(this.pos+4>this.len)throw so(this,4);return $3(this.buf,this.pos+=4)};Hr.prototype.sfixed32=function(){if(this.pos+4>this.len)throw so(this,4);return $3(this.buf,this.pos+=4)|0};function rk(){if(this.pos+8>this.len)throw so(this,8);return new nk($3(this.buf,this.pos+=4),$3(this.buf,this.pos+=4))}Hr.prototype.float=function(){if(this.pos+4>this.len)throw so(this,4);var e=aa.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};Hr.prototype.double=function(){if(this.pos+8>this.len)throw so(this,4);var e=aa.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};Hr.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw so(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)};Hr.prototype.string=function(){var e=this.bytes();return Ffe.read(e,0,e.length)};Hr.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw so(this,e);this.pos+=e}else do if(this.pos>=this.len)throw so(this);while(this.buf[this.pos++]&128);return this};Hr.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};Hr._configure=function(r){c_=r,Hr.create=ik(),c_._configure();var e=aa.Long?"toLong":"toNumber";aa.merge(Hr.prototype,{int64:function(){return a_.call(this)[e](!1)},uint64:function(){return a_.call(this)[e](!0)},sint64:function(){return a_.call(this).zzDecode()[e](!1)},fixed64:function(){return rk.call(this)[e](!0)},sfixed64:function(){return rk.call(this)[e](!1)}})}});var lk=R((CAe,ck)=>{"use strict";u();ck.exports=Cf;var ak=H3();(Cf.prototype=Object.create(ak.prototype)).constructor=Cf;var ok=sa();function Cf(r){ak.call(this,r)}Cf._configure=function(){ok.Buffer&&(Cf.prototype._slice=ok.Buffer.prototype.slice)};Cf.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))};Cf._configure()});var fk=R((PAe,uk)=>{"use strict";u();uk.exports=L1;var l_=sa();(L1.prototype=Object.create(l_.EventEmitter.prototype)).constructor=L1;function L1(r,e,t){if(typeof r!="function")throw TypeError("rpcImpl must be a function");l_.EventEmitter.call(this),this.rpcImpl=r,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(t)}L1.prototype.rpcCall=function r(e,t,n,i,s){if(!i)throw TypeError("request must be specified");var o=this;if(!s)return l_.asPromise(r,o,e,t,n,i);if(!o.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return o.rpcImpl(e,t[o.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(c,l){if(c)return o.emit("error",c,e),s(c);if(l===null){o.end(!0);return}if(!(l instanceof n))try{l=n[o.responseDelimited?"decodeDelimited":"decode"](l)}catch(f){return o.emit("error",f,e),s(f)}return o.emit("data",l,e),s(null,l)})}catch(a){o.emit("error",a,e),setTimeout(function(){s(a)},0);return}};L1.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var u_=R(hk=>{"use strict";u();var Vfe=hk;Vfe.Service=fk()});var f_=R((OAe,dk)=>{"use strict";u();dk.exports={}});var h_=R(mk=>{"use strict";u();var Ei=mk;Ei.build="minimal";Ei.Writer=z3();Ei.BufferWriter=ek();Ei.Reader=H3();Ei.BufferReader=lk();Ei.util=sa();Ei.rpc=u_();Ei.roots=f_();Ei.configure=pk;function pk(){Ei.util._configure(),Ei.Writer._configure(Ei.BufferWriter),Ei.Reader._configure(Ei.BufferReader)}pk()});var ca=R((NAe,yk)=>{"use strict";u();yk.exports=h_()});function wc(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.alloc!=null?globalThis.Buffer.alloc(r):new Uint8Array(r)}function ho(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var np=wv(()=>{u()});var oL=R((VCe,sL)=>{"use strict";u();sL.exports=function(){return Date.now()}});var Q1=R((KCe,aL)=>{"use strict";u();var d4=oL(),H_=class{constructor(e,t,n){let i=this;this._started=d4(),this._rescheduled=0,this._scheduled=t,this._args=n,this._triggered=!1,this._timerWrapper=()=>{i._rescheduled>0?(i._scheduled=i._rescheduled-(d4()-i._started),i._schedule(i._scheduled)):(i._triggered=!0,e.apply(null,i._args))},this._timer=setTimeout(this._timerWrapper,t)}reschedule(e){e||(e=this._scheduled);let t=d4();t+e-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(e)):this._triggered?this._schedule(e):(this._started=t,this._rescheduled=e)}_schedule(e){this._triggered=!1,this._started=d4(),this._rescheduled=0,this._scheduled=e,this._timer=setTimeout(this._timerWrapper,e)}clear(){clearTimeout(this._timer)}};function Qde(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("timeout needed");let r;if(arguments.length>0){r=new Array(arguments.length-2);for(var e=0;e<r.length;e++)r[e]=arguments[e+2]}return new H_(arguments[0],arguments[1],r)}aL.exports=Qde});var an=R((qCe,lL)=>{"use strict";u();var{AbortController:Xde}=globalThis,cL=Q1(),X1=class extends Xde{constructor(e){super(),this._ms=e,this._timer=cL(()=>this.abort(),e),Object.setPrototypeOf(this,X1.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=cL(()=>this.abort(),this._ms)}};lL.exports={TimeoutController:X1}});var bL=R((lPe,EL)=>{u();EL.exports=J_;var wL=128,ape=127,cpe=~ape,lpe=Math.pow(2,31);function J_(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw J_.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=lpe;)e[t++]=r&255|wL,r/=128;for(;r&cpe;)e[t++]=r&255|wL,r>>>=7;return e[t]=r|0,J_.bytes=t-n+1,e}});var SL=R((uPe,_L)=>{u();_L.exports=e9;var upe=128,vL=127;function e9(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a||i>49)throw e9.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&vL)<<i:(o&vL)*Math.pow(2,i),i+=7}while(o>=upe);return e9.bytes=s-n,t}});var TL=R((fPe,xL)=>{u();var fpe=Math.pow(2,7),hpe=Math.pow(2,14),dpe=Math.pow(2,21),ppe=Math.pow(2,28),mpe=Math.pow(2,35),ype=Math.pow(2,42),gpe=Math.pow(2,49),wpe=Math.pow(2,56),Epe=Math.pow(2,63);xL.exports=function(r){return r<fpe?1:r<hpe?2:r<dpe?3:r<ppe?4:r<mpe?5:r<ype?6:r<gpe?7:r<wpe?8:r<Epe?9:10}});var fa=R((hPe,IL)=>{u();IL.exports={encode:bL(),decode:SL(),encodingLength:TL()}});var AL={};Kt(AL,{concat:()=>Le});function Le(r,e){e||(e=r.reduce((i,s)=>i+s.length,0));let t=ho(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return t}var Mr=wv(()=>{u();np()});var d9=R((MPe,WL)=>{"use strict";u();var zpe=typeof navigator<"u"&&navigator.product==="ReactNative";function $pe(){return zpe?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var rm=self.URL,jL=$pe(),h9=class{constructor(e="",t=jL){this.super=new rm(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return rm.createObjectURL(e)}static revokeObjectURL(e){rm.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Hpe(r){if(typeof r=="string")return new rm(r).toString();if(!(r instanceof rm)){let e=r.username&&r.password?`${r.username}:${r.password}@`:"",t=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",i=r.protocol?r.protocol+"//":"",s=r.host||"",o=r.hostname||"",a=r.search||(r.query?"?"+r.query:""),c=r.hash||"",l=r.pathname||"",f=r.path||l+a;return`${i}${e||t}${s||o+n}${f}${c}`}}WL.exports={URLWithLegacySupport:h9,URLSearchParams:self.URLSearchParams,defaultBase:jL,format:Hpe}});var XL=R((UPe,QL)=>{"use strict";u();var{URLWithLegacySupport:YL,format:Gpe}=d9();QL.exports=(r,e={},t={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(t[i]||n||i)+":";let s;try{s=new YL(r)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new YL(r,Gpe(o)).toString()}});var x4=R((FPe,ZL)=>{"use strict";u();var{URLWithLegacySupport:jpe,format:Wpe,URLSearchParams:Ype,defaultBase:Qpe}=d9(),Xpe=XL();ZL.exports={URL:jpe,URLSearchParams:Ype,format:Wpe,relative:Xpe,defaultBase:Qpe}});var ai=R((JPe,p9)=>{u();function uB(r){let e=new globalThis.AbortController;function t(){e.abort();for(let n of r)!n||!n.removeEventListener||n.removeEventListener("abort",t)}for(let n of r)if(!(!n||!n.addEventListener)){if(n.aborted){t();break}n.addEventListener("abort",t)}return e.signal}p9.exports=uB;p9.exports.anySignal=uB});var op=R((EDe,EB)=>{u();EB.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function i(s,o){t[s]=o,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var o=t[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set:function(s,o){t[s]!==void 0?t[s]=o:i(s,o)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Hl=R((vDe,g9)=>{"use strict";u();var i0e=Object.prototype.hasOwnProperty,ci="~";function sm(){}Object.create&&(sm.prototype=Object.create(null),new sm().__proto__||(ci=!1));function s0e(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function vB(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new s0e(t,n||r,i),o=ci?ci+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],s]:r._events[o].push(s):(r._events[o]=s,r._eventsCount++),r}function N4(r,e){--r._eventsCount===0?r._events=new sm:delete r._events[e]}function Qn(){this._events=new sm,this._eventsCount=0}Qn.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)i0e.call(t,n)&&e.push(ci?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Qn.prototype.listeners=function(e){var t=ci?ci+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Qn.prototype.listenerCount=function(e){var t=ci?ci+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Qn.prototype.emit=function(e,t,n,i,s,o){var a=ci?ci+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,f,h;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,o),!0}for(h=1,f=new Array(l-1);h<l;h++)f[h-1]=arguments[h];c.fn.apply(c.context,f)}else{var p=c.length,d;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(e,c[h].fn,void 0,!0),l){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,t);break;case 3:c[h].fn.call(c[h].context,t,n);break;case 4:c[h].fn.call(c[h].context,t,n,i);break;default:if(!f)for(d=1,f=new Array(l-1);d<l;d++)f[d-1]=arguments[d];c[h].fn.apply(c[h].context,f)}}return!0};Qn.prototype.on=function(e,t,n){return vB(this,e,t,n,!1)};Qn.prototype.once=function(e,t,n){return vB(this,e,t,n,!0)};Qn.prototype.removeListener=function(e,t,n,i){var s=ci?ci+e:e;if(!this._events[s])return this;if(!t)return N4(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&N4(this,s);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:N4(this,s)}return this};Qn.prototype.removeAllListeners=function(e){var t;return e?(t=ci?ci+e:e,this._events[t]&&N4(this,t)):(this._events=new sm,this._eventsCount=0),this};Qn.prototype.off=Qn.prototype.removeListener;Qn.prototype.addListener=Qn.prototype.on;Qn.prefixed=ci;Qn.EventEmitter=Qn;typeof g9<"u"&&(g9.exports=Qn)});var A9=R(q4=>{"use strict";u();var x9=class extends Error{constructor(e="Request timed out"){super(e),this.name="TimeoutError"}};q4.TimeoutError=x9;var T9=class extends Error{constructor(e="The operation was aborted."){super(e),this.name="AbortError"}};q4.AbortError=T9;var I9=class extends Error{constructor(e){super(e.statusText),this.name="HTTPError",this.response=e}};q4.HTTPError=I9});var dm=R((ap,DB)=>{"use strict";u();var a0e=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof xc<"u")return xc;throw new Error("unable to locate global object")},xc=a0e();DB.exports=ap=xc.fetch;xc.fetch&&(ap.default=xc.fetch.bind(xc));ap.Headers=xc.Headers;ap.Request=xc.Request;ap.Response=xc.Response});var OB=R((PDe,R9)=>{"use strict";u();globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?R9.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:R9.exports={default:dm().default,Headers:dm().Headers,Request:dm().Request,Response:dm().Response}});var NB=R((DDe,kB)=>{"use strict";u();kB.exports=OB()});var MB=R((ODe,BB)=>{"use strict";u();var{TimeoutError:c0e,AbortError:l0e}=A9(),{Response:LB,Request:u0e,Headers:P9,default:f0e}=NB(),h0e=(r,e={})=>{let t=new XMLHttpRequest;t.open(e.method||"GET",r.toString(),!0);let{timeout:n,headers:i}=e;if(n&&n>0&&n<1/0&&(t.timeout=n),e.overrideMimeType!=null&&t.overrideMimeType(e.overrideMimeType),i)for(let[s,o]of new P9(i))t.setRequestHeader(s,o);return e.signal&&(e.signal.onabort=()=>t.abort()),e.onUploadProgress&&(t.upload.onprogress=e.onUploadProgress),t.responseType="arraybuffer",new Promise((s,o)=>{let a=c=>{switch(c.type){case"error":{s(LB.error());break}case"load":{s(new C9(t.responseURL,t.response,{status:t.status,statusText:t.statusText,headers:m0e(t.getAllResponseHeaders())}));break}case"timeout":{o(new c0e);break}case"abort":{o(new l0e);break}default:break}};t.onerror=a,t.onload=a,t.ontimeout=a,t.onabort=a,t.send(e.body)})},d0e=f0e,p0e=(r,e={})=>e.onUploadProgress!=null?h0e(r,e):d0e(r,e),m0e=r=>{let e=new P9;for(let t of r.trim().split(/[\r\n]+/)){let n=t.indexOf(": ");n>0&&e.set(t.slice(0,n),t.slice(n+1))}return e},C9=class extends LB{constructor(e,t,n){super(t,n),Object.defineProperty(this,"url",{value:e})}};BB.exports={fetch:p0e,Request:u0e,Headers:P9}});var cp=R((kDe,zB)=>{"use strict";u();var{fetch:y0e,Request:g0e,Headers:w0e}=MB(),{TimeoutError:D9,HTTPError:KB}=A9(),UB=Ov().bind({ignoreUndefined:!0}),{URL:FB,URLSearchParams:VB}=x4(),E0e=ai(),b0e=(r,e,t)=>{if(e===void 0)return r;let n=Date.now(),i=()=>Date.now()-n>=e;return new Promise((s,o)=>{let a=setTimeout(()=>{i()&&(o(new D9),t.abort())},e),c=l=>h=>{if(clearTimeout(a),i()){o(new D9);return}l(h)};r.then(c(s),c(o))})},v0e={throwHttpErrors:!0,credentials:"same-origin"},Xn=class{constructor(e={}){this.opts=UB(v0e,e)}async fetch(e,t={}){let n=UB(this.opts,t),i=new w0e(n.headers);if(typeof e!="string"&&!(e instanceof FB||e instanceof g0e))throw new TypeError("`resource` must be a string, URL, or Request");let s=new FB(e.toString(),n.base),{searchParams:o,transformSearchParams:a,json:c}=n;o&&(typeof a=="function"?s.search=a(new VB(n.searchParams)):s.search=new VB(n.searchParams)),c&&(n.body=JSON.stringify(n.json),i.set("content-type","application/json"));let l=new AbortController,f=E0e([l.signal,n.signal]),h=await b0e(y0e(s.toString(),{...n,signal:f,timeout:void 0,headers:i}),n.timeout,l);if(!h.ok&&n.throwHttpErrors)throw n.handleError&&await n.handleError(h),new KB(h);return h.iterator=async function*(){yield*qB(h.body)},h.ndjson=async function*(){for await(let p of _0e(h.iterator()))t.transform?yield t.transform(p):yield p},h}post(e,t={}){return this.fetch(e,{...t,method:"POST"})}get(e,t={}){return this.fetch(e,{...t,method:"GET"})}put(e,t={}){return this.fetch(e,{...t,method:"PUT"})}delete(e,t={}){return this.fetch(e,{...t,method:"DELETE"})}options(e,t={}){return this.fetch(e,{...t,method:"OPTIONS"})}},_0e=async function*(r){let e=new TextDecoder,t="";for await(let n of r){t+=e.decode(n,{stream:!0});let i=t.split(/\r?\n/);for(let s=0;s<i.length-1;s++){let o=i[s].trim();o.length>0&&(yield JSON.parse(o))}t=i[i.length-1]}t+=e.decode(),t=t.trim(),t.length!==0&&(yield JSON.parse(t))},qB=r=>{if(T0e(r)){let e=r[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return{next:e.next.bind(e),return(t){return r.destroy(),typeof e.return=="function"?e.return():Promise.resolve({done:!0,value:t})}}}}}if(x0e(r)){let e=r.getReader();return async function*(){try{for(;;){let{done:t,value:n}=await e.read();if(t)return;n&&(yield n)}}finally{e.releaseLock()}}()}if(S0e(r))return r;throw new TypeError("Body can't be converted to AsyncIterable")},S0e=r=>typeof r=="object"&&r!==null&&typeof r[Symbol.asyncIterator]=="function",x0e=r=>r&&typeof r.getReader=="function",T0e=r=>Object.prototype.hasOwnProperty.call(r,"readable")&&Object.prototype.hasOwnProperty.call(r,"writable");Xn.HTTPError=KB;Xn.TimeoutError=D9;Xn.streamToAsyncIterator=qB;Xn.post=(r,e)=>new Xn(e).post(r,e);Xn.get=(r,e)=>new Xn(e).get(r,e);Xn.put=(r,e)=>new Xn(e).put(r,e);Xn.delete=(r,e)=>new Xn(e).delete(r,e);Xn.options=(r,e)=>new Xn(e).options(r,e);zB.exports=Xn});var vi=R((tOe,JB)=>{"use strict";u();var O0e=async r=>{let e;for await(let t of r)e=t;return e};JB.exports=O0e});var aM=R((POe,M9)=>{u();var COe=function(){typeof M9<"u"&&(M9.exports=w);var r=24*3600,e=3200,t=(365*400+97)*e/400,n=r*t,i=n*1e3,s=1e3*1e4*1e4*r,o=16777216,a=65536*65536,c=1e3*1e3,l=1e3*1e3*1e3,f="000000000",h=Math.trunc||qe,p=w.prototype;w.fromDate=B,w.fromInt64BE=Oe(0,1,2,3,0,4),w.fromInt64LE=Oe(3,2,1,0,4,0),w.fromString=P,w.fromTimeT=q,p.year=0,p.time=0,p.nano=0,p.addNano=T,p.getNano=x,p.getTimeT=re,p.getYear=b,p.toDate=_,p.toJSON=ie,p.toString=Ce,p.writeInt64BE=Ee(0,1,2,3,0,4),p.writeInt64LE=Ee(3,2,1,0,4,0);var d="%Y-%m-%dT%H:%M:%S.%NZ",m=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g={"%":"%",F:"%Y-%m-%d",n:`
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return w;function w(ee,de,le){var Pe=this;if(!(Pe instanceof w))return new w(ee,de,le);Pe.time=+ee||0,Pe.nano=+de||0,Pe.year=+le||0,S(Pe)}function b(){var ee=this.toDate().getUTCFullYear();return ee+this.year}function S(ee){var de=ee.year,le=ee.time,Pe=ee.nano,Me,Be;if(Pe<0||c<=Pe){var Ye=Math.floor(Pe/c);Pe-=Ye*c,le+=Ye,Me=1}var W=de%e;if(le<-s||s<le||W){Be=h(le/i),Be&&(de+=Be*e,le-=Be*i);var $=I(le);$.setUTCFullYear(W+$.getUTCFullYear()),de-=W,le=+$,Be=h(de/e);var Q=le+Be*i;Be&&-s<=Q&&Q<=s&&(de-=Be*e,le=Q),Me=1}return Me&&(ee.year=de,ee.time=le,ee.nano=Pe),ee}function _(){var ee=S(this);return I(ee.time)}function I(ee){var de=new Date(0);return de.setTime(ee),de}function T(ee){return this.nano+=+ee||0,this}function x(){var ee=S(this);return(ee.time%1e3*c+ +ee.nano+l)%l}function P(ee){var de,le=new w;ee+="";var Pe=ee.replace(/^\s*[+\-]?\d+/,function(Me){var Be=+Me,Ye=1970+(Be-1970)%400;return le.year=Be-Ye,Ye}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(Me,Be,Ye){return Be<0&&(Ye*=-1),de=(+Be*60+ +Ye)*6e4,""}).replace(/\.\d+$/,function(Me){return le.nano=+(Me+f).substr(1,9),""}).split(/\D+/);if(Pe.length>1?Pe[1]--:Pe[1]=0,le.time=de=Date.UTC.apply(Date,Pe)-(de||0),isNaN(de))throw new TypeError("Invalid Date");return S(le)}function B(ee){return new w(+ee)}function q(ee){return Y(ee,0)}function Y(ee,de){de|=0,de*=a,ee=+ee||0;var le=h(de/n)+h(ee/n),Pe=de%n+ee%n,Me=h(Pe/n);return Me&&(le+=Me,Pe-=Me*n),new w(Pe*1e3,0,le*e)}function re(){var ee=S(this),de=Math.floor(ee.time/1e3),le=ee.year;return le&&(de+=le*t*r/e),de}function ie(){return this.toString().replace(/0{1,6}Z$/,"Z")}function Ce(ee){var de=this,le=de.toDate(),Pe={H:Q,L:De,M:ae,N:it,S:ce,Y:Be,a:gi,b:wn,d:W,e:$,m:Ye};return Me(ee||d);function Me(Gn){return Gn.replace(/%./g,function(gv){var Ad=gv[1],UD=g[Ad],FD=Pe[Ad];return UD?Me(UD):FD?FD():gv})}function Be(){var Gn=de.getYear();return Gn>999999?"+"+Gn:Gn>9999?"+"+Ze(Gn,6):Gn>=0?Ze(Gn,4):Gn>=-999999?"-"+Ze(-Gn,6):Gn}function Ye(){return Ke(le.getUTCMonth()+1)}function W(){return Ke(le.getUTCDate())}function $(){return zt(le.getUTCDate())}function Q(){return Ke(le.getUTCHours())}function ae(){return Ke(le.getUTCMinutes())}function ce(){return Ke(le.getUTCSeconds())}function De(){return Ze(le.getUTCMilliseconds(),3)}function it(){return Ze(de.getNano(),9)}function gi(){return y[le.getUTCDay()]}function wn(){return m[le.getUTCMonth()]}}function Ee(ee,de,le,Pe,Me,Be){return Ye;function Ye($,Q){var ae=S(this);$||($=new Array(8)),H($,Q|=0);var ce=Math.floor(ae.time/1e3),De=ae.year*(t*r/e),it=h(De/a)+h(ce/a),gi=De%a+ce%a,wn=Math.floor(gi/a);return wn&&(it+=wn,gi-=wn*a),W($,Q+Me,it),W($,Q+Be,gi),$}function W($,Q,ae){$[Q+ee]=ae>>24&255,$[Q+de]=ae>>16&255,$[Q+le]=ae>>8&255,$[Q+Pe]=ae&255}}function Oe(ee,de,le,Pe,Me,Be){return Ye;function Ye($,Q){H($,Q|=0);var ae=W($,Q+Me),ce=W($,Q+Be);return Y(ce,ae)}function W($,Q){return $[Q+ee]*o+($[Q+de]<<16|$[Q+le]<<8|$[Q+Pe])}}function H(ee,de){var le=ee&&ee.length;if(le==null)throw new TypeError("Invalid Buffer");if(le<de+8)throw new RangeError("Out of range")}function qe(ee){var de=ee-ee%1;return de===0&&(ee<0||ee===0&&1/ee!==1/0)?-0:de}function zt(ee){return(ee>9?"":" ")+(ee|0)}function Ke(ee){return(ee>9?"":"0")+(ee|0)}function Ze(ee,de){return(f+(ee|0)).substr(-de)}}()});var lM=R((DOe,cM)=>{"use strict";u();cM.exports=U9;function U9(r,e){typeof r=="string"&&(e=r,r=void 0);var t=[];function n(s){if(typeof s!="string"){var o=i();if(U9.verbose&&console.log("codegen: "+o),o="return "+o,s){for(var a=Object.keys(s),c=new Array(a.length+1),l=new Array(a.length),f=0;f<a.length;)c[f]=a[f],l[f]=s[a[f++]];return c[f]=o,Function.apply(null,c).apply(null,l)}return Function(o)()}for(var h=new Array(arguments.length-1),p=0;p<h.length;)h[p]=arguments[++p];if(p=0,s=s.replace(/%([%dfijs])/g,function(m,y){var g=h[p++];switch(y){case"d":case"f":return String(Number(g));case"i":return String(Math.floor(g));case"j":return JSON.stringify(g);case"s":return String(g)}return"%"}),p!==h.length)throw Error("parameter count mismatch");return t.push(s),n}function i(s){return"function "+(s||e||"")+"("+(r&&r.join(",")||"")+`){
`+t.join(`
`)+`
}`}return n.toString=i,n}U9.verbose=!1});var fM=R((OOe,uM)=>{"use strict";u();uM.exports=ym;var N0e=U3(),L0e=K3(),F9=L0e("fs");function ym(r,e,t){return typeof e=="function"?(t=e,e={}):e||(e={}),t?!e.xhr&&F9&&F9.readFile?F9.readFile(r,function(i,s){return i&&typeof XMLHttpRequest<"u"?ym.xhr(r,e,t):i?t(i):t(null,e.binary?s:s.toString("utf8"))}):ym.xhr(r,e,t):N0e(ym,this,r,e)}ym.xhr=function(e,t,n){var i=new XMLHttpRequest;i.onreadystatechange=function(){if(i.readyState===4){if(i.status!==0&&i.status!==200)return n(Error("status "+i.status));if(t.binary){var o=i.response;if(!o){o=[];for(var a=0;a<i.responseText.length;++a)o.push(i.responseText.charCodeAt(a)&255)}return n(null,typeof Uint8Array<"u"?new Uint8Array(o):o)}return n(null,i.responseText)}},t.binary&&("overrideMimeType"in i&&i.overrideMimeType("text/plain; charset=x-user-defined"),i.responseType="arraybuffer"),i.open("GET",e),i.send()}});var pM=R(dM=>{"use strict";u();var K9=dM,hM=K9.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},V9=K9.normalize=function(e){e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/");var t=e.split("/"),n=hM(e),i="";n&&(i=t.shift()+"/");for(var s=0;s<t.length;)t[s]===".."?s>0&&t[s-1]!==".."?t.splice(--s,2):n?t.splice(s,1):++s:t[s]==="."?t.splice(s,1):++s;return i+t.join("/")};K9.resolve=function(e,t,n){return n||(t=V9(t)),hM(t)?t:(n||(e=V9(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?V9(e+"/"+t):t)}});var Vf=R(mM=>{"use strict";u();var gm=mM,B0e=Rn(),M0e=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function wm(r,e){var t=0,n={};for(e|=0;t<r.length;)n[M0e[t+e]]=r[t++];return n}gm.basic=wm([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]);gm.defaults=wm([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",B0e.emptyArray,null]);gm.long=wm([0,0,0,1,1],7);gm.mapKey=wm([0,0,0,5,5,0,0,0,1,1,0,2],2);gm.packed=wm([1,5,0,0,0,5,5,0,0,0,1,1,0])});var Wl=R((LOe,wM)=>{"use strict";u();wM.exports=Cs;var j4=Kf();((Cs.prototype=Object.create(j4.prototype)).constructor=Cs).className="Field";var yM=wo(),gM=Vf(),un=Rn(),q9,U0e=/^required|optional|repeated$/;Cs.fromJSON=function(e,t){return new Cs(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)};function Cs(r,e,t,n,i,s,o){if(un.isObject(n)?(o=i,s=n,n=i=void 0):un.isObject(i)&&(o=s,s=i,i=void 0),j4.call(this,r,s),!un.isInteger(e)||e<0)throw TypeError("id must be a non-negative integer");if(!un.isString(t))throw TypeError("type must be a string");if(n!==void 0&&!U0e.test(n=n.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(i!==void 0&&!un.isString(i))throw TypeError("extend must be a string");n==="proto3_optional"&&(n="optional"),this.rule=n&&n!=="optional"?n:void 0,this.type=t,this.id=e,this.extend=i||void 0,this.required=n==="required",this.optional=!this.required,this.repeated=n==="repeated",this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=un.Long?gM.long[t]!==void 0:!1,this.bytes=t==="bytes",this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=o}Object.defineProperty(Cs.prototype,"packed",{get:function(){return this._packed===null&&(this._packed=this.getOption("packed")!==!1),this._packed}});Cs.prototype.setOption=function(e,t,n){return e==="packed"&&(this._packed=null),j4.prototype.setOption.call(this,e,t,n)};Cs.prototype.toJSON=function(e){var t=e?Boolean(e.keepComments):!1;return un.toObject(["rule",this.rule!=="optional"&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])};Cs.prototype.resolve=function(){if(this.resolved)return this;if((this.typeDefault=gM.defaults[this.type])===void 0?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof q9?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&this.options.default!=null&&(this.typeDefault=this.options.default,this.resolvedType instanceof yM&&typeof this.typeDefault=="string"&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&((this.options.packed===!0||this.options.packed!==void 0&&this.resolvedType&&!(this.resolvedType instanceof yM))&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=un.Long.fromNumber(this.typeDefault,this.type.charAt(0)==="u"),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&typeof this.typeDefault=="string"){var e;un.base64.test(this.typeDefault)?un.base64.decode(this.typeDefault,e=un.newBuffer(un.base64.length(this.typeDefault)),0):un.utf8.write(this.typeDefault,e=un.newBuffer(un.utf8.length(this.typeDefault)),0),this.typeDefault=e}return this.map?this.defaultValue=un.emptyObject:this.repeated?this.defaultValue=un.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof q9&&(this.parent.ctor.prototype[this.name]=this.defaultValue),j4.prototype.resolve.call(this)};Cs.d=function(e,t,n,i){return typeof t=="function"?t=un.decorateType(t).name:t&&typeof t=="object"&&(t=un.decorateEnum(t).name),function(o,a){un.decorateType(o.constructor).add(new Cs(a,e,t,n,{default:i}))}};Cs._configure=function(e){q9=e}});var fp=R((BOe,vM)=>{"use strict";u();vM.exports=Ps;var Y4=Kf();((Ps.prototype=Object.create(Y4.prototype)).constructor=Ps).className="OneOf";var EM=Wl(),W4=Rn();function Ps(r,e,t,n){if(Array.isArray(e)||(t=e,e=void 0),Y4.call(this,r,t),!(e===void 0||Array.isArray(e)))throw TypeError("fieldNames must be an Array");this.oneof=e||[],this.fieldsArray=[],this.comment=n}Ps.fromJSON=function(e,t){return new Ps(e,t.oneof,t.options,t.comment)};Ps.prototype.toJSON=function(e){var t=e?Boolean(e.keepComments):!1;return W4.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])};function bM(r){if(r.parent)for(var e=0;e<r.fieldsArray.length;++e)r.fieldsArray[e].parent||r.parent.add(r.fieldsArray[e])}Ps.prototype.add=function(e){if(!(e instanceof EM))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,bM(this),this};Ps.prototype.remove=function(e){if(!(e instanceof EM))throw TypeError("field must be a Field");var t=this.fieldsArray.indexOf(e);if(t<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(t,1),t=this.oneof.indexOf(e.name),t>-1&&this.oneof.splice(t,1),e.partOf=null,this};Ps.prototype.onAdd=function(e){Y4.prototype.onAdd.call(this,e);for(var t=this,n=0;n<this.oneof.length;++n){var i=e.get(this.oneof[n]);i&&!i.partOf&&(i.partOf=t,t.fieldsArray.push(i))}bM(this)};Ps.prototype.onRemove=function(e){for(var t=0,n;t<this.fieldsArray.length;++t)(n=this.fieldsArray[t]).parent&&n.parent.remove(n);Y4.prototype.onRemove.call(this,e)};Ps.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(i,s){W4.decorateType(i.constructor).add(new Ps(s,e)),Object.defineProperty(i,s,{get:W4.oneOfGetter(e),set:W4.oneOfSetter(e)})}}});var pp=R((MOe,TM)=>{"use strict";u();TM.exports=Bt;var z9=Kf();((Bt.prototype=Object.create(z9.prototype)).constructor=Bt).className="Namespace";var _M=Wl(),Q4=Rn(),F0e=fp(),hp,Em,dp;Bt.fromJSON=function(e,t){return new Bt(e,t.options).addJSON(t.nested)};function SM(r,e){if(!!(r&&r.length)){for(var t={},n=0;n<r.length;++n)t[r[n].name]=r[n].toJSON(e);return t}}Bt.arrayToJSON=SM;Bt.isReservedId=function(e,t){if(e){for(var n=0;n<e.length;++n)if(typeof e[n]!="string"&&e[n][0]<=t&&e[n][1]>t)return!0}return!1};Bt.isReservedName=function(e,t){if(e){for(var n=0;n<e.length;++n)if(e[n]===t)return!0}return!1};function Bt(r,e){z9.call(this,r,e),this.nested=void 0,this._nestedArray=null}function xM(r){return r._nestedArray=null,r}Object.defineProperty(Bt.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=Q4.toArray(this.nested))}});Bt.prototype.toJSON=function(e){return Q4.toObject(["options",this.options,"nested",SM(this.nestedArray,e)])};Bt.prototype.addJSON=function(e){var t=this;if(e)for(var n=Object.keys(e),i=0,s;i<n.length;++i)s=e[n[i]],t.add((s.fields!==void 0?hp.fromJSON:s.values!==void 0?dp.fromJSON:s.methods!==void 0?Em.fromJSON:s.id!==void 0?_M.fromJSON:Bt.fromJSON)(n[i],s));return this};Bt.prototype.get=function(e){return this.nested&&this.nested[e]||null};Bt.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof dp)return this.nested[e].values;throw Error("no such enum: "+e)};Bt.prototype.add=function(e){if(!(e instanceof _M&&e.extend!==void 0||e instanceof hp||e instanceof F0e||e instanceof dp||e instanceof Em||e instanceof Bt))throw TypeError("object must be a valid nested object");if(!this.nested)this.nested={};else{var t=this.get(e.name);if(t)if(t instanceof Bt&&e instanceof Bt&&!(t instanceof hp||t instanceof Em)){for(var n=t.nestedArray,i=0;i<n.length;++i)e.add(n[i]);this.remove(t),this.nested||(this.nested={}),e.setOptions(t.options,!0)}else throw Error("duplicate name '"+e.name+"' in "+this)}return this.nested[e.name]=e,e.onAdd(this),xM(this)};Bt.prototype.remove=function(e){if(!(e instanceof z9))throw TypeError("object must be a ReflectionObject");if(e.parent!==this)throw Error(e+" is not a member of "+this);return delete this.nested[e.name],Object.keys(this.nested).length||(this.nested=void 0),e.onRemove(this),xM(this)};Bt.prototype.define=function(e,t){if(Q4.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&e[0]==="")throw Error("path must be relative");for(var n=this;e.length>0;){var i=e.shift();if(n.nested&&n.nested[i]){if(n=n.nested[i],!(n instanceof Bt))throw Error("path conflicts with non-namespace objects")}else n.add(n=new Bt(i))}return t&&n.addJSON(t),n};Bt.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t<e.length;)e[t]instanceof Bt?e[t++].resolveAll():e[t++].resolve();return this.resolve()};Bt.prototype.lookup=function(e,t,n){if(typeof t=="boolean"?(n=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),Q4.isString(e)&&e.length){if(e===".")return this.root;e=e.split(".")}else if(!e.length)return this;if(e[0]==="")return this.root.lookup(e.slice(1),t);var i=this.get(e[0]);if(i){if(e.length===1){if(!t||t.indexOf(i.constructor)>-1)return i}else if(i instanceof Bt&&(i=i.lookup(e.slice(1),t,!0)))return i}else for(var s=0;s<this.nestedArray.length;++s)if(this._nestedArray[s]instanceof Bt&&(i=this._nestedArray[s].lookup(e,t,!0)))return i;return this.parent===null||n?null:this.parent.lookup(e,t)};Bt.prototype.lookupType=function(e){var t=this.lookup(e,[hp]);if(!t)throw Error("no such type: "+e);return t};Bt.prototype.lookupEnum=function(e){var t=this.lookup(e,[dp]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t};Bt.prototype.lookupTypeOrEnum=function(e){var t=this.lookup(e,[hp,dp]);if(!t)throw Error("no such Type or Enum '"+e+"' in "+this);return t};Bt.prototype.lookupService=function(e){var t=this.lookup(e,[Em]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t};Bt._configure=function(r,e,t){hp=r,Em=e,dp=t}});var X4=R((UOe,IM)=>{"use strict";u();IM.exports=Tc;var $9=Wl();((Tc.prototype=Object.create($9.prototype)).constructor=Tc).className="MapField";var V0e=Vf(),bm=Rn();function Tc(r,e,t,n,i,s){if($9.call(this,r,e,n,void 0,void 0,i,s),!bm.isString(t))throw TypeError("keyType must be a string");this.keyType=t,this.resolvedKeyType=null,this.map=!0}Tc.fromJSON=function(e,t){return new Tc(e,t.id,t.keyType,t.type,t.options,t.comment)};Tc.prototype.toJSON=function(e){var t=e?Boolean(e.keepComments):!1;return bm.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])};Tc.prototype.resolve=function(){if(this.resolved)return this;if(V0e.mapKey[this.keyType]===void 0)throw Error("invalid key type: "+this.keyType);return $9.prototype.resolve.call(this)};Tc.d=function(e,t,n){return typeof n=="function"?n=bm.decorateType(n).name:n&&typeof n=="object"&&(n=bm.decorateEnum(n).name),function(s,o){bm.decorateType(s.constructor).add(new Tc(o,e,t,n))}}});var Z4=R((FOe,AM)=>{"use strict";u();AM.exports=qf;var H9=Kf();((qf.prototype=Object.create(H9.prototype)).constructor=qf).className="Method";var mp=Rn();function qf(r,e,t,n,i,s,o,a,c){if(mp.isObject(i)?(o=i,i=s=void 0):mp.isObject(s)&&(o=s,s=void 0),!(e===void 0||mp.isString(e)))throw TypeError("type must be a string");if(!mp.isString(t))throw TypeError("requestType must be a string");if(!mp.isString(n))throw TypeError("responseType must be a string");H9.call(this,r,o),this.type=e||"rpc",this.requestType=t,this.requestStream=i?!0:void 0,this.responseType=n,this.responseStream=s?!0:void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=a,this.parsedOptions=c}qf.fromJSON=function(e,t){return new qf(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)};qf.prototype.toJSON=function(e){var t=e?Boolean(e.keepComments):!1;return mp.toObject(["type",this.type!=="rpc"&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",t?this.comment:void 0,"parsedOptions",this.parsedOptions])};qf.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),H9.prototype.resolve.call(this))}});var J4=R((VOe,CM)=>{"use strict";u();CM.exports=Ds;var Yl=pp();((Ds.prototype=Object.create(Yl.prototype)).constructor=Ds).className="Service";var G9=Z4(),vm=Rn(),K0e=u_();function Ds(r,e){Yl.call(this,r,e),this.methods={},this._methodsArray=null}Ds.fromJSON=function(e,t){var n=new Ds(e,t.options);if(t.methods)for(var i=Object.keys(t.methods),s=0;s<i.length;++s)n.add(G9.fromJSON(i[s],t.methods[i[s]]));return t.nested&&n.addJSON(t.nested),n.comment=t.comment,n};Ds.prototype.toJSON=function(e){var t=Yl.prototype.toJSON.call(this,e),n=e?Boolean(e.keepComments):!1;return vm.toObject(["options",t&&t.options||void 0,"methods",Yl.arrayToJSON(this.methodsArray,e)||{},"nested",t&&t.nested||void 0,"comment",n?this.comment:void 0])};Object.defineProperty(Ds.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=vm.toArray(this.methods))}});function RM(r){return r._methodsArray=null,r}Ds.prototype.get=function(e){return this.methods[e]||Yl.prototype.get.call(this,e)};Ds.prototype.resolveAll=function(){for(var e=this.methodsArray,t=0;t<e.length;++t)e[t].resolve();return Yl.prototype.resolve.call(this)};Ds.prototype.add=function(e){if(this.get(e.name))throw Error("duplicate name '"+e.name+"' in "+this);return e instanceof G9?(this.methods[e.name]=e,e.parent=this,RM(this)):Yl.prototype.add.call(this,e)};Ds.prototype.remove=function(e){if(e instanceof G9){if(this.methods[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.methods[e.name],e.parent=null,RM(this)}return Yl.prototype.remove.call(this,e)};Ds.prototype.create=function(e,t,n){for(var i=new K0e.Service(e,t,n),s=0,o;s<this.methodsArray.length;++s){var a=vm.lcFirst((o=this._methodsArray[s]).resolve().name).replace(/[^$\w_]/g,"");i[a]=vm.codegen(["r","c"],vm.isReserved(a)?a+"_":a)("return this.rpcCall(m,q,s,r,c)")({m:o,q:o.resolvedRequestType.ctor,s:o.resolvedResponseType.ctor})}return i}});var ew=R((KOe,PM)=>{"use strict";u();PM.exports=ma;var q0e=sa();function ma(r){if(r)for(var e=Object.keys(r),t=0;t<e.length;++t)this[e[t]]=r[e[t]]}ma.create=function(e){return this.$type.create(e)};ma.encode=function(e,t){return this.$type.encode(e,t)};ma.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)};ma.decode=function(e){return this.$type.decode(e)};ma.decodeDelimited=function(e){return this.$type.decodeDelimited(e)};ma.verify=function(e){return this.$type.verify(e)};ma.fromObject=function(e){return this.$type.fromObject(e)};ma.toObject=function(e,t){return this.$type.toObject(e,t)};ma.prototype.toJSON=function(){return this.$type.toObject(this,q0e.toJSONOptions)}});var j9=R((qOe,OM)=>{"use strict";u();OM.exports=H0e;var z0e=wo(),Ic=Vf(),DM=Rn();function $0e(r){return"missing required '"+r.name+"'"}function H0e(r){var e=DM.codegen(["r","l"],r.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(r.fieldsArray.filter(function(a){return a.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");r.group&&e("if((t&7)===4)")("break"),e("switch(t>>>3){");for(var t=0;t<r.fieldsArray.length;++t){var n=r._fieldsArray[t].resolve(),i=n.resolvedType instanceof z0e?"int32":n.type,s="m"+DM.safeProp(n.name);e("case %i: {",n.id),n.map?(e("if(%s===util.emptyObject)",s)("%s={}",s)("var c2 = r.uint32()+r.pos"),Ic.defaults[n.keyType]!==void 0?e("k=%j",Ic.defaults[n.keyType]):e("k=null"),Ic.defaults[i]!==void 0?e("value=%j",Ic.defaults[i]):e("value=null"),e("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",n.keyType)("case 2:"),Ic.basic[i]===void 0?e("value=types[%i].decode(r,r.uint32())",t):e("value=r.%s()",i),e("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),Ic.long[n.keyType]!==void 0?e('%s[typeof k==="object"?util.longToHash(k):k]=value',s):e("%s[k]=value",s)):n.repeated?(e("if(!(%s&&%s.length))",s,s)("%s=[]",s),Ic.packed[i]!==void 0&&e("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",s,i)("}else"),Ic.basic[i]===void 0?e(n.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",s,t):e("%s.push(r.%s())",s,i)):Ic.basic[i]===void 0?e(n.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",s,t):e("%s=r.%s()",s,i),e("break")("}")}for(e("default:")("r.skipType(t&7)")("break")("}")("}"),t=0;t<r._fieldsArray.length;++t){var o=r._fieldsArray[t];o.required&&e("if(!m.hasOwnProperty(%j))",o.name)("throw util.ProtocolError(%j,{instance:m})",$0e(o))}return e("return m")}});var Q9=R((zOe,kM)=>{"use strict";u();kM.exports=W0e;var G0e=wo(),W9=Rn();function Os(r,e){return r.name+": "+e+(r.repeated&&e!=="array"?"[]":r.map&&e!=="object"?"{k:"+r.keyType+"}":"")+" expected"}function Y9(r,e,t,n){if(e.resolvedType)if(e.resolvedType instanceof G0e){r("switch(%s){",n)("default:")("return%j",Os(e,"enum value"));for(var i=Object.keys(e.resolvedType.values),s=0;s<i.length;++s)r("case %i:",e.resolvedType.values[i[s]]);r("break")("}")}else r("{")("var e=types[%i].verify(%s);",t,n)("if(e)")("return%j+e",e.name+".")("}");else switch(e.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":r("if(!util.isInteger(%s))",n)("return%j",Os(e,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":r("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",n,n,n,n)("return%j",Os(e,"integer|Long"));break;case"float":case"double":r('if(typeof %s!=="number")',n)("return%j",Os(e,"number"));break;case"bool":r('if(typeof %s!=="boolean")',n)("return%j",Os(e,"boolean"));break;case"string":r("if(!util.isString(%s))",n)("return%j",Os(e,"string"));break;case"bytes":r('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',n,n,n)("return%j",Os(e,"buffer"));break}return r}function j0e(r,e,t){switch(e.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":r("if(!util.key32Re.test(%s))",t)("return%j",Os(e,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":r("if(!util.key64Re.test(%s))",t)("return%j",Os(e,"integer|Long key"));break;case"bool":r("if(!util.key2Re.test(%s))",t)("return%j",Os(e,"boolean key"));break}return r}function W0e(r){var e=W9.codegen(["m"],r.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),t=r.oneofsArray,n={};t.length&&e("var p={}");for(var i=0;i<r.fieldsArray.length;++i){var s=r._fieldsArray[i].resolve(),o="m"+W9.safeProp(s.name);if(s.optional&&e("if(%s!=null&&m.hasOwnProperty(%j)){",o,s.name),s.map)e("if(!util.isObject(%s))",o)("return%j",Os(s,"object"))("var k=Object.keys(%s)",o)("for(var i=0;i<k.length;++i){"),j0e(e,s,"k[i]"),Y9(e,s,i,o+"[k[i]]")("}");else if(s.repeated)e("if(!Array.isArray(%s))",o)("return%j",Os(s,"array"))("for(var i=0;i<%s.length;++i){",o),Y9(e,s,i,o+"[i]")("}");else{if(s.partOf){var a=W9.safeProp(s.partOf.name);n[s.partOf.name]===1&&e("if(p%s===1)",a)("return%j",s.partOf.name+": multiple values"),n[s.partOf.name]=1,e("p%s=1",a)}Y9(e,s,i,o)}s.optional&&e("}")}return e("return null")}});var J9=R(LM=>{"use strict";u();var NM=LM,_m=wo(),ya=Rn();function X9(r,e,t,n){var i=!1;if(e.resolvedType)if(e.resolvedType instanceof _m){r("switch(d%s){",n);for(var s=e.resolvedType.values,o=Object.keys(s),a=0;a<o.length;++a)s[o[a]]===e.typeDefault&&!i&&(r("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',n,n,n),e.repeated||r("break"),i=!0),r("case%j:",o[a])("case %i:",s[o[a]])("m%s=%j",n,s[o[a]])("break");r("}")}else r('if(typeof d%s!=="object")',n)("throw TypeError(%j)",e.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",n,t,n);else{var c=!1;switch(e.type){case"double":case"float":r("m%s=Number(d%s)",n,n);break;case"uint32":case"fixed32":r("m%s=d%s>>>0",n,n);break;case"int32":case"sint32":case"sfixed32":r("m%s=d%s|0",n,n);break;case"uint64":c=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":r("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",n,n,c)('else if(typeof d%s==="string")',n)("m%s=parseInt(d%s,10)",n,n)('else if(typeof d%s==="number")',n)("m%s=d%s",n,n)('else if(typeof d%s==="object")',n)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",n,n,n,c?"true":"");break;case"bytes":r('if(typeof d%s==="string")',n)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",n,n,n)("else if(d%s.length >= 0)",n)("m%s=d%s",n,n);break;case"string":r("m%s=String(d%s)",n,n);break;case"bool":r("m%s=Boolean(d%s)",n,n);break}}return r}NM.fromObject=function(e){var t=e.fieldsArray,n=ya.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return n("return new this.ctor");n("var m=new this.ctor");for(var i=0;i<t.length;++i){var s=t[i].resolve(),o=ya.safeProp(s.name);s.map?(n("if(d%s){",o)('if(typeof d%s!=="object")',o)("throw TypeError(%j)",s.fullName+": object expected")("m%s={}",o)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",o),X9(n,s,i,o+"[ks[i]]")("}")("}")):s.repeated?(n("if(d%s){",o)("if(!Array.isArray(d%s))",o)("throw TypeError(%j)",s.fullName+": array expected")("m%s=[]",o)("for(var i=0;i<d%s.length;++i){",o),X9(n,s,i,o+"[i]")("}")("}")):(s.resolvedType instanceof _m||n("if(d%s!=null){",o),X9(n,s,i,o),s.resolvedType instanceof _m||n("}"))}return n("return m")};function Z9(r,e,t,n){if(e.resolvedType)e.resolvedType instanceof _m?r("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",n,t,n,n,t,n,n):r("d%s=types[%i].toObject(m%s,o)",n,t,n);else{var i=!1;switch(e.type){case"double":case"float":r("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",n,n,n,n);break;case"uint64":i=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":r('if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",n,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",n,n,n,n,i?"true":"",n);break;case"bytes":r("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",n,n,n,n,n);break;default:r("d%s=m%s",n,n);break}}return r}NM.toObject=function(e){var t=e.fieldsArray.slice().sort(ya.compareFieldsById);if(!t.length)return ya.codegen()("return {}");for(var n=ya.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),i=[],s=[],o=[],a=0;a<t.length;++a)t[a].partOf||(t[a].resolve().repeated?i:t[a].map?s:o).push(t[a]);if(i.length){for(n("if(o.arrays||o.defaults){"),a=0;a<i.length;++a)n("d%s=[]",ya.safeProp(i[a].name));n("}")}if(s.length){for(n("if(o.objects||o.defaults){"),a=0;a<s.length;++a)n("d%s={}",ya.safeProp(s[a].name));n("}")}if(o.length){for(n("if(o.defaults){"),a=0;a<o.length;++a){var c=o[a],l=ya.safeProp(c.name);if(c.resolvedType instanceof _m)n("d%s=o.enums===String?%j:%j",l,c.resolvedType.valuesById[c.typeDefault],c.typeDefault);else if(c.long)n("if(util.Long){")("var n=new util.Long(%i,%i,%j)",c.typeDefault.low,c.typeDefault.high,c.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",l)("}else")("d%s=o.longs===String?%j:%i",l,c.typeDefault.toString(),c.typeDefault.toNumber());else if(c.bytes){var f="["+Array.prototype.slice.call(c.typeDefault).join(",")+"]";n("if(o.bytes===String)d%s=%j",l,String.fromCharCode.apply(String,c.typeDefault))("else{")("d%s=%s",l,f)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",l,l)("}")}else n("d%s=%j",l,c.typeDefault)}n("}")}var h=!1;for(a=0;a<t.length;++a){var c=t[a],p=e._fieldsArray.indexOf(c),l=ya.safeProp(c.name);c.map?(h||(h=!0,n("var ks2")),n("if(m%s&&(ks2=Object.keys(m%s)).length){",l,l)("d%s={}",l)("for(var j=0;j<ks2.length;++j){"),Z9(n,c,p,l+"[ks2[j]]")("}")):c.repeated?(n("if(m%s&&m%s.length){",l,l)("d%s=[]",l)("for(var j=0;j<m%s.length;++j){",l),Z9(n,c,p,l+"[j]")("}")):(n("if(m%s!=null&&m.hasOwnProperty(%j)){",l,c.name),Z9(n,c,p,l),c.partOf&&n("if(o.oneofs)")("d%s=%j",ya.safeProp(c.partOf.name),c.name)),n("}")}return n("return d")}});var eS=R(BM=>{"use strict";u();var Y0e=BM,Q0e=ew();Y0e[".google.protobuf.Any"]={fromObject:function(r){if(r&&r["@type"]){var e=r["@type"].substring(r["@type"].lastIndexOf("/")+1),t=this.lookup(e);if(t){var n=r["@type"].charAt(0)==="."?r["@type"].slice(1):r["@type"];return n.indexOf("/")===-1&&(n="/"+n),this.create({type_url:n,value:t.encode(t.fromObject(r)).finish()})}}return this.fromObject(r)},toObject:function(r,e){var t="type.googleapis.com/",n="",i="";if(e&&e.json&&r.type_url&&r.value){i=r.type_url.substring(r.type_url.lastIndexOf("/")+1),n=r.type_url.substring(0,r.type_url.lastIndexOf("/")+1);var s=this.lookup(i);s&&(r=s.decode(r.value))}if(!(r instanceof this.ctor)&&r instanceof Q0e){var o=r.$type.toObject(r,e),a=r.$type.fullName[0]==="."?r.$type.fullName.slice(1):r.$type.fullName;return n===""&&(n=t),i=n+a,o["@type"]=i,o}return this.toObject(r,e)}}});var nw=R((GOe,UM)=>{"use strict";u();UM.exports=ir;var Eo=pp();((ir.prototype=Object.create(Eo.prototype)).constructor=ir).className="Type";var X0e=wo(),nS=fp(),tw=Wl(),Z0e=X4(),J0e=J4(),tS=ew(),rS=H3(),e1e=z3(),Zn=Rn(),t1e=iS(),r1e=j9(),n1e=Q9(),MM=J9(),i1e=eS();function ir(r,e){Eo.call(this,r,e),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}Object.defineProperties(ir.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var r=Object.keys(this.fields),e=0;e<r.length;++e){var t=this.fields[r[e]],n=t.id;if(this._fieldsById[n])throw Error("duplicate id "+n+" in "+this);this._fieldsById[n]=t}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=Zn.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=Zn.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=ir.generateConstructor(this)())},set:function(r){var e=r.prototype;e instanceof tS||((r.prototype=new tS).constructor=r,Zn.merge(r.prototype,e)),r.$type=r.prototype.$type=this,Zn.merge(r,tS,!0),this._ctor=r;for(var t=0;t<this.fieldsArray.length;++t)this._fieldsArray[t].resolve();var n={};for(t=0;t<this.oneofsArray.length;++t)n[this._oneofsArray[t].resolve().name]={get:Zn.oneOfGetter(this._oneofsArray[t].oneof),set:Zn.oneOfSetter(this._oneofsArray[t].oneof)};t&&Object.defineProperties(r.prototype,n)}}});ir.generateConstructor=function(e){for(var t=Zn.codegen(["p"],e.name),n=0,i;n<e.fieldsArray.length;++n)(i=e._fieldsArray[n]).map?t("this%s={}",Zn.safeProp(i.name)):i.repeated&&t("this%s=[]",Zn.safeProp(i.name));return t("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")};function rw(r){return r._fieldsById=r._fieldsArray=r._oneofsArray=null,delete r.encode,delete r.decode,delete r.verify,r}ir.fromJSON=function(e,t){var n=new ir(e,t.options);n.extensions=t.extensions,n.reserved=t.reserved;for(var i=Object.keys(t.fields),s=0;s<i.length;++s)n.add((typeof t.fields[i[s]].keyType<"u"?Z0e.fromJSON:tw.fromJSON)(i[s],t.fields[i[s]]));if(t.oneofs)for(i=Object.keys(t.oneofs),s=0;s<i.length;++s)n.add(nS.fromJSON(i[s],t.oneofs[i[s]]));if(t.nested)for(i=Object.keys(t.nested),s=0;s<i.length;++s){var o=t.nested[i[s]];n.add((o.id!==void 0?tw.fromJSON:o.fields!==void 0?ir.fromJSON:o.values!==void 0?X0e.fromJSON:o.methods!==void 0?J0e.fromJSON:Eo.fromJSON)(i[s],o))}return t.extensions&&t.extensions.length&&(n.extensions=t.extensions),t.reserved&&t.reserved.length&&(n.reserved=t.reserved),t.group&&(n.group=!0),t.comment&&(n.comment=t.comment),n};ir.prototype.toJSON=function(e){var t=Eo.prototype.toJSON.call(this,e),n=e?Boolean(e.keepComments):!1;return Zn.toObject(["options",t&&t.options||void 0,"oneofs",Eo.arrayToJSON(this.oneofsArray,e),"fields",Eo.arrayToJSON(this.fieldsArray.filter(function(i){return!i.declaringField}),e)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",t&&t.nested||void 0,"comment",n?this.comment:void 0])};ir.prototype.resolveAll=function(){for(var e=this.fieldsArray,t=0;t<e.length;)e[t++].resolve();var n=this.oneofsArray;for(t=0;t<n.length;)n[t++].resolve();return Eo.prototype.resolveAll.call(this)};ir.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null};ir.prototype.add=function(e){if(this.get(e.name))throw Error("duplicate name '"+e.name+"' in "+this);if(e instanceof tw&&e.extend===void 0){if(this._fieldsById?this._fieldsById[e.id]:this.fieldsById[e.id])throw Error("duplicate id "+e.id+" in "+this);if(this.isReservedId(e.id))throw Error("id "+e.id+" is reserved in "+this);if(this.isReservedName(e.name))throw Error("name '"+e.name+"' is reserved in "+this);return e.parent&&e.parent.remove(e),this.fields[e.name]=e,e.message=this,e.onAdd(this),rw(this)}return e instanceof nS?(this.oneofs||(this.oneofs={}),this.oneofs[e.name]=e,e.onAdd(this),rw(this)):Eo.prototype.add.call(this,e)};ir.prototype.remove=function(e){if(e instanceof tw&&e.extend===void 0){if(!this.fields||this.fields[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.fields[e.name],e.parent=null,e.onRemove(this),rw(this)}if(e instanceof nS){if(!this.oneofs||this.oneofs[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.oneofs[e.name],e.parent=null,e.onRemove(this),rw(this)}return Eo.prototype.remove.call(this,e)};ir.prototype.isReservedId=function(e){return Eo.isReservedId(this.reserved,e)};ir.prototype.isReservedName=function(e){return Eo.isReservedName(this.reserved,e)};ir.prototype.create=function(e){return new this.ctor(e)};ir.prototype.setup=function(){for(var e=this.fullName,t=[],n=0;n<this.fieldsArray.length;++n)t.push(this._fieldsArray[n].resolve().resolvedType);this.encode=t1e(this)({Writer:e1e,types:t,util:Zn}),this.decode=r1e(this)({Reader:rS,types:t,util:Zn}),this.verify=n1e(this)({types:t,util:Zn}),this.fromObject=MM.fromObject(this)({types:t,util:Zn}),this.toObject=MM.toObject(this)({types:t,util:Zn});var i=i1e[e];if(i){var s=Object.create(this);s.fromObject=this.fromObject,this.fromObject=i.fromObject.bind(s),s.toObject=this.toObject,this.toObject=i.toObject.bind(s)}return this};ir.prototype.encode=function(e,t){return this.setup().encode(e,t)};ir.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()};ir.prototype.decode=function(e,t){return this.setup().decode(e,t)};ir.prototype.decodeDelimited=function(e){return e instanceof rS||(e=rS.create(e)),this.decode(e,e.uint32())};ir.prototype.verify=function(e){return this.setup().verify(e)};ir.prototype.fromObject=function(e){return this.setup().fromObject(e)};ir.prototype.toObject=function(e,t){return this.setup().toObject(e,t)};ir.d=function(e){return function(n){Zn.decorateType(n,e)}}});var ow=R((jOe,zM)=>{"use strict";u();zM.exports=zi;var sw=pp();((zi.prototype=Object.create(sw.prototype)).constructor=zi).className="Root";var oS=Wl(),VM=wo(),s1e=fp(),Ql=Rn(),KM,sS,Sm;function zi(r){sw.call(this,"",r),this.deferred=[],this.files=[]}zi.fromJSON=function(e,t){return t||(t=new zi),e.options&&t.setOptions(e.options),t.addJSON(e.nested)};zi.prototype.resolvePath=Ql.path.resolve;zi.prototype.fetch=Ql.fetch;function qM(){}zi.prototype.load=function r(e,t,n){typeof t=="function"&&(n=t,t=void 0);var i=this;if(!n)return Ql.asPromise(r,i,e,t);var s=n===qM;function o(d,m){if(!!n){var y=n;if(n=null,s)throw d;y(d,m)}}function a(d){var m=d.lastIndexOf("google/protobuf/");if(m>-1){var y=d.substring(m);if(y in Sm)return y}return null}function c(d,m){try{if(Ql.isString(m)&&m.charAt(0)==="{"&&(m=JSON.parse(m)),!Ql.isString(m))i.setOptions(m.options).addJSON(m.nested);else{sS.filename=d;var y=sS(m,i,t),g,w=0;if(y.imports)for(;w<y.imports.length;++w)(g=a(y.imports[w])||i.resolvePath(d,y.imports[w]))&&l(g);if(y.weakImports)for(w=0;w<y.weakImports.length;++w)(g=a(y.weakImports[w])||i.resolvePath(d,y.weakImports[w]))&&l(g,!0)}}catch(b){o(b)}!s&&!f&&o(null,i)}function l(d,m){if(!(i.files.indexOf(d)>-1)){if(i.files.push(d),d in Sm){s?c(d,Sm[d]):(++f,setTimeout(function(){--f,c(d,Sm[d])}));return}if(s){var y;try{y=Ql.fs.readFileSync(d).toString("utf8")}catch(g){m||o(g);return}c(d,y)}else++f,i.fetch(d,function(g,w){if(--f,!!n){if(g){m?f||o(null,i):o(g);return}c(d,w)}})}}var f=0;Ql.isString(e)&&(e=[e]);for(var h=0,p;h<e.length;++h)(p=i.resolvePath("",e[h]))&&l(p);if(s)return i;f||o(null,i)};zi.prototype.loadSync=function(e,t){if(!Ql.isNode)throw Error("not supported");return this.load(e,t,qM)};zi.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(e){return"'extend "+e.extend+"' in "+e.parent.fullName}).join(", "));return sw.prototype.resolveAll.call(this)};var iw=/^[A-Z]/;function FM(r,e){var t=e.parent.lookup(e.extend);if(t){var n=new oS(e.fullName,e.id,e.type,e.rule,void 0,e.options);return n.declaringField=e,e.extensionField=n,t.add(n),!0}return!1}zi.prototype._handleAdd=function(e){if(e instanceof oS)e.extend!==void 0&&!e.extensionField&&(FM(this,e)||this.deferred.push(e));else if(e instanceof VM)iw.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof s1e)){if(e instanceof KM)for(var t=0;t<this.deferred.length;)FM(this,this.deferred[t])?this.deferred.splice(t,1):++t;for(var n=0;n<e.nestedArray.length;++n)this._handleAdd(e._nestedArray[n]);iw.test(e.name)&&(e.parent[e.name]=e)}};zi.prototype._handleRemove=function(e){if(e instanceof oS){if(e.extend!==void 0)if(e.extensionField)e.extensionField.parent.remove(e.extensionField),e.extensionField=null;else{var t=this.deferred.indexOf(e);t>-1&&this.deferred.splice(t,1)}}else if(e instanceof VM)iw.test(e.name)&&delete e.parent[e.name];else if(e instanceof sw){for(var n=0;n<e.nestedArray.length;++n)this._handleRemove(e._nestedArray[n]);iw.test(e.name)&&delete e.parent[e.name]}};zi._configure=function(r,e,t){KM=r,sS=e,Sm=t}});var Rn=R((WOe,HM)=>{"use strict";u();var Wr=HM.exports=sa(),$M=f_(),aS,cS;Wr.codegen=lM();Wr.fetch=fM();Wr.path=pM();Wr.fs=Wr.inquire("fs");Wr.toArray=function(e){if(e){for(var t=Object.keys(e),n=new Array(t.length),i=0;i<t.length;)n[i]=e[t[i++]];return n}return[]};Wr.toObject=function(e){for(var t={},n=0;n<e.length;){var i=e[n++],s=e[n++];s!==void 0&&(t[i]=s)}return t};var o1e=/\\/g,a1e=/"/g;Wr.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)};Wr.safeProp=function(e){return!/^[$\w_]+$/.test(e)||Wr.isReserved(e)?'["'+e.replace(o1e,"\\\\").replace(a1e,'\\"')+'"]':"."+e};Wr.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var c1e=/_([a-z])/g;Wr.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(c1e,function(t,n){return n.toUpperCase()})};Wr.compareFieldsById=function(e,t){return e.id-t.id};Wr.decorateType=function(e,t){if(e.$type)return t&&e.$type.name!==t&&(Wr.decorateRoot.remove(e.$type),e.$type.name=t,Wr.decorateRoot.add(e.$type)),e.$type;aS||(aS=nw());var n=new aS(t||e.name);return Wr.decorateRoot.add(n),n.ctor=e,Object.defineProperty(e,"$type",{value:n,enumerable:!1}),Object.defineProperty(e.prototype,"$type",{value:n,enumerable:!1}),n};var l1e=0;Wr.decorateEnum=function(e){if(e.$type)return e.$type;cS||(cS=wo());var t=new cS("Enum"+l1e++,e);return Wr.decorateRoot.add(t),Object.defineProperty(e,"$type",{value:t,enumerable:!1}),t};Wr.setProperty=function(e,t,n){function i(s,o,a){var c=o.shift();if(c==="__proto__")return s;if(o.length>0)s[c]=i(s[c]||{},o,a);else{var l=s[c];l&&(a=[].concat(l).concat(a)),s[c]=a}return s}if(typeof e!="object")throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return t=t.split("."),i(e,t,n)};Object.defineProperty(Wr,"decorateRoot",{get:function(){return $M.decorated||($M.decorated=new(ow()))}})});var Kf=R((YOe,GM)=>{"use strict";u();GM.exports=$i;$i.className="ReflectionObject";var aw=Rn(),cw;function $i(r,e){if(!aw.isString(r))throw TypeError("name must be a string");if(e&&!aw.isObject(e))throw TypeError("options must be an object");this.options=e,this.parsedOptions=null,this.name=r,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties($i.prototype,{root:{get:function(){for(var r=this;r.parent!==null;)r=r.parent;return r}},fullName:{get:function(){for(var r=[this.name],e=this.parent;e;)r.unshift(e.name),e=e.parent;return r.join(".")}}});$i.prototype.toJSON=function(){throw Error()};$i.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var t=e.root;t instanceof cw&&t._handleAdd(this)};$i.prototype.onRemove=function(e){var t=e.root;t instanceof cw&&t._handleRemove(this),this.parent=null,this.resolved=!1};$i.prototype.resolve=function(){return this.resolved?this:(this.root instanceof cw&&(this.resolved=!0),this)};$i.prototype.getOption=function(e){if(this.options)return this.options[e]};$i.prototype.setOption=function(e,t,n){return(!n||!this.options||this.options[e]===void 0)&&((this.options||(this.options={}))[e]=t),this};$i.prototype.setParsedOption=function(e,t,n){this.parsedOptions||(this.parsedOptions=[]);var i=this.parsedOptions;if(n){var s=i.find(function(c){return Object.prototype.hasOwnProperty.call(c,e)});if(s){var o=s[e];aw.setProperty(o,n,t)}else s={},s[e]=aw.setProperty({},n,t),i.push(s)}else{var a={};a[e]=t,i.push(a)}return this};$i.prototype.setOptions=function(e,t){if(e)for(var n=Object.keys(e),i=0;i<n.length;++i)this.setOption(n[i],e[n[i]],t);return this};$i.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e};$i._configure=function(r){cw=r}});var wo=R((QOe,YM)=>{"use strict";u();YM.exports=ga;var jM=Kf();((ga.prototype=Object.create(jM.prototype)).constructor=ga).className="Enum";var WM=pp(),lw=Rn();function ga(r,e,t,n,i,s){if(jM.call(this,r,t),e&&typeof e!="object")throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=n,this.comments=i||{},this.valuesOptions=s,this.reserved=void 0,e)for(var o=Object.keys(e),a=0;a<o.length;++a)typeof e[o[a]]=="number"&&(this.valuesById[this.values[o[a]]=e[o[a]]]=o[a])}ga.fromJSON=function(e,t){var n=new ga(e,t.values,t.options,t.comment,t.comments);return n.reserved=t.reserved,n};ga.prototype.toJSON=function(e){var t=e?Boolean(e.keepComments):!1;return lw.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])};ga.prototype.add=function(e,t,n,i){if(!lw.isString(e))throw TypeError("name must be a string");if(!lw.isInteger(t))throw TypeError("id must be an integer");if(this.values[e]!==void 0)throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(this.valuesById[t]!==void 0){if(!(this.options&&this.options.allow_alias))throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return i&&(this.valuesOptions===void 0&&(this.valuesOptions={}),this.valuesOptions[e]=i||null),this.comments[e]=n||null,this};ga.prototype.remove=function(e){if(!lw.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(t==null)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this};ga.prototype.isReservedId=function(e){return WM.isReservedId(this.reserved,e)};ga.prototype.isReservedName=function(e){return WM.isReservedName(this.reserved,e)}});var iS=R((XOe,XM)=>{"use strict";u();XM.exports=f1e;var u1e=wo(),lS=Vf(),uS=Rn();function QM(r,e,t,n){return e.resolvedType.group?r("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",t,n,(e.id<<3|3)>>>0,(e.id<<3|4)>>>0):r("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",t,n,(e.id<<3|2)>>>0)}function f1e(r){for(var e=uS.codegen(["m","w"],r.name+"$encode")("if(!w)")("w=Writer.create()"),t,n,i=r.fieldsArray.slice().sort(uS.compareFieldsById),t=0;t<i.length;++t){var s=i[t].resolve(),o=r._fieldsArray.indexOf(s),a=s.resolvedType instanceof u1e?"int32":s.type,c=lS.basic[a];n="m"+uS.safeProp(s.name),s.map?(e("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",n,s.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",n)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(s.id<<3|2)>>>0,8|lS.mapKey[s.keyType],s.keyType),c===void 0?e("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",o,n):e(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|c,a,n),e("}")("}")):s.repeated?(e("if(%s!=null&&%s.length){",n,n),s.packed&&lS.packed[a]!==void 0?e("w.uint32(%i).fork()",(s.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",n)("w.%s(%s[i])",a,n)("w.ldelim()"):(e("for(var i=0;i<%s.length;++i)",n),c===void 0?QM(e,s,o,n+"[i]"):e("w.uint32(%i).%s(%s[i])",(s.id<<3|c)>>>0,a,n)),e("}")):(s.optional&&e("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",n,s.name),c===void 0?QM(e,s,o,n):e("w.uint32(%i).%s(%s)",(s.id<<3|c)>>>0,a,n))}return e("return w")}});var JM=R((ZOe,ZM)=>{"use strict";u();var Tt=ZM.exports=h_();Tt.build="light";function h1e(r,e,t){return typeof e=="function"?(t=e,e=new Tt.Root):e||(e=new Tt.Root),e.load(r,t)}Tt.load=h1e;function d1e(r,e){return e||(e=new Tt.Root),e.loadSync(r)}Tt.loadSync=d1e;Tt.encoder=iS();Tt.decoder=j9();Tt.verifier=Q9();Tt.converter=J9();Tt.ReflectionObject=Kf();Tt.Namespace=pp();Tt.Root=ow();Tt.Enum=wo();Tt.Type=nw();Tt.Field=Wl();Tt.OneOf=fp();Tt.MapField=X4();Tt.Service=J4();Tt.Method=Z4();Tt.Message=ew();Tt.wrappers=eS();Tt.types=Vf();Tt.util=Rn();Tt.ReflectionObject._configure(Tt.Root);Tt.Namespace._configure(Tt.Type,Tt.Service,Tt.Enum);Tt.Root._configure(Tt.Type);Tt.Field._configure(Tt.Type)});var hS=R((JOe,rU)=>{"use strict";u();rU.exports=tU;var fS=/[\s{}=;:[\],'"()<>]/g,p1e=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,m1e=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,y1e=/^ *[*/]+ */,g1e=/^\s*\*?\/*/,w1e=/\n/g,E1e=/\s/,b1e=/\\(.?)/g,v1e={0:"\0",r:"\r",n:`
`,t:" "};function eU(r){return r.replace(b1e,function(e,t){switch(t){case"\\":case"":return t;default:return v1e[t]||""}})}tU.unescape=eU;function tU(r,e){r=r.toString();var t=0,n=r.length,i=1,s=0,o={},a=[],c=null;function l(_){return Error("illegal "+_+" (line "+i+")")}function f(){var _=c==="'"?m1e:p1e;_.lastIndex=t-1;var I=_.exec(r);if(!I)throw l("string");return t=_.lastIndex,g(c),c=null,eU(I[1])}function h(_){return r.charAt(_)}function p(_,I,T){var x={type:r.charAt(_++),lineEmpty:!1,leading:T},P;e?P=2:P=3;var B=_-P,q;do if(--B<0||(q=r.charAt(B))===`
`){x.lineEmpty=!0;break}while(q===" "||q===" ");for(var Y=r.substring(_,I).split(w1e),re=0;re<Y.length;++re)Y[re]=Y[re].replace(e?g1e:y1e,"").trim();x.text=Y.join(`
`).trim(),o[i]=x,s=i}function d(_){var I=m(_),T=r.substring(_,I),x=/^\s*\/{1,2}/.test(T);return x}function m(_){for(var I=_;I<n&&h(I)!==`
`;)I++;return I}function y(){if(a.length>0)return a.shift();if(c)return f();var _,I,T,x,P,B=t===0;do{if(t===n)return null;for(_=!1;E1e.test(T=h(t));)if(T===`
`&&(B=!0,++i),++t===n)return null;if(h(t)==="/"){if(++t===n)throw l("comment");if(h(t)==="/")if(e){if(x=t,P=!1,d(t)){P=!0;do if(t=m(t),t===n||(t++,!B))break;while(d(t))}else t=Math.min(n,m(t)+1);P&&(p(x,t,B),B=!0),i++,_=!0}else{for(P=h(x=t+1)==="/";h(++t)!==`
`;)if(t===n)return null;++t,P&&(p(x,t-1,B),B=!0),++i,_=!0}else if((T=h(t))==="*"){x=t+1,P=e||h(x)==="*";do{if(T===`
`&&++i,++t===n)throw l("comment");I=T,T=h(t)}while(I!=="*"||T!=="/");++t,P&&(p(x,t-2,B),B=!0),_=!0}else return"/"}}while(_);var q=t;fS.lastIndex=0;var Y=fS.test(h(q++));if(!Y)for(;q<n&&!fS.test(h(q));)++q;var re=r.substring(t,t=q);return(re==='"'||re==="'")&&(c=re),re}function g(_){a.push(_)}function w(){if(!a.length){var _=y();if(_===null)return null;g(_)}return a[0]}function b(_,I){var T=w(),x=T===_;if(x)return y(),!0;if(!I)throw l("token '"+T+"', '"+_+"' expected");return!1}function S(_){var I=null,T;return _===void 0?(T=o[i-1],delete o[i-1],T&&(e||T.type==="*"||T.lineEmpty)&&(I=T.leading?T.text:null)):(s<_&&w(),T=o[_],delete o[_],T&&!T.lineEmpty&&(e||T.type==="/")&&(I=T.leading?null:T.text)),I}return Object.defineProperty({next:y,peek:w,push:g,skip:b,cmnt:S},"line",{get:function(){return i}})}});var cU=R((eke,aU)=>{"use strict";u();aU.exports=Ac;Ac.filename=null;Ac.defaults={keepCase:!1};var _1e=hS(),nU=ow(),iU=nw(),sU=Wl(),S1e=X4(),oU=fp(),x1e=wo(),T1e=J4(),I1e=Z4(),dS=Vf(),pS=Rn(),A1e=/^[1-9][0-9]*$/,R1e=/^-?[1-9][0-9]*$/,C1e=/^0[x][0-9a-fA-F]+$/,P1e=/^-?0[x][0-9a-fA-F]+$/,D1e=/^0[0-7]+$/,O1e=/^-?0[0-7]+$/,k1e=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,wa=/^[a-zA-Z_][a-zA-Z_0-9]*$/,Ea=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,N1e=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function Ac(r,e,t){e instanceof nU||(t=e,e=new nU),t||(t=Ac.defaults);var n=t.preferTrailingComment||!1,i=_1e(r,t.alternateCommentMode||!1),s=i.next,o=i.push,a=i.peek,c=i.skip,l=i.cmnt,f=!0,h,p,d,m,y=!1,g=e,w=t.keepCase?function(W){return W}:pS.camelCase;function b(W,$,Q){var ae=Ac.filename;return Q||(Ac.filename=null),Error("illegal "+($||"token")+" '"+W+"' ("+(ae?ae+", ":"")+"line "+i.line+")")}function S(){var W=[],$;do{if(($=s())!=='"'&&$!=="'")throw b($);W.push(s()),c($),$=a()}while($==='"'||$==="'");return W.join("")}function _(W){var $=s();switch($){case"'":case'"':return o($),S();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return T($,!0)}catch{if(W&&Ea.test($))return $;throw b($,"value")}}function I(W,$){var Q,ae;do $&&((Q=a())==='"'||Q==="'")?W.push(S()):W.push([ae=x(s()),c("to",!0)?x(s()):ae]);while(c(",",!0));c(";")}function T(W,$){var Q=1;switch(W.charAt(0)==="-"&&(Q=-1,W=W.substring(1)),W){case"inf":case"INF":case"Inf":return Q*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(A1e.test(W))return Q*parseInt(W,10);if(C1e.test(W))return Q*parseInt(W,16);if(D1e.test(W))return Q*parseInt(W,8);if(k1e.test(W))return Q*parseFloat(W);throw b(W,"number",$)}function x(W,$){switch(W){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!$&&W.charAt(0)==="-")throw b(W,"id");if(R1e.test(W))return parseInt(W,10);if(P1e.test(W))return parseInt(W,16);if(O1e.test(W))return parseInt(W,8);throw b(W,"id")}function P(){if(h!==void 0)throw b("package");if(h=s(),!Ea.test(h))throw b(h,"name");g=g.define(h),c(";")}function B(){var W=a(),$;switch(W){case"weak":$=d||(d=[]),s();break;case"public":s();default:$=p||(p=[]);break}W=S(),c(";"),$.push(W)}function q(){if(c("="),m=S(),y=m==="proto3",!y&&m!=="proto2")throw b(m,"syntax");c(";")}function Y(W,$){switch($){case"option":return Ke(W,$),c(";"),!0;case"message":return ie(W,$),!0;case"enum":return qe(W,$),!0;case"service":return Pe(W,$),!0;case"extend":return Be(W,$),!0}return!1}function re(W,$,Q){var ae=i.line;if(W&&(typeof W.comment!="string"&&(W.comment=l()),W.filename=Ac.filename),c("{",!0)){for(var ce;(ce=s())!=="}";)$(ce);c(";",!0)}else Q&&Q(),c(";"),W&&(typeof W.comment!="string"||n)&&(W.comment=l(ae)||W.comment)}function ie(W,$){if(!wa.test($=s()))throw b($,"type name");var Q=new iU($);re(Q,function(ce){if(!Y(Q,ce))switch(ce){case"map":Oe(Q,ce);break;case"required":case"repeated":Ce(Q,ce);break;case"optional":y?Ce(Q,"proto3_optional"):Ce(Q,"optional");break;case"oneof":H(Q,ce);break;case"extensions":I(Q.extensions||(Q.extensions=[]));break;case"reserved":I(Q.reserved||(Q.reserved=[]),!0);break;default:if(!y||!Ea.test(ce))throw b(ce);o(ce),Ce(Q,"optional");break}}),W.add(Q)}function Ce(W,$,Q){var ae=s();if(ae==="group"){Ee(W,$);return}if(!Ea.test(ae))throw b(ae,"type");var ce=s();if(!wa.test(ce))throw b(ce,"name");ce=w(ce),c("=");var De=new sU(ce,x(s()),ae,$,Q);if(re(De,function(wn){if(wn==="option")Ke(De,wn),c(";");else throw b(wn)},function(){le(De)}),$==="proto3_optional"){var it=new oU("_"+ce);De.setOption("proto3_optional",!0),it.add(De),W.add(it)}else W.add(De);!y&&De.repeated&&(dS.packed[ae]!==void 0||dS.basic[ae]===void 0)&&De.setOption("packed",!1,!0)}function Ee(W,$){var Q=s();if(!wa.test(Q))throw b(Q,"name");var ae=pS.lcFirst(Q);Q===ae&&(Q=pS.ucFirst(Q)),c("=");var ce=x(s()),De=new iU(Q);De.group=!0;var it=new sU(ae,ce,Q,$);it.filename=Ac.filename,re(De,function(wn){switch(wn){case"option":Ke(De,wn),c(";");break;case"required":case"repeated":Ce(De,wn);break;case"optional":y?Ce(De,"proto3_optional"):Ce(De,"optional");break;case"message":ie(De,wn);break;case"enum":qe(De,wn);break;default:throw b(wn)}}),W.add(De).add(it)}function Oe(W){c("<");var $=s();if(dS.mapKey[$]===void 0)throw b($,"type");c(",");var Q=s();if(!Ea.test(Q))throw b(Q,"type");c(">");var ae=s();if(!wa.test(ae))throw b(ae,"name");c("=");var ce=new S1e(w(ae),x(s()),$,Q);re(ce,function(it){if(it==="option")Ke(ce,it),c(";");else throw b(it)},function(){le(ce)}),W.add(ce)}function H(W,$){if(!wa.test($=s()))throw b($,"name");var Q=new oU(w($));re(Q,function(ce){ce==="option"?(Ke(Q,ce),c(";")):(o(ce),Ce(Q,"optional"))}),W.add(Q)}function qe(W,$){if(!wa.test($=s()))throw b($,"name");var Q=new x1e($);re(Q,function(ce){switch(ce){case"option":Ke(Q,ce),c(";");break;case"reserved":I(Q.reserved||(Q.reserved=[]),!0);break;default:zt(Q,ce)}}),W.add(Q)}function zt(W,$){if(!wa.test($))throw b($,"name");c("=");var Q=x(s(),!0),ae={options:void 0};ae.setOption=function(ce,De){this.options===void 0&&(this.options={}),this.options[ce]=De},re(ae,function(De){if(De==="option")Ke(ae,De),c(";");else throw b(De)},function(){le(ae)}),W.add($,Q,ae.comment,ae.options)}function Ke(W,$){var Q=c("(",!0);if(!Ea.test($=s()))throw b($,"name");var ae=$,ce=ae,De;Q&&(c(")"),ae="("+ae+")",ce=ae,$=a(),N1e.test($)&&(De=$.slice(1),ae+=$,s())),c("=");var it=Ze(W,ae);de(W,ce,it,De)}function Ze(W,$){if(c("{",!0)){for(var Q={};!c("}",!0);){if(!wa.test(Ye=s()))throw b(Ye,"name");var ae,ce=Ye;if(c(":",!0),a()==="{")ae=Ze(W,$+"."+Ye);else if(a()==="["){ae=[];var De;if(c("[",!0)){do De=_(!0),ae.push(De);while(c(",",!0));c("]"),typeof De<"u"&&ee(W,$+"."+Ye,De)}}else ae=_(!0),ee(W,$+"."+Ye,ae);var it=Q[ce];it&&(ae=[].concat(it).concat(ae)),Q[ce]=ae,c(",",!0),c(";",!0)}return Q}var gi=_(!0);return ee(W,$,gi),gi}function ee(W,$,Q){W.setOption&&W.setOption($,Q)}function de(W,$,Q,ae){W.setParsedOption&&W.setParsedOption($,Q,ae)}function le(W){if(c("[",!0)){do Ke(W,"option");while(c(",",!0));c("]")}return W}function Pe(W,$){if(!wa.test($=s()))throw b($,"service name");var Q=new T1e($);re(Q,function(ce){if(!Y(Q,ce))if(ce==="rpc")Me(Q,ce);else throw b(ce)}),W.add(Q)}function Me(W,$){var Q=l(),ae=$;if(!wa.test($=s()))throw b($,"name");var ce=$,De,it,gi,wn;if(c("("),c("stream",!0)&&(it=!0),!Ea.test($=s())||(De=$,c(")"),c("returns"),c("("),c("stream",!0)&&(wn=!0),!Ea.test($=s())))throw b($);gi=$,c(")");var Gn=new I1e(ce,ae,De,gi,it,wn);Gn.comment=Q,re(Gn,function(Ad){if(Ad==="option")Ke(Gn,Ad),c(";");else throw b(Ad)}),W.add(Gn)}function Be(W,$){if(!Ea.test($=s()))throw b($,"reference");var Q=$;re(null,function(ce){switch(ce){case"required":case"repeated":Ce(W,ce,Q);break;case"optional":y?Ce(W,"proto3_optional",Q):Ce(W,"optional",Q);break;default:if(!y||!Ea.test(ce))throw b(ce);o(ce),Ce(W,"optional",Q);break}})}for(var Ye;(Ye=s())!==null;)switch(Ye){case"package":if(!f)throw b(Ye);P();break;case"import":if(!f)throw b(Ye);B();break;case"syntax":if(!f)throw b(Ye);q();break;case"option":Ke(g,Ye),c(";");break;default:if(Y(g,Ye)){f=!1;continue}throw b(Ye)}return Ac.filename=null,{package:h,imports:p,weakImports:d,syntax:m,root:e}}});var fU=R((tke,uU)=>{"use strict";u();uU.exports=bo;var L1e=/\/|\./;function bo(r,e){L1e.test(r)||(r="google/protobuf/"+r+".proto",e={nested:{google:{nested:{protobuf:{nested:e}}}}}),bo[r]=e}bo("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}});var lU;bo("duration",{Duration:lU={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}});bo("timestamp",{Timestamp:lU});bo("empty",{Empty:{fields:{}}});bo("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}});bo("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}});bo("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}});bo.get=function(e){return bo[e]||null}});var dU=R((rke,hU)=>{"use strict";u();var Xl=hU.exports=JM();Xl.build="full";Xl.tokenize=hS();Xl.parse=cU();Xl.common=fU();Xl.Root._configure(Xl.Type,Xl.parse,Xl.common)});var mS=R((nke,pU)=>{"use strict";u();pU.exports=dU()});var ft=R((gke,gU)=>{u();gU.exports={options:{usePureJavaScript:!1}}});var bU=R((wke,EU)=>{u();var ES={};EU.exports=ES;var wU={};ES.encode=function(r,e,t){if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(t!==void 0&&typeof t!="number")throw new TypeError('"maxline" must be a number.');var n="";if(!(r instanceof Uint8Array))n=U1e(r,e);else{var i=0,s=e.length,o=e.charAt(0),a=[0];for(i=0;i<r.length;++i){for(var c=0,l=r[i];c<a.length;++c)l+=a[c]<<8,a[c]=l%s,l=l/s|0;for(;l>0;)a.push(l%s),l=l/s|0}for(i=0;r[i]===0&&i<r.length-1;++i)n+=o;for(i=a.length-1;i>=0;--i)n+=e[a[i]]}if(t){var f=new RegExp(".{1,"+t+"}","g");n=n.match(f).join(`\r
`)}return n};ES.decode=function(r,e){if(typeof r!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');var t=wU[e];if(!t){t=wU[e]=[];for(var n=0;n<e.length;++n)t[e.charCodeAt(n)]=n}r=r.replace(/\s/g,"");for(var i=e.length,s=e.charAt(0),o=[0],n=0;n<r.length;n++){var a=t[r.charCodeAt(n)];if(a===void 0)return;for(var c=0,l=a;c<o.length;++c)l+=o[c]*i,o[c]=l&255,l>>=8;for(;l>0;)o.push(l&255),l>>=8}for(var f=0;r[f]===s&&f<r.length-1;++f)o.push(0);return typeof Buffer<"u"?Buffer.from(o.reverse()):new Uint8Array(o.reverse())};function U1e(r,e){var t=0,n=e.length,i=e.charAt(0),s=[0];for(t=0;t<r.length();++t){for(var o=0,a=r.at(t);o<s.length;++o)a+=s[o]<<8,s[o]=a%n,a=a/n|0;for(;a>0;)s.push(a%n),a=a/n|0}var c="";for(t=0;r.at(t)===0&&t<r.length()-1;++t)c+=i;for(t=s.length-1;t>=0;--t)c+=e[s[t]];return c}});var sr=R((Eke,xU)=>{u();var vU=ft(),_U=bU(),N=xU.exports=vU.util=vU.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){N.nextTick=process.nextTick,typeof setImmediate=="function"?N.setImmediate=setImmediate:N.setImmediate=N.nextTick;return}if(typeof setImmediate=="function"){N.setImmediate=function(){return setImmediate.apply(void 0,arguments)},N.nextTick=function(a){return setImmediate(a)};return}if(N.setImmediate=function(a){setTimeout(a,0)},typeof window<"u"&&typeof window.postMessage=="function"){let a=function(c){if(c.source===window&&c.data===r){c.stopPropagation();var l=e.slice();e.length=0,l.forEach(function(f){f()})}};var o=a,r="forge.setImmediate",e=[];N.setImmediate=function(c){e.push(c),e.length===1&&window.postMessage(r,"*")},window.addEventListener("message",a,!0)}if(typeof MutationObserver<"u"){var t=Date.now(),n=!0,i=document.createElement("div"),e=[];new MutationObserver(function(){var c=e.slice();e.length=0,c.forEach(function(l){l()})}).observe(i,{attributes:!0});var s=N.setImmediate;N.setImmediate=function(c){Date.now()-t>15?(t=Date.now(),s(c)):(e.push(c),e.length===1&&i.setAttribute("a",n=!n))}}N.nextTick=N.setImmediate})();N.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;N.globalScope=function(){return N.isNodejs?globalThis:typeof self>"u"?window:self}();N.isArray=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"};N.isArrayBuffer=function(r){return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer};N.isArrayBufferView=function(r){return r&&N.isArrayBuffer(r.buffer)&&r.byteLength!==void 0};function xm(r){if(!(r===8||r===16||r===24||r===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+r)}N.ByteBuffer=bS;function bS(r){if(this.data="",this.read=0,typeof r=="string")this.data=r;else if(N.isArrayBuffer(r)||N.isArrayBufferView(r))if(typeof Buffer<"u"&&r instanceof Buffer)this.data=r.toString("binary");else{var e=new Uint8Array(r);try{this.data=String.fromCharCode.apply(null,e)}catch{for(var t=0;t<e.length;++t)this.putByte(e[t])}}else(r instanceof bS||typeof r=="object"&&typeof r.data=="string"&&typeof r.read=="number")&&(this.data=r.data,this.read=r.read);this._constructedStringLength=0}N.ByteStringBuffer=bS;var F1e=4096;N.ByteStringBuffer.prototype._optimizeConstructedString=function(r){this._constructedStringLength+=r,this._constructedStringLength>F1e&&(this.data.substr(0,1),this._constructedStringLength=0)};N.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};N.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};N.ByteStringBuffer.prototype.putByte=function(r){return this.putBytes(String.fromCharCode(r))};N.ByteStringBuffer.prototype.fillWithByte=function(r,e){r=String.fromCharCode(r);for(var t=this.data;e>0;)e&1&&(t+=r),e>>>=1,e>0&&(r+=r);return this.data=t,this._optimizeConstructedString(e),this};N.ByteStringBuffer.prototype.putBytes=function(r){return this.data+=r,this._optimizeConstructedString(r.length),this};N.ByteStringBuffer.prototype.putString=function(r){return this.putBytes(N.encodeUtf8(r))};N.ByteStringBuffer.prototype.putInt16=function(r){return this.putBytes(String.fromCharCode(r>>8&255)+String.fromCharCode(r&255))};N.ByteStringBuffer.prototype.putInt24=function(r){return this.putBytes(String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r&255))};N.ByteStringBuffer.prototype.putInt32=function(r){return this.putBytes(String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r&255))};N.ByteStringBuffer.prototype.putInt16Le=function(r){return this.putBytes(String.fromCharCode(r&255)+String.fromCharCode(r>>8&255))};N.ByteStringBuffer.prototype.putInt24Le=function(r){return this.putBytes(String.fromCharCode(r&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r>>16&255))};N.ByteStringBuffer.prototype.putInt32Le=function(r){return this.putBytes(String.fromCharCode(r&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>24&255))};N.ByteStringBuffer.prototype.putInt=function(r,e){xm(e);var t="";do e-=8,t+=String.fromCharCode(r>>e&255);while(e>0);return this.putBytes(t)};N.ByteStringBuffer.prototype.putSignedInt=function(r,e){return r<0&&(r+=2<<e-1),this.putInt(r,e)};N.ByteStringBuffer.prototype.putBuffer=function(r){return this.putBytes(r.getBytes())};N.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};N.ByteStringBuffer.prototype.getInt16=function(){var r=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,r};N.ByteStringBuffer.prototype.getInt24=function(){var r=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,r};N.ByteStringBuffer.prototype.getInt32=function(){var r=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,r};N.ByteStringBuffer.prototype.getInt16Le=function(){var r=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,r};N.ByteStringBuffer.prototype.getInt24Le=function(){var r=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,r};N.ByteStringBuffer.prototype.getInt32Le=function(){var r=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,r};N.ByteStringBuffer.prototype.getInt=function(r){xm(r);var e=0;do e=(e<<8)+this.data.charCodeAt(this.read++),r-=8;while(r>0);return e};N.ByteStringBuffer.prototype.getSignedInt=function(r){var e=this.getInt(r),t=2<<r-2;return e>=t&&(e-=t<<1),e};N.ByteStringBuffer.prototype.getBytes=function(r){var e;return r?(r=Math.min(this.length(),r),e=this.data.slice(this.read,this.read+r),this.read+=r):r===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};N.ByteStringBuffer.prototype.bytes=function(r){return typeof r>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+r)};N.ByteStringBuffer.prototype.at=function(r){return this.data.charCodeAt(this.read+r)};N.ByteStringBuffer.prototype.setAt=function(r,e){return this.data=this.data.substr(0,this.read+r)+String.fromCharCode(e)+this.data.substr(this.read+r+1),this};N.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};N.ByteStringBuffer.prototype.copy=function(){var r=N.createBuffer(this.data);return r.read=this.read,r};N.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};N.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};N.ByteStringBuffer.prototype.truncate=function(r){var e=Math.max(0,this.length()-r);return this.data=this.data.substr(this.read,e),this.read=0,this};N.ByteStringBuffer.prototype.toHex=function(){for(var r="",e=this.read;e<this.data.length;++e){var t=this.data.charCodeAt(e);t<16&&(r+="0"),r+=t.toString(16)}return r};N.ByteStringBuffer.prototype.toString=function(){return N.decodeUtf8(this.bytes())};function V1e(r,e){e=e||{},this.read=e.readOffset||0,this.growSize=e.growSize||1024;var t=N.isArrayBuffer(r),n=N.isArrayBufferView(r);if(t||n){t?this.data=new DataView(r):this.data=new DataView(r.buffer,r.byteOffset,r.byteLength),this.write="writeOffset"in e?e.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,r!=null&&this.putBytes(r),"writeOffset"in e&&(this.write=e.writeOffset)}N.DataBuffer=V1e;N.DataBuffer.prototype.length=function(){return this.write-this.read};N.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};N.DataBuffer.prototype.accommodate=function(r,e){if(this.length()>=r)return this;e=Math.max(e||this.growSize,r);var t=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+e);return n.set(t),this.data=new DataView(n.buffer),this};N.DataBuffer.prototype.putByte=function(r){return this.accommodate(1),this.data.setUint8(this.write++,r),this};N.DataBuffer.prototype.fillWithByte=function(r,e){this.accommodate(e);for(var t=0;t<e;++t)this.data.setUint8(r);return this};N.DataBuffer.prototype.putBytes=function(r,e){if(N.isArrayBufferView(r)){var t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength),n=t.byteLength-t.byteOffset;this.accommodate(n);var i=new Uint8Array(this.data.buffer,this.write);return i.set(t),this.write+=n,this}if(N.isArrayBuffer(r)){var t=new Uint8Array(r);this.accommodate(t.byteLength);var i=new Uint8Array(this.data.buffer);return i.set(t,this.write),this.write+=t.byteLength,this}if(r instanceof N.DataBuffer||typeof r=="object"&&typeof r.read=="number"&&typeof r.write=="number"&&N.isArrayBufferView(r.data)){var t=new Uint8Array(r.data.byteLength,r.read,r.length());this.accommodate(t.byteLength);var i=new Uint8Array(r.data.byteLength,this.write);return i.set(t),this.write+=t.byteLength,this}if(r instanceof N.ByteStringBuffer&&(r=r.data,e="binary"),e=e||"binary",typeof r=="string"){var s;if(e==="hex")return this.accommodate(Math.ceil(r.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=N.binary.hex.decode(r,s,this.write),this;if(e==="base64")return this.accommodate(Math.ceil(r.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=N.binary.base64.decode(r,s,this.write),this;if(e==="utf8"&&(r=N.encodeUtf8(r),e="binary"),e==="binary"||e==="raw")return this.accommodate(r.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=N.binary.raw.decode(s),this;if(e==="utf16")return this.accommodate(r.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=N.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+e)}throw Error("Invalid parameter: "+r)};N.DataBuffer.prototype.putBuffer=function(r){return this.putBytes(r),r.clear(),this};N.DataBuffer.prototype.putString=function(r){return this.putBytes(r,"utf16")};N.DataBuffer.prototype.putInt16=function(r){return this.accommodate(2),this.data.setInt16(this.write,r),this.write+=2,this};N.DataBuffer.prototype.putInt24=function(r){return this.accommodate(3),this.data.setInt16(this.write,r>>8&65535),this.data.setInt8(this.write,r>>16&255),this.write+=3,this};N.DataBuffer.prototype.putInt32=function(r){return this.accommodate(4),this.data.setInt32(this.write,r),this.write+=4,this};N.DataBuffer.prototype.putInt16Le=function(r){return this.accommodate(2),this.data.setInt16(this.write,r,!0),this.write+=2,this};N.DataBuffer.prototype.putInt24Le=function(r){return this.accommodate(3),this.data.setInt8(this.write,r>>16&255),this.data.setInt16(this.write,r>>8&65535,!0),this.write+=3,this};N.DataBuffer.prototype.putInt32Le=function(r){return this.accommodate(4),this.data.setInt32(this.write,r,!0),this.write+=4,this};N.DataBuffer.prototype.putInt=function(r,e){xm(e),this.accommodate(e/8);do e-=8,this.data.setInt8(this.write++,r>>e&255);while(e>0);return this};N.DataBuffer.prototype.putSignedInt=function(r,e){return xm(e),this.accommodate(e/8),r<0&&(r+=2<<e-1),this.putInt(r,e)};N.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};N.DataBuffer.prototype.getInt16=function(){var r=this.data.getInt16(this.read);return this.read+=2,r};N.DataBuffer.prototype.getInt24=function(){var r=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,r};N.DataBuffer.prototype.getInt32=function(){var r=this.data.getInt32(this.read);return this.read+=4,r};N.DataBuffer.prototype.getInt16Le=function(){var r=this.data.getInt16(this.read,!0);return this.read+=2,r};N.DataBuffer.prototype.getInt24Le=function(){var r=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,r};N.DataBuffer.prototype.getInt32Le=function(){var r=this.data.getInt32(this.read,!0);return this.read+=4,r};N.DataBuffer.prototype.getInt=function(r){xm(r);var e=0;do e=(e<<8)+this.data.getInt8(this.read++),r-=8;while(r>0);return e};N.DataBuffer.prototype.getSignedInt=function(r){var e=this.getInt(r),t=2<<r-2;return e>=t&&(e-=t<<1),e};N.DataBuffer.prototype.getBytes=function(r){var e;return r?(r=Math.min(this.length(),r),e=this.data.slice(this.read,this.read+r),this.read+=r):r===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};N.DataBuffer.prototype.bytes=function(r){return typeof r>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+r)};N.DataBuffer.prototype.at=function(r){return this.data.getUint8(this.read+r)};N.DataBuffer.prototype.setAt=function(r,e){return this.data.setUint8(r,e),this};N.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};N.DataBuffer.prototype.copy=function(){return new N.DataBuffer(this)};N.DataBuffer.prototype.compact=function(){if(this.read>0){var r=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(r.byteLength);e.set(r),this.data=new DataView(e),this.write-=this.read,this.read=0}return this};N.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};N.DataBuffer.prototype.truncate=function(r){return this.write=Math.max(0,this.length()-r),this.read=Math.min(this.read,this.write),this};N.DataBuffer.prototype.toHex=function(){for(var r="",e=this.read;e<this.data.byteLength;++e){var t=this.data.getUint8(e);t<16&&(r+="0"),r+=t.toString(16)}return r};N.DataBuffer.prototype.toString=function(r){var e=new Uint8Array(this.data,this.read,this.length());if(r=r||"utf8",r==="binary"||r==="raw")return N.binary.raw.encode(e);if(r==="hex")return N.binary.hex.encode(e);if(r==="base64")return N.binary.base64.encode(e);if(r==="utf8")return N.text.utf8.decode(e);if(r==="utf16")return N.text.utf16.decode(e);throw new Error("Invalid encoding: "+r)};N.createBuffer=function(r,e){return e=e||"raw",r!==void 0&&e==="utf8"&&(r=N.encodeUtf8(r)),new N.ByteBuffer(r)};N.fillString=function(r,e){for(var t="";e>0;)e&1&&(t+=r),e>>>=1,e>0&&(r+=r);return t};N.xorBytes=function(r,e,t){for(var n="",i="",s="",o=0,a=0;t>0;--t,++o)i=r.charCodeAt(o)^e.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s,n};N.hexToBytes=function(r){var e="",t=0;for(r.length&!0&&(t=1,e+=String.fromCharCode(parseInt(r[0],16)));t<r.length;t+=2)e+=String.fromCharCode(parseInt(r.substr(t,2),16));return e};N.bytesToHex=function(r){return N.createBuffer(r).toHex()};N.int32ToBytes=function(r){return String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r&255)};var Zl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Jl=[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],SU="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";N.encode64=function(r,e){for(var t="",n="",i,s,o,a=0;a<r.length;)i=r.charCodeAt(a++),s=r.charCodeAt(a++),o=r.charCodeAt(a++),t+=Zl.charAt(i>>2),t+=Zl.charAt((i&3)<<4|s>>4),isNaN(s)?t+="==":(t+=Zl.charAt((s&15)<<2|o>>6),t+=isNaN(o)?"=":Zl.charAt(o&63)),e&&t.length>e&&(n+=t.substr(0,e)+`\r
`,t=t.substr(e));return n+=t,n};N.decode64=function(r){r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e="",t,n,i,s,o=0;o<r.length;)t=Jl[r.charCodeAt(o++)-43],n=Jl[r.charCodeAt(o++)-43],i=Jl[r.charCodeAt(o++)-43],s=Jl[r.charCodeAt(o++)-43],e+=String.fromCharCode(t<<2|n>>4),i!==64&&(e+=String.fromCharCode((n&15)<<4|i>>2),s!==64&&(e+=String.fromCharCode((i&3)<<6|s)));return e};N.encodeUtf8=function(r){return unescape(encodeURIComponent(r))};N.decodeUtf8=function(r){return decodeURIComponent(escape(r))};N.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:_U.encode,decode:_U.decode}};N.binary.raw.encode=function(r){return String.fromCharCode.apply(null,r)};N.binary.raw.decode=function(r,e,t){var n=e;n||(n=new Uint8Array(r.length)),t=t||0;for(var i=t,s=0;s<r.length;++s)n[i++]=r.charCodeAt(s);return e?i-t:n};N.binary.hex.encode=N.bytesToHex;N.binary.hex.decode=function(r,e,t){var n=e;n||(n=new Uint8Array(Math.ceil(r.length/2))),t=t||0;var i=0,s=t;for(r.length&1&&(i=1,n[s++]=parseInt(r[0],16));i<r.length;i+=2)n[s++]=parseInt(r.substr(i,2),16);return e?s-t:n};N.binary.base64.encode=function(r,e){for(var t="",n="",i,s,o,a=0;a<r.byteLength;)i=r[a++],s=r[a++],o=r[a++],t+=Zl.charAt(i>>2),t+=Zl.charAt((i&3)<<4|s>>4),isNaN(s)?t+="==":(t+=Zl.charAt((s&15)<<2|o>>6),t+=isNaN(o)?"=":Zl.charAt(o&63)),e&&t.length>e&&(n+=t.substr(0,e)+`\r
`,t=t.substr(e));return n+=t,n};N.binary.base64.decode=function(r,e,t){var n=e;n||(n=new Uint8Array(Math.ceil(r.length/4)*3)),r=r.replace(/[^A-Za-z0-9\+\/\=]/g,""),t=t||0;for(var i,s,o,a,c=0,l=t;c<r.length;)i=Jl[r.charCodeAt(c++)-43],s=Jl[r.charCodeAt(c++)-43],o=Jl[r.charCodeAt(c++)-43],a=Jl[r.charCodeAt(c++)-43],n[l++]=i<<2|s>>4,o!==64&&(n[l++]=(s&15)<<4|o>>2,a!==64&&(n[l++]=(o&3)<<6|a));return e?l-t:n.subarray(0,l)};N.binary.base58.encode=function(r,e){return N.binary.baseN.encode(r,SU,e)};N.binary.base58.decode=function(r,e){return N.binary.baseN.decode(r,SU,e)};N.text={utf8:{},utf16:{}};N.text.utf8.encode=function(r,e,t){r=N.encodeUtf8(r);var n=e;n||(n=new Uint8Array(r.length)),t=t||0;for(var i=t,s=0;s<r.length;++s)n[i++]=r.charCodeAt(s);return e?i-t:n};N.text.utf8.decode=function(r){return N.decodeUtf8(String.fromCharCode.apply(null,r))};N.text.utf16.encode=function(r,e,t){var n=e;n||(n=new Uint8Array(r.length*2));var i=new Uint16Array(n.buffer);t=t||0;for(var s=t,o=t,a=0;a<r.length;++a)i[o++]=r.charCodeAt(a),s+=2;return e?s-t:n};N.text.utf16.decode=function(r){return String.fromCharCode.apply(null,new Uint16Array(r.buffer))};N.deflate=function(r,e,t){if(e=N.decode64(r.deflate(N.encode64(e)).rval),t){var n=2,i=e.charCodeAt(1);i&32&&(n=6),e=e.substring(n,e.length-4)}return e};N.inflate=function(r,e,t){var n=r.inflate(N.encode64(e)).rval;return n===null?null:N.decode64(n)};var vS=function(r,e,t){if(!r)throw new Error("WebStorage not available.");var n;if(t===null?n=r.removeItem(e):(t=N.encode64(JSON.stringify(t)),n=r.setItem(e,t)),typeof n<"u"&&n.rval!==!0){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},_S=function(r,e){if(!r)throw new Error("WebStorage not available.");var t=r.getItem(e);if(r.init)if(t.rval===null){if(t.error){var n=new Error(t.error.message);throw n.id=t.error.id,n.name=t.error.name,n}t=null}else t=t.rval;return t!==null&&(t=JSON.parse(N.decode64(t))),t},K1e=function(r,e,t,n){var i=_S(r,e);i===null&&(i={}),i[t]=n,vS(r,e,i)},q1e=function(r,e,t){var n=_S(r,e);return n!==null&&(n=t in n?n[t]:null),n},z1e=function(r,e,t){var n=_S(r,e);if(n!==null&&t in n){delete n[t];var i=!0;for(var s in n){i=!1;break}i&&(n=null),vS(r,e,n)}},$1e=function(r,e){vS(r,e,null)},fw=function(r,e,t){var n=null;typeof t>"u"&&(t=["web","flash"]);var i,s=!1,o=null;for(var a in t){i=t[a];try{if(i==="flash"||i==="both"){if(e[0]===null)throw new Error("Flash local storage not available.");n=r.apply(this,e),s=i==="flash"}(i==="web"||i==="both")&&(e[0]=localStorage,n=r.apply(this,e),s=!0)}catch(c){o=c}if(s)break}if(!s)throw o;return n};N.setItem=function(r,e,t,n,i){fw(K1e,arguments,i)};N.getItem=function(r,e,t,n){return fw(q1e,arguments,n)};N.removeItem=function(r,e,t,n){fw(z1e,arguments,n)};N.clearItems=function(r,e,t){fw($1e,arguments,t)};N.isEmpty=function(r){for(var e in r)if(r.hasOwnProperty(e))return!1;return!0};N.format=function(r){for(var e=/%./g,t,n,i=0,s=[],o=0;t=e.exec(r);){n=r.substring(o,e.lastIndex-2),n.length>0&&s.push(n),o=e.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i<arguments.length?s.push(arguments[i+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(r.substring(o)),s.join("")};N.formatNumber=function(r,e,t,n){var i=r,s=isNaN(e=Math.abs(e))?2:e,o=t===void 0?",":t,a=n===void 0?".":n,c=i<0?"-":"",l=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",f=l.length>3?l.length%3:0;return c+(f?l.substr(0,f)+a:"")+l.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-l).toFixed(s).slice(2):"")};N.formatSize=function(r){return r>=1073741824?r=N.formatNumber(r/1073741824,2,".","")+" GiB":r>=1048576?r=N.formatNumber(r/1048576,2,".","")+" MiB":r>=1024?r=N.formatNumber(r/1024,0)+" KiB":r=N.formatNumber(r,0)+" bytes",r};N.bytesFromIP=function(r){return r.indexOf(".")!==-1?N.bytesFromIPv4(r):r.indexOf(":")!==-1?N.bytesFromIPv6(r):null};N.bytesFromIPv4=function(r){if(r=r.split("."),r.length!==4)return null;for(var e=N.createBuffer(),t=0;t<r.length;++t){var n=parseInt(r[t],10);if(isNaN(n))return null;e.putByte(n)}return e.getBytes()};N.bytesFromIPv6=function(r){var e=0;r=r.split(":").filter(function(o){return o.length===0&&++e,!0});for(var t=(8-r.length+e)*2,n=N.createBuffer(),i=0;i<8;++i){if(!r[i]||r[i].length===0){n.fillWithByte(0,t),t=0;continue}var s=N.hexToBytes(r[i]);s.length<2&&n.putByte(0),n.putBytes(s)}return n.getBytes()};N.bytesToIP=function(r){return r.length===4?N.bytesToIPv4(r):r.length===16?N.bytesToIPv6(r):null};N.bytesToIPv4=function(r){if(r.length!==4)return null;for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e.join(".")};N.bytesToIPv6=function(r){if(r.length!==16)return null;for(var e=[],t=[],n=0,i=0;i<r.length;i+=2){for(var s=N.bytesToHex(r[i]+r[i+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var o=t[t.length-1],a=e.length;!o||a!==o.end+1?t.push({start:a,end:a}):(o.end=a,o.end-o.start>t[n].end-t[n].start&&(n=t.length-1))}e.push(s)}if(t.length>0){var c=t[n];c.end-c.start>0&&(e.splice(c.start,c.end-c.start+1,""),c.start===0&&e.unshift(""),c.end===7&&e.push(""))}return e.join(":")};N.estimateCores=function(r,e){if(typeof r=="function"&&(e=r,r={}),r=r||{},"cores"in N&&!r.update)return e(null,N.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return N.cores=navigator.hardwareConcurrency,e(null,N.cores);if(typeof Worker>"u")return N.cores=1,e(null,N.cores);if(typeof Blob>"u")return N.cores=2,e(null,N.cores);var t=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(o){for(var a=Date.now(),c=a+4;Date.now()<c;);self.postMessage({st:a,et:c})})}.toString(),")()"],{type:"application/javascript"}));n([],5,16);function n(o,a,c){if(a===0){var l=Math.floor(o.reduce(function(f,h){return f+h},0)/o.length);return N.cores=Math.max(1,l),URL.revokeObjectURL(t),e(null,N.cores)}i(c,function(f,h){o.push(s(c,h)),n(o,a-1,c)})}function i(o,a){for(var c=[],l=[],f=0;f<o;++f){var h=new Worker(t);h.addEventListener("message",function(p){if(l.push(p.data),l.length===o){for(var d=0;d<o;++d)c[d].terminate();a(null,l)}}),c.push(h)}for(var f=0;f<o;++f)c[f].postMessage(f)}function s(o,a){for(var c=[],l=0;l<o;++l)for(var f=a[l],h=c[l]=[],p=0;p<o;++p)if(l!==p){var d=a[p];(f.st>d.st&&f.st<d.et||d.st>f.st&&d.st<f.et)&&h.push(p)}return c.reduce(function(m,y){return Math.max(m,y.length)},0)}}});var wp=R((bke,TU)=>{u();var Tm=ft();Tm.pki=Tm.pki||{};var SS=TU.exports=Tm.pki.oids=Tm.oids=Tm.oids||{};function te(r,e){SS[r]=e,SS[e]=r}function $t(r,e){SS[r]=e}te("1.2.840.113549.1.1.1","rsaEncryption");te("1.2.840.113549.1.1.4","md5WithRSAEncryption");te("1.2.840.113549.1.1.5","sha1WithRSAEncryption");te("1.2.840.113549.1.1.7","RSAES-OAEP");te("1.2.840.113549.1.1.8","mgf1");te("1.2.840.113549.1.1.9","pSpecified");te("1.2.840.113549.1.1.10","RSASSA-PSS");te("1.2.840.113549.1.1.11","sha256WithRSAEncryption");te("1.2.840.113549.1.1.12","sha384WithRSAEncryption");te("1.2.840.113549.1.1.13","sha512WithRSAEncryption");te("1.3.101.112","EdDSA25519");te("1.2.840.10040.4.3","dsa-with-sha1");te("1.3.14.3.2.7","desCBC");te("1.3.14.3.2.26","sha1");te("1.3.14.3.2.29","sha1WithRSASignature");te("2.16.840.1.101.3.4.2.1","sha256");te("2.16.840.1.101.3.4.2.2","sha384");te("2.16.840.1.101.3.4.2.3","sha512");te("2.16.840.1.101.3.4.2.4","sha224");te("2.16.840.1.101.3.4.2.5","sha512-224");te("2.16.840.1.101.3.4.2.6","sha512-256");te("1.2.840.113549.2.2","md2");te("1.2.840.113549.2.5","md5");te("1.2.840.113549.1.7.1","data");te("1.2.840.113549.1.7.2","signedData");te("1.2.840.113549.1.7.3","envelopedData");te("1.2.840.113549.1.7.4","signedAndEnvelopedData");te("1.2.840.113549.1.7.5","digestedData");te("1.2.840.113549.1.7.6","encryptedData");te("1.2.840.113549.1.9.1","emailAddress");te("1.2.840.113549.1.9.2","unstructuredName");te("1.2.840.113549.1.9.3","contentType");te("1.2.840.113549.1.9.4","messageDigest");te("1.2.840.113549.1.9.5","signingTime");te("1.2.840.113549.1.9.6","counterSignature");te("1.2.840.113549.1.9.7","challengePassword");te("1.2.840.113549.1.9.8","unstructuredAddress");te("1.2.840.113549.1.9.14","extensionRequest");te("1.2.840.113549.1.9.20","friendlyName");te("1.2.840.113549.1.9.21","localKeyId");te("1.2.840.113549.1.9.22.1","x509Certificate");te("1.2.840.113549.1.12.10.1.1","keyBag");te("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");te("1.2.840.113549.1.12.10.1.3","certBag");te("1.2.840.113549.1.12.10.1.4","crlBag");te("1.2.840.113549.1.12.10.1.5","secretBag");te("1.2.840.113549.1.12.10.1.6","safeContentsBag");te("1.2.840.113549.1.5.13","pkcs5PBES2");te("1.2.840.113549.1.5.12","pkcs5PBKDF2");te("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");te("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");te("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");te("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");te("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");te("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");te("1.2.840.113549.2.7","hmacWithSHA1");te("1.2.840.113549.2.8","hmacWithSHA224");te("1.2.840.113549.2.9","hmacWithSHA256");te("1.2.840.113549.2.10","hmacWithSHA384");te("1.2.840.113549.2.11","hmacWithSHA512");te("1.2.840.113549.3.7","des-EDE3-CBC");te("2.16.840.1.101.3.4.1.2","aes128-CBC");te("2.16.840.1.101.3.4.1.22","aes192-CBC");te("2.16.840.1.101.3.4.1.42","aes256-CBC");te("2.5.4.3","commonName");te("2.5.4.4","surname");te("2.5.4.5","serialNumber");te("2.5.4.6","countryName");te("2.5.4.7","localityName");te("2.5.4.8","stateOrProvinceName");te("2.5.4.9","streetAddress");te("2.5.4.10","organizationName");te("2.5.4.11","organizationalUnitName");te("2.5.4.12","title");te("2.5.4.13","description");te("2.5.4.15","businessCategory");te("2.5.4.17","postalCode");te("2.5.4.42","givenName");te("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");te("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");te("2.16.840.1.113730.1.1","nsCertType");te("2.16.840.1.113730.1.13","nsComment");$t("2.5.29.1","authorityKeyIdentifier");$t("2.5.29.2","keyAttributes");$t("2.5.29.3","certificatePolicies");$t("2.5.29.4","keyUsageRestriction");$t("2.5.29.5","policyMapping");$t("2.5.29.6","subtreesConstraint");$t("2.5.29.7","subjectAltName");$t("2.5.29.8","issuerAltName");$t("2.5.29.9","subjectDirectoryAttributes");$t("2.5.29.10","basicConstraints");$t("2.5.29.11","nameConstraints");$t("2.5.29.12","policyConstraints");$t("2.5.29.13","basicConstraints");te("2.5.29.14","subjectKeyIdentifier");te("2.5.29.15","keyUsage");$t("2.5.29.16","privateKeyUsagePeriod");te("2.5.29.17","subjectAltName");te("2.5.29.18","issuerAltName");te("2.5.29.19","basicConstraints");$t("2.5.29.20","cRLNumber");$t("2.5.29.21","cRLReason");$t("2.5.29.22","expirationDate");$t("2.5.29.23","instructionCode");$t("2.5.29.24","invalidityDate");$t("2.5.29.25","cRLDistributionPoints");$t("2.5.29.26","issuingDistributionPoint");$t("2.5.29.27","deltaCRLIndicator");$t("2.5.29.28","issuingDistributionPoint");$t("2.5.29.29","certificateIssuer");$t("2.5.29.30","nameConstraints");te("2.5.29.31","cRLDistributionPoints");te("2.5.29.32","certificatePolicies");$t("2.5.29.33","policyMappings");$t("2.5.29.34","policyConstraints");te("2.5.29.35","authorityKeyIdentifier");$t("2.5.29.36","policyConstraints");te("2.5.29.37","extKeyUsage");$t("2.5.29.46","freshestCRL");$t("2.5.29.54","inhibitAnyPolicy");te("1.3.6.1.4.1.11129.2.4.2","timestampList");te("1.3.6.1.5.5.7.1.1","authorityInfoAccess");te("1.3.6.1.5.5.7.3.1","serverAuth");te("1.3.6.1.5.5.7.3.2","clientAuth");te("1.3.6.1.5.5.7.3.3","codeSigning");te("1.3.6.1.5.5.7.3.4","emailProtection");te("1.3.6.1.5.5.7.3.8","timeStamping")});var eu=R((vke,AU)=>{u();var hr=ft();sr();wp();var me=AU.exports=hr.asn1=hr.asn1||{};me.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};me.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};me.create=function(r,e,t,n,i){if(hr.util.isArray(n)){for(var s=[],o=0;o<n.length;++o)n[o]!==void 0&&s.push(n[o]);n=s}var a={tagClass:r,type:e,constructed:t,composed:t||hr.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(a.bitStringContents=i.bitStringContents,a.original=me.copy(a)),a};me.copy=function(r,e){var t;if(hr.util.isArray(r)){t=[];for(var n=0;n<r.length;++n)t.push(me.copy(r[n],e));return t}return typeof r=="string"?r:(t={tagClass:r.tagClass,type:r.type,constructed:r.constructed,composed:r.composed,value:me.copy(r.value,e)},e&&!e.excludeBitStringContents&&(t.bitStringContents=r.bitStringContents),t)};me.equals=function(r,e,t){if(hr.util.isArray(r)){if(!hr.util.isArray(e)||r.length!==e.length)return!1;for(var n=0;n<r.length;++n)if(!me.equals(r[n],e[n]))return!1;return!0}if(typeof r!=typeof e)return!1;if(typeof r=="string")return r===e;var i=r.tagClass===e.tagClass&&r.type===e.type&&r.constructed===e.constructed&&r.composed===e.composed&&me.equals(r.value,e.value);return t&&t.includeBitStringContents&&(i=i&&r.bitStringContents===e.bitStringContents),i};me.getBerValueLength=function(r){var e=r.getByte();if(e!==128){var t,n=e&128;return n?t=r.getInt((e&127)<<3):t=e,t}};function Im(r,e,t){if(t>e){var n=new Error("Too few bytes to parse DER.");throw n.available=r.length(),n.remaining=e,n.requested=t,n}}var H1e=function(r,e){var t=r.getByte();if(e--,t!==128){var n,i=t&128;if(!i)n=t;else{var s=t&127;Im(r,e,s),n=r.getInt(s<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};me.fromDer=function(r,e){e===void 0&&(e={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof e=="boolean"&&(e={strict:e,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in e||(e.strict=!0),"parseAllBytes"in e||(e.parseAllBytes=!0),"decodeBitStrings"in e||(e.decodeBitStrings=!0),typeof r=="string"&&(r=hr.util.createBuffer(r));var t=r.length(),n=hw(r,r.length(),0,e);if(e.parseAllBytes&&r.length()!==0){var i=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw i.byteCount=t,i.remaining=r.length(),i}return n};function hw(r,e,t,n){var i;Im(r,e,2);var s=r.getByte();e--;var o=s&192,a=s&31;i=r.length();var c=H1e(r,e);if(e-=i-r.length(),c!==void 0&&c>e){if(n.strict){var l=new Error("Too few bytes to read ASN.1 value.");throw l.available=r.length(),l.remaining=e,l.requested=c,l}c=e}var f,h,p=(s&32)===32;if(p)if(f=[],c===void 0)for(;;){if(Im(r,e,2),r.bytes(2)===String.fromCharCode(0,0)){r.getBytes(2),e-=2;break}i=r.length(),f.push(hw(r,e,t+1,n)),e-=i-r.length()}else for(;c>0;)i=r.length(),f.push(hw(r,c,t+1,n)),e-=i-r.length(),c-=i-r.length();if(f===void 0&&o===me.Class.UNIVERSAL&&a===me.Type.BITSTRING&&(h=r.bytes(c)),f===void 0&&n.decodeBitStrings&&o===me.Class.UNIVERSAL&&a===me.Type.BITSTRING&&c>1){var d=r.read,m=e,y=0;if(a===me.Type.BITSTRING&&(Im(r,e,1),y=r.getByte(),e--),y===0)try{i=r.length();var g={strict:!0,decodeBitStrings:!0},w=hw(r,e,t+1,g),b=i-r.length();e-=b,a==me.Type.BITSTRING&&b++;var S=w.tagClass;b===c&&(S===me.Class.UNIVERSAL||S===me.Class.CONTEXT_SPECIFIC)&&(f=[w])}catch{}f===void 0&&(r.read=d,e=m)}if(f===void 0){if(c===void 0){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");c=e}if(a===me.Type.BMPSTRING)for(f="";c>0;c-=2)Im(r,e,2),f+=String.fromCharCode(r.getInt16()),e-=2;else f=r.getBytes(c),e-=c}var _=h===void 0?null:{bitStringContents:h};return me.create(o,a,p,f,_)}me.toDer=function(r){var e=hr.util.createBuffer(),t=r.tagClass|r.type,n=hr.util.createBuffer(),i=!1;if("bitStringContents"in r&&(i=!0,r.original&&(i=me.equals(r,r.original))),i)n.putBytes(r.bitStringContents);else if(r.composed){r.constructed?t|=32:n.putByte(0);for(var s=0;s<r.value.length;++s)r.value[s]!==void 0&&n.putBuffer(me.toDer(r.value[s]))}else if(r.type===me.Type.BMPSTRING)for(var s=0;s<r.value.length;++s)n.putInt16(r.value.charCodeAt(s));else r.type===me.Type.INTEGER&&r.value.length>1&&(r.value.charCodeAt(0)===0&&(r.value.charCodeAt(1)&128)===0||r.value.charCodeAt(0)===255&&(r.value.charCodeAt(1)&128)===128)?n.putBytes(r.value.substr(1)):n.putBytes(r.value);if(e.putByte(t),n.length()<=127)e.putByte(n.length()&127);else{var o=n.length(),a="";do a+=String.fromCharCode(o&255),o=o>>>8;while(o>0);e.putByte(a.length|128);for(var s=a.length-1;s>=0;--s)e.putByte(a.charCodeAt(s))}return e.putBuffer(n),e};me.oidToDer=function(r){var e=r.split("."),t=hr.util.createBuffer();t.putByte(40*parseInt(e[0],10)+parseInt(e[1],10));for(var n,i,s,o,a=2;a<e.length;++a){n=!0,i=[],s=parseInt(e[a],10);do o=s&127,s=s>>>7,n||(o|=128),i.push(o),n=!1;while(s>0);for(var c=i.length-1;c>=0;--c)t.putByte(i[c])}return t};me.derToOid=function(r){var e;typeof r=="string"&&(r=hr.util.createBuffer(r));var t=r.getByte();e=Math.floor(t/40)+"."+t%40;for(var n=0;r.length()>0;)t=r.getByte(),n=n<<7,t&128?n+=t&127:(e+="."+(n+t),n=0);return e};me.utcTimeToDate=function(r){var e=new Date,t=parseInt(r.substr(0,2),10);t=t>=50?1900+t:2e3+t;var n=parseInt(r.substr(2,2),10)-1,i=parseInt(r.substr(4,2),10),s=parseInt(r.substr(6,2),10),o=parseInt(r.substr(8,2),10),a=0;if(r.length>11){var c=r.charAt(10),l=10;c!=="+"&&c!=="-"&&(a=parseInt(r.substr(10,2),10),l+=2)}if(e.setUTCFullYear(t,n,i),e.setUTCHours(s,o,a,0),l&&(c=r.charAt(l),c==="+"||c==="-")){var f=parseInt(r.substr(l+1,2),10),h=parseInt(r.substr(l+4,2),10),p=f*60+h;p*=6e4,c==="+"?e.setTime(+e-p):e.setTime(+e+p)}return e};me.generalizedTimeToDate=function(r){var e=new Date,t=parseInt(r.substr(0,4),10),n=parseInt(r.substr(4,2),10)-1,i=parseInt(r.substr(6,2),10),s=parseInt(r.substr(8,2),10),o=parseInt(r.substr(10,2),10),a=parseInt(r.substr(12,2),10),c=0,l=0,f=!1;r.charAt(r.length-1)==="Z"&&(f=!0);var h=r.length-5,p=r.charAt(h);if(p==="+"||p==="-"){var d=parseInt(r.substr(h+1,2),10),m=parseInt(r.substr(h+4,2),10);l=d*60+m,l*=6e4,p==="+"&&(l*=-1),f=!0}return r.charAt(14)==="."&&(c=parseFloat(r.substr(14),10)*1e3),f?(e.setUTCFullYear(t,n,i),e.setUTCHours(s,o,a,c),e.setTime(+e+l)):(e.setFullYear(t,n,i),e.setHours(s,o,a,c)),e};me.dateToUtcTime=function(r){if(typeof r=="string")return r;var e="",t=[];t.push((""+r.getUTCFullYear()).substr(2)),t.push(""+(r.getUTCMonth()+1)),t.push(""+r.getUTCDate()),t.push(""+r.getUTCHours()),t.push(""+r.getUTCMinutes()),t.push(""+r.getUTCSeconds());for(var n=0;n<t.length;++n)t[n].length<2&&(e+="0"),e+=t[n];return e+="Z",e};me.dateToGeneralizedTime=function(r){if(typeof r=="string")return r;var e="",t=[];t.push(""+r.getUTCFullYear()),t.push(""+(r.getUTCMonth()+1)),t.push(""+r.getUTCDate()),t.push(""+r.getUTCHours()),t.push(""+r.getUTCMinutes()),t.push(""+r.getUTCSeconds());for(var n=0;n<t.length;++n)t[n].length<2&&(e+="0"),e+=t[n];return e+="Z",e};me.integerToDer=function(r){var e=hr.util.createBuffer();if(r>=-128&&r<128)return e.putSignedInt(r,8);if(r>=-32768&&r<32768)return e.putSignedInt(r,16);if(r>=-8388608&&r<8388608)return e.putSignedInt(r,24);if(r>=-2147483648&&r<2147483648)return e.putSignedInt(r,32);var t=new Error("Integer too large; max is 32-bits.");throw t.integer=r,t};me.derToInteger=function(r){typeof r=="string"&&(r=hr.util.createBuffer(r));var e=r.length()*8;if(e>32)throw new Error("Integer too large; max is 32-bits.");return r.getSignedInt(e)};me.validate=function(r,e,t,n){var i=!1;if((r.tagClass===e.tagClass||typeof e.tagClass>"u")&&(r.type===e.type||typeof e.type>"u"))if(r.constructed===e.constructed||typeof e.constructed>"u"){if(i=!0,e.value&&hr.util.isArray(e.value))for(var s=0,o=0;i&&o<e.value.length;++o)i=e.value[o].optional||!1,r.value[s]&&(i=me.validate(r.value[s],e.value[o],t,n),i?++s:e.value[o].optional&&(i=!0)),!i&&n&&n.push("["+e.name+'] Tag class "'+e.tagClass+'", type "'+e.type+'" expected value length "'+e.value.length+'", got "'+r.value.length+'"');if(i&&t&&(e.capture&&(t[e.capture]=r.value),e.captureAsn1&&(t[e.captureAsn1]=r),e.captureBitStringContents&&"bitStringContents"in r&&(t[e.captureBitStringContents]=r.bitStringContents),e.captureBitStringValue&&"bitStringContents"in r)){var a;if(r.bitStringContents.length<2)t[e.captureBitStringValue]="";else{var c=r.bitStringContents.charCodeAt(0);if(c!==0)throw new Error("captureBitStringValue only supported for zero unused bits");t[e.captureBitStringValue]=r.bitStringContents.slice(1)}}}else n&&n.push("["+e.name+'] Expected constructed "'+e.constructed+'", got "'+r.constructed+'"');else n&&(r.tagClass!==e.tagClass&&n.push("["+e.name+'] Expected tag class "'+e.tagClass+'", got "'+r.tagClass+'"'),r.type!==e.type&&n.push("["+e.name+'] Expected type "'+e.type+'", got "'+r.type+'"'));return i};var IU=/[^\\u0000-\\u00ff]/;me.prettyPrint=function(r,e,t){var n="";e=e||0,t=t||2,e>0&&(n+=`
`);for(var i="",s=0;s<e*t;++s)i+=" ";switch(n+=i+"Tag: ",r.tagClass){case me.Class.UNIVERSAL:n+="Universal:";break;case me.Class.APPLICATION:n+="Application:";break;case me.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case me.Class.PRIVATE:n+="Private:";break}if(r.tagClass===me.Class.UNIVERSAL)switch(n+=r.type,r.type){case me.Type.NONE:n+=" (None)";break;case me.Type.BOOLEAN:n+=" (Boolean)";break;case me.Type.INTEGER:n+=" (Integer)";break;case me.Type.BITSTRING:n+=" (Bit string)";break;case me.Type.OCTETSTRING:n+=" (Octet string)";break;case me.Type.NULL:n+=" (Null)";break;case me.Type.OID:n+=" (Object Identifier)";break;case me.Type.ODESC:n+=" (Object Descriptor)";break;case me.Type.EXTERNAL:n+=" (External or Instance of)";break;case me.Type.REAL:n+=" (Real)";break;case me.Type.ENUMERATED:n+=" (Enumerated)";break;case me.Type.EMBEDDED:n+=" (Embedded PDV)";break;case me.Type.UTF8:n+=" (UTF8)";break;case me.Type.ROID:n+=" (Relative Object Identifier)";break;case me.Type.SEQUENCE:n+=" (Sequence)";break;case me.Type.SET:n+=" (Set)";break;case me.Type.PRINTABLESTRING:n+=" (Printable String)";break;case me.Type.IA5String:n+=" (IA5String (ASCII))";break;case me.Type.UTCTIME:n+=" (UTC time)";break;case me.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case me.Type.BMPSTRING:n+=" (BMP String)";break}else n+=r.type;if(n+=`
`,n+=i+"Constructed: "+r.constructed+`
`,r.composed){for(var o=0,a="",s=0;s<r.value.length;++s)r.value[s]!==void 0&&(o+=1,a+=me.prettyPrint(r.value[s],e+1,t),s+1<r.value.length&&(a+=","));n+=i+"Sub values: "+o+a}else{if(n+=i+"Value: ",r.type===me.Type.OID){var c=me.derToOid(r.value);n+=c,hr.pki&&hr.pki.oids&&c in hr.pki.oids&&(n+=" ("+hr.pki.oids[c]+") ")}if(r.type===me.Type.INTEGER)try{n+=me.derToInteger(r.value)}catch{n+="0x"+hr.util.bytesToHex(r.value)}else if(r.type===me.Type.BITSTRING){if(r.value.length>1?n+="0x"+hr.util.bytesToHex(r.value.slice(1)):n+="(none)",r.value.length>0){var l=r.value.charCodeAt(0);l==1?n+=" (1 unused bit shown)":l>1&&(n+=" ("+l+" unused bits shown)")}}else if(r.type===me.Type.OCTETSTRING)IU.test(r.value)||(n+="("+r.value+") "),n+="0x"+hr.util.bytesToHex(r.value);else if(r.type===me.Type.UTF8)try{n+=hr.util.decodeUtf8(r.value)}catch(f){if(f.message==="URI malformed")n+="0x"+hr.util.bytesToHex(r.value)+" (malformed UTF8)";else throw f}else r.type===me.Type.PRINTABLESTRING||r.type===me.Type.IA5String?n+=r.value:IU.test(r.value)?n+="0x"+hr.util.bytesToHex(r.value):r.value.length===0?n+="[null]":n+=r.value}return n}});var TS=R((_ke,RU)=>{u();var Cn=ft();sr();RU.exports=Cn.cipher=Cn.cipher||{};Cn.cipher.algorithms=Cn.cipher.algorithms||{};Cn.cipher.createCipher=function(r,e){var t=r;if(typeof t=="string"&&(t=Cn.cipher.getAlgorithm(t),t&&(t=t())),!t)throw new Error("Unsupported algorithm: "+r);return new Cn.cipher.BlockCipher({algorithm:t,key:e,decrypt:!1})};Cn.cipher.createDecipher=function(r,e){var t=r;if(typeof t=="string"&&(t=Cn.cipher.getAlgorithm(t),t&&(t=t())),!t)throw new Error("Unsupported algorithm: "+r);return new Cn.cipher.BlockCipher({algorithm:t,key:e,decrypt:!0})};Cn.cipher.registerAlgorithm=function(r,e){r=r.toUpperCase(),Cn.cipher.algorithms[r]=e};Cn.cipher.getAlgorithm=function(r){return r=r.toUpperCase(),r in Cn.cipher.algorithms?Cn.cipher.algorithms[r]:null};var xS=Cn.cipher.BlockCipher=function(r){this.algorithm=r.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=r.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=r.decrypt,this.algorithm.initialize(r)};xS.prototype.start=function(r){r=r||{};var e={};for(var t in r)e[t]=r[t];e.decrypt=this._decrypt,this._finish=!1,this._input=Cn.util.createBuffer(),this.output=r.output||Cn.util.createBuffer(),this.mode.start(e)};xS.prototype.update=function(r){for(r&&this._input.putBuffer(r);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};xS.prototype.finish=function(r){r&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(t){return r(this.blockSize,t,!1)},this.mode.unpad=function(t){return r(this.blockSize,t,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,e))}});var AS=R((Ske,CU)=>{u();var Pn=ft();sr();Pn.cipher=Pn.cipher||{};var ht=CU.exports=Pn.cipher.modes=Pn.cipher.modes||{};ht.ecb=function(r){r=r||{},this.name="ECB",this.cipher=r.cipher,this.blockSize=r.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};ht.ecb.prototype.start=function(r){};ht.ecb.prototype.encrypt=function(r,e,t){if(r.length()<this.blockSize&&!(t&&r.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=r.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};ht.ecb.prototype.decrypt=function(r,e,t){if(r.length()<this.blockSize&&!(t&&r.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=r.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};ht.ecb.prototype.pad=function(r,e){var t=r.length()===this.blockSize?this.blockSize:this.blockSize-r.length();return r.fillWithByte(t,t),!0};ht.ecb.prototype.unpad=function(r,e){if(e.overflow>0)return!1;var t=r.length(),n=r.at(t-1);return n>this.blockSize<<2?!1:(r.truncate(n),!0)};ht.cbc=function(r){r=r||{},this.name="CBC",this.cipher=r.cipher,this.blockSize=r.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};ht.cbc.prototype.start=function(r){if(r.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in r)this._iv=dw(r.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};ht.cbc.prototype.encrypt=function(r,e,t){if(r.length()<this.blockSize&&!(t&&r.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^r.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n]);this._prev=this._outBlock};ht.cbc.prototype.decrypt=function(r,e,t){if(r.length()<this.blockSize&&!(t&&r.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=r.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)};ht.cbc.prototype.pad=function(r,e){var t=r.length()===this.blockSize?this.blockSize:this.blockSize-r.length();return r.fillWithByte(t,t),!0};ht.cbc.prototype.unpad=function(r,e){if(e.overflow>0)return!1;var t=r.length(),n=r.at(t-1);return n>this.blockSize<<2?!1:(r.truncate(n),!0)};ht.cfb=function(r){r=r||{},this.name="CFB",this.cipher=r.cipher,this.blockSize=r.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=Pn.util.createBuffer(),this._partialBytes=0};ht.cfb.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");this._iv=dw(r.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};ht.cfb.prototype.encrypt=function(r,e,t){var n=r.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=r.getInt32()^this._outBlock[i],e.putInt32(this._inBlock[i]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=r.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(s>0)r.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!t)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};ht.cfb.prototype.decrypt=function(r,e,t){var n=r.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=r.getInt32(),e.putInt32(this._inBlock[i]^this._outBlock[i]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=r.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(s>0)r.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!t)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};ht.ofb=function(r){r=r||{},this.name="OFB",this.cipher=r.cipher,this.blockSize=r.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Pn.util.createBuffer(),this._partialBytes=0};ht.ofb.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");this._iv=dw(r.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};ht.ofb.prototype.encrypt=function(r,e,t){var n=r.length();if(r.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(r.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(r.getInt32()^this._outBlock[i]);if(s>0)r.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!t)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};ht.ofb.prototype.decrypt=ht.ofb.prototype.encrypt;ht.ctr=function(r){r=r||{},this.name="CTR",this.cipher=r.cipher,this.blockSize=r.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Pn.util.createBuffer(),this._partialBytes=0};ht.ctr.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");this._iv=dw(r.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};ht.ctr.prototype.encrypt=function(r,e,t){var n=r.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize)for(var i=0;i<this._ints;++i)e.putInt32(r.getInt32()^this._outBlock[i]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(r.getInt32()^this._outBlock[i]);if(s>0&&(r.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!t)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}pw(this._inBlock)};ht.ctr.prototype.decrypt=ht.ctr.prototype.encrypt;ht.gcm=function(r){r=r||{},this.name="GCM",this.cipher=r.cipher,this.blockSize=r.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=Pn.util.createBuffer(),this._partialBytes=0,this._R=3774873600};ht.gcm.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");var e=Pn.util.createBuffer(r.iv);this._cipherLength=0;var t;if("additionalData"in r?t=Pn.util.createBuffer(r.additionalData):t=Pn.util.createBuffer(),"tagLength"in r?this._tagLength=r.tagLength:this._tagLength=128,this._tag=null,r.decrypt&&(this._tag=Pn.util.createBuffer(r.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 n=e.length();if(n===12)this._j0=[e.getInt32(),e.getInt32(),e.getInt32(),1];else{for(this._j0=[0,0,0,0];e.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(IS(n*8)))}this._inBlock=this._j0.slice(0),pw(this._inBlock),this._partialBytes=0,t=Pn.util.createBuffer(t),this._aDataLength=IS(t.length()*8);var i=t.length()%this.blockSize;for(i&&t.fillWithByte(0,this.blockSize-i),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()])};ht.gcm.prototype.encrypt=function(r,e,t){var n=r.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^=r.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(r.getInt32()^this._outBlock[i]);if(s<=0||t){if(t){var o=n%this.blockSize;this._cipherLength+=o,this._partialOutput.truncate(this.blockSize-o)}else this._cipherLength+=this.blockSize;for(var 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),s>0&&!t)return r.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),pw(this._inBlock)};ht.gcm.prototype.decrypt=function(r,e,t){var n=r.length();if(n<this.blockSize&&!(t&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),pw(this._inBlock),this._hashBlock[0]=r.getInt32(),this._hashBlock[1]=r.getInt32(),this._hashBlock[2]=r.getInt32(),this._hashBlock[3]=r.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize};ht.gcm.prototype.afterFinish=function(r,e){var t=!0;e.decrypt&&e.overflow&&r.truncate(this.blockSize-e.overflow),this.tag=Pn.util.createBuffer();var n=this._aDataLength.concat(IS(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^i[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),e.decrypt&&this.tag.bytes()!==this._tag&&(t=!1),t};ht.gcm.prototype.multiply=function(r,e){for(var t=[0,0,0,0],n=e.slice(0),i=0;i<128;++i){var s=r[i/32|0]&1<<31-i%32;s&&(t[0]^=n[0],t[1]^=n[1],t[2]^=n[2],t[3]^=n[3]),this.pow(n,n)}return t};ht.gcm.prototype.pow=function(r,e){for(var t=r[3]&1,n=3;n>0;--n)e[n]=r[n]>>>1|(r[n-1]&1)<<31;e[0]=r[0]>>>1,t&&(e[0]^=this._R)};ht.gcm.prototype.tableMultiply=function(r){for(var e=[0,0,0,0],t=0;t<32;++t){var n=t/8|0,i=r[n]>>>(7-t%8)*4&15,s=this._m[t][i];e[0]^=s[0],e[1]^=s[1],e[2]^=s[2],e[3]^=s[3]}return e};ht.gcm.prototype.ghash=function(r,e,t){return e[0]^=t[0],e[1]^=t[1],e[2]^=t[2],e[3]^=t[3],this.tableMultiply(e)};ht.gcm.prototype.generateHashTable=function(r,e){for(var t=8/e,n=4*t,i=16*t,s=new Array(i),o=0;o<i;++o){var a=[0,0,0,0],c=o/n|0,l=(n-1-o%n)*e;a[c]=1<<e-1<<l,s[o]=this.generateSubHashTable(this.multiply(a,r),e)}return s};ht.gcm.prototype.generateSubHashTable=function(r,e){var t=1<<e,n=t>>>1,i=new Array(t);i[n]=r.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s<n;){for(var o=1;o<s;++o){var a=i[s],c=i[o];i[s+o]=[a[0]^c[0],a[1]^c[1],a[2]^c[2],a[3]^c[3]]}s*=2}for(i[0]=[0,0,0,0],s=n+1;s<t;++s){var l=i[s^n];i[s]=[r[0]^l[0],r[1]^l[1],r[2]^l[2],r[3]^l[3]]}return i};function dw(r,e){if(typeof r=="string"&&(r=Pn.util.createBuffer(r)),Pn.util.isArray(r)&&r.length>4){var t=r;r=Pn.util.createBuffer();for(var n=0;n<t.length;++n)r.putByte(t[n])}if(r.length()<e)throw new Error("Invalid IV length; got "+r.length()+" bytes and expected "+e+" bytes.");if(!Pn.util.isArray(r)){for(var i=[],s=e/4,n=0;n<s;++n)i.push(r.getInt32());r=i}return r}function pw(r){r[r.length-1]=r[r.length-1]+1&4294967295}function IS(r){return[r/4294967296|0,r&4294967295]}});var vp=R((xke,kU)=>{u();var or=ft();TS();AS();sr();kU.exports=or.aes=or.aes||{};or.aes.startEncrypting=function(r,e,t,n){var i=mw({key:r,output:t,decrypt:!1,mode:n});return i.start(e),i};or.aes.createEncryptionCipher=function(r,e){return mw({key:r,output:null,decrypt:!1,mode:e})};or.aes.startDecrypting=function(r,e,t,n){var i=mw({key:r,output:t,decrypt:!0,mode:n});return i.start(e),i};or.aes.createDecryptionCipher=function(r,e){return mw({key:r,output:null,decrypt:!0,mode:e})};or.aes.Algorithm=function(r,e){PS||DU();var t=this;t.name=r,t.mode=new e({blockSize:16,cipher:{encrypt:function(n,i){return CS(t._w,n,i,!1)},decrypt:function(n,i){return CS(t._w,n,i,!0)}}}),t._init=!1};or.aes.Algorithm.prototype.initialize=function(r){if(!this._init){var e=r.key,t;if(typeof e=="string"&&(e.length===16||e.length===24||e.length===32))e=or.util.createBuffer(e);else if(or.util.isArray(e)&&(e.length===16||e.length===24||e.length===32)){t=e,e=or.util.createBuffer();for(var n=0;n<t.length;++n)e.putByte(t[n])}if(!or.util.isArray(e)){t=e,e=[];var i=t.length();if(i===16||i===24||i===32){i=i>>>2;for(var n=0;n<i;++n)e.push(t.getInt32())}}if(!or.util.isArray(e)||!(e.length===4||e.length===6||e.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,o=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=OU(e,r.decrypt&&!o),this._init=!0}};or.aes._expandKey=function(r,e){return PS||DU(),OU(r,e)};or.aes._updateBlock=CS;bp("AES-ECB",or.cipher.modes.ecb);bp("AES-CBC",or.cipher.modes.cbc);bp("AES-CFB",or.cipher.modes.cfb);bp("AES-OFB",or.cipher.modes.ofb);bp("AES-CTR",or.cipher.modes.ctr);bp("AES-GCM",or.cipher.modes.gcm);function bp(r,e){var t=function(){return new or.aes.Algorithm(r,e)};or.cipher.registerAlgorithm(r,t)}var PS=!1,Ep=4,li,RS,PU,zf,So;function DU(){PS=!0,PU=[0,1,2,4,8,16,32,64,128,27,54];for(var r=new Array(256),e=0;e<128;++e)r[e]=e<<1,r[e+128]=e+128<<1^283;li=new Array(256),RS=new Array(256),zf=new Array(4),So=new Array(4);for(var e=0;e<4;++e)zf[e]=new Array(256),So[e]=new Array(256);for(var t=0,n=0,i,s,o,a,c,l,f,e=0;e<256;++e){a=n^n<<1^n<<2^n<<3^n<<4,a=a>>8^a&255^99,li[t]=a,RS[a]=t,c=r[a],i=r[t],s=r[i],o=r[s],l=c<<24^a<<16^a<<8^(a^c),f=(i^s^o)<<24^(t^o)<<16^(t^s^o)<<8^(t^i^o);for(var h=0;h<4;++h)zf[h][t]=l,So[h][a]=f,l=l<<24|l>>>8,f=f<<24|f>>>8;t===0?t=n=1:(t=i^r[r[r[i^o]]],n^=r[r[n]])}}function OU(r,e){for(var t=r.slice(0),n,i=1,s=t.length,o=s+6+1,a=Ep*o,c=s;c<a;++c)n=t[c-1],c%s===0?(n=li[n>>>16&255]<<24^li[n>>>8&255]<<16^li[n&255]<<8^li[n>>>24]^PU[i]<<24,i++):s>6&&c%s===4&&(n=li[n>>>24]<<24^li[n>>>16&255]<<16^li[n>>>8&255]<<8^li[n&255]),t[c]=t[c-s]^n;if(e){var l,f=So[0],h=So[1],p=So[2],d=So[3],m=t.slice(0);a=t.length;for(var c=0,y=a-Ep;c<a;c+=Ep,y-=Ep)if(c===0||c===a-Ep)m[c]=t[y],m[c+1]=t[y+3],m[c+2]=t[y+2],m[c+3]=t[y+1];else for(var g=0;g<Ep;++g)l=t[y+g],m[c+(3&-g)]=f[li[l>>>24]]^h[li[l>>>16&255]]^p[li[l>>>8&255]]^d[li[l&255]];t=m}return t}function CS(r,e,t,n){var i=r.length/4-1,s,o,a,c,l;n?(s=So[0],o=So[1],a=So[2],c=So[3],l=RS):(s=zf[0],o=zf[1],a=zf[2],c=zf[3],l=li);var f,h,p,d,m,y,g;f=e[0]^r[0],h=e[n?3:1]^r[1],p=e[2]^r[2],d=e[n?1:3]^r[3];for(var w=3,b=1;b<i;++b)m=s[f>>>24]^o[h>>>16&255]^a[p>>>8&255]^c[d&255]^r[++w],y=s[h>>>24]^o[p>>>16&255]^a[d>>>8&255]^c[f&255]^r[++w],g=s[p>>>24]^o[d>>>16&255]^a[f>>>8&255]^c[h&255]^r[++w],d=s[d>>>24]^o[f>>>16&255]^a[h>>>8&255]^c[p&255]^r[++w],f=m,h=y,p=g;t[0]=l[f>>>24]<<24^l[h>>>16&255]<<16^l[p>>>8&255]<<8^l[d&255]^r[++w],t[n?3:1]=l[h>>>24]<<24^l[p>>>16&255]<<16^l[d>>>8&255]<<8^l[f&255]^r[++w],t[2]=l[p>>>24]<<24^l[d>>>16&255]<<16^l[f>>>8&255]<<8^l[h&255]^r[++w],t[n?1:3]=l[d>>>24]<<24^l[f>>>16&255]<<16^l[h>>>8&255]<<8^l[p&255]^r[++w]}function mw(r){r=r||{};var e=(r.mode||"CBC").toUpperCase(),t="AES-"+e,n;r.decrypt?n=or.cipher.createDecipher(t,r.key):n=or.cipher.createCipher(t,r.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof or.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var gw=R((Tke,LU)=>{u();var gr=ft();TS();AS();sr();LU.exports=gr.des=gr.des||{};gr.des.startEncrypting=function(r,e,t,n){var i=yw({key:r,output:t,decrypt:!1,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};gr.des.createEncryptionCipher=function(r,e){return yw({key:r,output:null,decrypt:!1,mode:e})};gr.des.startDecrypting=function(r,e,t,n){var i=yw({key:r,output:t,decrypt:!0,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};gr.des.createDecryptionCipher=function(r,e){return yw({key:r,output:null,decrypt:!0,mode:e})};gr.des.Algorithm=function(r,e){var t=this;t.name=r,t.mode=new e({blockSize:8,cipher:{encrypt:function(n,i){return NU(t._keys,n,i,!1)},decrypt:function(n,i){return NU(t._keys,n,i,!0)}}}),t._init=!1};gr.des.Algorithm.prototype.initialize=function(r){if(!this._init){var e=gr.util.createBuffer(r.key);if(this.name.indexOf("3DES")===0&&e.length()!==24)throw new Error("Invalid Triple-DES key size: "+e.length()*8);this._keys=eme(e),this._init=!0}};ba("DES-ECB",gr.cipher.modes.ecb);ba("DES-CBC",gr.cipher.modes.cbc);ba("DES-CFB",gr.cipher.modes.cfb);ba("DES-OFB",gr.cipher.modes.ofb);ba("DES-CTR",gr.cipher.modes.ctr);ba("3DES-ECB",gr.cipher.modes.ecb);ba("3DES-CBC",gr.cipher.modes.cbc);ba("3DES-CFB",gr.cipher.modes.cfb);ba("3DES-OFB",gr.cipher.modes.ofb);ba("3DES-CTR",gr.cipher.modes.ctr);function ba(r,e){var t=function(){return new gr.des.Algorithm(r,e)};gr.cipher.registerAlgorithm(r,t)}var G1e=[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],j1e=[-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],W1e=[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],Y1e=[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],Q1e=[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],X1e=[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],Z1e=[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],J1e=[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 eme(r){for(var e=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],t=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[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],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],a=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],h=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],m=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=r.length()>8?3:1,g=[],w=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,S,_=0;_<y;_++){var I=r.getInt32(),T=r.getInt32();S=(I>>>4^T)&252645135,T^=S,I^=S<<4,S=(T>>>-16^I)&65535,I^=S,T^=S<<-16,S=(I>>>2^T)&858993459,T^=S,I^=S<<2,S=(T>>>-16^I)&65535,I^=S,T^=S<<-16,S=(I>>>1^T)&1431655765,T^=S,I^=S<<1,S=(T>>>8^I)&16711935,I^=S,T^=S<<8,S=(I>>>1^T)&1431655765,T^=S,I^=S<<1,S=I<<8|T>>>20&240,I=T<<24|T<<8&16711680|T>>>8&65280|T>>>24&240,T=S;for(var x=0;x<w.length;++x){w[x]?(I=I<<2|I>>>26,T=T<<2|T>>>26):(I=I<<1|I>>>27,T=T<<1|T>>>27),I&=-15,T&=-15;var P=e[I>>>28]|t[I>>>24&15]|n[I>>>20&15]|i[I>>>16&15]|s[I>>>12&15]|o[I>>>8&15]|a[I>>>4&15],B=c[T>>>28]|l[T>>>24&15]|f[T>>>20&15]|h[T>>>16&15]|p[T>>>12&15]|d[T>>>8&15]|m[T>>>4&15];S=(B>>>16^P)&65535,g[b++]=P^S,g[b++]=B^S<<16}}return g}function NU(r,e,t,n){var i=r.length===32?3:9,s;i===3?s=n?[30,-2,-2]:[0,32,2]:s=n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var o,a=e[0],c=e[1];o=(a>>>4^c)&252645135,c^=o,a^=o<<4,o=(a>>>16^c)&65535,c^=o,a^=o<<16,o=(c>>>2^a)&858993459,a^=o,c^=o<<2,o=(c>>>8^a)&16711935,a^=o,c^=o<<8,o=(a>>>1^c)&1431655765,c^=o,a^=o<<1,a=a<<1|a>>>31,c=c<<1|c>>>31;for(var l=0;l<i;l+=3){for(var f=s[l+1],h=s[l+2],p=s[l];p!=f;p+=h){var d=c^r[p],m=(c>>>4|c<<28)^r[p+1];o=a,a=c,c=o^(j1e[d>>>24&63]|Y1e[d>>>16&63]|X1e[d>>>8&63]|J1e[d&63]|G1e[m>>>24&63]|W1e[m>>>16&63]|Q1e[m>>>8&63]|Z1e[m&63])}o=a,a=c,c=o}a=a>>>1|a<<31,c=c>>>1|c<<31,o=(a>>>1^c)&1431655765,c^=o,a^=o<<1,o=(c>>>8^a)&16711935,a^=o,c^=o<<8,o=(c>>>2^a)&858993459,a^=o,c^=o<<2,o=(a>>>16^c)&65535,c^=o,a^=o<<16,o=(a>>>4^c)&252645135,c^=o,a^=o<<4,t[0]=a,t[1]=c}function yw(r){r=r||{};var e=(r.mode||"CBC").toUpperCase(),t="DES-"+e,n;r.decrypt?n=gr.cipher.createDecipher(t,r.key):n=gr.cipher.createCipher(t,r.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof gr.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var tu=R((Ike,BU)=>{u();var ww=ft();BU.exports=ww.md=ww.md||{};ww.md.algorithms=ww.md.algorithms||{}});var UU=R((Ake,MU)=>{u();var Rc=ft();tu();sr();var tme=MU.exports=Rc.hmac=Rc.hmac||{};tme.create=function(){var r=null,e=null,t=null,n=null,i={};return i.start=function(s,o){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in Rc.md.algorithms)e=Rc.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else e=s;if(o===null)o=r;else{if(typeof o=="string")o=Rc.util.createBuffer(o);else if(Rc.util.isArray(o)){var a=o;o=Rc.util.createBuffer();for(var c=0;c<a.length;++c)o.putByte(a[c])}var l=o.length();l>e.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),t=Rc.util.createBuffer(),n=Rc.util.createBuffer(),l=o.length();for(var c=0;c<l;++c){var a=o.at(c);t.putByte(54^a),n.putByte(92^a)}if(l<e.blockLength)for(var a=e.blockLength-l,c=0;c<a;++c)t.putByte(54),n.putByte(92);r=o,t=t.bytes(),n=n.bytes()}e.start(),e.update(t)},i.update=function(s){e.update(s)},i.getMac=function(){var s=e.digest().bytes();return e.start(),e.update(n),e.update(s),e.digest()},i.digest=i.getMac,i}});var ru=R(()=>{u()});var DS=R((Pke,FU)=>{u();var ui=ft();UU();tu();sr();var rme=ui.pkcs5=ui.pkcs5||{},Cc;ui.util.isNodejs&&!ui.options.usePureJavaScript&&(Cc=ru());FU.exports=ui.pbkdf2=rme.pbkdf2=function(r,e,t,n,i,s){if(typeof i=="function"&&(s=i,i=null),ui.util.isNodejs&&!ui.options.usePureJavaScript&&Cc.pbkdf2&&(i===null||typeof i!="object")&&(Cc.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),r=Buffer.from(r,"binary"),e=Buffer.from(e,"binary"),s?Cc.pbkdf2Sync.length===4?Cc.pbkdf2(r,e,t,n,function(S,_){if(S)return s(S);s(null,_.toString("binary"))}):Cc.pbkdf2(r,e,t,n,i,function(S,_){if(S)return s(S);s(null,_.toString("binary"))}):Cc.pbkdf2Sync.length===4?Cc.pbkdf2Sync(r,e,t,n).toString("binary"):Cc.pbkdf2Sync(r,e,t,n,i).toString("binary");if((typeof i>"u"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in ui.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=ui.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var a=new Error("Derived key is too long.");if(s)return s(a);throw a}var c=Math.ceil(n/o),l=n-(c-1)*o,f=ui.hmac.create();f.start(i,r);var h="",p,d,m;if(!s){for(var y=1;y<=c;++y){f.start(null,null),f.update(e),f.update(ui.util.int32ToBytes(y)),p=m=f.digest().getBytes();for(var g=2;g<=t;++g)f.start(null,null),f.update(m),d=f.digest().getBytes(),p=ui.util.xorBytes(p,d,o),m=d;h+=y<c?p:p.substr(0,l)}return h}var y=1,g;function w(){if(y>c)return s(null,h);f.start(null,null),f.update(e),f.update(ui.util.int32ToBytes(y)),p=m=f.digest().getBytes(),g=2,b()}function b(){if(g<=t)return f.start(null,null),f.update(m),d=f.digest().getBytes(),p=ui.util.xorBytes(p,d,o),m=d,++g,ui.util.setImmediate(b);h+=y<c?p:p.substr(0,l),++y,w()}w()}});var vw=R((Dke,KU)=>{u();var bw=ft();sr();var VU=KU.exports=bw.pem=bw.pem||{};VU.encode=function(r,e){e=e||{};var t="-----BEGIN "+r.type+`-----\r
`,n;if(r.procType&&(n={name:"Proc-Type",values:[String(r.procType.version),r.procType.type]},t+=Ew(n)),r.contentDomain&&(n={name:"Content-Domain",values:[r.contentDomain]},t+=Ew(n)),r.dekInfo&&(n={name:"DEK-Info",values:[r.dekInfo.algorithm]},r.dekInfo.parameters&&n.values.push(r.dekInfo.parameters),t+=Ew(n)),r.headers)for(var i=0;i<r.headers.length;++i)t+=Ew(r.headers[i]);return r.procType&&(t+=`\r
`),t+=bw.util.encode64(r.body,e.maxline||64)+`\r
`,t+="-----END "+r.type+`-----\r
`,t};VU.decode=function(r){for(var e=[],t=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,n=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,i=/\r?\n/,s;s=t.exec(r),!!s;){var o=s[1];o==="NEW CERTIFICATE REQUEST"&&(o="CERTIFICATE REQUEST");var a={type:o,procType:null,contentDomain:null,dekInfo:null,headers:[],body:bw.util.decode64(s[3])};if(e.push(a),!!s[2]){for(var c=s[2].split(i),l=0;s&&l<c.length;){for(var f=c[l].replace(/\s+$/,""),h=l+1;h<c.length;++h){var p=c[h];if(!/\s/.test(p[0]))break;f+=p,l=h}if(s=f.match(n),s){for(var d={name:s[1],values:[]},m=s[2].split(","),y=0;y<m.length;++y)d.values.push(nme(m[y]));if(a.procType)if(!a.contentDomain&&d.name==="Content-Domain")a.contentDomain=m[0]||"";else if(!a.dekInfo&&d.name==="DEK-Info"){if(d.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');a.dekInfo={algorithm:m[0],parameters:m[1]||null}}else a.headers.push(d);else{if(d.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(d.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');a.procType={version:m[0],type:m[1]}}}++l}if(a.procType==="ENCRYPTED"&&!a.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(e.length===0)throw new Error("Invalid PEM formatted message.");return e};function Ew(r){for(var e=r.name+": ",t=[],n=function(c,l){return" "+l},i=0;i<r.values.length;++i)t.push(r.values[i].replace(/^(\S+\r\n)/,n));e+=t.join(",")+`\r
`;for(var s=0,o=-1,i=0;i<e.length;++i,++s)if(s>65&&o!==-1){var a=e[o];a===","?(++o,e=e.substr(0,o)+`\r
`+e.substr(o)):e=e.substr(0,o)+`\r
`+a+e.substr(o+1),s=i-o-1,o=-1,++i}else(e[i]===" "||e[i]===" "||e[i]===",")&&(o=i);return e}function nme(r){return r.replace(/^\s+/,"")}});var jU=R((Oke,GU)=>{u();var va=ft();tu();sr();var zU=GU.exports=va.sha256=va.sha256||{};va.md.sha256=va.md.algorithms.sha256=zU;zU.create=function(){$U||ime();var r=null,e=va.util.createBuffer(),t=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=va.util.createBuffer(),r={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=va.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),qU(r,t,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=va.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(OS.substr(0,n.blockLength-o));for(var a,c,l=n.fullMessageLength[0]*8,f=0;f<n.fullMessageLength.length-1;++f)a=n.fullMessageLength[f+1]*8,c=a/4294967296>>>0,l+=c,i.putInt32(l>>>0),l=a>>>0;i.putInt32(l);var h={h0:r.h0,h1:r.h1,h2:r.h2,h3:r.h3,h4:r.h4,h5:r.h5,h6:r.h6,h7:r.h7};qU(h,t,i);var p=va.util.createBuffer();return p.putInt32(h.h0),p.putInt32(h.h1),p.putInt32(h.h2),p.putInt32(h.h3),p.putInt32(h.h4),p.putInt32(h.h5),p.putInt32(h.h6),p.putInt32(h.h7),p},n};var OS=null,$U=!1,HU=null;function ime(){OS=String.fromCharCode(128),OS+=va.util.fillString(String.fromCharCode(0),64),HU=[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],$U=!0}function qU(r,e,t){for(var n,i,s,o,a,c,l,f,h,p,d,m,y,g,w,b=t.length();b>=64;){for(l=0;l<16;++l)e[l]=t.getInt32();for(;l<64;++l)n=e[l-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=e[l-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[l]=n+e[l-7]+i+e[l-16]|0;for(f=r.h0,h=r.h1,p=r.h2,d=r.h3,m=r.h4,y=r.h5,g=r.h6,w=r.h7,l=0;l<64;++l)o=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),a=g^m&(y^g),s=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),c=f&h|p&(f^h),n=w+o+a+HU[l]+e[l],i=s+c,w=g,g=y,y=m,m=d+n>>>0,d=p,p=h,h=f,f=n+i>>>0;r.h0=r.h0+f|0,r.h1=r.h1+h|0,r.h2=r.h2+p|0,r.h3=r.h3+d|0,r.h4=r.h4+m|0,r.h5=r.h5+y|0,r.h6=r.h6+g|0,r.h7=r.h7+w|0,b-=64}}});var YU=R((kke,WU)=>{u();var _a=ft();sr();var _w=null;_a.util.isNodejs&&!_a.options.usePureJavaScript&&!process.versions["node-webkit"]&&(_w=ru());var sme=WU.exports=_a.prng=_a.prng||{};sme.create=function(r){for(var e={plugin:r,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},t=r.md,n=new Array(32),i=0;i<32;++i)n[i]=t.create();e.pools=n,e.pool=0,e.generate=function(l,f){if(!f)return e.generateSync(l);var h=e.plugin.cipher,p=e.plugin.increment,d=e.plugin.formatKey,m=e.plugin.formatSeed,y=_a.util.createBuffer();e.key=null,g();function g(w){if(w)return f(w);if(y.length()>=l)return f(null,y.getBytes(l));if(e.generated>1048575&&(e.key=null),e.key===null)return _a.util.nextTick(function(){s(g)});var b=h(e.key,e.seed);e.generated+=b.length,y.putBytes(b),e.key=d(h(e.key,p(e.seed))),e.seed=m(h(e.key,e.seed)),_a.util.setImmediate(g)}},e.generateSync=function(l){var f=e.plugin.cipher,h=e.plugin.increment,p=e.plugin.formatKey,d=e.plugin.formatSeed;e.key=null;for(var m=_a.util.createBuffer();m.length()<l;){e.generated>1048575&&(e.key=null),e.key===null&&o();var y=f(e.key,e.seed);e.generated+=y.length,m.putBytes(y),e.key=p(f(e.key,h(e.seed))),e.seed=d(f(e.key,e.seed))}return m.getBytes(l)};function s(l){if(e.pools[0].messageLength>=32)return a(),l();var f=32-e.pools[0].messageLength<<5;e.seedFile(f,function(h,p){if(h)return l(h);e.collect(p),a(),l()})}function o(){if(e.pools[0].messageLength>=32)return a();var l=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(l)),a()}function a(){e.reseeds=e.reseeds===4294967295?0:e.reseeds+1;var l=e.plugin.md.create();l.update(e.keyBytes);for(var f=1,h=0;h<32;++h)e.reseeds%f===0&&(l.update(e.pools[h].digest().getBytes()),e.pools[h].start()),f=f<<1;e.keyBytes=l.digest().getBytes(),l.start(),l.update(e.keyBytes);var p=l.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(p),e.generated=0}function c(l){var f=null,h=_a.util.globalScope,p=h.crypto||h.msCrypto;p&&p.getRandomValues&&(f=function(I){return p.getRandomValues(I)});var d=_a.util.createBuffer();if(f)for(;d.length()<l;){var m=Math.max(1,Math.min(l-d.length(),65536)/4),y=new Uint32Array(Math.floor(m));try{f(y);for(var g=0;g<y.length;++g)d.putInt32(y[g])}catch(I){if(!(typeof QuotaExceededError<"u"&&I instanceof QuotaExceededError))throw I}}if(d.length()<l)for(var w,b,S,_=Math.floor(Math.random()*65536);d.length()<l;){b=16807*(_&65535),w=16807*(_>>16),b+=(w&32767)<<16,b+=w>>15,b=(b&2147483647)+(b>>31),_=b&4294967295;for(var g=0;g<3;++g)S=_>>>(g<<3),S^=Math.floor(Math.random()*256),d.putByte(S&255)}return d.getBytes(l)}return _w?(e.seedFile=function(l,f){_w.randomBytes(l,function(h,p){if(h)return f(h);f(null,p.toString())})},e.seedFileSync=function(l){return _w.randomBytes(l).toString()}):(e.seedFile=function(l,f){try{f(null,c(l))}catch(h){f(h)}},e.seedFileSync=c),e.collect=function(l){for(var f=l.length,h=0;h<f;++h)e.pools[e.pool].update(l.substr(h,1)),e.pool=e.pool===31?0:e.pool+1},e.collectInt=function(l,f){for(var h="",p=0;p<f;p+=8)h+=String.fromCharCode(l>>p&255);e.collect(h)},e.registerWorker=function(l){if(l===self)e.seedFile=function(h,p){function d(m){var y=m.data;y.forge&&y.forge.prng&&(self.removeEventListener("message",d),p(y.forge.prng.err,y.forge.prng.bytes))}self.addEventListener("message",d),self.postMessage({forge:{prng:{needed:h}}})};else{var f=function(h){var p=h.data;p.forge&&p.forge.prng&&e.seedFile(p.forge.prng.needed,function(d,m){l.postMessage({forge:{prng:{err:d,bytes:m}}})})};l.addEventListener("message",f)}},e}});var $f=R((Nke,kS)=>{u();var Dn=ft();vp();jU();YU();sr();(function(){if(Dn.random&&Dn.random.getBytes){kS.exports=Dn.random;return}(function(r){var e={},t=new Array(4),n=Dn.util.createBuffer();e.formatKey=function(h){var p=Dn.util.createBuffer(h);return h=new Array(4),h[0]=p.getInt32(),h[1]=p.getInt32(),h[2]=p.getInt32(),h[3]=p.getInt32(),Dn.aes._expandKey(h,!1)},e.formatSeed=function(h){var p=Dn.util.createBuffer(h);return h=new Array(4),h[0]=p.getInt32(),h[1]=p.getInt32(),h[2]=p.getInt32(),h[3]=p.getInt32(),h},e.cipher=function(h,p){return Dn.aes._updateBlock(h,p,t,!1),n.putInt32(t[0]),n.putInt32(t[1]),n.putInt32(t[2]),n.putInt32(t[3]),n.getBytes()},e.increment=function(h){return++h[3],h},e.md=Dn.md.sha256;function i(){var h=Dn.prng.create(e);return h.getBytes=function(p,d){return h.generate(p,d)},h.getBytesSync=function(p){return h.generate(p)},h}var s=i(),o=null,a=Dn.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(o=function(h){return c.getRandomValues(h)}),Dn.options.usePureJavaScript||!Dn.util.isNodejs&&!o){if(typeof window>"u"||window.document,s.collectInt(+new Date,32),typeof navigator<"u"){var l="";for(var f in navigator)try{typeof navigator[f]=="string"&&(l+=navigator[f])}catch{}s.collect(l),l=null}r&&(r().mousemove(function(h){s.collectInt(h.clientX,16),s.collectInt(h.clientY,16)}),r().keypress(function(h){s.collectInt(h.charCode,8)}))}if(!Dn.random)Dn.random=s;else for(var f in s)Dn.random[f]=s[f];Dn.random.createInstance=i,kS.exports=Dn.random})(typeof jQuery<"u"?jQuery:null)})()});var JU=R((Lke,ZU)=>{u();var _i=ft();sr();var NS=[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],QU=[1,2,3,5],ome=function(r,e){return r<<e&65535|(r&65535)>>16-e},ame=function(r,e){return(r&65535)>>e|r<<16-e&65535};ZU.exports=_i.rc2=_i.rc2||{};_i.rc2.expandKey=function(r,e){typeof r=="string"&&(r=_i.util.createBuffer(r)),e=e||128;var t=r,n=r.length(),i=e,s=Math.ceil(i/8),o=255>>(i&7),a;for(a=n;a<128;a++)t.putByte(NS[t.at(a-1)+t.at(a-n)&255]);for(t.setAt(128-s,NS[t.at(128-s)&o]),a=127-s;a>=0;a--)t.setAt(a,NS[t.at(a+1)^t.at(a+s)]);return t};var XU=function(r,e,t){var n=!1,i=null,s=null,o=null,a,c,l,f,h=[];for(r=_i.rc2.expandKey(r,e),l=0;l<64;l++)h.push(r.getInt16Le());t?(a=function(m){for(l=0;l<4;l++)m[l]+=h[f]+(m[(l+3)%4]&m[(l+2)%4])+(~m[(l+3)%4]&m[(l+1)%4]),m[l]=ome(m[l],QU[l]),f++},c=function(m){for(l=0;l<4;l++)m[l]+=h[m[(l+3)%4]&63]}):(a=function(m){for(l=3;l>=0;l--)m[l]=ame(m[l],QU[l]),m[l]-=h[f]+(m[(l+3)%4]&m[(l+2)%4])+(~m[(l+3)%4]&m[(l+1)%4]),f--},c=function(m){for(l=3;l>=0;l--)m[l]-=h[m[(l+3)%4]&63]});var p=function(m){var y=[];for(l=0;l<4;l++){var g=i.getInt16Le();o!==null&&(t?g^=o.getInt16Le():o.putInt16Le(g)),y.push(g&65535)}f=t?0:63;for(var w=0;w<m.length;w++)for(var b=0;b<m[w][0];b++)m[w][1](y);for(l=0;l<4;l++)o!==null&&(t?o.putInt16Le(y[l]):y[l]^=o.getInt16Le()),s.putInt16Le(y[l])},d=null;return d={start:function(m,y){m&&typeof m=="string"&&(m=_i.util.createBuffer(m)),n=!1,i=_i.util.createBuffer(),s=y||new _i.util.createBuffer,o=m,d.output=s},update:function(m){for(n||i.putBuffer(m);i.length()>=8;)p([[5,a],[1,c],[6,a],[1,c],[5,a]])},finish:function(m){var y=!0;if(t)if(m)y=m(8,i,!t);else{var g=i.length()===8?8:8-i.length();i.fillWithByte(g,g)}if(y&&(n=!0,d.update()),!t&&(y=i.length()===0,y))if(m)y=m(8,s,!t);else{var w=s.length(),b=s.at(w-1);b>w?y=!1:s.truncate(b)}return y}},d};_i.rc2.startEncrypting=function(r,e,t){var n=_i.rc2.createEncryptionCipher(r,128);return n.start(e,t),n};_i.rc2.createEncryptionCipher=function(r,e){return XU(r,e,!0)};_i.rc2.startDecrypting=function(r,e,t){var n=_i.rc2.createDecryptionCipher(r,128);return n.start(e,t),n};_i.rc2.createDecryptionCipher=function(r,e){return XU(r,e,!1)}});var Tw=R((Bke,aF)=>{u();var LS=ft();aF.exports=LS.jsbn=LS.jsbn||{};var Pc,cme=0xdeadbeefcafe,eF=(cme&16777215)==15715070;function X(r,e,t){this.data=[],r!=null&&(typeof r=="number"?this.fromNumber(r,e,t):e==null&&typeof r!="string"?this.fromString(r,256):this.fromString(r,e))}LS.jsbn.BigInteger=X;function kt(){return new X(null)}function lme(r,e,t,n,i,s){for(;--s>=0;){var o=e*this.data[r++]+t.data[n]+i;i=Math.floor(o/67108864),t.data[n++]=o&67108863}return i}function ume(r,e,t,n,i,s){for(var o=e&32767,a=e>>15;--s>=0;){var c=this.data[r]&32767,l=this.data[r++]>>15,f=a*c+l*o;c=o*c+((f&32767)<<15)+t.data[n]+(i&1073741823),i=(c>>>30)+(f>>>15)+a*l+(i>>>30),t.data[n++]=c&1073741823}return i}function tF(r,e,t,n,i,s){for(var o=e&16383,a=e>>14;--s>=0;){var c=this.data[r]&16383,l=this.data[r++]>>14,f=a*c+l*o;c=o*c+((f&16383)<<14)+t.data[n]+i,i=(c>>28)+(f>>14)+a*l,t.data[n++]=c&268435455}return i}typeof navigator>"u"?(X.prototype.am=tF,Pc=28):eF&&navigator.appName=="Microsoft Internet Explorer"?(X.prototype.am=ume,Pc=30):eF&&navigator.appName!="Netscape"?(X.prototype.am=lme,Pc=26):(X.prototype.am=tF,Pc=28);X.prototype.DB=Pc;X.prototype.DM=(1<<Pc)-1;X.prototype.DV=1<<Pc;var BS=52;X.prototype.FV=Math.pow(2,BS);X.prototype.F1=BS-Pc;X.prototype.F2=2*Pc-BS;var fme="0123456789abcdefghijklmnopqrstuvwxyz",Sw=new Array,_p,ks;_p="0".charCodeAt(0);for(ks=0;ks<=9;++ks)Sw[_p++]=ks;_p="a".charCodeAt(0);for(ks=10;ks<36;++ks)Sw[_p++]=ks;_p="A".charCodeAt(0);for(ks=10;ks<36;++ks)Sw[_p++]=ks;function rF(r){return fme.charAt(r)}function nF(r,e){var t=Sw[r.charCodeAt(e)];return t??-1}function hme(r){for(var e=this.t-1;e>=0;--e)r.data[e]=this.data[e];r.t=this.t,r.s=this.s}function dme(r){this.t=1,this.s=r<0?-1:0,r>0?this.data[0]=r:r<-1?this.data[0]=r+this.DV:this.t=0}function nu(r){var e=kt();return e.fromInt(r),e}function pme(r,e){var t;if(e==16)t=4;else if(e==8)t=3;else if(e==256)t=8;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else{this.fromRadix(r,e);return}this.t=0,this.s=0;for(var n=r.length,i=!1,s=0;--n>=0;){var o=t==8?r[n]&255:nF(r,n);if(o<0){r.charAt(n)=="-"&&(i=!0);continue}i=!1,s==0?this.data[this.t++]=o:s+t>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this.data[this.t++]=o>>this.DB-s):this.data[this.t-1]|=o<<s,s+=t,s>=this.DB&&(s-=this.DB)}t==8&&(r[0]&128)!=0&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&X.ZERO.subTo(this,this)}function mme(){for(var r=this.s&this.DM;this.t>0&&this.data[this.t-1]==r;)--this.t}function yme(r){if(this.s<0)return"-"+this.negate().toString(r);var e;if(r==16)e=4;else if(r==8)e=3;else if(r==2)e=1;else if(r==32)e=5;else if(r==4)e=2;else return this.toRadix(r);var t=(1<<e)-1,n,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(n=this.data[o]>>a)>0&&(i=!0,s=rF(n));o>=0;)a<e?(n=(this.data[o]&(1<<a)-1)<<e-a,n|=this.data[--o]>>(a+=this.DB-e)):(n=this.data[o]>>(a-=e)&t,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=rF(n));return i?s:"0"}function gme(){var r=kt();return X.ZERO.subTo(this,r),r}function wme(){return this.s<0?this.negate():this}function Eme(r){var e=this.s-r.s;if(e!=0)return e;var t=this.t;if(e=t-r.t,e!=0)return this.s<0?-e:e;for(;--t>=0;)if((e=this.data[t]-r.data[t])!=0)return e;return 0}function xw(r){var e=1,t;return(t=r>>>16)!=0&&(r=t,e+=16),(t=r>>8)!=0&&(r=t,e+=8),(t=r>>4)!=0&&(r=t,e+=4),(t=r>>2)!=0&&(r=t,e+=2),(t=r>>1)!=0&&(r=t,e+=1),e}function bme(){return this.t<=0?0:this.DB*(this.t-1)+xw(this.data[this.t-1]^this.s&this.DM)}function vme(r,e){var t;for(t=this.t-1;t>=0;--t)e.data[t+r]=this.data[t];for(t=r-1;t>=0;--t)e.data[t]=0;e.t=this.t+r,e.s=this.s}function _me(r,e){for(var t=r;t<this.t;++t)e.data[t-r]=this.data[t];e.t=Math.max(this.t-r,0),e.s=this.s}function Sme(r,e){var t=r%this.DB,n=this.DB-t,i=(1<<n)-1,s=Math.floor(r/this.DB),o=this.s<<t&this.DM,a;for(a=this.t-1;a>=0;--a)e.data[a+s+1]=this.data[a]>>n|o,o=(this.data[a]&i)<<t;for(a=s-1;a>=0;--a)e.data[a]=0;e.data[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()}function xme(r,e){e.s=this.s;var t=Math.floor(r/this.DB);if(t>=this.t){e.t=0;return}var n=r%this.DB,i=this.DB-n,s=(1<<n)-1;e.data[0]=this.data[t]>>n;for(var o=t+1;o<this.t;++o)e.data[o-t-1]|=(this.data[o]&s)<<i,e.data[o-t]=this.data[o]>>n;n>0&&(e.data[this.t-t-1]|=(this.s&s)<<i),e.t=this.t-t,e.clamp()}function Tme(r,e){for(var t=0,n=0,i=Math.min(r.t,this.t);t<i;)n+=this.data[t]-r.data[t],e.data[t++]=n&this.DM,n>>=this.DB;if(r.t<this.t){for(n-=r.s;t<this.t;)n+=this.data[t],e.data[t++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;t<r.t;)n-=r.data[t],e.data[t++]=n&this.DM,n>>=this.DB;n-=r.s}e.s=n<0?-1:0,n<-1?e.data[t++]=this.DV+n:n>0&&(e.data[t++]=n),e.t=t,e.clamp()}function Ime(r,e){var t=this.abs(),n=r.abs(),i=t.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i<n.t;++i)e.data[i+t.t]=t.am(0,n.data[i],e,i,0,t.t);e.s=0,e.clamp(),this.s!=r.s&&X.ZERO.subTo(e,e)}function Ame(r){for(var e=this.abs(),t=r.t=2*e.t;--t>=0;)r.data[t]=0;for(t=0;t<e.t-1;++t){var n=e.am(t,e.data[t],r,2*t,0,1);(r.data[t+e.t]+=e.am(t+1,2*e.data[t],r,2*t+1,n,e.t-t-1))>=e.DV&&(r.data[t+e.t]-=e.DV,r.data[t+e.t+1]=1)}r.t>0&&(r.data[r.t-1]+=e.am(t,e.data[t],r,2*t,0,1)),r.s=0,r.clamp()}function Rme(r,e,t){var n=r.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t){e?.fromInt(0),t!=null&&this.copyTo(t);return}t==null&&(t=kt());var s=kt(),o=this.s,a=r.s,c=this.DB-xw(n.data[n.t-1]);c>0?(n.lShiftTo(c,s),i.lShiftTo(c,t)):(n.copyTo(s),i.copyTo(t));var l=s.t,f=s.data[l-1];if(f!=0){var h=f*(1<<this.F1)+(l>1?s.data[l-2]>>this.F2:0),p=this.FV/h,d=(1<<this.F1)/h,m=1<<this.F2,y=t.t,g=y-l,w=e??kt();for(s.dlShiftTo(g,w),t.compareTo(w)>=0&&(t.data[t.t++]=1,t.subTo(w,t)),X.ONE.dlShiftTo(l,w),w.subTo(s,s);s.t<l;)s.data[s.t++]=0;for(;--g>=0;){var b=t.data[--y]==f?this.DM:Math.floor(t.data[y]*p+(t.data[y-1]+m)*d);if((t.data[y]+=s.am(0,b,t,g,0,l))<b)for(s.dlShiftTo(g,w),t.subTo(w,t);t.data[y]<--b;)t.subTo(w,t)}e!=null&&(t.drShiftTo(l,e),o!=a&&X.ZERO.subTo(e,e)),t.t=l,t.clamp(),c>0&&t.rShiftTo(c,t),o<0&&X.ZERO.subTo(t,t)}}}function Cme(r){var e=kt();return this.abs().divRemTo(r,null,e),this.s<0&&e.compareTo(X.ZERO)>0&&r.subTo(e,e),e}function Hf(r){this.m=r}function Pme(r){return r.s<0||r.compareTo(this.m)>=0?r.mod(this.m):r}function Dme(r){return r}function Ome(r){r.divRemTo(this.m,null,r)}function kme(r,e,t){r.multiplyTo(e,t),this.reduce(t)}function Nme(r,e){r.squareTo(e),this.reduce(e)}Hf.prototype.convert=Pme;Hf.prototype.revert=Dme;Hf.prototype.reduce=Ome;Hf.prototype.mulTo=kme;Hf.prototype.sqrTo=Nme;function Lme(){if(this.t<1)return 0;var r=this.data[0];if((r&1)==0)return 0;var e=r&3;return e=e*(2-(r&15)*e)&15,e=e*(2-(r&255)*e)&255,e=e*(2-((r&65535)*e&65535))&65535,e=e*(2-r*e%this.DV)%this.DV,e>0?this.DV-e:-e}function Gf(r){this.m=r,this.mp=r.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<r.DB-15)-1,this.mt2=2*r.t}function Bme(r){var e=kt();return r.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),r.s<0&&e.compareTo(X.ZERO)>0&&this.m.subTo(e,e),e}function Mme(r){var e=kt();return r.copyTo(e),this.reduce(e),e}function Ume(r){for(;r.t<=this.mt2;)r.data[r.t++]=0;for(var e=0;e<this.m.t;++e){var t=r.data[e]&32767,n=t*this.mpl+((t*this.mph+(r.data[e]>>15)*this.mpl&this.um)<<15)&r.DM;for(t=e+this.m.t,r.data[t]+=this.m.am(0,n,r,e,0,this.m.t);r.data[t]>=r.DV;)r.data[t]-=r.DV,r.data[++t]++}r.clamp(),r.drShiftTo(this.m.t,r),r.compareTo(this.m)>=0&&r.subTo(this.m,r)}function Fme(r,e){r.squareTo(e),this.reduce(e)}function Vme(r,e,t){r.multiplyTo(e,t),this.reduce(t)}Gf.prototype.convert=Bme;Gf.prototype.revert=Mme;Gf.prototype.reduce=Ume;Gf.prototype.mulTo=Vme;Gf.prototype.sqrTo=Fme;function Kme(){return(this.t>0?this.data[0]&1:this.s)==0}function qme(r,e){if(r>4294967295||r<1)return X.ONE;var t=kt(),n=kt(),i=e.convert(this),s=xw(r)-1;for(i.copyTo(t);--s>=0;)if(e.sqrTo(t,n),(r&1<<s)>0)e.mulTo(n,i,t);else{var o=t;t=n,n=o}return e.revert(t)}function zme(r,e){var t;return r<256||e.isEven()?t=new Hf(e):t=new Gf(e),this.exp(r,t)}X.prototype.copyTo=hme;X.prototype.fromInt=dme;X.prototype.fromString=pme;X.prototype.clamp=mme;X.prototype.dlShiftTo=vme;X.prototype.drShiftTo=_me;X.prototype.lShiftTo=Sme;X.prototype.rShiftTo=xme;X.prototype.subTo=Tme;X.prototype.multiplyTo=Ime;X.prototype.squareTo=Ame;X.prototype.divRemTo=Rme;X.prototype.invDigit=Lme;X.prototype.isEven=Kme;X.prototype.exp=qme;X.prototype.toString=yme;X.prototype.negate=gme;X.prototype.abs=wme;X.prototype.compareTo=Eme;X.prototype.bitLength=bme;X.prototype.mod=Cme;X.prototype.modPowInt=zme;X.ZERO=nu(0);X.ONE=nu(1);function $me(){var r=kt();return this.copyTo(r),r}function Hme(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function Gme(){return this.t==0?this.s:this.data[0]<<24>>24}function jme(){return this.t==0?this.s:this.data[0]<<16>>16}function Wme(r){return Math.floor(Math.LN2*this.DB/Math.log(r))}function Yme(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function Qme(r){if(r==null&&(r=10),this.signum()==0||r<2||r>36)return"0";var e=this.chunkSize(r),t=Math.pow(r,e),n=nu(t),i=kt(),s=kt(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(t+s.intValue()).toString(r).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(r)+o}function Xme(r,e){this.fromInt(0),e==null&&(e=10);for(var t=this.chunkSize(e),n=Math.pow(e,t),i=!1,s=0,o=0,a=0;a<r.length;++a){var c=nF(r,a);if(c<0){r.charAt(a)=="-"&&this.signum()==0&&(i=!0);continue}o=e*o+c,++s>=t&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0)}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&X.ZERO.subTo(this,this)}function Zme(r,e,t){if(typeof e=="number")if(r<2)this.fromInt(1);else for(this.fromNumber(r,t),this.testBit(r-1)||this.bitwiseTo(X.ONE.shiftLeft(r-1),MS,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>r&&this.subTo(X.ONE.shiftLeft(r-1),this);else{var n=new Array,i=r&7;n.length=(r>>3)+1,e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}function Jme(){var r=this.t,e=new Array;e[0]=this.s;var t=this.DB-r*this.DB%8,n,i=0;if(r-- >0)for(t<this.DB&&(n=this.data[r]>>t)!=(this.s&this.DM)>>t&&(e[i++]=n|this.s<<this.DB-t);r>=0;)t<8?(n=(this.data[r]&(1<<t)-1)<<8-t,n|=this.data[--r]>>(t+=this.DB-8)):(n=this.data[r]>>(t-=8)&255,t<=0&&(t+=this.DB,--r)),(n&128)!=0&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e}function e2e(r){return this.compareTo(r)==0}function t2e(r){return this.compareTo(r)<0?this:r}function r2e(r){return this.compareTo(r)>0?this:r}function n2e(r,e,t){var n,i,s=Math.min(r.t,this.t);for(n=0;n<s;++n)t.data[n]=e(this.data[n],r.data[n]);if(r.t<this.t){for(i=r.s&this.DM,n=s;n<this.t;++n)t.data[n]=e(this.data[n],i);t.t=this.t}else{for(i=this.s&this.DM,n=s;n<r.t;++n)t.data[n]=e(i,r.data[n]);t.t=r.t}t.s=e(this.s,r.s),t.clamp()}function i2e(r,e){return r&e}function s2e(r){var e=kt();return this.bitwiseTo(r,i2e,e),e}function MS(r,e){return r|e}function o2e(r){var e=kt();return this.bitwiseTo(r,MS,e),e}function iF(r,e){return r^e}function a2e(r){var e=kt();return this.bitwiseTo(r,iF,e),e}function sF(r,e){return r&~e}function c2e(r){var e=kt();return this.bitwiseTo(r,sF,e),e}function l2e(){for(var r=kt(),e=0;e<this.t;++e)r.data[e]=this.DM&~this.data[e];return r.t=this.t,r.s=~this.s,r}function u2e(r){var e=kt();return r<0?this.rShiftTo(-r,e):this.lShiftTo(r,e),e}function f2e(r){var e=kt();return r<0?this.lShiftTo(-r,e):this.rShiftTo(r,e),e}function h2e(r){if(r==0)return-1;var e=0;return(r&65535)==0&&(r>>=16,e+=16),(r&255)==0&&(r>>=8,e+=8),(r&15)==0&&(r>>=4,e+=4),(r&3)==0&&(r>>=2,e+=2),(r&1)==0&&++e,e}function d2e(){for(var r=0;r<this.t;++r)if(this.data[r]!=0)return r*this.DB+h2e(this.data[r]);return this.s<0?this.t*this.DB:-1}function p2e(r){for(var e=0;r!=0;)r&=r-1,++e;return e}function m2e(){for(var r=0,e=this.s&this.DM,t=0;t<this.t;++t)r+=p2e(this.data[t]^e);return r}function y2e(r){var e=Math.floor(r/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<r%this.DB)!=0}function g2e(r,e){var t=X.ONE.shiftLeft(r);return this.bitwiseTo(t,e,t),t}function w2e(r){return this.changeBit(r,MS)}function E2e(r){return this.changeBit(r,sF)}function b2e(r){return this.changeBit(r,iF)}function v2e(r,e){for(var t=0,n=0,i=Math.min(r.t,this.t);t<i;)n+=this.data[t]+r.data[t],e.data[t++]=n&this.DM,n>>=this.DB;if(r.t<this.t){for(n+=r.s;t<this.t;)n+=this.data[t],e.data[t++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;t<r.t;)n+=r.data[t],e.data[t++]=n&this.DM,n>>=this.DB;n+=r.s}e.s=n<0?-1:0,n>0?e.data[t++]=n:n<-1&&(e.data[t++]=this.DV+n),e.t=t,e.clamp()}function _2e(r){var e=kt();return this.addTo(r,e),e}function S2e(r){var e=kt();return this.subTo(r,e),e}function x2e(r){var e=kt();return this.multiplyTo(r,e),e}function T2e(r){var e=kt();return this.divRemTo(r,e,null),e}function I2e(r){var e=kt();return this.divRemTo(r,null,e),e}function A2e(r){var e=kt(),t=kt();return this.divRemTo(r,e,t),new Array(e,t)}function R2e(r){this.data[this.t]=this.am(0,r-1,this,0,0,this.t),++this.t,this.clamp()}function C2e(r,e){if(r!=0){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=r;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}}function Am(){}function oF(r){return r}function P2e(r,e,t){r.multiplyTo(e,t)}function D2e(r,e){r.squareTo(e)}Am.prototype.convert=oF;Am.prototype.revert=oF;Am.prototype.mulTo=P2e;Am.prototype.sqrTo=D2e;function O2e(r){return this.exp(r,new Am)}function k2e(r,e,t){var n=Math.min(this.t+r.t,e);for(t.s=0,t.t=n;n>0;)t.data[--n]=0;var i;for(i=t.t-this.t;n<i;++n)t.data[n+this.t]=this.am(0,r.data[n],t,n,0,this.t);for(i=Math.min(r.t,e);n<i;++n)this.am(0,r.data[n],t,n,0,e-n);t.clamp()}function N2e(r,e,t){--e;var n=t.t=this.t+r.t-e;for(t.s=0;--n>=0;)t.data[n]=0;for(n=Math.max(e-this.t,0);n<r.t;++n)t.data[this.t+n-e]=this.am(e-n,r.data[n],t,0,0,this.t+n-e);t.clamp(),t.drShiftTo(1,t)}function Sp(r){this.r2=kt(),this.q3=kt(),X.ONE.dlShiftTo(2*r.t,this.r2),this.mu=this.r2.divide(r),this.m=r}function L2e(r){if(r.s<0||r.t>2*this.m.t)return r.mod(this.m);if(r.compareTo(this.m)<0)return r;var e=kt();return r.copyTo(e),this.reduce(e),e}function B2e(r){return r}function M2e(r){for(r.drShiftTo(this.m.t-1,this.r2),r.t>this.m.t+1&&(r.t=this.m.t+1,r.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);r.compareTo(this.r2)<0;)r.dAddOffset(1,this.m.t+1);for(r.subTo(this.r2,r);r.compareTo(this.m)>=0;)r.subTo(this.m,r)}function U2e(r,e){r.squareTo(e),this.reduce(e)}function F2e(r,e,t){r.multiplyTo(e,t),this.reduce(t)}Sp.prototype.convert=L2e;Sp.prototype.revert=B2e;Sp.prototype.reduce=M2e;Sp.prototype.mulTo=F2e;Sp.prototype.sqrTo=U2e;function V2e(r,e){var t=r.bitLength(),n,i=nu(1),s;if(t<=0)return i;t<18?n=1:t<48?n=3:t<144?n=4:t<768?n=5:n=6,t<8?s=new Hf(e):e.isEven()?s=new Sp(e):s=new Gf(e);var o=new Array,a=3,c=n-1,l=(1<<n)-1;if(o[1]=s.convert(this),n>1){var f=kt();for(s.sqrTo(o[1],f);a<=l;)o[a]=kt(),s.mulTo(f,o[a-2],o[a]),a+=2}var h=r.t-1,p,d=!0,m=kt(),y;for(t=xw(r.data[h])-1;h>=0;){for(t>=c?p=r.data[h]>>t-c&l:(p=(r.data[h]&(1<<t+1)-1)<<c-t,h>0&&(p|=r.data[h-1]>>this.DB+t-c)),a=n;(p&1)==0;)p>>=1,--a;if((t-=a)<0&&(t+=this.DB,--h),d)o[p].copyTo(i),d=!1;else{for(;a>1;)s.sqrTo(i,m),s.sqrTo(m,i),a-=2;a>0?s.sqrTo(i,m):(y=i,i=m,m=y),s.mulTo(m,o[p],i)}for(;h>=0&&(r.data[h]&1<<t)==0;)s.sqrTo(i,m),y=i,i=m,m=y,--t<0&&(t=this.DB-1,--h)}return s.revert(i)}function K2e(r){var e=this.s<0?this.negate():this.clone(),t=r.s<0?r.negate():r.clone();if(e.compareTo(t)<0){var n=e;e=t,t=n}var i=e.getLowestSetBit(),s=t.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),t.rShiftTo(s,t));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),e.compareTo(t)>=0?(e.subTo(t,e),e.rShiftTo(1,e)):(t.subTo(e,t),t.rShiftTo(1,t));return s>0&&t.lShiftTo(s,t),t}function q2e(r){if(r<=0)return 0;var e=this.DV%r,t=this.s<0?r-1:0;if(this.t>0)if(e==0)t=this.data[0]%r;else for(var n=this.t-1;n>=0;--n)t=(e*t+this.data[n])%r;return t}function z2e(r){var e=r.isEven();if(this.isEven()&&e||r.signum()==0)return X.ZERO;for(var t=r.clone(),n=this.clone(),i=nu(1),s=nu(0),o=nu(0),a=nu(1);t.signum()!=0;){for(;t.isEven();)t.rShiftTo(1,t),e?((!i.isEven()||!s.isEven())&&(i.addTo(this,i),s.subTo(r,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(r,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(r,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(r,a),a.rShiftTo(1,a);t.compareTo(n)>=0?(t.subTo(n,t),e&&i.subTo(o,i),s.subTo(a,s)):(n.subTo(t,n),e&&o.subTo(i,o),a.subTo(s,a))}if(n.compareTo(X.ONE)!=0)return X.ZERO;if(a.compareTo(r)>=0)return a.subtract(r);if(a.signum()<0)a.addTo(r,a);else return a;return a.signum()<0?a.add(r):a}var xo=[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],$2e=(1<<26)/xo[xo.length-1];function H2e(r){var e,t=this.abs();if(t.t==1&&t.data[0]<=xo[xo.length-1]){for(e=0;e<xo.length;++e)if(t.data[0]==xo[e])return!0;return!1}if(t.isEven())return!1;for(e=1;e<xo.length;){for(var n=xo[e],i=e+1;i<xo.length&&n<$2e;)n*=xo[i++];for(n=t.modInt(n);e<i;)if(n%xo[e++]==0)return!1}return t.millerRabin(r)}function G2e(r){var e=this.subtract(X.ONE),t=e.getLowestSetBit();if(t<=0)return!1;for(var n=e.shiftRight(t),i=j2e(),s,o=0;o<r;++o){do s=new X(this.bitLength(),i);while(s.compareTo(X.ONE)<=0||s.compareTo(e)>=0);var a=s.modPow(n,this);if(a.compareTo(X.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<t&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(X.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function j2e(){return{nextBytes:function(r){for(var e=0;e<r.length;++e)r[e]=Math.floor(Math.random()*256)}}}X.prototype.chunkSize=Wme;X.prototype.toRadix=Qme;X.prototype.fromRadix=Xme;X.prototype.fromNumber=Zme;X.prototype.bitwiseTo=n2e;X.prototype.changeBit=g2e;X.prototype.addTo=v2e;X.prototype.dMultiply=R2e;X.prototype.dAddOffset=C2e;X.prototype.multiplyLowerTo=k2e;X.prototype.multiplyUpperTo=N2e;X.prototype.modInt=q2e;X.prototype.millerRabin=G2e;X.prototype.clone=$me;X.prototype.intValue=Hme;X.prototype.byteValue=Gme;X.prototype.shortValue=jme;X.prototype.signum=Yme;X.prototype.toByteArray=Jme;X.prototype.equals=e2e;X.prototype.min=t2e;X.prototype.max=r2e;X.prototype.and=s2e;X.prototype.or=o2e;X.prototype.xor=a2e;X.prototype.andNot=c2e;X.prototype.not=l2e;X.prototype.shiftLeft=u2e;X.prototype.shiftRight=f2e;X.prototype.getLowestSetBit=d2e;X.prototype.bitCount=m2e;X.prototype.testBit=y2e;X.prototype.setBit=w2e;X.prototype.clearBit=E2e;X.prototype.flipBit=b2e;X.prototype.add=_2e;X.prototype.subtract=S2e;X.prototype.multiply=x2e;X.prototype.divide=T2e;X.prototype.remainder=I2e;X.prototype.divideAndRemainder=A2e;X.prototype.modPow=V2e;X.prototype.modInverse=z2e;X.prototype.pow=O2e;X.prototype.gcd=K2e;X.prototype.isProbablePrime=H2e});var hF=R((Mke,fF)=>{u();var Sa=ft();tu();sr();var lF=fF.exports=Sa.sha1=Sa.sha1||{};Sa.md.sha1=Sa.md.algorithms.sha1=lF;lF.create=function(){uF||W2e();var r=null,e=Sa.util.createBuffer(),t=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=Sa.util.createBuffer(),r={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=Sa.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),cF(r,t,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=Sa.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(US.substr(0,n.blockLength-o));for(var a,c,l=n.fullMessageLength[0]*8,f=0;f<n.fullMessageLength.length-1;++f)a=n.fullMessageLength[f+1]*8,c=a/4294967296>>>0,l+=c,i.putInt32(l>>>0),l=a>>>0;i.putInt32(l);var h={h0:r.h0,h1:r.h1,h2:r.h2,h3:r.h3,h4:r.h4};cF(h,t,i);var p=Sa.util.createBuffer();return p.putInt32(h.h0),p.putInt32(h.h1),p.putInt32(h.h2),p.putInt32(h.h3),p.putInt32(h.h4),p},n};var US=null,uF=!1;function W2e(){US=String.fromCharCode(128),US+=Sa.util.fillString(String.fromCharCode(0),64),uF=!0}function cF(r,e,t){for(var n,i,s,o,a,c,l,f,h=t.length();h>=64;){for(i=r.h0,s=r.h1,o=r.h2,a=r.h3,c=r.h4,f=0;f<16;++f)n=t.getInt32(),e[f]=n,l=a^s&(o^a),n=(i<<5|i>>>27)+l+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;f<20;++f)n=e[f-3]^e[f-8]^e[f-14]^e[f-16],n=n<<1|n>>>31,e[f]=n,l=a^s&(o^a),n=(i<<5|i>>>27)+l+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;f<32;++f)n=e[f-3]^e[f-8]^e[f-14]^e[f-16],n=n<<1|n>>>31,e[f]=n,l=s^o^a,n=(i<<5|i>>>27)+l+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;f<40;++f)n=e[f-6]^e[f-16]^e[f-28]^e[f-32],n=n<<2|n>>>30,e[f]=n,l=s^o^a,n=(i<<5|i>>>27)+l+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;f<60;++f)n=e[f-6]^e[f-16]^e[f-28]^e[f-32],n=n<<2|n>>>30,e[f]=n,l=s&o|a&(s^o),n=(i<<5|i>>>27)+l+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;f<80;++f)n=e[f-6]^e[f-16]^e[f-28]^e[f-32],n=n<<2|n>>>30,e[f]=n,l=s^o^a,n=(i<<5|i>>>27)+l+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;r.h0=r.h0+i|0,r.h1=r.h1+s|0,r.h2=r.h2+o|0,r.h3=r.h3+a|0,r.h4=r.h4+c|0,h-=64}}});var mF=R((Uke,pF)=>{u();var xa=ft();sr();$f();hF();var dF=pF.exports=xa.pkcs1=xa.pkcs1||{};dF.encode_rsa_oaep=function(r,e,t){var n,i,s,o;typeof t=="string"?(n=t,i=arguments[3]||void 0,s=arguments[4]||void 0):t&&(n=t.label||void 0,i=t.seed||void 0,s=t.md||void 0,t.mgf1&&t.mgf1.md&&(o=t.mgf1.md)),s?s.start():s=xa.md.sha1.create(),o||(o=s);var a=Math.ceil(r.n.bitLength()/8),c=a-2*s.digestLength-2;if(e.length>c){var l=new Error("RSAES-OAEP input message length is too long.");throw l.length=e.length,l.maxLength=c,l}n||(n=""),s.update(n,"raw");for(var f=s.digest(),h="",p=c-e.length,d=0;d<p;d++)h+="\0";var m=f.getBytes()+h+""+e;if(!i)i=xa.random.getBytes(s.digestLength);else if(i.length!==s.digestLength){var l=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw l.seedLength=i.length,l.digestLength=s.digestLength,l}var y=Iw(i,a-s.digestLength-1,o),g=xa.util.xorBytes(m,y,m.length),w=Iw(g,s.digestLength,o),b=xa.util.xorBytes(i,w,i.length);return"\0"+b+g};dF.decode_rsa_oaep=function(r,e,t){var n,i,s;typeof t=="string"?(n=t,i=arguments[3]||void 0):t&&(n=t.label||void 0,i=t.md||void 0,t.mgf1&&t.mgf1.md&&(s=t.mgf1.md));var o=Math.ceil(r.n.bitLength()/8);if(e.length!==o){var g=new Error("RSAES-OAEP encoded message length is invalid.");throw g.length=e.length,g.expectedLength=o,g}if(i===void 0?i=xa.md.sha1.create():i.start(),s||(s=i),o<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var a=i.digest().getBytes(),c=e.charAt(0),l=e.substring(1,i.digestLength+1),f=e.substring(1+i.digestLength),h=Iw(f,i.digestLength,s),p=xa.util.xorBytes(l,h,l.length),d=Iw(p,o-i.digestLength-1,s),m=xa.util.xorBytes(f,d,f.length),y=m.substring(0,i.digestLength),g=c!=="\0",w=0;w<i.digestLength;++w)g|=a.charAt(w)!==y.charAt(w);for(var b=1,S=i.digestLength,_=i.digestLength;_<m.length;_++){var I=m.charCodeAt(_),T=I&1^1,x=b?65534:0;g|=I&x,b=b&T,S+=b}if(g||m.charCodeAt(S)!==1)throw new Error("Invalid RSAES-OAEP padding.");return m.substring(S+1)};function Iw(r,e,t){t||(t=xa.md.sha1.create());for(var n="",i=Math.ceil(e/t.digestLength),s=0;s<i;++s){var o=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);t.start(),t.update(r+o),n+=t.digest().getBytes()}return n.substring(0,e)}});var yF=R((Fke,FS)=>{u();var iu=ft();sr();Tw();$f();(function(){if(iu.prime){FS.exports=iu.prime;return}var r=FS.exports=iu.prime=iu.prime||{},e=iu.jsbn.BigInteger,t=[6,4,2,4,2,4,6,2],n=new e(null);n.fromInt(30);var i=function(h,p){return h|p};r.generateProbablePrime=function(h,p,d){typeof p=="function"&&(d=p,p={}),p=p||{};var m=p.algorithm||"PRIMEINC";typeof m=="string"&&(m={name:m}),m.options=m.options||{};var y=p.prng||iu.random,g={nextBytes:function(w){for(var b=y.getBytesSync(w.length),S=0;S<w.length;++S)w[S]=b.charCodeAt(S)}};if(m.name==="PRIMEINC")return s(h,g,m.options,d);throw new Error("Invalid prime generation algorithm: "+m.name)};function s(h,p,d,m){return"workers"in d?c(h,p,d,m):o(h,p,d,m)}function o(h,p,d,m){var y=l(h,p),g=0,w=f(y.bitLength());"millerRabinTests"in d&&(w=d.millerRabinTests);var b=10;"maxBlockTime"in d&&(b=d.maxBlockTime),a(y,h,p,g,w,b,m)}function a(h,p,d,m,y,g,w){var b=+new Date;do{if(h.bitLength()>p&&(h=l(p,d)),h.isProbablePrime(y))return w(null,h);h.dAddOffset(t[m++%8],0)}while(g<0||+new Date-b<g);iu.util.setImmediate(function(){a(h,p,d,m,y,g,w)})}function c(h,p,d,m){if(typeof Worker>"u")return o(h,p,d,m);var y=l(h,p),g=d.workers,w=d.workLoad||100,b=w*30/8,S=d.workerScript||"forge/prime.worker.js";if(g===-1)return iu.util.estimateCores(function(I,T){I&&(T=2),g=T-1,_()});_();function _(){g=Math.max(1,g);for(var I=[],T=0;T<g;++T)I[T]=new Worker(S);for(var x=g,T=0;T<g;++T)I[T].addEventListener("message",B);var P=!1;function B(q){if(!P){--x;var Y=q.data;if(Y.found){for(var re=0;re<I.length;++re)I[re].terminate();return P=!0,m(null,new e(Y.prime,16))}y.bitLength()>h&&(y=l(h,p));var ie=y.toString(16);q.target.postMessage({hex:ie,workLoad:w}),y.dAddOffset(b,0)}}}}function l(h,p){var d=new e(h,p),m=h-1;return d.testBit(m)||d.bitwiseTo(e.ONE.shiftLeft(m),i,d),d.dAddOffset(31-d.mod(n).byteValue(),0),d}function f(h){return h<=100?27:h<=150?18:h<=200?15:h<=250?12:h<=300?9:h<=350?8:h<=400?7:h<=500?6:h<=600?5:h<=800?4:h<=1250?3:2}})()});var Rm=R((Vke,SF)=>{u();var Fe=ft();eu();Tw();wp();mF();yF();$f();sr();typeof It>"u"&&(It=Fe.jsbn.BigInteger);var It,VS=Fe.util.isNodejs?ru():null,U=Fe.asn1,Ns=Fe.util;Fe.pki=Fe.pki||{};SF.exports=Fe.pki.rsa=Fe.rsa=Fe.rsa||{};var et=Fe.pki,Y2e=[6,4,2,4,2,4,6,2],Q2e={name:"PrivateKeyInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},X2e={name:"RSAPrivateKey",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},Z2e={name:"RSAPublicKey",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},J2e=Fe.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:U.Class.UNIVERSAL,type:U.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},eye={name:"DigestInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:U.Class.UNIVERSAL,type:U.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:U.Class.UNIVERSAL,type:U.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},tye=function(r){var e;if(r.algorithm in et.oids)e=et.oids[r.algorithm];else{var t=new Error("Unknown message digest algorithm.");throw t.algorithm=r.algorithm,t}var n=U.oidToDer(e).getBytes(),i=U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[]),s=U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[]);s.value.push(U.create(U.Class.UNIVERSAL,U.Type.OID,!1,n)),s.value.push(U.create(U.Class.UNIVERSAL,U.Type.NULL,!1,""));var o=U.create(U.Class.UNIVERSAL,U.Type.OCTETSTRING,!1,r.digest().getBytes());return i.value.push(s),i.value.push(o),U.toDer(i).getBytes()},vF=function(r,e,t){if(t)return r.modPow(e.e,e.n);if(!e.p||!e.q)return r.modPow(e.d,e.n);e.dP||(e.dP=e.d.mod(e.p.subtract(It.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(It.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new It(Fe.util.bytesToHex(Fe.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(It.ONE));r=r.multiply(n.modPow(e.e,e.n)).mod(e.n);for(var i=r.mod(e.p).modPow(e.dP,e.p),s=r.mod(e.q).modPow(e.dQ,e.q);i.compareTo(s)<0;)i=i.add(e.p);var o=i.subtract(s).multiply(e.qInv).mod(e.p).multiply(e.q).add(s);return o=o.multiply(n.modInverse(e.n)).mod(e.n),o};et.rsa.encrypt=function(r,e,t){var n=t,i,s=Math.ceil(e.n.bitLength()/8);t!==!1&&t!==!0?(n=t===2,i=_F(r,e,t)):(i=Fe.util.createBuffer(),i.putBytes(r));for(var o=new It(i.toHex(),16),a=vF(o,e,n),c=a.toString(16),l=Fe.util.createBuffer(),f=s-Math.ceil(c.length/2);f>0;)l.putByte(0),--f;return l.putBytes(Fe.util.hexToBytes(c)),l.getBytes()};et.rsa.decrypt=function(r,e,t,n){var i=Math.ceil(e.n.bitLength()/8);if(r.length!==i){var s=new Error("Encrypted message length is invalid.");throw s.length=r.length,s.expected=i,s}var o=new It(Fe.util.createBuffer(r).toHex(),16);if(o.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=vF(o,e,t),c=a.toString(16),l=Fe.util.createBuffer(),f=i-Math.ceil(c.length/2);f>0;)l.putByte(0),--f;return l.putBytes(Fe.util.hexToBytes(c)),n!==!1?Aw(l.getBytes(),e,t):l.getBytes()};et.rsa.createKeyPairGenerationState=function(r,e,t){typeof r=="string"&&(r=parseInt(r,10)),r=r||2048,t=t||{};var n=t.prng||Fe.random,i={nextBytes:function(a){for(var c=n.getBytesSync(a.length),l=0;l<a.length;++l)a[l]=c.charCodeAt(l)}},s=t.algorithm||"PRIMEINC",o;if(s==="PRIMEINC")o={algorithm:s,state:0,bits:r,rng:i,eInt:e||65537,e:new It(null),p:null,q:null,qBits:r>>1,pBits:r-(r>>1),pqState:0,num:null,keys:null},o.e.fromInt(o.eInt);else throw new Error("Invalid key generation algorithm: "+s);return o};et.rsa.stepKeyPairGenerationState=function(r,e){"algorithm"in r||(r.algorithm="PRIMEINC");var t=new It(null);t.fromInt(30);for(var n=0,i=function(h,p){return h|p},s=+new Date,o,a=0;r.keys===null&&(e<=0||a<e);){if(r.state===0){var c=r.p===null?r.pBits:r.qBits,l=c-1;r.pqState===0?(r.num=new It(c,r.rng),r.num.testBit(l)||r.num.bitwiseTo(It.ONE.shiftLeft(l),i,r.num),r.num.dAddOffset(31-r.num.mod(t).byteValue(),0),n=0,++r.pqState):r.pqState===1?r.num.bitLength()>c?r.pqState=0:r.num.isProbablePrime(nye(r.num.bitLength()))?++r.pqState:r.num.dAddOffset(Y2e[n++%8],0):r.pqState===2?r.pqState=r.num.subtract(It.ONE).gcd(r.e).compareTo(It.ONE)===0?3:0:r.pqState===3&&(r.pqState=0,r.p===null?r.p=r.num:r.q=r.num,r.p!==null&&r.q!==null&&++r.state,r.num=null)}else if(r.state===1)r.p.compareTo(r.q)<0&&(r.num=r.p,r.p=r.q,r.q=r.num),++r.state;else if(r.state===2)r.p1=r.p.subtract(It.ONE),r.q1=r.q.subtract(It.ONE),r.phi=r.p1.multiply(r.q1),++r.state;else if(r.state===3)r.phi.gcd(r.e).compareTo(It.ONE)===0?++r.state:(r.p=null,r.q=null,r.state=0);else if(r.state===4)r.n=r.p.multiply(r.q),r.n.bitLength()===r.bits?++r.state:(r.q=null,r.state=0);else if(r.state===5){var f=r.e.modInverse(r.phi);r.keys={privateKey:et.rsa.setPrivateKey(r.n,r.e,f,r.p,r.q,f.mod(r.p1),f.mod(r.q1),r.q.modInverse(r.p)),publicKey:et.rsa.setPublicKey(r.n,r.e)}}o=+new Date,a+=o-s,s=o}return r.keys!==null};et.rsa.generateKeyPair=function(r,e,t,n){if(arguments.length===1?typeof r=="object"?(t=r,r=void 0):typeof r=="function"&&(n=r,r=void 0):arguments.length===2?typeof r=="number"?typeof e=="function"?(n=e,e=void 0):typeof e!="number"&&(t=e,e=void 0):(t=r,n=e,r=void 0,e=void 0):arguments.length===3&&(typeof e=="number"?typeof t=="function"&&(n=t,t=void 0):(n=t,t=e,e=void 0)),t=t||{},r===void 0&&(r=t.bits||2048),e===void 0&&(e=t.e||65537),!Fe.options.usePureJavaScript&&!t.prng&&r>=256&&r<=16384&&(e===65537||e===3)){if(n){if(gF("generateKeyPair"))return VS.generateKeyPair("rsa",{modulusLength:r,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(a,c,l){if(a)return n(a);n(null,{privateKey:et.privateKeyFromPem(l),publicKey:et.publicKeyFromPem(c)})});if(wF("generateKey")&&wF("exportKey"))return Ns.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:bF(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return Ns.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=et.privateKeyFromAsn1(U.fromDer(Fe.util.createBuffer(a)));n(null,{privateKey:c,publicKey:et.setRsaPublicKey(c.n,c.e)})}});if(EF("generateKey")&&EF("exportKey")){var i=Ns.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:bF(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,l=Ns.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);l.oncomplete=function(f){var h=f.target.result,p=et.privateKeyFromAsn1(U.fromDer(Fe.util.createBuffer(h)));n(null,{privateKey:p,publicKey:et.setRsaPublicKey(p.n,p.e)})},l.onerror=function(f){n(f)}},i.onerror=function(a){n(a)};return}}else if(gF("generateKeyPairSync")){var s=VS.generateKeyPairSync("rsa",{modulusLength:r,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:et.privateKeyFromPem(s.privateKey),publicKey:et.publicKeyFromPem(s.publicKey)}}}var o=et.rsa.createKeyPairGenerationState(r,e,t);if(!n)return et.rsa.stepKeyPairGenerationState(o,0),o.keys;rye(o,t,n)};et.setRsaPublicKey=et.rsa.setPublicKey=function(r,e){var t={n:r,e};return t.encrypt=function(n,i,s){if(typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSAES-PKCS1-V1_5"),i==="RSAES-PKCS1-V1_5")i={encode:function(a,c,l){return _F(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return Fe.pkcs1.encode_rsa_oaep(c,a,s)}};else if(["RAW","NONE","NULL",null].indexOf(i)!==-1)i={encode:function(a){return a}};else if(typeof i=="string")throw new Error('Unsupported encryption scheme: "'+i+'".');var o=i.encode(n,t,!0);return et.rsa.encrypt(o,t,!0)},t.verify=function(n,i,s,o){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),o===void 0&&(o={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in o||(o._parseAllDigestBytes=!0),s==="RSASSA-PKCS1-V1_5"?s={verify:function(c,l){l=Aw(l,t,!0);var f=U.fromDer(l,{parseAllBytes:o._parseAllDigestBytes}),h={},p=[];if(!U.validate(f,eye,h,p)){var d=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw d.errors=p,d}var m=U.derToOid(h.algorithmIdentifier);if(!(m===Fe.oids.md2||m===Fe.oids.md5||m===Fe.oids.sha1||m===Fe.oids.sha224||m===Fe.oids.sha256||m===Fe.oids.sha384||m===Fe.oids.sha512||m===Fe.oids["sha512-224"]||m===Fe.oids["sha512-256"])){var d=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw d.oid=m,d}if((m===Fe.oids.md2||m===Fe.oids.md5)&&!("parameters"in h))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return c===h.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(c,l){return l=Aw(l,t,!0),c===l}});var a=et.rsa.decrypt(i,t,!0,!1);return s.verify(n,a,t.n.bitLength())},t};et.setRsaPrivateKey=et.rsa.setPrivateKey=function(r,e,t,n,i,s,o,a){var c={n:r,e,d:t,p:n,q:i,dP:s,dQ:o,qInv:a};return c.decrypt=function(l,f,h){typeof f=="string"?f=f.toUpperCase():f===void 0&&(f="RSAES-PKCS1-V1_5");var p=et.rsa.decrypt(l,c,!1,!1);if(f==="RSAES-PKCS1-V1_5")f={decode:Aw};else if(f==="RSA-OAEP"||f==="RSAES-OAEP")f={decode:function(d,m){return Fe.pkcs1.decode_rsa_oaep(m,d,h)}};else if(["RAW","NONE","NULL",null].indexOf(f)!==-1)f={decode:function(d){return d}};else throw new Error('Unsupported encryption scheme: "'+f+'".');return f.decode(p,c,!1)},c.sign=function(l,f){var h=!1;typeof f=="string"&&(f=f.toUpperCase()),f===void 0||f==="RSASSA-PKCS1-V1_5"?(f={encode:tye},h=1):(f==="NONE"||f==="NULL"||f===null)&&(f={encode:function(){return l}},h=1);var p=f.encode(l,c.n.bitLength());return et.rsa.encrypt(p,c,h)},c};et.wrapRsaPrivateKey=function(r){return U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,U.integerToDer(0).getBytes()),U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[U.create(U.Class.UNIVERSAL,U.Type.OID,!1,U.oidToDer(et.oids.rsaEncryption).getBytes()),U.create(U.Class.UNIVERSAL,U.Type.NULL,!1,"")]),U.create(U.Class.UNIVERSAL,U.Type.OCTETSTRING,!1,U.toDer(r).getBytes())])};et.privateKeyFromAsn1=function(r){var e={},t=[];if(U.validate(r,Q2e,e,t)&&(r=U.fromDer(Fe.util.createBuffer(e.privateKey))),e={},t=[],!U.validate(r,X2e,e,t)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=t,n}var i,s,o,a,c,l,f,h;return i=Fe.util.createBuffer(e.privateKeyModulus).toHex(),s=Fe.util.createBuffer(e.privateKeyPublicExponent).toHex(),o=Fe.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=Fe.util.createBuffer(e.privateKeyPrime1).toHex(),c=Fe.util.createBuffer(e.privateKeyPrime2).toHex(),l=Fe.util.createBuffer(e.privateKeyExponent1).toHex(),f=Fe.util.createBuffer(e.privateKeyExponent2).toHex(),h=Fe.util.createBuffer(e.privateKeyCoefficient).toHex(),et.setRsaPrivateKey(new It(i,16),new It(s,16),new It(o,16),new It(a,16),new It(c,16),new It(l,16),new It(f,16),new It(h,16))};et.privateKeyToAsn1=et.privateKeyToRSAPrivateKey=function(r){return U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,U.integerToDer(0).getBytes()),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.n)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.e)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.d)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.p)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.q)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.dP)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.dQ)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.qInv))])};et.publicKeyFromAsn1=function(r){var e={},t=[];if(U.validate(r,J2e,e,t)){var n=U.derToOid(e.publicKeyOid);if(n!==et.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}r=e.rsaPublicKey}if(t=[],!U.validate(r,Z2e,e,t)){var i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw i.errors=t,i}var s=Fe.util.createBuffer(e.publicKeyModulus).toHex(),o=Fe.util.createBuffer(e.publicKeyExponent).toHex();return et.setRsaPublicKey(new It(s,16),new It(o,16))};et.publicKeyToAsn1=et.publicKeyToSubjectPublicKeyInfo=function(r){return U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[U.create(U.Class.UNIVERSAL,U.Type.OID,!1,U.oidToDer(et.oids.rsaEncryption).getBytes()),U.create(U.Class.UNIVERSAL,U.Type.NULL,!1,"")]),U.create(U.Class.UNIVERSAL,U.Type.BITSTRING,!1,[et.publicKeyToRSAPublicKey(r)])])};et.publicKeyToRSAPublicKey=function(r){return U.create(U.Class.UNIVERSAL,U.Type.SEQUENCE,!0,[U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.n)),U.create(U.Class.UNIVERSAL,U.Type.INTEGER,!1,Ta(r.e))])};function _F(r,e,t){var n=Fe.util.createBuffer(),i=Math.ceil(e.n.bitLength()/8);if(r.length>i-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=r.length,s.max=i-11,s}n.putByte(0),n.putByte(t);var o=i-3-r.length,a;if(t===0||t===1){a=t===0?0:255;for(var c=0;c<o;++c)n.putByte(a)}else for(;o>0;){for(var l=0,f=Fe.random.getBytes(o),c=0;c<o;++c)a=f.charCodeAt(c),a===0?++l:n.putByte(a);o=l}return n.putByte(0),n.putBytes(r),n}function Aw(r,e,t,n){var i=Math.ceil(e.n.bitLength()/8),s=Fe.util.createBuffer(r),o=s.getByte(),a=s.getByte();if(o!==0||t&&a!==0&&a!==1||!t&&a!=2||t&&a===0&&typeof n>"u")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var l=0;l<c;++l)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(a===1)for(c=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++c}else if(a===2)for(c=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++c}var f=s.getByte();if(f!==0||c!==i-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function rye(r,e,t){typeof e=="function"&&(t=e,e={}),e=e||{};var n={algorithm:{name:e.algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};"prng"in e&&(n.prng=e.prng),i();function i(){s(r.pBits,function(a,c){if(a)return t(a);if(r.p=c,r.q!==null)return o(a,r.q);s(r.qBits,o)})}function s(a,c){Fe.prime.generateProbablePrime(a,n,c)}function o(a,c){if(a)return t(a);if(r.q=c,r.p.compareTo(r.q)<0){var l=r.p;r.p=r.q,r.q=l}if(r.p.subtract(It.ONE).gcd(r.e).compareTo(It.ONE)!==0){r.p=null,i();return}if(r.q.subtract(It.ONE).gcd(r.e).compareTo(It.ONE)!==0){r.q=null,s(r.qBits,o);return}if(r.p1=r.p.subtract(It.ONE),r.q1=r.q.subtract(It.ONE),r.phi=r.p1.multiply(r.q1),r.phi.gcd(r.e).compareTo(It.ONE)!==0){r.p=r.q=null,i();return}if(r.n=r.p.multiply(r.q),r.n.bitLength()!==r.bits){r.q=null,s(r.qBits,o);return}var f=r.e.modInverse(r.phi);r.keys={privateKey:et.rsa.setPrivateKey(r.n,r.e,f,r.p,r.q,f.mod(r.p1),f.mod(r.q1),r.q.modInverse(r.p)),publicKey:et.rsa.setPublicKey(r.n,r.e)},t(null,r.keys)}}function Ta(r){var e=r.toString(16);e[0]>="8"&&(e="00"+e);var t=Fe.util.hexToBytes(e);return t.length>1&&(t.charCodeAt(0)===0&&(t.charCodeAt(1)&128)===0||t.charCodeAt(0)===255&&(t.charCodeAt(1)&128)===128)?t.substr(1):t}function nye(r){return r<=100?27:r<=150?18:r<=200?15:r<=250?12:r<=300?9:r<=350?8:r<=400?7:r<=500?6:r<=600?5:r<=800?4:r<=1250?3:2}function gF(r){return Fe.util.isNodejs&&typeof VS[r]=="function"}function wF(r){return typeof Ns.globalScope<"u"&&typeof Ns.globalScope.crypto=="object"&&typeof Ns.globalScope.crypto.subtle=="object"&&typeof Ns.globalScope.crypto.subtle[r]=="function"}function EF(r){return typeof Ns.globalScope<"u"&&typeof Ns.globalScope.msCrypto=="object"&&typeof Ns.globalScope.msCrypto.subtle=="object"&&typeof Ns.globalScope.msCrypto.subtle[r]=="function"}function bF(r){for(var e=Fe.util.hexToBytes(r.toString(16)),t=new Uint8Array(e.length),n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}});var KS=R((Kke,RF)=>{u();var ge=ft();vp();eu();gw();tu();wp();DS();vw();$f();JU();Rm();sr();typeof xF>"u"&&(xF=ge.jsbn.BigInteger);var xF,j=ge.asn1,rt=ge.pki=ge.pki||{};RF.exports=rt.pbe=ge.pbe=ge.pbe||{};var jf=rt.oids,iye={name:"EncryptedPrivateKeyInfo",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:j.Class.UNIVERSAL,type:j.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:j.Class.UNIVERSAL,type:j.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},sye={name:"PBES2Algorithms",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:j.Class.UNIVERSAL,type:j.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:j.Class.UNIVERSAL,type:j.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:j.Class.UNIVERSAL,type:j.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:j.Class.UNIVERSAL,type:j.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:j.Class.UNIVERSAL,type:j.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:j.Class.UNIVERSAL,type:j.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:j.Class.UNIVERSAL,type:j.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},oye={name:"pkcs-12PbeParams",tagClass:j.Class.UNIVERSAL,type:j.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:j.Class.UNIVERSAL,type:j.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:j.Class.UNIVERSAL,type:j.Type.INTEGER,constructed:!1,capture:"iterations"}]};rt.encryptPrivateKeyInfo=function(r,e,t){t=t||{},t.saltSize=t.saltSize||8,t.count=t.count||2048,t.algorithm=t.algorithm||"aes128",t.prfAlgorithm=t.prfAlgorithm||"sha1";var n=ge.random.getBytesSync(t.saltSize),i=t.count,s=j.integerToDer(i),o,a,c;if(t.algorithm.indexOf("aes")===0||t.algorithm==="des"){var l,f,h;switch(t.algorithm){case"aes128":o=16,l=16,f=jf["aes128-CBC"],h=ge.aes.createEncryptionCipher;break;case"aes192":o=24,l=16,f=jf["aes192-CBC"],h=ge.aes.createEncryptionCipher;break;case"aes256":o=32,l=16,f=jf["aes256-CBC"],h=ge.aes.createEncryptionCipher;break;case"des":o=8,l=8,f=jf.desCBC,h=ge.des.createEncryptionCipher;break;default:var p=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw p.algorithm=t.algorithm,p}var d="hmacWith"+t.prfAlgorithm.toUpperCase(),m=AF(d),y=ge.pkcs5.pbkdf2(e,n,i,o,m),g=ge.random.getBytesSync(l),w=h(y);w.start(g),w.update(j.toDer(r)),w.finish(),c=w.output.getBytes();var b=aye(n,s,o,d);a=j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OID,!1,j.oidToDer(jf.pkcs5PBES2).getBytes()),j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OID,!1,j.oidToDer(jf.pkcs5PBKDF2).getBytes()),b]),j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OID,!1,j.oidToDer(f).getBytes()),j.create(j.Class.UNIVERSAL,j.Type.OCTETSTRING,!1,g)])])])}else if(t.algorithm==="3des"){o=24;var S=new ge.util.ByteBuffer(n),y=rt.pbe.generatePkcs12Key(e,S,1,i,o),g=rt.pbe.generatePkcs12Key(e,S,2,i,o),w=ge.des.createEncryptionCipher(y);w.start(g),w.update(j.toDer(r)),w.finish(),c=w.output.getBytes(),a=j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OID,!1,j.oidToDer(jf["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OCTETSTRING,!1,n),j.create(j.Class.UNIVERSAL,j.Type.INTEGER,!1,s.getBytes())])])}else{var p=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw p.algorithm=t.algorithm,p}var _=j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[a,j.create(j.Class.UNIVERSAL,j.Type.OCTETSTRING,!1,c)]);return _};rt.decryptPrivateKeyInfo=function(r,e){var t=null,n={},i=[];if(!j.validate(r,iye,n,i)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=j.derToOid(n.encryptionOid),a=rt.pbe.getCipher(o,n.encryptionParams,e),c=ge.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(t=j.fromDer(a.output)),t};rt.encryptedPrivateKeyToPem=function(r,e){var t={type:"ENCRYPTED PRIVATE KEY",body:j.toDer(r).getBytes()};return ge.pem.encode(t,{maxline:e})};rt.encryptedPrivateKeyFromPem=function(r){var e=ge.pem.decode(r)[0];if(e.type!=="ENCRYPTED PRIVATE KEY"){var t=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw t.headerType=e.type,t}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return j.fromDer(e.body)};rt.encryptRsaPrivateKey=function(r,e,t){if(t=t||{},!t.legacy){var n=rt.wrapRsaPrivateKey(rt.privateKeyToAsn1(r));return n=rt.encryptPrivateKeyInfo(n,e,t),rt.encryptedPrivateKeyToPem(n)}var i,s,o,a;switch(t.algorithm){case"aes128":i="AES-128-CBC",o=16,s=ge.random.getBytesSync(16),a=ge.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,s=ge.random.getBytesSync(16),a=ge.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,s=ge.random.getBytesSync(16),a=ge.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,s=ge.random.getBytesSync(8),a=ge.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,s=ge.random.getBytesSync(8),a=ge.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+t.algorithm+'".');throw c.algorithm=t.algorithm,c}var l=ge.pbe.opensslDeriveBytes(e,s.substr(0,8),o),f=a(l);f.start(s),f.update(j.toDer(rt.privateKeyToAsn1(r))),f.finish();var h={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:ge.util.bytesToHex(s).toUpperCase()},body:f.output.getBytes()};return ge.pem.encode(h)};rt.decryptRsaPrivateKey=function(r,e){var t=null,n=ge.pem.decode(r)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw i.headerType=i,i}if(n.procType&&n.procType.type==="ENCRYPTED"){var s,o;switch(n.dekInfo.algorithm){case"DES-CBC":s=8,o=ge.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,o=ge.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,o=ge.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,o=ge.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,o=ge.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,o=function(h){return ge.rc2.createDecryptionCipher(h,40)};break;case"RC2-64-CBC":s=8,o=function(h){return ge.rc2.createDecryptionCipher(h,64)};break;case"RC2-128-CBC":s=16,o=function(h){return ge.rc2.createDecryptionCipher(h,128)};break;default:var i=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw i.algorithm=n.dekInfo.algorithm,i}var a=ge.util.hexToBytes(n.dekInfo.parameters),c=ge.pbe.opensslDeriveBytes(e,a.substr(0,8),s),l=o(c);if(l.start(a),l.update(ge.util.createBuffer(n.body)),l.finish())t=l.output.getBytes();else return t}else t=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?t=rt.decryptPrivateKeyInfo(j.fromDer(t),e):t=j.fromDer(t),t!==null&&(t=rt.privateKeyFromAsn1(t)),t};rt.pbe.generatePkcs12Key=function(r,e,t,n,i,s){var o,a;if(typeof s>"u"||s===null){if(!("sha1"in ge.md))throw new Error('"sha1" hash algorithm unavailable.');s=ge.md.sha1.create()}var c=s.digestLength,l=s.blockLength,f=new ge.util.ByteBuffer,h=new ge.util.ByteBuffer;if(r!=null){for(a=0;a<r.length;a++)h.putInt16(r.charCodeAt(a));h.putInt16(0)}var p=h.length(),d=e.length(),m=new ge.util.ByteBuffer;m.fillWithByte(t,l);var y=l*Math.ceil(d/l),g=new ge.util.ByteBuffer;for(a=0;a<y;a++)g.putByte(e.at(a%d));var w=l*Math.ceil(p/l),b=new ge.util.ByteBuffer;for(a=0;a<w;a++)b.putByte(h.at(a%p));var S=g;S.putBuffer(b);for(var _=Math.ceil(i/c),I=1;I<=_;I++){var T=new ge.util.ByteBuffer;T.putBytes(m.bytes()),T.putBytes(S.bytes());for(var x=0;x<n;x++)s.start(),s.update(T.getBytes()),T=s.digest();var P=new ge.util.ByteBuffer;for(a=0;a<l;a++)P.putByte(T.at(a%c));var B=Math.ceil(d/l)+Math.ceil(p/l),q=new ge.util.ByteBuffer;for(o=0;o<B;o++){var Y=new ge.util.ByteBuffer(S.getBytes(l)),re=511;for(a=P.length()-1;a>=0;a--)re=re>>8,re+=P.at(a)+Y.at(a),Y.setAt(a,re&255);q.putBuffer(Y)}S=q,f.putBuffer(T)}return f.truncate(f.length()-i),f};rt.pbe.getCipher=function(r,e,t){switch(r){case rt.oids.pkcs5PBES2:return rt.pbe.getCipherForPBES2(r,e,t);case rt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case rt.oids["pbewithSHAAnd40BitRC2-CBC"]:return rt.pbe.getCipherForPKCS12PBE(r,e,t);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=r,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};rt.pbe.getCipherForPBES2=function(r,e,t){var n={},i=[];if(!j.validate(e,sye,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}if(r=j.derToOid(n.kdfOid),r!==rt.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=r,s.supportedOids=["pkcs5PBKDF2"],s}if(r=j.derToOid(n.encOid),r!==rt.oids["aes128-CBC"]&&r!==rt.oids["aes192-CBC"]&&r!==rt.oids["aes256-CBC"]&&r!==rt.oids["des-EDE3-CBC"]&&r!==rt.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=r,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var o=n.kdfSalt,a=ge.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,l;switch(rt.oids[r]){case"aes128-CBC":c=16,l=ge.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,l=ge.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,l=ge.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,l=ge.des.createDecryptionCipher;break;case"desCBC":c=8,l=ge.des.createDecryptionCipher;break}var f=IF(n.prfOid),h=ge.pkcs5.pbkdf2(t,o,a,c,f),p=n.encIv,d=l(h);return d.start(p),d};rt.pbe.getCipherForPKCS12PBE=function(r,e,t){var n={},i=[];if(!j.validate(e,oye,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=ge.util.createBuffer(n.salt),a=ge.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,l,f;switch(r){case rt.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,l=8,f=ge.des.startDecrypting;break;case rt.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,l=8,f=function(y,g){var w=ge.rc2.createDecryptionCipher(y,40);return w.start(g,null),w};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=r,s}var h=IF(n.prfOid),p=rt.pbe.generatePkcs12Key(t,o,1,a,c,h);h.start();var d=rt.pbe.generatePkcs12Key(t,o,2,a,l,h);return f(p,d)};rt.pbe.opensslDeriveBytes=function(r,e,t,n){if(typeof n>"u"||n===null){if(!("md5"in ge.md))throw new Error('"md5" hash algorithm unavailable.');n=ge.md.md5.create()}e===null&&(e="");for(var i=[TF(n,r+e)],s=16,o=1;s<t;++o,s+=16)i.push(TF(n,i[o-1]+r+e));return i.join("").substr(0,t)};function TF(r,e){return r.start().update(e).digest().getBytes()}function IF(r){var e;if(!r)e="hmacWithSHA1";else if(e=rt.oids[j.derToOid(r)],!e){var t=new Error("Unsupported PRF OID.");throw t.oid=r,t.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],t}return AF(e)}function AF(r){var e=ge.md;switch(r){case"hmacWithSHA224":e=ge.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":r=r.substr(8).toLowerCase();break;default:var t=new Error("Unsupported PRF algorithm.");throw t.algorithm=r,t.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],t}if(!e||!(r in e))throw new Error("Unknown hash algorithm: "+r);return e[r].create()}function aye(r,e,t,n){var i=j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OCTETSTRING,!1,r),j.create(j.Class.UNIVERSAL,j.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(j.create(j.Class.UNIVERSAL,j.Type.INTEGER,!1,ge.util.hexToBytes(t.toString(16))),j.create(j.Class.UNIVERSAL,j.Type.SEQUENCE,!0,[j.create(j.Class.UNIVERSAL,j.Type.OID,!1,j.oidToDer(rt.oids[n]).getBytes()),j.create(j.Class.UNIVERSAL,j.Type.NULL,!1,"")])),i}});var GF=R((pNe,HF)=>{u();var dr=ft();tu();sr();var Cm=HF.exports=dr.sha512=dr.sha512||{};dr.md.sha512=dr.md.algorithms.sha512=Cm;var zF=dr.sha384=dr.sha512.sha384=dr.sha512.sha384||{};zF.create=function(){return Cm.create("SHA-384")};dr.md.sha384=dr.md.algorithms.sha384=zF;dr.sha512.sha256=dr.sha512.sha256||{create:function(){return Cm.create("SHA-512/256")}};dr.md["sha512/256"]=dr.md.algorithms["sha512/256"]=dr.sha512.sha256;dr.sha512.sha224=dr.sha512.sha224||{create:function(){return Cm.create("SHA-512/224")}};dr.md["sha512/224"]=dr.md.algorithms["sha512/224"]=dr.sha512.sha224;Cm.create=function(r){if($F||dye(),typeof r>"u"&&(r="SHA-512"),!(r in Wf))throw new Error("Invalid SHA-512 algorithm: "+r);for(var e=Wf[r],t=null,n=dr.util.createBuffer(),i=new Array(80),s=0;s<80;++s)i[s]=new Array(2);var o=64;switch(r){case"SHA-384":o=48;break;case"SHA-512/256":o=32;break;case"SHA-512/224":o=28;break}var a={algorithm:r.replace("-","").toLowerCase(),blockLength:128,digestLength:o,messageLength:0,fullMessageLength:null,messageLengthSize:16};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength128=[];for(var c=a.messageLengthSize/4,l=0;l<c;++l)a.fullMessageLength.push(0);n=dr.util.createBuffer(),t=new Array(e.length);for(var l=0;l<e.length;++l)t[l]=e[l].slice(0);return a},a.start(),a.update=function(c,l){l==="utf8"&&(c=dr.util.encodeUtf8(c));var f=c.length;a.messageLength+=f,f=[f/4294967296>>>0,f>>>0];for(var h=a.fullMessageLength.length-1;h>=0;--h)a.fullMessageLength[h]+=f[1],f[1]=f[0]+(a.fullMessageLength[h]/4294967296>>>0),a.fullMessageLength[h]=a.fullMessageLength[h]>>>0,f[0]=f[1]/4294967296>>>0;return n.putBytes(c),qF(t,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=dr.util.createBuffer();c.putBytes(n.bytes());var l=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,f=l&a.blockLength-1;c.putBytes($S.substr(0,a.blockLength-f));for(var h,p,d=a.fullMessageLength[0]*8,m=0;m<a.fullMessageLength.length-1;++m)h=a.fullMessageLength[m+1]*8,p=h/4294967296>>>0,d+=p,c.putInt32(d>>>0),d=h>>>0;c.putInt32(d);for(var y=new Array(t.length),m=0;m<t.length;++m)y[m]=t[m].slice(0);qF(y,i,c);var g=dr.util.createBuffer(),w;r==="SHA-512"?w=y.length:r==="SHA-384"?w=y.length-2:w=y.length-4;for(var m=0;m<w;++m)g.putInt32(y[m][0]),(m!==w-1||r!=="SHA-512/224")&&g.putInt32(y[m][1]);return g},a};var $S=null,$F=!1,HS=null,Wf=null;function dye(){$S=String.fromCharCode(128),$S+=dr.util.fillString(String.fromCharCode(0),128),HS=[[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]],Wf={},Wf["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Wf["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Wf["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Wf["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],$F=!0}function qF(r,e,t){for(var n,i,s,o,a,c,l,f,h,p,d,m,y,g,w,b,S,_,I,T,x,P,B,q,Y,re,ie,Ce,Ee,Oe,H,qe,zt,Ke,Ze,ee=t.length();ee>=128;){for(Ee=0;Ee<16;++Ee)e[Ee][0]=t.getInt32()>>>0,e[Ee][1]=t.getInt32()>>>0;for(;Ee<80;++Ee)qe=e[Ee-2],Oe=qe[0],H=qe[1],n=((Oe>>>19|H<<13)^(H>>>29|Oe<<3)^Oe>>>6)>>>0,i=((Oe<<13|H>>>19)^(H<<3|Oe>>>29)^(Oe<<26|H>>>6))>>>0,Ke=e[Ee-15],Oe=Ke[0],H=Ke[1],s=((Oe>>>1|H<<31)^(Oe>>>8|H<<24)^Oe>>>7)>>>0,o=((Oe<<31|H>>>1)^(Oe<<24|H>>>8)^(Oe<<25|H>>>7))>>>0,zt=e[Ee-7],Ze=e[Ee-16],H=i+zt[1]+o+Ze[1],e[Ee][0]=n+zt[0]+s+Ze[0]+(H/4294967296>>>0)>>>0,e[Ee][1]=H>>>0;for(y=r[0][0],g=r[0][1],w=r[1][0],b=r[1][1],S=r[2][0],_=r[2][1],I=r[3][0],T=r[3][1],x=r[4][0],P=r[4][1],B=r[5][0],q=r[5][1],Y=r[6][0],re=r[6][1],ie=r[7][0],Ce=r[7][1],Ee=0;Ee<80;++Ee)l=((x>>>14|P<<18)^(x>>>18|P<<14)^(P>>>9|x<<23))>>>0,f=((x<<18|P>>>14)^(x<<14|P>>>18)^(P<<23|x>>>9))>>>0,h=(Y^x&(B^Y))>>>0,p=(re^P&(q^re))>>>0,a=((y>>>28|g<<4)^(g>>>2|y<<30)^(g>>>7|y<<25))>>>0,c=((y<<4|g>>>28)^(g<<30|y>>>2)^(g<<25|y>>>7))>>>0,d=(y&w|S&(y^w))>>>0,m=(g&b|_&(g^b))>>>0,H=Ce+f+p+HS[Ee][1]+e[Ee][1],n=ie+l+h+HS[Ee][0]+e[Ee][0]+(H/4294967296>>>0)>>>0,i=H>>>0,H=c+m,s=a+d+(H/4294967296>>>0)>>>0,o=H>>>0,ie=Y,Ce=re,Y=B,re=q,B=x,q=P,H=T+i,x=I+n+(H/4294967296>>>0)>>>0,P=H>>>0,I=S,T=_,S=w,_=b,w=y,b=g,H=i+o,y=n+s+(H/4294967296>>>0)>>>0,g=H>>>0;H=r[0][1]+g,r[0][0]=r[0][0]+y+(H/4294967296>>>0)>>>0,r[0][1]=H>>>0,H=r[1][1]+b,r[1][0]=r[1][0]+w+(H/4294967296>>>0)>>>0,r[1][1]=H>>>0,H=r[2][1]+_,r[2][0]=r[2][0]+S+(H/4294967296>>>0)>>>0,r[2][1]=H>>>0,H=r[3][1]+T,r[3][0]=r[3][0]+I+(H/4294967296>>>0)>>>0,r[3][1]=H>>>0,H=r[4][1]+P,r[4][0]=r[4][0]+x+(H/4294967296>>>0)>>>0,r[4][1]=H>>>0,H=r[5][1]+q,r[5][0]=r[5][0]+B+(H/4294967296>>>0)>>>0,r[5][1]=H>>>0,H=r[6][1]+re,r[6][0]=r[6][0]+Y+(H/4294967296>>>0)>>>0,r[6][1]=H>>>0,H=r[7][1]+Ce,r[7][0]=r[7][0]+ie+(H/4294967296>>>0)>>>0,r[7][1]=H>>>0,ee-=128}}});var Ro=R((eBe,oK)=>{"use strict";u();var Ege=async r=>{let e=[];for await(let t of r)e.push(t);return e};oK.exports=Ege});var fi=R((rBe,cK)=>{"use strict";u();var bge=async r=>{for await(let e of r);};cK.exports=bge});var Ai=R((nBe,lK)=>{"use strict";u();var vge=async function*(r,e){for await(let t of r)await e(t)&&(yield t)};lK.exports=vge});var Kp=R((iBe,uK)=>{"use strict";u();var _ge=async function*(r,e){let t=0;if(!(e<1)){for await(let n of r)if(yield n,t++,t===e)return}};uK.exports=_ge});var Zw=R((Rx,Cx)=>{u();(function(r,e){typeof Rx=="object"&&typeof Cx<"u"?Cx.exports=function(t,n,i,s,o){for(n=n.split?n.split("."):n,s=0;s<n.length;s++)t=t?t[n[s]]:o;return t===o?i:t}:typeof define=="function"&&define.amd?define(function(){return function(t,n,i,s,o){for(n=n.split?n.split("."):n,s=0;s<n.length;s++)t=t?t[n[s]]:o;return t===o?i:t}}):r.dlv=function(t,n,i,s,o){for(n=n.split?n.split("."):n,s=0;s<n.length;s++)t=t?t[n[s]]:o;return t===o?i:t}})(Rx)});var Kn=R((RBe,mK)=>{"use strict";u();var Ige=async function*(r,e){for await(let t of r)yield e(t)};mK.exports=Ige});var gK=R((PBe,yK)=>{u();yK.exports=class{constructor(e){if(!(e>0)||(e-1&e)!==0)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 this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}});var Px=R((OBe,EK)=>{u();var wK=gK();EK.exports=class{constructor(e){this.hwm=e||16,this.head=new wK(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){let t=this.head;this.head=t.next=new wK(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next){let t=this.tail.next;return this.tail.next=null,this.tail=t,this.tail.shift()}return e}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}});var vK=R((kBe,bK)=>{u();var Dx=Px();bK.exports=r=>{r=r||{};let e;typeof r=="function"?(e=r,r={}):e=r.onEnd;let t=new Dx,n,i,s,o=()=>{if(!t.isEmpty()){if(r.writev){let y,g=[];for(;!t.isEmpty();){if(y=t.shift(),y.error)throw y.error;g.push(y.value)}return{done:y.done,value:g}}let m=t.shift();if(m.error)throw m.error;return m}return s?{done:!0}:new Promise((m,y)=>{i=g=>(i=null,g.error?y(g.error):r.writev&&!g.done?m({done:g.done,value:[g.value]}):m(g),n)})},a=m=>i?i(m):(t.push(m),n),c=m=>(t=new Dx,i?i({error:m}):(t.push({error:m}),n)),l=m=>s?n:a({done:!1,value:m}),f=m=>s?n:(s=!0,m?c(m):a({done:!0})),h=()=>(t=new Dx,f(),{done:!0}),p=m=>(f(m),{done:!0});if(n={[Symbol.asyncIterator](){return this},next:o,return:h,throw:p,push:l,end:f},!e)return n;let d=n;return n={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(m){return d.throw(m),e&&(e(m),e=null),{done:!0}},return(){return d.return(),e&&(e(),e=null),{done:!0}},push:l,end(m){return d.end(m),e&&(e(m),e=null),n}},n}});var Bc=R((NBe,_K)=>{"use strict";u();var Age=vK(),Rge=async function*(...r){let e=Age();setTimeout(async()=>{try{await Promise.all(r.map(async t=>{for await(let n of t)e.push(n)})),e.end()}catch(t){e.end(t)}},0),yield*e};_K.exports=Rge});var BK=R((hUe,LK)=>{"use strict";u();var Uge=/^(?:[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?\.){0,126}(?:[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9]))\.?$/i;LK.exports=function(e,t){if(t==null&&(t=!1),e.length<2||e.length>255)return!1;var n=e[e.length-1];if(t){if(n!==".")return!1}else if(n===".")return!1;return Uge.test(e)}});var iq=R((BFe,nq)=>{"use strict";u();var jge=()=>{let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r};nq.exports=jge});var bn=R((MFe,Kx)=>{"use strict";u();var Gp=typeof Reflect=="object"?Reflect:null,sq=Gp&&typeof Gp.apply=="function"?Gp.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},h6;Gp&&typeof Gp.ownKeys=="function"?h6=Gp.ownKeys:Object.getOwnPropertySymbols?h6=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:h6=function(e){return Object.getOwnPropertyNames(e)};function Wge(r){console&&console.warn&&console.warn(r)}var aq=Number.isNaN||function(e){return e!==e};function Qt(){Qt.init.call(this)}Kx.exports=Qt;Kx.exports.once=Zge;Qt.EventEmitter=Qt;Qt.prototype._events=void 0;Qt.prototype._eventsCount=0;Qt.prototype._maxListeners=void 0;var oq=10;function d6(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Qt,"defaultMaxListeners",{enumerable:!0,get:function(){return oq},set:function(r){if(typeof r!="number"||r<0||aq(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");oq=r}});Qt.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Qt.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||aq(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function cq(r){return r._maxListeners===void 0?Qt.defaultMaxListeners:r._maxListeners}Qt.prototype.getMaxListeners=function(){return cq(this)};Qt.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")sq(c,this,t);else for(var l=c.length,f=dq(c,l),n=0;n<l;++n)sq(f[n],this,t);return!0};function lq(r,e,t,n){var i,s,o;if(d6(t),s=r._events,s===void 0?(s=r._events=Object.create(null),r._eventsCount=0):(s.newListener!==void 0&&(r.emit("newListener",e,t.listener?t.listener:t),s=r._events),o=s[e]),o===void 0)o=s[e]=t,++r._eventsCount;else if(typeof o=="function"?o=s[e]=n?[t,o]:[o,t]:n?o.unshift(t):o.push(t),i=cq(r),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=o.length,Wge(a)}return r}Qt.prototype.addListener=function(e,t){return lq(this,e,t,!1)};Qt.prototype.on=Qt.prototype.addListener;Qt.prototype.prependListener=function(e,t){return lq(this,e,t,!0)};function Yge(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function uq(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},i=Yge.bind(n);return i.listener=t,n.wrapFn=i,i}Qt.prototype.once=function(e,t){return d6(t),this.on(e,uq(this,e,t)),this};Qt.prototype.prependOnceListener=function(e,t){return d6(t),this.prependListener(e,uq(this,e,t)),this};Qt.prototype.removeListener=function(e,t){var n,i,s,o,a;if(d6(t),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():Qge(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};Qt.prototype.off=Qt.prototype.removeListener;Qt.prototype.removeAllListeners=function(e){var t,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function fq(r,e,t){var n=r._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?Xge(i):dq(i,i.length)}Qt.prototype.listeners=function(e){return fq(this,e,!0)};Qt.prototype.rawListeners=function(e){return fq(this,e,!1)};Qt.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):hq.call(r,e)};Qt.prototype.listenerCount=hq;function hq(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Qt.prototype.eventNames=function(){return this._eventsCount>0?h6(this._events):[]};function dq(r,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=r[n];return t}function Qge(r,e){for(;e+1<r.length;e++)r[e]=r[e+1];r.pop()}function Xge(r){for(var e=new Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}function Zge(r,e){return new Promise(function(t,n){function i(o){r.removeListener(e,s),n(o)}function s(){typeof r.removeListener=="function"&&r.removeListener("error",i),t([].slice.call(arguments))}pq(r,e,s,{once:!0}),e!=="error"&&Jge(r,i,{once:!0})})}function Jge(r,e,t){typeof r.on=="function"&&pq(r,"error",e,t)}function pq(r,e,t,n){if(typeof r.on=="function")n.once?r.once(e,t):r.on(e,t);else if(typeof r.addEventListener=="function")r.addEventListener(e,function i(s){n.once&&r.removeEventListener(e,i),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}});var r2=R((UFe,mq)=>{"use strict";u();var p6=iq(),e3e=bn().EventEmitter;async function*t3e(r,e={}){let t=e.concurrency||1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,i=new e3e,s=[],o=p6(),a=p6(),c=!1,l,f=!1;i.on("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(s.length===t&&(o=p6(),await o.promise),f)break;let y={done:!1};s.push(y),m().then(g=>{y.done=!0,y.ok=!0,y.value=g,i.emit("task-complete")},g=>{y.done=!0,y.err=g,i.emit("task-complete")})}c=!0,i.emit("task-complete")}catch(m){l=m,i.emit("task-complete")}});function h(){return Boolean(n?s[0]&&s[0].done:s.find(m=>m.done))}function*p(){for(;s.length&&s[0].done;){let m=s[0];if(s.shift(),m.ok)yield m.value;else throw f=!0,o.resolve(),m.err;o.resolve()}}function*d(){for(;h();)for(let m=0;m<s.length;m++)if(s[m].done){let y=s[m];if(s.splice(m,1),m--,y.ok)yield y.value;else throw f=!0,o.resolve(),y.err;o.resolve()}}for(;;){if(h()||(a=p6(),await a.promise),l)throw l;if(n?yield*p():yield*d(),c&&s.length===0)break}}mq.exports=t3e});var jp=R((JFe,_q)=>{"use strict";u();async function*n3e(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&t.cancel(),t.releaseLock()}}_q.exports=n3e});var Tq=R((eVe,xq)=>{"use strict";u();var Sq=jp();function i3e(r){return typeof r.stream=="function"?Sq(r.stream()):Sq(new Response(r).body)}xq.exports=i3e});var Wp=R((tVe,Iq)=>{"use strict";u();function s3e(r){let[e,t]=r[Symbol.asyncIterator]?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}Iq.exports=s3e});var _6=R((pVe,Uq)=>{"use strict";u();async function*o3e(r,e=1){let t=[];e<1&&(e=1);for await(let n of r)for(t.push(n);t.length>=e;)yield t.slice(0,e),t=t.slice(e);for(;t.length;)yield t.slice(0,e),t=t.slice(e)}Uq.exports=o3e});var S6=R((mVe,Fq)=>{"use strict";u();var a3e=_6();async function*c3e(r,e=1){for await(let t of a3e(r,e)){let n=t.map(i=>i().then(s=>({ok:!0,value:s}),s=>({ok:!1,err:s})));for(let i=0;i<n.length;i++){let s=await n[i];if(s.ok)yield s.value;else throw s.err}}}Fq.exports=c3e});var Vq=R((i2,x6)=>{u();(function(r,e){"use strict";var t={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(d){if(!Array.isArray(d)&&!ArrayBuffer.isView(d))return!1;for(var m=0;m<d.length;m++)if(!Number.isInteger(d[m])||d[m]<0||d[m]>255)return!1;return!0}function i(d,m){return(d&65535)*m+(((d>>>16)*m&65535)<<16)}function s(d,m){return d<<m|d>>>32-m}function o(d){return d^=d>>>16,d=i(d,2246822507),d^=d>>>13,d=i(d,3266489909),d^=d>>>16,d}function a(d,m){d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535],m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535];var y=[0,0,0,0];return y[3]+=d[3]+m[3],y[2]+=y[3]>>>16,y[3]&=65535,y[2]+=d[2]+m[2],y[1]+=y[2]>>>16,y[2]&=65535,y[1]+=d[1]+m[1],y[0]+=y[1]>>>16,y[1]&=65535,y[0]+=d[0]+m[0],y[0]&=65535,[y[0]<<16|y[1],y[2]<<16|y[3]]}function c(d,m){d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535],m=[m[0]>>>16,m[0]&65535,m[1]>>>16,m[1]&65535];var y=[0,0,0,0];return y[3]+=d[3]*m[3],y[2]+=y[3]>>>16,y[3]&=65535,y[2]+=d[2]*m[3],y[1]+=y[2]>>>16,y[2]&=65535,y[2]+=d[3]*m[2],y[1]+=y[2]>>>16,y[2]&=65535,y[1]+=d[1]*m[3],y[0]+=y[1]>>>16,y[1]&=65535,y[1]+=d[2]*m[2],y[0]+=y[1]>>>16,y[1]&=65535,y[1]+=d[3]*m[1],y[0]+=y[1]>>>16,y[1]&=65535,y[0]+=d[0]*m[3]+d[1]*m[2]+d[2]*m[1]+d[3]*m[0],y[0]&=65535,[y[0]<<16|y[1],y[2]<<16|y[3]]}function l(d,m){return m%=64,m===32?[d[1],d[0]]:m<32?[d[0]<<m|d[1]>>>32-m,d[1]<<m|d[0]>>>32-m]:(m-=32,[d[1]<<m|d[0]>>>32-m,d[0]<<m|d[1]>>>32-m])}function f(d,m){return m%=64,m===0?d:m<32?[d[0]<<m|d[1]>>>32-m,d[1]<<m]:[d[1]<<m-32,0]}function h(d,m){return[d[0]^m[0],d[1]^m[1]]}function p(d){return d=h(d,[0,d[0]>>>1]),d=c(d,[4283543511,3981806797]),d=h(d,[0,d[0]>>>1]),d=c(d,[3301882366,444984403]),d=h(d,[0,d[0]>>>1]),d}t.x86.hash32=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%4,g=d.length-y,w=m,b=0,S=3432918353,_=461845907,I=0;I<g;I=I+4)b=d[I]|d[I+1]<<8|d[I+2]<<16|d[I+3]<<24,b=i(b,S),b=s(b,15),b=i(b,_),w^=b,w=s(w,13),w=i(w,5)+3864292196;switch(b=0,y){case 3:b^=d[I+2]<<16;case 2:b^=d[I+1]<<8;case 1:b^=d[I],b=i(b,S),b=s(b,15),b=i(b,_),w^=b}return w^=d.length,w=o(w),w>>>0},t.x86.hash128=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%16,g=d.length-y,w=m,b=m,S=m,_=m,I=0,T=0,x=0,P=0,B=597399067,q=2869860233,Y=951274213,re=2716044179,ie=0;ie<g;ie=ie+16)I=d[ie]|d[ie+1]<<8|d[ie+2]<<16|d[ie+3]<<24,T=d[ie+4]|d[ie+5]<<8|d[ie+6]<<16|d[ie+7]<<24,x=d[ie+8]|d[ie+9]<<8|d[ie+10]<<16|d[ie+11]<<24,P=d[ie+12]|d[ie+13]<<8|d[ie+14]<<16|d[ie+15]<<24,I=i(I,B),I=s(I,15),I=i(I,q),w^=I,w=s(w,19),w+=b,w=i(w,5)+1444728091,T=i(T,q),T=s(T,16),T=i(T,Y),b^=T,b=s(b,17),b+=S,b=i(b,5)+197830471,x=i(x,Y),x=s(x,17),x=i(x,re),S^=x,S=s(S,15),S+=_,S=i(S,5)+2530024501,P=i(P,re),P=s(P,18),P=i(P,B),_^=P,_=s(_,13),_+=w,_=i(_,5)+850148119;switch(I=0,T=0,x=0,P=0,y){case 15:P^=d[ie+14]<<16;case 14:P^=d[ie+13]<<8;case 13:P^=d[ie+12],P=i(P,re),P=s(P,18),P=i(P,B),_^=P;case 12:x^=d[ie+11]<<24;case 11:x^=d[ie+10]<<16;case 10:x^=d[ie+9]<<8;case 9:x^=d[ie+8],x=i(x,Y),x=s(x,17),x=i(x,re),S^=x;case 8:T^=d[ie+7]<<24;case 7:T^=d[ie+6]<<16;case 6:T^=d[ie+5]<<8;case 5:T^=d[ie+4],T=i(T,q),T=s(T,16),T=i(T,Y),b^=T;case 4:I^=d[ie+3]<<24;case 3:I^=d[ie+2]<<16;case 2:I^=d[ie+1]<<8;case 1:I^=d[ie],I=i(I,B),I=s(I,15),I=i(I,q),w^=I}return w^=d.length,b^=d.length,S^=d.length,_^=d.length,w+=b,w+=S,w+=_,b+=w,S+=w,_+=w,w=o(w),b=o(b),S=o(S),_=o(_),w+=b,w+=S,w+=_,b+=w,S+=w,_+=w,("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)+("00000000"+(S>>>0).toString(16)).slice(-8)+("00000000"+(_>>>0).toString(16)).slice(-8)},t.x64.hash128=function(d,m){if(t.inputValidation&&!n(d))return e;m=m||0;for(var y=d.length%16,g=d.length-y,w=[0,m],b=[0,m],S=[0,0],_=[0,0],I=[2277735313,289559509],T=[1291169091,658871167],x=0;x<g;x=x+16)S=[d[x+4]|d[x+5]<<8|d[x+6]<<16|d[x+7]<<24,d[x]|d[x+1]<<8|d[x+2]<<16|d[x+3]<<24],_=[d[x+12]|d[x+13]<<8|d[x+14]<<16|d[x+15]<<24,d[x+8]|d[x+9]<<8|d[x+10]<<16|d[x+11]<<24],S=c(S,I),S=l(S,31),S=c(S,T),w=h(w,S),w=l(w,27),w=a(w,b),w=a(c(w,[0,5]),[0,1390208809]),_=c(_,T),_=l(_,33),_=c(_,I),b=h(b,_),b=l(b,31),b=a(b,w),b=a(c(b,[0,5]),[0,944331445]);switch(S=[0,0],_=[0,0],y){case 15:_=h(_,f([0,d[x+14]],48));case 14:_=h(_,f([0,d[x+13]],40));case 13:_=h(_,f([0,d[x+12]],32));case 12:_=h(_,f([0,d[x+11]],24));case 11:_=h(_,f([0,d[x+10]],16));case 10:_=h(_,f([0,d[x+9]],8));case 9:_=h(_,[0,d[x+8]]),_=c(_,T),_=l(_,33),_=c(_,I),b=h(b,_);case 8:S=h(S,f([0,d[x+7]],56));case 7:S=h(S,f([0,d[x+6]],48));case 6:S=h(S,f([0,d[x+5]],40));case 5:S=h(S,f([0,d[x+4]],32));case 4:S=h(S,f([0,d[x+3]],24));case 3:S=h(S,f([0,d[x+2]],16));case 2:S=h(S,f([0,d[x+1]],8));case 1:S=h(S,[0,d[x]]),S=c(S,I),S=l(S,31),S=c(S,T),w=h(w,S)}return w=h(w,[0,d.length]),b=h(b,[0,d.length]),w=a(w,b),b=a(b,w),w=p(w),b=p(b),w=a(w,b),b=a(b,w),("00000000"+(w[0]>>>0).toString(16)).slice(-8)+("00000000"+(w[1]>>>0).toString(16)).slice(-8)+("00000000"+(b[0]>>>0).toString(16)).slice(-8)+("00000000"+(b[1]>>>0).toString(16)).slice(-8)},typeof i2<"u"?(typeof x6<"u"&&x6.exports&&(i2=x6.exports=t),i2.murmurHash3=t):typeof define=="function"&&define.amd?define([],function(){return t}):(t._murmurHash3=r.murmurHash3,t.noConflict=function(){return r.murmurHash3=t._murmurHash3,t._murmurHash3=e,t.noConflict=e,t},r.murmurHash3=t)})(i2)});var qq=R((yVe,Kq)=>{u();Kq.exports=Vq()});var Hx=R((GVe,nz)=>{"use strict";u();var{Buffer:Po}=Tf(),rz=Symbol.for("BufferList");function cr(r){if(!(this instanceof cr))return new cr(r);cr._init.call(this,r)}cr._init=function(e){Object.defineProperty(this,rz,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)};cr.prototype._new=function(e){return new cr(e)};cr.prototype._offset=function(e){if(e===0)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){let i=t+this._bufs[n].length;if(e<i||n===this._bufs.length-1)return[n,e-t];t=i}};cr.prototype._reverseOffset=function(r){let e=r[0],t=r[1];for(let n=0;n<e;n++)t+=this._bufs[n].length;return t};cr.prototype.get=function(e){if(e>this.length||e<0)return;let t=this._offset(e);return this._bufs[t[0]][t[1]]};cr.prototype.slice=function(e,t){return typeof e=="number"&&e<0&&(e+=this.length),typeof t=="number"&&t<0&&(t+=this.length),this.copy(null,0,e,t)};cr.prototype.copy=function(e,t,n,i){if((typeof n!="number"||n<0)&&(n=0),(typeof i!="number"||i>this.length)&&(i=this.length),n>=this.length||i<=0)return e||Po.alloc(0);let s=!!e,o=this._offset(n),a=i-n,c=a,l=s&&t||0,f=o[1];if(n===0&&i===this.length){if(!s)return this._bufs.length===1?this._bufs[0]:Po.concat(this._bufs,this.length);for(let h=0;h<this._bufs.length;h++)this._bufs[h].copy(e,l),l+=this._bufs[h].length;return e}if(c<=this._bufs[o[0]].length-f)return s?this._bufs[o[0]].copy(e,t,f,f+c):this._bufs[o[0]].slice(f,f+c);s||(e=Po.allocUnsafe(a));for(let h=o[0];h<this._bufs.length;h++){let p=this._bufs[h].length-f;if(c>p)this._bufs[h].copy(e,l,f),l+=p;else{this._bufs[h].copy(e,l,f,f+c),l+=p;break}c-=p,f&&(f=0)}return e.length>l?e.slice(0,l):e};cr.prototype.shallowSlice=function(e,t){if(e=e||0,t=typeof t!="number"?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();let n=this._offset(e),i=this._offset(t),s=this._bufs.slice(n[0],i[0]+1);return i[1]===0?s.pop():s[s.length-1]=s[s.length-1].slice(0,i[1]),n[1]!==0&&(s[0]=s[0].slice(n[1])),this._new(s)};cr.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)};cr.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;)if(e>=this._bufs[0].length)e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}return this};cr.prototype.duplicate=function(){let e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e};cr.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(Po.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else typeof e=="number"&&(e=e.toString()),this._appendBuffer(Po.from(e));return this};cr.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length};cr.prototype.indexOf=function(r,e,t){if(t===void 0&&typeof e=="string"&&(t=e,e=void 0),typeof r=="function"||Array.isArray(r))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof r=="number"?r=Po.from([r]):typeof r=="string"?r=Po.from(r,t):this._isBufferList(r)?r=r.slice():Array.isArray(r.buffer)?r=Po.from(r.buffer,r.byteOffset,r.byteLength):Po.isBuffer(r)||(r=Po.from(r)),e=Number(e||0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),r.length===0)return e>this.length?this.length:e;let n=this._offset(e),i=n[0],s=n[1];for(;i<this._bufs.length;i++){let o=this._bufs[i];for(;s<o.length;)if(o.length-s>=r.length){let c=o.indexOf(r,s);if(c!==-1)return this._reverseOffset([i,c]);s=o.length-r.length+1}else{let c=this._reverseOffset([i,s]);if(this._match(c,r))return c;s++}s=0}return-1};cr.prototype._match=function(r,e){if(this.length-r<e.length)return!1;for(let t=0;t<e.length;t++)if(this.get(r+t)!==e[t])return!1;return!0};(function(){let r={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let e in r)(function(t){r[t]===null?cr.prototype[t]=function(n,i){return this.slice(n,n+i)[t](0,i)}:cr.prototype[t]=function(n=0){return this.slice(n,n+r[t])[t](0)}})(e)})();cr.prototype._isBufferList=function(e){return e instanceof cr||cr.isBufferList(e)};cr.isBufferList=function(e){return e!=null&&e[rz]};nz.exports=cr});var sz=R((jVe,iz)=>{u();var Gx=class{constructor(e,t=12,n=8*1024,i=32*1024,s=64,o){this.bits=t,this.min=n,this.max=i,this.asModule=e,this.rabin=new e.Rabin(t,n,i,s,o),this.polynomial=o}fingerprint(e){let{__retain:t,__release:n,__allocArray:i,__getInt32Array:s,Int32Array_ID:o,Uint8Array_ID:a}=this.asModule,c=new Int32Array(Math.ceil(e.length/this.min)),l=t(i(o,c)),f=t(i(a,e)),h=this.rabin.fingerprint(f,l),p=s(h);n(f),n(l);let d=p.indexOf(0);return d>=0?p.subarray(0,d):p}};iz.exports=Gx});var fz=R(a2=>{"use strict";u();var _3e=typeof BigUint64Array<"u",s2=Symbol(),o2=1024;function oz(r,e){let t=new Uint32Array(r),n=new Uint16Array(r);var i=t[e+-4>>>2]>>>1,s=e>>>1;if(i<=o2)return String.fromCharCode.apply(String,n.subarray(s,s+i));let o=[];do{let a=n[s+o2-1],c=a>=55296&&a<56320?o2-1:o2;o.push(String.fromCharCode.apply(String,n.subarray(s,s+=c))),i-=c}while(i>o2);return o.join("")+String.fromCharCode.apply(String,n.subarray(s,s+i))}function jx(r){let e={};function t(i,s){return i?oz(i.buffer,s):"<yet unknown>"}let n=r.env=r.env||{};return n.abort=n.abort||function(s,o,a,c){let l=e.memory||n.memory;throw Error("abort: "+t(l,s)+" at "+t(l,o)+":"+a+":"+c)},n.trace=n.trace||function(s,o){let a=e.memory||n.memory;console.log("trace: "+t(a,s)+(o?" ":"")+Array.prototype.slice.call(arguments,2,2+o).join(", "))},r.Math=r.Math||Math,r.Date=r.Date||Date,e}function Wx(r,e){let t=e.exports,n=t.memory,i=t.table,s=t.__alloc,o=t.__retain,a=t.__rtti_base||-1;function c(T){let x=new Uint32Array(n.buffer),P=x[a>>>2];if((T>>>=0)>=P)throw Error("invalid id: "+T);return x[(a+4>>>2)+T*2]}function l(T){let x=new Uint32Array(n.buffer),P=x[a>>>2];if((T>>>=0)>=P)throw Error("invalid id: "+T);return x[(a+4>>>2)+T*2+1]}function f(T){return 31-Math.clz32(T>>>5&31)}function h(T){return 31-Math.clz32(T>>>14&31)}function p(T){let x=T.length,P=s(x<<1,1),B=new Uint16Array(n.buffer);for(var q=0,Y=P>>>1;q<x;++q)B[Y+q]=T.charCodeAt(q);return P}r.__allocString=p;function d(T){let x=n.buffer;if(new Uint32Array(x)[T+-8>>>2]!==1)throw Error("not a string: "+T);return oz(x,T)}r.__getString=d;function m(T,x,P){let B=n.buffer;if(P)switch(T){case 2:return new Float32Array(B);case 3:return new Float64Array(B)}else switch(T){case 0:return new(x?Int8Array:Uint8Array)(B);case 1:return new(x?Int16Array:Uint16Array)(B);case 2:return new(x?Int32Array:Uint32Array)(B);case 3:return new(x?BigInt64Array:BigUint64Array)(B)}throw Error("unsupported align: "+T)}function y(T,x){let P=c(T);if(!(P&3))throw Error("not an array: "+T+" @ "+P);let B=f(P),q=x.length,Y=s(q<<B,0),re=s(P&2?16:12,T),ie=new Uint32Array(n.buffer);ie[re+0>>>2]=o(Y),ie[re+4>>>2]=Y,ie[re+8>>>2]=q<<B,P&2&&(ie[re+12>>>2]=q);let Ce=m(B,P&1024,P&2048);if(P&8192)for(let Ee=0;Ee<q;++Ee)Ce[(Y>>>B)+Ee]=o(x[Ee]);else Ce.set(x,Y>>>B);return re}r.__allocArray=y;function g(T){let x=new Uint32Array(n.buffer),P=x[T+-8>>>2],B=c(P);if(!(B&1))throw Error("not an array: "+P);let q=f(B);var Y=x[T+4>>>2];let re=B&2?x[T+12>>>2]:x[Y+-4>>>2]>>>q;return m(q,B&1024,B&2048).subarray(Y>>>=q,Y+re)}r.__getArrayView=g;function w(T){let x=g(T),P=x.length,B=new Array(P);for(let q=0;q<P;q++)B[q]=x[q];return B}r.__getArray=w;function b(T){let x=n.buffer,P=new Uint32Array(x)[T+-4>>>2];return x.slice(T,T+P)}r.__getArrayBuffer=b;function S(T,x,P){return new T(_(T,x,P))}function _(T,x,P){let B=n.buffer,q=new Uint32Array(B),Y=q[P+4>>>2];return new T(B,Y,q[Y+-4>>>2]>>>x)}r.__getInt8Array=S.bind(null,Int8Array,0),r.__getInt8ArrayView=_.bind(null,Int8Array,0),r.__getUint8Array=S.bind(null,Uint8Array,0),r.__getUint8ArrayView=_.bind(null,Uint8Array,0),r.__getUint8ClampedArray=S.bind(null,Uint8ClampedArray,0),r.__getUint8ClampedArrayView=_.bind(null,Uint8ClampedArray,0),r.__getInt16Array=S.bind(null,Int16Array,1),r.__getInt16ArrayView=_.bind(null,Int16Array,1),r.__getUint16Array=S.bind(null,Uint16Array,1),r.__getUint16ArrayView=_.bind(null,Uint16Array,1),r.__getInt32Array=S.bind(null,Int32Array,2),r.__getInt32ArrayView=_.bind(null,Int32Array,2),r.__getUint32Array=S.bind(null,Uint32Array,2),r.__getUint32ArrayView=_.bind(null,Uint32Array,2),_3e&&(r.__getInt64Array=S.bind(null,BigInt64Array,3),r.__getInt64ArrayView=_.bind(null,BigInt64Array,3),r.__getUint64Array=S.bind(null,BigUint64Array,3),r.__getUint64ArrayView=_.bind(null,BigUint64Array,3)),r.__getFloat32Array=S.bind(null,Float32Array,2),r.__getFloat32ArrayView=_.bind(null,Float32Array,2),r.__getFloat64Array=S.bind(null,Float64Array,3),r.__getFloat64ArrayView=_.bind(null,Float64Array,3);function I(T,x){let P=new Uint32Array(n.buffer);var B=P[T+-8>>>2];if(B<=P[a>>>2])do if(B==x)return!0;while(B=l(B));return!1}return r.__instanceof=I,r.memory=r.memory||n,r.table=r.table||i,uz(t,r)}function az(r){return typeof Response<"u"&&r instanceof Response}async function cz(r,e){return az(r=await r)?lz(r,e):Wx(jx(e||(e={})),await WebAssembly.instantiate(r instanceof WebAssembly.Module?r:await WebAssembly.compile(r),e))}a2.instantiate=cz;function S3e(r,e){return Wx(jx(e||(e={})),new WebAssembly.Instance(r instanceof WebAssembly.Module?r:new WebAssembly.Module(r),e))}a2.instantiateSync=S3e;async function lz(r,e){return WebAssembly.instantiateStreaming?Wx(jx(e||(e={})),(await WebAssembly.instantiateStreaming(r,e)).instance):cz(az(r=await r)?r.arrayBuffer():r,e)}a2.instantiateStreaming=lz;function uz(r,e){var t=e?Object.create(e):{},n=r.__argumentsLength?function(i){r.__argumentsLength.value=i}:r.__setArgumentsLength||r.__setargc||function(){};for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let s=r[i],o=i.split("."),a=t;for(;o.length>1;){let f=o.shift();Object.prototype.hasOwnProperty.call(a,f)||(a[f]={}),a=a[f]}let c=o[0],l=c.indexOf("#");if(l>=0){let f=c.substring(0,l),h=a[f];if(typeof h>"u"||!h.prototype){let p=function(...d){return p.wrap(p.prototype.constructor(0,...d))};p.prototype={valueOf:function(){return this[s2]}},p.wrap=function(d){return Object.create(p.prototype,{[s2]:{value:d,writable:!1}})},h&&Object.getOwnPropertyNames(h).forEach(d=>Object.defineProperty(p,d,Object.getOwnPropertyDescriptor(h,d))),a[f]=p}if(c=c.substring(l+1),a=a[f].prototype,/^(get|set):/.test(c)){if(!Object.prototype.hasOwnProperty.call(a,c=c.substring(4))){let p=r[i.replace("set:","get:")],d=r[i.replace("get:","set:")];Object.defineProperty(a,c,{get:function(){return p(this[s2])},set:function(m){d(this[s2],m)},enumerable:!0})}}else c==="constructor"?(a[c]=(...p)=>(n(p.length),s(...p))).original=s:(a[c]=function(...p){return n(p.length),s(this[s2],...p)}).original=s}else/^(get|set):/.test(c)?Object.prototype.hasOwnProperty.call(a,c=c.substring(4))||Object.defineProperty(a,c,{get:r[i.replace("set:","get:")],set:r[i.replace("get:","set:")],enumerable:!0}):typeof s=="function"&&s!==n?(a[c]=(...f)=>(n(f.length),s(...f))).original=s:a[c]=s}return t}a2.demangle=uz});var dz=R((YVe,hz)=>{u();var{instantiate:x3e}=fz();Yx.supported=typeof WebAssembly<"u";function Yx(r={}){if(!Yx.supported)return null;var e=new Uint8Array([0,97,115,109,1,0,0,0,1,78,14,96,2,127,126,0,96,1,127,1,126,96,2,127,127,0,96,1,127,1,127,96,1,127,0,96,2,127,127,1,127,96,3,127,127,127,1,127,96,0,0,96,3,127,127,127,0,96,0,1,127,96,4,127,127,127,127,0,96,5,127,127,127,127,127,1,127,96,1,126,1,127,96,2,126,126,1,126,2,13,1,3,101,110,118,5,97,98,111,114,116,0,10,3,54,53,2,2,8,9,3,5,2,8,6,5,3,4,2,6,9,12,13,2,5,11,3,2,3,2,3,2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,6,7,7,4,4,5,3,1,0,1,6,47,9,127,1,65,0,11,127,1,65,0,11,127,0,65,3,11,127,0,65,4,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,0,65,240,2,11,127,0,65,6,11,7,240,5,41,6,109,101,109,111,114,121,2,0,7,95,95,97,108,108,111,99,0,10,8,95,95,114,101,116,97,105,110,0,11,9,95,95,114,101,108,101,97,115,101,0,12,9,95,95,99,111,108,108,101,99,116,0,51,11,95,95,114,116,116,105,95,98,97,115,101,3,7,13,73,110,116,51,50,65,114,114,97,121,95,73,68,3,2,13,85,105,110,116,56,65,114,114,97,121,95,73,68,3,3,6,100,101,103,114,101,101,0,16,3,109,111,100,0,17,5,82,97,98,105,110,3,8,16,82,97,98,105,110,35,103,101,116,58,119,105,110,100,111,119,0,21,16,82,97,98,105,110,35,115,101,116,58,119,105,110,100,111,119,0,22,21,82,97,98,105,110,35,103,101,116,58,119,105,110,100,111,119,95,115,105,122,101,0,23,21,82,97,98,105,110,35,115,101,116,58,119,105,110,100,111,119,95,115,105,122,101,0,24,14,82,97,98,105,110,35,103,101,116,58,119,112,111,115,0,25,14,82,97,98,105,110,35,115,101,116,58,119,112,111,115,0,26,15,82,97,98,105,110,35,103,101,116,58,99,111,117,110,116,0,27,15,82,97,98,105,110,35,115,101,116,58,99,111,117,110,116,0,28,13,82,97,98,105,110,35,103,101,116,58,112,111,115,0,29,13,82,97,98,105,110,35,115,101,116,58,112,111,115,0,30,15,82,97,98,105,110,35,103,101,116,58,115,116,97,114,116,0,31,15,82,97,98,105,110,35,115,101,116,58,115,116,97,114,116,0,32,16,82,97,98,105,110,35,103,101,116,58,100,105,103,101,115,116,0,33,16,82,97,98,105,110,35,115,101,116,58,100,105,103,101,115,116,0,34,21,82,97,98,105,110,35,103,101,116,58,99,104,117,110,107,95,115,116,97,114,116,0,35,21,82,97,98,105,110,35,115,101,116,58,99,104,117,110,107,95,115,116,97,114,116,0,36,22,82,97,98,105,110,35,103,101,116,58,99,104,117,110,107,95,108,101,110,103,116,104,0,37,22,82,97,98,105,110,35,115,101,116,58,99,104,117,110,107,95,108,101,110,103,116,104,0,38,31,82,97,98,105,110,35,103,101,116,58,99,104,117,110,107,95,99,117,116,95,102,105,110,103,101,114,112,114,105,110,116,0,39,31,82,97,98,105,110,35,115,101,116,58,99,104,117,110,107,95,99,117,116,95,102,105,110,103,101,114,112,114,105,110,116,0,40,20,82,97,98,105,110,35,103,101,116,58,112,111,108,121,110,111,109,105,97,108,0,41,20,82,97,98,105,110,35,115,101,116,58,112,111,108,121,110,111,109,105,97,108,0,42,17,82,97,98,105,110,35,103,101,116,58,109,105,110,115,105,122,101,0,43,17,82,97,98,105,110,35,115,101,116,58,109,105,110,115,105,122,101,0,44,17,82,97,98,105,110,35,103,101,116,58,109,97,120,115,105,122,101,0,45,17,82,97,98,105,110,35,115,101,116,58,109,97,120,115,105,122,101,0,46,14,82,97,98,105,110,35,103,101,116,58,109,97,115,107,0,47,14,82,97,98,105,110,35,115,101,116,58,109,97,115,107,0,48,17,82,97,98,105,110,35,99,111,110,115,116,114,117,99,116,111,114,0,20,17,82,97,98,105,110,35,102,105,110,103,101,114,112,114,105,110,116,0,49,8,1,50,10,165,31,53,199,1,1,4,127,32,1,40,2,0,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,33,4,65,0,5,32,2,65,31,32,2,103,107,34,3,65,4,107,118,65,16,115,33,4,32,3,65,7,107,11,33,3,32,1,40,2,20,33,2,32,1,40,2,16,34,5,4,64,32,5,32,2,54,2,20,11,32,2,4,64,32,2,32,5,54,2,16,11,32,1,32,0,32,4,32,3,65,4,116,106,65,2,116,106,40,2,96,70,4,64,32,0,32,4,32,3,65,4,116,106,65,2,116,106,32,2,54,2,96,32,2,69,4,64,32,0,32,3,65,2,116,106,32,0,32,3,65,2,116,106,40,2,4,65,1,32,4,116,65,127,115,113,34,1,54,2,4,32,1,69,4,64,32,0,32,0,40,2,0,65,1,32,3,116,65,127,115,113,54,2,0,11,11,11,11,226,2,1,6,127,32,1,40,2,0,33,3,32,1,65,16,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,34,5,65,1,113,4,64,32,3,65,124,113,65,16,106,32,5,65,124,113,106,34,2,65,240,255,255,255,3,73,4,64,32,0,32,4,16,1,32,1,32,2,32,3,65,3,113,114,34,3,54,2,0,32,1,65,16,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,33,5,11,11,32,3,65,2,113,4,64,32,1,65,4,107,40,2,0,34,2,40,2,0,34,6,65,124,113,65,16,106,32,3,65,124,113,106,34,7,65,240,255,255,255,3,73,4,64,32,0,32,2,16,1,32,2,32,7,32,6,65,3,113,114,34,3,54,2,0,32,2,33,1,11,11,32,4,32,5,65,2,114,54,2,0,32,4,65,4,107,32,1,54,2,0,32,0,32,3,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,33,4,65,0,5,32,2,65,31,32,2,103,107,34,2,65,4,107,118,65,16,115,33,4,32,2,65,7,107,11,34,3,65,4,116,32,4,106,65,2,116,106,40,2,96,33,2,32,1,65,0,54,2,16,32,1,32,2,54,2,20,32,2,4,64,32,2,32,1,54,2,16,11,32,0,32,4,32,3,65,4,116,106,65,2,116,106,32,1,54,2,96,32,0,32,0,40,2,0,65,1,32,3,116,114,54,2,0,32,0,32,3,65,2,116,106,32,0,32,3,65,2,116,106,40,2,4,65,1,32,4,116,114,54,2,4,11,119,1,1,127,32,2,2,127,32,0,40,2,160,12,34,2,4,64,32,2,32,1,65,16,107,70,4,64,32,2,40,2,0,33,3,32,1,65,16,107,33,1,11,11,32,1,11,107,34,2,65,48,73,4,64,15,11,32,1,32,3,65,2,113,32,2,65,32,107,65,1,114,114,54,2,0,32,1,65,0,54,2,16,32,1,65,0,54,2,20,32,1,32,2,106,65,16,107,34,2,65,2,54,2,0,32,0,32,2,54,2,160,12,32,0,32,1,16,2,11,155,1,1,3,127,35,0,34,0,69,4,64,65,1,63,0,34,0,74,4,127,65,1,32,0,107,64,0,65,0,72,5,65,0,11,4,64,0,11,65,176,3,34,0,65,0,54,2,0,65,208,15,65,0,54,2,0,3,64,32,1,65,23,73,4,64,32,1,65,2,116,65,176,3,106,65,0,54,2,4,65,0,33,2,3,64,32,2,65,16,73,4,64,32,1,65,4,116,32,2,106,65,2,116,65,176,3,106,65,0,54,2,96,32,2,65,1,106,33,2,12,1,11,11,32,1,65,1,106,33,1,12,1,11,11,65,176,3,65,224,15,63,0,65,16,116,16,3,65,176,3,36,0,11,32,0,11,45,0,32,0,65,240,255,255,255,3,79,4,64,65,32,65,224,0,65,201,3,65,29,16,0,0,11,32,0,65,15,106,65,112,113,34,0,65,16,32,0,65,16,75,27,11,169,1,1,1,127,32,0,32,1,65,128,2,73,4,127,32,1,65,4,118,33,1,65,0,5,32,1,65,248,255,255,255,1,73,4,64,32,1,65,1,65,27,32,1,103,107,116,106,65,1,107,33,1,11,32,1,65,31,32,1,103,107,34,2,65,4,107,118,65,16,115,33,1,32,2,65,7,107,11,34,2,65,2,116,106,40,2,4,65,127,32,1,116,113,34,1,4,127,32,0,32,1,104,32,2,65,4,116,106,65,2,116,106,40,2,96,5,32,0,40,2,0,65,127,32,2,65,1,106,116,113,34,1,4,127,32,0,32,0,32,1,104,34,0,65,2,116,106,40,2,4,104,32,0,65,4,116,106,65,2,116,106,40,2,96,5,65,0,11,11,11,111,1,1,127,63,0,34,2,32,1,65,248,255,255,255,1,73,4,127,32,1,65,1,65,27,32,1,103,107,116,65,1,107,106,5,32,1,11,65,16,32,0,40,2,160,12,32,2,65,16,116,65,16,107,71,116,106,65,255,255,3,106,65,128,128,124,113,65,16,118,34,1,32,2,32,1,74,27,64,0,65,0,72,4,64,32,1,64,0,65,0,72,4,64,0,11,11,32,0,32,2,65,16,116,63,0,65,16,116,16,3,11,113,1,2,127,32,1,40,2,0,34,3,65,124,113,32,2,107,34,4,65,32,79,4,64,32,1,32,2,32,3,65,2,113,114,54,2,0,32,2,32,1,65,16,106,106,34,1,32,4,65,16,107,65,1,114,54,2,0,32,0,32,1,16,2,5,32,1,32,3,65,126,113,54,2,0,32,1,65,16,106,32,1,40,2,0,65,124,113,106,32,1,65,16,106,32,1,40,2,0,65,124,113,106,40,2,0,65,125,113,54,2,0,11,11,91,1,2,127,32,0,32,1,16,5,34,4,16,6,34,3,69,4,64,65,1,36,1,65,0,36,1,32,0,32,4,16,6,34,3,69,4,64,32,0,32,4,16,7,32,0,32,4,16,6,33,3,11,11,32,3,65,0,54,2,4,32,3,32,2,54,2,8,32,3,32,1,54,2,12,32,0,32,3,16,1,32,0,32,3,32,4,16,8,32,3,11,13,0,16,4,32,0,32,1,16,9,65,16,106,11,33,1,1,127,32,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,32,0,11,18,0,32,0,65,172,3,75,4,64,32,0,65,16,107,16,52,11,11,140,3,1,1,127,2,64,32,1,69,13,0,32,0,65,0,58,0,0,32,0,32,1,106,65,1,107,65,0,58,0,0,32,1,65,2,77,13,0,32,0,65,1,106,65,0,58,0,0,32,0,65,2,106,65,0,58,0,0,32,0,32,1,106,34,2,65,2,107,65,0,58,0,0,32,2,65,3,107,65,0,58,0,0,32,1,65,6,77,13,0,32,0,65,3,106,65,0,58,0,0,32,0,32,1,106,65,4,107,65,0,58,0,0,32,1,65,8,77,13,0,32,1,65,0,32,0,107,65,3,113,34,1,107,33,2,32,0,32,1,106,34,0,65,0,54,2,0,32,0,32,2,65,124,113,34,1,106,65,4,107,65,0,54,2,0,32,1,65,8,77,13,0,32,0,65,4,106,65,0,54,2,0,32,0,65,8,106,65,0,54,2,0,32,0,32,1,106,34,2,65,12,107,65,0,54,2,0,32,2,65,8,107,65,0,54,2,0,32,1,65,24,77,13,0,32,0,65,12,106,65,0,54,2,0,32,0,65,16,106,65,0,54,2,0,32,0,65,20,106,65,0,54,2,0,32,0,65,24,106,65,0,54,2,0,32,0,32,1,106,34,2,65,28,107,65,0,54,2,0,32,2,65,24,107,65,0,54,2,0,32,2,65,20,107,65,0,54,2,0,32,2,65,16,107,65,0,54,2,0,32,0,32,0,65,4,113,65,24,106,34,2,106,33,0,32,1,32,2,107,33,1,3,64,32,1,65,32,79,4,64,32,0,66,0,55,3,0,32,0,65,8,106,66,0,55,3,0,32,0,65,16,106,66,0,55,3,0,32,0,65,24,106,66,0,55,3,0,32,1,65,32,107,33,1,32,0,65,32,106,33,0,12,1,11,11,11,11,178,1,1,3,127,32,1,65,240,255,255,255,3,32,2,118,75,4,64,65,144,1,65,192,1,65,23,65,56,16,0,0,11,32,1,32,2,116,34,3,65,0,16,10,34,2,32,3,16,13,32,0,69,4,64,65,12,65,2,16,10,34,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,11,32,0,65,0,54,2,0,32,0,65,0,54,2,4,32,0,65,0,54,2,8,32,2,34,1,32,0,40,2,0,34,4,71,4,64,32,1,65,172,3,75,4,64,32,1,65,16,107,34,5,32,5,40,2,4,65,1,106,54,2,4,11,32,4,16,12,11,32,0,32,1,54,2,0,32,0,32,2,54,2,4,32,0,32,3,54,2,8,32,0,11,46,1,2,127,65,12,65,5,16,10,34,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,32,0,65,128,2,65,3,16,14,11,9,0,65,63,32,0,121,167,107,11,49,1,2,127,65,63,32,1,121,167,107,33,2,3,64,65,63,32,0,121,167,107,32,2,107,34,3,65,0,78,4,64,32,0,32,1,32,3,172,134,133,33,0,12,1,11,11,32,0,11,40,0,32,1,32,0,40,2,8,79,4,64,65,128,2,65,192,2,65,163,1,65,44,16,0,0,11,32,1,32,0,40,2,4,106,65,0,58,0,0,11,38,0,32,1,32,0,40,2,8,79,4,64,65,128,2,65,192,2,65,152,1,65,44,16,0,0,11,32,1,32,0,40,2,4,106,45,0,0,11,254,5,2,1,127,4,126,32,0,69,4,64,65,232,0,65,6,16,10,34,0,65,172,3,75,4,64,32,0,65,16,107,34,5,32,5,40,2,4,65,1,106,54,2,4,11,11,32,0,65,0,54,2,0,32,0,65,0,54,2,4,32,0,65,0,54,2,8,32,0,66,0,55,3,16,32,0,66,0,55,3,24,32,0,66,0,55,3,32,32,0,66,0,55,3,40,32,0,66,0,55,3,48,32,0,66,0,55,3,56,32,0,66,0,55,3,64,32,0,66,0,55,3,72,32,0,66,0,55,3,80,32,0,66,0,55,3,88,32,0,66,0,55,3,96,32,0,32,2,173,55,3,80,32,0,32,3,173,55,3,88,65,12,65,4,16,10,34,2,65,172,3,75,4,64,32,2,65,16,107,34,3,32,3,40,2,4,65,1,106,54,2,4,11,32,2,32,4,65,0,16,14,33,2,32,0,40,2,0,16,12,32,0,32,2,54,2,0,32,0,32,4,54,2,4,32,0,66,1,32,1,173,134,66,1,125,55,3,96,32,0,66,243,130,183,218,216,230,232,30,55,3,72,35,4,69,4,64,65,0,33,2,3,64,32,2,65,128,2,72,4,64,32,2,65,255,1,113,173,33,6,32,0,41,3,72,34,7,33,8,65,63,32,7,121,167,107,33,1,3,64,65,63,32,6,121,167,107,32,1,107,34,3,65,0,78,4,64,32,6,32,8,32,3,172,134,133,33,6,12,1,11,11,65,0,33,4,3,64,32,4,32,0,40,2,4,65,1,107,72,4,64,32,6,66,8,134,33,6,32,0,41,3,72,34,7,33,8,65,63,32,7,121,167,107,33,1,3,64,65,63,32,6,121,167,107,32,1,107,34,3,65,0,78,4,64,32,6,32,8,32,3,172,134,133,33,6,12,1,11,11,32,4,65,1,106,33,4,12,1,11,11,35,6,40,2,4,32,2,65,3,116,106,32,6,55,3,0,32,2,65,1,106,33,2,12,1,11,11,65,63,32,0,41,3,72,121,167,107,172,33,7,65,0,33,2,3,64,32,2,65,128,2,72,4,64,35,5,33,1,32,2,172,32,7,134,34,8,33,6,65,63,32,0,41,3,72,34,9,121,167,107,33,3,3,64,65,63,32,6,121,167,107,32,3,107,34,4,65,0,78,4,64,32,6,32,9,32,4,172,134,133,33,6,12,1,11,11,32,1,40,2,4,32,2,65,3,116,106,32,6,32,8,132,55,3,0,32,2,65,1,106,33,2,12,1,11,11,65,1,36,4,11,32,0,66,0,55,3,24,32,0,66,0,55,3,32,65,0,33,2,3,64,32,2,32,0,40,2,4,72,4,64,32,0,40,2,0,32,2,16,18,32,2,65,1,106,33,2,12,1,11,11,32,0,66,0,55,3,40,32,0,65,0,54,2,8,32,0,66,0,55,3,16,32,0,66,0,55,3,40,32,0,40,2,0,32,0,40,2,8,16,19,33,1,32,0,40,2,8,32,0,40,2,0,40,2,4,106,65,1,58,0,0,32,0,32,0,41,3,40,35,6,40,2,4,32,1,65,3,116,106,41,3,0,133,55,3,40,32,0,32,0,40,2,8,65,1,106,32,0,40,2,4,111,54,2,8,32,0,35,5,40,2,4,32,0,41,3,40,34,6,66,45,136,167,65,3,116,106,41,3,0,32,6,66,8,134,66,1,132,133,55,3,40,32,0,11,38,1,1,127,32,0,40,2,0,34,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,32,0,11,55,1,2,127,32,1,32,0,40,2,0,34,2,71,4,64,32,1,65,172,3,75,4,64,32,1,65,16,107,34,3,32,3,40,2,4,65,1,106,54,2,4,11,32,2,16,12,11,32,0,32,1,54,2,0,11,7,0,32,0,40,2,4,11,9,0,32,0,32,1,54,2,4,11,7,0,32,0,40,2,8,11,9,0,32,0,32,1,54,2,8,11,7,0,32,0,41,3,16,11,9,0,32,0,32,1,55,3,16,11,7,0,32,0,41,3,24,11,9,0,32,0,32,1,55,3,24,11,7,0,32,0,41,3,32,11,9,0,32,0,32,1,55,3,32,11,7,0,32,0,41,3,40,11,9,0,32,0,32,1,55,3,40,11,7,0,32,0,41,3,48,11,9,0,32,0,32,1,55,3,48,11,7,0,32,0,41,3,56,11,9,0,32,0,32,1,55,3,56,11,7,0,32,0,41,3,64,11,9,0,32,0,32,1,55,3,64,11,7,0,32,0,41,3,72,11,9,0,32,0,32,1,55,3,72,11,7,0,32,0,41,3,80,11,9,0,32,0,32,1,55,3,80,11,7,0,32,0,41,3,88,11,9,0,32,0,32,1,55,3,88,11,7,0,32,0,41,3,96,11,9,0,32,0,32,1,55,3,96,11,172,4,2,5,127,1,126,32,2,65,172,3,75,4,64,32,2,65,16,107,34,4,32,4,40,2,4,65,1,106,54,2,4,11,32,2,33,4,65,0,33,2,32,1,40,2,8,33,5,32,1,40,2,4,33,6,3,64,2,127,65,0,33,3,3,64,32,3,32,5,72,4,64,32,3,32,6,106,45,0,0,33,1,32,0,40,2,0,32,0,40,2,8,16,19,33,7,32,0,40,2,8,32,0,40,2,0,40,2,4,106,32,1,58,0,0,32,0,32,0,41,3,40,35,6,40,2,4,32,7,65,3,116,106,41,3,0,133,55,3,40,32,0,32,0,40,2,8,65,1,106,32,0,40,2,4,111,54,2,8,32,0,35,5,40,2,4,32,0,41,3,40,34,8,66,45,136,167,65,3,116,106,41,3,0,32,1,173,32,8,66,8,134,132,133,55,3,40,32,0,32,0,41,3,16,66,1,124,55,3,16,32,0,32,0,41,3,24,66,1,124,55,3,24,32,0,41,3,16,32,0,41,3,80,90,4,127,32,0,41,3,40,32,0,41,3,96,131,80,5,65,0,11,4,127,65,1,5,32,0,41,3,16,32,0,41,3,88,90,11,4,64,32,0,32,0,41,3,32,55,3,48,32,0,32,0,41,3,16,55,3,56,32,0,32,0,41,3,40,55,3,64,65,0,33,1,3,64,32,1,32,0,40,2,4,72,4,64,32,0,40,2,0,32,1,16,18,32,1,65,1,106,33,1,12,1,11,11,32,0,66,0,55,3,40,32,0,65,0,54,2,8,32,0,66,0,55,3,16,32,0,66,0,55,3,40,32,0,40,2,0,32,0,40,2,8,16,19,33,1,32,0,40,2,8,32,0,40,2,0,40,2,4,106,65,1,58,0,0,32,0,32,0,41,3,40,35,6,40,2,4,32,1,65,3,116,106,41,3,0,133,55,3,40,32,0,32,0,40,2,8,65,1,106,32,0,40,2,4,111,54,2,8,32,0,35,5,40,2,4,32,0,41,3,40,34,8,66,45,136,167,65,3,116,106,41,3,0,32,8,66,8,134,66,1,132,133,55,3,40,32,3,65,1,106,12,3,11,32,3,65,1,106,33,3,12,1,11,11,65,127,11,34,1,65,0,78,4,64,32,5,32,1,107,33,5,32,1,32,6,106,33,6,32,2,34,1,65,1,106,33,2,32,4,40,2,4,32,1,65,2,116,106,32,0,41,3,56,62,2,0,12,1,11,11,32,4,11,10,0,16,15,36,5,16,15,36,6,11,3,0,1,11,73,1,2,127,32,0,40,2,4,34,1,65,255,255,255,255,0,113,34,2,65,1,70,4,64,32,0,65,16,106,16,53,32,0,32,0,40,2,0,65,1,114,54,2,0,35,0,32,0,16,2,5,32,0,32,2,65,1,107,32,1,65,128,128,128,128,127,113,114,54,2,4,11,11,58,0,2,64,2,64,2,64,32,0,65,8,107,40,2,0,14,7,0,0,1,1,1,1,1,2,11,15,11,32,0,40,2,0,34,0,4,64,32,0,65,172,3,79,4,64,32,0,65,16,107,16,52,11,11,15,11,0,11,11,137,3,7,0,65,16,11,55,40,0,0,0,1,0,0,0,1,0,0,0,40,0,0,0,97,0,108,0,108,0,111,0,99,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,111,0,111,0,32,0,108,0,97,0,114,0,103,0,101,0,65,208,0,11,45,30,0,0,0,1,0,0,0,1,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,108,0,115,0,102,0,46,0,116,0,115,0,65,128,1,11,43,28,0,0,0,1,0,0,0,1,0,0,0,28,0,0,0,73,0,110,0,118,0,97,0,108,0,105,0,100,0,32,0,108,0,101,0,110,0,103,0,116,0,104,0,65,176,1,11,53,38,0,0,0,1,0,0,0,1,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,98,0,117,0,102,0,102,0,101,0,114,0,46,0,116,0,115,0,65,240,1,11,51,36,0,0,0,1,0,0,0,1,0,0,0,36,0,0,0,73,0,110,0,100,0,101,0,120,0,32,0,111,0,117,0,116,0,32,0,111,0,102,0,32,0,114,0,97,0,110,0,103,0,101,0,65,176,2,11,51,36,0,0,0,1,0,0,0,1,0,0,0,36,0,0,0,126,0,108,0,105,0,98,0,47,0,116,0,121,0,112,0,101,0,100,0,97,0,114,0,114,0,97,0,121,0,46,0,116,0,115,0,65,240,2,11,53,7,0,0,0,16,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,145,4,0,0,2,0,0,0,49,0,0,0,2,0,0,0,17,1,0,0,2,0,0,0,16,0,34,16,115,111,117,114,99,101,77,97,112,112,105,110,103,85,82,76,16,46,47,114,97,98,105,110,46,119,97,115,109,46,109,97,112]);return x3e(new Response(new Blob([e],{type:"application/wasm"})),r)}hz.exports=Yx});var yz=R((QVe,mz)=>{u();var pz=sz(),T3e=dz(),I3e=async(r,e,t,n,i)=>{let s=await T3e();return new pz(s,r,e,t,n,i)};mz.exports={Rabin:pz,create:I3e}});var Tz=R((pKe,xz)=>{"use strict";u();xz.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let n=this._internalPositionFor(e,!1);if(t===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):i=!0,this._setInternalPos(n,e,t,i),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let t=this._internalPositionFor(e,!0);if(t!==-1)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t<this.length;)e(this.get(t),t,this),t++}map(e){let t=0,n=new Array(this.length);for(;t<this.length;)n[t]=e(this.get(t),t,this),t++;return n}reduce(e,t){let n=0,i=t;for(;n<this.length;){let s=this.get(n);i=e(i,s,n),n++}return i}find(e){let t=0,n,i;for(;t<this.length&&!n;)i=this.get(t),n=e(i),t++;return n?i:void 0}_internalPositionFor(e,t){let n=this._bytePosFor(e,t);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],s=e-n*7;if(!((i&1<<s)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(L3e,0),c=~(4294967295<<s+1),l=Sz(i&c);return a+l-1}_bytePosFor(e,t){let n=Math.floor(e/7),i=n+1;for(;!t&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]|=1<<e-t*7}_unsetBit(e){let t=this._bytePosFor(e,!1);this._bitArrays[t]&=~(1<<e-t*7)}_setInternalPos(e,t,n,i){let s=this._data,o=[t,n];if(i)this._sortData(),s[e]=o;else{if(s.length)if(s[s.length-1][0]>=t)s.push(o);else if(s[0][0]<=t)s.unshift(o);else{let a=Math.round(s.length/2);this._data=s.slice(0,a).concat(o).concat(s.slice(a))}else this._data.push(o);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(B3e),this._changedData=!1}bitField(){let e=[],t=8,n=0,i=0,s,o=this._bitArrays.slice();for(;o.length||n;){n===0&&(s=o.shift(),n=7);let c=Math.min(n,t),l=~(255<<c);i|=(s&l)<<8-t,s=s>>>c,n-=c,t-=c,(!t||!n&&!o.length)&&(e.push(i),i=0,t=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(M3e)}};function L3e(r,e){return r+Sz(e)}function Sz(r){let e=r;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function B3e(r,e){return r[0]-e[0]}function M3e(r){return r[1]}});var v$=R((Aze,b$)=>{"use strict";u();b$.exports={RTLD_LAZY:1,RTLD_NOW:2,RTLD_GLOBAL:256,RTLD_LOCAL:0,RTLD_DEEPBIND:8,E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOPNOTSUPP:95,EOVERFLOW:75,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18,PRIORITY_LOW:19,PRIORITY_BELOW_NORMAL:10,PRIORITY_NORMAL:0,PRIORITY_ABOVE_NORMAL:-7,PRIORITY_HIGH:-14,PRIORITY_HIGHEST:-20,SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:17,SIGSTKFLT:16,SIGCONT:18,SIGSTOP:19,SIGTSTP:20,SIGTTIN:21,SIGTTOU:22,SIGURG:23,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:29,SIGPOLL:29,SIGPWR:30,SIGSYS:31,SIGUNUSED:31,UV_FS_SYMLINK_DIR:1,UV_FS_SYMLINK_JUNCTION:2,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,UV_DIRENT_UNKNOWN:0,UV_DIRENT_FILE:1,UV_DIRENT_DIR:2,UV_DIRENT_LINK:3,UV_DIRENT_FIFO:4,UV_DIRENT_SOCKET:5,UV_DIRENT_CHAR:6,UV_DIRENT_BLOCK:7,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:64,O_EXCL:128,UV_FS_O_FILEMAP:0,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_DIRECTORY:65536,O_NOATIME:262144,O_NOFOLLOW:131072,O_SYNC:1052672,O_DSYNC:4096,O_DIRECT:16384,O_NONBLOCK:2048,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_FS_COPYFILE_EXCL:1,COPYFILE_EXCL:1,UV_FS_COPYFILE_FICLONE:2,COPYFILE_FICLONE:2,UV_FS_COPYFILE_FICLONE_FORCE:4,COPYFILE_FICLONE_FORCE:4,OPENSSL_VERSION_NUMBER:269488415,SSL_OP_ALL:2147485780,SSL_OP_ALLOW_NO_DHE_KEX:1024,SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION:262144,SSL_OP_CIPHER_SERVER_PREFERENCE:4194304,SSL_OP_CISCO_ANYCONNECT:32768,SSL_OP_COOKIE_EXCHANGE:8192,SSL_OP_CRYPTOPRO_TLSEXT_BUG:2147483648,SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS:2048,SSL_OP_EPHEMERAL_RSA:0,SSL_OP_LEGACY_SERVER_CONNECT:4,SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER:0,SSL_OP_MICROSOFT_SESS_ID_BUG:0,SSL_OP_MSIE_SSLV2_RSA_PADDING:0,SSL_OP_NETSCAPE_CA_DN_BUG:0,SSL_OP_NETSCAPE_CHALLENGE_BUG:0,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG:0,SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG:0,SSL_OP_NO_COMPRESSION:131072,SSL_OP_NO_ENCRYPT_THEN_MAC:524288,SSL_OP_NO_QUERY_MTU:4096,SSL_OP_NO_RENEGOTIATION:1073741824,SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION:65536,SSL_OP_NO_SSLv2:0,SSL_OP_NO_SSLv3:33554432,SSL_OP_NO_TICKET:16384,SSL_OP_NO_TLSv1:67108864,SSL_OP_NO_TLSv1_1:268435456,SSL_OP_NO_TLSv1_2:134217728,SSL_OP_NO_TLSv1_3:536870912,SSL_OP_PKCS1_CHECK_1:0,SSL_OP_PKCS1_CHECK_2:0,SSL_OP_PRIORITIZE_CHACHA:2097152,SSL_OP_SINGLE_DH_USE:0,SSL_OP_SINGLE_ECDH_USE:0,SSL_OP_SSLEAY_080_CLIENT_DH_BUG:0,SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG:0,SSL_OP_TLS_BLOCK_PADDING_BUG:0,SSL_OP_TLS_D5_BUG:0,SSL_OP_TLS_ROLLBACK_BUG:8388608,ENGINE_METHOD_RSA:1,ENGINE_METHOD_DSA:2,ENGINE_METHOD_DH:4,ENGINE_METHOD_RAND:8,ENGINE_METHOD_EC:2048,ENGINE_METHOD_CIPHERS:64,ENGINE_METHOD_DIGESTS:128,ENGINE_METHOD_PKEY_METHS:512,ENGINE_METHOD_PKEY_ASN1_METHS:1024,ENGINE_METHOD_ALL:65535,ENGINE_METHOD_NONE:0,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,RSA_PSS_SALTLEN_DIGEST:-1,RSA_PSS_SALTLEN_MAX_SIGN:-2,RSA_PSS_SALTLEN_AUTO:-2,defaultCoreCipherList:"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA",TLS1_VERSION:769,TLS1_1_VERSION:770,TLS1_2_VERSION:771,TLS1_3_VERSION:772,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}});var dT=R((Rze,_$)=>{"use strict";u();var{concat:v4e}=(Mr(),KD(AL));async function _4e(r){let e=new Uint8Array(0);for await(let t of r)e=v4e([e,t],e.length+t.length);return e}_$.exports=_4e});var Oa=R((j$e,fG)=>{"use strict";u();var o8e=async r=>{for await(let e of r)return e};fG.exports=o8e});var J2=R(($Qe,Qj)=>{"use strict";u();var pEe=async r=>{let e=0;for await(let t of r)e++;return e};Qj.exports=pEe});var sW=R((xI,iW)=>{"use strict";u();Object.defineProperty(xI,"__esModule",{value:!0});U5.BASE=2166136261;function U5(r,e=U5.BASE){let t=r.length;for(let n=0;n<t;n++)e^=r.charCodeAt(n),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}xI.default=U5;iW.exports=U5});var DW=R((eZe,j5)=>{"use strict";u();j5.exports=qEe;j5.exports.format=CW;j5.exports.parse=PW;var FEe=/\B(?=(\d{3})+(?!\d))/g,VEe=/(?:\.0*|(\.[^0]+)0+)$/,Bu={b:1,kb:1<<10,mb:1<<20,gb:1<<30,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},KEe=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function qEe(r,e){return typeof r=="string"?PW(r):typeof r=="number"?CW(r,e):null}function CW(r,e){if(!Number.isFinite(r))return null;var t=Math.abs(r),n=e&&e.thousandsSeparator||"",i=e&&e.unitSeparator||"",s=e&&e.decimalPlaces!==void 0?e.decimalPlaces:2,o=Boolean(e&&e.fixedDecimals),a=e&&e.unit||"";(!a||!Bu[a.toLowerCase()])&&(t>=Bu.pb?a="PB":t>=Bu.tb?a="TB":t>=Bu.gb?a="GB":t>=Bu.mb?a="MB":t>=Bu.kb?a="KB":a="B");var c=r/Bu[a.toLowerCase()],l=c.toFixed(s);return o||(l=l.replace(VEe,"$1")),n&&(l=l.split(".").map(function(f,h){return h===0?f.replace(FEe,n):f}).join(".")),l+i+a}function PW(r){if(typeof r=="number"&&!isNaN(r))return r;if(typeof r!="string")return null;var e=KEe.exec(r),t,n="b";return e?(t=parseFloat(e[1]),n=e[4].toLowerCase()):(t=parseInt(r,10),n="b"),isNaN(t)?null:Math.floor(Bu[n]*t)}});var gy=R((AJe,EY)=>{"use strict";u();var abe=Ro(),cbe=async function*(r,e){yield*(await abe(r)).sort(e)};EY.exports=cbe});var vY=R(bY=>{"use strict";u();bY.supports=function(...e){let t=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(t,{snapshots:t.snapshots||!1,permanence:t.permanence||!1,seek:t.seek||!1,clear:t.clear||!1,getMany:t.getMany||!1,keyIterator:t.keyIterator||!1,valueIterator:t.valueIterator||!1,iteratorNextv:t.iteratorNextv||!1,iteratorAll:t.iteratorAll||!1,status:t.status||!1,createIfMissing:t.createIfMissing||!1,errorIfExists:t.errorIfExists||!1,deferredOpen:t.deferredOpen||!1,promises:t.promises||!1,streams:t.streams||!1,encodings:Object.assign({},t.encodings),events:Object.assign({},t.events),additionalMethods:Object.assign({},t.additionalMethods)})}});var Mo=R((PJe,_Y)=>{"use strict";u();_Y.exports=class extends Error{constructor(e,t){super(e||""),typeof t=="object"&&t!==null&&(t.code&&(this.code=String(t.code)),t.expected&&(this.expected=!0),t.transient&&(this.transient=!0),t.cause&&(this.cause=t.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var rA=R((DJe,SY)=>{"use strict";u();var tA=null;SY.exports=function(){return tA===null&&(tA={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),tA}});var sA=R(xY=>{"use strict";u();var nA=Mo(),lbe=new Set(["buffer","view","utf8"]),iA=class{constructor(e){if(this.encode=e.encode||this.encode,this.decode=e.decode||this.decode,this.name=e.name||this.name,this.format=e.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!lbe.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");e.createViewTranscoder&&(this.createViewTranscoder=e.createViewTranscoder),e.createBufferTranscoder&&(this.createBufferTranscoder=e.createBufferTranscoder),e.createUTF8Transcoder&&(this.createUTF8Transcoder=e.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new nA(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new nA(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new nA(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};xY.Encoding=iA});var lA=R(a8=>{"use strict";u();var{Buffer:aA}=Tf()||{},{Encoding:cA}=sA(),ube=rA(),wy=class extends cA{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new Ey({encode:this.encode,decode:e=>this.decode(aA.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Ey=class extends cA{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new wy({encode:e=>{let t=this.encode(e);return aA.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},oA=class extends cA{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new wy({encode:e=>aA.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=ube();return new Ey({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(t.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};a8.BufferFormat=wy;a8.ViewFormat=Ey;a8.UTF8Format=oA});var RY=R(Bh=>{"use strict";u();var{Buffer:Jn}=Tf()||{Buffer:{isBuffer:()=>!1}},{textEncoder:IY,textDecoder:TY}=rA()(),{BufferFormat:by,ViewFormat:uA,UTF8Format:AY}=lA(),c8=r=>r;Bh.utf8=new AY({encode:function(r){return Jn.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?TY.decode(r):String(r)},decode:c8,name:"utf8",createViewTranscoder(){return new uA({encode:function(r){return ArrayBuffer.isView(r)?r:IY.encode(r)},decode:function(r){return TY.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new by({encode:function(r){return Jn.isBuffer(r)?r:ArrayBuffer.isView(r)?Jn.from(r.buffer,r.byteOffset,r.byteLength):Jn.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});Bh.json=new AY({encode:JSON.stringify,decode:JSON.parse,name:"json"});Bh.buffer=new by({encode:function(r){return Jn.isBuffer(r)?r:ArrayBuffer.isView(r)?Jn.from(r.buffer,r.byteOffset,r.byteLength):Jn.from(String(r),"utf8")},decode:c8,name:"buffer",createViewTranscoder(){return new uA({encode:function(r){return ArrayBuffer.isView(r)?r:Jn.from(String(r),"utf8")},decode:function(r){return Jn.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});Bh.view=new uA({encode:function(r){return ArrayBuffer.isView(r)?r:IY.encode(r)},decode:c8,name:"view",createBufferTranscoder(){return new by({encode:function(r){return Jn.isBuffer(r)?r:ArrayBuffer.isView(r)?Jn.from(r.buffer,r.byteOffset,r.byteLength):Jn.from(String(r),"utf8")},decode:c8,name:`${this.name}+buffer`})}});Bh.hex=new by({encode:function(r){return Jn.isBuffer(r)?r:Jn.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});Bh.base64=new by({encode:function(r){return Jn.isBuffer(r)?r:Jn.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var DY=R(PY=>{"use strict";u();var CY=Mo(),u8=RY(),{Encoding:fbe}=sA(),{BufferFormat:hbe,ViewFormat:dbe,UTF8Format:pbe}=lA(),vy=Symbol("formats"),l8=Symbol("encodings"),mbe=new Set(["buffer","view","utf8"]),fA=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>mbe.has(t)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[l8]=new Map,this[vy]=new Set(e);for(let t in u8)try{this.encoding(t)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[l8].values()))}encoding(e){let t=this[l8].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=Ebe[e],!t)throw new CY(`Encoding '${e}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof e!="object"||e===null)throw new TypeError("First argument 'encoding' must be a string or object");t=ybe(e)}let{name:n,format:i}=t;if(!this[vy].has(i))if(this[vy].has("view"))t=t.createViewTranscoder();else if(this[vy].has("buffer"))t=t.createBufferTranscoder();else if(this[vy].has("utf8"))t=t.createUTF8Transcoder();else throw new CY(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let s of[e,n,t.name,t.commonName])this[l8].set(s,t)}return t}};PY.Transcoder=fA;function ybe(r){if(r instanceof fbe)return r;let e="type"in r&&typeof r.type=="string"?r.type:void 0,t=r.name||e||`anonymous-${bbe++}`;switch(gbe(r)){case"view":return new dbe({...r,name:t});case"utf8":return new pbe({...r,name:t});case"buffer":return new hbe({...r,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function gbe(r){return"format"in r&&r.format!==void 0?r.format:"buffer"in r&&typeof r.buffer=="boolean"?r.buffer?"buffer":"utf8":"code"in r&&Number.isInteger(r.code)?"view":"buffer"}var wbe={binary:u8.buffer,"utf-8":u8.utf8},Ebe={...u8,...wbe},bbe=0});var kY=R((BJe,OY)=>{u();OY.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var _y=R(hA=>{"use strict";u();var NY=kY();hA.fromCallback=function(r,e){if(r===void 0){var t=new Promise(function(n,i){r=function(s,o){s?i(s):n(o)}});r[e!==void 0?e:"promise"]=t}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};hA.fromPromise=function(r,e){if(e===void 0)return r;r.then(function(t){NY(()=>e(null,t))}).catch(function(t){NY(()=>e(t))})}});var f8=R(dA=>{"use strict";u();dA.getCallback=function(r,e){return typeof r=="function"?r:e};dA.getOptions=function(r,e){return typeof r=="object"&&r!==null?r:e!==void 0?e:{}}});var Hu=R(m8=>{"use strict";u();var{fromCallback:pA}=_y(),is=Mo(),{getOptions:mA,getCallback:LY}=f8(),Mh=Symbol("promise"),_0=Symbol("callback"),Va=Symbol("working"),Uh=Symbol("handleOne"),Yc=Symbol("handleMany"),yA=Symbol("autoClose"),zu=Symbol("finishWork"),Ka=Symbol("returnMany"),Vu=Symbol("closing"),Sy=Symbol("handleClose"),h8=Symbol("closed"),xy=Symbol("closeCallbacks"),qu=Symbol("keyEncoding"),Fh=Symbol("valueEncoding"),gA=Symbol("abortOnClose"),d8=Symbol("legacy"),wA=Symbol("keys"),EA=Symbol("values"),Ku=Symbol("limit"),zs=Symbol("count"),p8=Object.freeze({}),vbe=()=>{},BY=!1,Ty=class{constructor(e,t,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof t!="object"||t===null)throw new TypeError("The second argument must be an options object");this[h8]=!1,this[xy]=[],this[Va]=!1,this[Vu]=!1,this[yA]=!1,this[_0]=null,this[Uh]=this[Uh].bind(this),this[Yc]=this[Yc].bind(this),this[Sy]=this[Sy].bind(this),this[qu]=t[qu],this[Fh]=t[Fh],this[d8]=n,this[Ku]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[zs]=0,this[gA]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[zs]}get limit(){return this[Ku]}next(e){let t;if(e===void 0)t=new Promise((n,i)=>{e=(s,o,a)=>{s?i(s):this[d8]?o===void 0&&a===void 0?n():n([o,a]):n(o)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[Vu]?this.nextTick(e,new is("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Va]?this.nextTick(e,new is("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Va]=!0,this[_0]=e,this[zs]>=this[Ku]?this.nextTick(this[Uh],null):this._next(this[Uh])),t}_next(e){this.nextTick(e)}nextv(e,t,n){return n=LY(t,n),n=pA(n,Mh),t=mA(t,p8),Number.isInteger(e)?(this[Vu]?this.nextTick(n,new is("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Va]?this.nextTick(n,new is("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Ku]<1/0&&(e=Math.min(e,this[Ku]-this[zs])),this[Va]=!0,this[_0]=n,e<=0?this.nextTick(this[Yc],null,[]):this._nextv(e,t,this[Yc])),n[Mh]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Mh])}_nextv(e,t,n){let i=[],s=(o,a,c)=>{if(o)return n(o);if(this[d8]?a===void 0&&c===void 0:a===void 0)return n(null,i);i.push(this[d8]?[a,c]:a),i.length===e?n(null,i):this._next(s)};this._next(s)}all(e,t){return t=LY(e,t),t=pA(t,Mh),e=mA(e,p8),this[Vu]?this.nextTick(t,new is("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Va]?this.nextTick(t,new is("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Va]=!0,this[_0]=t,this[yA]=!0,this[zs]>=this[Ku]?this.nextTick(this[Yc],null,[]):this._all(e,this[Yc])),t[Mh]}_all(e,t){let n=this[zs],i=[],s=()=>{let a=this[Ku]<1/0?Math.min(1e3,this[Ku]-n):1e3;a<=0?this.nextTick(t,null,i):this._nextv(a,p8,o)},o=(a,c)=>{a?t(a):c.length===0?t(null,i):(i.push.apply(i,c),n+=c.length,s())};s()}[zu](){let e=this[_0];return this[gA]&&e===null?vbe:(this[Va]=!1,this[_0]=null,this[Vu]&&this._close(this[Sy]),e)}[Ka](e,t,n){this[yA]?this.close(e.bind(null,t,n)):e(t,n)}seek(e,t){if(t=mA(t,p8),!this[Vu]){if(this[Va])throw new is("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(t.keyEncoding||this[qu]),i=n.format;t.keyEncoding!==i&&(t={...t,keyEncoding:i});let s=this.db.prefixKey(n.encode(e),i);this._seek(s,t)}}}_seek(e,t){throw new is("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=pA(e,Mh),this[h8]?this.nextTick(e):this[Vu]?this[xy].push(e):(this[Vu]=!0,this[xy].push(e),this[Va]?this[gA]&&this[zu]()(new is("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Sy])),e[Mh]}_close(e){this.nextTick(e)}[Sy](){this[h8]=!0,this.db.detachResource(this);let e=this[xy];this[xy]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[h8]||await this.close()}}},S0=class extends Ty{constructor(e,t){super(e,t,!0),this[wA]=t.keys!==!1,this[EA]=t.values!==!1}[Uh](e,t,n){let i=this[zu]();if(e)return i(e);try{t=this[wA]&&t!==void 0?this[qu].decode(t):void 0,n=this[EA]&&n!==void 0?this[Fh].decode(n):void 0}catch(s){return i(new $u("entry",s))}t===void 0&&n===void 0||this[zs]++,i(null,t,n)}[Yc](e,t){let n=this[zu]();if(e)return this[Ka](n,e);try{for(let i of t){let s=i[0],o=i[1];i[0]=this[wA]&&s!==void 0?this[qu].decode(s):void 0,i[1]=this[EA]&&o!==void 0?this[Fh].decode(o):void 0}}catch(i){return this[Ka](n,new $u("entries",i))}this[zs]+=t.length,this[Ka](n,null,t)}end(e){return!BY&&typeof console<"u"&&(BY=!0,console.warn(new is("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(e)}},bA=class extends Ty{constructor(e,t){super(e,t,!1)}[Uh](e,t){let n=this[zu]();if(e)return n(e);try{t=t!==void 0?this[qu].decode(t):void 0}catch(i){return n(new $u("key",i))}t!==void 0&&this[zs]++,n(null,t)}[Yc](e,t){let n=this[zu]();if(e)return this[Ka](n,e);try{for(let i=0;i<t.length;i++){let s=t[i];t[i]=s!==void 0?this[qu].decode(s):void 0}}catch(i){return this[Ka](n,new $u("keys",i))}this[zs]+=t.length,this[Ka](n,null,t)}},vA=class extends Ty{constructor(e,t){super(e,t,!1)}[Uh](e,t){let n=this[zu]();if(e)return n(e);try{t=t!==void 0?this[Fh].decode(t):void 0}catch(i){return n(new $u("value",i))}t!==void 0&&this[zs]++,n(null,t)}[Yc](e,t){let n=this[zu]();if(e)return this[Ka](n,e);try{for(let i=0;i<t.length;i++){let s=t[i];t[i]=s!==void 0?this[Fh].decode(s):void 0}}catch(i){return this[Ka](n,new $u("values",i))}this[zs]+=t.length,this[Ka](n,null,t)}},$u=class extends is{constructor(e,t){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:t})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(S0.prototype,r.split(" ")[0],{get(){throw new is(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new is(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});S0.keyEncoding=qu;S0.valueEncoding=Fh;m8.AbstractIterator=S0;m8.AbstractKeyIterator=bA;m8.AbstractValueIterator=vA});var MY=R(_A=>{"use strict";u();var{AbstractKeyIterator:_be,AbstractValueIterator:Sbe}=Hu(),Vh=Symbol("iterator"),Iy=Symbol("callback"),x0=Symbol("handleOne"),Kh=Symbol("handleMany"),Ay=class extends _be{constructor(e,t){super(e,t),this[Vh]=e.iterator({...t,keys:!0,values:!1}),this[x0]=this[x0].bind(this),this[Kh]=this[Kh].bind(this)}},y8=class extends Sbe{constructor(e,t){super(e,t),this[Vh]=e.iterator({...t,keys:!1,values:!0}),this[x0]=this[x0].bind(this),this[Kh]=this[Kh].bind(this)}};for(let r of[Ay,y8]){let e=r===Ay,t=e?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[Iy]=n,this[Vh].next(this[x0])},r.prototype[x0]=function(n,i,s){let o=this[Iy];n?o(n):o(null,e?i:s)},r.prototype._nextv=function(n,i,s){this[Iy]=s,this[Vh].nextv(n,i,this[Kh])},r.prototype._all=function(n,i){this[Iy]=i,this[Vh].all(n,this[Kh])},r.prototype[Kh]=function(n,i){let s=this[Iy];n?s(n):s(null,i.map(t))},r.prototype._seek=function(n,i){this[Vh].seek(n,i)},r.prototype._close=function(n){this[Vh].close(n)}}_A.DefaultKeyIterator=Ay;_A.DefaultValueIterator=y8});var UY=R(_8=>{"use strict";u();var{AbstractIterator:xbe,AbstractKeyIterator:Tbe,AbstractValueIterator:Ibe}=Hu(),SA=Mo(),Oi=Symbol("nut"),b8=Symbol("undefer"),v8=Symbol("factory"),g8=class extends xbe{constructor(e,t){super(e,t),this[Oi]=null,this[v8]=()=>e.iterator(t),this.db.defer(()=>this[b8]())}},w8=class extends Tbe{constructor(e,t){super(e,t),this[Oi]=null,this[v8]=()=>e.keys(t),this.db.defer(()=>this[b8]())}},E8=class extends Ibe{constructor(e,t){super(e,t),this[Oi]=null,this[v8]=()=>e.values(t),this.db.defer(()=>this[b8]())}};for(let r of[g8,w8,E8])r.prototype[b8]=function(){this.db.status==="open"&&(this[Oi]=this[v8]())},r.prototype._next=function(e){this[Oi]!==null?this[Oi].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new SA("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(e,t,n){this[Oi]!==null?this[Oi].nextv(e,t,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,t,n)):this.nextTick(n,new SA("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(e,t){this[Oi]!==null?this[Oi].all(t):this.db.status==="opening"?this.db.defer(()=>this._all(e,t)):this.nextTick(t,new SA("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(e,t){this[Oi]!==null?this[Oi]._seek(e,t):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,t))},r.prototype._close=function(e){this[Oi]!==null?this[Oi].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};_8.DeferredIterator=g8;_8.DeferredKeyIterator=w8;_8.DeferredValueIterator=E8});var TA=R(VY=>{"use strict";u();var{fromCallback:FY}=_y(),S8=Mo(),{getCallback:Abe,getOptions:Rbe}=f8(),x8=Symbol("promise"),$s=Symbol("status"),T0=Symbol("operations"),Ry=Symbol("finishClose"),I0=Symbol("closeCallbacks"),xA=class{constructor(e){if(typeof e!="object"||e===null){let t=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${t}`)}this[T0]=[],this[I0]=[],this[$s]="open",this[Ry]=this[Ry].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[T0].length}put(e,t,n){if(this[$s]!=="open")throw new S8("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(e)||this.db._checkValue(t);if(i)throw i;let s=n&&n.sublevel!=null?n.sublevel:this.db,o=n,a=s.keyEncoding(n&&n.keyEncoding),c=s.valueEncoding(n&&n.valueEncoding),l=a.format;n={...n,keyEncoding:l,valueEncoding:c.format},s!==this.db&&(n.sublevel=null);let f=s.prefixKey(a.encode(e),l),h=c.encode(t);return this._put(f,h,n),this[T0].push({...o,type:"put",key:e,value:t}),this}_put(e,t,n){}del(e,t){if(this[$s]!=="open")throw new S8("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=t&&t.sublevel!=null?t.sublevel:this.db,s=t,o=i.keyEncoding(t&&t.keyEncoding),a=o.format;return t={...t,keyEncoding:a},i!==this.db&&(t.sublevel=null),this._del(i.prefixKey(o.encode(e),a),t),this[T0].push({...s,type:"del",key:e}),this}_del(e,t){}clear(){if(this[$s]!=="open")throw new S8("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[T0]=[],this}_clear(){}write(e,t){return t=Abe(e,t),t=FY(t,x8),e=Rbe(e),this[$s]!=="open"?this.nextTick(t,new S8("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(t):(this[$s]="writing",this._write(e,n=>{this[$s]="closing",this[I0].push(()=>t(n)),n||this.db.emit("batch",this[T0]),this._close(this[Ry])})),t[x8]}_write(e,t){}close(e){return e=FY(e,x8),this[$s]==="closing"?this[I0].push(e):this[$s]==="closed"?this.nextTick(e):(this[I0].push(e),this[$s]!=="writing"&&(this[$s]="closing",this._close(this[Ry]))),e[x8]}_close(e){this.nextTick(e)}[Ry](){this[$s]="closed",this.db.detachResource(this);let e=this[I0];this[I0]=[];for(let t of e)t()}};VY.AbstractChainedBatch=xA});var qY=R(KY=>{"use strict";u();var{AbstractChainedBatch:Cbe}=TA(),Pbe=Mo(),A0=Symbol("encoded"),IA=class extends Cbe{constructor(e){super(e),this[A0]=[]}_put(e,t,n){this[A0].push({...n,type:"put",key:e,value:t})}_del(e,t){this[A0].push({...t,type:"del",key:e})}_clear(){this[A0]=[]}_write(e,t){this.db.status==="opening"?this.db.defer(()=>this._write(e,t)):this.db.status==="open"?this[A0].length===0?this.nextTick(t):this.db._batch(this[A0],e,t):this.nextTick(t,new Pbe("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};KY.DefaultChainedBatch=IA});var HY=R(($Je,$Y)=>{"use strict";u();var zY=Mo(),Dbe=Object.prototype.hasOwnProperty,Obe=new Set(["lt","lte","gt","gte"]);$Y.exports=function(r,e){let t={};for(let n in r)if(!!Dbe.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new zY(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new zY("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Obe.has(n)?t[n]=e.encode(r[n]):t[n]=r[n]}return t.reverse=!!t.reverse,t.limit=Number.isInteger(t.limit)&&t.limit>=0?t.limit:-1,t}});var AA=R((HJe,jY)=>{u();var GY;jY.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(GY||(GY=Promise.resolve())).then(r).catch(e=>setTimeout(()=>{throw e},0))});var QY=R((GJe,YY)=>{"use strict";u();var WY=AA();YY.exports=function(r,...e){e.length===0?WY(r):WY(()=>r(...e))}});var XY=R(T8=>{"use strict";u();var{AbstractIterator:kbe,AbstractKeyIterator:Nbe,AbstractValueIterator:Lbe}=Hu(),R0=Symbol("unfix"),Uo=Symbol("iterator"),qh=Symbol("handleOne"),Gu=Symbol("handleMany"),Qc=Symbol("callback"),Cy=class extends kbe{constructor(e,t,n,i){super(e,t),this[Uo]=n,this[R0]=i,this[qh]=this[qh].bind(this),this[Gu]=this[Gu].bind(this),this[Qc]=null}[qh](e,t,n){let i=this[Qc];if(e)return i(e);t!==void 0&&(t=this[R0](t)),i(e,t,n)}[Gu](e,t){let n=this[Qc];if(e)return n(e);for(let i of t){let s=i[0];s!==void 0&&(i[0]=this[R0](s))}n(e,t)}},Py=class extends Nbe{constructor(e,t,n,i){super(e,t),this[Uo]=n,this[R0]=i,this[qh]=this[qh].bind(this),this[Gu]=this[Gu].bind(this),this[Qc]=null}[qh](e,t){let n=this[Qc];if(e)return n(e);t!==void 0&&(t=this[R0](t)),n(e,t)}[Gu](e,t){let n=this[Qc];if(e)return n(e);for(let i=0;i<t.length;i++){let s=t[i];s!==void 0&&(t[i]=this[R0](s))}n(e,t)}},Dy=class extends Lbe{constructor(e,t,n){super(e,t),this[Uo]=n}};for(let r of[Cy,Py])r.prototype._next=function(e){this[Qc]=e,this[Uo].next(this[qh])},r.prototype._nextv=function(e,t,n){this[Qc]=n,this[Uo].nextv(e,t,this[Gu])},r.prototype._all=function(e,t){this[Qc]=t,this[Uo].all(e,this[Gu])};for(let r of[Dy])r.prototype._next=function(e){this[Uo].next(e)},r.prototype._nextv=function(e,t,n){this[Uo].nextv(e,t,n)},r.prototype._all=function(e,t){this[Uo].all(e,t)};for(let r of[Cy,Py,Dy])r.prototype._seek=function(e,t){this[Uo].seek(e,t)},r.prototype._close=function(e){this[Uo].close(e)};T8.AbstractSublevelIterator=Cy;T8.AbstractSublevelKeyIterator=Py;T8.AbstractSublevelValueIterator=Dy});var tQ=R((WJe,eQ)=>{"use strict";u();var RA=Mo(),{Buffer:DA}=Tf()||{},{AbstractSublevelIterator:Bbe,AbstractSublevelKeyIterator:Mbe,AbstractSublevelValueIterator:Ube}=XY(),Xc=Symbol("prefix"),ZY=Symbol("upperBound"),Oy=Symbol("prefixRange"),ss=Symbol("parent"),CA=Symbol("unfix"),JY=new TextEncoder,Fbe={separator:"!"};eQ.exports=function({AbstractLevel:r}){class e extends r{static defaults(n){if(typeof n=="string")throw new RA("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new RA("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?Fbe:n.separator?n:{...n,separator:"!"}}constructor(n,i,s){let{separator:o,manifest:a,...c}=e.defaults(s);i=Kbe(i,o);let l=o.charCodeAt(0)+1,f=n[ss]||n;if(!JY.encode(i).every(d=>d>l&&d<127))throw new RA(`Prefix must use bytes > ${l} < ${127}`,{code:"LEVEL_INVALID_PREFIX"});super(Vbe(f,a),c);let h=(n.prefix||"")+o+i+o,p=h.slice(0,-1)+String.fromCharCode(l);this[ss]=f,this[Xc]=new I8(h),this[ZY]=new I8(p),this[CA]=new OA,this.nextTick=f.nextTick}prefixKey(n,i){if(i==="utf8")return this[Xc].utf8+n;if(n.byteLength===0)return this[Xc][i];if(i==="view"){let s=this[Xc].view,o=new Uint8Array(s.byteLength+n.byteLength);return o.set(s,0),o.set(n,s.byteLength),o}else{let s=this[Xc].buffer;return DA.concat([s,n],s.byteLength+n.byteLength)}}[Oy](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[Xc][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[ZY][i]}get prefix(){return this[Xc].utf8}get db(){return this[ss]}_open(n,i){this[ss].open({passive:!0},i)}_put(n,i,s,o){this[ss].put(n,i,s,o)}_get(n,i,s){this[ss].get(n,i,s)}_getMany(n,i,s){this[ss].getMany(n,i,s)}_del(n,i,s){this[ss].del(n,i,s)}_batch(n,i,s){this[ss].batch(n,i,s)}_clear(n,i){this[Oy](n,n.keyEncoding),this[ss].clear(n,i)}_iterator(n){this[Oy](n,n.keyEncoding);let i=this[ss].iterator(n),s=this[CA].get(this[Xc].utf8.length,n.keyEncoding);return new Bbe(this,n,i,s)}_keys(n){this[Oy](n,n.keyEncoding);let i=this[ss].keys(n),s=this[CA].get(this[Xc].utf8.length,n.keyEncoding);return new Mbe(this,n,i,s)}_values(n){this[Oy](n,n.keyEncoding);let i=this[ss].values(n);return new Ube(this,n,i)}}return{AbstractSublevel:e}};var Vbe=function(r,e){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:PA(r,"utf8"),buffer:PA(r,"buffer"),view:PA(r,"view")}}},PA=function(r,e){return r.supports.encodings[e]?r.keyEncoding(e).name===e:!1},I8=class{constructor(e){this.utf8=e,this.view=JY.encode(e),this.buffer=DA?DA.from(this.view.buffer,0,this.view.byteLength):{}}},OA=class{constructor(){this.cache=new Map}get(e,t){let n=this.cache.get(t);return n===void 0&&(t==="view"?n=function(i,s){return s.subarray(i)}.bind(null,e):n=function(i,s){return s.slice(i)}.bind(null,e),this.cache.set(t,n)),n}},Kbe=function(r,e){let t=0,n=r.length;for(;t<n&&r[t]===e;)t++;for(;n>t&&r[n-1]===e;)n--;return r.slice(t,n)}});var MA=R(BA=>{"use strict";u();var{supports:qbe}=vY(),{Transcoder:zbe}=DY(),{EventEmitter:$be}=bn(),{fromCallback:ju}=_y(),Fo=Mo(),{AbstractIterator:zh}=Hu(),{DefaultKeyIterator:Hbe,DefaultValueIterator:Gbe}=MY(),{DeferredIterator:jbe,DeferredKeyIterator:Wbe,DeferredValueIterator:Ybe}=UY(),{DefaultChainedBatch:rQ}=qY(),{getCallback:$h,getOptions:Wu}=f8(),A8=HY(),nt=Symbol("promise"),Zc=Symbol("landed"),Hh=Symbol("resources"),kA=Symbol("closeResources"),ky=Symbol("operations"),Ny=Symbol("undefer"),R8=Symbol("deferOpen"),nQ=Symbol("options"),dt=Symbol("status"),Gh=Symbol("defaultOptions"),C0=Symbol("transcoder"),C8=Symbol("keyEncoding"),NA=Symbol("valueEncoding"),Qbe=()=>{},Ly=class extends $be{constructor(e,t){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");t=Wu(t);let{keyEncoding:n,valueEncoding:i,passive:s,...o}=t;this[Hh]=new Set,this[ky]=[],this[R8]=!0,this[nQ]=o,this[dt]="opening",this.supports=qbe(e,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:e.snapshots!==!1,permanence:e.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:e.encodings||{},events:Object.assign({},e.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[C0]=new zbe(Xbe(this)),this[C8]=this[C0].encoding(n||"utf8"),this[NA]=this[C0].encoding(i||"utf8");for(let a of this[C0].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Gh]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[C8].commonName,valueEncoding:this[NA].commonName}),key:Object.freeze({keyEncoding:this[C8].commonName})},this.nextTick(()=>{this[R8]&&this.open({passive:!1},Qbe)})}get status(){return this[dt]}keyEncoding(e){return this[C0].encoding(e??this[C8])}valueEncoding(e){return this[C0].encoding(e??this[NA])}open(e,t){t=$h(e,t),t=ju(t,nt),e={...this[nQ],...Wu(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[dt]==="closing"||this[dt]==="opening"?this.once(Zc,i?()=>n(i):n):this[dt]!=="open"?t(new Fo("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):t()};return e.passive?this[dt]==="opening"?this.once(Zc,n):this.nextTick(n):this[dt]==="closed"||this[R8]?(this[R8]=!1,this[dt]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[dt]="closed",this[kA](()=>{this.emit(Zc),n(i)}),this[Ny]();return}this[dt]="open",this[Ny](),this.emit(Zc),this[dt]==="open"&&this.emit("open"),this[dt]==="open"&&this.emit("ready"),n()})):this[dt]==="open"?this.nextTick(n):this.once(Zc,()=>this.open(e,t)),t[nt]}_open(e,t){this.nextTick(t)}close(e){e=ju(e,nt);let t=n=>{this[dt]==="opening"||this[dt]==="closing"?this.once(Zc,n?t(n):t):this[dt]!=="closed"?e(new Fo("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[dt]==="open"){this[dt]="closing",this.emit("closing");let n=i=>{this[dt]="open",this[Ny](),this.emit(Zc),t(i)};this[kA](()=>{this._close(i=>{if(i)return n(i);this[dt]="closed",this[Ny](),this.emit(Zc),this[dt]==="closed"&&this.emit("closed"),t()})})}else this[dt]==="closed"?this.nextTick(t):this.once(Zc,()=>this.close(e));return e[nt]}[kA](e){if(this[Hh].size===0)return this.nextTick(e);let t=this[Hh].size,n=!0,i=()=>{--t===0&&(n?this.nextTick(e):e())};for(let s of this[Hh])s.close(i);n=!1,this[Hh].clear()}_close(e){this.nextTick(e)}get(e,t,n){if(n=$h(t,n),n=ju(n,nt),t=Wu(t,this[Gh].entry),this[dt]==="opening")return this.defer(()=>this.get(e,t,n)),n[nt];if(P0(this,n))return n[nt];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[nt];let s=this.keyEncoding(t.keyEncoding),o=this.valueEncoding(t.valueEncoding),a=s.format,c=o.format;return(t.keyEncoding!==a||t.valueEncoding!==c)&&(t=Object.assign({},t,{keyEncoding:a,valueEncoding:c})),this._get(this.prefixKey(s.encode(e),a),t,(l,f)=>{if(l)return(l.code==="LEVEL_NOT_FOUND"||l.notFound||/NotFound/i.test(l))&&(l.code||(l.code="LEVEL_NOT_FOUND"),l.notFound||(l.notFound=!0),l.status||(l.status=404)),n(l);try{f=o.decode(f)}catch(h){return n(new Fo("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,f)}),n[nt]}_get(e,t,n){this.nextTick(n,new Error("NotFound"))}getMany(e,t,n){if(n=$h(t,n),n=ju(n,nt),t=Wu(t,this[Gh].entry),this[dt]==="opening")return this.defer(()=>this.getMany(e,t,n)),n[nt];if(P0(this,n))return n[nt];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[nt];if(e.length===0)return this.nextTick(n,null,[]),n[nt];let i=this.keyEncoding(t.keyEncoding),s=this.valueEncoding(t.valueEncoding),o=i.format,a=s.format;(t.keyEncoding!==o||t.valueEncoding!==a)&&(t=Object.assign({},t,{keyEncoding:o,valueEncoding:a}));let c=new Array(e.length);for(let l=0;l<e.length;l++){let f=e[l],h=this._checkKey(f);if(h)return this.nextTick(n,h),n[nt];c[l]=this.prefixKey(i.encode(f),o)}return this._getMany(c,t,(l,f)=>{if(l)return n(l);try{for(let h=0;h<f.length;h++)f[h]!==void 0&&(f[h]=s.decode(f[h]))}catch(h){return n(new Fo(`Could not decode one or more of ${f.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,f)}),n[nt]}_getMany(e,t,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,t,n,i){if(i=$h(n,i),i=ju(i,nt),n=Wu(n,this[Gh].entry),this[dt]==="opening")return this.defer(()=>this.put(e,t,n,i)),i[nt];if(P0(this,i))return i[nt];let s=this._checkKey(e)||this._checkValue(t);if(s)return this.nextTick(i,s),i[nt];let o=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=o.format,l=a.format;(n.keyEncoding!==c||n.valueEncoding!==l)&&(n=Object.assign({},n,{keyEncoding:c,valueEncoding:l}));let f=this.prefixKey(o.encode(e),c),h=a.encode(t);return this._put(f,h,n,p=>{if(p)return i(p);this.emit("put",e,t),i()}),i[nt]}_put(e,t,n,i){this.nextTick(i)}del(e,t,n){if(n=$h(t,n),n=ju(n,nt),t=Wu(t,this[Gh].key),this[dt]==="opening")return this.defer(()=>this.del(e,t,n)),n[nt];if(P0(this,n))return n[nt];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[nt];let s=this.keyEncoding(t.keyEncoding),o=s.format;return t.keyEncoding!==o&&(t=Object.assign({},t,{keyEncoding:o})),this._del(this.prefixKey(s.encode(e),o),t,a=>{if(a)return n(a);this.emit("del",e),n()}),n[nt]}_del(e,t,n){this.nextTick(n)}batch(e,t,n){if(!arguments.length){if(this[dt]==="opening")return new rQ(this);if(this[dt]!=="open")throw new Fo("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=$h(t,n),n=ju(n,nt),t=Wu(t,this[Gh].empty),this[dt]==="opening")return this.defer(()=>this.batch(e,t,n)),n[nt];if(P0(this,n))return n[nt];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[nt];if(e.length===0)return this.nextTick(n),n[nt];let i=new Array(e.length),{keyEncoding:s,valueEncoding:o,...a}=t;for(let c=0;c<e.length;c++){if(typeof e[c]!="object"||e[c]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[nt];let l=Object.assign({},e[c]);if(l.type!=="put"&&l.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[nt];let f=this._checkKey(l.key);if(f)return this.nextTick(n,f),n[nt];let h=l.sublevel!=null?l.sublevel:this,p=h.keyEncoding(l.keyEncoding||s),d=p.format;if(l.key=h.prefixKey(p.encode(l.key),d),l.keyEncoding=d,l.type==="put"){let m=this._checkValue(l.value);if(m)return this.nextTick(n,m),n[nt];let y=h.valueEncoding(l.valueEncoding||o);l.value=y.encode(l.value),l.valueEncoding=y.format}h!==this&&(l.sublevel=null),i[c]=l}return this._batch(i,a,c=>{if(c)return n(c);this.emit("batch",e),n()}),n[nt]}_batch(e,t,n){this.nextTick(n)}sublevel(e,t){return this._sublevel(e,LA.defaults(t))}_sublevel(e,t){return new LA(this,e,t)}prefixKey(e,t){return e}clear(e,t){if(t=$h(e,t),t=ju(t,nt),e=Wu(e,this[Gh].empty),this[dt]==="opening")return this.defer(()=>this.clear(e,t)),t[nt];if(P0(this,t))return t[nt];let n=e,i=this.keyEncoding(e.keyEncoding);return e=A8(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(t):this._clear(e,s=>{if(s)return t(s);this.emit("clear",n),t()}),t[nt]}_clear(e,t){this.nextTick(t)}iterator(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=A8(e,t),e.keys=e.keys!==!1,e.values=e.values!==!1,e[zh.keyEncoding]=t,e[zh.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[dt]==="opening")return new jbe(this,e);if(this[dt]!=="open")throw new Fo("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new zh(this,e)}keys(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=A8(e,t),e[zh.keyEncoding]=t,e[zh.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[dt]==="opening")return new Wbe(this,e);if(this[dt]!=="open")throw new Fo("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new Hbe(this,e)}values(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=A8(e,t),e[zh.keyEncoding]=t,e[zh.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[dt]==="opening")return new Ybe(this,e);if(this[dt]!=="open")throw new Fo("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new Gbe(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[ky].push(e)}[Ny](){if(this[ky].length===0)return;let e=this[ky];this[ky]=[];for(let t of e)t()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[Hh].add(e)}detachResource(e){this[Hh].delete(e)}_chainedBatch(){return new rQ(this)}_checkKey(e){if(e==null)return new Fo("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new Fo("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Ly.prototype.nextTick=QY();var{AbstractSublevel:LA}=tQ()({AbstractLevel:Ly});BA.AbstractLevel=Ly;BA.AbstractSublevel=LA;var P0=function(r,e){return r[dt]!=="open"?(r.nextTick(e,new Fo("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},Xbe=function(r){return Object.keys(r.supports.encodings).filter(e=>!!r.supports.encodings[e])}});var UA=R(jh=>{"use strict";u();jh.AbstractLevel=MA().AbstractLevel;jh.AbstractSublevel=MA().AbstractSublevel;jh.AbstractIterator=Hu().AbstractIterator;jh.AbstractKeyIterator=Hu().AbstractKeyIterator;jh.AbstractValueIterator=Hu().AbstractValueIterator;jh.AbstractChainedBatch=TA().AbstractChainedBatch});var sQ=R((XJe,iQ)=>{u();iQ.exports=Jbe;var Zbe=AA();function Jbe(r,e,t){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,s,o,a,c=!0,l;Array.isArray(r)?(n=[],s=i=r.length):(o=Object.keys(r),n={},s=i=o.length);function f(p){function d(){t&&t(p,n),t=null}c?Zbe(d):d()}function h(p,d,m){if(n[p]=m,d&&(a=!0),--s===0||d)f(d);else if(!a&&l<i){let y;o?(y=o[l],l+=1,r[y](function(g,w){h(y,g,w)})):(y=l,l+=1,r[y](function(g,w){h(y,g,w)}))}}l=e,s?o?o.some(function(p,d){return r[p](function(m,y){h(p,m,y)}),d===e-1}):r.some(function(p,d){return p(function(m,y){h(d,m,y)}),d===e-1}):f(null),c=!1}});var FA=R((ZJe,oQ)=>{"use strict";u();oQ.exports=function(e){let t=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,s=e.lte===void 0;return t!==void 0&&n!==void 0?IDBKeyRange.bound(t,n,i,s):t!==void 0?IDBKeyRange.lowerBound(t,i):n!==void 0?IDBKeyRange.upperBound(n,s):null}});var VA=R((JJe,aQ)=>{"use strict";u();var e7e=new TextEncoder;aQ.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):e7e.encode(r)}});var hQ=R(fQ=>{"use strict";u();var{AbstractIterator:t7e}=UA(),cQ=FA(),P8=VA(),qa=Symbol("cache"),Jc=Symbol("finished"),os=Symbol("options"),el=Symbol("currentOptions"),Wh=Symbol("position"),KA=Symbol("location"),D0=Symbol("first"),lQ={},qA=class extends t7e{constructor(e,t,n){super(e,n),this[qa]=[],this[Jc]=this.limit===0,this[os]=n,this[el]={...n},this[Wh]=void 0,this[KA]=t,this[D0]=!0}_nextv(e,t,n){if(this[D0]=!1,this[Jc])return this.nextTick(n,null,[]);if(this[qa].length>0)return e=Math.min(e,this[qa].length),this.nextTick(n,null,this[qa].splice(0,e));this[Wh]!==void 0&&(this[os].reverse?(this[el].lt=this[Wh],this[el].lte=void 0):(this[el].gt=this[Wh],this[el].gte=void 0));let i;try{i=cQ(this[el])}catch{return this[Jc]=!0,this.nextTick(n,null,[])}let s=this.db.db.transaction([this[KA]],"readonly"),o=s.objectStore(this[KA]),a=[];if(this[os].reverse){let c=!this[os].values&&o.openKeyCursor?"openKeyCursor":"openCursor";o[c](i,"prev").onsuccess=l=>{let f=l.target.result;if(f){let{key:h,value:p}=f;this[Wh]=h,a.push([this[os].keys&&h!==void 0?P8(h):void 0,this[os].values&&p!==void 0?P8(p):void 0]),a.length<e?f.continue():uQ(s)}else this[Jc]=!0}}else{let c,l,f=()=>{if(c===void 0||l===void 0)return;let h=Math.max(c.length,l.length);h===0||e===1/0?this[Jc]=!0:this[Wh]=c[h-1],a.length=h;for(let p=0;p<h;p++){let d=c[p],m=l[p];a[p]=[this[os].keys&&d!==void 0?P8(d):void 0,this[os].values&&m!==void 0?P8(m):void 0]}uQ(s)};this[os].keys||e<1/0?o.getAllKeys(i,e<1/0?e:void 0).onsuccess=h=>{c=h.target.result,f()}:(c=[],this.nextTick(f)),this[os].values?o.getAll(i,e<1/0?e:void 0).onsuccess=h=>{l=h.target.result,f()}:(l=[],this.nextTick(f))}s.onabort=()=>{n(s.error||new Error("aborted by user")),n=null},s.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[qa].length>0){let[t,n]=this[qa].shift();this.nextTick(e,null,t,n)}else if(this[Jc])this.nextTick(e);else{let t=Math.min(100,this.limit-this.count);this[D0]&&(this[D0]=!1,t=1),this._nextv(t,lQ,(n,i)=>{if(n)return e(n);this[qa]=i,this._next(e)})}}_all(e,t){this[D0]=!1;let n=this[qa].splice(0,this[qa].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(t,null,n);this._nextv(i,lQ,(s,o)=>{if(s)return t(s);n.length>0&&(o=n.concat(o)),t(null,o)})}_seek(e,t){this[D0]=!0,this[qa]=[],this[Jc]=!1,this[Wh]=void 0,this[el]={...this[os]};let n;try{n=cQ(this[os])}catch{this[Jc]=!0;return}n!==null&&!n.includes(e)?this[Jc]=!0:this[os].reverse?this[el].lte=e:this[el].gte=e}};fQ.Iterator=qA;function uQ(r){typeof r.commit=="function"&&r.commit()}});var pQ=R((tet,dQ)=>{"use strict";u();dQ.exports=function(e,t,n,i,s){if(i.limit===0)return e.nextTick(s);let o=e.db.transaction([t],"readwrite"),a=o.objectStore(t),c=0;o.oncomplete=function(){s()},o.onabort=function(){s(o.error||new Error("aborted by user"))};let l=a.openKeyCursor?"openKeyCursor":"openCursor",f=i.reverse?"prev":"next";a[l](n,f).onsuccess=function(h){let p=h.target.result;p&&(a.delete(p.key).onsuccess=function(){(i.limit<=0||++c<i.limit)&&p.continue()})}}});var bQ=R(EQ=>{"use strict";u();var{AbstractLevel:r7e}=UA(),mQ=Mo(),n7e=sQ(),{fromCallback:i7e}=_y(),{Iterator:s7e}=hQ(),yQ=VA(),o7e=pQ(),a7e=FA(),wQ="level-js-",By=Symbol("idb"),zA=Symbol("namePrefix"),tl=Symbol("location"),$A=Symbol("version"),Yh=Symbol("store"),My=Symbol("onComplete"),gQ=Symbol("promise"),D8=class extends r7e{constructor(e,t,n){if(typeof t=="function"||typeof n=="function")throw new mQ("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:s,...o}=t||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},o),typeof e!="string")throw new Error("constructor requires a location string argument");this[tl]=e,this[zA]=i??wQ,this[$A]=parseInt(s||1,10),this[By]=null}get location(){return this[tl]}get namePrefix(){return this[zA]}get version(){return this[$A]}get db(){return this[By]}get type(){return"browser-level"}_open(e,t){let n=indexedDB.open(this[zA]+this[tl],this[$A]);n.onerror=function(){t(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[By]=n.result,t()},n.onupgradeneeded=i=>{let s=i.target.result;s.objectStoreNames.contains(this[tl])||s.createObjectStore(this[tl])}}[Yh](e){return this[By].transaction([this[tl]],e).objectStore(this[tl])}[My](e,t){let n=e.transaction;n.onabort=function(){t(n.error||new Error("aborted by user"))},n.oncomplete=function(){t(null,e.result)}}_get(e,t,n){let i=this[Yh]("readonly"),s;try{s=i.get(e)}catch(o){return this.nextTick(n,o)}this[My](s,function(o,a){if(o)return n(o);if(a===void 0)return n(new mQ("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,yQ(a))})}_getMany(e,t,n){let i=this[Yh]("readonly"),s=e.map(o=>a=>{let c;try{c=i.get(o)}catch(l){return a(l)}c.onsuccess=()=>{let l=c.result;a(null,l===void 0?l:yQ(l))},c.onerror=l=>{l.stopPropagation(),a(c.error)}});n7e(s,16,n)}_del(e,t,n){let i=this[Yh]("readwrite"),s;try{s=i.delete(e)}catch(o){return this.nextTick(n,o)}this[My](s,n)}_put(e,t,n,i){let s=this[Yh]("readwrite"),o;try{o=s.put(t,e)}catch(a){return this.nextTick(i,a)}this[My](o,i)}_iterator(e){return new s7e(this,this[tl],e)}_batch(e,t,n){let i=this[Yh]("readwrite"),s=i.transaction,o=0,a;s.onabort=function(){n(a||s.error||new Error("aborted by user"))},s.oncomplete=function(){n()};function c(){let l=e[o++],f=l.key,h;try{h=l.type==="del"?i.delete(f):i.put(l.value,f)}catch(p){a=p,s.abort();return}o<e.length?h.onsuccess=c:typeof s.commit=="function"&&s.commit()}c()}_clear(e,t){let n,i;try{n=a7e(e)}catch{return this.nextTick(t)}if(e.limit>=0)return o7e(this,this[tl],n,e,t);try{let s=this[Yh]("readwrite");i=n?s.delete(n):s.clear()}catch(s){return this.nextTick(t,s)}this[My](i,t)}_close(e){this[By].close(),this.nextTick(e)}};D8.destroy=function(r,e,t){typeof e=="function"&&(t=e,e=wQ),t=i7e(t,gQ);let n=indexedDB.deleteDatabase(e+r);return n.onsuccess=function(){t()},n.onerror=function(i){t(i)},t[gQ]};EQ.BrowserLevel=D8});var _Q=R(vQ=>{u();vQ.Level=bQ().BrowserLevel});var FQ=R((itt,UQ)=>{"use strict";u();UQ.exports=Bn;var Ky=Zu();function Bn(r,e){this.lo=r>>>0,this.hi=e>>>0}var Zh=Bn.zero=new Bn(0,0);Zh.toNumber=function(){return 0};Zh.zzEncode=Zh.zzDecode=function(){return this};Zh.length=function(){return 1};var _7e=Bn.zeroHash="\0\0\0\0\0\0\0\0";Bn.fromNumber=function(e){if(e===0)return Zh;var t=e<0;t&&(e=-e);var n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new Bn(n,i)};Bn.from=function(e){if(typeof e=="number")return Bn.fromNumber(e);if(Ky.isString(e))if(Ky.Long)e=Ky.Long.fromString(e);else return Bn.fromNumber(parseInt(e,10));return e.low||e.high?new Bn(e.low>>>0,e.high>>>0):Zh};Bn.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=~this.lo+1>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296};Bn.prototype.toLong=function(e){return Ky.Long?new Ky.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var Xu=String.prototype.charCodeAt;Bn.fromHash=function(e){return e===_7e?Zh:new Bn((Xu.call(e,0)|Xu.call(e,1)<<8|Xu.call(e,2)<<16|Xu.call(e,3)<<24)>>>0,(Xu.call(e,4)|Xu.call(e,5)<<8|Xu.call(e,6)<<16|Xu.call(e,7)<<24)>>>0)};Bn.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};Bn.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};Bn.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};Bn.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}});var Zu=R(JA=>{"use strict";u();var Ne=JA;Ne.asPromise=U3();Ne.base64=Wv();Ne.EventEmitter=Yv();Ne.float=Qv();Ne.inquire=K3();Ne.utf8=Zv();Ne.pool=Jv();Ne.LongBits=FQ();Ne.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);Ne.global=Ne.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||JA;Ne.emptyArray=Object.freeze?Object.freeze([]):[];Ne.emptyObject=Object.freeze?Object.freeze({}):{};Ne.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};Ne.isString=function(e){return typeof e=="string"||e instanceof String};Ne.isObject=function(e){return e&&typeof e=="object"};Ne.isset=Ne.isSet=function(e,t){var n=e[t];return n!=null&&e.hasOwnProperty(t)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};Ne.Buffer=function(){try{var r=Ne.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();Ne._Buffer_from=null;Ne._Buffer_allocUnsafe=null;Ne.newBuffer=function(e){return typeof e=="number"?Ne.Buffer?Ne._Buffer_allocUnsafe(e):new Ne.Array(e):Ne.Buffer?Ne._Buffer_from(e):typeof Uint8Array>"u"?e:new Uint8Array(e)};Ne.Array=typeof Uint8Array<"u"?Uint8Array:Array;Ne.Long=Ne.global.dcodeIO&&Ne.global.dcodeIO.Long||Ne.global.Long||Ne.inquire("long");Ne.key2Re=/^true|false|0|1$/;Ne.key32Re=/^-?(?:0|[1-9][0-9]*)$/;Ne.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;Ne.longToHash=function(e){return e?Ne.LongBits.from(e).toHash():Ne.LongBits.zeroHash};Ne.longFromHash=function(e,t){var n=Ne.LongBits.fromHash(e);return Ne.Long?Ne.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))};function VQ(r,e,t){for(var n=Object.keys(e),i=0;i<n.length;++i)(r[n[i]]===void 0||!t)&&(r[n[i]]=e[n[i]]);return r}Ne.merge=VQ;Ne.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function KQ(r){function e(t,n){if(!(this instanceof e))return new e(t,n);Object.defineProperty(this,"message",{get:function(){return t}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&VQ(this,n)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return r}}),e.prototype.toString=function(){return this.name+": "+this.message},e}Ne.newError=KQ;Ne.ProtocolError=KQ("ProtocolError");Ne.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(t[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};Ne.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}};Ne.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};Ne._configure=function(){var r=Ne.Buffer;if(!r){Ne._Buffer_from=Ne._Buffer_allocUnsafe=null;return}Ne._Buffer_from=r.from!==Uint8Array.from&&r.from||function(t,n){return new r(t,n)},Ne._Buffer_allocUnsafe=r.allocUnsafe||function(t){return new r(t)}}});var oR=R((ott,HQ)=>{"use strict";u();HQ.exports=Nt;var Hs=Zu(),eR,B8=Hs.LongBits,qQ=Hs.base64,zQ=Hs.utf8;function qy(r,e,t){this.fn=r,this.len=e,this.next=void 0,this.val=t}function rR(){}function S7e(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function Nt(){this.len=0,this.head=new qy(rR,0,0),this.tail=this.head,this.states=null}var $Q=function(){return Hs.Buffer?function(){return(Nt.create=function(){return new eR})()}:function(){return new Nt}};Nt.create=$Q();Nt.alloc=function(e){return new Hs.Array(e)};Hs.Array!==Array&&(Nt.alloc=Hs.pool(Nt.alloc,Hs.Array.prototype.subarray));Nt.prototype._push=function(e,t,n){return this.tail=this.tail.next=new qy(e,t,n),this.len+=t,this};function nR(r,e,t){e[t]=r&255}function x7e(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}function iR(r,e){this.len=r,this.next=void 0,this.val=e}iR.prototype=Object.create(qy.prototype);iR.prototype.fn=x7e;Nt.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new iR((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};Nt.prototype.int32=function(e){return e<0?this._push(sR,10,B8.fromNumber(e)):this.uint32(e)};Nt.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function sR(r,e,t){for(;r.hi;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}Nt.prototype.uint64=function(e){var t=B8.from(e);return this._push(sR,t.length(),t)};Nt.prototype.int64=Nt.prototype.uint64;Nt.prototype.sint64=function(e){var t=B8.from(e).zzEncode();return this._push(sR,t.length(),t)};Nt.prototype.bool=function(e){return this._push(nR,1,e?1:0)};function tR(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}Nt.prototype.fixed32=function(e){return this._push(tR,4,e>>>0)};Nt.prototype.sfixed32=Nt.prototype.fixed32;Nt.prototype.fixed64=function(e){var t=B8.from(e);return this._push(tR,4,t.lo)._push(tR,4,t.hi)};Nt.prototype.sfixed64=Nt.prototype.fixed64;Nt.prototype.float=function(e){return this._push(Hs.float.writeFloatLE,4,e)};Nt.prototype.double=function(e){return this._push(Hs.float.writeDoubleLE,8,e)};var T7e=Hs.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var i=0;i<e.length;++i)t[n+i]=e[i]};Nt.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(nR,1,0);if(Hs.isString(e)){var n=Nt.alloc(t=qQ.length(e));qQ.decode(e,n,0),e=n}return this.uint32(t)._push(T7e,t,e)};Nt.prototype.string=function(e){var t=zQ.length(e);return t?this.uint32(t)._push(zQ.write,t,e):this._push(nR,1,0)};Nt.prototype.fork=function(){return this.states=new S7e(this),this.head=this.tail=new qy(rR,0,0),this.len=0,this};Nt.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 qy(rR,0,0),this.len=0),this};Nt.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this};Nt.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t};Nt._configure=function(r){eR=r,Nt.create=$Q(),eR._configure()}});var WQ=R((att,jQ)=>{"use strict";u();jQ.exports=$a;var GQ=oR();($a.prototype=Object.create(GQ.prototype)).constructor=$a;var Ju=Zu();function $a(){GQ.call(this)}$a._configure=function(){$a.alloc=Ju._Buffer_allocUnsafe,$a.writeBytesBuffer=Ju.Buffer&&Ju.Buffer.prototype instanceof Uint8Array&&Ju.Buffer.prototype.set.name==="set"?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var i=0;i<e.length;)t[n++]=e[i++]}};$a.prototype.bytes=function(e){Ju.isString(e)&&(e=Ju._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push($a.writeBytesBuffer,t,e),this};function I7e(r,e,t){r.length<40?Ju.utf8.write(r,e,t):e.utf8Write?e.utf8Write(r,t):e.write(r,t)}$a.prototype.string=function(e){var t=Ju.Buffer.byteLength(e);return this.uint32(t),t&&this._push(I7e,t,e),this};$a._configure()});var lR=R((ctt,JQ)=>{"use strict";u();JQ.exports=en;var Ha=Zu(),cR,XQ=Ha.LongBits,A7e=Ha.utf8;function Ko(r,e){return RangeError("index out of range: "+r.pos+" + "+(e||1)+" > "+r.len)}function en(r){this.buf=r,this.pos=0,this.len=r.length}var YQ=typeof Uint8Array<"u"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new en(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new en(e);throw Error("illegal buffer")},ZQ=function(){return Ha.Buffer?function(t){return(en.create=function(i){return Ha.Buffer.isBuffer(i)?new cR(i):YQ(i)})(t)}:YQ};en.create=ZQ();en.prototype._slice=Ha.Array.prototype.subarray||Ha.Array.prototype.slice;en.prototype.uint32=function(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ko(this,10);return e}}();en.prototype.int32=function(){return this.uint32()|0};en.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function aR(){var r=new XQ(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Ko(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,r}if(this.len-this.pos>4){for(;e<5;++e)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;e<5;++e){if(this.pos>=this.len)throw Ko(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}en.prototype.bool=function(){return this.uint32()!==0};function M8(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}en.prototype.fixed32=function(){if(this.pos+4>this.len)throw Ko(this,4);return M8(this.buf,this.pos+=4)};en.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Ko(this,4);return M8(this.buf,this.pos+=4)|0};function QQ(){if(this.pos+8>this.len)throw Ko(this,8);return new XQ(M8(this.buf,this.pos+=4),M8(this.buf,this.pos+=4))}en.prototype.float=function(){if(this.pos+4>this.len)throw Ko(this,4);var e=Ha.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};en.prototype.double=function(){if(this.pos+8>this.len)throw Ko(this,4);var e=Ha.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};en.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Ko(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)};en.prototype.string=function(){var e=this.bytes();return A7e.read(e,0,e.length)};en.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ko(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ko(this);while(this.buf[this.pos++]&128);return this};en.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};en._configure=function(r){cR=r,en.create=ZQ(),cR._configure();var e=Ha.Long?"toLong":"toNumber";Ha.merge(en.prototype,{int64:function(){return aR.call(this)[e](!1)},uint64:function(){return aR.call(this)[e](!0)},sint64:function(){return aR.call(this).zzDecode()[e](!1)},fixed64:function(){return QQ.call(this)[e](!0)},sfixed64:function(){return QQ.call(this)[e](!1)}})}});var nX=R((ltt,rX)=>{"use strict";u();rX.exports=Jh;var tX=lR();(Jh.prototype=Object.create(tX.prototype)).constructor=Jh;var eX=Zu();function Jh(r){tX.call(this,r)}Jh._configure=function(){eX.Buffer&&(Jh.prototype._slice=eX.Buffer.prototype.slice)};Jh.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))};Jh._configure()});var sX=R((utt,iX)=>{"use strict";u();iX.exports=zy;var uR=Zu();(zy.prototype=Object.create(uR.EventEmitter.prototype)).constructor=zy;function zy(r,e,t){if(typeof r!="function")throw TypeError("rpcImpl must be a function");uR.EventEmitter.call(this),this.rpcImpl=r,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(t)}zy.prototype.rpcCall=function r(e,t,n,i,s){if(!i)throw TypeError("request must be specified");var o=this;if(!s)return uR.asPromise(r,o,e,t,n,i);if(!o.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return o.rpcImpl(e,t[o.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(c,l){if(c)return o.emit("error",c,e),s(c);if(l===null){o.end(!0);return}if(!(l instanceof n))try{l=n[o.responseDelimited?"decodeDelimited":"decode"](l)}catch(f){return o.emit("error",f,e),s(f)}return o.emit("data",l,e),s(null,l)})}catch(a){o.emit("error",a,e),setTimeout(function(){s(a)},0);return}};zy.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var aX=R(oX=>{"use strict";u();var R7e=oX;R7e.Service=sX()});var lX=R((htt,cX)=>{"use strict";u();cX.exports={}});var hX=R(fX=>{"use strict";u();var ki=fX;ki.build="minimal";ki.Writer=oR();ki.BufferWriter=WQ();ki.Reader=lR();ki.BufferReader=nX();ki.util=Zu();ki.rpc=aX();ki.roots=lX();ki.configure=uX;function uX(){ki.util._configure(),ki.Writer._configure(ki.BufferWriter),ki.Reader._configure(ki.BufferReader)}uX()});var pX=R((ptt,dX)=>{"use strict";u();dX.exports=hX()});var yX=R((mX,$y)=>{"use strict";u();(function(r,e){typeof define=="function"&&define.amd?define(["protobufjs/minimal"],e):typeof Rd=="function"&&typeof $y=="object"&&$y&&$y.exports&&($y.exports=e(pX()))})(mX,function(r){"use strict";var e=r.Reader,t=r.Writer,n=r.util,i=r.roots.default||(r.roots.default={});return i.RPC=function(){function s(a){if(this.subscriptions=[],this.messages=[],a)for(var c=Object.keys(a),l=0;l<c.length;++l)a[c[l]]!=null&&(this[c[l]]=a[c[l]])}s.prototype.subscriptions=n.emptyArray,s.prototype.messages=n.emptyArray,s.prototype.control=null;var o;return Object.defineProperty(s.prototype,"_control",{get:n.oneOfGetter(o=["control"]),set:n.oneOfSetter(o)}),s.encode=function(c,l){if(l||(l=t.create()),c.subscriptions!=null&&c.subscriptions.length)for(var f=0;f<c.subscriptions.length;++f)i.RPC.SubOpts.encode(c.subscriptions[f],l.uint32(10).fork()).ldelim();if(c.messages!=null&&c.messages.length)for(var f=0;f<c.messages.length;++f)i.RPC.Message.encode(c.messages[f],l.uint32(18).fork()).ldelim();return c.control!=null&&Object.hasOwnProperty.call(c,"control")&&i.RPC.ControlMessage.encode(c.control,l.uint32(26).fork()).ldelim(),l},s.decode=function(c,l){c instanceof e||(c=e.create(c));for(var f=l===void 0?c.len:c.pos+l,h=new i.RPC;c.pos<f;){var p=c.uint32();switch(p>>>3){case 1:h.subscriptions&&h.subscriptions.length||(h.subscriptions=[]),h.subscriptions.push(i.RPC.SubOpts.decode(c,c.uint32()));break;case 2:h.messages&&h.messages.length||(h.messages=[]),h.messages.push(i.RPC.Message.decode(c,c.uint32()));break;case 3:h.control=i.RPC.ControlMessage.decode(c,c.uint32());break;default:c.skipType(p&7);break}}return h},s.fromObject=function(c){if(c instanceof i.RPC)return c;var l=new i.RPC;if(c.subscriptions){if(!Array.isArray(c.subscriptions))throw TypeError(".RPC.subscriptions: array expected");l.subscriptions=[];for(var f=0;f<c.subscriptions.length;++f){if(typeof c.subscriptions[f]!="object")throw TypeError(".RPC.subscriptions: object expected");l.subscriptions[f]=i.RPC.SubOpts.fromObject(c.subscriptions[f])}}if(c.messages){if(!Array.isArray(c.messages))throw TypeError(".RPC.messages: array expected");l.messages=[];for(var f=0;f<c.messages.length;++f){if(typeof c.messages[f]!="object")throw TypeError(".RPC.messages: object expected");l.messages[f]=i.RPC.Message.fromObject(c.messages[f])}}if(c.control!=null){if(typeof c.control!="object")throw TypeError(".RPC.control: object expected");l.control=i.RPC.ControlMessage.fromObject(c.control)}return l},s.toObject=function(c,l){l||(l={});var f={};if((l.arrays||l.defaults)&&(f.subscriptions=[],f.messages=[]),c.subscriptions&&c.subscriptions.length){f.subscriptions=[];for(var h=0;h<c.subscriptions.length;++h)f.subscriptions[h]=i.RPC.SubOpts.toObject(c.subscriptions[h],l)}if(c.messages&&c.messages.length){f.messages=[];for(var h=0;h<c.messages.length;++h)f.messages[h]=i.RPC.Message.toObject(c.messages[h],l)}return c.control!=null&&c.hasOwnProperty("control")&&(f.control=i.RPC.ControlMessage.toObject(c.control,l),l.oneofs&&(f._control="control")),f},s.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},s.SubOpts=function(){function a(l){if(l)for(var f=Object.keys(l),h=0;h<f.length;++h)l[f[h]]!=null&&(this[f[h]]=l[f[h]])}a.prototype.subscribe=null,a.prototype.topic=null;var c;return Object.defineProperty(a.prototype,"_subscribe",{get:n.oneOfGetter(c=["subscribe"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_topic",{get:n.oneOfGetter(c=["topic"]),set:n.oneOfSetter(c)}),a.encode=function(f,h){return h||(h=t.create()),f.subscribe!=null&&Object.hasOwnProperty.call(f,"subscribe")&&h.uint32(8).bool(f.subscribe),f.topic!=null&&Object.hasOwnProperty.call(f,"topic")&&h.uint32(18).string(f.topic),h},a.decode=function(f,h){f instanceof e||(f=e.create(f));for(var p=h===void 0?f.len:f.pos+h,d=new i.RPC.SubOpts;f.pos<p;){var m=f.uint32();switch(m>>>3){case 1:d.subscribe=f.bool();break;case 2:d.topic=f.string();break;default:f.skipType(m&7);break}}return d},a.fromObject=function(f){if(f instanceof i.RPC.SubOpts)return f;var h=new i.RPC.SubOpts;return f.subscribe!=null&&(h.subscribe=Boolean(f.subscribe)),f.topic!=null&&(h.topic=String(f.topic)),h},a.toObject=function(f,h){h||(h={});var p={};return f.subscribe!=null&&f.hasOwnProperty("subscribe")&&(p.subscribe=f.subscribe,h.oneofs&&(p._subscribe="subscribe")),f.topic!=null&&f.hasOwnProperty("topic")&&(p.topic=f.topic,h.oneofs&&(p._topic="topic")),p},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.Message=function(){function a(l){if(l)for(var f=Object.keys(l),h=0;h<f.length;++h)l[f[h]]!=null&&(this[f[h]]=l[f[h]])}a.prototype.from=null,a.prototype.data=null,a.prototype.seqno=null,a.prototype.topic="",a.prototype.signature=null,a.prototype.key=null;var c;return Object.defineProperty(a.prototype,"_from",{get:n.oneOfGetter(c=["from"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_data",{get:n.oneOfGetter(c=["data"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_seqno",{get:n.oneOfGetter(c=["seqno"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_signature",{get:n.oneOfGetter(c=["signature"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_key",{get:n.oneOfGetter(c=["key"]),set:n.oneOfSetter(c)}),a.encode=function(f,h){return h||(h=t.create()),f.from!=null&&Object.hasOwnProperty.call(f,"from")&&h.uint32(10).bytes(f.from),f.data!=null&&Object.hasOwnProperty.call(f,"data")&&h.uint32(18).bytes(f.data),f.seqno!=null&&Object.hasOwnProperty.call(f,"seqno")&&h.uint32(26).bytes(f.seqno),h.uint32(34).string(f.topic),f.signature!=null&&Object.hasOwnProperty.call(f,"signature")&&h.uint32(42).bytes(f.signature),f.key!=null&&Object.hasOwnProperty.call(f,"key")&&h.uint32(50).bytes(f.key),h},a.decode=function(f,h){f instanceof e||(f=e.create(f));for(var p=h===void 0?f.len:f.pos+h,d=new i.RPC.Message;f.pos<p;){var m=f.uint32();switch(m>>>3){case 1:d.from=f.bytes();break;case 2:d.data=f.bytes();break;case 3:d.seqno=f.bytes();break;case 4:d.topic=f.string();break;case 5:d.signature=f.bytes();break;case 6:d.key=f.bytes();break;default:f.skipType(m&7);break}}if(!d.hasOwnProperty("topic"))throw n.ProtocolError("missing required 'topic'",{instance:d});return d},a.fromObject=function(f){if(f instanceof i.RPC.Message)return f;var h=new i.RPC.Message;return f.from!=null&&(typeof f.from=="string"?n.base64.decode(f.from,h.from=n.newBuffer(n.base64.length(f.from)),0):f.from.length&&(h.from=f.from)),f.data!=null&&(typeof f.data=="string"?n.base64.decode(f.data,h.data=n.newBuffer(n.base64.length(f.data)),0):f.data.length&&(h.data=f.data)),f.seqno!=null&&(typeof f.seqno=="string"?n.base64.decode(f.seqno,h.seqno=n.newBuffer(n.base64.length(f.seqno)),0):f.seqno.length&&(h.seqno=f.seqno)),f.topic!=null&&(h.topic=String(f.topic)),f.signature!=null&&(typeof f.signature=="string"?n.base64.decode(f.signature,h.signature=n.newBuffer(n.base64.length(f.signature)),0):f.signature.length&&(h.signature=f.signature)),f.key!=null&&(typeof f.key=="string"?n.base64.decode(f.key,h.key=n.newBuffer(n.base64.length(f.key)),0):f.key.length&&(h.key=f.key)),h},a.toObject=function(f,h){h||(h={});var p={};return h.defaults&&(p.topic=""),f.from!=null&&f.hasOwnProperty("from")&&(p.from=h.bytes===String?n.base64.encode(f.from,0,f.from.length):h.bytes===Array?Array.prototype.slice.call(f.from):f.from,h.oneofs&&(p._from="from")),f.data!=null&&f.hasOwnProperty("data")&&(p.data=h.bytes===String?n.base64.encode(f.data,0,f.data.length):h.bytes===Array?Array.prototype.slice.call(f.data):f.data,h.oneofs&&(p._data="data")),f.seqno!=null&&f.hasOwnProperty("seqno")&&(p.seqno=h.bytes===String?n.base64.encode(f.seqno,0,f.seqno.length):h.bytes===Array?Array.prototype.slice.call(f.seqno):f.seqno,h.oneofs&&(p._seqno="seqno")),f.topic!=null&&f.hasOwnProperty("topic")&&(p.topic=f.topic),f.signature!=null&&f.hasOwnProperty("signature")&&(p.signature=h.bytes===String?n.base64.encode(f.signature,0,f.signature.length):h.bytes===Array?Array.prototype.slice.call(f.signature):f.signature,h.oneofs&&(p._signature="signature")),f.key!=null&&f.hasOwnProperty("key")&&(p.key=h.bytes===String?n.base64.encode(f.key,0,f.key.length):h.bytes===Array?Array.prototype.slice.call(f.key):f.key,h.oneofs&&(p._key="key")),p},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.ControlMessage=function(){function a(c){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],c)for(var l=Object.keys(c),f=0;f<l.length;++f)c[l[f]]!=null&&(this[l[f]]=c[l[f]])}return a.prototype.ihave=n.emptyArray,a.prototype.iwant=n.emptyArray,a.prototype.graft=n.emptyArray,a.prototype.prune=n.emptyArray,a.encode=function(l,f){if(f||(f=t.create()),l.ihave!=null&&l.ihave.length)for(var h=0;h<l.ihave.length;++h)i.RPC.ControlIHave.encode(l.ihave[h],f.uint32(10).fork()).ldelim();if(l.iwant!=null&&l.iwant.length)for(var h=0;h<l.iwant.length;++h)i.RPC.ControlIWant.encode(l.iwant[h],f.uint32(18).fork()).ldelim();if(l.graft!=null&&l.graft.length)for(var h=0;h<l.graft.length;++h)i.RPC.ControlGraft.encode(l.graft[h],f.uint32(26).fork()).ldelim();if(l.prune!=null&&l.prune.length)for(var h=0;h<l.prune.length;++h)i.RPC.ControlPrune.encode(l.prune[h],f.uint32(34).fork()).ldelim();return f},a.decode=function(l,f){l instanceof e||(l=e.create(l));for(var h=f===void 0?l.len:l.pos+f,p=new i.RPC.ControlMessage;l.pos<h;){var d=l.uint32();switch(d>>>3){case 1:p.ihave&&p.ihave.length||(p.ihave=[]),p.ihave.push(i.RPC.ControlIHave.decode(l,l.uint32()));break;case 2:p.iwant&&p.iwant.length||(p.iwant=[]),p.iwant.push(i.RPC.ControlIWant.decode(l,l.uint32()));break;case 3:p.graft&&p.graft.length||(p.graft=[]),p.graft.push(i.RPC.ControlGraft.decode(l,l.uint32()));break;case 4:p.prune&&p.prune.length||(p.prune=[]),p.prune.push(i.RPC.ControlPrune.decode(l,l.uint32()));break;default:l.skipType(d&7);break}}return p},a.fromObject=function(l){if(l instanceof i.RPC.ControlMessage)return l;var f=new i.RPC.ControlMessage;if(l.ihave){if(!Array.isArray(l.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");f.ihave=[];for(var h=0;h<l.ihave.length;++h){if(typeof l.ihave[h]!="object")throw TypeError(".RPC.ControlMessage.ihave: object expected");f.ihave[h]=i.RPC.ControlIHave.fromObject(l.ihave[h])}}if(l.iwant){if(!Array.isArray(l.iwant))throw TypeError(".RPC.ControlMessage.iwant: array expected");f.iwant=[];for(var h=0;h<l.iwant.length;++h){if(typeof l.iwant[h]!="object")throw TypeError(".RPC.ControlMessage.iwant: object expected");f.iwant[h]=i.RPC.ControlIWant.fromObject(l.iwant[h])}}if(l.graft){if(!Array.isArray(l.graft))throw TypeError(".RPC.ControlMessage.graft: array expected");f.graft=[];for(var h=0;h<l.graft.length;++h){if(typeof l.graft[h]!="object")throw TypeError(".RPC.ControlMessage.graft: object expected");f.graft[h]=i.RPC.ControlGraft.fromObject(l.graft[h])}}if(l.prune){if(!Array.isArray(l.prune))throw TypeError(".RPC.ControlMessage.prune: array expected");f.prune=[];for(var h=0;h<l.prune.length;++h){if(typeof l.prune[h]!="object")throw TypeError(".RPC.ControlMessage.prune: object expected");f.prune[h]=i.RPC.ControlPrune.fromObject(l.prune[h])}}return f},a.toObject=function(l,f){f||(f={});var h={};if((f.arrays||f.defaults)&&(h.ihave=[],h.iwant=[],h.graft=[],h.prune=[]),l.ihave&&l.ihave.length){h.ihave=[];for(var p=0;p<l.ihave.length;++p)h.ihave[p]=i.RPC.ControlIHave.toObject(l.ihave[p],f)}if(l.iwant&&l.iwant.length){h.iwant=[];for(var p=0;p<l.iwant.length;++p)h.iwant[p]=i.RPC.ControlIWant.toObject(l.iwant[p],f)}if(l.graft&&l.graft.length){h.graft=[];for(var p=0;p<l.graft.length;++p)h.graft[p]=i.RPC.ControlGraft.toObject(l.graft[p],f)}if(l.prune&&l.prune.length){h.prune=[];for(var p=0;p<l.prune.length;++p)h.prune[p]=i.RPC.ControlPrune.toObject(l.prune[p],f)}return h},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.ControlIHave=function(){function a(l){if(this.messageIDs=[],l)for(var f=Object.keys(l),h=0;h<f.length;++h)l[f[h]]!=null&&(this[f[h]]=l[f[h]])}a.prototype.topicID=null,a.prototype.messageIDs=n.emptyArray;var c;return Object.defineProperty(a.prototype,"_topicID",{get:n.oneOfGetter(c=["topicID"]),set:n.oneOfSetter(c)}),a.encode=function(f,h){if(h||(h=t.create()),f.topicID!=null&&Object.hasOwnProperty.call(f,"topicID")&&h.uint32(10).string(f.topicID),f.messageIDs!=null&&f.messageIDs.length)for(var p=0;p<f.messageIDs.length;++p)h.uint32(18).bytes(f.messageIDs[p]);return h},a.decode=function(f,h){f instanceof e||(f=e.create(f));for(var p=h===void 0?f.len:f.pos+h,d=new i.RPC.ControlIHave;f.pos<p;){var m=f.uint32();switch(m>>>3){case 1:d.topicID=f.string();break;case 2:d.messageIDs&&d.messageIDs.length||(d.messageIDs=[]),d.messageIDs.push(f.bytes());break;default:f.skipType(m&7);break}}return d},a.fromObject=function(f){if(f instanceof i.RPC.ControlIHave)return f;var h=new i.RPC.ControlIHave;if(f.topicID!=null&&(h.topicID=String(f.topicID)),f.messageIDs){if(!Array.isArray(f.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");h.messageIDs=[];for(var p=0;p<f.messageIDs.length;++p)typeof f.messageIDs[p]=="string"?n.base64.decode(f.messageIDs[p],h.messageIDs[p]=n.newBuffer(n.base64.length(f.messageIDs[p])),0):f.messageIDs[p].length&&(h.messageIDs[p]=f.messageIDs[p])}return h},a.toObject=function(f,h){h||(h={});var p={};if((h.arrays||h.defaults)&&(p.messageIDs=[]),f.topicID!=null&&f.hasOwnProperty("topicID")&&(p.topicID=f.topicID,h.oneofs&&(p._topicID="topicID")),f.messageIDs&&f.messageIDs.length){p.messageIDs=[];for(var d=0;d<f.messageIDs.length;++d)p.messageIDs[d]=h.bytes===String?n.base64.encode(f.messageIDs[d],0,f.messageIDs[d].length):h.bytes===Array?Array.prototype.slice.call(f.messageIDs[d]):f.messageIDs[d]}return p},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.ControlIWant=function(){function a(c){if(this.messageIDs=[],c)for(var l=Object.keys(c),f=0;f<l.length;++f)c[l[f]]!=null&&(this[l[f]]=c[l[f]])}return a.prototype.messageIDs=n.emptyArray,a.encode=function(l,f){if(f||(f=t.create()),l.messageIDs!=null&&l.messageIDs.length)for(var h=0;h<l.messageIDs.length;++h)f.uint32(10).bytes(l.messageIDs[h]);return f},a.decode=function(l,f){l instanceof e||(l=e.create(l));for(var h=f===void 0?l.len:l.pos+f,p=new i.RPC.ControlIWant;l.pos<h;){var d=l.uint32();switch(d>>>3){case 1:p.messageIDs&&p.messageIDs.length||(p.messageIDs=[]),p.messageIDs.push(l.bytes());break;default:l.skipType(d&7);break}}return p},a.fromObject=function(l){if(l instanceof i.RPC.ControlIWant)return l;var f=new i.RPC.ControlIWant;if(l.messageIDs){if(!Array.isArray(l.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");f.messageIDs=[];for(var h=0;h<l.messageIDs.length;++h)typeof l.messageIDs[h]=="string"?n.base64.decode(l.messageIDs[h],f.messageIDs[h]=n.newBuffer(n.base64.length(l.messageIDs[h])),0):l.messageIDs[h].length&&(f.messageIDs[h]=l.messageIDs[h])}return f},a.toObject=function(l,f){f||(f={});var h={};if((f.arrays||f.defaults)&&(h.messageIDs=[]),l.messageIDs&&l.messageIDs.length){h.messageIDs=[];for(var p=0;p<l.messageIDs.length;++p)h.messageIDs[p]=f.bytes===String?n.base64.encode(l.messageIDs[p],0,l.messageIDs[p].length):f.bytes===Array?Array.prototype.slice.call(l.messageIDs[p]):l.messageIDs[p]}return h},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.ControlGraft=function(){function a(l){if(l)for(var f=Object.keys(l),h=0;h<f.length;++h)l[f[h]]!=null&&(this[f[h]]=l[f[h]])}a.prototype.topicID=null;var c;return Object.defineProperty(a.prototype,"_topicID",{get:n.oneOfGetter(c=["topicID"]),set:n.oneOfSetter(c)}),a.encode=function(f,h){return h||(h=t.create()),f.topicID!=null&&Object.hasOwnProperty.call(f,"topicID")&&h.uint32(10).string(f.topicID),h},a.decode=function(f,h){f instanceof e||(f=e.create(f));for(var p=h===void 0?f.len:f.pos+h,d=new i.RPC.ControlGraft;f.pos<p;){var m=f.uint32();switch(m>>>3){case 1:d.topicID=f.string();break;default:f.skipType(m&7);break}}return d},a.fromObject=function(f){if(f instanceof i.RPC.ControlGraft)return f;var h=new i.RPC.ControlGraft;return f.topicID!=null&&(h.topicID=String(f.topicID)),h},a.toObject=function(f,h){h||(h={});var p={};return f.topicID!=null&&f.hasOwnProperty("topicID")&&(p.topicID=f.topicID,h.oneofs&&(p._topicID="topicID")),p},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.ControlPrune=function(){function a(l){if(this.peers=[],l)for(var f=Object.keys(l),h=0;h<f.length;++h)l[f[h]]!=null&&(this[f[h]]=l[f[h]])}a.prototype.topicID=null,a.prototype.peers=n.emptyArray,a.prototype.backoff=null;var c;return Object.defineProperty(a.prototype,"_topicID",{get:n.oneOfGetter(c=["topicID"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_backoff",{get:n.oneOfGetter(c=["backoff"]),set:n.oneOfSetter(c)}),a.encode=function(f,h){if(h||(h=t.create()),f.topicID!=null&&Object.hasOwnProperty.call(f,"topicID")&&h.uint32(10).string(f.topicID),f.peers!=null&&f.peers.length)for(var p=0;p<f.peers.length;++p)i.RPC.PeerInfo.encode(f.peers[p],h.uint32(18).fork()).ldelim();return f.backoff!=null&&Object.hasOwnProperty.call(f,"backoff")&&h.uint32(24).uint64(f.backoff),h},a.decode=function(f,h){f instanceof e||(f=e.create(f));for(var p=h===void 0?f.len:f.pos+h,d=new i.RPC.ControlPrune;f.pos<p;){var m=f.uint32();switch(m>>>3){case 1:d.topicID=f.string();break;case 2:d.peers&&d.peers.length||(d.peers=[]),d.peers.push(i.RPC.PeerInfo.decode(f,f.uint32()));break;case 3:d.backoff=f.uint64();break;default:f.skipType(m&7);break}}return d},a.fromObject=function(f){if(f instanceof i.RPC.ControlPrune)return f;var h=new i.RPC.ControlPrune;if(f.topicID!=null&&(h.topicID=String(f.topicID)),f.peers){if(!Array.isArray(f.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");h.peers=[];for(var p=0;p<f.peers.length;++p){if(typeof f.peers[p]!="object")throw TypeError(".RPC.ControlPrune.peers: object expected");h.peers[p]=i.RPC.PeerInfo.fromObject(f.peers[p])}}return f.backoff!=null&&(n.Long?(h.backoff=n.Long.fromValue(f.backoff)).unsigned=!0:typeof f.backoff=="string"?h.backoff=parseInt(f.backoff,10):typeof f.backoff=="number"?h.backoff=f.backoff:typeof f.backoff=="object"&&(h.backoff=new n.LongBits(f.backoff.low>>>0,f.backoff.high>>>0).toNumber(!0))),h},a.toObject=function(f,h){h||(h={});var p={};if((h.arrays||h.defaults)&&(p.peers=[]),f.topicID!=null&&f.hasOwnProperty("topicID")&&(p.topicID=f.topicID,h.oneofs&&(p._topicID="topicID")),f.peers&&f.peers.length){p.peers=[];for(var d=0;d<f.peers.length;++d)p.peers[d]=i.RPC.PeerInfo.toObject(f.peers[d],h)}return f.backoff!=null&&f.hasOwnProperty("backoff")&&(typeof f.backoff=="number"?p.backoff=h.longs===String?String(f.backoff):f.backoff:p.backoff=h.longs===String?n.Long.prototype.toString.call(f.backoff):h.longs===Number?new n.LongBits(f.backoff.low>>>0,f.backoff.high>>>0).toNumber(!0):f.backoff,h.oneofs&&(p._backoff="backoff")),p},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s.PeerInfo=function(){function a(l){if(l)for(var f=Object.keys(l),h=0;h<f.length;++h)l[f[h]]!=null&&(this[f[h]]=l[f[h]])}a.prototype.peerID=null,a.prototype.signedPeerRecord=null;var c;return Object.defineProperty(a.prototype,"_peerID",{get:n.oneOfGetter(c=["peerID"]),set:n.oneOfSetter(c)}),Object.defineProperty(a.prototype,"_signedPeerRecord",{get:n.oneOfGetter(c=["signedPeerRecord"]),set:n.oneOfSetter(c)}),a.encode=function(f,h){return h||(h=t.create()),f.peerID!=null&&Object.hasOwnProperty.call(f,"peerID")&&h.uint32(10).bytes(f.peerID),f.signedPeerRecord!=null&&Object.hasOwnProperty.call(f,"signedPeerRecord")&&h.uint32(18).bytes(f.signedPeerRecord),h},a.decode=function(f,h){f instanceof e||(f=e.create(f));for(var p=h===void 0?f.len:f.pos+h,d=new i.RPC.PeerInfo;f.pos<p;){var m=f.uint32();switch(m>>>3){case 1:d.peerID=f.bytes();break;case 2:d.signedPeerRecord=f.bytes();break;default:f.skipType(m&7);break}}return d},a.fromObject=function(f){if(f instanceof i.RPC.PeerInfo)return f;var h=new i.RPC.PeerInfo;return f.peerID!=null&&(typeof f.peerID=="string"?n.base64.decode(f.peerID,h.peerID=n.newBuffer(n.base64.length(f.peerID)),0):f.peerID.length&&(h.peerID=f.peerID)),f.signedPeerRecord!=null&&(typeof f.signedPeerRecord=="string"?n.base64.decode(f.signedPeerRecord,h.signedPeerRecord=n.newBuffer(n.base64.length(f.signedPeerRecord)),0):f.signedPeerRecord.length&&(h.signedPeerRecord=f.signedPeerRecord)),h},a.toObject=function(f,h){h||(h={});var p={};return f.peerID!=null&&f.hasOwnProperty("peerID")&&(p.peerID=h.bytes===String?n.base64.encode(f.peerID,0,f.peerID.length):h.bytes===Array?Array.prototype.slice.call(f.peerID):f.peerID,h.oneofs&&(p._peerID="peerID")),f.signedPeerRecord!=null&&f.hasOwnProperty("signedPeerRecord")&&(p.signedPeerRecord=h.bytes===String?n.base64.encode(f.signedPeerRecord,0,f.signedPeerRecord.length):h.bytes===Array?Array.prototype.slice.call(f.signedPeerRecord):f.signedPeerRecord,h.oneofs&&(p._signedPeerRecord="signedPeerRecord")),p},a.prototype.toJSON=function(){return this.constructor.toObject(this,r.util.toJSONOptions)},a}(),s}(),i})});var AX=R((Utt,IX)=>{"use strict";u();function Vr(r,t){var t=t||{};this._head=0,this._tail=0,this._capacity=t.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(r)&&this._fromArray(r)}Vr.prototype.peekAt=function(e){var t=e;if(t===(t|0)){var n=this.size();if(!(t>=n||t<-n))return t<0&&(t+=n),t=this._head+t&this._capacityMask,this._list[t]}};Vr.prototype.get=function(e){return this.peekAt(e)};Vr.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]};Vr.prototype.peekFront=function(){return this.peek()};Vr.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(Vr.prototype,"length",{get:function(){return this.size()}});Vr.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};Vr.prototype.unshift=function(e){if(e===void 0)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)};Vr.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}};Vr.prototype.push=function(e){if(e===void 0)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)};Vr.prototype.pop=function(){var e=this._tail;if(e!==this._head){var t=this._list.length;this._tail=e-1+t&this._capacityMask;var n=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=t>>>2&&this._shrinkArray(),n}};Vr.prototype.removeOne=function(e){var t=e;if(t===(t|0)&&this._head!==this._tail){var n=this.size(),i=this._list.length;if(!(t>=n||t<-n)){t<0&&(t+=n),t=this._head+t&this._capacityMask;var s=this._list[t],o;if(e<n/2){for(o=e;o>0;o--)this._list[t]=this._list[t=t-1+i&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+i&this._capacityMask}else{for(o=n-1-e;o>0;o--)this._list[t]=this._list[t=t+1+i&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+i&this._capacityMask}return s}}};Vr.prototype.remove=function(e,t){var n=e,i,s=t;if(n===(n|0)&&this._head!==this._tail){var o=this.size(),a=this._list.length;if(!(n>=o||n<-o||t<1)){if(n<0&&(n+=o),t===1||!t)return i=new Array(1),i[0]=this.removeOne(n),i;if(n===0&&n+t>=o)return i=this.toArray(),this.clear(),i;n+t>o&&(t=o-n);var c;for(i=new Array(t),c=0;c<t;c++)i[c]=this._list[this._head+n+c&this._capacityMask];if(n=this._head+n&this._capacityMask,e+t===o){for(this._tail=this._tail-t+a&this._capacityMask,c=t;c>0;c--)this._list[n=n+1+a&this._capacityMask]=void 0;return i}if(e===0){for(this._head=this._head+t+a&this._capacityMask,c=t-1;c>0;c--)this._list[n=n+1+a&this._capacityMask]=void 0;return i}if(n<o/2){for(this._head=this._head+e+t+a&this._capacityMask,c=e;c>0;c--)this.unshift(this._list[n=n-1+a&this._capacityMask]);for(n=this._head-1+a&this._capacityMask;s>0;)this._list[n=n-1+a&this._capacityMask]=void 0,s--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+a&this._capacityMask,c=o-(t+e);c>0;c--)this.push(this._list[n++]);for(n=this._tail;s>0;)this._list[n=n+1+a&this._capacityMask]=void 0,s--}return this._head<2&&this._tail>1e4&&this._tail<=a>>>2&&this._shrinkArray(),i}}};Vr.prototype.splice=function(e,t){var n=e;if(n===(n|0)){var i=this.size();if(n<0&&(n+=i),!(n>i))if(arguments.length>2){var s,o,a,c=arguments.length,l=this._list.length,f=2;if(!i||n<i/2){for(o=new Array(n),s=0;s<n;s++)o[s]=this._list[this._head+s&this._capacityMask];for(t===0?(a=[],n>0&&(this._head=this._head+n+l&this._capacityMask)):(a=this.remove(n,t),this._head=this._head+n+l&this._capacityMask);c>f;)this.unshift(arguments[--c]);for(s=n;s>0;s--)this.unshift(o[s-1])}else{o=new Array(i-(n+t));var h=o.length;for(s=0;s<h;s++)o[s]=this._list[this._head+n+t+s&this._capacityMask];for(t===0?(a=[],n!=i&&(this._tail=this._head+n+l&this._capacityMask)):(a=this.remove(n,t),this._tail=this._tail-h+l&this._capacityMask);f<c;)this.push(arguments[f++]);for(s=0;s<h;s++)this.push(o[s])}return a}else return this.remove(n,t)}};Vr.prototype.clear=function(){this._head=0,this._tail=0};Vr.prototype.isEmpty=function(){return this._head===this._tail};Vr.prototype.toArray=function(){return this._copyArray(!1)};Vr.prototype._fromArray=function(e){for(var t=0;t<e.length;t++)this.push(e[t])};Vr.prototype._copyArray=function(e){var t=[],n=this._list,i=n.length,s;if(e||this._head>this._tail){for(s=this._head;s<i;s++)t.push(n[s]);for(s=0;s<this._tail;s++)t.push(n[s])}else for(s=this._head;s<this._tail;s++)t.push(n[s]);return t};Vr.prototype._growArray=function(){this._head&&(this._list=this._copyArray(!0),this._head=0),this._tail=this._list.length,this._list.length<<=1,this._capacityMask=this._capacityMask<<1|1};Vr.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};IX.exports=Vr});var _J=R((kct,vJ)=>{u();vJ.exports=r=>{if(r[Symbol.asyncIterator])return r;if(r.getReader)return async function*(){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}();throw new Error("unknown stream")}});var NR=R(()=>{u()});var LR=R((R0t,dte)=>{"use strict";u();var r_e=cp(),n_e=(r,e)=>({path:decodeURIComponent(new URL(r).pathname.split("/").pop()||""),content:i_e(r,e)});async function*i_e(r,e){yield*(await new r_e().get(r,e)).iterator()}dte.exports=n_e});var DE=R((Ymt,Vte)=>{"use strict";u();function D_e(r){let e=new Uint8Array(r),t=0;if(r>0)if(r>65536)for(;t<r;)t+65536>r?(crypto.getRandomValues(e.subarray(t,t+(r-t))),t+=r-t):(crypto.getRandomValues(e.subarray(t,t+65536)),t+=65536);else crypto.getRandomValues(e);return e}Vte.exports=D_e});var WR=R((Zmt,jR)=>{"use strict";u();var k_e=(r,e)=>Math.floor(Math.random()*(e-r+1)+r),zte=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},$te=({clearTimeout:r,setTimeout:e,willResolve:t})=>(n,{value:i,signal:s}={})=>{if(s&&s.aborted)return Promise.reject(zte());let o,a,c,l=r||clearTimeout,f=()=>{l(o),c(zte())},h=()=>{s&&s.removeEventListener("abort",f)},p=new Promise((d,m)=>{a=()=>{h(),t?d(i):m(i)},c=m,o=(e||setTimeout)(a,n)});return s&&s.addEventListener("abort",f,{once:!0}),p.clear=()=>{l(o),o=null,a()},p},Hte=r=>{let e=$te({...r,willResolve:!0});return e.reject=$te({...r,willResolve:!1}),e.range=(t,n,i)=>e(k_e(t,n),i),e},GR=Hte();GR.createWithTimers=Hte;jR.exports=GR;jR.exports.default=GR});var iC=R((Eyt,ure)=>{"use strict";u();var e1=new Map,$_e=()=>`${Date.now()}:${Math.floor(Math.random()*1e6)}`;async function H_e(r,e,t){for(;e1.get(t);){try{await r()}catch(n){setTimeout(()=>{throw n},1);break}if(!e1.get(t))break;await new Promise(n=>{let i=setTimeout(n,e);e1.set(t,i)})}}function G_e(r,e,t){t=t||e;let n=$_e(),i=setTimeout(()=>{H_e(r,e,n)},t);return e1.set(n,i),n}function j_e(r){let e=e1.get(r);e&&(clearTimeout(e),e1.delete(r))}ure.exports={setDelayedInterval:G_e,clearDelayedInterval:j_e}});var Lre=R(Rg=>{u();(function(){var r,e,t,n,i,s,o,a;a=function(c){var l,f,h,p;return l=(c&255<<24)>>>24,f=(c&255<<16)>>>16,h=(c&255<<8)>>>8,p=c&255,[l,f,h,p].join(".")},o=function(c){var l,f,h,p,d,m;for(l=[],h=p=0;p<=3&&c.length!==0;h=++p){if(h>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}m=e(c),d=m[0],f=m[1],c=c.substring(f),l.push(d)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),s=t("a"),i=t("A"),e=function(c){var l,f,h,p,d;for(p=0,l=10,f="9",h=0,c.length>1&&c[h]==="0"&&(c[h+1]==="x"||c[h+1]==="X"?(h+=2,l=16):"0"<=c[h+1]&&c[h+1]<="9"&&(h++,l=8,f="7")),d=h;h<c.length;){if("0"<=c[h]&&c[h]<=f)p=p*l+(t(c[h])-n)>>>0;else if(l===16)if("a"<=c[h]&&c[h]<="f")p=p*l+(10+t(c[h])-s)>>>0;else if("A"<=c[h]&&c[h]<="F")p=p*l+(10+t(c[h])-i)>>>0;else break;else break;if(p>4294967295)throw new Error("too large");h++}if(h===d)throw new Error("empty octet");return[p,h]},r=function(){function c(l,f){var h,p,d,m;if(typeof l!="string")throw new Error("Missing `net' parameter");if(f||(m=l.split("/",2),l=m[0],f=m[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=o(f)}catch(y){throw h=y,new Error("Invalid mask: "+f)}for(p=d=32;d>=0;p=--d)if(this.maskLong===4294967295<<32-p>>>0){this.bitmask=p;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(l)&this.maskLong)>>>0}catch(y){throw h=y,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(o(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var f,h,p;for(p=o(this.first),h=o(this.last),f=0;p<=h;)l(a(p),p,f),f++,p++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Rg.ip2long=o,Rg.long2ip=a,Rg.Netmask=r}).call(Rg)});var EC=R((_3t,Mre)=>{"use strict";u();var Bre="[a-fA-F\\d:]",hf=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${Bre})|(?<=${Bre})(?=\\s|$))`:"",Ho="(?: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}",mn="[a-fA-F\\d]{1,4}",tb=`
(?:
(?:${mn}:){7}(?:${mn}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:${mn}:){6}(?:${Ho}|:${mn}|:)| // 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
(?:${mn}:){5}(?::${Ho}|(?::${mn}){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
(?:${mn}:){4}(?:(?::${mn}){0,1}:${Ho}|(?::${mn}){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
(?:${mn}:){3}(?:(?::${mn}){0,2}:${Ho}|(?::${mn}){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
(?:${mn}:){2}(?:(?::${mn}){0,3}:${Ho}|(?::${mn}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:${mn}:){1}(?:(?::${mn}){0,4}:${Ho}|(?::${mn}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::${mn}){0,5}:${Ho}|(?::${mn}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),n9e=new RegExp(`(?:^${Ho}$)|(?:^${tb}$)`),i9e=new RegExp(`^${Ho}$`),s9e=new RegExp(`^${tb}$`),wC=r=>r&&r.exact?n9e:new RegExp(`(?:${hf(r)}${Ho}${hf(r)})|(?:${hf(r)}${tb}${hf(r)})`,"g");wC.v4=r=>r&&r.exact?i9e:new RegExp(`${hf(r)}${Ho}${hf(r)}`,"g");wC.v6=r=>r&&r.exact?s9e:new RegExp(`${hf(r)}${tb}${hf(r)}`,"g");Mre.exports=wC});var Fre=R((S3t,Ure)=>{"use strict";u();var bC=EC(),r1=r=>bC({exact:!0}).test(r);r1.v4=r=>bC.v4({exact:!0}).test(r);r1.v6=r=>bC.v6({exact:!0}).test(r);r1.version=r=>r1(r)?r1.v4(r)?4:6:void 0;Ure.exports=r1});var Kre=R((Vre,rb)=>{u();(function(r){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",t={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(s,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${s})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${s})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${e}\\.${e}\\.${e}\\.${e}(${s})?$`,"i")};function c(d,m){if(d.indexOf("::")!==d.lastIndexOf("::"))return null;let y=0,g=-1,w=(d.match(a.zoneIndex)||[])[0],b,S;for(w&&(w=w.substring(1),d=d.replace(/%.+$/,""));(g=d.indexOf(":",g+1))>=0;)y++;if(d.substr(0,2)==="::"&&y--,d.substr(-2,2)==="::"&&y--,y>m)return null;for(S=m-y,b=":";S--;)b+="0:";return d=d.replace("::",b),d[0]===":"&&(d=d.slice(1)),d[d.length-1]===":"&&(d=d.slice(0,-1)),m=function(){let _=d.split(":"),I=[];for(let T=0;T<_.length;T++)I.push(parseInt(_[T],16));return I}(),{parts:m,zoneId:w}}function l(d,m,y,g){if(d.length!==m.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let w=0,b;for(;g>0;){if(b=y-g,b<0&&(b=0),d[w]>>b!==m[w]>>b)return!1;g-=y,w+=1}return!0}function f(d){if(i.test(d))return parseInt(d,16);if(d[0]==="0"&&!isNaN(parseInt(d[1],10))){if(n.test(d))return parseInt(d,8);throw new Error(`ipaddr: cannot parse ${d} as octal`)}return parseInt(d,10)}function h(d,m){for(;d.length<m;)d=`0${d}`;return d}let p={};p.IPv4=function(){function d(m){if(m.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let y,g;for(y=0;y<m.length;y++)if(g=m[y],!(0<=g&&g<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=m}return d.prototype.SpecialRanges={unspecified:[[new d([0,0,0,0]),8]],broadcast:[[new d([255,255,255,255]),32]],multicast:[[new d([224,0,0,0]),4]],linkLocal:[[new d([169,254,0,0]),16]],loopback:[[new d([127,0,0,0]),8]],carrierGradeNat:[[new d([100,64,0,0]),10]],private:[[new d([10,0,0,0]),8],[new d([172,16,0,0]),12],[new d([192,168,0,0]),16]],reserved:[[new d([192,0,0,0]),24],[new d([192,0,2,0]),24],[new d([192,88,99,0]),24],[new d([198,51,100,0]),24],[new d([203,0,113,0]),24],[new d([240,0,0,0]),4]]},d.prototype.kind=function(){return"ipv4"},d.prototype.match=function(m,y){let g;if(y===void 0&&(g=m,m=g[0],y=g[1]),m.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,m.octets,8,y)},d.prototype.prefixLengthFromSubnetMask=function(){let m=0,y=!1,g={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},w,b,S;for(w=3;w>=0;w-=1)if(b=this.octets[w],b in g){if(S=g[b],y&&S!==0)return null;S!==8&&(y=!0),m+=S}else return null;return 32-m},d.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){return this.octets.slice(0)},d.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},d.prototype.toNormalizedString=function(){return this.toString()},d.prototype.toString=function(){return this.octets.join(".")},d}(),p.IPv4.broadcastAddressFromCIDR=function(d){try{let m=this.parseCIDR(d),y=m[0].toByteArray(),g=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),w=[],b=0;for(;b<4;)w.push(parseInt(y[b],10)|parseInt(g[b],10)^255),b++;return new this(w)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},p.IPv4.isIPv4=function(d){return this.parser(d)!==null},p.IPv4.isValid=function(d){try{return new this(this.parser(d)),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(d){return!!(p.IPv4.isValid(d)&&d.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.networkAddressFromCIDR=function(d){let m,y,g,w,b;try{for(m=this.parseCIDR(d),g=m[0].toByteArray(),b=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),w=[],y=0;y<4;)w.push(parseInt(g[y],10)&parseInt(b[y],10)),y++;return new this(w)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},p.IPv4.parse=function(d){let m=this.parser(d);if(m===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(m)},p.IPv4.parseCIDR=function(d){let m;if(m=d.match(/^(.+)\/(\d+)$/)){let y=parseInt(m[2]);if(y>=0&&y<=32){let g=[this.parse(m[1]),y];return Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},p.IPv4.parser=function(d){let m,y,g;if(m=d.match(t.fourOctet))return function(){let w=m.slice(1,6),b=[];for(let S=0;S<w.length;S++)y=w[S],b.push(f(y));return b}();if(m=d.match(t.longValue)){if(g=f(m[1]),g>4294967295||g<0)throw new Error("ipaddr: address outside defined range");return function(){let w=[],b;for(b=0;b<=24;b+=8)w.push(g>>b&255);return w}().reverse()}else return(m=d.match(t.twoOctet))?function(){let w=m.slice(1,4),b=[];if(g=f(w[1]),g>16777215||g<0)throw new Error("ipaddr: address outside defined range");return b.push(f(w[0])),b.push(g>>16&255),b.push(g>>8&255),b.push(g&255),b}():(m=d.match(t.threeOctet))?function(){let w=m.slice(1,5),b=[];if(g=f(w[2]),g>65535||g<0)throw new Error("ipaddr: address outside defined range");return b.push(f(w[0])),b.push(f(w[1])),b.push(g>>8&255),b.push(g&255),b}():null},p.IPv4.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>32)throw new Error("ipaddr: invalid IPv4 prefix length");let m=[0,0,0,0],y=0,g=Math.floor(d/8);for(;y<g;)m[y]=255,y++;return g<4&&(m[g]=Math.pow(2,d%8)-1<<8-d%8),new this(m)},p.IPv6=function(){function d(m,y){let g,w;if(m.length===16)for(this.parts=[],g=0;g<=14;g+=2)this.parts.push(m[g]<<8|m[g+1]);else if(m.length===8)this.parts=m;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(g=0;g<this.parts.length;g++)if(w=this.parts[g],!(0<=w&&w<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");y&&(this.zoneId=y)}return d.prototype.SpecialRanges={unspecified:[new d([0,0,0,0,0,0,0,0]),128],linkLocal:[new d([65152,0,0,0,0,0,0,0]),10],multicast:[new d([65280,0,0,0,0,0,0,0]),8],loopback:[new d([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new d([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new d([0,0,0,0,0,65535,0,0]),96],rfc6145:[new d([0,0,0,0,65535,0,0,0]),96],rfc6052:[new d([100,65435,0,0,0,0,0,0]),96],"6to4":[new d([8194,0,0,0,0,0,0,0]),16],teredo:[new d([8193,0,0,0,0,0,0,0]),32],reserved:[[new d([8193,3512,0,0,0,0,0,0]),32]]},d.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},d.prototype.kind=function(){return"ipv6"},d.prototype.match=function(m,y){let g;if(y===void 0&&(g=m,m=g[0],y=g[1]),m.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,m.parts,16,y)},d.prototype.prefixLengthFromSubnetMask=function(){let m=0,y=!1,g={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},w,b;for(let S=7;S>=0;S-=1)if(w=this.parts[S],w in g){if(b=g[w],y&&b!==0)return null;b!==16&&(y=!0),m+=b}else return null;return 128-m},d.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){let m,y=[],g=this.parts;for(let w=0;w<g.length;w++)m=g[w],y.push(m>>8),y.push(m&255);return y},d.prototype.toFixedLengthString=function(){let m=function(){let g=[];for(let w=0;w<this.parts.length;w++)g.push(h(this.parts[w].toString(16),4));return g}.call(this).join(":"),y="";return this.zoneId&&(y=`%${this.zoneId}`),m+y},d.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let m=this.parts.slice(-2),y=m[0],g=m[1];return new p.IPv4([y>>8,y&255,g>>8,g&255])},d.prototype.toNormalizedString=function(){let m=function(){let g=[];for(let w=0;w<this.parts.length;w++)g.push(this.parts[w].toString(16));return g}.call(this).join(":"),y="";return this.zoneId&&(y=`%${this.zoneId}`),m+y},d.prototype.toRFC5952String=function(){let m=/((^|:)(0(:|$)){2,})/g,y=this.toNormalizedString(),g=0,w=-1,b;for(;b=m.exec(y);)b[0].length>w&&(g=b.index,w=b[0].length);return w<0?y:`${y.substring(0,g)}::${y.substring(g+w)}`},d.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},d}(),p.IPv6.broadcastAddressFromCIDR=function(d){try{let m=this.parseCIDR(d),y=m[0].toByteArray(),g=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),w=[],b=0;for(;b<16;)w.push(parseInt(y[b],10)|parseInt(g[b],10)^255),b++;return new this(w)}catch(m){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${m})`)}},p.IPv6.isIPv6=function(d){return this.parser(d)!==null},p.IPv6.isValid=function(d){if(typeof d=="string"&&d.indexOf(":")===-1)return!1;try{let m=this.parser(d);return new this(m.parts,m.zoneId),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(d){let m,y,g,w,b;try{for(m=this.parseCIDR(d),g=m[0].toByteArray(),b=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),w=[],y=0;y<16;)w.push(parseInt(g[y],10)&parseInt(b[y],10)),y++;return new this(w)}catch(S){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${S})`)}},p.IPv6.parse=function(d){let m=this.parser(d);if(m.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(m.parts,m.zoneId)},p.IPv6.parseCIDR=function(d){let m,y,g;if((y=d.match(/^(.+)\/(\d+)$/))&&(m=parseInt(y[2]),m>=0&&m<=128))return g=[this.parse(y[1]),m],Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},p.IPv6.parser=function(d){let m,y,g,w,b,S;if(g=d.match(a.deprecatedTransitional))return this.parser(`::ffff:${g[1]}`);if(a.native.test(d))return c(d,8);if((g=d.match(a.transitional))&&(S=g[6]||"",m=c(g[1].slice(0,-1)+S,6),m.parts)){for(b=[parseInt(g[2]),parseInt(g[3]),parseInt(g[4]),parseInt(g[5])],y=0;y<b.length;y++)if(w=b[y],!(0<=w&&w<=255))return null;return m.parts.push(b[0]<<8|b[1]),m.parts.push(b[2]<<8|b[3]),{parts:m.parts,zoneId:m.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>128)throw new Error("ipaddr: invalid IPv6 prefix length");let m=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],y=0,g=Math.floor(d/8);for(;y<g;)m[y]=255,y++;return g<16&&(m[g]=Math.pow(2,d%8)-1<<8-d%8),new this(m)},p.fromByteArray=function(d){let m=d.length;if(m===4)return new p.IPv4(d);if(m===16)return new p.IPv6(d);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},p.isValid=function(d){return p.IPv6.isValid(d)||p.IPv4.isValid(d)},p.parse=function(d){if(p.IPv6.isValid(d))return p.IPv6.parse(d);if(p.IPv4.isValid(d))return p.IPv4.parse(d);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},p.parseCIDR=function(d){try{return p.IPv6.parseCIDR(d)}catch{try{return p.IPv4.parseCIDR(d)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},p.process=function(d){let m=this.parse(d);return m.kind()==="ipv6"&&m.isIPv4MappedAddress()?m.toIPv4Address():m},p.subnetMatch=function(d,m,y){let g,w,b,S;y==null&&(y="unicast");for(w in m)if(Object.prototype.hasOwnProperty.call(m,w)){for(b=m[w],b[0]&&!(b[0]instanceof Array)&&(b=[b]),g=0;g<b.length;g++)if(S=b[g],d.kind()===S[0].kind()&&d.match.apply(d,S))return w}return y},typeof rb<"u"&&rb.exports?rb.exports=p:r.ipaddr=p})(Vre)});var Hre=R(Cg=>{"use strict";u();var $re=Cg&&Cg.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Cg,"__esModule",{value:!0});var o9e=Lre(),a9e=$re(EC()),c9e=$re(Fre()),qre=Kre(),l9e=["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"],u9e=l9e.map(r=>new o9e.Netmask(r));function f9e(r){for(let e of u9e)if(e.contains(r))return!0;return!1}function zre(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^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(r)||/^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(r)||/^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(r)||/^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(r)||/^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(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}Cg.default=r=>{if((0,qre.isValid)(r)){let e=(0,qre.parse)(r);if(e.kind()==="ipv4")return f9e(e.toNormalizedString());if(e.kind()==="ipv6")return zre(r)}else if((0,c9e.default)(r)&&a9e.default.v6().test(r))return zre(r)}});var nb=R((T3t,Gre)=>{"use strict";u();Gre.exports=Hre().default});var Zre=R((H3t,Xre)=>{"use strict";u();function p9e(r){return r>=55296&&r<=56319}function m9e(r){return r>=56320&&r<=57343}Xre.exports=function(e,t,n){if(typeof t!="string")throw new Error("Input must be string");for(var i=t.length,s=0,o,a,c=0;c<i;c+=1){if(o=t.charCodeAt(c),a=t[c],p9e(o)&&m9e(t.charCodeAt(c+1))&&(c+=1,a+=t[c]),s+=e(a),s===n)return t.slice(0,c+1);if(s>n)return t.slice(0,c-a.length+1)}return t}});var ene=R((G3t,Jre)=>{"use strict";u();function y9e(r){return r>=55296&&r<=56319}function g9e(r){return r>=56320&&r<=57343}Jre.exports=function(e){if(typeof e!="string")throw new Error("Input must be string");for(var t=e.length,n=0,i=null,s=null,o=0;o<t;o++)i=e.charCodeAt(o),g9e(i)?s!=null&&y9e(s)?n+=1:n+=3:i<=127?n+=1:i>=128&&i<=2047?n+=2:i>=2048&&i<=65535&&(n+=3),s=i;return n}});var rne=R((j3t,tne)=>{"use strict";u();var w9e=Zre(),E9e=ene();tne.exports=w9e.bind(null,E9e)});var sne=R((W3t,ine)=>{"use strict";u();var b9e=rne(),v9e=/[\/\?<>\\:\*\|"]/g,_9e=/[\x00-\x1f\x80-\x9f]/g,S9e=/^\.+$/,x9e=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,T9e=/[\. ]+$/;function nne(r,e){if(typeof r!="string")throw new Error("Input must be string");var t=r.replace(v9e,e).replace(_9e,e).replace(S9e,e).replace(x9e,e).replace(T9e,e);return b9e(t,255)}ine.exports=function(r,e){var t=e&&e.replacement||"",n=nne(r,t);return t===""?n:nne(n,"")}});var lne=R((Y3t,cne)=>{u();var i1=ft();eu();sr();var ye=i1.asn1,s1=cne.exports=i1.pkcs7asn1=i1.pkcs7asn1||{};i1.pkcs7=i1.pkcs7||{};i1.pkcs7.asn1=s1;var one={name:"ContentInfo",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:ye.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};s1.contentInfoValidator=one;var ane={name:"EncryptedContentInfo",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:ye.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:ye.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};s1.envelopedDataValidator={name:"EnvelopedData",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(ane)};s1.encryptedDataValidator={name:"EncryptedData",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1,capture:"version"}].concat(ane)};var I9e={name:"SignerInfo",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:ye.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:ye.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:ye.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};s1.signedDataValidator={name:"SignedData",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},one,{name:"SignedData.Certificates",tagClass:ye.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:ye.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SET,capture:"signerInfos",optional:!0,value:[I9e]}]};s1.recipientInfoValidator={name:"RecipientInfo",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:ye.Class.UNIVERSAL,type:ye.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:ye.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:ye.Class.UNIVERSAL,type:ye.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var fne=R((Q3t,une)=>{u();var hd=ft();sr();hd.mgf=hd.mgf||{};var A9e=une.exports=hd.mgf.mgf1=hd.mgf1=hd.mgf1||{};A9e.create=function(r){var e={generate:function(t,n){for(var i=new hd.util.ByteBuffer,s=Math.ceil(n/r.digestLength),o=0;o<s;o++){var a=new hd.util.ByteBuffer;a.putInt32(o),r.start(),r.update(t+a.getBytes()),i.putBuffer(r.digest())}return i.truncate(i.length()-n),i.getBytes()}};return e}});var dne=R((X3t,hne)=>{u();var ab=ft();fne();hne.exports=ab.mgf=ab.mgf||{};ab.mgf.mgf1=ab.mgf1});var mne=R((Z3t,pne)=>{u();var dd=ft();$f();sr();var R9e=pne.exports=dd.pss=dd.pss||{};R9e.create=function(r){arguments.length===3&&(r={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e=r.md,t=r.mgf,n=e.digestLength,i=r.salt||null;typeof i=="string"&&(i=dd.util.createBuffer(i));var s;if("saltLength"in r)s=r.saltLength;else if(i!==null)s=i.length();else throw new Error("Salt length not specified or specific salt not given.");if(i!==null&&i.length()!==s)throw new Error("Given salt length does not match length of given salt.");var o=r.prng||dd.random,a={};return a.encode=function(c,l){var f,h=l-1,p=Math.ceil(h/8),d=c.digest().getBytes();if(p<n+s+2)throw new Error("Message is too long to encrypt.");var m;i===null?m=o.getBytesSync(s):m=i.bytes();var y=new dd.util.ByteBuffer;y.fillWithByte(0,8),y.putBytes(d),y.putBytes(m),e.start(),e.update(y.getBytes());var g=e.digest().getBytes(),w=new dd.util.ByteBuffer;w.fillWithByte(0,p-s-n-2),w.putByte(1),w.putBytes(m);var b=w.getBytes(),S=p-n-1,_=t.generate(g,S),I="";for(f=0;f<S;f++)I+=String.fromCharCode(b.charCodeAt(f)^_.charCodeAt(f));var T=65280>>8*p-h&255;return I=String.fromCharCode(I.charCodeAt(0)&~T)+I.substr(1),I+g+String.fromCharCode(188)},a.verify=function(c,l,f){var h,p=f-1,d=Math.ceil(p/8);if(l=l.substr(-d),d<n+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(l.charCodeAt(d-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var m=d-n-1,y=l.substr(0,m),g=l.substr(m,n),w=65280>>8*d-p&255;if((y.charCodeAt(0)&w)!==0)throw new Error("Bits beyond keysize not zero as expected.");var b=t.generate(g,m),S="";for(h=0;h<m;h++)S+=String.fromCharCode(y.charCodeAt(h)^b.charCodeAt(h));S=String.fromCharCode(S.charCodeAt(0)&~w)+S.substr(1);var _=d-n-s-2;for(h=0;h<_;h++)if(S.charCodeAt(h)!==0)throw new Error("Leftmost octets not zero as expected");if(S.charCodeAt(_)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var I=S.substr(-s),T=new dd.util.ByteBuffer;T.fillWithByte(0,8),T.putBytes(c),T.putBytes(I),e.start(),e.update(T.getBytes());var x=e.digest().getBytes();return g===x},a}});var SC=R((J3t,bne)=>{u();var Ve=ft();vp();eu();gw();tu();dne();wp();vw();mne();Rm();sr();var v=Ve.asn1,oe=bne.exports=Ve.pki=Ve.pki||{},Pt=oe.oids,qr={};qr.CN=Pt.commonName;qr.commonName="CN";qr.C=Pt.countryName;qr.countryName="C";qr.L=Pt.localityName;qr.localityName="L";qr.ST=Pt.stateOrProvinceName;qr.stateOrProvinceName="ST";qr.O=Pt.organizationName;qr.organizationName="O";qr.OU=Pt.organizationalUnitName;qr.organizationalUnitName="OU";qr.E=Pt.emailAddress;qr.emailAddress="E";var gne=Ve.pki.rsa.publicKeyValidator,C9e={name:"Certificate",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:v.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:v.Class.UNIVERSAL,type:v.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:v.Class.UNIVERSAL,type:v.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:v.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:v.Class.UNIVERSAL,type:v.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:v.Class.UNIVERSAL,type:v.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:v.Class.UNIVERSAL,type:v.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:v.Class.UNIVERSAL,type:v.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},gne,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:v.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:v.Class.UNIVERSAL,type:v.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:v.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:v.Class.UNIVERSAL,type:v.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:v.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:v.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:v.Class.UNIVERSAL,type:v.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},P9e={name:"rsapss",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:v.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:v.Class.UNIVERSAL,type:v.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:v.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:v.Class.UNIVERSAL,type:v.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:v.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:v.Class.UNIVERSAL,type:v.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:v.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:v.Class.UNIVERSAL,type:v.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},D9e={name:"CertificationRequestInfo",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:v.Class.UNIVERSAL,type:v.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},gne,{name:"CertificationRequestInfo.attributes",tagClass:v.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:v.Class.UNIVERSAL,type:v.Type.SET,constructed:!0}]}]}]},O9e={name:"CertificationRequest",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[D9e,{name:"CertificationRequest.signatureAlgorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:v.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:v.Class.UNIVERSAL,type:v.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};oe.RDNAttributesAsArray=function(r,e){for(var t=[],n,i,s,o=0;o<r.value.length;++o){n=r.value[o];for(var a=0;a<n.value.length;++a)s={},i=n.value[a],s.type=v.derToOid(i.value[0].value),s.value=i.value[1].value,s.valueTagClass=i.value[1].type,s.type in Pt&&(s.name=Pt[s.type],s.name in qr&&(s.shortName=qr[s.name])),e&&(e.update(s.type),e.update(s.value)),t.push(s)}return t};oe.CRIAttributesAsArray=function(r){for(var e=[],t=0;t<r.length;++t)for(var n=r[t],i=v.derToOid(n.value[0].value),s=n.value[1].value,o=0;o<s.length;++o){var a={};if(a.type=i,a.value=s[o].value,a.valueTagClass=s[o].type,a.type in Pt&&(a.name=Pt[a.type],a.name in qr&&(a.shortName=qr[a.name])),a.type===Pt.extensionRequest){a.extensions=[];for(var c=0;c<a.value.length;++c)a.extensions.push(oe.certificateExtensionFromAsn1(a.value[c]))}e.push(a)}return e};function df(r,e){typeof e=="string"&&(e={shortName:e});for(var t=null,n,i=0;t===null&&i<r.attributes.length;++i)n=r.attributes[i],(e.type&&e.type===n.type||e.name&&e.name===n.name||e.shortName&&e.shortName===n.shortName)&&(t=n);return t}var cb=function(r,e,t){var n={};if(r!==Pt["RSASSA-PSS"])return n;t&&(n={hash:{algorithmOid:Pt.sha1},mgf:{algorithmOid:Pt.mgf1,hash:{algorithmOid:Pt.sha1}},saltLength:20});var i={},s=[];if(!v.validate(e,P9e,i,s)){var o=new Error("Cannot read RSASSA-PSS parameter block.");throw o.errors=s,o}return i.hashOid!==void 0&&(n.hash=n.hash||{},n.hash.algorithmOid=v.derToOid(i.hashOid)),i.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=v.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=v.derToOid(i.maskGenHashOid)),i.saltLength!==void 0&&(n.saltLength=i.saltLength.charCodeAt(0)),n},lb=function(r){switch(Pt[r.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return Ve.md.sha1.create();case"md5WithRSAEncryption":return Ve.md.md5.create();case"sha256WithRSAEncryption":return Ve.md.sha256.create();case"sha384WithRSAEncryption":return Ve.md.sha384.create();case"sha512WithRSAEncryption":return Ve.md.sha512.create();case"RSASSA-PSS":return Ve.md.sha256.create();default:var e=new Error("Could not compute "+r.type+" digest. Unknown signature OID.");throw e.signatureOid=r.signatureOid,e}},wne=function(r){var e=r.certificate,t;switch(e.signatureOid){case Pt.sha1WithRSAEncryption:case Pt.sha1WithRSASignature:break;case Pt["RSASSA-PSS"]:var n,i;if(n=Pt[e.signatureParameters.mgf.hash.algorithmOid],n===void 0||Ve.md[n]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=e.signatureParameters.mgf.hash.algorithmOid,s.name=n,s}if(i=Pt[e.signatureParameters.mgf.algorithmOid],i===void 0||Ve.mgf[i]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=e.signatureParameters.mgf.algorithmOid,s.name=i,s}if(i=Ve.mgf[i].create(Ve.md[n].create()),n=Pt[e.signatureParameters.hash.algorithmOid],n===void 0||Ve.md[n]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=e.signatureParameters.hash.algorithmOid,s.name=n,s}t=Ve.pss.create(Ve.md[n].create(),i,e.signatureParameters.saltLength);break}return e.publicKey.verify(r.md.digest().getBytes(),r.signature,t)};oe.certificateFromPem=function(r,e,t){var n=Ve.pem.decode(r)[0];if(n.type!=="CERTIFICATE"&&n.type!=="X509 CERTIFICATE"&&n.type!=="TRUSTED CERTIFICATE"){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=v.fromDer(n.body,t);return oe.certificateFromAsn1(s,e)};oe.certificateToPem=function(r,e){var t={type:"CERTIFICATE",body:v.toDer(oe.certificateToAsn1(r)).getBytes()};return Ve.pem.encode(t,{maxline:e})};oe.publicKeyFromPem=function(r){var e=Ve.pem.decode(r)[0];if(e.type!=="PUBLIC KEY"&&e.type!=="RSA PUBLIC KEY"){var t=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw t.headerType=e.type,t}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=v.fromDer(e.body);return oe.publicKeyFromAsn1(n)};oe.publicKeyToPem=function(r,e){var t={type:"PUBLIC KEY",body:v.toDer(oe.publicKeyToAsn1(r)).getBytes()};return Ve.pem.encode(t,{maxline:e})};oe.publicKeyToRSAPublicKeyPem=function(r,e){var t={type:"RSA PUBLIC KEY",body:v.toDer(oe.publicKeyToRSAPublicKey(r)).getBytes()};return Ve.pem.encode(t,{maxline:e})};oe.getPublicKeyFingerprint=function(r,e){e=e||{};var t=e.md||Ve.md.sha1.create(),n=e.type||"RSAPublicKey",i;switch(n){case"RSAPublicKey":i=v.toDer(oe.publicKeyToRSAPublicKey(r)).getBytes();break;case"SubjectPublicKeyInfo":i=v.toDer(oe.publicKeyToAsn1(r)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+e.type+'".')}t.start(),t.update(i);var s=t.digest();if(e.encoding==="hex"){var o=s.toHex();return e.delimiter?o.match(/.{2}/g).join(e.delimiter):o}else{if(e.encoding==="binary")return s.getBytes();if(e.encoding)throw new Error('Unknown encoding "'+e.encoding+'".')}return s};oe.certificationRequestFromPem=function(r,e,t){var n=Ve.pem.decode(r)[0];if(n.type!=="CERTIFICATE REQUEST"){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=v.fromDer(n.body,t);return oe.certificationRequestFromAsn1(s,e)};oe.certificationRequestToPem=function(r,e){var t={type:"CERTIFICATE REQUEST",body:v.toDer(oe.certificationRequestToAsn1(r)).getBytes()};return Ve.pem.encode(t,{maxline:e})};oe.createCertificate=function(){var r={};return r.version=2,r.serialNumber="00",r.signatureOid=null,r.signature=null,r.siginfo={},r.siginfo.algorithmOid=null,r.validity={},r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.issuer={},r.issuer.getField=function(e){return df(r.issuer,e)},r.issuer.addField=function(e){Zs([e]),r.issuer.attributes.push(e)},r.issuer.attributes=[],r.issuer.hash=null,r.subject={},r.subject.getField=function(e){return df(r.subject,e)},r.subject.addField=function(e){Zs([e]),r.subject.attributes.push(e)},r.subject.attributes=[],r.subject.hash=null,r.extensions=[],r.publicKey=null,r.md=null,r.setSubject=function(e,t){Zs(e),r.subject.attributes=e,delete r.subject.uniqueId,t&&(r.subject.uniqueId=t),r.subject.hash=null},r.setIssuer=function(e,t){Zs(e),r.issuer.attributes=e,delete r.issuer.uniqueId,t&&(r.issuer.uniqueId=t),r.issuer.hash=null},r.setExtensions=function(e){for(var t=0;t<e.length;++t)Ene(e[t],{cert:r});r.extensions=e},r.getExtension=function(e){typeof e=="string"&&(e={name:e});for(var t=null,n,i=0;t===null&&i<r.extensions.length;++i)n=r.extensions[i],(e.id&&n.id===e.id||e.name&&n.name===e.name)&&(t=n);return t},r.sign=function(e,t){r.md=t||Ve.md.sha1.create();var n=Pt[r.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=r.md.algorithm,i}r.signatureOid=r.siginfo.algorithmOid=n,r.tbsCertificate=oe.getTBSCertificate(r);var s=v.toDer(r.tbsCertificate);r.md.update(s.getBytes()),r.signature=e.sign(r.md)},r.verify=function(e){var t=!1;if(!r.issued(e)){var n=e.issuer,i=r.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=i.attributes,s.actualIssuer=n.attributes,s}var o=e.md;if(o===null){o=lb({signatureOid:e.signatureOid,type:"certificate"});var a=e.tbsCertificate||oe.getTBSCertificate(e),c=v.toDer(a);o.update(c.getBytes())}return o!==null&&(t=wne({certificate:r,md:o,signature:e.signature})),t},r.isIssuer=function(e){var t=!1,n=r.issuer,i=e.subject;if(n.hash&&i.hash)t=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){t=!0;for(var s,o,a=0;t&&a<n.attributes.length;++a)s=n.attributes[a],o=i.attributes[a],(s.type!==o.type||s.value!==o.value)&&(t=!1)}return t},r.issued=function(e){return e.isIssuer(r)},r.generateSubjectKeyIdentifier=function(){return oe.getPublicKeyFingerprint(r.publicKey,{type:"RSAPublicKey"})},r.verifySubjectKeyIdentifier=function(){for(var e=Pt.subjectKeyIdentifier,t=0;t<r.extensions.length;++t){var n=r.extensions[t];if(n.id===e){var i=r.generateSubjectKeyIdentifier().getBytes();return Ve.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},r};oe.certificateFromAsn1=function(r,e){var t={},n=[];if(!v.validate(r,C9e,t,n)){var i=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw i.errors=n,i}var s=v.derToOid(t.publicKeyOid);if(s!==oe.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=oe.createCertificate();o.version=t.certVersion?t.certVersion.charCodeAt(0):0;var a=Ve.util.createBuffer(t.certSerialNumber);o.serialNumber=a.toHex(),o.signatureOid=Ve.asn1.derToOid(t.certSignatureOid),o.signatureParameters=cb(o.signatureOid,t.certSignatureParams,!0),o.siginfo.algorithmOid=Ve.asn1.derToOid(t.certinfoSignatureOid),o.siginfo.parameters=cb(o.siginfo.algorithmOid,t.certinfoSignatureParams,!1),o.signature=t.certSignature;var c=[];if(t.certValidity1UTCTime!==void 0&&c.push(v.utcTimeToDate(t.certValidity1UTCTime)),t.certValidity2GeneralizedTime!==void 0&&c.push(v.generalizedTimeToDate(t.certValidity2GeneralizedTime)),t.certValidity3UTCTime!==void 0&&c.push(v.utcTimeToDate(t.certValidity3UTCTime)),t.certValidity4GeneralizedTime!==void 0&&c.push(v.generalizedTimeToDate(t.certValidity4GeneralizedTime)),c.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(o.validity.notBefore=c[0],o.validity.notAfter=c[1],o.tbsCertificate=t.tbsCertificate,e){o.md=lb({signatureOid:o.signatureOid,type:"certificate"});var l=v.toDer(o.tbsCertificate);o.md.update(l.getBytes())}var f=Ve.md.sha1.create(),h=v.toDer(t.certIssuer);f.update(h.getBytes()),o.issuer.getField=function(m){return df(o.issuer,m)},o.issuer.addField=function(m){Zs([m]),o.issuer.attributes.push(m)},o.issuer.attributes=oe.RDNAttributesAsArray(t.certIssuer),t.certIssuerUniqueId&&(o.issuer.uniqueId=t.certIssuerUniqueId),o.issuer.hash=f.digest().toHex();var p=Ve.md.sha1.create(),d=v.toDer(t.certSubject);return p.update(d.getBytes()),o.subject.getField=function(m){return df(o.subject,m)},o.subject.addField=function(m){Zs([m]),o.subject.attributes.push(m)},o.subject.attributes=oe.RDNAttributesAsArray(t.certSubject),t.certSubjectUniqueId&&(o.subject.uniqueId=t.certSubjectUniqueId),o.subject.hash=p.digest().toHex(),t.certExtensions?o.extensions=oe.certificateExtensionsFromAsn1(t.certExtensions):o.extensions=[],o.publicKey=oe.publicKeyFromAsn1(t.subjectPublicKeyInfo),o};oe.certificateExtensionsFromAsn1=function(r){for(var e=[],t=0;t<r.value.length;++t)for(var n=r.value[t],i=0;i<n.value.length;++i)e.push(oe.certificateExtensionFromAsn1(n.value[i]));return e};oe.certificateExtensionFromAsn1=function(r){var e={};if(e.id=v.derToOid(r.value[0].value),e.critical=!1,r.value[1].type===v.Type.BOOLEAN?(e.critical=r.value[1].value.charCodeAt(0)!==0,e.value=r.value[2].value):e.value=r.value[1].value,e.id in Pt){if(e.name=Pt[e.id],e.name==="keyUsage"){var t=v.fromDer(e.value),n=0,i=0;t.value.length>1&&(n=t.value.charCodeAt(1),i=t.value.length>2?t.value.charCodeAt(2):0),e.digitalSignature=(n&128)===128,e.nonRepudiation=(n&64)===64,e.keyEncipherment=(n&32)===32,e.dataEncipherment=(n&16)===16,e.keyAgreement=(n&8)===8,e.keyCertSign=(n&4)===4,e.cRLSign=(n&2)===2,e.encipherOnly=(n&1)===1,e.decipherOnly=(i&128)===128}else if(e.name==="basicConstraints"){var t=v.fromDer(e.value);t.value.length>0&&t.value[0].type===v.Type.BOOLEAN?e.cA=t.value[0].value.charCodeAt(0)!==0:e.cA=!1;var s=null;t.value.length>0&&t.value[0].type===v.Type.INTEGER?s=t.value[0].value:t.value.length>1&&(s=t.value[1].value),s!==null&&(e.pathLenConstraint=v.derToInteger(s))}else if(e.name==="extKeyUsage")for(var t=v.fromDer(e.value),o=0;o<t.value.length;++o){var a=v.derToOid(t.value[o].value);a in Pt?e[Pt[a]]=!0:e[a]=!0}else if(e.name==="nsCertType"){var t=v.fromDer(e.value),n=0;t.value.length>1&&(n=t.value.charCodeAt(1)),e.client=(n&128)===128,e.server=(n&64)===64,e.email=(n&32)===32,e.objsign=(n&16)===16,e.reserved=(n&8)===8,e.sslCA=(n&4)===4,e.emailCA=(n&2)===2,e.objCA=(n&1)===1}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.altNames=[];for(var c,t=v.fromDer(e.value),l=0;l<t.value.length;++l){c=t.value[l];var f={type:c.type,value:c.value};switch(e.altNames.push(f),c.type){case 1:case 2:case 6:break;case 7:f.ip=Ve.util.bytesToIP(c.value);break;case 8:f.oid=v.derToOid(c.value);break;default:}}}else if(e.name==="subjectKeyIdentifier"){var t=v.fromDer(e.value);e.subjectKeyIdentifier=Ve.util.bytesToHex(t.value)}}return e};oe.certificationRequestFromAsn1=function(r,e){var t={},n=[];if(!v.validate(r,O9e,t,n)){var i=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw i.errors=n,i}var s=v.derToOid(t.publicKeyOid);if(s!==oe.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=oe.createCertificationRequest();if(o.version=t.csrVersion?t.csrVersion.charCodeAt(0):0,o.signatureOid=Ve.asn1.derToOid(t.csrSignatureOid),o.signatureParameters=cb(o.signatureOid,t.csrSignatureParams,!0),o.siginfo.algorithmOid=Ve.asn1.derToOid(t.csrSignatureOid),o.siginfo.parameters=cb(o.siginfo.algorithmOid,t.csrSignatureParams,!1),o.signature=t.csrSignature,o.certificationRequestInfo=t.certificationRequestInfo,e){o.md=lb({signatureOid:o.signatureOid,type:"certification request"});var a=v.toDer(o.certificationRequestInfo);o.md.update(a.getBytes())}var c=Ve.md.sha1.create();return o.subject.getField=function(l){return df(o.subject,l)},o.subject.addField=function(l){Zs([l]),o.subject.attributes.push(l)},o.subject.attributes=oe.RDNAttributesAsArray(t.certificationRequestInfoSubject,c),o.subject.hash=c.digest().toHex(),o.publicKey=oe.publicKeyFromAsn1(t.subjectPublicKeyInfo),o.getAttribute=function(l){return df(o,l)},o.addAttribute=function(l){Zs([l]),o.attributes.push(l)},o.attributes=oe.CRIAttributesAsArray(t.certificationRequestInfoAttributes||[]),o};oe.createCertificationRequest=function(){var r={};return r.version=0,r.signatureOid=null,r.signature=null,r.siginfo={},r.siginfo.algorithmOid=null,r.subject={},r.subject.getField=function(e){return df(r.subject,e)},r.subject.addField=function(e){Zs([e]),r.subject.attributes.push(e)},r.subject.attributes=[],r.subject.hash=null,r.publicKey=null,r.attributes=[],r.getAttribute=function(e){return df(r,e)},r.addAttribute=function(e){Zs([e]),r.attributes.push(e)},r.md=null,r.setSubject=function(e){Zs(e),r.subject.attributes=e,r.subject.hash=null},r.setAttributes=function(e){Zs(e),r.attributes=e},r.sign=function(e,t){r.md=t||Ve.md.sha1.create();var n=Pt[r.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=r.md.algorithm,i}r.signatureOid=r.siginfo.algorithmOid=n,r.certificationRequestInfo=oe.getCertificationRequestInfo(r);var s=v.toDer(r.certificationRequestInfo);r.md.update(s.getBytes()),r.signature=e.sign(r.md)},r.verify=function(){var e=!1,t=r.md;if(t===null){t=lb({signatureOid:r.signatureOid,type:"certification request"});var n=r.certificationRequestInfo||oe.getCertificationRequestInfo(r),i=v.toDer(n);t.update(i.getBytes())}return t!==null&&(e=wne({certificate:r,md:t,signature:r.signature})),e},r};function o1(r){for(var e=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]),t,n,i=r.attributes,s=0;s<i.length;++s){t=i[s];var o=t.value,a=v.Type.PRINTABLESTRING;"valueTagClass"in t&&(a=t.valueTagClass,a===v.Type.UTF8&&(o=Ve.util.encodeUtf8(o))),n=v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),v.create(v.Class.UNIVERSAL,a,!1,o)])]),e.value.push(n)}return e}function Zs(r){for(var e,t=0;t<r.length;++t){if(e=r[t],typeof e.name>"u"&&(e.type&&e.type in oe.oids?e.name=oe.oids[e.type]:e.shortName&&e.shortName in qr&&(e.name=oe.oids[qr[e.shortName]])),typeof e.type>"u")if(e.name&&e.name in oe.oids)e.type=oe.oids[e.name];else{var n=new Error("Attribute type not specified.");throw n.attribute=e,n}if(typeof e.shortName>"u"&&e.name&&e.name in qr&&(e.shortName=qr[e.name]),e.type===Pt.extensionRequest&&(e.valueConstructed=!0,e.valueTagClass=v.Type.SEQUENCE,!e.value&&e.extensions)){e.value=[];for(var i=0;i<e.extensions.length;++i)e.value.push(oe.certificateExtensionToAsn1(Ene(e.extensions[i])))}if(typeof e.value>"u"){var n=new Error("Attribute value not specified.");throw n.attribute=e,n}}}function Ene(r,e){if(e=e||{},typeof r.name>"u"&&r.id&&r.id in oe.oids&&(r.name=oe.oids[r.id]),typeof r.id>"u")if(r.name&&r.name in oe.oids)r.id=oe.oids[r.name];else{var t=new Error("Extension ID not specified.");throw t.extension=r,t}if(typeof r.value<"u")return r;if(r.name==="keyUsage"){var n=0,i=0,s=0;r.digitalSignature&&(i|=128,n=7),r.nonRepudiation&&(i|=64,n=6),r.keyEncipherment&&(i|=32,n=5),r.dataEncipherment&&(i|=16,n=4),r.keyAgreement&&(i|=8,n=3),r.keyCertSign&&(i|=4,n=2),r.cRLSign&&(i|=2,n=1),r.encipherOnly&&(i|=1,n=0),r.decipherOnly&&(s|=128,n=7);var o=String.fromCharCode(n);s!==0?o+=String.fromCharCode(i)+String.fromCharCode(s):i!==0&&(o+=String.fromCharCode(i)),r.value=v.create(v.Class.UNIVERSAL,v.Type.BITSTRING,!1,o)}else if(r.name==="basicConstraints")r.value=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]),r.cA&&r.value.value.push(v.create(v.Class.UNIVERSAL,v.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in r&&r.value.value.push(v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(r.pathLenConstraint).getBytes()));else if(r.name==="extKeyUsage"){r.value=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]);var a=r.value.value;for(var c in r)r[c]===!0&&(c in Pt?a.push(v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(Pt[c]).getBytes())):c.indexOf(".")!==-1&&a.push(v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(c).getBytes())))}else if(r.name==="nsCertType"){var n=0,i=0;r.client&&(i|=128,n=7),r.server&&(i|=64,n=6),r.email&&(i|=32,n=5),r.objsign&&(i|=16,n=4),r.reserved&&(i|=8,n=3),r.sslCA&&(i|=4,n=2),r.emailCA&&(i|=2,n=1),r.objCA&&(i|=1,n=0);var o=String.fromCharCode(n);i!==0&&(o+=String.fromCharCode(i)),r.value=v.create(v.Class.UNIVERSAL,v.Type.BITSTRING,!1,o)}else if(r.name==="subjectAltName"||r.name==="issuerAltName"){r.value=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]);for(var l,f=0;f<r.altNames.length;++f){l=r.altNames[f];var o=l.value;if(l.type===7&&l.ip){if(o=Ve.util.bytesFromIP(l.ip),o===null){var t=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw t.extension=r,t}}else l.type===8&&(l.oid?o=v.oidToDer(v.oidToDer(l.oid)):o=v.oidToDer(o));r.value.value.push(v.create(v.Class.CONTEXT_SPECIFIC,l.type,!1,o))}}else if(r.name==="nsComment"&&e.cert){if(!/^[\x00-\x7F]*$/.test(r.comment)||r.comment.length<1||r.comment.length>128)throw new Error('Invalid "nsComment" content.');r.value=v.create(v.Class.UNIVERSAL,v.Type.IA5STRING,!1,r.comment)}else if(r.name==="subjectKeyIdentifier"&&e.cert){var h=e.cert.generateSubjectKeyIdentifier();r.subjectKeyIdentifier=h.toHex(),r.value=v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,h.getBytes())}else if(r.name==="authorityKeyIdentifier"&&e.cert){r.value=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]);var a=r.value.value;if(r.keyIdentifier){var p=r.keyIdentifier===!0?e.cert.generateSubjectKeyIdentifier().getBytes():r.keyIdentifier;a.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!1,p))}if(r.authorityCertIssuer){var d=[v.create(v.Class.CONTEXT_SPECIFIC,4,!0,[o1(r.authorityCertIssuer===!0?e.cert.issuer:r.authorityCertIssuer)])];a.push(v.create(v.Class.CONTEXT_SPECIFIC,1,!0,d))}if(r.serialNumber){var m=Ve.util.hexToBytes(r.serialNumber===!0?e.cert.serialNumber:r.serialNumber);a.push(v.create(v.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if(r.name==="cRLDistributionPoints"){r.value=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]);for(var a=r.value.value,y=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]),g=v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[]),l,f=0;f<r.altNames.length;++f){l=r.altNames[f];var o=l.value;if(l.type===7&&l.ip){if(o=Ve.util.bytesFromIP(l.ip),o===null){var t=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw t.extension=r,t}}else l.type===8&&(l.oid?o=v.oidToDer(v.oidToDer(l.oid)):o=v.oidToDer(o));g.value.push(v.create(v.Class.CONTEXT_SPECIFIC,l.type,!1,o))}y.value.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[g])),a.push(y)}if(typeof r.value>"u"){var t=new Error("Extension value not specified.");throw t.extension=r,t}return r}function _C(r,e){switch(r){case Pt["RSASSA-PSS"]:var t=[];return e.hash.algorithmOid!==void 0&&t.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(e.hash.algorithmOid).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")])])),e.mgf.algorithmOid!==void 0&&t.push(v.create(v.Class.CONTEXT_SPECIFIC,1,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(e.mgf.algorithmOid).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(e.mgf.hash.algorithmOid).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")])])])),e.saltLength!==void 0&&t.push(v.create(v.Class.CONTEXT_SPECIFIC,2,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(e.saltLength).getBytes())])),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,t);default:return v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")}}function k9e(r){var e=v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[]);if(r.attributes.length===0)return e;for(var t=r.attributes,n=0;n<t.length;++n){var i=t[n],s=i.value,o=v.Type.UTF8;"valueTagClass"in i&&(o=i.valueTagClass),o===v.Type.UTF8&&(s=Ve.util.encodeUtf8(s));var a=!1;"valueConstructed"in i&&(a=i.valueConstructed);var c=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(i.type).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[v.create(v.Class.UNIVERSAL,o,a,s)])]);e.value.push(c)}return e}var N9e=new Date("1950-01-01T00:00:00Z"),L9e=new Date("2050-01-01T00:00:00Z");function yne(r){return r>=N9e&&r<L9e?v.create(v.Class.UNIVERSAL,v.Type.UTCTIME,!1,v.dateToUtcTime(r)):v.create(v.Class.UNIVERSAL,v.Type.GENERALIZEDTIME,!1,v.dateToGeneralizedTime(r))}oe.getTBSCertificate=function(r){var e=yne(r.validity.notBefore),t=yne(r.validity.notAfter),n=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(r.version).getBytes())]),v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,Ve.util.hexToBytes(r.serialNumber)),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(r.siginfo.algorithmOid).getBytes()),_C(r.siginfo.algorithmOid,r.siginfo.parameters)]),o1(r.issuer),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[e,t]),o1(r.subject),oe.publicKeyToAsn1(r.publicKey)]);return r.issuer.uniqueId&&n.value.push(v.create(v.Class.CONTEXT_SPECIFIC,1,!0,[v.create(v.Class.UNIVERSAL,v.Type.BITSTRING,!1,String.fromCharCode(0)+r.issuer.uniqueId)])),r.subject.uniqueId&&n.value.push(v.create(v.Class.CONTEXT_SPECIFIC,2,!0,[v.create(v.Class.UNIVERSAL,v.Type.BITSTRING,!1,String.fromCharCode(0)+r.subject.uniqueId)])),r.extensions.length>0&&n.value.push(oe.certificateExtensionsToAsn1(r.extensions)),n};oe.getCertificationRequestInfo=function(r){var e=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(r.version).getBytes()),o1(r.subject),oe.publicKeyToAsn1(r.publicKey),k9e(r)]);return e};oe.distinguishedNameToAsn1=function(r){return o1(r)};oe.certificateToAsn1=function(r){var e=r.tbsCertificate||oe.getTBSCertificate(r);return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[e,v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(r.signatureOid).getBytes()),_C(r.signatureOid,r.signatureParameters)]),v.create(v.Class.UNIVERSAL,v.Type.BITSTRING,!1,String.fromCharCode(0)+r.signature)])};oe.certificateExtensionsToAsn1=function(r){var e=v.create(v.Class.CONTEXT_SPECIFIC,3,!0,[]),t=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]);e.value.push(t);for(var n=0;n<r.length;++n)t.value.push(oe.certificateExtensionToAsn1(r[n]));return e};oe.certificateExtensionToAsn1=function(r){var e=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[]);e.value.push(v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(r.id).getBytes())),r.critical&&e.value.push(v.create(v.Class.UNIVERSAL,v.Type.BOOLEAN,!1,String.fromCharCode(255)));var t=r.value;return typeof r.value!="string"&&(t=v.toDer(t).getBytes()),e.value.push(v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t)),e};oe.certificationRequestToAsn1=function(r){var e=r.certificationRequestInfo||oe.getCertificationRequestInfo(r);return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[e,v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(r.signatureOid).getBytes()),_C(r.signatureOid,r.signatureParameters)]),v.create(v.Class.UNIVERSAL,v.Type.BITSTRING,!1,String.fromCharCode(0)+r.signature)])};oe.createCaStore=function(r){var e={certs:{}};e.getIssuer=function(o){var a=t(o.issuer);return a},e.addCertificate=function(o){if(typeof o=="string"&&(o=Ve.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))if(o.subject.hash in e.certs){var a=e.certs[o.subject.hash];Ve.util.isArray(a)||(a=[a]),a.push(o),e.certs[o.subject.hash]=a}else e.certs[o.subject.hash]=o},e.hasCertificate=function(o){typeof o=="string"&&(o=Ve.pki.certificateFromPem(o));var a=t(o.subject);if(!a)return!1;Ve.util.isArray(a)||(a=[a]);for(var c=v.toDer(oe.certificateToAsn1(o)).getBytes(),l=0;l<a.length;++l){var f=v.toDer(oe.certificateToAsn1(a[l])).getBytes();if(c===f)return!0}return!1},e.listAllCertificates=function(){var o=[];for(var a in e.certs)if(e.certs.hasOwnProperty(a)){var c=e.certs[a];if(!Ve.util.isArray(c))o.push(c);else for(var l=0;l<c.length;++l)o.push(c[l])}return o},e.removeCertificate=function(o){var a;if(typeof o=="string"&&(o=Ve.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))return null;var c=t(o.subject);if(!Ve.util.isArray(c))return a=e.certs[o.subject.hash],delete e.certs[o.subject.hash],a;for(var l=v.toDer(oe.certificateToAsn1(o)).getBytes(),f=0;f<c.length;++f){var h=v.toDer(oe.certificateToAsn1(c[f])).getBytes();l===h&&(a=c[f],c.splice(f,1))}return c.length===0&&delete e.certs[o.subject.hash],a};function t(o){return n(o),e.certs[o.hash]||null}function n(o){if(!o.hash){var a=Ve.md.sha1.create();o.attributes=oe.RDNAttributesAsArray(o1(o),a),o.hash=a.digest().toHex()}}if(r)for(var i=0;i<r.length;++i){var s=r[i];e.addCertificate(s)}return e};oe.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};oe.verifyCertificateChain=function(r,e,t){typeof t=="function"&&(t={verify:t}),t=t||{},e=e.slice(0);var n=e.slice(0),i=t.validityCheckDate;typeof i>"u"&&(i=new Date);var s=!0,o=null,a=0;do{var c=e.shift(),l=null,f=!1;if(i&&(i<c.validity.notBefore||i>c.validity.notAfter)&&(o={message:"Certificate is not valid yet or has expired.",error:oe.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:i}),o===null){if(l=e[0]||r.getIssuer(c),l===null&&c.isIssuer(c)&&(f=!0,l=c),l){var h=l;Ve.util.isArray(h)||(h=[h]);for(var p=!1;!p&&h.length>0;){l=h.shift();try{p=l.verify(c)}catch{}}p||(o={message:"Certificate signature is invalid.",error:oe.certificateError.bad_certificate})}o===null&&(!l||f)&&!r.hasCertificate(c)&&(o={message:"Certificate is not trusted.",error:oe.certificateError.unknown_ca})}if(o===null&&l&&!c.isIssuer(l)&&(o={message:"Certificate issuer is invalid.",error:oe.certificateError.bad_certificate}),o===null)for(var d={keyUsage:!0,basicConstraints:!0},m=0;o===null&&m<c.extensions.length;++m){var y=c.extensions[m];y.critical&&!(y.name in d)&&(o={message:"Certificate has an unsupported critical extension.",error:oe.certificateError.unsupported_certificate})}if(o===null&&(!s||e.length===0&&(!l||f))){var g=c.getExtension("basicConstraints"),w=c.getExtension("keyUsage");if(w!==null&&(!w.keyCertSign||g===null)&&(o={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:oe.certificateError.bad_certificate}),o===null&&g!==null&&!g.cA&&(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:oe.certificateError.bad_certificate}),o===null&&w!==null&&"pathLenConstraint"in g){var b=a-1;b>g.pathLenConstraint&&(o={message:"Certificate basicConstraints pathLenConstraint violated.",error:oe.certificateError.bad_certificate})}}var S=o===null?!0:o.error,_=t.verify?t.verify(S,a,n):S;if(_===!0)o=null;else throw S===!0&&(o={message:"The application rejected the certificate.",error:oe.certificateError.bad_certificate}),(_||_===0)&&(typeof _=="object"&&!Ve.util.isArray(_)?(_.message&&(o.message=_.message),_.error&&(o.error=_.error)):typeof _=="string"&&(o.error=_)),o;s=!1,++a}while(e.length>0);return!0}});var Sne=R((e4t,_ne)=>{u();var he=ft();vp();eu();gw();wp();vw();lne();$f();sr();SC();var O=he.asn1,mi=_ne.exports=he.pkcs7=he.pkcs7||{};mi.messageFromPem=function(r){var e=he.pem.decode(r)[0];if(e.type!=="PKCS7"){var t=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw t.headerType=e.type,t}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=O.fromDer(e.body);return mi.messageFromAsn1(n)};mi.messageToPem=function(r,e){var t={type:"PKCS7",body:O.toDer(r.toAsn1()).getBytes()};return he.pem.encode(t,{maxline:e})};mi.messageFromAsn1=function(r){var e={},t=[];if(!O.validate(r,mi.asn1.contentInfoValidator,e,t)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=t,n}var i=O.derToOid(e.contentType),s;switch(i){case he.pki.oids.envelopedData:s=mi.createEnvelopedData();break;case he.pki.oids.encryptedData:s=mi.createEncryptedData();break;case he.pki.oids.signedData:s=mi.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+i+" is not (yet) supported.")}return s.fromAsn1(e.content.value[0]),s};mi.createSignedData=function(){var r=null;return r={type:he.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(TC(r,n,mi.asn1.signedDataValidator),r.certificates=[],r.crls=[],r.digestAlgorithmIdentifiers=[],r.contentInfo=null,r.signerInfos=[],r.rawCapture.certificates)for(var i=r.rawCapture.certificates.value,s=0;s<i.length;++s)r.certificates.push(he.pki.certificateFromAsn1(i[s]))},toAsn1:function(){r.contentInfo||r.sign();for(var n=[],i=0;i<r.certificates.length;++i)n.push(he.pki.certificateToAsn1(r.certificates[i]));var s=[],o=O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,O.integerToDer(r.version).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SET,!0,r.digestAlgorithmIdentifiers),r.contentInfo])]);return n.length>0&&o.value[0].value.push(O.create(O.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&o.value[0].value.push(O.create(O.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(O.create(O.Class.UNIVERSAL,O.Type.SET,!0,r.signerInfos)),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.type).getBytes()),o])},addSigner:function(n){var i=n.issuer,s=n.serialNumber;if(n.certificate){var o=n.certificate;typeof o=="string"&&(o=he.pki.certificateFromPem(o)),i=o.issuer.attributes,s=o.serialNumber}var a=n.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof a=="string"&&(a=he.pki.privateKeyFromPem(a));var c=n.digestAlgorithm||he.pki.oids.sha1;switch(c){case he.pki.oids.sha1:case he.pki.oids.sha256:case he.pki.oids.sha384:case he.pki.oids.sha512:case he.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+c)}var l=n.authenticatedAttributes||[];if(l.length>0){for(var f=!1,h=!1,p=0;p<l.length;++p){var d=l[p];if(!f&&d.type===he.pki.oids.contentType){if(f=!0,h)break;continue}if(!h&&d.type===he.pki.oids.messageDigest){if(h=!0,f)break;continue}}if(!f||!h)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}r.signers.push({key:a,version:1,issuer:i,serialNumber:s,digestAlgorithm:c,signatureAlgorithm:he.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:l,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof r.content!="object"||r.contentInfo===null)&&(r.contentInfo=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(he.pki.oids.data).getBytes())]),"content"in r)){var i;r.content instanceof he.util.ByteBuffer?i=r.content.bytes():typeof r.content=="string"&&(i=he.util.encodeUtf8(r.content)),n.detached?r.detachedContent=O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,i):r.contentInfo.value.push(O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,i)]))}if(r.signers.length!==0){var s=e();t(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(n){typeof n=="string"&&(n=he.pki.certificateFromPem(n)),r.certificates.push(n)},addCertificateRevokationList:function(n){throw new Error("PKCS#7 CRL support not yet implemented.")}},r;function e(){for(var n={},i=0;i<r.signers.length;++i){var s=r.signers[i],o=s.digestAlgorithm;o in n||(n[o]=he.md[he.pki.oids[o]].create()),s.authenticatedAttributes.length===0?s.md=n[o]:s.md=he.md[he.pki.oids[o]].create()}r.digestAlgorithmIdentifiers=[];for(var o in n)r.digestAlgorithmIdentifiers.push(O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(o).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.NULL,!1,"")]));return n}function t(n){var i;if(r.detachedContent?i=r.detachedContent:(i=r.contentInfo.value[1],i=i.value[0]),!i)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=O.derToOid(r.contentInfo.value[0].value),o=O.toDer(i);o.getByte(),O.getBerValueLength(o),o=o.getBytes();for(var a in n)n[a].start().update(o);for(var c=new Date,l=0;l<r.signers.length;++l){var f=r.signers[l];if(f.authenticatedAttributes.length===0){if(s!==he.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{f.authenticatedAttributesAsn1=O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var h=O.create(O.Class.UNIVERSAL,O.Type.SET,!0,[]),p=0;p<f.authenticatedAttributes.length;++p){var d=f.authenticatedAttributes[p];d.type===he.pki.oids.messageDigest?d.value=n[f.digestAlgorithm].digest():d.type===he.pki.oids.signingTime&&(d.value||(d.value=c)),h.value.push(xC(d)),f.authenticatedAttributesAsn1.value.push(xC(d))}o=O.toDer(h).getBytes(),f.md.start().update(o)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}r.signerInfos=K9e(r.signers)}};mi.createEncryptedData=function(){var r=null;return r={type:he.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:he.pki.oids["aes256-CBC"]},fromAsn1:function(e){TC(r,e,mi.asn1.encryptedDataValidator)},decrypt:function(e){e!==void 0&&(r.encryptedContent.key=e),vne(r)}},r};mi.createEnvelopedData=function(){var r=null;return r={type:he.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:he.pki.oids["aes256-CBC"]},fromAsn1:function(e){var t=TC(r,e,mi.asn1.envelopedDataValidator);r.recipients=U9e(t.recipientInfos.value)},toAsn1:function(){return O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.type).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,O.integerToDer(r.version).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SET,!0,F9e(r.recipients)),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,q9e(r.encryptedContent))])])])},findRecipient:function(e){for(var t=e.issuer.attributes,n=0;n<r.recipients.length;++n){var i=r.recipients[n],s=i.issuer;if(i.serialNumber===e.serialNumber&&s.length===t.length){for(var o=!0,a=0;a<t.length;++a)if(s[a].type!==t[a].type||s[a].value!==t[a].value){o=!1;break}if(o)return i}}return null},decrypt:function(e,t){if(r.encryptedContent.key===void 0&&e!==void 0&&t!==void 0)switch(e.encryptedContent.algorithm){case he.pki.oids.rsaEncryption:case he.pki.oids.desCBC:var n=t.decrypt(e.encryptedContent.content);r.encryptedContent.key=he.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+e.encryptedContent.algorithm)}vne(r)},addRecipient:function(e){r.recipients.push({version:0,issuer:e.issuer.attributes,serialNumber:e.serialNumber,encryptedContent:{algorithm:he.pki.oids.rsaEncryption,key:e.publicKey}})},encrypt:function(e,t){if(r.encryptedContent.content===void 0){t=t||r.encryptedContent.algorithm,e=e||r.encryptedContent.key;var n,i,s;switch(t){case he.pki.oids["aes128-CBC"]:n=16,i=16,s=he.aes.createEncryptionCipher;break;case he.pki.oids["aes192-CBC"]:n=24,i=16,s=he.aes.createEncryptionCipher;break;case he.pki.oids["aes256-CBC"]:n=32,i=16,s=he.aes.createEncryptionCipher;break;case he.pki.oids["des-EDE3-CBC"]:n=24,i=8,s=he.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+t)}if(e===void 0)e=he.util.createBuffer(he.random.getBytes(n));else if(e.length()!=n)throw new Error("Symmetric key has wrong length; got "+e.length()+" bytes, expected "+n+".");r.encryptedContent.algorithm=t,r.encryptedContent.key=e,r.encryptedContent.parameter=he.util.createBuffer(he.random.getBytes(i));var o=s(e);if(o.start(r.encryptedContent.parameter.copy()),o.update(r.content),!o.finish())throw new Error("Symmetric encryption failed.");r.encryptedContent.content=o.output}for(var a=0;a<r.recipients.length;++a){var c=r.recipients[a];if(c.encryptedContent.content===void 0)switch(c.encryptedContent.algorithm){case he.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(r.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}},r};function B9e(r){var e={},t=[];if(!O.validate(r,mi.asn1.recipientInfoValidator,e,t)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=t,n}return{version:e.version.charCodeAt(0),issuer:he.pki.RDNAttributesAsArray(e.issuer),serialNumber:he.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:O.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}}function M9e(r){return O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,O.integerToDer(r.version).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[he.pki.distinguishedNameToAsn1({attributes:r.issuer}),O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,he.util.hexToBytes(r.serialNumber))]),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.encryptedContent.algorithm).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.NULL,!1,"")]),O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,r.encryptedContent.content)])}function U9e(r){for(var e=[],t=0;t<r.length;++t)e.push(B9e(r[t]));return e}function F9e(r){for(var e=[],t=0;t<r.length;++t)e.push(M9e(r[t]));return e}function V9e(r){var e=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,O.integerToDer(r.version).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[he.pki.distinguishedNameToAsn1({attributes:r.issuer}),O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,he.util.hexToBytes(r.serialNumber))]),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.digestAlgorithm).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.NULL,!1,"")])]);if(r.authenticatedAttributesAsn1&&e.value.push(r.authenticatedAttributesAsn1),e.value.push(O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.signatureAlgorithm).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.NULL,!1,"")])),e.value.push(O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,r.signature)),r.unauthenticatedAttributes.length>0){for(var t=O.create(O.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<r.unauthenticatedAttributes.length;++n){var i=r.unauthenticatedAttributes[n];t.values.push(xC(i))}e.value.push(t)}return e}function K9e(r){for(var e=[],t=0;t<r.length;++t)e.push(V9e(r[t]));return e}function xC(r){var e;if(r.type===he.pki.oids.contentType)e=O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.value).getBytes());else if(r.type===he.pki.oids.messageDigest)e=O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,r.value.bytes());else if(r.type===he.pki.oids.signingTime){var t=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=r.value;if(typeof i=="string"){var s=Date.parse(i);isNaN(s)?i.length===13?i=O.utcTimeToDate(i):i=O.generalizedTimeToDate(i):i=new Date(s)}i>=t&&i<n?e=O.create(O.Class.UNIVERSAL,O.Type.UTCTIME,!1,O.dateToUtcTime(i)):e=O.create(O.Class.UNIVERSAL,O.Type.GENERALIZEDTIME,!1,O.dateToGeneralizedTime(i))}return O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.type).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SET,!0,[e])])}function q9e(r){return[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(he.pki.oids.data).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(r.algorithm).getBytes()),r.parameter?O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,r.parameter.getBytes()):void 0]),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,r.content.getBytes())])]}function TC(r,e,t){var n={},i=[];if(!O.validate(e,t,n,i)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var o=O.derToOid(n.contentType);if(o!==he.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(he.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==O.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[c].value}else a=n.encryptedContent;r.encryptedContent={algorithm:O.derToOid(n.encAlgorithm),parameter:he.util.createBuffer(n.encParameter.value),content:he.util.createBuffer(a)}}if(n.content){var a="";if(he.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==O.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[c].value}else a=n.content;r.content=he.util.createBuffer(a)}return r.version=n.version.charCodeAt(0),r.rawCapture=n,n}function vne(r){if(r.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(r.content===void 0){var e;switch(r.encryptedContent.algorithm){case he.pki.oids["aes128-CBC"]:case he.pki.oids["aes192-CBC"]:case he.pki.oids["aes256-CBC"]:e=he.aes.createDecryptionCipher(r.encryptedContent.key);break;case he.pki.oids.desCBC:case he.pki.oids["des-EDE3-CBC"]:e=he.des.createDecryptionCipher(r.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+r.encryptedContent.algorithm)}if(e.start(r.encryptedContent.parameter),e.update(r.encryptedContent.content),!e.finish())throw new Error("Symmetric decryption failed.");r.content=e.output}}});var RC=R((v4t,Pne)=>{"use strict";u();var H9e=async function*(r,e){for await(let t of r)await e(t),yield t};Pne.exports=H9e});var Vne=R((uwt,Fne)=>{"use strict";u();function Z9e(r){if(Array.isArray(r)){for(var e=0,t=Array(r.length);e<r.length;e++)t[e]=r[e];return t}else return Array.from(r)}Fne.exports=function(e){var t=void 0,n=void 0;function i(a){if(!(a instanceof Object))throw new Error('Target "'+a+'" is not an object');n=a}function s(a){Object.keys(a).forEach(function(c){var l=a[c];if(typeof l!="function")throw new Error('Trap "'+c+": "+l+'" is not a function');if(!Reflect[c])throw new Error('Trap "'+c+": "+l+'" is not a valid trap')}),t=a}i(function(){}),e&&i(e),s(Reflect);var o=new Proxy({},{get:function(c,l){return function(){for(var f=arguments.length,h=Array(f),p=0;p<f;p++)h[p]=arguments[p];return t[l].apply(null,[n].concat(Z9e(h.slice(1))))}}});return{setTarget:i,setHandler:s,getTarget:function(){return n},getHandler:function(){return t},proxy:new Proxy(n,o)}}});var Lie=R((O5t,Nie)=>{"use strict";u();Nie.exports=kie;var aSe=Lv(),mf=kie.prototype,cSe=new Date%1e9;function lSe(){return(Math.random()*1e9>>>0)+cSe++}function kie(r){r=r||{},this.id=r.id||lSe(),this.max=r.max||1/0,this.items=r.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(r.lastModified||new Date);for(var e,t,n=this.items.length;n--;)e=this.items[n],t=new Date(e.expires)-new Date,this._lookup[e.key]=e,t>0?this.expire(e.key,t):t<=0&&this.delete(e.key)}mf.has=function(r){return r in this._lookup};mf.get=function(r){if(!this.has(r))return null;var e=this._lookup[r];return e.refresh&&this.expire(r,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};mf.meta=function(r){if(!this.has(r))return null;var e=this._lookup[r];return"meta"in e?e.meta:null};mf.set=function(r,e,t){var n=this._lookup[r],i=this._lookup[r]={key:r,value:e};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++),t&&("ttl"in t&&this.expire(r,t.ttl),"meta"in t&&(i.meta=t.meta),t.refresh&&(i.refresh=t.ttl)),this};mf.delete=function(r){var e=this._lookup[r];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[r],this.size--,this):!1};mf.expire=function(r,e){var t=e||0,n=this._lookup[r];if(!n)return this;if(typeof t=="string"&&(t=aSe(e)),typeof t!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),t),n.expires=Number(new Date)+t,this};mf.clear=function(){for(var r=this.items.length;r--;)this.delete(this.items[r].key);return this};mf.toJSON=function(){for(var r=new Array(this.items.length),e,t=r.length;t--;)e=this.items[t],r[t]={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:r}}});var Gie=R((h8t,Hie)=>{"use strict";u();var ySe=()=>{let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r};Hie.exports=ySe});var Qie=R((p8t,Yie)=>{u();var jie=Px(),Wie=Gie();Yie.exports=class{constructor(){this._buffer=new jie,this._waitingConsumers=new jie}push(e){let{promise:t,resolve:n}=Wie();return this._buffer.push({chunk:e,resolve:n}),this._consume(),t}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){let e=this._waitingConsumers.shift(),t=this._buffer.shift();e.resolve(t.chunk),t.resolve()}}shift(){let{promise:e,resolve:t}=Wie();return this._waitingConsumers.push({resolve:t}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}});var hse=R((hP,fse)=>{u();var Yb=Tf(),tc=Yb.Buffer;function use(r,e){for(var t in r)e[t]=r[t]}tc.from&&tc.alloc&&tc.allocUnsafe&&tc.allocUnsafeSlow?fse.exports=Yb:(use(Yb,hP),hP.Buffer=_d);function _d(r,e,t){return tc(r,e,t)}_d.prototype=Object.create(tc.prototype);use(tc,_d);_d.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return tc(r,e,t)};_d.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=tc(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};_d.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return tc(r)};_d.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return Yb.SlowBuffer(r)}});var dse=R((mEt,pP)=>{"use strict";u();var dP=65536,bSe=4294967295;function vSe(){throw new Error(`Secure random number generation is not supported by this browser.
Use Chrome, Firefox or Internet Explorer 11`)}var _Se=hse().Buffer,Qb=globalThis.crypto||globalThis.msCrypto;Qb&&Qb.getRandomValues?pP.exports=SSe:pP.exports=vSe;function SSe(r,e){if(r>bSe)throw new RangeError("requested too many random bytes");var t=_Se.allocUnsafe(r);if(r>0)if(r>dP)for(var n=0;n<r;n+=dP)Qb.getRandomValues(t.slice(n,n+dP));else Qb.getRandomValues(t);return typeof e=="function"?process.nextTick(function(){e(null,t)}):t}});var yse=R((yEt,mse)=>{"use strict";u();var xSe=dse(),{EventEmitter:TSe}=bn();function pse(r,e){if(r===e)return!0;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;++t)if(r[t]!==e[t])return!1;return!0}function mP(){return{contacts:[],dontSplit:!1,left:null,right:null}}function $g(r,e){if(!(e instanceof Uint8Array))throw new TypeError(r+" is not a Uint8Array")}var d1=class extends TSe{constructor(e={}){super(),this.localNodeId=e.localNodeId||xSe(20),this.numberOfNodesPerKBucket=e.numberOfNodesPerKBucket||20,this.numberOfNodesToPing=e.numberOfNodesToPing||3,this.distance=e.distance||d1.distance,this.arbiter=e.arbiter||d1.arbiter,this.metadata=Object.assign({},e.metadata),$g("option.localNodeId as parameter 1",this.localNodeId),this.root=mP()}static arbiter(e,t){return e.vectorClock>t.vectorClock?e:t}static distance(e,t){let n=0,i=0,s=Math.min(e.length,t.length),o=Math.max(e.length,t.length);for(;i<s;++i)n=n*256+(e[i]^t[i]);for(;i<o;++i)n=n*256+255;return n}add(e){$g("contact.id",(e||{}).id);let t=0,n=this.root;for(;n.contacts===null;)n=this._determineNode(n,e.id,t++);let i=this._indexOf(n,e.id);return i>=0?(this._update(n,i,e),this):n.contacts.length<this.numberOfNodesPerKBucket?(n.contacts.push(e),this.emit("added",e),this):n.dontSplit?(this.emit("ping",n.contacts.slice(0,this.numberOfNodesToPing),e),this):(this._split(n,t),this.add(e))}closest(e,t=1/0){if($g("id",e),!Number.isInteger(t)&&t!==1/0||t<=0)throw new TypeError("n is not positive number");let n=[];for(let i=[this.root],s=0;i.length>0&&n.length<t;){let o=i.pop();if(o.contacts===null){let a=this._determineNode(o,e,s++);i.push(o.left===a?o.right:o.left),i.push(a)}else n=n.concat(o.contacts)}return n.map(i=>[this.distance(i.id,e),i]).sort((i,s)=>i[0]-s[0]).slice(0,t).map(i=>i[1])}count(){let e=0;for(let t=[this.root];t.length>0;){let n=t.pop();n.contacts===null?t.push(n.right,n.left):e+=n.contacts.length}return e}_determineNode(e,t,n){let i=n>>3,s=n%8;return t.length<=i&&s!==0?e.left:t[i]&1<<7-s?e.right:e.left}get(e){$g("id",e);let t=0,n=this.root;for(;n.contacts===null;)n=this._determineNode(n,e,t++);let i=this._indexOf(n,e);return i>=0?n.contacts[i]:null}_indexOf(e,t){for(let n=0;n<e.contacts.length;++n)if(pse(e.contacts[n].id,t))return n;return-1}remove(e){$g("the id as parameter 1",e);let t=0,n=this.root;for(;n.contacts===null;)n=this._determineNode(n,e,t++);let i=this._indexOf(n,e);if(i>=0){let s=n.contacts.splice(i,1)[0];this.emit("removed",s)}return this}_split(e,t){e.left=mP(),e.right=mP();for(let s of e.contacts)this._determineNode(e,s.id,t).contacts.push(s);e.contacts=null;let n=this._determineNode(e,this.localNodeId,t),i=e.left===n?e.right:e.left;i.dontSplit=!0}toArray(){let e=[];for(let t=[this.root];t.length>0;){let n=t.pop();n.contacts===null?t.push(n.right,n.left):e=e.concat(n.contacts)}return e}*toIterable(){for(let e=[this.root];e.length>0;){let t=e.pop();t.contacts===null?e.push(t.right,t.left):yield*t.contacts}}_update(e,t,n){if(!pse(e.contacts[t].id,n.id))throw new Error("wrong index for _update");let i=e.contacts[t],s=this.arbiter(i,n);s===i&&i!==n||(e.contacts.splice(t,1),e.contacts.push(s),this.emit("updated",i,s))}};mse.exports=d1});var Soe=R(P7=>{"use strict";u();Object.defineProperty(P7,"__esModule",{value:!0});var NP=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let t={value:e,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let 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(let t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{let t=Promise.reject(e);t.catch(()=>{}),this.pushQueue.push(t)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let t=this.pushQueue.shift();return t?(this.lowWaterMark!==void 0&&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((n,i)=>{this.pullQueue.push({resolve:n,reject:i})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},C7=class{constructor(e,{highWaterMark:t=100,lowWaterMark:n=1}={}){let i=new NP;i.highWaterMark=t,i.lowWaterMark=n,i.removeCallback=e({push:s=>i.push(s),stop:()=>i.stop(),fail:s=>i.fail(s),on:(s,o)=>{i.eventHandlers[s]=o}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}};P7.EventIterator=C7;P7.default=C7});var xoe=R(o3=>{"use strict";u();Object.defineProperty(o3,"__esModule",{value:!0});var LP=Soe();o3.EventIterator=LP.EventIterator;function HSe(r,e,t){return new LP.EventIterator(({push:n})=>(this.addEventListener(r,n,e),()=>this.removeEventListener(r,n,e)),t)}o3.subscribe=HSe;o3.default=LP.EventIterator});var c3=R((Y_t,Qoe)=>{u();Qoe.exports=class{constructor(e={}){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=typeof e>"u"?1:e}get msDuration(){return this.duration*1e3}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration=typeof e>"u"?0:e}get msBlockDuration(){return this.blockDuration*1e3}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly=typeof e>"u"?!1:Boolean(e)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs=typeof e>"u"?Math.ceil(this.msDuration/this.points):e}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if(typeof e>"u"&&(e="rlflx"),typeof e!="string")throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(e={}){return e&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?`${this.keyPrefix}:${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'!")}}});var Zoe=R((X_t,Xoe)=>{u();Xoe.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){let 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,t*1e3)}addMs(e,t){this._keys[e]=Date.now()+t,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(e){let t=this._keys[e];if(t&&t>=Date.now()){this.collectExpired();let n=Date.now();return t>=n?t-n:0}return 0}delete(e){e?delete this._keys[e]:Object.keys(this._keys).forEach(t=>{delete this._keys[t]})}}});var eae=R((Z_t,Joe)=>{u();var rxe=Zoe();Joe.exports=rxe});var ws=R((e9t,tae)=>{u();tae.exports=class{constructor(e,t,n,i){this.remainingPoints=typeof e>"u"?0:e,this.msBeforeNext=typeof t>"u"?0:t,this.consumedPoints=typeof n>"u"?0:n,this.isFirstInDuration=typeof i>"u"?!1:i}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()}}});var _1=R((r9t,nae)=>{u();var zP=c3(),nxe=eae(),rae=ws();nae.exports=class extends zP{constructor(e={}){super(e),this.inmemoryBlockOnConsumed=e.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=e.inmemoryBlockDuration,this.insuranceLimiter=e.insuranceLimiter,this._inmemoryBlockedKeys=new nxe}get client(){return this._client}set client(e){if(typeof e>"u")throw new Error("storeClient is not set");this._client=e}_afterConsume(e,t,n,i,s,o={}){let a=this._getRateLimiterRes(n,i,s);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&a.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(n,a.msBeforeNext),a.consumedPoints>this.points?t(a):e(a);if(a.consumedPoints>this.points){let c=Promise.resolve();this.blockDuration>0&&a.consumedPoints<=this.points+i&&(a.msBeforeNext=this.msBlockDuration,c=this._block(n,a.consumedPoints,this.msBlockDuration,o)),this.inmemoryBlockOnConsumed>0&&a.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(n,this.inmemoryBlockDuration),a.msBeforeNext=this.msInmemoryBlockDuration),c.then(()=>{t(a)}).catch(l=>{t(l)})}else if(this.execEvenly&&a.msBeforeNext>0&&!a.isFirstInDuration){let c=Math.ceil(a.msBeforeNext/(a.remainingPoints+2));c<this.execEvenlyMinDelayMs&&(c=a.consumedPoints*this.execEvenlyMinDelayMs),setTimeout(e,c,a)}else e(a)}_handleError(e,t,n,i,s,o=!1,a={}){this.insuranceLimiter instanceof zP?this.insuranceLimiter[t](s,o,a).then(c=>{n(c)}).catch(c=>{i(c)}):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&&this.inmemoryBlockOnConsumed===0)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return this._inmemoryBlockDuration*1e3}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(e){if(typeof e<"u"&&!(e instanceof zP))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,n={}){let i=t*1e3;return this._block(this.getKey(e),this.points+1,i,n)}set(e,t,n,i={}){let s=(n>=0?n:this.duration)*1e3;return this._block(this.getKey(e),t,s,i)}consume(e,t=1,n={}){return new Promise((i,s)=>{let o=this.getKey(e),a=this.getInmemoryBlockMsBeforeExpire(o);if(a>0)return s(new rae(0,a));this._upsert(o,t,this._getKeySecDuration(n)*1e3,!1,n).then(c=>{this._afterConsume(i,s,o,t,c)}).catch(c=>{this._handleError(c,"consume",i,s,e,t,n)})})}penalty(e,t=1,n={}){let i=this.getKey(e);return new Promise((s,o)=>{this._upsert(i,t,this._getKeySecDuration(n)*1e3,!1,n).then(a=>{s(this._getRateLimiterRes(i,t,a))}).catch(a=>{this._handleError(a,"penalty",s,o,e,t,n)})})}reward(e,t=1,n={}){let i=this.getKey(e);return new Promise((s,o)=>{this._upsert(i,-t,this._getKeySecDuration(n)*1e3,!1,n).then(a=>{s(this._getRateLimiterRes(i,-t,a))}).catch(a=>{this._handleError(a,"reward",s,o,e,t,n)})})}get(e,t={}){let n=this.getKey(e);return new Promise((i,s)=>{this._get(n,t).then(o=>{i(o===null||typeof o>"u"?null:this._getRateLimiterRes(n,0,o))}).catch(o=>{this._handleError(o,"get",i,s,e,t)})})}delete(e,t={}){let n=this.getKey(e);return new Promise((i,s)=>{this._delete(n,t).then(o=>{this._inmemoryBlockedKeys.delete(n),i(o)}).catch(o=>{this._handleError(o,"delete",i,s,e,t)})})}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(e,t,n){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(e,t,n,i={}){return new Promise((s,o)=>{this._upsert(e,t,n,!0,i).then(()=>{s(new rae(0,n>0?n:-1,t))}).catch(a=>{this._handleError(a,"block",s,o,this.parseKey(e),n/1e3,i)})})}_get(e,t={}){throw new Error("You have to implement the method '_get'!")}_delete(e,t={}){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}});var oae=R((n9t,sae)=>{u();var ixe=_1(),sxe=ws(),iae="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} ",$P=class extends ixe{constructor(e){super(e),e.redis?this.client=e.redis:this.client=e.storeClient,typeof this.client.defineCommand=="function"&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:iae})}_getRateLimiterRes(e,t,n){let[i,s]=n;Array.isArray(i)&&([,i]=i,[,s]=s);let o=new sxe;return o.consumedPoints=parseInt(i),o.isFirstInDuration=o.consumedPoints===t,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=s,o}_upsert(e,t,n,i=!1){return new Promise((s,o)=>{let a=Math.floor(n/1e3),c=this.client.multi();if(i)a>0?c.set(e,t,"EX",a):c.set(e,t),c.pttl(e).exec((l,f)=>l?o(l):s(f));else if(a>0){let l=function(f,h){return f?o(f):s(h)};typeof this.client.rlflxIncr=="function"?this.client.rlflxIncr(e,t,a,l):this.client.eval(iae,1,e,t,a,l)}else c.incrby(e,t).pttl(e).exec((l,f)=>l?o(l):s(f))})}_get(e){return new Promise((t,n)=>{this.client.multi().get(e).pttl(e).exec((i,s)=>{if(i)n(i);else{let[o]=s;if(o===null)return t(null);t(s)}})})}_delete(e){return new Promise((t,n)=>{this.client.del(e,(i,s)=>{i?n(i):t(s>0)})})}};sae.exports=$P});var lae=R((i9t,cae)=>{u();var oxe=_1(),axe=ws();function aae(r){try{let e=r.client?r.client:r,{version:t}=e.topology.s.options.metadata.driver,n=t.split(".").map(i=>parseInt(i));return{major:n[0],feature:n[1],patch:n[2]}}catch{return{major:0,feature:0,patch:0}}}var l3=class extends oxe{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,typeof this.client.then=="function"?this.client.then(t=>{this.client=t,this._initCollection(),this._driverVersion=aae(this.client)}):(this._initCollection(),this._driverVersion=aae(this.client))}get dbName(){return this._dbName}set dbName(e){this._dbName=typeof e>"u"?l3.getDbName():e}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(e){this._tableName=typeof e>"u"?this.keyPrefix:e}get client(){return this._client}set client(e){if(typeof e>"u")throw new Error("mongo is not set");this._client=e}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(e){this._indexKeyPrefix=e||{}}_initCollection(){let t=(typeof this.client.db=="function"?this.client.db(this.dbName):this.client).collection(this.tableName);t.createIndex({expire:-1},{expireAfterSeconds:0}),t.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=t}_getRateLimiterRes(e,t,n){let i=new axe,s;return typeof n.value>"u"?s=n:s=n.value,i.isFirstInDuration=s.points===t,i.consumedPoints=s.points,i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i.msBeforeNext=s.expire!==null?Math.max(new Date(s.expire).getTime()-Date.now(),0):-1,i}_upsert(e,t,n,i=!1,s={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));let o=s.attrs||{},a,c;i?(a={key:e},a=Object.assign(a,o),c={$set:{key:e,points:t,expire:n>0?new Date(Date.now()+n):null}},c.$set=Object.assign(c.$set,o)):(a={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:e},a=Object.assign(a,o),c={$setOnInsert:{key:e,expire:n>0?new Date(Date.now()+n):null},$inc:{points:t}},c.$setOnInsert=Object.assign(c.$setOnInsert,o));let l={upsert:!0};return this._driverVersion.major>=4||this._driverVersion.major===3&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?l.returnDocument="after":l.returnOriginal=!1,new Promise((f,h)=>{this._collection.findOneAndUpdate(a,c,l).then(p=>{f(p)}).catch(p=>{if(p&&p.code===11e3){let d=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:e},o),m={$set:Object.assign({key:e,points:t,expire:n>0?new Date(Date.now()+n):null},o)};this._collection.findOneAndUpdate(d,m,l).then(y=>{f(y)}).catch(y=>{y&&y.code===11e3?this._upsert(e,t,n,i).then(g=>f(g)).catch(g=>h(g)):h(y)})}else h(p)})})}_get(e,t={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));let n=t.attrs||{},i=Object.assign({key:e,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},n);return this._collection.findOne(i)}_delete(e,t={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));let n=t.attrs||{},i=Object.assign({key:e},n);return this._collection.deleteOne(i).then(s=>s.deletedCount>0)}};cae.exports=l3});var fae=R((s9t,uae)=>{u();var cxe=_1(),lxe=ws(),HP=class extends cxe{constructor(e,t=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(),typeof t=="function"&&t()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),typeof t=="function"&&t()}).catch(n=>{if(typeof t=="function")t(n);else throw n})}clearExpired(e){return new Promise(t=>{this._getConnection().then(n=>{n.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,e],()=>{this._releaseConnection(n),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((n,i)=>{if(n)return t(n);e(i)})});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(n=>{n.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,i=>{if(i)return this._releaseConnection(n),t(i);n.query(this._getCreateTableStmt(),s=>{if(s)return this._releaseConnection(n),t(s);this._releaseConnection(n),e()})})}).catch(n=>{t(n)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${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(typeof e>"u")if(this.client.constructor.name==="Connection")e="connection";else if(this.client.constructor.name==="Pool")e="pool";else if(this.client.constructor.name==="Sequelize")e="sequelize";else throw new Error("storeType is not defined");this._clientType=e.toLowerCase()}get dbName(){return this._dbName}set dbName(e){this._dbName=typeof e>"u"?"rtlmtrflx":e}get tableName(){return this._tableName}set tableName(e){this._tableName=typeof e>"u"?this.keyPrefix:e}get tableCreated(){return this._tableCreated}set tableCreated(e){this._tableCreated=typeof e>"u"?!1:!!e}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(e){this._clearExpiredByTimeout=typeof e>"u"?!0:Boolean(e)}_getRateLimiterRes(e,t,n){let i=new lxe,[s]=n;return i.isFirstInDuration=t===s.points,i.consumedPoints=i.isFirstInDuration?t:s.points,i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i.msBeforeNext=s.expire?Math.max(s.expire-Date.now(),0):-1,i}_upsertTransaction(e,t,n,i,s){return new Promise((o,a)=>{e.query("BEGIN",c=>{if(c)return e.rollback(),a(c);let l=Date.now(),f=i>0?l+i:null,h,p;s?(h=`INSERT INTO ??.?? VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE
points = ?,
expire = ?;`,p=[this.dbName,this.tableName,t,n,f,n,f]):(h=`INSERT INTO ??.?? VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE
points = IF(expire <= ?, ?, points + (?)),
expire = IF(expire <= ?, ?, expire);`,p=[this.dbName,this.tableName,t,n,f,l,n,n,l,f]),e.query(h,p,d=>{if(d)return e.rollback(),a(d);e.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,t],(m,y)=>{if(m)return e.rollback(),a(m);e.query("COMMIT",g=>{if(g)return e.rollback(),a(g);o(y)})})})})})}_upsert(e,t,n,i=!1){return this.tableCreated?new Promise((s,o)=>{this._getConnection().then(a=>{this._upsertTransaction(a,e,t,n,i).then(c=>{s(c),this._releaseConnection(a)}).catch(c=>{o(c),this._releaseConnection(a)})}).catch(a=>{o(a)})}):Promise.reject(Error("Table is not created yet"))}_get(e){return this.tableCreated?new Promise((t,n)=>{this._getConnection().then(i=>{i.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,e,Date.now()],(s,o)=>{s?n(s):o.length===0?t(null):t(o),this._releaseConnection(i)})}).catch(i=>{n(i)})}):Promise.reject(Error("Table is not created yet"))}_delete(e){return this.tableCreated?new Promise((t,n)=>{this._getConnection().then(i=>{i.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,e],(s,o)=>{s?n(s):t(o.affectedRows>0),this._releaseConnection(i)})}).catch(i=>{n(i)})}):Promise.reject(Error("Table is not created yet"))}};uae.exports=HP});var dae=R((o9t,hae)=>{u();var uxe=_1(),fxe=ws(),GP=class extends uxe{constructor(e,t=null){super(e),this.client=e.storeClient,this.clientType=e.storeType,this.tableName=e.tableName,this.clearExpiredByTimeout=e.clearExpiredByTimeout,this.tableCreated=e.tableCreated,this.tableCreated?typeof t=="function"&&t():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),typeof t=="function"&&t()}).catch(n=>{if(typeof t=="function")t(n);else throw n})}clearExpired(e){return new Promise(t=>{let n={name:"rlflx-clear-expired",text:`DELETE FROM ${this.tableName} WHERE expire < $1`,values:[e]};this._query(n).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":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);default:return Promise.resolve(this.client)}}_releaseConnection(e){switch(this.clientType){case"pool":return!0;case"sequelize":return this.client.connectionManager.releaseConnection(e);case"knex":return this.client.client.releaseConnection(e);case"typeorm":return!0;default:return!0}}_createTable(){return new Promise((e,t)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{e()}).catch(n=>{n.code==="23505"?e():t(n)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this.tableName} (
key varchar(255) PRIMARY KEY,
points integer NOT NULL DEFAULT 0,
expire bigint
);`}get clientType(){return this._clientType}set clientType(e){let t=this.client.constructor.name;if(typeof e>"u")if(t==="Client")e="client";else if(t==="Pool"||t==="BoundPool")e="pool";else if(t==="Sequelize")e="sequelize";else throw new Error("storeType is not defined");this._clientType=e.toLowerCase()}get tableName(){return this._tableName}set tableName(e){this._tableName=typeof e>"u"?this.keyPrefix:e}get tableCreated(){return this._tableCreated}set tableCreated(e){this._tableCreated=typeof e>"u"?!1:!!e}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(e){this._clearExpiredByTimeout=typeof e>"u"?!0:Boolean(e)}_getRateLimiterRes(e,t,n){let i=new fxe,s=n.rows[0];return i.isFirstInDuration=t===s.points,i.consumedPoints=i.isFirstInDuration?t:s.points,i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i.msBeforeNext=s.expire?Math.max(s.expire-Date.now(),0):-1,i}_query(e){let n={name:`${this.tableName.toLowerCase()}:${e.name}`,text:e.text,values:e.values};return new Promise((i,s)=>{this._getConnection().then(o=>{o.query(n).then(a=>{i(a),this._releaseConnection(o)}).catch(a=>{s(a),this._releaseConnection(o)})}).catch(o=>{s(o)})})}_upsert(e,t,n,i=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));let s=n>0?Date.now()+n:null,o=i?" $3 ":` CASE
WHEN ${this.tableName}.expire <= $4 THEN $3
ELSE ${this.tableName}.expire
END `;return this._query({name:i?"rlflx-upsert-force":"rlflx-upsert",text:`
INSERT INTO ${this.tableName} VALUES ($1, $2, $3)
ON CONFLICT(key) DO UPDATE SET
points = CASE
WHEN (${this.tableName}.expire <= $4 OR 1=${i?1:0}) THEN $2
ELSE ${this.tableName}.points + ($2)
END,
expire = ${o}
RETURNING points, expire;`,values:[e,t,s,Date.now()]})}_get(e){return this.tableCreated?new Promise((t,n)=>{this._query({name:"rlflx-get",text:`
SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[e,Date.now()]}).then(i=>{i.rowCount===0&&(i=null),t(i)}).catch(i=>{n(i)})}):Promise.reject(Error("Table is not created yet"))}_delete(e){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[e]}).then(t=>t.rowCount>0):Promise.reject(Error("Table is not created yet"))}};hae.exports=GP});var pae=R(()=>{u()});var yae=R((u9t,mae)=>{u();mae.exports=class{constructor(e,t,n=null){this.value=e,this.expiresAt=t,this.timeoutId=n}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}}});var wae=R((h9t,gae)=>{u();var hxe=yae(),jP=ws();gae.exports=class{constructor(){this._storage={}}incrby(e,t,n){if(this._storage[e]){let i=this._storage[e].expiresAt?this._storage[e].expiresAt.getTime()-new Date().getTime():-1;return i!==0?(this._storage[e].value=this._storage[e].value+t,new jP(0,i,this._storage[e].value,!1)):this.set(e,t,n)}return this.set(e,t,n)}set(e,t,n){let i=n*1e3;return this._storage[e]&&this._storage[e].timeoutId&&clearTimeout(this._storage[e].timeoutId),this._storage[e]=new hxe(t,i>0?new Date(Date.now()+i):null),i>0&&(this._storage[e].timeoutId=setTimeout(()=>{delete this._storage[e]},i),this._storage[e].timeoutId.unref&&this._storage[e].timeoutId.unref()),new jP(0,i===0?-1:i,this._storage[e].value,!0)}get(e){if(this._storage[e]){let t=this._storage[e].expiresAt?this._storage[e].expiresAt.getTime()-new Date().getTime():-1;return new jP(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):!1}}});var YP=R((d9t,bae)=>{u();var dxe=c3(),pxe=wae(),Eae=ws(),WP=class extends dxe{constructor(e={}){super(e),this._memoryStorage=new pxe}consume(e,t=1,n={}){return new Promise((i,s)=>{let o=this.getKey(e),a=this._getKeySecDuration(n),c=this._memoryStorage.incrby(o,t,a);if(c.remainingPoints=Math.max(this.points-c.consumedPoints,0),c.consumedPoints>this.points)this.blockDuration>0&&c.consumedPoints<=this.points+t&&(c=this._memoryStorage.set(o,c.consumedPoints,this.blockDuration)),s(c);else if(this.execEvenly&&c.msBeforeNext>0&&!c.isFirstInDuration){let l=Math.ceil(c.msBeforeNext/(c.remainingPoints+2));l<this.execEvenlyMinDelayMs&&(l=c.consumedPoints*this.execEvenlyMinDelayMs),setTimeout(i,l,c)}else i(c)})}penalty(e,t=1,n={}){let i=this.getKey(e);return new Promise(s=>{let o=this._getKeySecDuration(n),a=this._memoryStorage.incrby(i,t,o);a.remainingPoints=Math.max(this.points-a.consumedPoints,0),s(a)})}reward(e,t=1,n={}){let i=this.getKey(e);return new Promise(s=>{let o=this._getKeySecDuration(n),a=this._memoryStorage.incrby(i,-t,o);a.remainingPoints=Math.max(this.points-a.consumedPoints,0),s(a)})}block(e,t){let n=t*1e3,i=this.points+1;return this._memoryStorage.set(this.getKey(e),i,t),Promise.resolve(new Eae(0,n===0?-1:n,i))}set(e,t,n){let i=(n>=0?n:this.duration)*1e3;return this._memoryStorage.set(this.getKey(e),t,n),Promise.resolve(new Eae(0,i===0?-1:i,t))}get(e){let t=this._memoryStorage.get(this.getKey(e));return t!==null&&(t.remainingPoints=Math.max(this.points-t.consumedPoints,0)),Promise.resolve(t)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}};bae.exports=WP});var Aae=R((p9t,Iae)=>{u();var vae=pae(),mxe=ru(),yxe=c3(),Sae=YP(),gxe=ws(),to="rate_limiter_flexible",T1=null,_ae=function(r,e,t,n){let i;n===null||n===!0||n===!1?i=n:i={remainingPoints:n.remainingPoints,msBeforeNext:n.msBeforeNext,consumedPoints:n.consumedPoints,isFirstInDuration:n.isFirstInDuration},r.send({channel:to,keyPrefix:e.keyPrefix,promiseId:e.promiseId,type:t,data:i})},xae=function(r){setTimeout(()=>{this._initiated?process.send(r):typeof this._promises[r.promiseId]<"u"&&xae.call(this,r)},30)},S1=function(r,e,t,n,i){let s={channel:to,keyPrefix:this.keyPrefix,func:r,promiseId:e,data:{key:t,arg:n,opts:i}};this._initiated?process.send(s):xae.call(this,s)},Tae=function(r,e){if(!e||e.channel!==to||typeof this._rateLimiters[e.keyPrefix]>"u")return!1;let t;switch(e.func){case"consume":t=this._rateLimiters[e.keyPrefix].consume(e.data.key,e.data.arg,e.data.opts);break;case"penalty":t=this._rateLimiters[e.keyPrefix].penalty(e.data.key,e.data.arg,e.data.opts);break;case"reward":t=this._rateLimiters[e.keyPrefix].reward(e.data.key,e.data.arg,e.data.opts);break;case"block":t=this._rateLimiters[e.keyPrefix].block(e.data.key,e.data.arg,e.data.opts);break;case"get":t=this._rateLimiters[e.keyPrefix].get(e.data.key,e.data.opts);break;case"delete":t=this._rateLimiters[e.keyPrefix].delete(e.data.key,e.data.opts);break;default:return!1}t&&t.then(n=>{_ae(r,e,"resolve",n)}).catch(n=>{_ae(r,e,"reject",n)})},wxe=function(r){if(!r||r.channel!==to||r.keyPrefix!==this.keyPrefix)return!1;if(this._promises[r.promiseId]){clearTimeout(this._promises[r.promiseId].timeoutId);let e;switch(r.data===null||r.data===!0||r.data===!1?e=r.data:e=new gxe(r.data.remainingPoints,r.data.msBeforeNext,r.data.consumedPoints,r.data.isFirstInDuration),r.type){case"resolve":this._promises[r.promiseId].resolve(e);break;case"reject":this._promises[r.promiseId].reject(e);break;default:throw new Error(`RateLimiterCluster: no such message type '${r.type}'`)}delete this._promises[r.promiseId]}},Exe=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},x1=function(r,e){let t=process.hrtime(),n=t[0].toString()+t[1].toString();return typeof this._promises[n]<"u"&&(n+=mxe.randomBytes(12).toString("base64")),this._promises[n]={resolve:r,reject:e,timeoutId:setTimeout(()=>{delete this._promises[n],e(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},n},QP=class{constructor(){if(T1)return T1;this._rateLimiters={},vae.setMaxListeners(0),vae.on("message",(e,t)=>{t&&t.channel===to&&t.type==="init"?(typeof this._rateLimiters[t.opts.keyPrefix]>"u"&&(this._rateLimiters[t.opts.keyPrefix]=new Sae(t.opts)),e.send({channel:to,type:"init",keyPrefix:t.opts.keyPrefix})):Tae.call(this,e,t)}),T1=this}},XP=class{constructor(e){if(T1)return T1;this._rateLimiters={},e.launchBus((t,n)=>{n.on("process:msg",i=>{let s=i.raw;if(s&&s.channel===to&&s.type==="init")typeof this._rateLimiters[s.opts.keyPrefix]>"u"&&(this._rateLimiters[s.opts.keyPrefix]=new Sae(s.opts)),e.sendDataToProcessId(i.process.pm_id,{data:{},topic:to,channel:to,type:"init",keyPrefix:s.opts.keyPrefix},(o,a)=>{o&&console.log(o,a)});else{let o={send:a=>{let c=a;c.topic=to,typeof c.data>"u"&&(c.data={}),e.sendDataToProcessId(i.process.pm_id,c,(l,f)=>{l&&console.log(l,f)})}};Tae.call(this,o,s)}})}),T1=this}},ZP=class extends yxe{get timeoutMs(){return this._timeoutMs}set timeoutMs(e){this._timeoutMs=typeof e>"u"?5e3:Math.abs(parseInt(e))}constructor(e={}){super(e),process.setMaxListeners(0),this.timeoutMs=e.timeoutMs,this._initiated=!1,process.on("message",t=>{t&&t.channel===to&&t.type==="init"&&t.keyPrefix===this.keyPrefix?this._initiated=!0:wxe.call(this,t)}),process.send({channel:to,type:"init",opts:Exe.call(this)}),this._promises={}}consume(e,t=1,n={}){return new Promise((i,s)=>{let o=x1.call(this,i,s);S1.call(this,"consume",o,e,t,n)})}penalty(e,t=1,n={}){return new Promise((i,s)=>{let o=x1.call(this,i,s);S1.call(this,"penalty",o,e,t,n)})}reward(e,t=1,n={}){return new Promise((i,s)=>{let o=x1.call(this,i,s);S1.call(this,"reward",o,e,t,n)})}block(e,t,n={}){return new Promise((i,s)=>{let o=x1.call(this,i,s);S1.call(this,"block",o,e,t,n)})}get(e,t={}){return new Promise((n,i)=>{let s=x1.call(this,n,i);S1.call(this,"get",s,e,t)})}delete(e,t={}){return new Promise((n,i)=>{let s=x1.call(this,n,i);S1.call(this,"delete",s,e,t)})}};Iae.exports={RateLimiterClusterMaster:QP,RateLimiterClusterMasterPM2:XP,RateLimiterCluster:ZP}});var Cae=R((m9t,Rae)=>{u();var bxe=_1(),vxe=ws(),JP=class extends bxe{constructor(e){super(e),this.client=e.storeClient}_getRateLimiterRes(e,t,n){let i=new vxe;return i.consumedPoints=parseInt(n.consumedPoints),i.isFirstInDuration=n.consumedPoints===t,i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i.msBeforeNext=n.msBeforeNext,i}_upsert(e,t,n,i=!1,s={}){return new Promise((o,a)=>{let c=Date.now(),l=Math.floor(n/1e3);i?this.client.set(e,t,l,f=>{f?a(f):this.client.set(`${e}_expire`,l>0?c+l*1e3:-1,l,()=>{let h={consumedPoints:t,msBeforeNext:l>0?l*1e3:-1};o(h)})}):this.client.incr(e,t,(f,h)=>{f||h===!1?this.client.add(e,t,l,(p,d)=>{if(p||!d)if(typeof s.attemptNumber>"u"||s.attemptNumber<3){let m=Object.assign({},s);m.attemptNumber=m.attemptNumber?m.attemptNumber+1:1,this._upsert(e,t,n,i,m).then(y=>o(y)).catch(y=>a(y))}else a(new Error("Can not add key"));else this.client.add(`${e}_expire`,l>0?c+l*1e3:-1,l,()=>{let m={consumedPoints:t,msBeforeNext:l>0?l*1e3:-1};o(m)})}):this.client.get(`${e}_expire`,(p,d)=>{if(p)a(p);else{let m=d===!1?0:d,y={consumedPoints:h,msBeforeNext:m>=0?Math.max(m-c,0):-1};o(y)}})})})}_get(e){return new Promise((t,n)=>{let i=Date.now();this.client.get(e,(s,o)=>{o?this.client.get(`${e}_expire`,(a,c)=>{if(a)n(a);else{let l=c===!1?0:c,f={consumedPoints:o,msBeforeNext:l>=0?Math.max(l-i,0):-1};t(f)}}):t(null)})})}_delete(e){return new Promise((t,n)=>{this.client.del(e,(i,s)=>{i?n(i):s===!1?t(s):this.client.del(`${e}_expire`,o=>{o?n(o):t(s)})})})}};Rae.exports=JP});var Oae=R((g9t,Dae)=>{u();var Pae=ws();Dae.exports=class{constructor(e={}){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(typeof e>"u")throw new Error("limiter is not set");this._limiter=e}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(e){this._runActionAnyway=typeof e>"u"?!1:e}get blackList(){return this._blackList}set blackList(e){this._blackList=Array.isArray(e)?e:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(e){if(typeof e>"u"&&(e=()=>!1),typeof e!="function")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(typeof e>"u"&&(e=()=>!1),typeof e!="function")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 Pae(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new Pae(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,t=1){let n;return this.isWhiteListedSomewhere(e)?n=this.resolveWhite():this.isBlackListedSomewhere(e)&&(n=this.rejectBlack()),typeof n>"u"?this.limiter.consume(e,t):(this.runActionAnyway&&this.limiter.consume(e,t).catch(()=>{}),n)}block(e,t){let n;return this.isWhiteListedSomewhere(e)?n=this.resolveWhite():this.isBlackListedSomewhere(e)&&(n=this.resolveBlack()),typeof n>"u"?this.limiter.block(e,t):(this.runActionAnyway&&this.limiter.block(e,t).catch(()=>{}),n)}penalty(e,t){let n;return this.isWhiteListedSomewhere(e)?n=this.resolveWhite():this.isBlackListedSomewhere(e)&&(n=this.resolveBlack()),typeof n>"u"?this.limiter.penalty(e,t):(this.runActionAnyway&&this.limiter.penalty(e,t).catch(()=>{}),n)}reward(e,t){let n;return this.isWhiteListedSomewhere(e)?n=this.resolveWhite():this.isBlackListedSomewhere(e)&&(n=this.resolveBlack()),typeof n>"u"?this.limiter.reward(e,t):(this.runActionAnyway&&this.limiter.reward(e,t).catch(()=>{}),n)}get(e){let t;return this.isWhiteListedSomewhere(e)?t=this.resolveWhite():this.isBlackListedSomewhere(e)&&(t=this.resolveBlack()),typeof t>"u"||this.runActionAnyway?this.limiter.get(e):t}delete(e){return this.limiter.delete(e)}}});var Nae=R((E9t,kae)=>{u();var _xe=c3();kae.exports=class{constructor(...e){if(e.length<2)throw new Error("RateLimiterUnion: at least two limiters have to be set");e.forEach(t=>{if(!(t instanceof _xe))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=e}consume(e,t=1){return new Promise((n,i)=>{let s=[];this._limiters.forEach(o=>{s.push(o.consume(e,t).catch(a=>({rejected:!0,rej:a})))}),Promise.all(s).then(o=>{let a={},c=!1;o.forEach(l=>{l.rejected===!0&&(c=!0)});for(let l=0;l<o.length;l++)c&&o[l].rejected===!0?a[this._limiters[l].keyPrefix]=o[l].rej:c||(a[this._limiters[l].keyPrefix]=o[l]);c?i(a):n(a)})})}}});var Bae=R((v9t,Lae)=>{u();Lae.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)}}});var Vae=R((S9t,Fae)=>{u();var Mae=Bae(),Uae=4294967295,eD="limiter";Fae.exports=class{constructor(e,t={maxQueueSize:Uae}){this._queueLimiters={KEY_DEFAULT:new k7(e,t)},this._limiterFlexible=e,this._maxQueueSize=t.maxQueueSize}getTokensRemaining(e=eD){return this._queueLimiters[e]?this._queueLimiters[e].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(e,t=eD){return this._queueLimiters[t]||(this._queueLimiters[t]=new k7(this._limiterFlexible,{key:t,maxQueueSize:this._maxQueueSize})),this._queueLimiters[t].removeTokens(e)}};var k7=class{constructor(e,t={maxQueueSize:Uae,key:eD}){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=>e!==null?e.remainingPoints:this._limiterFlexible.points)}removeTokens(e){let t=this;return new Promise((n,i)=>{if(e>t._limiterFlexible.points){i(new Mae(`Requested tokens ${e} exceeds maximum ${t._limiterFlexible.points} tokens per interval`));return}t._queue.length>0?t._queueRequest.call(t,n,i,e):t._limiterFlexible.consume(t._key,e).then(s=>{n(s.remainingPoints)}).catch(s=>{s instanceof Error?i(s):(t._queueRequest.call(t,n,i,e),t._waitTimeout===null&&(t._waitTimeout=setTimeout(t._processFIFO.bind(t),s.msBeforeNext)))})})}_queueRequest(e,t,n){let i=this;i._queue.length<i._maxQueueSize?i._queue.push({resolve:e,reject:t,tokens:n}):t(new Mae(`Number of requests reached it's maximum ${i._maxQueueSize}`))}_processFIFO(){let e=this;if(e._waitTimeout!==null&&(clearTimeout(e._waitTimeout),e._waitTimeout=null),e._queue.length===0)return;let t=e._queue.shift();e._limiterFlexible.consume(e._key,t.tokens).then(n=>{t.resolve(n.remainingPoints),e._processFIFO.call(e)}).catch(n=>{n instanceof Error?(t.reject(n),e._processFIFO.call(e)):(e._queue.unshift(t),e._waitTimeout===null&&(e._waitTimeout=setTimeout(e._processFIFO.bind(e),n.msBeforeNext)))})}}});var qae=R((T9t,Kae)=>{u();var tD=ws();Kae.exports=class{constructor(e,t){this._rateLimiter=e,this._burstLimiter=t}_combineRes(e,t){return new tD(e.remainingPoints,Math.min(e.msBeforeNext,t.msBeforeNext),e.consumedPoints,e.isFirstInDuration)}consume(e,t=1,n={}){return this._rateLimiter.consume(e,t,n).catch(i=>i instanceof tD?this._burstLimiter.consume(e,t,n).then(s=>Promise.resolve(this._combineRes(i,s))).catch(s=>s instanceof tD?Promise.reject(this._combineRes(i,s)):Promise.reject(s)):Promise.reject(i))}get(e){return Promise.all([this._rateLimiter.get(e),this._burstLimiter.get(e)]).then(([t,n])=>this._combineRes(t,n))}get points(){return this._rateLimiter.points}}});var $ae=R((I9t,zae)=>{u();var Sxe=oae(),xxe=lae(),Txe=fae(),Ixe=dae(),{RateLimiterClusterMaster:Axe,RateLimiterClusterMasterPM2:Rxe,RateLimiterCluster:Cxe}=Aae(),Pxe=YP(),Dxe=Cae(),Oxe=Oae(),kxe=Nae(),Nxe=Vae(),Lxe=qae(),Bxe=ws();zae.exports={RateLimiterRedis:Sxe,RateLimiterMongo:xxe,RateLimiterMySQL:Txe,RateLimiterPostgres:Ixe,RateLimiterMemory:Pxe,RateLimiterMemcache:Dxe,RateLimiterClusterMaster:Axe,RateLimiterClusterMasterPM2:Rxe,RateLimiterCluster:Cxe,RLWrapperBlackAndWhite:Oxe,RateLimiterUnion:kxe,RateLimiterQueue:Nxe,BurstyRateLimiter:Lxe,RateLimiterRes:Bxe}});var Wae=R(nD=>{"use strict";u();Object.defineProperty(nD,"__esModule",{value:!0});function Kxe(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}nD.isSerializableHash=Kxe});var B7=R(I1=>{"use strict";u();Object.defineProperty(I1,"__esModule",{value:!0});function qxe(r,e,t){return~(r-1)&e|r-1&t}I1.select=qxe;function zxe(r,e){return(r|0)-(e|0)-1>>>31&1}I1.lessOrEqual=zxe;function Yae(r,e){if(r.length!==e.length)return 0;for(var t=0,n=0;n<r.length;n++)t|=r[n]^e[n];return 1&t-1>>>8}I1.compare=Yae;function $xe(r,e){return r.length===0||e.length===0?!1:Yae(r,e)!==0}I1.equal=$xe});var nc=R(iD=>{"use strict";u();Object.defineProperty(iD,"__esModule",{value:!0});function Hxe(r){for(var e=0;e<r.length;e++)r[e]=0;return r}iD.wipe=Hxe});var Xae=R(u3=>{"use strict";u();Object.defineProperty(u3,"__esModule",{value:!0});var ic=Wae(),Gxe=B7(),jxe=nc(),Qae=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(n).clean():n.set(t);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),ic.isSerializableHash(this._inner)&&ic.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),jxe.wipe(n)}return r.prototype.reset=function(){if(!ic.isSerializableHash(this._inner)||!ic.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.clean=function(){ic.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),ic.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},r.prototype.update=function(e){return this._inner.update(e),this},r.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(!ic.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},r.prototype.restoreState=function(e){if(!ic.isSerializableHash(this._inner)||!ic.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},r.prototype.cleanSavedState=function(e){if(!ic.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},r}();u3.HMAC=Qae;function Wxe(r,e,t){var n=new Qae(r,e);n.update(t);var i=n.digest();return n.clean(),i}u3.hmac=Wxe;u3.equal=Gxe.equal});var ece=R(sD=>{"use strict";u();Object.defineProperty(sD,"__esModule",{value:!0});var Zae=Xae(),Jae=nc(),Yxe=function(){function r(e,t,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=Zae.hmac(this._hash,n,t);this._hmac=new Zae.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),n=0;n<t.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[n]=this._buffer[this._bufpos++];return t},r.prototype.clean=function(){this._hmac.clean(),Jae.wipe(this._buffer),Jae.wipe(this._counter),this._bufpos=0},r}();sD.HKDF=Yxe});var rce=R(M7=>{"use strict";u();Object.defineProperty(M7,"__esModule",{value:!0});M7.BrowserRandomSource=void 0;var tce=65536,oD=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let n=0;n<t.length;n+=tce)this._crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,tce)));return t}};M7.BrowserRandomSource=oD});var nce=R(U7=>{"use strict";u();Object.defineProperty(U7,"__esModule",{value:!0});U7.NodeRandomSource=void 0;var Qxe=nc(),aD=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Rd<"u"){let e=ru();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let n=new Uint8Array(e);for(let i=0;i<n.length;i++)n[i]=t[i];return(0,Qxe.wipe)(t),n}};U7.NodeRandomSource=aD});var ice=R(F7=>{"use strict";u();Object.defineProperty(F7,"__esModule",{value:!0});F7.SystemRandomSource=void 0;var Xxe=rce(),Zxe=nce(),cD=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Xxe.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new Zxe.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};F7.SystemRandomSource=cD});var sce=R(Es=>{"use strict";u();Object.defineProperty(Es,"__esModule",{value:!0});function Jxe(r,e){var t=r>>>16&65535,n=r&65535,i=e>>>16&65535,s=e&65535;return n*s+(t*s+n*i<<16>>>0)|0}Es.mul=Math.imul||Jxe;function eTe(r,e){return r+e|0}Es.add=eTe;function tTe(r,e){return r-e|0}Es.sub=tTe;function rTe(r,e){return r<<e|r>>>32-e}Es.rotl=rTe;function nTe(r,e){return r<<32-e|r>>>e}Es.rotr=nTe;function iTe(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Es.isInteger=Number.isInteger||iTe;Es.MAX_SAFE_INTEGER=9007199254740991;Es.isSafeInteger=function(r){return Es.isInteger(r)&&r>=-Es.MAX_SAFE_INTEGER&&r<=Es.MAX_SAFE_INTEGER}});var f3=R(ut=>{"use strict";u();Object.defineProperty(ut,"__esModule",{value:!0});var oce=sce();function sTe(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}ut.readInt16BE=sTe;function oTe(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}ut.readUint16BE=oTe;function aTe(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}ut.readInt16LE=aTe;function cTe(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}ut.readUint16LE=cTe;function ace(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}ut.writeUint16BE=ace;ut.writeInt16BE=ace;function cce(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}ut.writeUint16LE=cce;ut.writeInt16LE=cce;function lD(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}ut.readInt32BE=lD;function uD(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}ut.readUint32BE=uD;function fD(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}ut.readInt32LE=fD;function hD(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}ut.readUint32LE=hD;function V7(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}ut.writeUint32BE=V7;ut.writeInt32BE=V7;function K7(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}ut.writeUint32LE=K7;ut.writeInt32LE=K7;function lTe(r,e){e===void 0&&(e=0);var t=lD(r,e),n=lD(r,e+4);return t*4294967296+n-(n>>31)*4294967296}ut.readInt64BE=lTe;function uTe(r,e){e===void 0&&(e=0);var t=uD(r,e),n=uD(r,e+4);return t*4294967296+n}ut.readUint64BE=uTe;function fTe(r,e){e===void 0&&(e=0);var t=fD(r,e),n=fD(r,e+4);return n*4294967296+t-(t>>31)*4294967296}ut.readInt64LE=fTe;function hTe(r,e){e===void 0&&(e=0);var t=hD(r,e),n=hD(r,e+4);return n*4294967296+t}ut.readUint64LE=hTe;function lce(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),V7(r/4294967296>>>0,e,t),V7(r>>>0,e,t+4),e}ut.writeUint64BE=lce;ut.writeInt64BE=lce;function uce(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),K7(r>>>0,e,t),K7(r/4294967296>>>0,e,t+4),e}ut.writeUint64LE=uce;ut.writeInt64LE=uce;function dTe(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=r/8+t-1;s>=t;s--)n+=e[s]*i,i*=256;return n}ut.readUintBE=dTe;function pTe(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=t;s<t+r/8;s++)n+=e[s]*i,i*=256;return n}ut.readUintLE=pTe;function mTe(r,e,t,n){if(t===void 0&&(t=new Uint8Array(r/8)),n===void 0&&(n=0),r%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!oce.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=r/8+n-1;s>=n;s--)t[s]=e/i&255,i*=256;return t}ut.writeUintBE=mTe;function yTe(r,e,t,n){if(t===void 0&&(t=new Uint8Array(r/8)),n===void 0&&(n=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!oce.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+r/8;s++)t[s]=e/i&255,i*=256;return t}ut.writeUintLE=yTe;function gTe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e)}ut.readFloat32BE=gTe;function wTe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e,!0)}ut.readFloat32LE=wTe;function ETe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e)}ut.readFloat64BE=ETe;function bTe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e,!0)}ut.readFloat64LE=bTe;function vTe(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(t,r),e}ut.writeFloat32BE=vTe;function _Te(r,e,t){e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(t,r,!0),e}ut.writeFloat32LE=_Te;function STe(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(t,r),e}ut.writeFloat64BE=STe;function xTe(r,e,t){e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(t,r,!0),e}ut.writeFloat64LE=xTe});var pce=R(si=>{"use strict";u();Object.defineProperty(si,"__esModule",{value:!0});si.randomStringForEntropy=si.randomString=si.randomUint32=si.randomBytes=si.defaultRandomSource=void 0;var TTe=ice(),ITe=f3(),fce=nc();si.defaultRandomSource=new TTe.SystemRandomSource;function dD(r,e=si.defaultRandomSource){return e.randomBytes(r)}si.randomBytes=dD;function ATe(r=si.defaultRandomSource){let e=dD(4,r),t=(0,ITe.readUint32LE)(e);return(0,fce.wipe)(e),t}si.randomUint32=ATe;var hce="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function dce(r,e=hce,t=si.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let n="",i=e.length,s=256-256%i;for(;r>0;){let o=dD(Math.ceil(r*256/s),t);for(let a=0;a<o.length&&r>0;a++){let c=o[a];c<s&&(n+=e.charAt(c%i),r--)}(0,fce.wipe)(o)}return n}si.randomString=dce;function RTe(r,e=hce,t=si.defaultRandomSource){let n=Math.ceil(r/(Math.log(e.length)/Math.LN2));return dce(n,e,t)}si.randomStringForEntropy=RTe});var wce=R(zr=>{"use strict";u();Object.defineProperty(zr,"__esModule",{value:!0});zr.sharedKey=zr.generateKeyPair=zr.generateKeyPairFromSeed=zr.scalarMultBase=zr.scalarMult=zr.SHARED_KEY_LENGTH=zr.SECRET_KEY_LENGTH=zr.PUBLIC_KEY_LENGTH=void 0;var CTe=pce(),PTe=nc();zr.PUBLIC_KEY_LENGTH=32;zr.SECRET_KEY_LENGTH=32;zr.SHARED_KEY_LENGTH=32;function sc(r){let e=new Float64Array(16);if(r)for(let t=0;t<r.length;t++)e[t]=r[t];return e}var mce=new Uint8Array(32);mce[0]=9;var DTe=sc([56129,1]);function pD(r){let e=1;for(let t=0;t<16;t++){let n=r[t]+e+65535;e=Math.floor(n/65536),r[t]=n-e*65536}r[0]+=e-1+37*(e-1)}function h3(r,e,t){let n=~(t-1);for(let i=0;i<16;i++){let s=n&(r[i]^e[i]);r[i]^=s,e[i]^=s}}function OTe(r,e){let t=sc(),n=sc();for(let i=0;i<16;i++)n[i]=e[i];pD(n),pD(n),pD(n);for(let i=0;i<2;i++){t[0]=n[0]-65517;for(let o=1;o<15;o++)t[o]=n[o]-65535-(t[o-1]>>16&1),t[o-1]&=65535;t[15]=n[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,h3(n,t,1-s)}for(let i=0;i<16;i++)r[2*i]=n[i]&255,r[2*i+1]=n[i]>>8}function kTe(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function q7(r,e,t){for(let n=0;n<16;n++)r[n]=e[n]+t[n]}function z7(r,e,t){for(let n=0;n<16;n++)r[n]=e[n]-t[n]}function Tl(r,e,t){let n,i,s=0,o=0,a=0,c=0,l=0,f=0,h=0,p=0,d=0,m=0,y=0,g=0,w=0,b=0,S=0,_=0,I=0,T=0,x=0,P=0,B=0,q=0,Y=0,re=0,ie=0,Ce=0,Ee=0,Oe=0,H=0,qe=0,zt=0,Ke=t[0],Ze=t[1],ee=t[2],de=t[3],le=t[4],Pe=t[5],Me=t[6],Be=t[7],Ye=t[8],W=t[9],$=t[10],Q=t[11],ae=t[12],ce=t[13],De=t[14],it=t[15];n=e[0],s+=n*Ke,o+=n*Ze,a+=n*ee,c+=n*de,l+=n*le,f+=n*Pe,h+=n*Me,p+=n*Be,d+=n*Ye,m+=n*W,y+=n*$,g+=n*Q,w+=n*ae,b+=n*ce,S+=n*De,_+=n*it,n=e[1],o+=n*Ke,a+=n*Ze,c+=n*ee,l+=n*de,f+=n*le,h+=n*Pe,p+=n*Me,d+=n*Be,m+=n*Ye,y+=n*W,g+=n*$,w+=n*Q,b+=n*ae,S+=n*ce,_+=n*De,I+=n*it,n=e[2],a+=n*Ke,c+=n*Ze,l+=n*ee,f+=n*de,h+=n*le,p+=n*Pe,d+=n*Me,m+=n*Be,y+=n*Ye,g+=n*W,w+=n*$,b+=n*Q,S+=n*ae,_+=n*ce,I+=n*De,T+=n*it,n=e[3],c+=n*Ke,l+=n*Ze,f+=n*ee,h+=n*de,p+=n*le,d+=n*Pe,m+=n*Me,y+=n*Be,g+=n*Ye,w+=n*W,b+=n*$,S+=n*Q,_+=n*ae,I+=n*ce,T+=n*De,x+=n*it,n=e[4],l+=n*Ke,f+=n*Ze,h+=n*ee,p+=n*de,d+=n*le,m+=n*Pe,y+=n*Me,g+=n*Be,w+=n*Ye,b+=n*W,S+=n*$,_+=n*Q,I+=n*ae,T+=n*ce,x+=n*De,P+=n*it,n=e[5],f+=n*Ke,h+=n*Ze,p+=n*ee,d+=n*de,m+=n*le,y+=n*Pe,g+=n*Me,w+=n*Be,b+=n*Ye,S+=n*W,_+=n*$,I+=n*Q,T+=n*ae,x+=n*ce,P+=n*De,B+=n*it,n=e[6],h+=n*Ke,p+=n*Ze,d+=n*ee,m+=n*de,y+=n*le,g+=n*Pe,w+=n*Me,b+=n*Be,S+=n*Ye,_+=n*W,I+=n*$,T+=n*Q,x+=n*ae,P+=n*ce,B+=n*De,q+=n*it,n=e[7],p+=n*Ke,d+=n*Ze,m+=n*ee,y+=n*de,g+=n*le,w+=n*Pe,b+=n*Me,S+=n*Be,_+=n*Ye,I+=n*W,T+=n*$,x+=n*Q,P+=n*ae,B+=n*ce,q+=n*De,Y+=n*it,n=e[8],d+=n*Ke,m+=n*Ze,y+=n*ee,g+=n*de,w+=n*le,b+=n*Pe,S+=n*Me,_+=n*Be,I+=n*Ye,T+=n*W,x+=n*$,P+=n*Q,B+=n*ae,q+=n*ce,Y+=n*De,re+=n*it,n=e[9],m+=n*Ke,y+=n*Ze,g+=n*ee,w+=n*de,b+=n*le,S+=n*Pe,_+=n*Me,I+=n*Be,T+=n*Ye,x+=n*W,P+=n*$,B+=n*Q,q+=n*ae,Y+=n*ce,re+=n*De,ie+=n*it,n=e[10],y+=n*Ke,g+=n*Ze,w+=n*ee,b+=n*de,S+=n*le,_+=n*Pe,I+=n*Me,T+=n*Be,x+=n*Ye,P+=n*W,B+=n*$,q+=n*Q,Y+=n*ae,re+=n*ce,ie+=n*De,Ce+=n*it,n=e[11],g+=n*Ke,w+=n*Ze,b+=n*ee,S+=n*de,_+=n*le,I+=n*Pe,T+=n*Me,x+=n*Be,P+=n*Ye,B+=n*W,q+=n*$,Y+=n*Q,re+=n*ae,ie+=n*ce,Ce+=n*De,Ee+=n*it,n=e[12],w+=n*Ke,b+=n*Ze,S+=n*ee,_+=n*de,I+=n*le,T+=n*Pe,x+=n*Me,P+=n*Be,B+=n*Ye,q+=n*W,Y+=n*$,re+=n*Q,ie+=n*ae,Ce+=n*ce,Ee+=n*De,Oe+=n*it,n=e[13],b+=n*Ke,S+=n*Ze,_+=n*ee,I+=n*de,T+=n*le,x+=n*Pe,P+=n*Me,B+=n*Be,q+=n*Ye,Y+=n*W,re+=n*$,ie+=n*Q,Ce+=n*ae,Ee+=n*ce,Oe+=n*De,H+=n*it,n=e[14],S+=n*Ke,_+=n*Ze,I+=n*ee,T+=n*de,x+=n*le,P+=n*Pe,B+=n*Me,q+=n*Be,Y+=n*Ye,re+=n*W,ie+=n*$,Ce+=n*Q,Ee+=n*ae,Oe+=n*ce,H+=n*De,qe+=n*it,n=e[15],_+=n*Ke,I+=n*Ze,T+=n*ee,x+=n*de,P+=n*le,B+=n*Pe,q+=n*Me,Y+=n*Be,re+=n*Ye,ie+=n*W,Ce+=n*$,Ee+=n*Q,Oe+=n*ae,H+=n*ce,qe+=n*De,zt+=n*it,s+=38*I,o+=38*T,a+=38*x,c+=38*P,l+=38*B,f+=38*q,h+=38*Y,p+=38*re,d+=38*ie,m+=38*Ce,y+=38*Ee,g+=38*Oe,w+=38*H,b+=38*qe,S+=38*zt,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-i*65536,n=o+i+65535,i=Math.floor(n/65536),o=n-i*65536,n=a+i+65535,i=Math.floor(n/65536),a=n-i*65536,n=c+i+65535,i=Math.floor(n/65536),c=n-i*65536,n=l+i+65535,i=Math.floor(n/65536),l=n-i*65536,n=f+i+65535,i=Math.floor(n/65536),f=n-i*65536,n=h+i+65535,i=Math.floor(n/65536),h=n-i*65536,n=p+i+65535,i=Math.floor(n/65536),p=n-i*65536,n=d+i+65535,i=Math.floor(n/65536),d=n-i*65536,n=m+i+65535,i=Math.floor(n/65536),m=n-i*65536,n=y+i+65535,i=Math.floor(n/65536),y=n-i*65536,n=g+i+65535,i=Math.floor(n/65536),g=n-i*65536,n=w+i+65535,i=Math.floor(n/65536),w=n-i*65536,n=b+i+65535,i=Math.floor(n/65536),b=n-i*65536,n=S+i+65535,i=Math.floor(n/65536),S=n-i*65536,n=_+i+65535,i=Math.floor(n/65536),_=n-i*65536,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-i*65536,n=o+i+65535,i=Math.floor(n/65536),o=n-i*65536,n=a+i+65535,i=Math.floor(n/65536),a=n-i*65536,n=c+i+65535,i=Math.floor(n/65536),c=n-i*65536,n=l+i+65535,i=Math.floor(n/65536),l=n-i*65536,n=f+i+65535,i=Math.floor(n/65536),f=n-i*65536,n=h+i+65535,i=Math.floor(n/65536),h=n-i*65536,n=p+i+65535,i=Math.floor(n/65536),p=n-i*65536,n=d+i+65535,i=Math.floor(n/65536),d=n-i*65536,n=m+i+65535,i=Math.floor(n/65536),m=n-i*65536,n=y+i+65535,i=Math.floor(n/65536),y=n-i*65536,n=g+i+65535,i=Math.floor(n/65536),g=n-i*65536,n=w+i+65535,i=Math.floor(n/65536),w=n-i*65536,n=b+i+65535,i=Math.floor(n/65536),b=n-i*65536,n=S+i+65535,i=Math.floor(n/65536),S=n-i*65536,n=_+i+65535,i=Math.floor(n/65536),_=n-i*65536,s+=i-1+37*(i-1),r[0]=s,r[1]=o,r[2]=a,r[3]=c,r[4]=l,r[5]=f,r[6]=h,r[7]=p,r[8]=d,r[9]=m,r[10]=y,r[11]=g,r[12]=w,r[13]=b,r[14]=S,r[15]=_}function d3(r,e){Tl(r,e,e)}function NTe(r,e){let t=sc();for(let n=0;n<16;n++)t[n]=e[n];for(let n=253;n>=0;n--)d3(t,t),n!==2&&n!==4&&Tl(t,t,e);for(let n=0;n<16;n++)r[n]=t[n]}function mD(r,e){let t=new Uint8Array(32),n=new Float64Array(80),i=sc(),s=sc(),o=sc(),a=sc(),c=sc(),l=sc();for(let d=0;d<31;d++)t[d]=r[d];t[31]=r[31]&127|64,t[0]&=248,kTe(n,e);for(let d=0;d<16;d++)s[d]=n[d];i[0]=a[0]=1;for(let d=254;d>=0;--d){let m=t[d>>>3]>>>(d&7)&1;h3(i,s,m),h3(o,a,m),q7(c,i,o),z7(i,i,o),q7(o,s,a),z7(s,s,a),d3(a,c),d3(l,i),Tl(i,o,i),Tl(o,s,c),q7(c,i,o),z7(i,i,o),d3(s,i),z7(o,a,l),Tl(i,o,DTe),q7(i,i,a),Tl(o,o,i),Tl(i,a,l),Tl(a,s,n),d3(s,c),h3(i,s,m),h3(o,a,m)}for(let d=0;d<16;d++)n[d+16]=i[d],n[d+32]=o[d],n[d+48]=s[d],n[d+64]=a[d];let f=n.subarray(32),h=n.subarray(16);NTe(f,f),Tl(h,h,f);let p=new Uint8Array(32);return OTe(p,h),p}zr.scalarMult=mD;function yce(r){return mD(r,mce)}zr.scalarMultBase=yce;function gce(r){if(r.length!==zr.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${zr.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:yce(e),secretKey:e}}zr.generateKeyPairFromSeed=gce;function LTe(r){let e=(0,CTe.randomBytes)(32,r),t=gce(e);return(0,PTe.wipe)(e),t}zr.generateKeyPair=LTe;function BTe(r,e,t=!1){if(r.length!==zr.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==zr.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let n=mD(r,e);if(t){let i=0;for(let s=0;s<n.length;s++)i|=n[s];if(i===0)throw new Error("X25519: invalid shared key")}return n}zr.sharedKey=BTe});var bce=R(bf=>{"use strict";u();Object.defineProperty(bf,"__esModule",{value:!0});var H7=f3(),$7=nc();bf.DIGEST_LENGTH=32;bf.BLOCK_SIZE=64;var Ece=function(){function r(){this.digestLength=bf.DIGEST_LENGTH,this.blockSize=bf.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){$7.wipe(this._buffer),$7.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var n=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&t>0;)this._buffer[this._bufferLength++]=e[n++],t--;this._bufferLength===this.blockSize&&(yD(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=yD(this._temp,this._state,e,n,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[n++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,n=this._bufferLength,i=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[n]=128;for(var a=n+1;a<o-8;a++)this._buffer[a]=0;H7.writeUint32BE(i,this._buffer,o-8),H7.writeUint32BE(s,this._buffer,o-4),yD(this._temp,this._state,this._buffer,0,o),this._finished=!0}for(var a=0;a<this.digestLength/4;a++)H7.writeUint32BE(this._state[a],e,a*4);return this},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){$7.wipe(e.state),e.buffer&&$7.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();bf.SHA256=Ece;var MTe=new Int32Array([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]);function yD(r,e,t,n,i){for(;i>=64;){for(var s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],f=e[5],h=e[6],p=e[7],d=0;d<16;d++){var m=n+d*4;r[d]=H7.readUint32BE(t,m)}for(var d=16;d<64;d++){var y=r[d-2],g=(y>>>17|y<<32-17)^(y>>>19|y<<32-19)^y>>>10;y=r[d-15];var w=(y>>>7|y<<32-7)^(y>>>18|y<<32-18)^y>>>3;r[d]=(g+r[d-7]|0)+(w+r[d-16]|0)}for(var d=0;d<64;d++){var g=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&h)|0)+(p+(MTe[d]+r[d]|0)|0)|0,w=((s>>>2|s<<32-2)^(s>>>13|s<<32-13)^(s>>>22|s<<32-22))+(s&o^s&a^o&a)|0;p=h,h=f,f=l,l=c+g|0,c=a,a=o,o=s,s=g+w|0}e[0]+=s,e[1]+=o,e[2]+=a,e[3]+=c,e[4]+=l,e[5]+=f,e[6]+=h,e[7]+=p,n+=64,i-=64}return n}function UTe(r){var e=new Ece;e.update(r);var t=e.digest();return e.clean(),t}bf.hash=UTe});var _ce=R(G7=>{"use strict";u();Object.defineProperty(G7,"__esModule",{value:!0});var oi=f3(),gD=nc(),FTe=20;function VTe(r,e,t){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=t[3]<<24|t[2]<<16|t[1]<<8|t[0],c=t[7]<<24|t[6]<<16|t[5]<<8|t[4],l=t[11]<<24|t[10]<<16|t[9]<<8|t[8],f=t[15]<<24|t[14]<<16|t[13]<<8|t[12],h=t[19]<<24|t[18]<<16|t[17]<<8|t[16],p=t[23]<<24|t[22]<<16|t[21]<<8|t[20],d=t[27]<<24|t[26]<<16|t[25]<<8|t[24],m=t[31]<<24|t[30]<<16|t[29]<<8|t[28],y=e[3]<<24|e[2]<<16|e[1]<<8|e[0],g=e[7]<<24|e[6]<<16|e[5]<<8|e[4],w=e[11]<<24|e[10]<<16|e[9]<<8|e[8],b=e[15]<<24|e[14]<<16|e[13]<<8|e[12],S=n,_=i,I=s,T=o,x=a,P=c,B=l,q=f,Y=h,re=p,ie=d,Ce=m,Ee=y,Oe=g,H=w,qe=b,zt=0;zt<FTe;zt+=2)S=S+x|0,Ee^=S,Ee=Ee>>>32-16|Ee<<16,Y=Y+Ee|0,x^=Y,x=x>>>32-12|x<<12,_=_+P|0,Oe^=_,Oe=Oe>>>32-16|Oe<<16,re=re+Oe|0,P^=re,P=P>>>32-12|P<<12,I=I+B|0,H^=I,H=H>>>32-16|H<<16,ie=ie+H|0,B^=ie,B=B>>>32-12|B<<12,T=T+q|0,qe^=T,qe=qe>>>32-16|qe<<16,Ce=Ce+qe|0,q^=Ce,q=q>>>32-12|q<<12,I=I+B|0,H^=I,H=H>>>32-8|H<<8,ie=ie+H|0,B^=ie,B=B>>>32-7|B<<7,T=T+q|0,qe^=T,qe=qe>>>32-8|qe<<8,Ce=Ce+qe|0,q^=Ce,q=q>>>32-7|q<<7,_=_+P|0,Oe^=_,Oe=Oe>>>32-8|Oe<<8,re=re+Oe|0,P^=re,P=P>>>32-7|P<<7,S=S+x|0,Ee^=S,Ee=Ee>>>32-8|Ee<<8,Y=Y+Ee|0,x^=Y,x=x>>>32-7|x<<7,S=S+P|0,qe^=S,qe=qe>>>32-16|qe<<16,ie=ie+qe|0,P^=ie,P=P>>>32-12|P<<12,_=_+B|0,Ee^=_,Ee=Ee>>>32-16|Ee<<16,Ce=Ce+Ee|0,B^=Ce,B=B>>>32-12|B<<12,I=I+q|0,Oe^=I,Oe=Oe>>>32-16|Oe<<16,Y=Y+Oe|0,q^=Y,q=q>>>32-12|q<<12,T=T+x|0,H^=T,H=H>>>32-16|H<<16,re=re+H|0,x^=re,x=x>>>32-12|x<<12,I=I+q|0,Oe^=I,Oe=Oe>>>32-8|Oe<<8,Y=Y+Oe|0,q^=Y,q=q>>>32-7|q<<7,T=T+x|0,H^=T,H=H>>>32-8|H<<8,re=re+H|0,x^=re,x=x>>>32-7|x<<7,_=_+B|0,Ee^=_,Ee=Ee>>>32-8|Ee<<8,Ce=Ce+Ee|0,B^=Ce,B=B>>>32-7|B<<7,S=S+P|0,qe^=S,qe=qe>>>32-8|qe<<8,ie=ie+qe|0,P^=ie,P=P>>>32-7|P<<7;oi.writeUint32LE(S+n|0,r,0),oi.writeUint32LE(_+i|0,r,4),oi.writeUint32LE(I+s|0,r,8),oi.writeUint32LE(T+o|0,r,12),oi.writeUint32LE(x+a|0,r,16),oi.writeUint32LE(P+c|0,r,20),oi.writeUint32LE(B+l|0,r,24),oi.writeUint32LE(q+f|0,r,28),oi.writeUint32LE(Y+h|0,r,32),oi.writeUint32LE(re+p|0,r,36),oi.writeUint32LE(ie+d|0,r,40),oi.writeUint32LE(Ce+m|0,r,44),oi.writeUint32LE(Ee+y|0,r,48),oi.writeUint32LE(Oe+g|0,r,52),oi.writeUint32LE(H+w|0,r,56),oi.writeUint32LE(qe+b|0,r,60)}function vce(r,e,t,n,i){if(i===void 0&&(i=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<t.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}for(var a=new Uint8Array(64),c=0;c<t.length;c+=64){VTe(a,s,r);for(var l=c;l<c+64&&l<t.length;l++)n[l]=t[l]^a[l-c];qTe(s,0,o)}return gD.wipe(a),i===0&&gD.wipe(s),n}G7.streamXOR=vce;function KTe(r,e,t,n){return n===void 0&&(n=0),gD.wipe(t),vce(r,e,t,t,n)}G7.stream=KTe;function qTe(r,e,t){for(var n=1;t--;)n=n+(r[e]&255)|0,r[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}});var xce=R(Il=>{"use strict";u();Object.defineProperty(Il,"__esModule",{value:!0});var zTe=B7(),j7=nc();Il.DIGEST_LENGTH=16;var Sce=function(){function r(e){this.digestLength=Il.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var n=e[2]|e[3]<<8;this._r[1]=(t>>>13|n<<3)&8191;var i=e[4]|e[5]<<8;this._r[2]=(n>>>10|i<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(i>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var c=e[12]|e[13]<<8;this._r[7]=(a>>>11|c<<5)&8065;var l=e[14]|e[15]<<8;this._r[8]=(c>>>8|l<<8)&8191,this._r[9]=l>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,n){for(var i=this._fin?0:2048,s=this._h[0],o=this._h[1],a=this._h[2],c=this._h[3],l=this._h[4],f=this._h[5],h=this._h[6],p=this._h[7],d=this._h[8],m=this._h[9],y=this._r[0],g=this._r[1],w=this._r[2],b=this._r[3],S=this._r[4],_=this._r[5],I=this._r[6],T=this._r[7],x=this._r[8],P=this._r[9];n>=16;){var B=e[t+0]|e[t+1]<<8;s+=B&8191;var q=e[t+2]|e[t+3]<<8;o+=(B>>>13|q<<3)&8191;var Y=e[t+4]|e[t+5]<<8;a+=(q>>>10|Y<<6)&8191;var re=e[t+6]|e[t+7]<<8;c+=(Y>>>7|re<<9)&8191;var ie=e[t+8]|e[t+9]<<8;l+=(re>>>4|ie<<12)&8191,f+=ie>>>1&8191;var Ce=e[t+10]|e[t+11]<<8;h+=(ie>>>14|Ce<<2)&8191;var Ee=e[t+12]|e[t+13]<<8;p+=(Ce>>>11|Ee<<5)&8191;var Oe=e[t+14]|e[t+15]<<8;d+=(Ee>>>8|Oe<<8)&8191,m+=Oe>>>5|i;var H=0,qe=H;qe+=s*y,qe+=o*(5*P),qe+=a*(5*x),qe+=c*(5*T),qe+=l*(5*I),H=qe>>>13,qe&=8191,qe+=f*(5*_),qe+=h*(5*S),qe+=p*(5*b),qe+=d*(5*w),qe+=m*(5*g),H+=qe>>>13,qe&=8191;var zt=H;zt+=s*g,zt+=o*y,zt+=a*(5*P),zt+=c*(5*x),zt+=l*(5*T),H=zt>>>13,zt&=8191,zt+=f*(5*I),zt+=h*(5*_),zt+=p*(5*S),zt+=d*(5*b),zt+=m*(5*w),H+=zt>>>13,zt&=8191;var Ke=H;Ke+=s*w,Ke+=o*g,Ke+=a*y,Ke+=c*(5*P),Ke+=l*(5*x),H=Ke>>>13,Ke&=8191,Ke+=f*(5*T),Ke+=h*(5*I),Ke+=p*(5*_),Ke+=d*(5*S),Ke+=m*(5*b),H+=Ke>>>13,Ke&=8191;var Ze=H;Ze+=s*b,Ze+=o*w,Ze+=a*g,Ze+=c*y,Ze+=l*(5*P),H=Ze>>>13,Ze&=8191,Ze+=f*(5*x),Ze+=h*(5*T),Ze+=p*(5*I),Ze+=d*(5*_),Ze+=m*(5*S),H+=Ze>>>13,Ze&=8191;var ee=H;ee+=s*S,ee+=o*b,ee+=a*w,ee+=c*g,ee+=l*y,H=ee>>>13,ee&=8191,ee+=f*(5*P),ee+=h*(5*x),ee+=p*(5*T),ee+=d*(5*I),ee+=m*(5*_),H+=ee>>>13,ee&=8191;var de=H;de+=s*_,de+=o*S,de+=a*b,de+=c*w,de+=l*g,H=de>>>13,de&=8191,de+=f*y,de+=h*(5*P),de+=p*(5*x),de+=d*(5*T),de+=m*(5*I),H+=de>>>13,de&=8191;var le=H;le+=s*I,le+=o*_,le+=a*S,le+=c*b,le+=l*w,H=le>>>13,le&=8191,le+=f*g,le+=h*y,le+=p*(5*P),le+=d*(5*x),le+=m*(5*T),H+=le>>>13,le&=8191;var Pe=H;Pe+=s*T,Pe+=o*I,Pe+=a*_,Pe+=c*S,Pe+=l*b,H=Pe>>>13,Pe&=8191,Pe+=f*w,Pe+=h*g,Pe+=p*y,Pe+=d*(5*P),Pe+=m*(5*x),H+=Pe>>>13,Pe&=8191;var Me=H;Me+=s*x,Me+=o*T,Me+=a*I,Me+=c*_,Me+=l*S,H=Me>>>13,Me&=8191,Me+=f*b,Me+=h*w,Me+=p*g,Me+=d*y,Me+=m*(5*P),H+=Me>>>13,Me&=8191;var Be=H;Be+=s*P,Be+=o*x,Be+=a*T,Be+=c*I,Be+=l*_,H=Be>>>13,Be&=8191,Be+=f*S,Be+=h*b,Be+=p*w,Be+=d*g,Be+=m*y,H+=Be>>>13,Be&=8191,H=(H<<2)+H|0,H=H+qe|0,qe=H&8191,H=H>>>13,zt+=H,s=qe,o=zt,a=Ke,c=Ze,l=ee,f=de,h=le,p=Pe,d=Me,m=Be,t+=16,n-=16}this._h[0]=s,this._h[1]=o,this._h[2]=a,this._h[3]=c,this._h[4]=l,this._h[5]=f,this._h[6]=h,this._h[7]=p,this._h[8]=d,this._h[9]=m},r.prototype.finish=function(e,t){t===void 0&&(t=0);var n=new Uint16Array(10),i,s,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(i=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=i,i=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=i*5,i=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=i,i=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=i,n[0]=this._h[0]+5,i=n[0]>>>13,n[0]&=8191,a=1;a<10;a++)n[a]=this._h[a]+i,i=n[a]>>>13,n[a]&=8191;for(n[9]-=1<<13,s=(i^1)-1,a=0;a<10;a++)n[a]&=s;for(s=~s,a=0;a<10;a++)this._h[a]=this._h[a]&s|n[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,n=e.length,i;if(this._leftover){i=16-this._leftover,i>n&&(i=n);for(var s=0;s<i;s++)this._buffer[this._leftover+s]=e[t+s];if(n-=i,t+=i,this._leftover+=i,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(var s=0;s<n;s++)this._buffer[this._leftover+s]=e[t+s];this._leftover+=n}return this},r.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var e=new Uint8Array(16);return this.finish(e),e},r.prototype.clean=function(){return j7.wipe(this._buffer),j7.wipe(this._r),j7.wipe(this._h),j7.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},r}();Il.Poly1305=Sce;function $Te(r,e){var t=new Sce(r);t.update(e);var n=t.digest();return t.clean(),n}Il.oneTimeAuth=$Te;function HTe(r,e){return r.length!==Il.DIGEST_LENGTH||e.length!==Il.DIGEST_LENGTH?!1:zTe.equal(r,e)}Il.equal=HTe});var Ace=R(Al=>{"use strict";u();Object.defineProperty(Al,"__esModule",{value:!0});var W7=_ce(),GTe=xce(),p3=nc(),Tce=f3(),jTe=B7();Al.KEY_LENGTH=32;Al.NONCE_LENGTH=12;Al.TAG_LENGTH=16;var Ice=new Uint8Array(16),WTe=function(){function r(e){if(this.nonceLength=Al.NONCE_LENGTH,this.tagLength=Al.TAG_LENGTH,e.length!==Al.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);W7.stream(this._key,s,o,4);var a=t.length+this.tagLength,c;if(i){if(i.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");c=i}else c=new Uint8Array(a);return W7.streamXOR(this._key,s,t,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),o,c.subarray(0,c.length-this.tagLength),n),p3.wipe(s),c},r.prototype.open=function(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length<this.tagLength)return null;var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);W7.stream(this._key,s,o,4);var a=new Uint8Array(this.tagLength);if(this._authenticate(a,o,t.subarray(0,t.length-this.tagLength),n),!jTe.equal(a,t.subarray(t.length-this.tagLength,t.length)))return null;var c=t.length-this.tagLength,l;if(i){if(i.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");l=i}else l=new Uint8Array(c);return W7.streamXOR(this._key,s,t.subarray(0,t.length-this.tagLength),l,4),p3.wipe(s),l},r.prototype.clean=function(){return p3.wipe(this._key),this},r.prototype._authenticate=function(e,t,n,i){var s=new GTe.Poly1305(t);i&&(s.update(i),i.length%16>0&&s.update(Ice.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(Ice.subarray(n.length%16));var o=new Uint8Array(8);i&&Tce.writeUint64LE(i.length,o),s.update(o),Tce.writeUint64LE(n.length,o),s.update(o);for(var a=s.digest(),c=0;c<a.length;c++)e[c]=a[c];s.clean(),p3.wipe(a),p3.wipe(o)},r}();Al.ChaCha20Poly1305=WTe});var ele=R((Fxt,Jce)=>{u();Jce.exports=Zce;var Xce=128,aIe=127,cIe=~aIe,lIe=Math.pow(2,31);function Zce(r,e,t){e=e||[],t=t||0;for(var n=t;r>=lIe;)e[t++]=r&255|Xce,r/=128;for(;r&cIe;)e[t++]=r&255|Xce,r>>>=7;return e[t]=r|0,Zce.bytes=t-n+1,e}});var nle=R((Vxt,rle)=>{u();rle.exports=AD;var uIe=128,tle=127;function AD(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw AD.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&tle)<<i:(o&tle)*Math.pow(2,i),i+=7}while(o>=uIe);return AD.bytes=s-n,t}});var sle=R((Kxt,ile)=>{u();var fIe=Math.pow(2,7),hIe=Math.pow(2,14),dIe=Math.pow(2,21),pIe=Math.pow(2,28),mIe=Math.pow(2,35),yIe=Math.pow(2,42),gIe=Math.pow(2,49),wIe=Math.pow(2,56),EIe=Math.pow(2,63);ile.exports=function(r){return r<fIe?1:r<hIe?2:r<dIe?3:r<pIe?4:r<mIe?5:r<yIe?6:r<gIe?7:r<wIe?8:r<EIe?9:10}});var ale=R((qxt,ole)=>{u();ole.exports={encode:ele(),decode:nle(),encodingLength:sle()}});var ule=R((zxt,lle)=>{"use strict";u();var cle=ale();lle.exports=r=>{if(!(r instanceof Uint8Array))throw new Error("arg needs to be a Uint8Array");let e=[];for(;r.length>0;){let t=cle.decode(r);e.push(t),r=r.slice(cle.decode.bytes)}return e}});var Ale=R((Tle,Ile)=>{"use strict";u();var OIe=Math.exp;Tle=Ile.exports=function(e){if(typeof e!="number")throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let t,n=0,i=0,s=0,o,a={};function c(l,f){return 1-OIe(-(l-f)/e)}return a.push=function(f,h){if(o){let p=c(f,o),d=h-t,m=p*d;t=p*h+(1-p)*t,n=(1-p)*(n+d*m),i=Math.sqrt(n),s=t+p*d}else t=h;o=f},a.movingAverage=function(){return t},a.variance=function(){return n},a.deviation=function(){return i},a.forecast=function(){return s},a}});var GIe={};Kt(GIe,{create:()=>qIe,globSource:()=>zIe,path:()=>HIe,urlSource:()=>$Ie});u();u();u();u();var bO=E(Ov(),1),Qe=bO.default;var Wle=E(Nv(),1);u();var ia=E(Li(),1);var zv={};Kt(zv,{base58btc:()=>Ue,base58flickr:()=>_fe});u();u();u();function pfe(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var s=r.charAt(i),o=s.charCodeAt(0);if(t[o]!==255)throw new TypeError(s+" is ambiguous");t[o]=i}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function h(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var y=0,g=0,w=0,b=m.length;w!==b&&m[w]===0;)w++,y++;for(var S=(b-w)*f+1>>>0,_=new Uint8Array(S);w!==b;){for(var I=m[w],T=0,x=S-1;(I!==0||T<g)&&x!==-1;x--,T++)I+=256*_[x]>>>0,_[x]=I%a>>>0,I=I/a>>>0;if(I!==0)throw new Error("Non-zero carry");g=T,w++}for(var P=S-g;P!==S&&_[P]===0;)P++;for(var B=c.repeat(y);P<S;++P)B+=r.charAt(_[P]);return B}function p(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var y=0;if(m[y]!==" "){for(var g=0,w=0;m[y]===c;)g++,y++;for(var b=(m.length-y)*l+1>>>0,S=new Uint8Array(b);m[y];){var _=t[m.charCodeAt(y)];if(_===255)return;for(var I=0,T=b-1;(_!==0||I<w)&&T!==-1;T--,I++)_+=a*S[T]>>>0,S[T]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");w=I,y++}if(m[y]!==" "){for(var x=b-w;x!==b&&S[x]===0;)x++;for(var P=new Uint8Array(g+(b-x)),B=g;x!==b;)P[B++]=S[x++];return P}}}function d(m){var y=p(m);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:p,decode:d}}var mfe=pfe,yfe=mfe,IO=yfe;var Fd={};Kt(Fd,{coerce:()=>_s,empty:()=>AO,equals:()=>Bv,fromHex:()=>wfe,fromString:()=>Mv,isBinary:()=>Efe,toHex:()=>gfe,toString:()=>Uv});u();var AO=new Uint8Array(0),gfe=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),wfe=r=>{let e=r.match(/../g);return e?new Uint8Array(e.map(t=>parseInt(t,16))):AO},Bv=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},_s=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},Efe=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),Mv=r=>new TextEncoder().encode(r),Uv=r=>new TextDecoder().decode(r);var Fv=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Vv=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return RO(this,e)}},Kv=class{constructor(e){this.decoders=e}or(e){return RO(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},RO=(r,e)=>new Kv({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),qv=class{constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new Fv(e,t,n),this.decoder=new Vv(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Vd=({name:r,prefix:e,encode:t,decode:n})=>new qv(r,e,t,n),Dl=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:i}=IO(t,e);return Vd({prefix:r,name:e,encode:n,decode:s=>_s(i(s))})},bfe=(r,e,t,n)=>{let i={};for(let f=0;f<e.length;++f)i[e[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let o=new Uint8Array(s*t/8|0),a=0,c=0,l=0;for(let f=0;f<s;++f){let h=i[r[f]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|h,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},vfe=(r,e,t)=>{let n=e[e.length-1]==="=",i=(1<<t)-1,s="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<<t-o]),n)for(;s.length*t&7;)s+="=";return s},Br=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Vd({prefix:e,name:r,encode(i){return vfe(i,n,t)},decode(i){return bfe(i,n,t,r)}});var Ue=Dl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_fe=Dl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gv={};Kt(Gv,{base32:()=>mt,base32hex:()=>xfe,base32hexpad:()=>Ife,base32hexpadupper:()=>Afe,base32hexupper:()=>Tfe,base32pad:()=>Hv,base32padupper:()=>Sfe,base32upper:()=>$v,base32z:()=>Rfe});u();var mt=Br({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$v=Br({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hv=Br({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Sfe=Br({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xfe=Br({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Tfe=Br({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ife=Br({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Afe=Br({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rfe=Br({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jv={};Kt(jv,{base64:()=>na,base64pad:()=>Cfe,base64url:()=>Ol,base64urlpad:()=>Pfe});u();var na=Br({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cfe=Br({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ol=Br({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pfe=Br({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});ia.default.formatters.b=r=>r==null?"undefined":Ue.baseEncode(r);ia.default.formatters.t=r=>r==null?"undefined":mt.baseEncode(r);ia.default.formatters.m=r=>r==null?"undefined":na.baseEncode(r);ia.default.formatters.p=r=>r==null?"undefined":r.toString();ia.default.formatters.c=r=>r==null?"undefined":r.toString();ia.default.formatters.k=r=>r==null?"undefined":r.toString();function C(r){return Object.assign((0,ia.default)(r),{error:(0,ia.default)(`${r}:error`),trace:(0,ia.default)(`${r}:trace`)})}var yv=E(V(),1);u();var G3=E(V(),1);u();var uc=E(ca(),1),qd=uc.default.Reader,d_=uc.default.Writer,He=uc.default.util,Un=uc.default.roots["ipfs-unixfs"]||(uc.default.roots["ipfs-unixfs"]={}),gk=Un.Data=(()=>{function r(e){if(this.blocksizes=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.Type=0,r.prototype.Data=He.newBuffer([]),r.prototype.filesize=He.Long?He.Long.fromBits(0,0,!0):0,r.prototype.blocksizes=He.emptyArray,r.prototype.hashType=He.Long?He.Long.fromBits(0,0,!0):0,r.prototype.fanout=He.Long?He.Long.fromBits(0,0,!0):0,r.prototype.mode=0,r.prototype.mtime=null,r.encode=function(t,n){if(n||(n=d_.create()),n.uint32(8).int32(t.Type),t.Data!=null&&Object.hasOwnProperty.call(t,"Data")&&n.uint32(18).bytes(t.Data),t.filesize!=null&&Object.hasOwnProperty.call(t,"filesize")&&n.uint32(24).uint64(t.filesize),t.blocksizes!=null&&t.blocksizes.length)for(var i=0;i<t.blocksizes.length;++i)n.uint32(32).uint64(t.blocksizes[i]);return t.hashType!=null&&Object.hasOwnProperty.call(t,"hashType")&&n.uint32(40).uint64(t.hashType),t.fanout!=null&&Object.hasOwnProperty.call(t,"fanout")&&n.uint32(48).uint64(t.fanout),t.mode!=null&&Object.hasOwnProperty.call(t,"mode")&&n.uint32(56).uint32(t.mode),t.mtime!=null&&Object.hasOwnProperty.call(t,"mtime")&&Un.UnixTime.encode(t.mtime,n.uint32(66).fork()).ldelim(),n},r.decode=function(t,n){t instanceof qd||(t=qd.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Un.Data;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.Type=t.int32();break;case 2:s.Data=t.bytes();break;case 3:s.filesize=t.uint64();break;case 4:if(s.blocksizes&&s.blocksizes.length||(s.blocksizes=[]),(o&7)===2)for(var a=t.uint32()+t.pos;t.pos<a;)s.blocksizes.push(t.uint64());else s.blocksizes.push(t.uint64());break;case 5:s.hashType=t.uint64();break;case 6:s.fanout=t.uint64();break;case 7:s.mode=t.uint32();break;case 8:s.mtime=Un.UnixTime.decode(t,t.uint32());break;default:t.skipType(o&7);break}}if(!s.hasOwnProperty("Type"))throw He.ProtocolError("missing required 'Type'",{instance:s});return s},r.fromObject=function(t){if(t instanceof Un.Data)return t;var n=new Un.Data;switch(t.Type){case"Raw":case 0:n.Type=0;break;case"Directory":case 1:n.Type=1;break;case"File":case 2:n.Type=2;break;case"Metadata":case 3:n.Type=3;break;case"Symlink":case 4:n.Type=4;break;case"HAMTShard":case 5:n.Type=5;break}if(t.Data!=null&&(typeof t.Data=="string"?He.base64.decode(t.Data,n.Data=He.newBuffer(He.base64.length(t.Data)),0):t.Data.length&&(n.Data=t.Data)),t.filesize!=null&&(He.Long?(n.filesize=He.Long.fromValue(t.filesize)).unsigned=!0:typeof t.filesize=="string"?n.filesize=parseInt(t.filesize,10):typeof t.filesize=="number"?n.filesize=t.filesize:typeof t.filesize=="object"&&(n.filesize=new He.LongBits(t.filesize.low>>>0,t.filesize.high>>>0).toNumber(!0))),t.blocksizes){if(!Array.isArray(t.blocksizes))throw TypeError(".Data.blocksizes: array expected");n.blocksizes=[];for(var i=0;i<t.blocksizes.length;++i)He.Long?(n.blocksizes[i]=He.Long.fromValue(t.blocksizes[i])).unsigned=!0:typeof t.blocksizes[i]=="string"?n.blocksizes[i]=parseInt(t.blocksizes[i],10):typeof t.blocksizes[i]=="number"?n.blocksizes[i]=t.blocksizes[i]:typeof t.blocksizes[i]=="object"&&(n.blocksizes[i]=new He.LongBits(t.blocksizes[i].low>>>0,t.blocksizes[i].high>>>0).toNumber(!0))}if(t.hashType!=null&&(He.Long?(n.hashType=He.Long.fromValue(t.hashType)).unsigned=!0:typeof t.hashType=="string"?n.hashType=parseInt(t.hashType,10):typeof t.hashType=="number"?n.hashType=t.hashType:typeof t.hashType=="object"&&(n.hashType=new He.LongBits(t.hashType.low>>>0,t.hashType.high>>>0).toNumber(!0))),t.fanout!=null&&(He.Long?(n.fanout=He.Long.fromValue(t.fanout)).unsigned=!0:typeof t.fanout=="string"?n.fanout=parseInt(t.fanout,10):typeof t.fanout=="number"?n.fanout=t.fanout:typeof t.fanout=="object"&&(n.fanout=new He.LongBits(t.fanout.low>>>0,t.fanout.high>>>0).toNumber(!0))),t.mode!=null&&(n.mode=t.mode>>>0),t.mtime!=null){if(typeof t.mtime!="object")throw TypeError(".Data.mtime: object expected");n.mtime=Un.UnixTime.fromObject(t.mtime)}return n},r.toObject=function(t,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.blocksizes=[]),n.defaults){if(i.Type=n.enums===String?"Raw":0,n.bytes===String?i.Data="":(i.Data=[],n.bytes!==Array&&(i.Data=He.newBuffer(i.Data))),He.Long){var s=new He.Long(0,0,!0);i.filesize=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.filesize=n.longs===String?"0":0;if(He.Long){var s=new He.Long(0,0,!0);i.hashType=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.hashType=n.longs===String?"0":0;if(He.Long){var s=new He.Long(0,0,!0);i.fanout=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.fanout=n.longs===String?"0":0;i.mode=0,i.mtime=null}if(t.Type!=null&&t.hasOwnProperty("Type")&&(i.Type=n.enums===String?Un.Data.DataType[t.Type]:t.Type),t.Data!=null&&t.hasOwnProperty("Data")&&(i.Data=n.bytes===String?He.base64.encode(t.Data,0,t.Data.length):n.bytes===Array?Array.prototype.slice.call(t.Data):t.Data),t.filesize!=null&&t.hasOwnProperty("filesize")&&(typeof t.filesize=="number"?i.filesize=n.longs===String?String(t.filesize):t.filesize:i.filesize=n.longs===String?He.Long.prototype.toString.call(t.filesize):n.longs===Number?new He.LongBits(t.filesize.low>>>0,t.filesize.high>>>0).toNumber(!0):t.filesize),t.blocksizes&&t.blocksizes.length){i.blocksizes=[];for(var o=0;o<t.blocksizes.length;++o)typeof t.blocksizes[o]=="number"?i.blocksizes[o]=n.longs===String?String(t.blocksizes[o]):t.blocksizes[o]:i.blocksizes[o]=n.longs===String?He.Long.prototype.toString.call(t.blocksizes[o]):n.longs===Number?new He.LongBits(t.blocksizes[o].low>>>0,t.blocksizes[o].high>>>0).toNumber(!0):t.blocksizes[o]}return t.hashType!=null&&t.hasOwnProperty("hashType")&&(typeof t.hashType=="number"?i.hashType=n.longs===String?String(t.hashType):t.hashType:i.hashType=n.longs===String?He.Long.prototype.toString.call(t.hashType):n.longs===Number?new He.LongBits(t.hashType.low>>>0,t.hashType.high>>>0).toNumber(!0):t.hashType),t.fanout!=null&&t.hasOwnProperty("fanout")&&(typeof t.fanout=="number"?i.fanout=n.longs===String?String(t.fanout):t.fanout:i.fanout=n.longs===String?He.Long.prototype.toString.call(t.fanout):n.longs===Number?new He.LongBits(t.fanout.low>>>0,t.fanout.high>>>0).toNumber(!0):t.fanout),t.mode!=null&&t.hasOwnProperty("mode")&&(i.mode=t.mode),t.mtime!=null&&t.hasOwnProperty("mtime")&&(i.mtime=Un.UnixTime.toObject(t.mtime,n)),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,uc.default.util.toJSONOptions)},r.DataType=function(){let e={},t=Object.create(e);return t[e[0]="Raw"]=0,t[e[1]="Directory"]=1,t[e[2]="File"]=2,t[e[3]="Metadata"]=3,t[e[4]="Symlink"]=4,t[e[5]="HAMTShard"]=5,t}(),r})(),LAe=Un.UnixTime=(()=>{function r(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.Seconds=He.Long?He.Long.fromBits(0,0,!1):0,r.prototype.FractionalNanoseconds=0,r.encode=function(t,n){return n||(n=d_.create()),n.uint32(8).int64(t.Seconds),t.FractionalNanoseconds!=null&&Object.hasOwnProperty.call(t,"FractionalNanoseconds")&&n.uint32(21).fixed32(t.FractionalNanoseconds),n},r.decode=function(t,n){t instanceof qd||(t=qd.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Un.UnixTime;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.Seconds=t.int64();break;case 2:s.FractionalNanoseconds=t.fixed32();break;default:t.skipType(o&7);break}}if(!s.hasOwnProperty("Seconds"))throw He.ProtocolError("missing required 'Seconds'",{instance:s});return s},r.fromObject=function(t){if(t instanceof Un.UnixTime)return t;var n=new Un.UnixTime;return t.Seconds!=null&&(He.Long?(n.Seconds=He.Long.fromValue(t.Seconds)).unsigned=!1:typeof t.Seconds=="string"?n.Seconds=parseInt(t.Seconds,10):typeof t.Seconds=="number"?n.Seconds=t.Seconds:typeof t.Seconds=="object"&&(n.Seconds=new He.LongBits(t.Seconds.low>>>0,t.Seconds.high>>>0).toNumber())),t.FractionalNanoseconds!=null&&(n.FractionalNanoseconds=t.FractionalNanoseconds>>>0),n},r.toObject=function(t,n){n||(n={});var i={};if(n.defaults){if(He.Long){var s=new He.Long(0,0,!1);i.Seconds=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.Seconds=n.longs===String?"0":0;i.FractionalNanoseconds=0}return t.Seconds!=null&&t.hasOwnProperty("Seconds")&&(typeof t.Seconds=="number"?i.Seconds=n.longs===String?String(t.Seconds):t.Seconds:i.Seconds=n.longs===String?He.Long.prototype.toString.call(t.Seconds):n.longs===Number?new He.LongBits(t.Seconds.low>>>0,t.Seconds.high>>>0).toNumber():t.Seconds),t.FractionalNanoseconds!=null&&t.hasOwnProperty("FractionalNanoseconds")&&(i.FractionalNanoseconds=t.FractionalNanoseconds),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,uc.default.util.toJSONOptions)},r})(),BAe=Un.Metadata=(()=>{function r(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.MimeType="",r.encode=function(t,n){return n||(n=d_.create()),t.MimeType!=null&&Object.hasOwnProperty.call(t,"MimeType")&&n.uint32(10).string(t.MimeType),n},r.decode=function(t,n){t instanceof qd||(t=qd.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Un.Metadata;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.MimeType=t.string();break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof Un.Metadata)return t;var n=new Un.Metadata;return t.MimeType!=null&&(n.MimeType=String(t.MimeType)),n},r.toObject=function(t,n){n||(n={});var i={};return n.defaults&&(i.MimeType=""),t.MimeType!=null&&t.hasOwnProperty("MimeType")&&(i.MimeType=t.MimeType),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,uc.default.util.toJSONOptions)},r})();var fc=gk,wk=["raw","directory","file","metadata","symlink","hamt-sharded-directory"],qfe=["directory","hamt-sharded-directory"],Ek=parseInt("0644",8),bk=parseInt("0755",8);function hc(r){if(r!=null)return typeof r=="number"?r&4095:(r=r.toString(),r.substring(0,1)==="0"?parseInt(r,8)&4095:parseInt(r,10)&4095)}function Ll(r){if(r==null)return;let e;if(r.secs!=null&&(e={secs:r.secs,nsecs:r.nsecs}),r.Seconds!=null&&(e={secs:r.Seconds,nsecs:r.FractionalNanoseconds}),Array.isArray(r)&&(e={secs:r[0],nsecs:r[1]}),r instanceof Date){let t=r.getTime(),n=Math.floor(t/1e3);e={secs:n,nsecs:(t-n*1e3)*1e3}}if(!!Object.prototype.hasOwnProperty.call(e,"secs")){if(e!=null&&e.nsecs!=null&&(e.nsecs<0||e.nsecs>999999999))throw(0,G3.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}var Je=class{static unmarshal(e){let t=fc.decode(e),n=fc.toObject(t,{defaults:!1,arrays:!0,longs:Number,objects:!1}),i=new Je({type:wk[n.Type],data:n.Data,blockSizes:n.blocksizes,mode:n.mode,mtime:n.mtime?{secs:n.mtime.Seconds,nsecs:n.mtime.FractionalNanoseconds}:void 0});return i._originalMode=n.mode||0,i}constructor(e={type:"file"}){let{type:t,data:n,blockSizes:i,hashType:s,fanout:o,mtime:a,mode:c}=e;if(t&&!wk.includes(t))throw(0,G3.default)(new Error("Type: "+t+" is not valid"),"ERR_INVALID_TYPE");this.type=t||"file",this.data=n,this.hashType=s,this.fanout=o,this.blockSizes=i||[],this._originalMode=0,this.mode=hc(c),a&&(this.mtime=Ll(a),this.mtime&&!this.mtime.nsecs&&(this.mtime.nsecs=0))}set mode(e){this._mode=this.isDirectory()?bk:Ek;let t=hc(e);t!==void 0&&(this._mode=t)}get mode(){return this._mode}isDirectory(){return Boolean(this.type&&qfe.includes(this.type))}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0;let e=0;return this.blockSizes.forEach(t=>{e+=t}),this.data&&(e+=this.data.length),e}marshal(){let e;switch(this.type){case"raw":e=fc.DataType.Raw;break;case"directory":e=fc.DataType.Directory;break;case"file":e=fc.DataType.File;break;case"metadata":e=fc.DataType.Metadata;break;case"symlink":e=fc.DataType.Symlink;break;case"hamt-sharded-directory":e=fc.DataType.HAMTShard;break;default:throw(0,G3.default)(new Error("Type: "+e+" is not valid"),"ERR_INVALID_TYPE")}let t=this.data;(!this.data||!this.data.length)&&(t=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(hc(this.mode)||0),n===Ek&&!this.isDirectory()&&(n=void 0),n===bk&&this.isDirectory()&&(n=void 0));let i;if(this.mtime!=null){let o=Ll(this.mtime);o&&(i={Seconds:o.secs,FractionalNanoseconds:o.nsecs},i.FractionalNanoseconds===0&&delete i.FractionalNanoseconds)}let s={Type:e,Data:t,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i};return fc.encode(s).finish()}};var _t={};Kt(_t,{code:()=>at,createLink:()=>Bk,createNode:()=>Lk,decode:()=>vt,encode:()=>Xe,name:()=>xhe,prepare:()=>Tn,validate:()=>g_});u();u();u();u();var zfe=Sk,vk=128,$fe=127,Hfe=~$fe,Gfe=Math.pow(2,31);function Sk(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Gfe;)e[t++]=r&255|vk,r/=128;for(;r&Hfe;)e[t++]=r&255|vk,r>>>=7;return e[t]=r|0,Sk.bytes=t-n+1,e}var jfe=p_,Wfe=128,_k=127;function p_(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw p_.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&_k)<<i:(o&_k)*Math.pow(2,i),i+=7}while(o>=Wfe);return p_.bytes=s-n,t}var Yfe=Math.pow(2,7),Qfe=Math.pow(2,14),Xfe=Math.pow(2,21),Zfe=Math.pow(2,28),Jfe=Math.pow(2,35),ehe=Math.pow(2,42),the=Math.pow(2,49),rhe=Math.pow(2,56),nhe=Math.pow(2,63),ihe=function(r){return r<Yfe?1:r<Qfe?2:r<Xfe?3:r<Zfe?4:r<Jfe?5:r<ehe?6:r<the?7:r<rhe?8:r<nhe?9:10},she={encode:zfe,decode:jfe,encodingLength:ihe},ohe=she,B1=ohe;var M1=(r,e=0)=>[B1.decode(r,e),B1.decode.bytes],zd=(r,e,t=0)=>(B1.encode(r,e,t),e),$d=r=>B1.encodingLength(r);u();var la=(r,e)=>{let t=e.byteLength,n=$d(r),i=n+$d(t),s=new Uint8Array(i+t);return zd(r,s,0),zd(t,s,n),s.set(e,i),new Hd(r,t,e,s)},nr=r=>{let e=_s(r),[t,n]=M1(e),[i,s]=M1(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new Hd(t,i,o,e)},xk=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&Bv(r.bytes,e.bytes),Hd=class{constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var A=class{constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Y3,byteLength:Y3,code:W3,version:W3,multihash:W3,bytes:W3,_baseCache:Y3,asCID:Y3})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==U1)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==uhe)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return A.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=la(e,t);return A.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&xk(this.multihash,e.multihash)}toString(e){let{bytes:t,version:n,_baseCache:i}=this;switch(n){case 0:return che(t,i,e||Ue.encoder);default:return lhe(t,i,e||mt.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return hhe(/^0\.0/,dhe),!!(e&&(e[Ik]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof A)return e;if(e!=null&&e.asCID===e){let{version:t,code:n,multihash:i,bytes:s}=e;return new A(t,n,i,s||Tk(t,n,i.bytes))}else if(e!=null&&e[Ik]===!0){let{version:t,multihash:n,code:i}=e,s=nr(n);return A.create(t,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==U1)throw new Error(`Version 0 CID must use dag-pb (code: ${U1}) block encoding`);return new A(e,t,n,n.bytes)}case 1:{let i=Tk(e,t,n.bytes);return new A(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return A.create(0,U1,e)}static createV1(e,t){return A.create(1,e,t)}static decode(e){let[t,n]=A.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=A.inspectBytes(e),n=t.size-t.multihashSize,i=_s(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=i.subarray(t.multihashSize-t.digestSize),o=new Hd(t.multihashCode,t.digestSize,s,i);return[t.version===0?A.createV0(o):A.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[h,p]=M1(e.subarray(t));return t+=p,h},i=n(),s=U1;if(i===18?(i=0,t=0):i===1&&(s=n()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=t,a=n(),c=n(),l=t+c,f=l-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(e,t){let[n,i]=ahe(e,t),s=A.decode(i);return s._baseCache.set(n,e),s}},ahe=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ue;return[Ue.prefix,t.decode(`${Ue.prefix}${r}`)]}case Ue.prefix:{let t=e||Ue;return[Ue.prefix,t.decode(r)]}case mt.prefix:{let t=e||mt;return[mt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},che=(r,e,t)=>{let{prefix:n}=t;if(n!==Ue.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return i},lhe=(r,e,t)=>{let{prefix:n}=t,i=e.get(n);if(i==null){let s=t.encode(r);return e.set(n,s),s}else return i},U1=112,uhe=18,Tk=(r,e,t)=>{let n=$d(r),i=n+$d(e),s=new Uint8Array(i+t.byteLength);return zd(r,s,0),zd(e,s,n),s.set(t,i),s},Ik=Symbol.for("@ipld/js-cid/CID"),W3={writable:!1,configurable:!1,enumerable:!0},Y3={writable:!1,enumerable:!1,configurable:!1},fhe="0.0.0-dev",hhe=(r,e)=>{if(r.test(fhe))console.warn(e);else throw new Error(e)},dhe=`CID.isCID(v) is deprecated and will be removed in the next major release.
Following code pattern:
if (CID.isCID(value)) {
doSomethingWithCID(value)
}
Is replaced with:
const cid = CID.asCID(value)
if (cid) {
// Make sure to use cid instead of value
doSomethingWithCID(cid)
}
`;u();var phe=new TextDecoder;function m_(r,e){let t=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=r.length)throw new Error("protobuf: unexpected end of data");let i=r[e++];if(t+=n<28?(i&127)<<n:(i&127)*2**n,i<128)break}return[t,e]}function Q3(r,e){let t;[t,e]=m_(r,e);let n=e+t;if(t<0||n<0)throw new Error("protobuf: invalid length");if(n>r.length)throw new Error("protobuf: unexpected end of data");return[r.subarray(e,n),n]}function Ak(r,e){let t;return[t,e]=m_(r,e),[t&7,t>>3,e]}function mhe(r){let e={},t=r.length,n=0;for(;n<t;){let i,s;if([i,s,n]=Ak(r,n),s===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=Q3(r,n)}else if(s===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let o;[o,n]=Q3(r,n),e.Name=phe.decode(o)}else if(s===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[e.Tsize,n]=m_(r,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${s}`)}if(n>t)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function Rk(r){let e=r.length,t=0,n,i=!1,s;for(;t<e;){let a,c;if([a,c,t]=Ak(r,t),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(c===1){if(s)throw new Error("protobuf: (PBNode) duplicate Data section");[s,t]=Q3(r,t),n&&(i=!0)}else if(c===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let l;[l,t]=Q3(r,t),n.push(mhe(l))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(t>e)throw new Error("protobuf: (PBNode) unexpected end of data");let o={};return s&&(o.Data=s),o.Links=n||[],o}u();var Pk=new TextEncoder,Ck=2**32,yhe=2**31;function ghe(r,e){let t=e.length;if(typeof r.Tsize=="number"){if(r.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(r.Tsize))throw new Error("Tsize too large for encoding");t=F1(e,t,r.Tsize)-1,e[t]=24}if(typeof r.Name=="string"){let n=Pk.encode(r.Name);t-=n.length,e.set(n,t),t=F1(e,t,n.length)-1,e[t]=18}return r.Hash&&(t-=r.Hash.length,e.set(r.Hash,t),t=F1(e,t,r.Hash.length)-1,e[t]=10),e.length-t}function Dk(r){let e=Ehe(r),t=new Uint8Array(e),n=e;if(r.Data&&(n-=r.Data.length,t.set(r.Data,n),n=F1(t,n,r.Data.length)-1,t[n]=10),r.Links)for(let i=r.Links.length-1;i>=0;i--){let s=ghe(r.Links[i],t.subarray(0,n));n-=s,n=F1(t,n,s)-1,t[n]=18}return t}function whe(r){let e=0;if(r.Hash){let t=r.Hash.length;e+=1+t+Gd(t)}if(typeof r.Name=="string"){let t=Pk.encode(r.Name).length;e+=1+t+Gd(t)}return typeof r.Tsize=="number"&&(e+=1+Gd(r.Tsize)),e}function Ehe(r){let e=0;if(r.Data){let t=r.Data.length;e+=1+t+Gd(t)}if(r.Links)for(let t of r.Links){let n=whe(t);e+=1+n+Gd(n)}return e}function F1(r,e,t){e-=Gd(t);let n=e;for(;t>=yhe;)r[e++]=t&127|128,t/=128;for(;t>=128;)r[e++]=t&127|128,t>>>=7;return r[e]=t,n}function Gd(r){return r%2===0&&r++,Math.floor((bhe(r)+6)/7)}function bhe(r){let e=0;return r>=Ck&&(r=Math.floor(r/Ck),e=32),r>=1<<16&&(r>>>=16,e+=16),r>=1<<8&&(r>>>=8,e+=8),e+vhe[r]}var vhe=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];u();var _he=["Data","Links"],She=["Hash","Name","Tsize"],y_=new TextEncoder;function kk(r,e){if(r===e)return 0;let t=r.Name?y_.encode(r.Name):[],n=e.Name?y_.encode(e.Name):[],i=t.length,s=n.length;for(let o=0,a=Math.min(i,s);o<a;++o)if(t[o]!==n[o]){i=t[o],s=n[o];break}return i<s?-1:s<i?1:0}function Ok(r,e){return!Object.keys(r).some(t=>!e.includes(t))}function Nk(r){if(typeof r.asCID=="object"){let t=A.asCID(r);if(!t)throw new TypeError("Invalid DAG-PB form");return{Hash:t}}if(typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");let e={};if(r.Hash){let t=A.asCID(r.Hash);try{t||(typeof r.Hash=="string"?t=A.parse(r.Hash):r.Hash instanceof Uint8Array&&(t=A.decode(r.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}t&&(e.Hash=t)}if(!e.Hash)throw new TypeError("Invalid DAG-PB form");return typeof r.Name=="string"&&(e.Name=r.Name),typeof r.Tsize=="number"&&(e.Tsize=r.Tsize),e}function Tn(r){if((r instanceof Uint8Array||typeof r=="string")&&(r={Data:r}),typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");let e={};if(r.Data!==void 0)if(typeof r.Data=="string")e.Data=y_.encode(r.Data);else if(r.Data instanceof Uint8Array)e.Data=r.Data;else throw new TypeError("Invalid DAG-PB form");if(r.Links!==void 0)if(Array.isArray(r.Links))e.Links=r.Links.map(Nk),e.Links.sort(kk);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function g_(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");if(!Ok(r,_he))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(r.Data!==void 0&&!(r.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be a Uint8Array)");if(!Array.isArray(r.Links))throw new TypeError("Invalid DAG-PB form (Links must be an array)");for(let e=0;e<r.Links.length;e++){let t=r.Links[e];if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form (bad link object)");if(!Ok(t,She))throw new TypeError("Invalid DAG-PB form (extraneous properties on link object)");if(!t.Hash)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(t.Hash.asCID!==t.Hash)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(t.Name!==void 0&&typeof t.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(t.Tsize!==void 0&&(typeof t.Tsize!="number"||t.Tsize%1!==0))throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(e>0&&kk(t,r.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Lk(r,e=[]){return Tn({Data:r,Links:e})}function Bk(r,e,t){return Nk({Hash:t,Name:r,Tsize:e})}var xhe="dag-pb",at=112;function Xe(r){g_(r);let e={};return r.Links&&(e.Links=r.Links.map(t=>{let n={};return t.Hash&&(n.Hash=t.Hash.bytes),t.Name!==void 0&&(n.Name=t.Name),t.Tsize!==void 0&&(n.Tsize=t.Tsize),n})),r.Data&&(e.Data=r.Data),Dk(e)}function vt(r){let e=Rk(r),t={};return e.Data&&(t.Data=e.Data),e.Links&&(t.Links=e.Links.map(n=>{let i={};try{i.Hash=A.decode(n.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(i.Name=n.Name),n.Tsize!==void 0&&(i.Tsize=n.Tsize),i})),t}var mc={};Kt(mc,{code:()=>j1,decode:()=>Df,encode:()=>W1,name:()=>nde});u();u();u();u();var The=["string","number","bigint","symbol"],Ihe=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Mk(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(The.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Ahe(r))return"Buffer";let t=Rhe(r);return t||"Object"}function Ahe(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Rhe(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Ihe.includes(e))return e}u();var L=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};L.uint=new L(0,"uint",!0);L.negint=new L(1,"negint",!0);L.bytes=new L(2,"bytes",!0);L.string=new L(3,"string",!0);L.array=new L(4,"array",!1);L.map=new L(5,"map",!1);L.tag=new L(6,"tag",!1);L.float=new L(7,"float",!0);L.false=new L(7,"false",!0);L.true=new L(7,"true",!0);L.null=new L(7,"null",!0);L.undefined=new L(7,"undefined",!0);L.break=new L(7,"break",!0);var J=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};u();u();var jd=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Che=new TextDecoder,Phe=new TextEncoder;function X3(r){return jd&&globalThis.Buffer.isBuffer(r)}function V1(r){return r instanceof Uint8Array?X3(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Kk=jd?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Fk(r,e,t):(r,e,t)=>t-e>64?Che.decode(r.subarray(e,t)):Fk(r,e,t),Z3=jd?r=>r.length>64?globalThis.Buffer.from(r):Uk(r):r=>r.length>64?Phe.encode(r):Uk(r),ua=r=>Uint8Array.from(r),Wd=jd?(r,e,t)=>X3(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),qk=jd?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),V1(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let i of r)n+i.length>t.length&&(i=i.subarray(0,t.length-n)),t.set(i,n),n+=i.length;return t},zk=jd?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function $k(r,e){if(X3(r)&&X3(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Uk(r,e=1/0){let t,n=r.length,i=null,s=[];for(let o=0;o<n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Fk(r,e,t){let n=[];for(;e<t;){let i=r[e],s=null,o=i>239?4:i>223?3:i>191?2:1;if(e+o<=t){let a,c,l,f;switch(o){case 1:i<128&&(s=i);break;case 2:a=r[e+1],(a&192)===128&&(f=(i&31)<<6|a&63,f>127&&(s=f));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(f=(i&15)<<12|(a&63)<<6|c&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:a=r[e+1],c=r[e+2],l=r[e+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(f=(i&15)<<18|(a&63)<<12|(c&63)<<6|l&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=o}return w_(n)}var Vk=4096;function w_(r){let e=r.length;if(e<=Vk)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Vk));return t}var Dhe=256,K1=class{constructor(e=Dhe){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=t.length-(this.maxCursor-this.cursor)-1;t.set(e,i)}else{if(t){let i=t.length-(this.maxCursor-this.cursor)-1;i<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=zk(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Wd(n,0,this.cursor)}else t=qk(this.chunks,this.cursor);return e&&this.reset(),t}};u();var ve="CBOR decode error:",dc="CBOR encode error:",q1=[];q1[23]=1;q1[24]=2;q1[25]=3;q1[26]=5;q1[27]=9;function pc(r,e,t){if(r.length-e<t)throw new Error(`${ve} not enough data for type`)}u();u();var In=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Bi(r,e,t){pc(r,e,1);let n=r[e];if(t.strict===!0&&n<In[0])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function Mi(r,e,t){pc(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<In[1])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function Ui(r,e,t){pc(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<In[2])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function Fi(r,e,t){pc(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],i=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],s=(BigInt(n)<<BigInt(32))+BigInt(i);if(t.strict===!0&&s<In[3])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(t.allowBigInt===!0)return s;throw new Error(`${ve} integers outside of the safe integer range are not supported`)}function Hk(r,e,t,n){return new J(L.uint,Bi(r,e+1,n),2)}function Gk(r,e,t,n){return new J(L.uint,Mi(r,e+1,n),3)}function jk(r,e,t,n){return new J(L.uint,Ui(r,e+1,n),5)}function Wk(r,e,t,n){return new J(L.uint,Fi(r,e+1,n),9)}function xs(r,e){return Vn(r,0,e.value)}function Vn(r,e,t){if(t<In[0]){let n=Number(t);r.push([e|n])}else if(t<In[1]){let n=Number(t);r.push([e|24,n])}else if(t<In[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<In[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<In[4]){let i=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),o=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=s&255,s=s>>8,i[7]=s&255,s=s>>8,i[6]=s&255,s=s>>8,i[5]=s&255,i[4]=o&255,o=o>>8,i[3]=o&255,o=o>>8,i[2]=o&255,o=o>>8,i[1]=o&255,r.push(i)}else throw new Error(`${ve} encountered BigInt larger than allowable range`)}}xs.encodedSize=function(e){return Vn.encodedSize(e.value)};Vn.encodedSize=function(e){return e<In[0]?1:e<In[1]?2:e<In[2]?3:e<In[3]?5:9};xs.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};u();function Yk(r,e,t,n){return new J(L.negint,-1-Bi(r,e+1,n),2)}function Qk(r,e,t,n){return new J(L.negint,-1-Mi(r,e+1,n),3)}function Xk(r,e,t,n){return new J(L.negint,-1-Ui(r,e+1,n),5)}var E_=BigInt(-1),Zk=BigInt(1);function Jk(r,e,t,n){let i=Fi(r,e+1,n);if(typeof i!="bigint"){let s=-1-i;if(s>=Number.MIN_SAFE_INTEGER)return new J(L.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${ve} integers outside of the safe integer range are not supported`);return new J(L.negint,E_-BigInt(i),9)}function J3(r,e){let t=e.value,n=typeof t=="bigint"?t*E_-Zk:t*-1-1;Vn(r,e.type.majorEncoded,n)}J3.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*E_-Zk:t*-1-1;return n<In[0]?1:n<In[1]?2:n<In[2]?3:n<In[3]?5:9};J3.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};u();function z1(r,e,t,n){pc(r,e,t+n);let i=Wd(r,e+t,e+t+n);return new J(L.bytes,i,t+n)}function eN(r,e,t,n){return z1(r,e,1,t)}function tN(r,e,t,n){return z1(r,e,2,Bi(r,e+1,n))}function rN(r,e,t,n){return z1(r,e,3,Mi(r,e+1,n))}function nN(r,e,t,n){return z1(r,e,5,Ui(r,e+1,n))}function iN(r,e,t,n){let i=Fi(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer bytes lengths not supported`);return z1(r,e,9,i)}function e4(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===L.string?Z3(r.value):r.value),r.encodedBytes}function Yd(r,e){let t=e4(e);Vn(r,e.type.majorEncoded,t.length),r.push(t)}Yd.encodedSize=function(e){let t=e4(e);return Vn.encodedSize(t.length)+t.length};Yd.compareTokens=function(e,t){return khe(e4(e),e4(t))};function khe(r,e){return r.length<e.length?-1:r.length>e.length?1:$k(r,e)}u();function $1(r,e,t,n,i){let s=t+n;pc(r,e,s);let o=new J(L.string,Kk(r,e+t,e+s),s);return i.retainStringBytes===!0&&(o.byteValue=Wd(r,e+t,e+s)),o}function sN(r,e,t,n){return $1(r,e,1,t,n)}function oN(r,e,t,n){return $1(r,e,2,Bi(r,e+1,n),n)}function aN(r,e,t,n){return $1(r,e,3,Mi(r,e+1,n),n)}function cN(r,e,t,n){return $1(r,e,5,Ui(r,e+1,n),n)}function lN(r,e,t,n){let i=Fi(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer string lengths not supported`);return $1(r,e,9,i,n)}var uN=Yd;u();function Qd(r,e,t,n){return new J(L.array,n,t)}function fN(r,e,t,n){return Qd(r,e,1,t)}function hN(r,e,t,n){return Qd(r,e,2,Bi(r,e+1,n))}function dN(r,e,t,n){return Qd(r,e,3,Mi(r,e+1,n))}function pN(r,e,t,n){return Qd(r,e,5,Ui(r,e+1,n))}function mN(r,e,t,n){let i=Fi(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer array lengths not supported`);return Qd(r,e,9,i)}function yN(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return Qd(r,e,1,1/0)}function t4(r,e){Vn(r,L.array.majorEncoded,e.value)}t4.compareTokens=xs.compareTokens;t4.encodedSize=function(e){return Vn.encodedSize(e.value)};u();function Xd(r,e,t,n){return new J(L.map,n,t)}function gN(r,e,t,n){return Xd(r,e,1,t)}function wN(r,e,t,n){return Xd(r,e,2,Bi(r,e+1,n))}function EN(r,e,t,n){return Xd(r,e,3,Mi(r,e+1,n))}function bN(r,e,t,n){return Xd(r,e,5,Ui(r,e+1,n))}function vN(r,e,t,n){let i=Fi(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer map lengths not supported`);return Xd(r,e,9,i)}function _N(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return Xd(r,e,1,1/0)}function r4(r,e){Vn(r,L.map.majorEncoded,e.value)}r4.compareTokens=xs.compareTokens;r4.encodedSize=function(e){return Vn.encodedSize(e.value)};u();function SN(r,e,t,n){return new J(L.tag,t,1)}function xN(r,e,t,n){return new J(L.tag,Bi(r,e+1,n),2)}function TN(r,e,t,n){return new J(L.tag,Mi(r,e+1,n),3)}function IN(r,e,t,n){return new J(L.tag,Ui(r,e+1,n),5)}function AN(r,e,t,n){return new J(L.tag,Fi(r,e+1,n),9)}function n4(r,e){Vn(r,L.tag.majorEncoded,e.value)}n4.compareTokens=xs.compareTokens;n4.encodedSize=function(e){return Vn.encodedSize(e.value)};u();var Fhe=20,Vhe=21,Khe=22,qhe=23;function RN(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${ve} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new J(L.null,null,1):new J(L.undefined,void 0,1)}function CN(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return new J(L.break,void 0,1)}function b_(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${ve} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${ve} Infinity values are not supported`)}return new J(L.float,r,e)}function PN(r,e,t,n){return b_(v_(r,e+1),3,n)}function DN(r,e,t,n){return b_(__(r,e+1),5,n)}function ON(r,e,t,n){return b_(BN(r,e+1),9,n)}function i4(r,e,t){let n=e.value;if(n===!1)r.push([L.float.majorEncoded|Fhe]);else if(n===!0)r.push([L.float.majorEncoded|Vhe]);else if(n===null)r.push([L.float.majorEncoded|Khe]);else if(n===void 0)r.push([L.float.majorEncoded|qhe]);else{let i,s=!1;(!t||t.float64!==!0)&&(NN(n),i=v_(oo,1),n===i||Number.isNaN(n)?(oo[0]=249,r.push(oo.slice(0,3)),s=!0):(LN(n),i=__(oo,1),n===i&&(oo[0]=250,r.push(oo.slice(0,5)),s=!0))),s||(zhe(n),i=BN(oo,1),oo[0]=251,r.push(oo.slice(0,9)))}}i4.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){NN(n);let i=v_(oo,1);if(n===i||Number.isNaN(n))return 3;if(LN(n),i=__(oo,1),n===i)return 5}return 9};var kN=new ArrayBuffer(9),Ts=new DataView(kN,1),oo=new Uint8Array(kN,0);function NN(r){if(r===1/0)Ts.setUint16(0,31744,!1);else if(r===-1/0)Ts.setUint16(0,64512,!1);else if(Number.isNaN(r))Ts.setUint16(0,32256,!1);else{Ts.setFloat32(0,r);let e=Ts.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Ts.setUint16(0,31744,!1);else if(t===0)Ts.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let i=t-127;i<-24?Ts.setUint16(0,0):i<-14?Ts.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Ts.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function v_(r,e){if(r.length-e<2)throw new Error(`${ve} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,i=t&1023,s;return n===0?s=i*2**-24:n!==31?s=(i+1024)*2**(n-25):s=i===0?1/0:NaN,t&32768?-s:s}function LN(r){Ts.setFloat32(0,r,!1)}function __(r,e){if(r.length-e<4)throw new Error(`${ve} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function zhe(r){Ts.setFloat64(0,r,!1)}function BN(r,e){if(r.length-e<8)throw new Error(`${ve} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}i4.compareTokens=xs.compareTokens;function Lt(r,e,t){throw new Error(`${ve} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function s4(r){return()=>{throw new Error(`${ve} ${r}`)}}var ue=[];for(let r=0;r<=23;r++)ue[r]=Lt;ue[24]=Hk;ue[25]=Gk;ue[26]=jk;ue[27]=Wk;ue[28]=Lt;ue[29]=Lt;ue[30]=Lt;ue[31]=Lt;for(let r=32;r<=55;r++)ue[r]=Lt;ue[56]=Yk;ue[57]=Qk;ue[58]=Xk;ue[59]=Jk;ue[60]=Lt;ue[61]=Lt;ue[62]=Lt;ue[63]=Lt;for(let r=64;r<=87;r++)ue[r]=eN;ue[88]=tN;ue[89]=rN;ue[90]=nN;ue[91]=iN;ue[92]=Lt;ue[93]=Lt;ue[94]=Lt;ue[95]=s4("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)ue[r]=sN;ue[120]=oN;ue[121]=aN;ue[122]=cN;ue[123]=lN;ue[124]=Lt;ue[125]=Lt;ue[126]=Lt;ue[127]=s4("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)ue[r]=fN;ue[152]=hN;ue[153]=dN;ue[154]=pN;ue[155]=mN;ue[156]=Lt;ue[157]=Lt;ue[158]=Lt;ue[159]=yN;for(let r=160;r<=183;r++)ue[r]=gN;ue[184]=wN;ue[185]=EN;ue[186]=bN;ue[187]=vN;ue[188]=Lt;ue[189]=Lt;ue[190]=Lt;ue[191]=_N;for(let r=192;r<=215;r++)ue[r]=SN;ue[216]=xN;ue[217]=TN;ue[218]=IN;ue[219]=AN;ue[220]=Lt;ue[221]=Lt;ue[222]=Lt;ue[223]=Lt;for(let r=224;r<=243;r++)ue[r]=s4("simple values are not supported");ue[244]=Lt;ue[245]=Lt;ue[246]=Lt;ue[247]=RN;ue[248]=s4("simple values are not supported");ue[249]=PN;ue[250]=DN;ue[251]=ON;ue[252]=Lt;ue[253]=Lt;ue[254]=Lt;ue[255]=CN;var ao=[];for(let r=0;r<24;r++)ao[r]=new J(L.uint,r,1);for(let r=-1;r>=-24;r--)ao[31-r]=new J(L.negint,r,1);ao[64]=new J(L.bytes,new Uint8Array(0),1);ao[96]=new J(L.string,"",1);ao[128]=new J(L.array,0,1);ao[160]=new J(L.map,0,1);ao[244]=new J(L.false,!1,1);ao[245]=new J(L.true,!0,1);ao[246]=new J(L.null,null,1);function MN(r){switch(r.type){case L.false:return ua([244]);case L.true:return ua([245]);case L.null:return ua([246]);case L.bytes:return r.value.length?void 0:ua([64]);case L.string:return r.value===""?ua([96]):void 0;case L.array:return r.value===0?ua([128]):void 0;case L.map:return r.value===0?ua([160]):void 0;case L.uint:return r.value<24?ua([Number(r.value)]):void 0;case L.negint:if(r.value>=-24)return ua([31-Number(r.value)])}}var Hhe={float64:!1,mapSorter:Whe,quickEncodeToken:MN};function Ghe(){let r=[];return r[L.uint.major]=xs,r[L.negint.major]=J3,r[L.bytes.major]=Yd,r[L.string.major]=uN,r[L.array.major]=t4,r[L.map.major]=r4,r[L.tag.major]=n4,r[L.float.major]=i4,r}var UN=Ghe(),S_=new K1,Zd=class{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${dc} object contains circular references`);return new Zd(t,e)}},Bl={null:new J(L.null,null),undefined:new J(L.undefined,void 0),true:new J(L.true,!0),false:new J(L.false,!1),emptyArray:new J(L.array,0),emptyMap:new J(L.map,0)},Ml={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new J(L.float,r):r>=0?new J(L.uint,r):new J(L.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new J(L.uint,r):new J(L.negint,r)},Uint8Array(r,e,t,n){return new J(L.bytes,r)},string(r,e,t,n){return new J(L.string,r)},boolean(r,e,t,n){return r?Bl.true:Bl.false},null(r,e,t,n){return Bl.null},undefined(r,e,t,n){return Bl.undefined},ArrayBuffer(r,e,t,n){return new J(L.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new J(L.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Bl.emptyArray,new J(L.break)]:Bl.emptyArray;n=Zd.createCheck(n,r);let i=[],s=0;for(let o of r)i[s++]=o4(o,t,n);return t.addBreakTokens?[new J(L.array,r.length),i,new J(L.break)]:[new J(L.array,r.length),i]},Object(r,e,t,n){let i=e!=="Object",s=i?r.keys():Object.keys(r),o=i?r.size:s.length;if(!o)return t.addBreakTokens===!0?[Bl.emptyMap,new J(L.break)]:Bl.emptyMap;n=Zd.createCheck(n,r);let a=[],c=0;for(let l of s)a[c++]=[o4(l,t,n),o4(i?r.get(l):r[l],t,n)];return jhe(a,t),t.addBreakTokens?[new J(L.map,o),a,new J(L.break)]:[new J(L.map,o),a]}};Ml.Map=Ml.Object;Ml.Buffer=Ml.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ml[`${r}Array`]=Ml.DataView;function o4(r,e={},t){let n=Mk(r),i=e&&e.typeEncoders&&e.typeEncoders[n]||Ml[n];if(typeof i=="function"){let o=i(r,n,e,t);if(o!=null)return o}let s=Ml[n];if(!s)throw new Error(`${dc} unsupported type: ${n}`);return s(r,n,e,t)}function jhe(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Whe(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let i=t.type.major,s=UN[i].compareTokens(t,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function FN(r,e,t,n){if(Array.isArray(e))for(let i of e)FN(r,i,t,n);else t[e.type.major](r,e,n)}function x_(r,e,t){let n=o4(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let i=t.quickEncodeToken(n);if(i)return i;let s=e[n.type.major];if(s.encodedSize){let o=s.encodedSize(n,t),a=new K1(o);if(s(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return V1(a.chunks[0])}}return S_.reset(),FN(S_,n,e,t),S_.toBytes(!0)}function co(r,e){return e=Object.assign({},Hhe,e),x_(r,UN,e)}u();var Yhe={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},T_=class{constructor(e,t={}){this.pos=0,this.data=e,this.options=t}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],t=ao[e];if(t===void 0){let n=ue[e];if(!n)throw new Error(`${ve} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;t=n(this.data,this.pos,i,this.options)}return this.pos+=t.encodedLength,t}},H1=Symbol.for("DONE"),a4=Symbol.for("BREAK");function Qhe(r,e,t){let n=[];for(let i=0;i<r.value;i++){let s=G1(e,t);if(s===a4){if(r.value===1/0)break;throw new Error(`${ve} got unexpected break to lengthed array`)}if(s===H1)throw new Error(`${ve} found array but not enough entries (got ${i}, expected ${r.value})`);n[i]=s}return n}function Xhe(r,e,t){let n=t.useMaps===!0,i=n?void 0:{},s=n?new Map:void 0;for(let o=0;o<r.value;o++){let a=G1(e,t);if(a===a4){if(r.value===1/0)break;throw new Error(`${ve} got unexpected break to lengthed map`)}if(a===H1)throw new Error(`${ve} found map but not enough entries (got ${o} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ve} non-string keys not supported (got ${typeof a})`);let c=G1(e,t);if(c===H1)throw new Error(`${ve} found map but not enough entries (got ${o} [no value], expected ${r.value})`);n?s.set(a,c):i[a]=c}return n?s:i}function G1(r,e){if(r.done())return H1;let t=r.next();if(t.type===L.break)return a4;if(t.type.terminal)return t.value;if(t.type===L.array)return Qhe(t,r,e);if(t.type===L.map)return Xhe(t,r,e);if(t.type===L.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=G1(r,e);return e.tags[t.value](n)}throw new Error(`${ve} tag not supported (${t.value})`)}throw new Error("unsupported")}function jn(r,e){if(!(r instanceof Uint8Array))throw new Error(`${ve} data to decode must be a Uint8Array`);e=Object.assign({},Yhe,e);let t=e.tokenizer||new T_(r,e),n=G1(t,e);if(n===H1)throw new Error(`${ve} did not find any content to decode`);if(n===a4)throw new Error(`${ve} got unexpected break`);if(!t.done())throw new Error(`${ve} too many terminals, data makes no sense`);return n}var VN=42;function Zhe(r){if(r.asCID!==r)return null;let e=A.asCID(r);if(!e)return null;let t=new Uint8Array(e.bytes.byteLength+1);return t.set(e.bytes,1),[new J(L.tag,VN),new J(L.bytes,t)]}function Jhe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function ede(r){if(Number.isNaN(r))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(r===1/0||r===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var tde={float64:!0,typeEncoders:{Object:Zhe,undefined:Jhe,number:ede}};function rde(r){if(r[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return A.decode(r.subarray(1))}var KN={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};KN.tags[VN]=rde;var nde="dag-cbor",j1=113,W1=r=>co(r,tde),Df=r=>jn(r,KN);var tp={};Kt(tp,{code:()=>O_,decode:()=>dde,encode:()=>hde,name:()=>fde});u();u();u();var Jd=({name:r,code:e,encode:t})=>new I_(r,e,t),I_=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?la(this.code,t):t.then(n=>la(this.code,n))}else throw Error("Unknown type, must be binary type")}};u();u();var A_=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let t=this.inRecursive[this.inRecursive.length-1];t&&(t.type===L.array&&(t.elements++,t.elements!==1&&e.push([44])),t.type===L.map&&(t.elements++,t.elements!==1&&(t.elements%2===1?e.push([44]):e.push([58]))))}[L.uint.major](e,t){this.prefix(e);let n=String(t.value),i=[];for(let s=0;s<n.length;s++)i[s]=n.charCodeAt(s);e.push(i)}[L.negint.major](e,t){this[L.uint.major](e,t)}[L.bytes.major](e,t){throw new Error(`${dc} unsupported type: Uint8Array`)}[L.string.major](e,t){this.prefix(e);let n=Z3(JSON.stringify(t.value));e.push(n.length>32?V1(n):n)}[L.array.major](e,t){this.prefix(e),this.inRecursive.push({type:L.array,elements:0}),e.push([91])}[L.map.major](e,t){this.prefix(e),this.inRecursive.push({type:L.map,elements:0}),e.push([123])}[L.tag.major](e,t){}[L.float.major](e,t){if(t.type.name==="break"){let o=this.inRecursive.pop();if(o){if(o.type===L.array)e.push([93]);else if(o.type===L.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(t.value===void 0)throw new Error(`${dc} unsupported type: undefined`);if(this.prefix(e),t.type.name==="true"){e.push([116,114,117,101]);return}else if(t.type.name==="false"){e.push([102,97,108,115,101]);return}else if(t.type.name==="null"){e.push([110,117,108,108]);return}let n=String(t.value),i=[],s=!1;for(let o=0;o<n.length;o++)i[o]=n.charCodeAt(o),!s&&(i[o]===46||i[o]===101||i[o]===69)&&(s=!0);s||(i.push(46),i.push(48)),e.push(i)}};function ide(r,e){if(Array.isArray(r[0])||Array.isArray(e[0]))throw new Error(`${dc} complex map keys are not supported`);let t=r[0],n=e[0];if(t.type!==L.string||n.type!==L.string)throw new Error(`${dc} non-string map keys are not supported`);if(t<n)return-1;if(t>n)return 1;throw new Error(`${dc} unexpected duplicate map keys, this is not supported`)}var sde={addBreakTokens:!0,mapSorter:ide};function R_(r,e){return e=Object.assign({},sde,e),x_(r,new A_,e)}u();var ep=class{constructor(e,t={}){this.pos=0,this.data=e,this.options=t,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${ve} unexpected end of input at position ${this.pos}`);for(let t=0;t<e.length;t++)if(this.data[this.pos++]!==e[t])throw new Error(`${ve} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,t=!1,n=!1,i=a=>{for(;!this.done();){let c=this.ch();if(a.includes(c))this.pos++;else break}};if(this.ch()===45&&(t=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new J(L.uint,0,this.pos-e);if(i([48,49,50,51,52,53,54,55,56,57]),t&&this.pos===e+1)throw new Error(`${ve} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${ve} unexpected token at position ${this.pos}`);n=!0,this.pos++,i([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,i([48,49,50,51,52,53,54,55,56,57]));let s=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),o=parseFloat(s);return n?new J(L.float,o,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(o)?new J(o>=0?L.uint:L.negint,o,this.pos-e):new J(o>=0?L.uint:L.negint,BigInt(s),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${ve} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let s=this.pos,o=0;s<this.data.length&&o<65536;s++,o++){let a=this.data[s];if(a===92||a<32||a>=128)break;if(a===34){let c=String.fromCharCode.apply(null,this.data.subarray(this.pos,s));return this.pos=s+1,new J(L.string,c,o)}}let e=this.pos,t=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${ve} unexpected end of unicode escape sequence at position ${this.pos}`);let s=0;for(let o=0;o<4;o++){let a=this.ch();if(a>=48&&a<=57)a-=48;else if(a>=97&&a<=102)a=a-97+10;else if(a>=65&&a<=70)a=a-65+10;else throw new Error(`${ve} unexpected unicode escape character at position ${this.pos}`);s=s*16+a,this.pos++}return s},i=()=>{let s=this.ch(),o=null,a=s>239?4:s>223?3:s>191?2:1;if(this.pos+a>this.data.length)throw new Error(`${ve} unexpected unicode sequence at position ${this.pos}`);let c,l,f,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=this.data[this.pos+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=this.data[this.pos+1],l=this.data[this.pos+2],(c&192)===128&&(l&192)===128&&(h=(s&15)<<12|(c&63)<<6|l&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=this.data[this.pos+1],l=this.data[this.pos+2],f=this.data[this.pos+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(h=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,h>65535&&h<1114112&&(o=h))}o===null?(o=65533,a=1):o>65535&&(o-=65536,t.push(o>>>10&1023|55296),o=56320|o&1023),t.push(o),this.pos+=a};for(;!this.done();){let s=this.ch(),o;switch(s){case 92:if(this.pos++,this.done())throw new Error(`${ve} unexpected string termination at position ${this.pos}`);switch(o=this.ch(),this.pos++,o){case 34:case 39:case 92:case 47:t.push(o);break;case 98:t.push(8);break;case 116:t.push(9);break;case 110:t.push(10);break;case 102:t.push(12);break;case 114:t.push(13);break;case 117:t.push(n());break;default:throw new Error(`${ve} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new J(L.string,w_(t),this.pos-e);default:if(s<32)throw new Error(`${ve} invalid control character at position ${this.pos}`);s<128?(t.push(s),this.pos++):i()}}throw new Error(`${ve} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new J(L.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new J(L.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new J(L.null,null,4);case 102:return this.expect([102,97,108,115,101]),new J(L.false,!1,5);case 116:return this.expect([116,114,117,101]),new J(L.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${ve} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new J(L.break,void 0,1);if(this.ch()!==44)throw new Error(`${ve} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new J(L.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new J(L.break,void 0,1);if(this.ch()!==44)throw new Error(`${ve} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new J(L.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${ve} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${ve} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function C_(r,e){return e=Object.assign({tokenizer:new ep(r,e)},e),jn(r,e)}function ade(r){if(r.asCID!==r)return null;let e=A.asCID(r);if(!e)return null;let t=e.toString();return[new J(L.map,1/0,1),new J(L.string,"/",1),new J(L.string,t,t.length),new J(L.break,void 0,1)]}function zN(r){let e=na.encode(r).slice(1);return[new J(L.map,1/0,1),new J(L.string,"/",1),new J(L.map,1/0,1),new J(L.string,"bytes",5),new J(L.string,e,e.length),new J(L.break,void 0,1),new J(L.break,void 0,1)]}function cde(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function lde(r){if(Number.isNaN(r))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(r===1/0||r===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var ude={typeEncoders:{Object:ade,Uint8Array:zN,Buffer:zN,undefined:cde,number:lde}},P_=class extends ep{constructor(e,t){super(e,t),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===L.map){let t=this._next();if(t.type===L.string&&t.value==="/"){let n=this._next();if(n.type===L.string){if(this._next().type!==L.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new J(L.tag,42,0)}if(n.type===L.map){let i=this._next();if(i.type===L.string&&i.value==="bytes"){let s=this._next();if(s.type===L.string){for(let a=0;a<2;a++)if(this._next().type!==L.break)throw new Error("Invalid encoded Bytes form");let o=na.decode(`m${s.value}`);return new J(L.bytes,o,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(i)}this.tokenBuffer.push(n)}this.tokenBuffer.push(t)}return e}},D_={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};D_.tags[42]=A.parse;var fde="dag-json",O_=297,hde=r=>R_(r,ude),dde=r=>{let e=Object.assign(D_,{tokenizer:new P_(r,D_)});return C_(r,e)};var Y1={};Kt(Y1,{code:()=>vde,decode:()=>Tde,encode:()=>xde,name:()=>bde,toGeneral:()=>ZN});u();u();u();function lo(r){return Ol.encode(r).slice(1)}function Is(r){return Ol.decode(`u${r}`)}function $N(r){let[e,t,n]=r;return{payload:t,signatures:[{protected:e,signature:n}],link:A.decode(Is(t))}}function pde(r){let e={signature:Is(r.signature)};return r.header&&(e.header=r.header),r.protected&&(e.protected=Is(r.protected)),e}function HN(r){let e=Is(r.payload);try{A.decode(e)}catch{throw new Error("Not a valid DagJWS")}return{payload:e,signatures:r.signatures.map(pde)}}function mde(r){let e={signature:lo(r.signature)};return r.header&&(e.header=r.header),r.protected&&(e.protected=lo(r.protected)),e}function GN(r){let e={payload:lo(r.payload),signatures:r.signatures.map(mde)};return e.link=A.decode(new Uint8Array(r.payload)),e}u();function jN(r){let[e,t,n,i,s]=r,o={ciphertext:i,iv:n,protected:e,tag:s};return t&&(o.recipients=[{encrypted_key:t}]),o}function gde(r){let e={};return r.encrypted_key&&(e.encrypted_key=Is(r.encrypted_key)),r.header&&(e.header=r.header),e}function WN(r){let e={ciphertext:Is(r.ciphertext),protected:Is(r.protected),iv:Is(r.iv),tag:Is(r.tag)};return r.aad&&(e.aad=Is(r.aad)),r.recipients&&(e.recipients=r.recipients.map(gde)),r.unprotected&&(e.unprotected=r.unprotected),e}function wde(r){let e={};return r.encrypted_key&&(e.encrypted_key=lo(r.encrypted_key)),r.header&&(e.header=r.header),e}function YN(r){let e={ciphertext:lo(r.ciphertext),protected:lo(r.protected),iv:lo(r.iv),tag:lo(r.tag)};return r.aad&&(e.aad=lo(r.aad)),r.recipients&&(e.recipients=r.recipients.map(wde)),r.unprotected&&(e.unprotected=r.unprotected),e}var bde="dag-jose",vde=133;function QN(r){return"payload"in r&&typeof r.payload=="string"&&"signatures"in r&&Array.isArray(r.signatures)}function _de(r){return"payload"in r&&r.payload instanceof Uint8Array&&"signatures"in r&&Array.isArray(r.signatures)}function Sde(r){return"ciphertext"in r&&r.ciphertext instanceof Uint8Array&&"iv"in r&&r.iv instanceof Uint8Array&&"protected"in r&&r.protected instanceof Uint8Array&&"tag"in r&&r.tag instanceof Uint8Array}function XN(r){return"ciphertext"in r&&typeof r.ciphertext=="string"&&"iv"in r&&typeof r.iv=="string"&&"protected"in r&&typeof r.protected=="string"&&"tag"in r&&typeof r.tag=="string"}function ZN(r){if(typeof r=="string"){let e=r.split(".");if(e.length===3)return $N(e);if(e.length===5)return jN(e);throw new Error("Not a valid JOSE string")}if(QN(r)||XN(r))return r;throw new Error("Not a valid unencoded JOSE object")}function xde(r){typeof r=="string"&&(r=ZN(r));let e;if(QN(r))e=HN(r);else if(XN(r))e=WN(r);else throw new Error("Not a valid JOSE object");return new Uint8Array(W1(e))}function Tde(r){let e;try{e=Df(r)}catch{throw new Error("Not a valid DAG-JOSE object")}if(_de(e))return GN(e);if(Sde(e))return YN(e);throw new Error("Not a valid DAG-JOSE object")}var k_={};Kt(k_,{identity:()=>on});u();var JN=0,Ide="identity",eL=_s,Ade=r=>la(JN,eL(r)),on={code:JN,name:Ide,encode:eL,digest:Ade};u();var N_={};Kt(N_,{identity:()=>Rde});u();var Rde=Vd({prefix:"\0",name:"identity",encode:r=>Uv(r),decode:r=>Mv(r)});var L_={};Kt(L_,{base2:()=>Cde});u();var Cde=Br({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var B_={};Kt(B_,{base8:()=>Pde});u();var Pde=Br({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var M_={};Kt(M_,{base10:()=>Dde});u();var Dde=Dl({prefix:"9",name:"base10",alphabet:"0123456789"});var U_={};Kt(U_,{base16:()=>Ode,base16upper:()=>kde});u();var Ode=Br({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),kde=Br({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var F_={};Kt(F_,{base36:()=>rp,base36upper:()=>Nde});u();var rp=Dl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Nde=Dl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var V_={};Kt(V_,{base256emoji:()=>Fde});u();var tL=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Lde=tL.reduce((r,e,t)=>(r[t]=e,r),[]),Bde=tL.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Mde(r){return r.reduce((e,t)=>(e+=Lde[t],e),"")}function Ude(r){let e=[];for(let t of r){let n=Bde[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Fde=Vd({prefix:"\u{1F680}",name:"base256emoji",encode:Mde,decode:Ude});var K_={};Kt(K_,{sha256:()=>$e,sha512:()=>Vde});u();var rL=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),$e=Jd({name:"sha2-256",code:18,encode:rL("SHA-256")}),Vde=Jd({name:"sha2-512",code:19,encode:rL("SHA-512")});var bi={};Kt(bi,{code:()=>An,decode:()=>zde,encode:()=>qde,name:()=>Kde});u();var Kde="raw",An=85,qde=r=>_s(r),zde=r=>_s(r);var l4={};Kt(l4,{code:()=>q_,decode:()=>Wde,encode:()=>jde,name:()=>Gde});u();var $de=new TextEncoder,Hde=new TextDecoder,Gde="json",q_=512,jde=r=>$de.encode(JSON.stringify(r)),Wde=r=>JSON.parse(Hde.decode(r));var As={...N_,...L_,...B_,...M_,...U_,...Gv,...F_,...zv,...jv,...V_},u4={...K_,...k_},f4={raw:bi,json:l4};u();u();var yc=class extends Error{constructor(e="not initialized"){super(e),this.name="NotInitializedError",this.code=yc.code}};yc.code="ERR_NOT_INITIALIZED";var z_=class extends Error{constructor(e="cannot initialize an initializing node"){super(e),this.name="AlreadyInitializingError",this.code=uo.code}};z_.code="ERR_ALREADY_INITIALIZING";var uo=class extends Error{constructor(e="cannot re-initialize an initialized node"){super(e),this.name="AlreadyInitializedError",this.code=uo.code}};uo.code="ERR_ALREADY_INITIALIZED";var gc=class extends Error{constructor(e="not started"){super(e),this.name="NotStartedError",this.code=gc.code}};gc.code="ERR_NOT_STARTED";var Of=class extends Error{constructor(e="cannot start, already startin"){super(e),this.name="AlreadyStartingError",this.code=Of.code}};Of.code="ERR_ALREADY_STARTING";var kf=class extends Error{constructor(e="cannot start, already started"){super(e),this.name="AlreadyStartedError",this.code=kf.code}};kf.code="ERR_ALREADY_STARTED";var fo=class extends Error{constructor(e="not enabled"){super(e),this.name="NotEnabledError",this.code=fo.code}};fo.code="ERR_NOT_ENABLED";u();u();np();function iL(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var nL=iL("utf8","u",r=>{let e=new TextDecoder("utf8");return"u"+e.decode(r)},r=>new TextEncoder().encode(r.substring(1))),$_=iL("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ho(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Yde={utf8:nL,"utf-8":nL,hex:As.base16,latin1:$_,ascii:$_,binary:$_,...As},h4=Yde;function z(r,e="utf8"){let t=h4[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}var Yle=E(an(),1);u();u();u();u();u();u();u();u();u();u();var uL="[a-fA-F\\d:]",Ul=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${uL})|(?<=${uL})(?=\\s|$))`:"",po="(?: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}",cn="[a-fA-F\\d]{1,4}",p4=`
(?:
(?:${cn}:){7}(?:${cn}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:${cn}:){6}(?:${po}|:${cn}|:)| // 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
(?:${cn}:){5}(?::${po}|(?::${cn}){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
(?:${cn}:){4}(?:(?::${cn}){0,1}:${po}|(?::${cn}){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
(?:${cn}:){3}(?:(?::${cn}){0,2}:${po}|(?::${cn}){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
(?:${cn}:){2}(?:(?::${cn}){0,3}:${po}|(?::${cn}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:${cn}:){1}(?:(?::${cn}){0,4}:${po}|(?::${cn}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::${cn}){0,5}:${po}|(?::${cn}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Zde=new RegExp(`(?:^${po}$)|(?:^${p4}$)`),Jde=new RegExp(`^${po}$`),epe=new RegExp(`^${p4}$`),G_=r=>r&&r.exact?Zde:new RegExp(`(?:${Ul(r)}${po}${Ul(r)})|(?:${Ul(r)}${p4}${Ul(r)})`,"g");G_.v4=r=>r&&r.exact?Jde:new RegExp(`${Ul(r)}${po}${Ul(r)}`,"g");G_.v6=r=>r&&r.exact?epe:new RegExp(`${Ul(r)}${p4}${Ul(r)}`,"g");var m4=G_;u();u();function j_(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function fL(){return!1}u();u();u();var{toString:tpe}=Object.prototype;function W_(r){return tpe.call(r)==="[object RegExp]"}var hL={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Y_(r,e={}){if(!W_(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(hL).map(i=>(typeof e[i]=="boolean"?e[i]:r[i])?hL[i]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function y4(r,e,{timeout:t}={}){try{return j_(()=>Y_(r).test(e),{timeout:t})()}catch(n){if(fL(n))return!1;throw n}}var rpe=15,dL=45,Q_={timeout:400};function g4(r){return y4(m4({exact:!0}),r.slice(0,dL),Q_)}function pL(r){return y4(m4.v6({exact:!0}),r.slice(0,dL),Q_)}function mL(r){return y4(m4.v4({exact:!0}),r.slice(0,rpe),Q_)}u();function K(r,e="utf8"){let t=h4[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var yL=mL,npe=pL,X_=function(r){let e=0;if(r=r.toString().trim(),yL(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(npe(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=yL(t[n]),o;s&&(o=X_(t[n]),t[n]=K(o.slice(0,2),"base16")),o!=null&&++n<8&&t.splice(n,0,K(o.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);i[e++]=s>>8&255,i[e++]=s&255}return i}throw new Error("invalid ip address")},gL=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let s=0;s<t;s++)i.push(r[e+s]);return i.join(".")}if(t===16){let i=[];for(let s=0;s<t;s+=2)i.push(n.getUint16(e+s).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};u();var Z1={},Z_={},spe=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[460,0,"quic"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];spe.forEach(r=>{let e=ope(...r);Z_[e.code]=e,Z1[e.name]=e});function ope(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:Boolean(n),path:Boolean(i)}}function Yt(r){if(typeof r=="number"){if(Z_[r]!=null)return Z_[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Z1[r]!=null)return Z1[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ha=E(fa(),1);Mr();function PL(r,e){switch(Yt(r).code){case 4:case 41:return vpe(e);case 6:case 273:case 33:case 132:return OL(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Spe(e);case 421:return Ape(e);case 444:return CL(e);case 445:return CL(e);case 466:return Ipe(e);default:return K(e,"base16")}}function DL(r,e){switch(Yt(r).code){case 4:return RL(e);case 41:return RL(e);case 6:case 273:case 33:case 132:return r9(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return _pe(e);case 421:return xpe(e);case 444:return Rpe(e);case 445:return Cpe(e);case 466:return Tpe(e);default:return z(e,"base16")}}var t9=Object.values(As).map(r=>r.decoder),bpe=function(){let r=t9[0].or(t9[1]);return t9.slice(2).forEach(e=>r=r.or(e)),r}();function RL(r){if(!g4(r))throw new Error("invalid ip address");return X_(r)}function vpe(r){let e=gL(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!g4(e))throw new Error("invalid ip address");return e}function r9(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function OL(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function _pe(r){let e=z(r),t=Uint8Array.from(ha.default.encode(e.length));return Le([t,e],t.length+e.length)}function Spe(r){let e=ha.default.decode(r);if(r=r.slice(ha.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return K(r)}function xpe(r){let e;r[0]==="Q"||r[0]==="1"?e=nr(Ue.decode(`z${r}`)).bytes:e=A.parse(r).multihash.bytes;let t=Uint8Array.from(ha.default.encode(e.length));return Le([t,e],t.length+e.length)}function Tpe(r){let e=bpe.decode(r),t=Uint8Array.from(ha.default.encode(e.length));return Le([t,e],t.length+e.length)}function Ipe(r){let e=ha.default.decode(r),t=r.slice(ha.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+K(t,"base64url")}function Ape(r){let e=ha.default.decode(r),t=r.slice(ha.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return K(t,"base58btc")}function Rpe(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=mt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=r9(n);return Le([t,i],t.length+i.length)}function Cpe(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=mt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=r9(n);return Le([t,i],t.length+i.length)}function CL(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=K(e,"base32"),i=OL(t);return`${n}:${i}`}var ip=E(fa(),1);Mr();function Ppe(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let i=t[n],s=Yt(i);if(s.size===0){e.push([i]);continue}if(n++,n>=t.length)throw NL("invalid address: "+r);if(s.path===!0){e.push([i,a9(t.slice(n).join("/"))]);break}e.push([i,t[n]])}return e}function Dpe(r){let e=[];return r.map(t=>{let n=E4(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),a9(e.join("/"))}function Ope(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=E4(e);return e.length>1?[t.code,DL(t.code,e[1])]:[t.code]})}function n9(r){return r.map(e=>{let t=E4(e);return e[1]!=null?[t.code,PL(t.code,e[1])]:[t.code]})}function i9(r){return w4(Le(r.map(e=>{let t=E4(e),n=Uint8Array.from(ip.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=Le([n,e[1]])),n})))}function s9(r,e){return r.size>0?r.size/8:r.size===0?0:ip.default.decode(e)+ip.default.decode.bytes}function J1(r){let e=[],t=0;for(;t<r.length;){let n=ip.default.decode(r,t),i=ip.default.decode.bytes,s=Yt(n),o=s9(s,r.slice(t+i));if(o===0){e.push([n]),t+=i;continue}let a=r.slice(t+i,t+i+o);if(t+=o+i,t>r.length)throw NL("Invalid address Uint8Array: "+K(r,"base16"));e.push([n,a])}return e}function o9(r){let e=J1(r),t=n9(e);return Dpe(t)}function kpe(r){r=a9(r);let e=Ppe(r),t=Ope(e);return i9(t)}function kL(r){return kpe(r)}function w4(r){let e=Npe(r);if(e!=null)throw e;return Uint8Array.from(r)}function Npe(r){try{J1(r)}catch(e){return e}}function a9(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function NL(r){return new Error("Error parsing address: "+r)}function E4(r){return Yt(r[0])}var c9=E(fa(),1);var ML=E(V(),1);u();function ze(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var LL,Bpe=Symbol.for("nodejs.util.inspect.custom"),BL=[Yt("dns").code,Yt("dns4").code,Yt("dns6").code,Yt("dnsaddr").code],Mpe=[Yt("p2p").code,Yt("ipfs").code],l9=new Map,UL=Symbol.for("@multiformats/js-multiaddr/multiaddr");function FL(r,e){if(r==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let t;switch(r.family){case 4:t="ip4";break;case 6:t="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new da("/"+[t,r.address,e,r.port].join("/"))}function VL(r){return Ec(r)?r.protos().some(e=>e.resolvable):!1}function Ec(r){return Boolean(r?.[UL])}var da=class{constructor(e){if(this[LL]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=w4(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=kL(e)}else if(Ec(e))this.bytes=w4(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return o9(this.bytes)}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),t=this.toString().split("/").slice(1),n,i;if(t.length>2)BL.includes(e[0])&&Mpe.includes(e[1])?(n=Yt("tcp").name,i=443):(n=Yt(t[2]).name,i=parseInt(t[3]));else if(BL.includes(e[0]))n=Yt("tcp").name,i=443;else throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e[0]===41||e[0]===55?6:4,host:t[1],transport:n,port:i}}protos(){return this.protoCodes().map(e=>Object.assign({},Yt(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let i=c9.default.decode(t,n),s=c9.default.decode.bytes,o=Yt(i);n+=s9(o,t.slice(n+s))+s,e.push(i)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return J1(this.bytes)}stringTuples(){let e=J1(this.bytes);return n9(e)}encapsulate(e){return e=new da(e),new da(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new da(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new da(i9(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Z1.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?K(Ue.decode(`z${n}`),"base58btc"):K(A.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>Yt(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return ze(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=l9.get(t.name);if(n==null)throw(0,ML.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new da(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[(LL=UL,Bpe)](){return this.inspect()}inspect(){return"<Multiaddr "+K(this.bytes,"base16")+" - "+o9(this.bytes)+">"}};function se(r){return new da(r)}u();var Upe=Ge("dns4"),Fpe=Ge("dns6"),Vpe=Ge("dnsaddr"),Kl=Wn(Ge("dns"),Vpe,Upe,Fpe),b4=Wn(Ge("ip4"),Ge("ip6")),tm=Wn(st(b4,Ge("tcp")),st(Kl,Ge("tcp"))),qL=st(b4,Ge("udp")),Kpe=st(qL,Ge("utp")),qpe=st(qL,Ge("quic")),Lf=Wn(st(tm,Ge("ws")),st(Kl,Ge("ws"))),Vl=Wn(st(tm,Ge("wss")),st(Kl,Ge("wss"))),u9=Wn(st(tm,Ge("http")),st(b4,Ge("http")),st(Kl,Ge("http"))),f9=Wn(st(tm,Ge("https")),st(b4,Ge("https")),st(Kl,Ge("https"))),v4=Wn(st(Lf,Ge("p2p-webrtc-star"),Ge("p2p")),st(Vl,Ge("p2p-webrtc-star"),Ge("p2p")),st(Lf,Ge("p2p-webrtc-star")),st(Vl,Ge("p2p-webrtc-star"))),LPe=Wn(st(Lf,Ge("p2p-websocket-star"),Ge("p2p")),st(Vl,Ge("p2p-websocket-star"),Ge("p2p")),st(Lf,Ge("p2p-websocket-star")),st(Vl,Ge("p2p-websocket-star"))),zL=Wn(st(u9,Ge("p2p-webrtc-direct"),Ge("p2p")),st(f9,Ge("p2p-webrtc-direct"),Ge("p2p")),st(u9,Ge("p2p-webrtc-direct")),st(f9,Ge("p2p-webrtc-direct"))),em=Wn(Lf,Vl,u9,f9,v4,zL,tm,Kpe,qpe,Kl),BPe=Wn(st(em,Ge("p2p-stardust"),Ge("p2p")),st(em,Ge("p2p-stardust"))),Fl=Wn(st(em,Ge("p2p")),v4,zL,Ge("p2p")),KL=Wn(st(Fl,Ge("p2p-circuit"),Fl),st(Fl,Ge("p2p-circuit")),st(Ge("p2p-circuit"),Fl),st(em,Ge("p2p-circuit")),st(Ge("p2p-circuit"),em),Ge("p2p-circuit")),$L=()=>Wn(st(KL,$L),KL),Nf=$L(),_4=Wn(st(Nf,Fl,Nf),st(Fl,Nf),st(Nf,Fl),Nf,Fl),HL=_4;function GL(r){function e(t){let n;try{n=se(t)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return e}function st(...r){function e(t){if(t.length<r.length)return null;let n=t;return r.some(i=>(n=typeof i=="function"?i().partialMatch(t):i.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:GL(e),partialMatch:e}}function Wn(...r){function e(n){let i=null;return r.some(s=>{let o=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return o!=null?(i=o,!0):!1}),i}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:GL(e),partialMatch:e}}function Ge(r){let e=r;function t(i){let s;try{s=se(i)}catch{return!1}let o=s.protoNames();return o.length===1&&o[0]===e}function n(i){return i.length===0?null:i[0]===e?i.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var JL=E(x4(),1);var T4=/^\/(ip[fn]s)\/([^/?#]+)/,eB=1,tB=2,rB=/^https?:\/\/([^/]+)\.(ip[fn]s)\.[^/?]+/;var Zpe=/^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)+([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$/;function I4(r){try{return sB(r)?Boolean(A.parse(r)):r instanceof Uint8Array?Boolean(A.decode(r)):Boolean(A.asCID(r))}catch{return!1}}function nB(r,e,t=eB,n=tB){let i=oB(r);if(i===!1)return!1;let s=i.match(e);if(s==null||s[t]!=="ipfs")return!1;let o=s[n];return o!=null&&e===rB&&(o=o.toLowerCase()),I4(o)}function iB(r,e,t=eB,n=tB){let i=oB(r);if(i===!1)return!1;let s=i.match(e);if(s==null||s[t]!=="ipns")return!1;let o=s[n];if(o!=null&&e===rB){if(o=o.toLowerCase(),I4(o))return!0;try{!o.includes(".")&&o.includes("-")&&(o=o.replace(/--/g,"@").replace(/-/g,".").replace(/@/g,"-"));let{hostname:a}=new JL.URL(`http://${o}`);return Zpe.test(a)}catch{return!1}}return!0}function sB(r){return typeof r=="string"}function oB(r){return r instanceof Uint8Array?K(r,"base58btc"):sB(r)?r:!1}var A4=r=>nB(r,T4)||iB(r,T4);var aB=r=>nB(r,T4),R4=r=>iB(r,T4);u();u();u();var cB=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");var bc="/",lB=new TextEncoder().encode(bc),P4=lB[0],fe=class{constructor(e,t){if(typeof e=="string")this._buf=z(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==P4)throw new Error("Invalid key")}toString(e="utf8"){return K(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new fe(e.join(bc))}static random(){return new fe(cB().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new fe(e):typeof e.uint8Array=="function"?new fe(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=lB),this._buf[0]!==P4){let e=new Uint8Array(this._buf.byteLength+1);e.fill(P4,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===P4;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let i=0;i<t.length;i++){if(n.length<i+1)return!1;let s=t[i],o=n[i];if(s<o)return!0;if(s>o)return!1}return t.length<n.length}reverse(){return fe.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(bc).slice(1)}type(){return Jpe(this.baseNamespace())}name(){return e0e(this.baseNamespace())}instance(e){return new fe(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(bc)||(e+=bc),e+=this.type(),new fe(e)}parent(){let e=this.list();return e.length===1?new fe(bc):new fe(e.slice(0,-1).join(bc))}child(e){return this.toString()===bc?e:e.toString()===bc?this:new fe(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return fe.withNamespaces([...this.namespaces(),...t0e(e.map(t=>t.namespaces()))])}};function Jpe(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function e0e(r){let e=r.split(":");return e[e.length-1]}function t0e(r){return[].concat(...r)}var D4=E(V(),1);u();var hB=E(an(),1),dB=E(ai(),1);u();var r0e=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/uig;ct.nanosecond=ct.ns=1/1e6;ct.\u00B5s=ct.\u03BCs=ct.us=ct.microsecond=1/1e3;ct.millisecond=ct.ms=ct[""]=1;ct.second=ct.sec=ct.s=ct.ms*1e3;ct.minute=ct.min=ct.m=ct.s*60;ct.hour=ct.hr=ct.h=ct.m*60;ct.day=ct.d=ct.h*24;ct.week=ct.wk=ct.w=ct.d*7;ct.month=ct.b=ct.d*(365.25/12);ct.year=ct.yr=ct.y=ct.d*365.25;function ct(r="",e="ms"){var t=null;return r=(r+"").replace(/(\d)[,_](\d)/g,"$1$2"),r.replace(r0e,function(n,i,s){s=fB(s),s&&(t=(t||0)+parseFloat(i,10)*s)}),t&&t/(fB(e)||1)}function fB(r){return ct[r]||ct[r.toLowerCase().replace(/s$/,"")]}var ql=ct;u();var vc=class extends Error{constructor(e="request timed out"){super(e),this.name="TimeoutError",this.code=vc.code}};vc.code="ERR_TIMEOUT";function M(r,e){return(...t)=>{let n=t[e??t.length-1];if(!n||!n.timeout)return r(...t);let i=typeof n.timeout=="string"?ql(n.timeout):n.timeout,s=new hB.TimeoutController(i);n.signal=(0,dB.anySignal)([n.signal,s.signal]);let o=r(...t),a=new Promise((f,h)=>{s.signal.addEventListener("abort",()=>{h(new vc)})}),c=Date.now(),l=()=>{if(s.signal.aborted)throw new vc;if(Date.now()-c>i)throw s.abort(),new vc};return o[Symbol.asyncIterator]?async function*(){let f=o[Symbol.asyncIterator]();try{for(;;){let{value:h,done:p}=await Promise.race([f.next(),a]);if(p)break;l(),yield h}}catch(h){throw l(),h}finally{s.clear(),f.return&&f.return()}}():(async()=>{try{let f=await Promise.race([o,a]);return l(),f}catch(f){throw l(),f}finally{s.clear()}})()}}u();var m9=E(V(),1),pB="/ipfs/";function _c(r){if(r instanceof Uint8Array)try{r=A.decode(r)}catch(i){throw(0,m9.default)(i,"ERR_INVALID_CID")}let e=A.asCID(r);if(e)return{cid:e,path:void 0};r=r.toString(),r.startsWith(pB)&&(r=r.substring(pB.length));let t=r.split("/"),n;try{e=A.parse(t.shift()||"")}catch(i){throw(0,m9.default)(i,"ERR_INVALID_CID")}return t.length&&(n=`/${t.join("/")}`),{cid:e,path:n}}var n0e="ERR_BAD_PATH",O4="This command must be run in online mode. Try running 'ipfs daemon' first.",nm=new fe("/local/filesroot"),im=262144;var mB=r=>{if(A.asCID(r))return`/ipfs/${r}`;let t=r.toString();try{return`/ipfs/${A.parse(t)}`}catch{}if(A4(t))return t;throw(0,D4.default)(new Error(`invalid path: ${r}`),n0e)},sp=r=>r instanceof Uint8Array?A.decode(r).toString():(r=r.toString(),r.indexOf("/ipfs/")===0&&(r=r.substring(6)),r.charAt(r.length-1)==="/"&&(r=r.substring(0,r.length-1)),r),zl=async function(r,e,t,n={}){let{cid:i,path:s}=_c(t);s&&(n.path=s);let o=i,a=n.path||"";if(a.startsWith("/")&&(a=a.substring(1)),n.path)try{for await(let{value:c,remainderPath:l}of $l(i,n.path,e,r,{signal:n.signal})){if(!A.asCID(c))break;a=l,o=c}}catch(c){throw c.message.startsWith("Object has no property")&&(c.message=`no link named "${a.split("/")[0]}" under ${o}`,c.code="ERR_NO_LINK"),c}return{cid:o,remainderPath:a||""}},y9=r=>{if(r.type!=="file"&&r.type!=="directory"&&r.type!=="raw")throw new Error(`Unknown node type '${r.type}'`);let e={cid:r.cid,path:r.path,name:r.name,size:r.size,type:"file"};return r.type==="directory"&&(e.type="dir"),r.type==="file"&&(e.size=r.unixfs.fileSize()),(r.type==="file"||r.type==="directory")&&(e.mode=r.unixfs.mode,r.unixfs.mtime!==void 0&&(e.mtime=r.unixfs.mtime)),e},yB=M(async(r,e)=>await r),$l=async function*(r,e,t,n,i){let s=async l=>{let f=await t.getCodec(l.code),h=await n.blocks.get(l,i);return f.decode(h)},o=e.split("/").filter(Boolean),a=await s(r),c=r;for(;o.length;){let l=o.shift();if(!l)throw(0,D4.default)(new Error(`Could not resolve path "${e}"`),"ERR_INVALID_PATH");if(r.code===at&&Array.isArray(a.Links)){let f=a.Links.find(h=>h.Name===l);if(f){yield{value:f.Hash,remainderPath:o.join("/")},a=await s(f.Hash),c=f.Hash;continue}}if(Object.prototype.hasOwnProperty.call(a,l))a=a[l],yield{value:a,remainderPath:o.join("/")};else throw(0,D4.default)(new Error(`no link named "${l}" under ${c}`),"ERR_NO_LINK");A.asCID(a)&&(c=a,a=await s(a))}yield{value:a,remainderPath:""}};var Yn=class{static create({start:e,stop:t}){return new Yn(e,t)}static async start(e,t){let{state:n,activate:i}=e;switch(n.status){case"stopped":try{let s=i(t);e.state={status:"starting",ready:s};let o=await s;return e.state={status:"started",value:o},o}catch(s){throw e.state={status:"stopped"},s}case"starting":throw new Of;case"started":throw new kf;case"stopping":return await n.ready,await Yn.start(e,t);default:return Yn.panic(e)}}static async stop(e){let{state:t,deactivate:n}=e;switch(t.status){case"stopped":break;case"starting":{try{await t.ready}catch{}return await Yn.stop(e)}case"stopping":return await t.ready;case"started":{n&&await n(t.value),e.state={status:"stopped"};break}default:Yn.panic(t)}}static try({state:e}){switch(e.status){case"started":return e.value;default:return null}}static async use({state:e},t){switch(e.status){case"started":return e.value;case"starting":return await yB(e.ready,t);default:throw new gc}}static panic({state:e}){let t=JSON.stringify({status:e.status});throw RangeError(`Service in invalid state ${t}, should never happen if you see this please report a bug`)}constructor(e,t){this.activate=e,this.deactivate=t,this.state={status:"stopped"}}async use(e){return await Yn.use(this,e)}try(){return Yn.try(this)}};function gB({network:r,preload:e,peerId:t,keychain:n,repo:i,ipns:s,mfsPreload:o,print:a,hashers:c,options:l}){return async()=>{let{libp2p:h}=await Yn.start(r,{peerId:t,repo:i,print:a,hashers:c,options:l});await Promise.all([s.startOnline({keychain:n,libp2p:h,peerId:t,repo:i}),e.start(),o.start()])}}u();function wB({network:r,preload:e,ipns:t,repo:n,mfsPreload:i}){return async()=>{await Promise.all([e.stop(),t.stop(),i.stop()]),await Yn.stop(r),await n.close()}}u();u();u();var bB=E(op(),1),k4=class{constructor(e){this.lru=(0,bB.default)(e)}get(e){let t=this.lru.get(e);if(t){if(t.expire&&t.expire<Date.now()){this.lru.remove(e);return}return t.value}}set(e,t,n){this.lru.set(e,{value:t,expire:Date.now()+n})}has(e){return!!this.get(e)}remove(e){this.lru.remove(e)}clear(){this.lru.clear()}};u();var PB=E(Hl(),1);u();var om=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},w9=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},_B=r=>globalThis.DOMException===void 0?new w9(r):new DOMException(r),SB=r=>{let e=r.reason===void 0?_B("This operation was aborted."):r.reason;return e instanceof Error?e:_B(e)};function E9(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(SB(c)),c.addEventListener("abort",()=>{a(SB(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new om(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function b9(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var Bf=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Sc,am=class{constructor(){Sc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Bf(this,Sc,"f")[this.size-1].priority>=t.priority){Bf(this,Sc,"f").push(n);return}let i=b9(Bf(this,Sc,"f"),n,(s,o)=>o.priority-s.priority);Bf(this,Sc,"f").splice(i,0,n)}dequeue(){let e=Bf(this,Sc,"f").shift();return e?.run}filter(e){return Bf(this,Sc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Bf(this,Sc,"f").length}};Sc=new WeakMap;var Tr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},_e=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Gr,lm,um,jl,V4,fm,L4,mo,cm,Vi,B4,Ki,hm,Gl,M4,xB,TB,CB,IB,AB,RB,U4,v9,_9,K4,F4,o0e=new om,S9=class extends Error{},yo=class extends PB.default{constructor(e){var t,n,i,s;if(super(),Gr.add(this),lm.set(this,void 0),um.set(this,void 0),jl.set(this,0),V4.set(this,void 0),fm.set(this,void 0),L4.set(this,0),mo.set(this,void 0),cm.set(this,void 0),Vi.set(this,void 0),B4.set(this,void 0),Ki.set(this,0),hm.set(this,void 0),Gl.set(this,void 0),M4.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:am,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);Tr(this,lm,e.carryoverConcurrencyCount,"f"),Tr(this,um,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Tr(this,V4,e.intervalCap,"f"),Tr(this,fm,e.interval,"f"),Tr(this,Vi,new e.queueClass,"f"),Tr(this,B4,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Tr(this,M4,e.throwOnTimeout===!0,"f"),Tr(this,Gl,e.autoStart===!1,"f")}get concurrency(){return _e(this,hm,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Tr(this,hm,e,"f"),_e(this,Gr,"m",K4).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Tr(this,Ki,(a=_e(this,Ki,"f"),a++,a),"f"),Tr(this,jl,(c=_e(this,jl,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new S9("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):E9(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?_e(this,M4,"f"):t.throwOnTimeout)&&i(o0e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}_e(this,Gr,"m",CB).call(this)};_e(this,Vi,"f").enqueue(s,t),_e(this,Gr,"m",U4).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return _e(this,Gl,"f")?(Tr(this,Gl,!1,"f"),_e(this,Gr,"m",K4).call(this),this):this}pause(){Tr(this,Gl,!0,"f")}clear(){Tr(this,Vi,new(_e(this,B4,"f")),"f")}async onEmpty(){_e(this,Vi,"f").size!==0&&await _e(this,Gr,"m",F4).call(this,"empty")}async onSizeLessThan(e){_e(this,Vi,"f").size<e||await _e(this,Gr,"m",F4).call(this,"next",()=>_e(this,Vi,"f").size<e)}async onIdle(){_e(this,Ki,"f")===0&&_e(this,Vi,"f").size===0||await _e(this,Gr,"m",F4).call(this,"idle")}get size(){return _e(this,Vi,"f").size}sizeBy(e){return _e(this,Vi,"f").filter(e).length}get pending(){return _e(this,Ki,"f")}get isPaused(){return _e(this,Gl,"f")}};lm=new WeakMap,um=new WeakMap,jl=new WeakMap,V4=new WeakMap,fm=new WeakMap,L4=new WeakMap,mo=new WeakMap,cm=new WeakMap,Vi=new WeakMap,B4=new WeakMap,Ki=new WeakMap,hm=new WeakMap,Gl=new WeakMap,M4=new WeakMap,Gr=new WeakSet,xB=function(){return _e(this,um,"f")||_e(this,jl,"f")<_e(this,V4,"f")},TB=function(){return _e(this,Ki,"f")<_e(this,hm,"f")},CB=function(){var e;Tr(this,Ki,(e=_e(this,Ki,"f"),e--,e),"f"),_e(this,Gr,"m",U4).call(this),this.emit("next")},IB=function(){this.emit("empty"),_e(this,Ki,"f")===0&&this.emit("idle")},AB=function(){_e(this,Gr,"m",_9).call(this),_e(this,Gr,"m",v9).call(this),Tr(this,cm,void 0,"f")},RB=function(){let e=Date.now();if(_e(this,mo,"f")===void 0){let t=_e(this,L4,"f")-e;if(t<0)Tr(this,jl,_e(this,lm,"f")?_e(this,Ki,"f"):0,"f");else return _e(this,cm,"f")===void 0&&Tr(this,cm,setTimeout(()=>{_e(this,Gr,"m",AB).call(this)},t),"f"),!0}return!1},U4=function(){if(_e(this,Vi,"f").size===0)return _e(this,mo,"f")&&clearInterval(_e(this,mo,"f")),Tr(this,mo,void 0,"f"),_e(this,Gr,"m",IB).call(this),!1;if(!_e(this,Gl,"f")){let e=!_e(this,Gr,"a",RB);if(_e(this,Gr,"a",xB)&&_e(this,Gr,"a",TB)){let t=_e(this,Vi,"f").dequeue();return t?(this.emit("active"),t(),e&&_e(this,Gr,"m",v9).call(this),!0):!1}}return!1},v9=function(){_e(this,um,"f")||_e(this,mo,"f")!==void 0||(Tr(this,mo,setInterval(()=>{_e(this,Gr,"m",_9).call(this)},_e(this,fm,"f")),"f"),Tr(this,L4,Date.now()+_e(this,fm,"f"),"f"))},_9=function(){_e(this,jl,"f")===0&&_e(this,Ki,"f")===0&&_e(this,mo,"f")&&(clearInterval(_e(this,mo,"f")),Tr(this,mo,void 0,"f")),Tr(this,jl,_e(this,lm,"f")?_e(this,Ki,"f"):0,"f"),_e(this,Gr,"m",K4).call(this)},K4=function(){for(;_e(this,Gr,"m",U4).call(this););},F4=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var HB=E(cp(),1),O9=new k4(1e3),I0e=60*1e3,A0e=yo.default?yo.default:yo,R0e=new A0e({concurrency:4}),$B=r=>{if(r.Path)return r.Path;throw new Error(r.Message)};async function GB(r,e){return(async(n,i={})=>{let s=new URLSearchParams(i);s.set("arg",n);let o=s.toString();if(!i.nocache&&O9.has(o)){let c=O9.get(o);return $B(c)}let a=await R0e.add(async()=>{let c=await HB.default.get("https://ipfs.io/api/v0/dns",{searchParams:s}),l=new URL(c.url).search.slice(1),f=await c.json();return O9.set(l,f,I0e),f});return $B(a)})(r,e)}function C0e(r){return r.endsWith(".eth")&&(r=r.replace(/.eth$/,".eth.link")),r}function jB(){return M(async(e,t={recursive:!0})=>{if(typeof e!="string")throw new Error("Invalid arguments, domain must be a string");return e=C0e(e),GB(e,t)})}u();function WB({network:r}){return()=>{let e=r.try();return e!=null&&Boolean(e.libp2p.isStarted())}}u();u();var QB=E(V(),1);u();var k9=Symbol.for("@libp2p/peer-id");function Rs(r){return r!=null&&Boolean(r[k9])}var YB=Object.values(As).map(r=>r.decoder).reduce((r,e)=>r.or(e),As.identity.decoder),XB=114,N9=36,L9=37,pm=class{constructor(e){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(${this.toString()})`}get[k9](){return!0}toString(){return this.string==null&&(this.string=Ue.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return A.createV1(XB,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return ze(this.multihash.bytes,e);if(typeof e=="string")return pe(e).equals(this);if(e?.multihash?.bytes!=null)return ze(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}},Mf=class extends pm{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},Uf=class extends pm{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},Ff=class extends pm{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function jr(r){if(r.type==="RSA")return new Mf(r);if(r.type==="Ed25519")return new Uf(r);if(r.type==="secp256k1")return new Ff(r);throw(0,QB.default)(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function pe(r,e){if(e=e??YB,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=nr(Ue.decode(`z${r}`));return r.startsWith("12D")?new Uf({multihash:t}):r.startsWith("16U")?new Ff({multihash:t}):new Mf({multihash:t})}return Ir(YB.decode(r))}function Ir(r){try{let e=nr(r);if(e.code===on.code){if(e.digest.length===N9)return new Uf({multihash:e});if(e.digest.length===L9)return new Ff({multihash:e})}if(e.code===$e.code)return new Mf({multihash:e})}catch{return P0e(A.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function P0e(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==XB)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===$e.code)return new Mf({multihash:r.multihash});if(e.code===on.code){if(e.digest.length===N9)return new Uf({multihash:r.multihash});if(e.digest.length===L9)return new Ff({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function ln(r,e){return r.length===N9?new Uf({multihash:la(on.code,r),privateKey:e}):r.length===L9?new Ff({multihash:la(on.code,r),privateKey:e}):new Mf({multihash:await $e.digest(r),publicKey:r,privateKey:e})}function ZB({repo:r,codecs:e,bases:t,name:n}){async function i(s,o={}){if(!A4(s))throw new Error("invalid argument "+s);if(R4(s))for await(let g of n.resolve(s,o))s=g;let[,a,c,...l]=s.split("/"),f=o.cidBase?await t.getBase(o.cidBase):void 0,h=D0e(c);if(l.length===0){let g=f?f.encoder.encode(h):c;return`/${a}/${g}`}let p=A.decode(h);s=l.join("/");let d=$l(p,s,e,r,o),m=p,y=s;for await(let g of d)A.asCID(g.value)&&(m=g.value,y=g.remainderPath);return`/ipfs/${m.toString(f&&f.encoder)}${y?"/"+y:""}`}return M(i)}function D0e(r){try{return pe(r).toBytes()}catch{return A.parse(r).bytes}}u();u();var eM=E(vi(),1);function tM({addAll:r}){return(e,t={})=>{let n,i=A.asCID(e);return i?n=r([{cid:i,...t}],t):n=r([{path:e.toString(),...t}],t),(0,eM.default)(n)}}u();u();var lp=E(V(),1);async function*pa(r){if(r==null)throw(0,lp.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT");let e=A.asCID(r);if(e){yield go({cid:e});return}if(r instanceof String||typeof r=="string"){yield go({path:r});return}if(r.cid!=null||r.path!=null)return yield go(r);if(Symbol.iterator in r){let t=r[Symbol.iterator](),n=t.next();if(n.done)return t;if(A.asCID(n.value)||n.value instanceof String||typeof n.value=="string"){yield go({cid:n.value});for(let i of t)yield go({cid:i});return}if(n.value.cid!=null||n.value.path!=null){yield go(n.value);for(let i of t)yield go(i);return}throw(0,lp.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}if(Symbol.asyncIterator in r){let t=r[Symbol.asyncIterator](),n=await t.next();if(n.done)return t;if(A.asCID(n.value)||n.value instanceof String||typeof n.value=="string"){yield go({cid:n.value});for await(let i of t)yield go({cid:i});return}if(n.value.cid!=null||n.value.path!=null){yield go(n.value);for await(let i of t)yield go(i);return}throw(0,lp.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}throw(0,lp.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}function go(r){let e=r.cid||`${r.path}`;if(!e)throw(0,lp.default)(new Error("Unexpected input: Please path either a CID or an IPFS path"),"ERR_UNEXPECTED_INPUT");let t={path:e,recursive:r.recursive!==!1};return r.metadata!=null&&(t.metadata=r.metadata),t}u();var yt={direct:"direct",recursive:"recursive",indirect:"indirect",all:"all"};function rM({repo:r,codecs:e}){async function*t(n,i={}){let s=async function*(){for await(let{path:c,recursive:l,metadata:f}of pa(n)){let{cid:h}=await zl(r,e,c),{reason:p}=await r.pins.isPinnedWithType(h,[yt.recursive,yt.direct]);if(p==="recursive"&&!l)throw new Error(`${h} already pinned recursively`);l?await r.pins.pinRecursively(h,{metadata:f}):await r.pins.pinDirectly(h,{metadata:f}),yield h}};if(!Boolean(i.lock)){yield*s();return}let a=await r.gcLock.readLock();try{yield*s()}finally{a()}}return M(t)}u();var B9=E(V(),1);function mm(r,e,t){let n={type:r,cid:e};return t&&(n.metadata=t),n}function nM({repo:r,codecs:e}){async function*t(n={}){let i=yt.all;if(n.type&&(i=n.type,!Object.keys(yt).includes(i)))throw(0,B9.default)(new Error("Invalid pin type"),"ERR_INVALID_PIN_TYPE");if(n.paths){let s=!1;for await(let{path:o}of pa(n.paths)){let{cid:a}=await zl(r,e,o),{reason:c,pinned:l,parent:f,metadata:h}=await r.pins.isPinnedWithType(a,i);if(!l)throw(0,B9.default)(new Error(`path '${o}' is not pinned`),"ERR_NOT_PINNED");switch(c){case yt.direct:case yt.recursive:s=!0,yield mm(c,a,h);break;default:s=!0,yield mm(`${yt.indirect} through ${f}`,a,h)}}if(!s)throw new Error("No match found");return}if(i===yt.recursive||i===yt.all)for await(let{cid:s,metadata:o}of r.pins.recursiveKeys())yield mm(yt.recursive,s,o);if(i===yt.indirect||i===yt.all)for await(let s of r.pins.indirectKeys(n))yield mm(yt.indirect,s);if(i===yt.direct||i===yt.all)for await(let{cid:s,metadata:o}of r.pins.directKeys())yield mm(yt.direct,s,o)}return M(t)}u();var iM=E(vi(),1);function sM({rmAll:r}){async function e(t,n={}){let i=await(0,iM.default)(r([{path:t,...n}],n));if(!i)throw new Error("CID expected");return i}return e}u();function oM({repo:r,codecs:e}){async function*t(n,i={}){let s=await r.gcLock.readLock();try{for await(let{path:o,recursive:a}of pa(n)){let{cid:c}=await zl(r,e,o),{pinned:l,reason:f}=await r.pins.isPinnedWithType(c,yt.all);if(!l)throw new Error(`${c} is not pinned`);switch(f){case yt.recursive:if(!a)throw new Error(`${c} is pinned recursively`);await r.pins.unpin(c),yield c;break;case yt.direct:await r.pins.unpin(c),yield c;break;default:throw new Error(`${c} is pinned indirectly under ${f}`)}}}finally{s()}}return M(t)}var z4=class{constructor({codecs:e,repo:t}){let n=rM({codecs:e,repo:t});this.addAll=n,this.add=tM({addAll:n});let i=oM({codecs:e,repo:t});this.rmAll=i,this.rm=sM({rmAll:i}),this.ls=nM({codecs:e,repo:t}),this.remote={add:(s,o={})=>Promise.reject(new Error("Not implemented")),ls:async function*(s,o={}){return Promise.reject(new Error("Not implemented"))},rm:(s,o={})=>Promise.reject(new Error("Not implemented")),rmAll:(s,o={})=>Promise.reject(new Error("Not implemented")),service:{add:(s,o)=>Promise.reject(new Error("Not implemented")),rm:(s,o={})=>Promise.reject(new Error("Not implemented")),ls:(s={})=>Promise.reject(new Error("Not implemented"))}}}};u();u();var sK=E(V(),1);u();var qi={};Kt(qi,{abortedError:()=>k0e,dbDeleteFailedError:()=>H4,dbOpenFailedError:()=>$4,dbWriteFailedError:()=>G4,notFoundError:()=>En});u();var up=E(V(),1);function $4(r){return r=r||new Error("Cannot open database"),(0,up.default)(r,"ERR_DB_OPEN_FAILED")}function H4(r){return r=r||new Error("Delete failed"),(0,up.default)(r,"ERR_DB_DELETE_FAILED")}function G4(r){return r=r||new Error("Write failed"),(0,up.default)(r,"ERR_DB_WRITE_FAILED")}function En(r){return r=r||new Error("Not Found"),(0,up.default)(r,"ERR_NOT_FOUND")}function k0e(r){return r=r||new Error("Aborted"),(0,up.default)(r,"ERR_ABORTED")}var Ms=E(V(),1);u();var WV=E(aM(),1);var qw={};Kt(qw,{generateEphemeralKeyPair:()=>FF,generateKeyPair:()=>Mp,generateKeyPairFromSeed:()=>lge,importKey:()=>Nc,keyStretcher:()=>kF,keysPBM:()=>gp,marshalPrivateKey:()=>gx,marshalPublicKey:()=>zm,supportedKeys:()=>Ra,unmarshalPrivateKey:()=>kn,unmarshalPublicKey:()=>Ti});u();var gp={};Kt(gp,{KeyType:()=>tr,PrivateKey:()=>_o,PublicKey:()=>vo});u();u();u();var mU=E(mS(),1),yS=mU.default.Reader,B1e=["uint64","int64","sint64","fixed64","sfixed64"];B1e.forEach(r=>{let e=yS.prototype[r];yS.prototype[r]=function(){return BigInt(e.call(this).toString())}});function gt(r,e){let t=yS.create(r instanceof Uint8Array?r:r.subarray());return e.decode(t)}u();var yU=E(mS(),1),gS=yU.default.Writer,M1e=["uint64","int64","sint64","fixed64","sfixed64"];M1e.forEach(r=>{let e=gS.prototype[r];gS.prototype[r]=function(t){return e.call(this,t.toString())}});function wt(r,e){let t=gS.create();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}u();u();var yp;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(yp||(yp={}));function uw(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Hi(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(s,o){let a=e(s);o.int32(a)},n=function(s){let o=s.uint32();return e(o)};return uw("enum",yp.VARINT,t,n)}u();function Et(r,e){return uw("message",yp.LENGTH_DELIMITED,r,e)}var tr;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(tr||(tr={}));var wS;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(wS||(wS={}));(function(r){r.codec=()=>Hi(wS)})(tr||(tr={}));var vo;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.Type!=null)n.uint32(8),tr.codec().encode(t.Type,n);else throw new Error('Protocol error: required field "Type" was not found in object');if(t.Data!=null)n.uint32(18),n.bytes(t.Data);else throw new Error('Protocol error: required field "Data" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={Type:tr.RSA,Data:new Uint8Array(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.Type=tr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(o&7);break}}if(i.Type==null)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(i.Data==null)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(vo||(vo={}));var _o;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.Type!=null)n.uint32(8),tr.codec().encode(t.Type,n);else throw new Error('Protocol error: required field "Type" was not found in object');if(t.Data!=null)n.uint32(18),n.bytes(t.Data);else throw new Error('Protocol error: required field "Data" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={Type:tr.RSA,Data:new Uint8Array(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.Type=tr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(o&7);break}}if(i.Type==null)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(i.Data==null)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(_o||(_o={}));var WNe=E(eu(),1),YNe=E(KS(),1),Vw=E(ft(),1),Kw=E(V(),1);u();var qS=E(V(),1);Mr();u();u();var Yr={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)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}};u();var CF={SHA1:20,SHA256:32,SHA512:64};var cye={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},lye=async(r,e)=>{let t=await Yr.get().subtle.sign({name:"HMAC"},r,e);return new Uint8Array(t,0,t.byteLength)};async function PF(r,e){let t=cye[r],n=await Yr.get().subtle.importKey("raw",e,{name:"HMAC",hash:{name:t}},!1,["sign"]);return{async digest(i){return await lye(n,i)},length:CF[r]}}var OF={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,keySize:32}};async function kF(r,e,t){let n=OF[r];if(n==null){let b=Object.keys(OF).join(" / ");throw(0,qS.default)(new Error(`unknown cipher type '${r}'. Must be ${b}`),"ERR_INVALID_CIPHER_TYPE")}if(e==null)throw(0,qS.default)(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");let i=n.keySize,s=n.ivSize,o=20,a=z("key expansion"),c=2*(s+i+o),l=await PF(e,t),f=await l.digest(a),h=[],p=0;for(;p<c;){let b=await l.digest(Le([f,a])),S=b.length;p+S>c&&(S=c-p),h.push(b),p+=S,f=await l.digest(f)}let d=c/2,m=Le(h),y=m.slice(0,d),g=m.slice(d,c),w=b=>({iv:b.slice(0,s),cipherKey:b.slice(s,s+i),macKey:b.slice(s+i)});return{k1:w(y),k2:w(g)}}u();u();var xp=E(V(),1);u();var Yke=E(sr(),1),Qke=E(Tw(),1),NF=E(ft(),1);Mr();function To(r,e){let t=Uint8Array.from(r.abs().toByteArray());if(t=t[0]===0?t.slice(1):t,e!=null){if(t.length>e)throw new Error("byte array longer than desired length");t=Le([new Uint8Array(e-t.length),t])}return K(t,"base64url")}function Gi(r){let e=Rw(r);return new NF.default.jsbn.BigInteger(K(e,"base16"),16)}function Rw(r,e){let t=z(r,"base64urlpad");if(e!=null){if(t.length>e)throw new Error("byte array longer than desired length");t=Le([new Uint8Array(e-t.length),t])}return t}Mr();var LF={"P-256":256,"P-384":384,"P-521":521},uye=Object.keys(LF),zS=uye.join(" / ");async function BF(r){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw(0,xp.default)(new Error(`Unknown curve: ${r}. Must be ${zS}`),"ERR_INVALID_CURVE");let e=await Yr.get().subtle.generateKey({name:"ECDH",namedCurve:r},!0,["deriveBits"]),t=async(s,o)=>{let a;o!=null?a=await Yr.get().subtle.importKey("jwk",hye(r,o),{name:"ECDH",namedCurve:r},!1,["deriveBits"]):a=e.privateKey;let c=await Yr.get().subtle.importKey("jwk",UF(r,s),{name:"ECDH",namedCurve:r},!1,[]),l=await Yr.get().subtle.deriveBits({name:"ECDH",namedCurve:r,public:c},a,LF[r]);return new Uint8Array(l,0,l.byteLength)},n=await Yr.get().subtle.exportKey("jwk",e.publicKey);return{key:fye(n),genSharedKey:t}}var MF={"P-256":32,"P-384":48,"P-521":66};function fye(r){if(r.crv==null||r.x==null||r.y==null)throw(0,xp.default)(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");if(r.crv!=="P-256"&&r.crv!=="P-384"&&r.crv!=="P-521")throw(0,xp.default)(new Error(`Unknown curve: ${r.crv}. Must be ${zS}`),"ERR_INVALID_CURVE");let e=MF[r.crv];return Le([Uint8Array.from([4]),Rw(r.x,e),Rw(r.y,e)],1+e*2)}function UF(r,e){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw(0,xp.default)(new Error(`Unknown curve: ${r}. Must be ${zS}`),"ERR_INVALID_CURVE");let t=MF[r];if(!ze(e.slice(0,1),Uint8Array.from([4])))throw(0,xp.default)(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:r,x:K(e.slice(1,t+1),"base64url"),y:K(e.slice(1+t),"base64url"),ext:!0}}var hye=(r,e)=>({...UF(r,e.public),d:K(e.private,"base64url")});var FF=BF;u();u();Mr();function Cw(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,i=r?.digest??"SHA-256",s=r?.saltLength??16,o=r?.iterations??32767,a=Yr.get();t*=8;async function c(h,p){let d=a.getRandomValues(new Uint8Array(s)),m=a.getRandomValues(new Uint8Array(n)),y={name:e,iv:m};typeof p=="string"&&(p=z(p));let g={name:"PBKDF2",salt:d,iterations:o,hash:{name:i}},w=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),b=await a.subtle.deriveKey(g,w,{name:e,length:t},!0,["encrypt"]),S=await a.subtle.encrypt(y,b,h);return Le([d,y.iv,new Uint8Array(S)])}async function l(h,p){let d=h.slice(0,s),m=h.slice(s,s+n),y=h.slice(s+n),g={name:e,iv:m};typeof p=="string"&&(p=z(p));let w={name:"PBKDF2",salt:d,iterations:o,hash:{name:i}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),S=await a.subtle.deriveKey(w,b,{name:e,length:t},!0,["decrypt"]),_=await a.subtle.decrypt(g,S,y);return new Uint8Array(_)}return{encrypt:c,decrypt:l}}async function KF(r,e){let t=na.decode(r);return await Cw().decrypt(t,e)}var tx={};Kt(tx,{RsaPrivateKey:()=>Op,RsaPublicKey:()=>Lm,fromJwk:()=>Mye,generateKeyPair:()=>Uye,unmarshalRsaPrivateKey:()=>Lye,unmarshalRsaPublicKey:()=>Bye});u();var ex=E(V(),1);var LNe=E(GF(),1),Nm=E(ft(),1);u();u();u();var pye=E(ru(),1);var At=BigInt(0),pr=BigInt(1),su=BigInt(2),Dm=BigInt(3),mye=BigInt(8),wr=Object.freeze({a:At,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:pr,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function jF(r){let{a:e,b:t}=wr,n=be(r*r),i=be(n*r);return be(i+e*r+t)}var Pw=wr.a===At,Ow=class extends Error{constructor(e){super(e)}},qt=class{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof jt))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new qt(e.x,e.y,pr)}static toAffineBatch(e){let t=bye(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(t[i]))}static normalizeZ(e){return qt.toAffineBatch(e).map(qt.fromAffine)}equals(e){if(!(e instanceof qt))throw new TypeError("JacobianPoint expected");let{x:t,y:n,z:i}=this,{x:s,y:o,z:a}=e,c=be(i*i),l=be(a*a),f=be(t*l),h=be(s*c),p=be(be(n*a)*l),d=be(be(o*i)*c);return f===h&&p===d}negate(){return new qt(this.x,be(-this.y),this.z)}double(){let{x:e,y:t,z:n}=this,i=be(e*e),s=be(t*t),o=be(s*s),a=e+s,c=be(su*(be(a*a)-i-o)),l=be(Dm*i),f=be(l*l),h=be(f-su*c),p=be(l*(c-h)-mye*o),d=be(su*t*n);return new qt(h,p,d)}add(e){if(!(e instanceof qt))throw new TypeError("JacobianPoint expected");let{x:t,y:n,z:i}=this,{x:s,y:o,z:a}=e;if(s===At||o===At)return this;if(t===At||n===At)return e;let c=be(i*i),l=be(a*a),f=be(t*l),h=be(s*c),p=be(be(n*a)*l),d=be(be(o*i)*c),m=be(h-f),y=be(d-p);if(m===At)return y===At?this.double():qt.ZERO;let g=be(m*m),w=be(m*g),b=be(f*g),S=be(y*y-w-su*b),_=be(y*(b-S)-p*w),I=be(i*a*m);return new qt(S,_,I)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let t=qt.ZERO;if(typeof e=="bigint"&&e===At)return t;let n=QF(e);if(n===pr)return this;if(!Pw){let h=t,p=this;for(;n>At;)n&pr&&(h=h.add(p)),p=p.double(),n>>=pr;return h}let{k1neg:i,k1:s,k2neg:o,k2:a}=ZF(n),c=t,l=t,f=this;for(;s>At||a>At;)s&pr&&(c=c.add(f)),a&pr&&(l=l.add(f)),f=f.double(),s>>=pr,a>>=pr;return i&&(c=c.negate()),o&&(l=l.negate()),l=new qt(be(l.x*wr.beta),l.y,l.z),c.add(l)}precomputeWindow(e){let t=Pw?128/e+1:256/e+1,n=[],i=this,s=i;for(let o=0;o<t;o++){s=i,n.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t){!t&&this.equals(qt.BASE)&&(t=jt.BASE);let n=t&&t._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=t&&jS.get(t);i||(i=this.precomputeWindow(n),t&&n!==1&&(i=qt.normalizeZ(i),jS.set(t,i)));let s=qt.ZERO,o=qt.ZERO,a=1+(Pw?128/n:256/n),c=2**(n-1),l=BigInt(2**n-1),f=2**n,h=BigInt(n);for(let p=0;p<a;p++){let d=p*c,m=Number(e&l);if(e>>=h,m>c&&(m-=f,e+=pr),m===0){let y=i[d];p%2&&(y=y.negate()),o=o.add(y)}else{let y=i[d+Math.abs(m)-1];m<0&&(y=y.negate()),s=s.add(y)}}return{p:s,f:o}}multiply(e,t){let n=QF(e),i,s;if(Pw){let{k1neg:o,k1:a,k2neg:c,k2:l}=ZF(n),{p:f,f:h}=this.wNAF(a,t),{p,f:d}=this.wNAF(l,t);o&&(f=f.negate()),c&&(p=p.negate()),p=new qt(be(p.x*wr.beta),p.y,p.z),i=f.add(p),s=h.add(d)}else{let{p:o,f:a}=this.wNAF(n,t);i=o,s=a}return qt.normalizeZ([i,s])[0]}toAffine(e=Pp(this.z)){let{x:t,y:n,z:i}=this,s=e,o=be(s*s),a=be(o*s),c=be(t*o),l=be(n*a);if(be(i*s)!==pr)throw new Error("invZ was invalid");return new jt(c,l)}};qt.BASE=new qt(wr.Gx,wr.Gy,pr);qt.ZERO=new qt(At,pr,At);var jS=new WeakMap,jt=class{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,jS.delete(this)}hasEvenY(){return this.y%su===At}static fromCompressedHex(e){let t=e.length===32,n=Dc(t?e:e.subarray(1));if(!GS(n))throw new Error("Point is not on curve");let i=jF(n),s=Eye(i),o=(s&pr)===pr;t?o&&(s=be(-s)):(e[0]&1)===1!==o&&(s=be(-s));let a=new jt(n,s);return a.assertValidity(),a}static fromUncompressedHex(e){let t=Dc(e.subarray(1,33)),n=Dc(e.subarray(33,65)),i=new jt(t,n);return i.assertValidity(),i}static fromHex(e){let t=Cp(e),n=t.length,i=t[0];if(n===32||n===33&&(i===2||i===3))return this.fromCompressedHex(t);if(n===65&&i===4)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return jt.BASE.multiply(Nw(e))}static fromSignature(e,t,n){e=Cp(e);let i=JF(e),{r:s,s:o}=eV(t);if(n!==0&&n!==1)throw new Error("Cannot recover signature: invalid recovery bit");let a=n&1?"03":"02",c=jt.fromHex(a+Ip(s)),{n:l}=wr,f=Pp(s,l),h=be(-i*f,l),p=be(o*f,l),d=jt.BASE.multiplyAndAddUnsafe(c,h,p);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(e=!1){return Yf(this.toHex(e))}toHex(e=!1){let t=Ip(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Ip(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){let e="Point is not on elliptic curve",{x:t,y:n}=this;if(!GS(t)||!GS(n))throw new Error(e);let i=be(n*n),s=jF(t);if(be(i-s)!==At)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new jt(this.x,be(-this.y))}double(){return qt.fromAffine(this).double().toAffine()}add(e){return qt.fromAffine(this).add(qt.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return qt.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){let i=qt.fromAffine(this),s=t===At||t===pr||this!==jt.BASE?i.multiplyUnsafe(t):i.multiply(t),o=qt.fromAffine(e).multiplyUnsafe(n),a=s.add(o);return a.equals(qt.ZERO)?void 0:a.toAffine()}};jt.BASE=new jt(wr.Gx,wr.Gy);jt.ZERO=new jt(At,At);function WF(r){return Number.parseInt(r[0],16)>=8?"00"+r:r}function YF(r){if(r.length<2||r[0]!==2)throw new Error(`Invalid signature integer tag: ${Rp(r)}`);let e=r[1],t=r.subarray(2,e+2);if(!e||t.length!==e)throw new Error("Invalid signature integer: wrong length");if(t[0]===0&&t[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Dc(t),left:r.subarray(e+2)}}function yye(r){if(r.length<2||r[0]!=48)throw new Error(`Invalid signature tag: ${Rp(r)}`);if(r[1]!==r.length-2)throw new Error("Invalid signature: incorrect length");let{data:e,left:t}=YF(r.subarray(2)),{data:n,left:i}=YF(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Rp(i)}`);return{r:e,s:n}}var Ia=class{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){let t=e instanceof Uint8Array,n="Signature.fromCompact";if(typeof e!="string"&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);let i=t?Rp(e):e;if(i.length!==128)throw new Error(`${n}: Expected 64-byte hex`);return new Ia(kw(i.slice(0,64)),kw(i.slice(64,128)))}static fromDER(e){let t=e instanceof Uint8Array;if(typeof e!="string"&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");let{r:n,s:i}=yye(t?e:Yf(e));return new Ia(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){let{r:e,s:t}=this;if(!km(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!km(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){let e=wr.n>>pr;return this.s>e}normalizeS(){return this.hasHighS()?new Ia(this.r,wr.n-this.s):this}toDERRawBytes(e=!1){return Yf(this.toDERHex(e))}toDERHex(e=!1){let t=WF(Pm(this.s));if(e)return t;let n=WF(Pm(this.r)),i=Pm(n.length/2),s=Pm(t.length/2);return`30${Pm(n.length/2+t.length/2+4)}02${i}${n}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Yf(this.toCompactHex())}toCompactHex(){return Ip(this.r)+Ip(this.s)}};function Tp(...r){if(!r.every(n=>n instanceof Uint8Array))throw new Error("Uint8Array list expected");if(r.length===1)return r[0];let e=r.reduce((n,i)=>n+i.length,0),t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}var gye=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Rp(r){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t<r.length;t++)e+=gye[r[t]];return e}var wye=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function Ip(r){if(typeof r!="bigint")throw new Error("Expected bigint");if(!(At<=r&&r<wye))throw new Error("Expected number < 2^256");return r.toString(16).padStart(64,"0")}function WS(r){let e=Yf(Ip(r));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function Pm(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function kw(r){if(typeof r!="string")throw new TypeError("hexToNumber: expected string, got "+typeof r);return BigInt(`0x${r}`)}function Yf(r){if(typeof r!="string")throw new TypeError("hexToBytes: expected string, got "+typeof r);if(r.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+r.length);let e=new Uint8Array(r.length/2);for(let t=0;t<e.length;t++){let n=t*2,i=r.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");e[t]=s}return e}function Dc(r){return kw(Rp(r))}function Cp(r){return r instanceof Uint8Array?Uint8Array.from(r):Yf(r)}function QF(r){if(typeof r=="number"&&Number.isSafeInteger(r)&&r>0)return BigInt(r);if(typeof r=="bigint"&&km(r))return r;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function be(r,e=wr.P){let t=r%e;return t>=At?t:e+t}function Ls(r,e){let{P:t}=wr,n=r;for(;e-- >At;)n*=n,n%=t;return n}function Eye(r){let{P:e}=wr,t=BigInt(6),n=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),c=r*r*r%e,l=c*c*r%e,f=Ls(l,Dm)*l%e,h=Ls(f,Dm)*l%e,p=Ls(h,su)*c%e,d=Ls(p,n)*p%e,m=Ls(d,i)*d%e,y=Ls(m,o)*m%e,g=Ls(y,a)*y%e,w=Ls(g,o)*m%e,b=Ls(w,Dm)*l%e,S=Ls(b,s)*d%e,_=Ls(S,t)*c%e;return Ls(_,su)}function Pp(r,e=wr.P){if(r===At||e<=At)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=be(r,e),n=e,i=At,s=pr,o=pr,a=At;for(;t!==At;){let l=n/t,f=n%t,h=i-o*l,p=s-a*l;n=t,t=f,i=o,s=a,o=h,a=p}if(n!==pr)throw new Error("invert: does not exist");return be(i,e)}function bye(r,e=wr.P){let t=new Array(r.length),n=r.reduce((s,o,a)=>o===At?s:(t[a]=s,be(s*o,e)),pr),i=Pp(n,e);return r.reduceRight((s,o,a)=>o===At?s:(t[a]=be(s*t[a],e),be(s*o,e)),i),t}var XF=(r,e)=>(r+e/su)/e,vye={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-pr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function ZF(r){let{n:e}=wr,{a1:t,b1:n,a2:i,b2:s,POW_2_128:o}=vye,a=XF(s*r,e),c=XF(-n*r,e),l=be(r-a*t-c*i,e),f=be(-a*n-c*s,e),h=l>o,p=f>o;if(h&&(l=e-l),p&&(f=e-f),l>o||f>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+r);return{k1neg:h,k1:l,k2neg:p,k2:f}}function JF(r){let{n:e}=wr,n=r.length*8-256,i=Dc(r);return n>0&&(i=i>>BigInt(n)),i>=e&&(i-=e),i}var Ap,Om,YS=class{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Io.hmacSha256(this.k,...e)}hmacSync(...e){return Om(this.k,...e)}checkSync(){if(typeof Om!="function")throw new Ow("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(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),e.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){return this.incr(),this.v=await this.hmac(this.v),this.v}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}};function km(r){return At<r&&r<wr.n}function GS(r){return At<r&&r<wr.P}function _ye(r,e,t){let n=Dc(r);if(!km(n))return;let{n:i}=wr,s=jt.BASE.multiply(n),o=be(s.x,i);if(o===At)return;let a=be(Pp(n,i)*be(e+t*o,i),i);if(a===At)return;let c=new Ia(o,a),l=(s.x===c.r?0:2)|Number(s.y&pr);return{sig:c,recovery:l}}function Nw(r){let e;if(typeof r=="bigint")e=r;else if(typeof r=="number"&&Number.isSafeInteger(r)&&r>0)e=BigInt(r);else if(typeof r=="string"){if(r.length!==64)throw new Error("Expected 32 bytes of private key");e=kw(r)}else if(r instanceof Uint8Array){if(r.length!==32)throw new Error("Expected 32 bytes of private key");e=Dc(r)}else throw new TypeError("Expected valid private key");if(!km(e))throw new Error("Expected private key: 0 < key < n");return e}function Sye(r){return r instanceof jt?(r.assertValidity(),r):jt.fromHex(r)}function eV(r){if(r instanceof Ia)return r.assertValidity(),r;try{return Ia.fromDER(r)}catch{return Ia.fromCompact(r)}}function QS(r,e=!1){return jt.fromPrivateKey(r).toRawBytes(e)}function tV(r){let e=r.length>32?r.slice(0,32):r;return Dc(e)}function xye(r){let e=tV(r),t=be(e,wr.n);return rV(t<At?e:t)}function rV(r){return WS(r)}function Tye(r,e,t){if(r==null)throw new Error(`sign: expected valid message hash, not "${r}"`);let n=Cp(r),i=Nw(e),s=[rV(i),xye(n)];if(t!=null){t===!0&&(t=Io.randomBytes(32));let c=Cp(t);if(c.length!==32)throw new Error("sign: Expected 32 bytes of extra data");s.push(c)}let o=Tp(...s),a=tV(n);return{seed:o,m:a,d:i}}function Iye(r,e){let{sig:t,recovery:n}=r,{canonical:i,der:s,recovered:o}=Object.assign({canonical:!0,der:!0},e);i&&t.hasHighS()&&(t=t.normalizeS(),n^=1);let a=s?t.toDERRawBytes():t.toCompactRawBytes();return o?[a,n]:a}async function nV(r,e,t={}){let{seed:n,m:i,d:s}=Tye(r,e,t.extraEntropy),o,a=new YS;for(await a.reseed(n);!(o=_ye(await a.generate(),i,s));)await a.reseed();return Iye(o,t)}var Aye={strict:!0};function iV(r,e,t,n=Aye){let i;try{i=eV(r),e=Cp(e)}catch{return!1}let{r:s,s:o}=i;if(n.strict&&i.hasHighS())return!1;let a=JF(e),c;try{c=Sye(t)}catch{return!1}let{n:l}=wr,f=Pp(o,l),h=be(a*f,l),p=be(s*f,l),d=jt.BASE.multiplyAndAddUnsafe(c,h,p);return d?be(d.x,l)===s:!1}jt.BASE._setWindowSize(8);var ji={node:pye,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};var Dw={},Io={bytesToHex:Rp,hexToBytes:Yf,concatBytes:Tp,mod:be,invert:Pp,isValidPrivateKey(r){try{return Nw(r),!0}catch{return!1}},_bigintTo32Bytes:WS,_normalizePrivateKey:Nw,hashToPrivateKey:r=>{if(r=Cp(r),r.length<40||r.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");let e=be(Dc(r),wr.n-pr)+pr;return WS(e)},randomBytes:(r=32)=>{if(ji.web)return ji.web.getRandomValues(new Uint8Array(r));if(ji.node){let{randomBytes:e}=ji.node;return Uint8Array.from(e(r))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Io.hashToPrivateKey(Io.randomBytes(40)),sha256:async(...r)=>{if(ji.web){let e=await ji.web.subtle.digest("SHA-256",Tp(...r));return new Uint8Array(e)}else if(ji.node){let{createHash:e}=ji.node,t=e("sha256");return r.forEach(n=>t.update(n)),Uint8Array.from(t.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(r,...e)=>{if(ji.web){let t=await ji.web.subtle.importKey("raw",r,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=Tp(...e),i=await ji.web.subtle.sign("HMAC",t,n);return new Uint8Array(i)}else if(ji.node){let{createHmac:t}=ji.node,n=t("sha256",r);return e.forEach(i=>n.update(i)),Uint8Array.from(n.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(r,...e)=>{let t=Dw[r];if(t===void 0){let n=await Io.sha256(Uint8Array.from(r,i=>i.charCodeAt(0)));t=Tp(n,n),Dw[r]=t}return Io.sha256(t,...e)},taggedHashSync:(r,...e)=>{if(typeof Ap!="function")throw new Ow("sha256Sync is undefined, you need to set it");let t=Dw[r];if(t===void 0){let n=Ap(Uint8Array.from(r,i=>i.charCodeAt(0)));t=Tp(n,n),Dw[r]=t}return Ap(t,...e)},precompute(r=8,e=jt.BASE){let t=e===jt.BASE?e:new jt(e.x,e.y);return t._setWindowSize(r),t.multiply(Dm),t}};Object.defineProperties(Io,{sha256Sync:{configurable:!1,get(){return Ap},set(r){Ap||(Ap=r)}},hmacSha256Sync:{configurable:!1,get(){return Om},set(r){Om||(Om=r)}}});var sV=E(V(),1);function Si(r){if(isNaN(r)||r<=0)throw(0,sV.default)(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return Io.randomBytes(r)}var Qf={};Kt(Qf,{jwkToPkcs1:()=>Pye,jwkToPkix:()=>Oye,pkcs1ToJwk:()=>Cye,pkixToJwk:()=>Dye});u();var gNe=E(eu(),1),wNe=E(Rm(),1),Oc=E(ft(),1);var XS=E(V(),1);function Cye(r){let e=Oc.default.asn1.fromDer(K(r,"ascii")),t=Oc.default.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:To(t.n),e:To(t.e),d:To(t.d),p:To(t.p),q:To(t.q),dp:To(t.dP),dq:To(t.dQ),qi:To(t.qInv),alg:"RS256"}}function Pye(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw(0,XS.default)(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");let e=Oc.default.pki.privateKeyToAsn1({n:Gi(r.n),e:Gi(r.e),d:Gi(r.d),p:Gi(r.p),q:Gi(r.q),dP:Gi(r.dp),dQ:Gi(r.dq),qInv:Gi(r.qi)});return z(Oc.default.asn1.toDer(e).getBytes(),"ascii")}function Dye(r){let e=Oc.default.asn1.fromDer(K(r,"ascii")),t=Oc.default.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:To(t.n),e:To(t.e)}}function Oye(r){if(r.n==null||r.e==null)throw(0,XS.default)(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");let e=Oc.default.pki.publicKeyToAsn1({n:Gi(r.n),e:Gi(r.e)});return z(Oc.default.asn1.toDer(e).getBytes(),"ascii")}u();var _Ne=E(Rm(),1),ZS=E(ft(),1);function oV(r,e){return e.map(t=>Gi(r[t]))}function aV(r){return ZS.default.pki.setRsaPrivateKey(...oV(r,["n","e","d","p","q","dp","dq","qi"]))}function cV(r){return ZS.default.pki.setRsaPublicKey(...oV(r,["n","e"]))}var lV=E(V(),1);async function uV(r){let e=await Yr.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await dV(e);return{privateKey:t[0],publicKey:t[1]}}async function JS(r){let t=[await Yr.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await kye(r)],n=await dV({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function fV(r,e){let t=await Yr.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Yr.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(n,0,n.byteLength)}async function hV(r,e,t){let n=await Yr.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return await Yr.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t)}async function dV(r){if(r.privateKey==null||r.publicKey==null)throw(0,lV.default)(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return await Promise.all([Yr.get().subtle.exportKey("jwk",r.privateKey),Yr.get().subtle.exportKey("jwk",r.publicKey)])}async function kye(r){return await Yr.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function pV(r,e,t,n){let i=e?cV(r):aV(r),s=K(Uint8Array.from(t),"ascii"),o=n(s,i);return z(o,"ascii")}function mV(r,e){return pV(r,!0,e,(t,n)=>n.encrypt(t))}function yV(r,e){return pV(r,!1,e,(t,n)=>n.decrypt(t))}u();async function Dp(r,e){let n=await Cw().encrypt(r,e);return na.encode(n)}var Lm=class{constructor(e){this._key=e}async verify(e,t){return await hV(this._key,t,e)}marshal(){return Qf.jwkToPkix(this._key)}get bytes(){return vo.encode({Type:tr.RSA,Data:this.marshal()}).subarray()}encrypt(e){return mV(this._key,e)}equals(e){return ze(this.bytes,e.bytes)}async hash(){let{bytes:e}=await $e.digest(this.bytes);return e}},Op=class{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Si(16)}async sign(e){return await fV(this._key,e)}get public(){if(this._publicKey==null)throw(0,ex.default)(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Lm(this._publicKey)}decrypt(e){return yV(this._key,e)}marshal(){return Qf.jwkToPkcs1(this._key)}get bytes(){return _o.encode({Type:tr.RSA,Data:this.marshal()}).subarray()}equals(e){return ze(this.bytes,e.bytes)}async hash(){let{bytes:e}=await $e.digest(this.bytes);return e}async id(){let e=await this.public.hash();return K(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8"){let n=new Nm.default.util.ByteBuffer(this.marshal()),i=Nm.default.asn1.fromDer(n),s=Nm.default.pki.privateKeyFromAsn1(i),o={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return Nm.default.pki.encryptRsaPrivateKey(s,e,o)}else{if(t==="libp2p-key")return await Dp(this.bytes,e);throw(0,ex.default)(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}};async function Lye(r){let e=Qf.pkcs1ToJwk(r),t=await JS(e);return new Op(t.privateKey,t.publicKey)}function Bye(r){let e=Qf.pkixToJwk(r);return new Lm(e)}async function Mye(r){let e=await JS(r);return new Op(e.privateKey,e.publicKey)}async function Uye(r){let e=await uV(r);return new Op(e.privateKey,e.publicKey)}var hx={};Kt(hx,{Ed25519PrivateKey:()=>Zf,Ed25519PublicKey:()=>Vm,generateKeyPair:()=>ige,generateKeyPairFromSeed:()=>fx,unmarshalEd25519PrivateKey:()=>rge,unmarshalEd25519PublicKey:()=>nge});u();var ux=E(V(),1);u();u();var Fye=E(ru(),1);var On=BigInt(0),Ct=BigInt(1),kp=BigInt(2),gV=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Er=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:gV,n:gV,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")});var vV=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),Bm=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),MNe=BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),Vye=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Kye=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),qye=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),zye=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Rt=class{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.t=i}static fromAffine(e){if(!(e instanceof Ar))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(Ar.ZERO)?Rt.ZERO:new Rt(e.x,e.y,Ct,Z(e.x*e.y))}static toAffineBatch(e){let t=Gye(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(t[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){wV(e);let{x:t,y:n,z:i}=this,{x:s,y:o,z:a}=e,c=Z(t*a),l=Z(s*i),f=Z(n*a),h=Z(o*i);return c===l&&f===h}negate(){return new Rt(Z(-this.x),this.y,this.z,Z(-this.t))}double(){let{x:e,y:t,z:n}=this,{a:i}=Er,s=Z(e*e),o=Z(t*t),a=Z(kp*Z(n*n)),c=Z(i*s),l=e+t,f=Z(Z(l*l)-s-o),h=c+o,p=h-a,d=c-o,m=Z(f*p),y=Z(h*d),g=Z(f*d),w=Z(p*h);return new Rt(m,y,w,g)}add(e){wV(e);let{x:t,y:n,z:i,t:s}=this,{x:o,y:a,z:c,t:l}=e,f=Z((n-t)*(a+o)),h=Z((n+t)*(a-o)),p=Z(h-f);if(p===On)return this.double();let d=Z(i*kp*l),m=Z(s*kp*c),y=m+d,g=h+f,w=m-d,b=Z(y*p),S=Z(g*w),_=Z(y*w),I=Z(p*g);return new Rt(b,S,I,_)}subtract(e){return this.add(e.negate())}precomputeWindow(e){let t=1+256/e,n=[],i=this,s=i;for(let o=0;o<t;o++){s=i,n.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t){!t&&this.equals(Rt.BASE)&&(t=Ar.BASE);let n=t&&t._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=t&&ox.get(t);i||(i=this.precomputeWindow(n),t&&n!==1&&(i=Rt.normalizeZ(i),ox.set(t,i)));let s=Rt.ZERO,o=Rt.ZERO,a=1+256/n,c=2**(n-1),l=BigInt(2**n-1),f=2**n,h=BigInt(n);for(let p=0;p<a;p++){let d=p*c,m=Number(e&l);if(e>>=h,m>c&&(m-=f,e+=Ct),m===0){let y=i[d];p%2&&(y=y.negate()),o=o.add(y)}else{let y=i[d+Math.abs(m)-1];m<0&&(y=y.negate()),s=s.add(y)}}return Rt.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Bw(e,Er.l),t)}multiplyUnsafe(e){let t=Bw(e,Er.l,!1),n=Rt.BASE,i=Rt.ZERO;if(t===On)return i;if(this.equals(i)||t===Ct)return this;if(this.equals(n))return this.wNAF(t);let s=i,o=this;for(;t>On;)t&Ct&&(s=s.add(o)),o=o.double(),t>>=Ct;return s}isSmallOrder(){return this.multiplyUnsafe(Er.h).equals(Rt.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Er.l).equals(Rt.ZERO)}toAffine(e=Mw(this.z)){let{x:t,y:n,z:i}=this,s=Z(t*e),o=Z(n*e);if(Z(i*e)!==Ct)throw new Error("invZ was invalid");return new Ar(s,o)}fromRistrettoBytes(){nx()}toRistrettoBytes(){nx()}fromRistrettoHash(){nx()}};Rt.BASE=new Rt(Er.Gx,Er.Gy,Ct,Z(Er.Gx*Er.Gy));Rt.ZERO=new Rt(On,Ct,Ct,On);function wV(r){if(!(r instanceof Rt))throw new TypeError("ExtendedPoint expected")}function rx(r){if(!(r instanceof xi))throw new TypeError("RistrettoPoint expected")}function nx(){throw new Error("Legacy method: switch to RistrettoPoint")}var xi=class{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){let{d:t}=Er,n=Z(Bm*e*e),i=Z((n+Ct)*qye),s=BigInt(-1),o=Z((s-t*n)*Z(n+t)),{isValid:a,value:c}=cx(i,o),l=Z(c*e);au(l)||(l=Z(-l)),a||(c=l),a||(s=n);let f=Z(s*(n-Ct)*zye-o),h=c*c,p=Z((c+c)*o),d=Z(f*Vye),m=Z(Ct-h),y=Z(Ct+h);return new Rt(Z(p*y),Z(m*d),Z(d*y),Z(p*m))}static hashToCurve(e){e=cu(e,64);let t=ix(e.slice(0,32)),n=this.calcElligatorRistrettoMap(t),i=ix(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new xi(n.add(s))}static fromHex(e){e=cu(e,32);let{a:t,d:n}=Er,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=ix(e);if(!Wye(Mm(s),e)||au(s))throw new Error(i);let o=Z(s*s),a=Z(Ct+t*o),c=Z(Ct-t*o),l=Z(a*a),f=Z(c*c),h=Z(t*n*l-f),{isValid:p,value:d}=bV(Z(h*f)),m=Z(d*c),y=Z(d*m*h),g=Z((s+s)*m);au(g)&&(g=Z(-g));let w=Z(a*y),b=Z(g*w);if(!p||au(b)||w===On)throw new Error(i);return new xi(new Rt(g,w,Ct,b))}toRawBytes(){let{x:e,y:t,z:n,t:i}=this.ep,s=Z(Z(n+t)*Z(n-t)),o=Z(e*t),a=Z(o*o),{value:c}=bV(Z(s*a)),l=Z(c*s),f=Z(c*o),h=Z(l*f*i),p;if(au(i*h)){let m=Z(t*Bm),y=Z(e*Bm);e=m,t=y,p=Z(l*Kye)}else p=f;au(e*h)&&(t=Z(-t));let d=Z((n-t)*p);return au(d)&&(d=Z(-d)),Mm(d)}toHex(){return Um(this.toRawBytes())}toString(){return this.toHex()}equals(e){rx(e);let t=this.ep,n=e.ep,i=Z(t.x*n.y)===Z(t.y*n.x),s=Z(t.y*n.y)===Z(t.x*n.x);return i||s}add(e){return rx(e),new xi(this.ep.add(e.ep))}subtract(e){return rx(e),new xi(this.ep.subtract(e.ep))}multiply(e){return new xi(this.ep.multiply(e))}multiplyUnsafe(e){return new xi(this.ep.multiplyUnsafe(e))}};xi.BASE=new xi(Rt.BASE);xi.ZERO=new xi(Rt.ZERO);var ox=new WeakMap,Ar=class{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,ox.delete(this)}static fromHex(e,t=!0){let{d:n,P:i}=Er;e=cu(e,32);let s=e.slice();s[31]=e[31]&-129;let o=Fm(s);if(t&&o>=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=vV)throw new Error("Expected 0 < hex < 2**256");let a=Z(o*o),c=Z(a-Ct),l=Z(n*a+Ct),{isValid:f,value:h}=cx(c,l);if(!f)throw new Error("Point.fromHex: invalid y coordinate");let p=(h&Ct)===Ct;return(e[31]&128)!==0!==p&&(h=Z(-h)),new Ar(h,o)}static async fromPrivateKey(e){return(await Uw(e)).point}toRawBytes(){let e=Mm(this.y);return e[31]|=this.x&Ct?128:0,e}toHex(){return Um(this.toRawBytes())}toX25519(){let{y:e}=this,t=Z((Ct+e)*Mw(Ct-e));return Mm(t)}isTorsionFree(){return Rt.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Ar(Z(-this.x),this.y)}add(e){return Rt.fromAffine(this).add(Rt.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Rt.fromAffine(this).multiply(e,this).toAffine()}};Ar.BASE=new Ar(Er.Gx,Er.Gy);Ar.ZERO=new Ar(On,Ct);var Xf=class{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){let t=cu(e,64),n=Ar.fromHex(t.slice(0,32),!1),i=Fm(t.slice(32,64));return new Xf(n,i)}assertValidity(){let{r:e,s:t}=this;if(!(e instanceof Ar))throw new Error("Expected Point instance");return Bw(t,Er.l,!1),this}toRawBytes(){let e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Mm(this.s),32),e}toHex(){return Um(this.toRawBytes())}};function EV(...r){if(!r.every(n=>n instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(r.length===1)return r[0];let e=r.reduce((n,i)=>n+i.length,0),t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let s=r[n];t.set(s,i),i+=s.length}return t}var $ye=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Um(r){if(!(r instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=$ye[r[t]];return e}function ax(r){if(typeof r!="string")throw new TypeError("hexToBytes: expected string, got "+typeof r);if(r.length%2)throw new Error("hexToBytes: received invalid unpadded hex");let e=new Uint8Array(r.length/2);for(let t=0;t<e.length;t++){let n=t*2,i=r.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");e[t]=s}return e}function _V(r){let t=r.toString(16).padStart(64,"0");return ax(t)}function Mm(r){return _V(r).reverse()}function au(r){return(Z(r)&Ct)===Ct}function Fm(r){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+Um(Uint8Array.from(r).reverse()))}var Hye=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function ix(r){return Z(Fm(r)&Hye)}function Z(r,e=Er.P){let t=r%e;return t>=On?t:e+t}function Mw(r,e=Er.P){if(r===On||e<=On)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Z(r,e),n=e,i=On,s=Ct,o=Ct,a=On;for(;t!==On;){let l=n/t,f=n%t,h=i-o*l,p=s-a*l;n=t,t=f,i=o,s=a,o=h,a=p}if(n!==Ct)throw new Error("invert: does not exist");return Z(i,e)}function Gye(r,e=Er.P){let t=new Array(r.length),n=r.reduce((s,o,a)=>o===On?s:(t[a]=s,Z(s*o,e)),Ct),i=Mw(n,e);return r.reduceRight((s,o,a)=>o===On?s:(t[a]=Z(s*t[a],e),Z(s*o,e)),i),t}function Aa(r,e){let{P:t}=Er,n=r;for(;e-- >On;)n*=n,n%=t;return n}function jye(r){let{P:e}=Er,t=BigInt(5),n=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),c=r*r%e*r%e,l=Aa(c,kp)*c%e,f=Aa(l,Ct)*r%e,h=Aa(f,t)*f%e,p=Aa(h,n)*h%e,d=Aa(p,i)*p%e,m=Aa(d,s)*d%e,y=Aa(m,o)*m%e,g=Aa(y,o)*m%e,w=Aa(g,n)*h%e;return{pow_p_5_8:Aa(w,kp)*r%e,b2:c}}function cx(r,e){let t=Z(e*e*e),n=Z(t*t*e),i=jye(r*n).pow_p_5_8,s=Z(r*t*i),o=Z(e*s*s),a=s,c=Z(s*Bm),l=o===r,f=o===Z(-r),h=o===Z(-r*Bm);return l&&(s=a),(f||h)&&(s=c),au(s)&&(s=Z(-s)),{isValid:l||f,value:s}}function bV(r){return cx(Ct,r)}function Lw(r){return Z(Fm(r),Er.l)}function Wye(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function cu(r,e){let t=r instanceof Uint8Array?Uint8Array.from(r):ax(r);if(typeof e=="number"&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Bw(r,e,t=!0){if(!e)throw new TypeError("Specify max value");if(typeof r=="number"&&Number.isSafeInteger(r)&&(r=BigInt(r)),typeof r=="bigint"&&r<e){if(t){if(On<r)return r}else if(On<=r)return r}throw new TypeError("Expected valid scalar: 0 < scalar < max")}function Yye(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Qye(r){if(r=typeof r=="bigint"||typeof r=="number"?_V(Bw(r,vV)):cu(r),r.length!==32)throw new Error("Expected 32 bytes");return r}function Xye(r){let e=Yye(r.slice(0,32)),t=r.slice(32,64),n=Lw(e),i=Ar.BASE.multiply(n),s=i.toRawBytes();return{head:e,prefix:t,scalar:n,point:i,pointBytes:s}}var sx;async function Uw(r){return Xye(await lu.sha512(Qye(r)))}async function lx(r){return(await Uw(r)).pointBytes}async function SV(r,e){r=cu(r);let{prefix:t,scalar:n,pointBytes:i}=await Uw(e),s=Lw(await lu.sha512(t,r)),o=Ar.BASE.multiply(s),a=Lw(await lu.sha512(o.toRawBytes(),i,r)),c=Z(s+a*n,Er.l);return new Xf(o,c).toRawBytes()}function Zye(r,e,t){e=cu(e),t instanceof Ar||(t=Ar.fromHex(t,!1));let{r:n,s:i}=r instanceof Xf?r.assertValidity():Xf.fromHex(r),s=Rt.BASE.multiplyUnsafe(i);return{r:n,s:i,SB:s,pub:t,msg:e}}function Jye(r,e,t,n){let i=Lw(n),s=Rt.fromAffine(r).multiplyUnsafe(i);return Rt.fromAffine(e).add(s).subtract(t).multiplyUnsafe(Er.h).equals(Rt.ZERO)}async function xV(r,e,t){let{r:n,SB:i,msg:s,pub:o}=Zye(r,e,t),a=await lu.sha512(n.toRawBytes(),o.toRawBytes(),s);return Jye(o,n,i,a)}Ar.BASE._setWindowSize(8);var ou={node:Fye,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},lu={bytesToHex:Um,hexToBytes:ax,concatBytes:EV,getExtendedPublicKey:Uw,mod:Z,invert:Mw,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:r=>{if(r=cu(r),r.length<40||r.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(Fm(r),Er.l-Ct)+Ct},randomBytes:(r=32)=>{if(ou.web)return ou.web.getRandomValues(new Uint8Array(r));if(ou.node){let{randomBytes:e}=ou.node;return new Uint8Array(e(r).buffer)}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>lu.randomBytes(32),sha512:async(...r)=>{let e=EV(...r);if(ou.web){let t=await ou.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}else{if(ou.node)return Uint8Array.from(ou.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")}},precompute(r=8,e=Ar.BASE){let t=e.equals(Ar.BASE)?e:new Ar(e.x,e.y);return t._setWindowSize(r),t.multiply(kp),t},sha512Sync:void 0};Object.defineProperties(lu,{sha512Sync:{configurable:!1,get(){return sx},set(r){sx||(sx=r)}}});var Np=32,kc=64,Fw=32;async function TV(){let r=lu.randomPrivateKey(),e=await lx(r);return{privateKey:CV(r,e),publicKey:e}}async function IV(r){if(r.length!==Fw)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=await lx(e);return{privateKey:CV(e,t),publicKey:t}}async function AV(r,e){let t=r.slice(0,Fw);return await SV(e,t)}async function RV(r,e,t){return await xV(e,t,r)}function CV(r,e){let t=new Uint8Array(kc);for(let n=0;n<Fw;n++)t[n]=r[n],t[Fw+n]=e[n];return t}var Vm=class{constructor(e){this._key=Lp(e,Np)}async verify(e,t){return await RV(this._key,t,e)}marshal(){return this._key}get bytes(){return vo.encode({Type:tr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ze(this.bytes,e.bytes)}async hash(){let{bytes:e}=await $e.digest(this.bytes);return e}},Zf=class{constructor(e,t){this._key=Lp(e,kc),this._publicKey=Lp(t,Np)}async sign(e){return await AV(this._key,e)}get public(){return new Vm(this._publicKey)}marshal(){return this._key}get bytes(){return _o.encode({Type:tr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ze(this.bytes,e.bytes)}async hash(){let{bytes:e}=await $e.digest(this.bytes);return e}async id(){let e=await on.digest(this.public.bytes);return Ue.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return await Dp(this.bytes,e);throw(0,ux.default)(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}};function rge(r){if(r.length>kc){r=Lp(r,kc+Np);let n=r.slice(0,kc),i=r.slice(kc,r.length);return new Zf(n,i)}r=Lp(r,kc);let e=r.slice(0,kc),t=r.slice(Np);return new Zf(e,t)}function nge(r){return r=Lp(r,Np),new Vm(r)}async function ige(){let{privateKey:r,publicKey:e}=await TV();return new Zf(r,e)}async function fx(r){let{privateKey:e,publicKey:t}=await IV(r);return new Zf(e,t)}function Lp(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw(0,ux.default)(new Error(`Key must be a Uint8Array of length ${e}, got ${r.length}`),"ERR_INVALID_KEY_TYPE");return r}var px={};Kt(px,{Secp256k1PrivateKey:()=>qm,Secp256k1PublicKey:()=>Km,generateKeyPair:()=>cge,unmarshalSecp256k1PrivateKey:()=>oge,unmarshalSecp256k1PublicKey:()=>age});u();var BV=E(V(),1);u();var Bp=E(V(),1);function PV(){return Io.randomPrivateKey()}async function DV(r,e){let{digest:t}=await $e.digest(e);try{return await nV(t,r)}catch(n){throw(0,Bp.default)(n,"ERR_INVALID_INPUT")}}async function OV(r,e,t){try{let{digest:n}=await $e.digest(t);return iV(e,n,r)}catch(n){throw(0,Bp.default)(n,"ERR_INVALID_INPUT")}}function kV(r){return jt.fromHex(r).toRawBytes(!0)}function NV(r){try{QS(r,!0)}catch(e){throw(0,Bp.default)(e,"ERR_INVALID_PRIVATE_KEY")}}function dx(r){try{jt.fromHex(r)}catch(e){throw(0,Bp.default)(e,"ERR_INVALID_PUBLIC_KEY")}}function LV(r){try{return QS(r,!0)}catch(e){throw(0,Bp.default)(e,"ERR_INVALID_PRIVATE_KEY")}}var Km=class{constructor(e){dx(e),this._key=e}async verify(e,t){return await OV(this._key,t,e)}marshal(){return kV(this._key)}get bytes(){return vo.encode({Type:tr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ze(this.bytes,e.bytes)}async hash(){let{bytes:e}=await $e.digest(this.bytes);return e}},qm=class{constructor(e,t){this._key=e,this._publicKey=t??LV(e),NV(this._key),dx(this._publicKey)}async sign(e){return await DV(this._key,e)}get public(){return new Km(this._publicKey)}marshal(){return this._key}get bytes(){return _o.encode({Type:tr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ze(this.bytes,e.bytes)}async hash(){let{bytes:e}=await $e.digest(this.bytes);return e}async id(){let e=await this.public.hash();return K(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return await Dp(this.bytes,e);throw(0,BV.default)(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}};function oge(r){return new qm(r)}function age(r){return new Km(r)}async function cge(){let r=await PV();return new qm(r)}var Ra={rsa:tx,ed25519:hx,secp256k1:px};function mx(r){let e=Object.keys(Ra).join(" / ");return(0,Kw.default)(new Error(`invalid or unsupported key type ${r}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function yx(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return Ra[r];throw mx(r)}async function Mp(r,e){return await yx(r).generateKeyPair(e??2048)}async function lge(r,e,t){if(r.toLowerCase()!=="ed25519")throw(0,Kw.default)(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return await fx(e)}function Ti(r){let e=vo.decode(r),t=e.Data;switch(e.Type){case tr.RSA:return Ra.rsa.unmarshalRsaPublicKey(t);case tr.Ed25519:return Ra.ed25519.unmarshalEd25519PublicKey(t);case tr.Secp256k1:return Ra.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw mx(e.Type)}}function zm(r,e){return e=(e??"rsa").toLowerCase(),yx(e),r.bytes}async function kn(r){let e=_o.decode(r),t=e.Data;switch(e.Type){case tr.RSA:return await Ra.rsa.unmarshalRsaPrivateKey(t);case tr.Ed25519:return Ra.ed25519.unmarshalEd25519PrivateKey(t);case tr.Secp256k1:return Ra.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw mx(e.Type)}}function gx(r,e){return e=(e??"rsa").toLowerCase(),yx(e),r.bytes}async function Nc(r,e){try{let i=await KF(r,e);return await kn(i)}catch{}let t=Vw.default.pki.decryptRsaPrivateKey(r,e);if(t===null)throw(0,Kw.default)(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let n=Vw.default.asn1.toDer(Vw.default.pki.privateKeyToAsn1(t));return n=z(n.getBytes(),"ascii"),await Ra.rsa.unmarshalRsaPrivateKey(n)}var _x=E(V(),1);u();var Up=E(V(),1);u();var MV="ERR_IPNS_EXPIRED_RECORD",$m="ERR_UNRECOGNIZED_VALIDITY",UV="ERR_SIGNATURE_CREATION",Jf="ERR_SIGNATURE_VERIFICATION",FV="ERR_UNRECOGNIZED_FORMAT";var wx="ERR_UNDEFINED_PARAMETER",VV="ERR_INVALID_RECORD_DATA",KV="ERR_INVALID_EMBEDDED_KEY",qV="ERR_MISSING_PRIVATE_KEY";u();var Ii;(function(r){let e;(function(i){i.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(i){i[i.EOL=0]="EOL"})(t||(t={})),function(i){i.codec=()=>Hi(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Et((i,s,o={})=>{o.lengthDelimited!==!1&&s.fork(),i.value!=null&&(s.uint32(10),s.bytes(i.value)),i.signature!=null&&(s.uint32(18),s.bytes(i.signature)),i.validityType!=null&&(s.uint32(24),r.ValidityType.codec().encode(i.validityType,s)),i.validity!=null&&(s.uint32(34),s.bytes(i.validity)),i.sequence!=null&&(s.uint32(40),s.uint64(i.sequence)),i.ttl!=null&&(s.uint32(48),s.uint64(i.ttl)),i.pubKey!=null&&(s.uint32(58),s.bytes(i.pubKey)),i.signatureV2!=null&&(s.uint32(66),s.bytes(i.signatureV2)),i.data!=null&&(s.uint32(74),s.bytes(i.data)),o.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let o={},a=s==null?i.len:i.pos+s;for(;i.pos<a;){let c=i.uint32();switch(c>>>3){case 1:o.value=i.bytes();break;case 2:o.signature=i.bytes();break;case 3:o.validityType=r.ValidityType.codec().decode(i);break;case 4:o.validity=i.bytes();break;case 5:o.sequence=i.uint64();break;case 6:o.ttl=i.uint64();break;case 7:o.pubKey=i.bytes();break;case 8:o.signatureV2=i.bytes();break;case 9:o.data=i.bytes();break;default:i.skipType(c&7);break}}return o})),n),r.encode=i=>wt(i,r.codec()),r.decode=i=>gt(i,r.codec())})(Ii||(Ii={}));Mr();var zV=C("ipns:utils"),$V=z("/ipns/");function Hm(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),i=parseInt(t[2],10)-1,s=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),l=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,i,s,o,a,c,l))}var HV=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw zV.error(n),(0,Up.default)(n,wx)}let t;if(e.pubKey!=null){try{t=Ti(e.pubKey)}catch(i){throw zV.error(i),i}if(!(await ln(e.pubKey)).equals(r))throw(0,Up.default)(new Error("Embedded public key did not match PeerID"),KV)}else r.publicKey!=null&&(t=Ti(r.publicKey));if(t!=null)return t;throw(0,Up.default)(new Error("no public key is available"),wx)},zw=(r,e,t)=>{let n=z(e);return Le([r,t,n])},$w=r=>{let e=z("ipns-signature:");return Le([e,r])},bx=r=>Ii.encode(r),Lc=r=>{let e=Ii.decode(r);return e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),{value:e.value??new Uint8Array(0),signature:e.signature??new Uint8Array(0),validityType:e.validityType??Ii.ValidityType.EOL,validity:e.validity??new Uint8Array(0),sequence:e.sequence??0n,pubKey:e.pubKey,ttl:e.ttl??void 0,signatureV2:e.signatureV2,data:e.data}},uu=r=>Le([$V,r.toBytes()]),vx=r=>Ir(r.slice($V.length)),GV=(r,e,t,n,i)=>{let s;if(t===Ii.ValidityType.EOL)s=0;else throw(0,Up.default)(new Error("Unknown validity type"),$m);return co({Value:r,Validity:e,ValidityType:s,Sequence:n,TTL:i})},jV=r=>{let e=jn(r);if(e.ValidityType===0)e.ValidityType=Ii.ValidityType.EOL;else throw(0,Up.default)(new Error("Unknown validity type"),$m);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e};var YV=C("ipns"),uge=on.code,Gm="/ipns/",Hw=Gm.length,QV=async(r,e,t,n)=>{let i=new WV.default(Date.now()+Number(n)),s=Ii.ValidityType.EOL,[o,a]=n.toString().split("."),c=BigInt(o)*BigInt(1e5)+BigInt(a??"0");return await fge(r,e,t,s,i,c)};var fge=async(r,e,t,n,i,s)=>{t=BigInt(t);let o=z(i.toString());if(r.privateKey==null)throw(0,_x.default)(new Error("Missing private key"),qV);let a=await kn(r.privateKey),c=await dge(a,e,n,o),l=GV(e,o,n,t,s),f=$w(l),h=await a.sign(f),p={value:e,signature:c,validityType:n,validity:o,sequence:t,ttl:s,signatureV2:h,data:l};if(r.publicKey!=null){let d=nr(r.toBytes());(d.code!==uge||!ze(r.publicKey,d.digest))&&(p.pubKey=r.publicKey)}return YV("ipns entry for %b created",e),p},hge=r=>$v.encode(r).slice(1),jm=r=>new fe(`/ipns/${hge(r)}`),dge=async(r,e,t,n)=>{try{let i=zw(e,t,n);return await r.sign(i)}catch(i){throw YV.error("record signature creation failed",i),(0,_x.default)(new Error("record signature creation failed"),UV)}};var Bs=C("ipfs:ipns:publisher"),XV=En().code,ZV=60*60*1e3,eh=class{constructor(e,t){this._routing=e,this._datastore=t}async publishWithEOL(e,t,n,i){let s=await this._updateOrCreateRecord(e,t,n,i);return this._putRecordToRouting(s,e,i)}publish(e,t,n){return this.publishWithEOL(e,t,ZV,n)}async _putRecordToRouting(e,t,n){if(!Rs(t)){let s="peerId received is not valid";throw Bs.error(s),(0,Ms.default)(new Error(s),"ERR_INVALID_PEER_ID")}if(t.publicKey==null)throw(0,Ms.default)(new Error("Public key was missing"),"ERR_MISSING_PUBLIC_KEY");let i=uu(t);return await this._publishEntry(i,e,n),e}async _publishEntry(e,t,n){try{let i=await this._routing.put(e,t,n);return Bs(`ipns record for ${K(e,"base32")} was stored in the routing`),i}catch(i){let s=`ipns record for ${K(e,"base32")} could not be stored in the routing - ${i.stack}`;throw Bs.error(s),Bs.error(i),(0,Ms.default)(new Error(s),"ERR_PUTTING_TO_ROUTING")}}async _getPublished(e,t={}){if(!Rs(e)){let i="peerId received is not valid";throw Bs.error(i),(0,Ms.default)(new Error(i),"ERR_INVALID_PEER_ID")}let n=t.checkRouting!==!1;try{let i=await this._datastore.get(jm(e.toBytes()));return this._unmarshalData(i)}catch(i){if(i.code!==XV){let s=`unexpected error getting the ipns record ${e.toString()} from datastore`;throw Bs.error(s),(0,Ms.default)(new Error(s),"ERR_UNEXPECTED_DATASTORE_RESPONSE")}if(!n)throw(0,Ms.default)(i,"ERR_NOT_FOUND_AND_CHECK_ROUTING_NOT_ENABLED");try{let s=uu(e),o=await this._routing.get(s);return this._unmarshalData(o)}catch(s){throw Bs.error(s),s}}}_unmarshalData(e){try{return Lc(e)}catch(t){throw(0,Ms.default)(t,"ERR_INVALID_RECORD_DATA")}}async _updateOrCreateRecord(e,t,n,i){if(!Rs(e)){let l="peerId received is not valid";throw Bs.error(l),(0,Ms.default)(new Error(l),"ERR_INVALID_PEER_ID")}let s={checkRouting:!0},o;try{o=await this._getPublished(e,s)}catch(l){if(l.code!==XV){let f=`unexpected error when determining the last published IPNS record for ${e.toString()} ${l.stack}`;throw Bs.error(f),(0,Ms.default)(new Error(f),"ERR_DETERMINING_PUBLISHED_RECORD")}}let a=0n;o&&o.sequence!==void 0&&(a=ze(o.value,t)?o.sequence:o.sequence+BigInt(1));let c;try{c=await QV(e,t,a,n)}catch(l){let f=`ipns record for ${t} could not be created`;throw Bs.error(l),(0,Ms.default)(new Error(f),"ERR_CREATING_IPNS_RECORD")}try{let l=bx(c);return await this._datastore.put(jm(e.toBytes()),l,i),Bs(`ipns record for ${K(t,"base32")} was stored in the datastore`),l}catch{let f=`ipns record for ${t} could not be stored in the datastore`;throw Bs.error(f),(0,Ms.default)(new Error(f),"ERR_STORING_IN_DATASTORE")}}};eh.defaultRecordLifetime=ZV;u();var th=E(V(),1);var JV=E(an(),1),Gw=C("ipfs:ipns:republisher"),eK=60*1e3,tK=60*eK,pge=4*tK,mge=24*tK,jw=class{constructor(e,t,n,i,s={pass:""}){this._publisher=e,this._datastore=t,this._peerId=n,this._keychain=i,this._options=s,this._republishHandle=null}async start(){if(this._republishHandle)throw(0,th.default)(new Error("republisher is already running"),"ERR_REPUBLISH_ALREADY_RUNNING");let e={_task:null,_inflightTask:null,_timeoutId:null,runPeriodically:i=>{e._timeoutId=setTimeout(async()=>{e._timeoutId=null;try{e._inflightTask=e._task(),await e._inflightTask,e._task&&e.runPeriodically(i)}catch(s){Gw.error(s)}},i())},cancel:async()=>{e._timeoutId!=null&&clearTimeout(e._timeoutId),e._task=null,await e._inflightTask}},{pass:t}=this._options,n=!0;e._task=async()=>{let i=new JV.TimeoutController(3e4);try{await this._republishEntries(this._peerId,t,{signal:i.signal})}finally{i.clear()}},e.runPeriodically(()=>n?(n=!1,this._options.initialBroadcastInterval||eK):this._options.broadcastInterval||pge),this._republishHandle=e}async stop(){let e=this._republishHandle;if(!e)throw(0,th.default)(new Error("republisher is not running"),"ERR_REPUBLISH_NOT_RUNNING");this._republishHandle=null,await e.cancel()}async _republishEntries(e,t,n){try{await this._republishEntry(e,n)}catch{let s="cannot republish entry for the node's private key";Gw.error(s);return}if(t)try{let i=await this._keychain.listKeys();for(let s of i){if(s.name==="self")continue;let o=await this._keychain.exportKey(s.name,t),a=await Nc(o,t),c=await ln(a.public.bytes,a.bytes);await this._republishEntry(c,n)}}catch(i){Gw.error(i)}}async _republishEntry(e,t){try{let n=await this._getPreviousValue(e);await this._publisher.publishWithEOL(e,n,mge,t)}catch(n){if(n.code==="ERR_NO_ENTRY_FOUND")return;throw n}}async _getPreviousValue(e){if(!Rs(e))throw(0,th.default)(new Error("invalid peer ID"),"ERR_INVALID_PEER_ID");try{let t=await this._datastore.get(jm(e.toBytes()));if(!(t instanceof Uint8Array))throw(0,th.default)(new Error("found ipns record that we couldn't process"),"ERR_INVALID_IPNS_RECORD");try{return Lc(t).value}catch(n){throw Gw.error(n),(0,th.default)(new Error("found ipns record that we couldn't convert to a value"),"ERR_INVALID_IPNS_RECORD")}}catch(t){throw t&&t.notFound?(0,th.default)(new Error(`no previous entry for record with id: ${e.toString()}`),"ERR_NO_ENTRY_FOUND"):t}}};u();var Vp=E(V(),1);Mr();u();var Ao=E(V(),1);var Wm=C("ipns:validator"),yge=async(r,e)=>{let{value:t,validityType:n,validity:i}=e,s,o;e.signatureV2!=null&&e.data!=null?(o=e.signatureV2,s=$w(e.data),gge(e)):(o=e.signature??new Uint8Array(0),s=zw(t,n,i));let a;try{a=await r.verify(s,o)}catch{a=!1}if(!a)throw Wm.error("record signature verification failed"),(0,Ao.default)(new Error("record signature verification failed"),Jf);if(i!=null&&n===Ii.ValidityType.EOL){let c;try{c=Hm(K(i))}catch{throw Wm.error("unrecognized validity format (not an rfc3339 format)"),(0,Ao.default)(new Error("unrecognized validity format (not an rfc3339 format)"),FV)}if(c.getTime()<Date.now())throw Wm.error("record has expired"),(0,Ao.default)(new Error("record has expired"),MV)}else if(n!=null)throw Wm.error("unrecognized validity type"),(0,Ao.default)(new Error("unrecognized validity type"),$m);Wm("ipns entry for %b is valid",t)},gge=r=>{if(r.data==null)throw(0,Ao.default)(new Error("Record data is missing"),VV);let e=jV(r.data);if(!ze(e.Value,r.value))throw(0,Ao.default)(new Error('Field "value" did not match between protobuf and CBOR'),Jf);if(!ze(e.Validity,r.validity))throw(0,Ao.default)(new Error('Field "validity" did not match between protobuf and CBOR'),Jf);if(e.ValidityType!==r.validityType)throw(0,Ao.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),Jf);if(e.Sequence!==r.sequence)throw(0,Ao.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),Jf);if(e.TTL!==r.ttl)throw(0,Ao.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),Jf)},Fp=async(r,e)=>{let t=vx(r),n=Lc(e),i=await HV(t,n);await yge(i,n)};var xx=C("ipfs:ipns:resolver"),wge=En().code,rK=32,Ww=class{constructor(e){this._routing=e}async resolve(e,t={}){if(typeof e!="string")throw(0,Vp.default)(new Error("invalid name"),"ERR_INVALID_NAME");let n=t.recursive&&t.recursive.toString()==="true",i=e.split("/");if(i.length!==3||i[0]!=="")throw(0,Vp.default)(new Error("invalid name"),"ERR_INVALID_NAME");let s=i[2],o=1/0;n&&(o=rK);let a=await this.resolver(s,o,t);return xx(`${e} was locally resolved correctly`),a}async resolver(e,t,n){if(t===0){let o=`could not resolve name (recursion limit of ${rK} exceeded)`;throw xx.error(o),(0,Vp.default)(new Error(o),"ERR_RESOLVE_RECURSION_LIMIT")}let i=await this._resolveName(e,n),s=i.split("/");return s[1]==="ipfs"||!t?i:this.resolver(s[2],t-1,n)}async _resolveName(e,t){let n=pe(e),i=uu(n),s;try{s=await this._routing.get(i,t)}catch(o){throw xx.error("could not get record from routing",o),o.code===wge?(0,Vp.default)(new Error(`record requested for ${e} was not found in the network`),"ERR_NO_RECORD_FOUND"):(0,Vp.default)(new Error(`unexpected error getting the ipns record ${n.toString()}`),"ERR_UNEXPECTED_ERROR_GETTING_RECORD")}return this._validateRecord(n,s)}async _validateRecord(e,t){await Fp(Le([z("/ipns/"),e.toBytes()]),t);let n=Lc(t);return K(n.value)}};u();var nK=E(op(),1),Yw=class{constructor(e){this.lru=(0,nK.default)(e)}get(e){let t=this.lru.get(e);if(t){if(t.expire&&t.expire<Date.now()){this.lru.remove(e);return}return t.value}}set(e,t,n){this.lru.set(e,{value:t,expire:Date.now()+n})}has(e){return!!this.get(e)}remove(e){this.lru.remove(e)}clear(){this.lru.clear()}};var Ym=C("ipfs:ipns"),iK=60*1e3,Qm=class{constructor(e,t,n,i,s){this.publisher=new eh(e,t),this.republisher=new jw(this.publisher,t,n,i,s),this.resolver=new Ww(e),this.cache=new Yw(1e3),this.routing=e}async publish(e,t,n=eh.defaultRecordLifetime,i){try{await this.publisher.publishWithEOL(e,t,n,i),Ym(`IPNS value ${K(t,"base32")} was published correctly`);let s=e.toString(),o=parseFloat(n),a=o<iK?o:iK;return this.cache.set(s,t,a),Ym(`IPNS value ${K(t,"base32")} was cached correctly`),{name:s,value:t}}catch(s){throw Ym.error(s),s}}async resolve(e,t={}){if(typeof e!="string")throw(0,sK.default)(new Error("name received is not valid"),"ERR_INVALID_NAME");if(!t.nocache&&!t.recursive){let n=e.split("/")[2],i=this.cache.get(n);if(i)return i}try{let n=await this.resolver.resolve(e,t);return Ym(`IPNS record from ${e} was resolved correctly`),n}catch(n){throw Ym.error(n),n}}async initializeKeyspace(e,t,n){return this.publish(e,t,eh.defaultRecordLifetime,n)}};u();u();u();u();var aK=E(Ro(),1),Qw=(r,e)=>async function*(){yield*(await(0,aK.default)(r)).sort(e)}();var Tx=E(fi(),1),rh=E(Ai(),1),Ix=E(Kp(),1),Ri=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,n){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"))}async*putMany(e,t={}){for await(let{key:n,value:i}of e)await this.put(n,i,t),yield{key:n,value:i}}async*getMany(e,t={}){for await(let n of e)yield this.get(n,t)}async*deleteMany(e,t={}){for await(let n of e)await this.delete(n,t),yield n}batch(){let e=[],t=[];return{put(n,i){e.push({key:n,value:i})},delete(n){t.push(n)},commit:async n=>{await(0,Tx.default)(this.putMany(e,n)),e=[],await(0,Tx.default)(this.deleteMany(t,n)),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 n=this._all(e,t);if(e.prefix!=null&&(n=(0,rh.default)(n,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,rh.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Qw(i,s),n)),e.offset!=null){let i=0;n=(0,rh.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Ix.default)(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(e.prefix!=null&&(n=(0,rh.default)(n,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,rh.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Qw(i,s),n)),e.offset!=null){let i=0;n=(0,rh.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Ix.default)(n,e.limit)),n}};u();u();var Xw=class{constructor(e){if(!(e>0)||(e-1&e)!==0)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 this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},qp=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Xw(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Xw(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function ar(r={}){return hK(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function fK(r={}){return hK(t=>{let n,i=[];for(;!t.isEmpty()&&(n=t.shift(),n!=null);){if(n.error!=null)throw n.error;n.done===!1&&i.push(n.value)}return n==null?{done:!0}:{done:n.done===!0,value:i}},r)}function hK(r,e){e=e??{};let t=e.onEnd,n=new qp,i,s,o,a=async()=>n.isEmpty()?o?{done:!0}:await new Promise((y,g)=>{s=w=>{s=null,n.push(w);try{y(r(n))}catch(b){g(b)}return i}}):r(n),c=y=>s!=null?s(y):(n.push(y),i),l=y=>(n=new qp,s!=null?s({error:y}):(n.push({error:y}),i)),f=y=>{if(o)return i;if(e?.objectMode!==!0&&y?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:y})},h=y=>o?i:(o=!0,y!=null?l(y):c({done:!0})),p=()=>(n=new qp,h(),{done:!0}),d=y=>(h(y),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:a,return:p,throw:d,push:f,end:h,get readableLength(){return n.size}},t==null)return i;let m=i;return i={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(y){return m.throw(y),t!=null&&(t(y),t=void 0),{done:!0}},return(){return m.return(),t!=null&&(t(),t=void 0),{done:!0}},push:f,end(y){return m.end(y),t!=null&&(t(y),t=void 0),i},get readableLength(){return m.readableLength}},i}var Ax=E(fi(),1),Sge=C("datastore:core:tiered"),Xm=class extends Ri{constructor(e){super(),this.stores=e.slice()}async open(){try{await Promise.all(this.stores.map(e=>e.open()))}catch{throw $4()}}async put(e,t,n){try{await Promise.all(this.stores.map(i=>i.put(e,t,n)))}catch{throw G4()}}async get(e,t){for(let n of this.stores)try{let i=await n.get(e,t);if(i)return i}catch(i){Sge.error(i)}throw En()}async has(e,t){for(let n of this.stores)if(await n.has(e,t))return!0;return!1}async delete(e,t){try{await Promise.all(this.stores.map(n=>n.delete(e,t)))}catch{throw H4()}}async*putMany(e,t={}){let n,i=this.stores.map(s=>{let o=ar({objectMode:!0});return(0,Ax.default)(s.putMany(o,t)).catch(a=>{n=a}),o});try{for await(let s of e){if(n)throw n;i.forEach(o=>o.push(s)),yield s}}finally{i.forEach(s=>s.end())}}async*deleteMany(e,t={}){let n,i=this.stores.map(s=>{let o=ar({objectMode:!0});return(0,Ax.default)(s.deleteMany(o,t)).catch(a=>{n=a}),o});try{for await(let s of e){if(n)throw n;i.forEach(o=>o.push(s)),yield s}}finally{i.forEach(s=>s.end())}}async close(){await Promise.all(this.stores.map(e=>e.close()))}batch(){let e=this.stores.map(t=>t.batch());return{put:(t,n)=>{e.forEach(i=>i.put(t,n))},delete:t=>{e.forEach(n=>n.delete(t))},commit:async t=>{for(let n of e)await n.commit(t)}}}query(e,t){return this.stores[this.stores.length-1].query(e,t)}queryKeys(e,t){return this.stores[this.stores.length-1].queryKeys(e,t)}};var t2=E(Zw(),1);u();u();var Jw=(r,e)=>{let t=e.map((n,i)=>({entry:Ii.decode(n),index:i}));return t.sort((n,i)=>{if(n.entry.signatureV2!=null&&i.entry.signatureV2==null)return-1;if(n.entry.signatureV2==null&&i.entry.signatureV2!=null)return 1;let s=n.entry.sequence??0n,o=i.entry.sequence??0n;if(s>o)return-1;if(s<o)return 1;let a=n.entry.validity??new Uint8Array(0),c=i.entry.validity??new Uint8Array(0),l=Hm(K(a)),f=Hm(K(c));return l.getTime()>f.getTime()?-1:l.getTime()<f.getTime()?1:0}),t[0].index};u();u();u();u();u();var dK="SHARDING",pK="_README";u();var Zm=class extends Ri{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,t){this.data[e.toString()]=t}async get(e){if(!await this.has(e))throw En();return this.data[e.toString()]}async has(e){return this.data[e.toString()]!==void 0}async delete(e){delete this.data[e.toString()]}async*_all(){yield*Object.entries(this.data).map(([e,t])=>({key:new fe(e),value:t}))}async*_allKeys(){yield*Object.entries(this.data).map(([e])=>new fe(e))}};u();var Dge=E(Kn(),1);u();var SK=E(Bc(),1),Cge=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},xK=r=>r!=null&&(typeof r[Symbol.asyncIterator]=="function"||typeof r[Symbol.iterator]=="function"||typeof r.next=="function"),Ox=r=>r!=null&&typeof r.sink=="function"&&xK(r.source),Pge=r=>e=>{let t=r.sink(e);if(t.then!=null){let n=ar({objectMode:!0});return t.then(()=>{n.end()},s=>{n.end(s)}),(0,SK.default)(n,async function*(){yield*r.source,n.end()}())}return r.source};function we(r,...e){if(Ox(r)){let n=r;r=()=>n.source}else if(xK(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Ox(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)Ox(t[n])&&(t[n]=Pge(t[n]));return Cge(...t)}u();var HBe=new fe(dK),GBe=new fe(pK);u();var Oge=E(Ai(),1),kge=E(Kp(),1),Nge=E(Bc(),1);u();u();var IK=E(V(),1);var e6="/record/";function kx(r){return K(r,"base32")}function Jm(r){(typeof r=="string"||r instanceof String)&&(r=z(r.toString()));let e=K(r,"base64url");return`${e6}${e}`}function AK(r){if(r.substring(0,e6.length)!==e6)throw(0,IK.default)(new Error("topic received is not from a record"),"ERR_TOPIC_IS_NOT_FROM_RECORD_NAMESPACE");let e=r.substring(e6.length);return z(e,"base64url")}var Wi=E(V(),1);var qn=C("datastore-pubsub:publisher"),t6=class extends Ri{constructor(e,t,n,i,s,o){if(super(),!i)throw(0,Wi.default)(new TypeError("missing validator"),"ERR_INVALID_PARAMETERS");if(typeof i!="function")throw(0,Wi.default)(new TypeError("missing validate function"),"ERR_INVALID_PARAMETERS");if(typeof s!="function")throw(0,Wi.default)(new TypeError("missing select function"),"ERR_INVALID_PARAMETERS");if(o&&typeof o!="function")throw(0,Wi.default)(new TypeError("invalid subscriptionKeyFn received"),"ERR_INVALID_PARAMETERS");this._pubsub=e,this._datastore=t,this._peerId=n,this._validator=i,this._selector=s,this._handleSubscriptionKeyFn=o,this._onMessage=this._onMessage.bind(this),this._pubsub.addEventListener("message",this._onMessage)}async put(e,t,n){if(!(e instanceof Uint8Array)){let s="datastore key does not have a valid format";throw qn.error(s),(0,Wi.default)(new Error(s),"ERR_INVALID_DATASTORE_KEY")}if(!(t instanceof Uint8Array)){let s="received value is not a Uint8Array";throw qn.error(s),(0,Wi.default)(new Error(s),"ERR_INVALID_VALUE_RECEIVED")}let i=Jm(e);qn(`publish value for topic ${i}`),await this._pubsub.publish(i,t)}async get(e,t){if(!(e instanceof Uint8Array)){let s="datastore key does not have a valid format";throw qn.error(s),(0,Wi.default)(new Error(s),"ERR_INVALID_DATASTORE_KEY")}let n=Jm(e),i=await this._pubsub.getTopics();if(i&&Array.isArray(i)&&i.indexOf(n)>-1)return this._getLocal(e,t);try{await this._pubsub.subscribe(n)}catch{let o=`cannot subscribe topic ${n}`;throw qn.error(o),(0,Wi.default)(new Error(o),"ERR_SUBSCRIBING_TOPIC")}return qn(`subscribed values for key ${n}`),this._getLocal(e)}unsubscribe(e){let t=Jm(e);return this._pubsub.unsubscribe(t)}async _getLocal(e,t){let n=new fe("/"+kx(e),!1),i;try{i=await this._datastore.get(n,t)}catch(s){if(s.code!=="ERR_NOT_FOUND"){let a=`unexpected error getting the ipns record for ${n.toString()}`;throw qn.error(a),(0,Wi.default)(new Error(a),"ERR_UNEXPECTED_ERROR_GETTING_RECORD")}let o=`local record requested was not found for ${n.toString()}`;throw qn.error(o),(0,Wi.default)(new Error(o),"ERR_NOT_FOUND")}if(!(i instanceof Uint8Array)){let s="found record that we couldn't convert to a value";throw qn.error(s),(0,Wi.default)(new Error(s),"ERR_INVALID_RECORD_RECEIVED")}return i}async _onMessage(e){let t=e.detail;if(t.type!=="signed"){qn.error("unsigned message received, this module can only work with signed messages");return}let{data:n,from:i,topic:s}=t,o;try{o=AK(s)}catch(a){qn.error(a);return}if(qn(`message received for topic ${s}`),this._peerId.equals(i)){qn("message discarded as it is from the same peer");return}if(this._handleSubscriptionKeyFn){let a;try{a=await this._handleSubscriptionKeyFn(o)}catch{qn.error("message discarded by the subscriptionKeyFn");return}o=a}try{await this._storeIfSubscriptionIsBetter(o,n)}catch(a){qn.error(a)}}async _storeIfSubscriptionIsBetter(e,t,n){let i=!1;try{i=await this._isBetter(e,t)}catch(s){if(s.code!=="ERR_NOT_VALID_RECORD")throw s}i&&await this._storeRecord(e,t,n)}async _validateRecord(e,t){return this._validator(e,t)}async _selectRecord(e,t){return await this._selector(e,t)===0}async _isBetter(e,t){try{await this._validateRecord(e,t)}catch{let o="record received through pubsub is not valid";throw qn.error(o),(0,Wi.default)(new Error(o),"ERR_NOT_VALID_RECORD")}let n=new fe(e),i;try{i=await this._getLocal(n.uint8Array())}catch{return!0}return ze(i,t)?!1:this._selectRecord(e,[i,t])}async _storeRecord(e,t,n){let i=new fe("/"+kx(e),!1);await this._datastore.put(i,t,n),qn(`record for ${Jm(e)} was stored in the datastore`)}};var Nx=E(V(),1);var r6=C("ipfs:ipns:pubsub"),nh=class{constructor(e,t,n){this._subscriptions={},this._handleSubscriptionKey=this._handleSubscriptionKey.bind(this),this._pubsubDs=new t6(e,t,n,Fp,Jw,this._handleSubscriptionKey)}async put(e,t,n){try{await this._pubsubDs.put(e,t,n)}catch(i){throw r6.error(i),i}}async get(e,t){let n,i;try{n=await this._pubsubDs.get(e,t)}catch(o){i=o}let s=e.slice(0,Hw);if(K(s)===Gm){let o=Ue.encode(e).substring(1),a=Ue.encode(e.slice(Hw)).substring(1);this._subscriptions[o]=a,r6(`subscribed to pubsub topic ${o}, id ${a}`)}if(i)throw i;return n}_handleSubscriptionKey(e){e instanceof Uint8Array&&(e=K(e,"base58btc"));let t=this._subscriptions[e];if(!t)throw(0,Nx.default)(new Error(`key ${e} does not correspond to a subscription`),"ERR_INVALID_KEY");try{return uu(pe(t))}catch(n){throw r6.error(n),n}}getSubscriptions(){return Object.values(this._subscriptions).filter(Boolean).map(t=>`${Gm}${t}`)}async cancel(e){if(typeof e!="string")throw(0,Nx.default)(new Error("invalid subscription name"),"ERR_INVALID_SUBSCRIPTION_NAME");e.startsWith(Gm)&&(e=e.substring(Hw));let t=Object.keys(this._subscriptions).find(i=>this._subscriptions[i]===e);if(!t)return{canceled:!1};let n=z(t);return this._pubsubDs.unsubscribe(n),delete this._subscriptions[t],r6(`unsubscribed pubsub ${t}: ${e}`),{canceled:!0}}};u();u();u();var e2;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.key!=null)n.uint32(10),n.bytes(t.key);else throw new Error('Protocol error: required field "key" was not found in object');if(t.value!=null)n.uint32(18),n.bytes(t.value);else throw new Error('Protocol error: required field "value" was not found in object');if(t.timeReceived!=null)n.uint32(42),n.string(t.timeReceived);else throw new Error('Protocol error: required field "timeReceived" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.key=t.bytes();break;case 2:i.value=t.bytes();break;case 5:i.timeReceived=t.string();break;default:t.skipType(o&7);break}}if(i.key==null)throw new Error('Protocol error: value for required field "key" was not found in protobuf');if(i.value==null)throw new Error('Protocol error: value for required field "value" was not found in protobuf');if(i.timeReceived==null)throw new Error('Protocol error: value for required field "timeReceived" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(e2||(e2={}));u();function RK(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),i=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${i}:${s}:${o}.${c}Z`}function CK(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),i=parseInt(t[2],10)-1,s=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),l=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,i,s,o,a,c,l))}var Rr=class{constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return e2.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:RK(this.timeReceived)}}static deserialize(e){let t=e2.decode(e);return new Rr(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=CK(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new Rr(e.key,e.value,t)}};var zp=E(V(),1);var Lx=C("ipfs:ipns:offline-datastore"),$p=class{constructor(e){this._datastore=e,this.stores=[]}async put(e,t,n){if(!(e instanceof Uint8Array))throw(0,zp.default)(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");if(!(t instanceof Uint8Array))throw(0,zp.default)(new Error("Offline datastore value must be a Uint8Array"),"ERR_INVALID_VALUE");let i;try{i=this._routingKey(e)}catch(o){throw Lx.error(o),(0,zp.default)(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}let s=new Rr(e,t,new Date);await this._datastore.put(i,s.serialize(),n)}async get(e,t){if(!(e instanceof Uint8Array))throw(0,zp.default)(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");let n;try{n=this._routingKey(e)}catch(o){throw Lx.error(o),(0,zp.default)(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}let i=await this._datastore.get(n,t),s;try{s=Rr.deserialize(i)}catch(o){throw Lx.error(o),o}return s.value}_routingKey(e){return new fe("/dht/record/"+K(e,"base32"),!1)}};u();var PK=E(fi(),1);var Bge=C("ipfs:ipns:dht-datastore"),n6=class{constructor(e){this._dht=e}async put(e,t,n){try{await(0,PK.default)(this._dht.put(e,t,n))}catch(i){throw Bge.error(i),i}}async get(e,t){for await(let n of this._dht.get(e,t))if(n.name==="VALUE")return n.value;throw En()}};function DK({libp2p:r,repo:e,peerId:t,options:n}){let i=[],s;if((0,t2.default)(n,"EXPERIMENTAL.ipnsPubsub",!1)&&(s=new nh(r.pubsub,e.datastore,t),i.push(s)),(0,t2.default)(n,"offline",!1)!==!0&&["dht","dhtclient","dhtserver"].includes((0,t2.default)(n,"config.Routing.Type","none"))&&i.push(new n6(r.dht)),(0,t2.default)(n,"offline",!1)||i.length===0){let o=new $p(e.datastore);i.push(o)}return new Xm(i)}var Mge=C("ipfs:components:ipns"),i6=class{constructor(e={pass:""}){this.options=e,this.offline=null,this.online=null}getIPNS(){let e=this.online||this.offline;if(e)return e;throw new yc}get routing(){return this.getIPNS().routing}startOffline({repo:e,peerId:t,keychain:n}){if(this.offline!=null)throw new uo;Mge("initializing IPNS keyspace (offline)");let i=new $p(e.datastore),s=new Qm(i,e.datastore,t,n,this.options);this.offline=s}async startOnline({libp2p:e,repo:t,peerId:n,keychain:i}){if(this.online!=null)throw new uo;let s=DK({libp2p:e,repo:t,peerId:n,options:this.options}),o=new Qm(s,t.datastore,n,i,this.options);await o.republisher.start(),this.online=o}async stop(){let e=this.online;e&&(await e.republisher.stop(),this.online=null)}publish(e,t,n,i){return this.getIPNS().publish(e,t,n,i)}resolve(e,t){return this.getIPNS().resolve(e,t)}initializeKeyspace(e,t,n){return this.getIPNS().initializeKeyspace(e,t,n)}};u();u();var Mx=E(V(),1);u();var OK=E(fi(),1);async function kK({ipns:r,repo:e,codecs:t},n,i){if(R4(n))return r.resolve(n);let{cid:s,path:o}=_c(n);await(0,OK.default)($l(s,o||"",t,e,i))}var Bx=C("ipfs:name:publish");function NK({ipns:r,repo:e,codecs:t,peerId:n,isOnline:i,keychain:s}){let o=async c=>{let l;if(c==="self"&&n.privateKey!=null)l=await kn(n.privateKey);else try{let f=await s.exportKey(c,"temp");l=await Nc(f,"temp")}catch(f){throw Bx.error(f),(0,Mx.default)(f,"ERR_CANNOT_GET_KEY")}return ln(l.public.bytes,l.bytes)};async function a(c,l={}){let f=l.resolve!==!1,h=l.lifetime||"24h",p=l.key||"self";if(!i())throw(0,Mx.default)(new Error(O4),"OFFLINE_ERROR");try{c=mB(c)}catch(w){throw Bx.error(w),w}let d=0;try{d=ql(h)||0,d=parseFloat(d.toFixed(6))}catch(w){throw Bx.error(w),w}let m=await Promise.all([o(p),f?kK({ipns:r,repo:e,codecs:t},c):Promise.resolve()]),y=z(c),g=await r.publish(m[0],y,d,l);return{name:g.name,value:K(g.value)}}return M(a)}u();var s6=E(V(),1);var UK=E(BK(),1);var Fge=Qe.bind({ignoreUndefined:!0}),Vge=C("ipfs:name:resolve"),MK=(r,e)=>e.length>0?r+"/"+e.join("/"):r;function FK({dns:r,ipns:e,isOnline:t,options:{offline:n}}){async function*i(s,o={}){if(o=Fge({nocache:!1,recursive:!0},o),n&&o&&o.nocache)throw(0,s6.default)(new Error("cannot specify both offline and nocache"),"ERR_NOCACHE_AND_OFFLINE");if(!t()&&!n)throw(0,s6.default)(new Error(O4),"OFFLINE_ERROR");let a=s.toString();a.startsWith("/ipns/")||(a=`/ipns/${a}`);let[c,l,...f]=a.slice(1).split("/");try{if(l.substring(0,1)==="1"){let p=pe(l),d=nr(p.toBytes());l=A.createV1(114,d).toString(rp)}else{let p=A.parse(l);p.version===1&&(l=p.toString(rp))}}catch(p){if((0,UK.default)(l)){yield MK(await r(l,o),f);return}throw Vge.error(p),(0,s6.default)(new Error("Invalid IPNS name"),"ERR_IPNS_INVALID_NAME")}let h=await e.resolve(`/${c}/${l}`,o);yield MK(h instanceof Uint8Array?K(h):h,f)}return M(i)}u();u();u();var Ux=E(V(),1);function Hp(r,e){if(!r||!(e&&e.ipnsPubsub))throw(0,Ux.default)(new Error("IPNS pubsub subsystem is not enabled"),"ERR_IPNS_PUBSUB_NOT_ENABLED");if(r.routing instanceof nh)return r.routing;let t=(r.routing.stores||[]).find(n=>n instanceof nh);if(!t)throw(0,Ux.default)(new Error("IPNS pubsub datastore not found"),"ERR_PUBSUB_DATASTORE_NOT_FOUND");return t}function VK({ipns:r,options:e}){let t=e.EXPERIMENTAL;async function n(i,s={}){return Hp(r,t).cancel(i,s)}return M(n)}u();function KK({ipns:r,options:e}){let t=e.EXPERIMENTAL;async function n(i={}){try{return{enabled:Boolean(Hp(r,t))}}catch{return{enabled:!1}}}return M(n)}u();function qK({ipns:r,options:e}){let t=e.EXPERIMENTAL;async function n(i={}){return Hp(r,t).getSubscriptions(i)}return M(n)}var o6=class{constructor({ipns:e,options:t}){this.cancel=VK({ipns:e,options:t}),this.state=KK({ipns:e,options:t}),this.subs=qK({ipns:e,options:t})}};var a6=class{constructor({dns:e,ipns:t,repo:n,codecs:i,peerId:s,isOnline:o,keychain:a,options:c}){this.publish=NK({ipns:t,repo:n,codecs:i,peerId:s,isOnline:o,keychain:a}),this.resolve=FK({dns:e,ipns:t,isOnline:o,options:c}),this.pubsub=new o6({ipns:t,options:c})}};u();var zK=E(an(),1),$K=E(ai(),1),Kge=En().code,Fx={default:"<dst>",edges:"<src> -> <dst>"};function HK({repo:r,codecs:e,resolve:t,preload:n}){async function*i(s,o={}){if(o.maxDepth===0)return;if(o.edges&&o.format&&o.format!==Fx.default)throw new Error("Cannot set edges to true and also specify format");if(o.format=o.edges?Fx.edges:o.format,typeof o.maxDepth!="number"&&(o.maxDepth=o.recursive?1/0:1),o.timeout){let f=[new zK.TimeoutController(o.timeout).signal];o.signal&&f.push(o.signal),o.signal=(0,$K.anySignal)(f)}let c=(Array.isArray(s)?s:[s]).map(l=>qge(n,l,o));for(let l of c)try{yield*zge(t,r,e,l,o)}catch(f){yield{ref:"",err:f.message}}}return i}function qge(r,e,t){let{cid:n,path:i}=_c(e);return t.preload!==!1&&r(n),`/ipfs/${n}${i||""}`}async function*zge(r,e,t,n,i){let s=await r(n,i),{cid:o}=_c(s),a=i.maxDepth!=null?i.maxDepth:1/0,c=i.unique||!1;for await(let l of Hge(e,t,o,a,c,i))!l.parent||l.isDuplicate||(yield{ref:$ge(l.parent.cid,l.node.cid,l.node.name,i.format)})}function $ge(r,e,t="",n=Fx.default){let i=n.replace(/<src>/g,r.toString());return i=i.replace(/<dst>/g,e.toString()),i=i.replace(/<linkname>/g,t),i}async function*Hge(r,e,t,n,i,s){let o=new Set;async function*a(c,l){let f=l+1;if(!(f>n))try{for await(let h of Gge(r,e,c.cid,s))yield{parent:c,node:h,isDuplicate:i&&o.has(h.cid.toString())},i&&o.add(h.cid.toString()),yield*a(h,f)}catch(h){throw h.code===Kge&&(h.message=`Could not find object with CID: ${c.cid}`),h}}yield*a({cid:t},0)}async function*Gge(r,e,t,n){let i=await r.blocks.get(t,n),o=(await e.getCodec(t.code)).decode(i),a=t.code===at,c=[];for(let[l,f]of Vx(o,c)){if(a){let h=l.match(/^Links\/(\d+)\/Hash$/);if(h){let p=Number(h[1]);if(p<o.Links.length){yield{name:o.Links[p].Name,cid:f};continue}}}yield{name:l,cid:f}}}var Vx=function*(r,e){if(r!=null&&!(r instanceof Uint8Array)){for(let[t,n]of Object.entries(r)){let i=[...e,t];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let[s,o]of n.entries()){let a=[...i,s],c=A.asCID(o);c?yield[a.join("/"),c]:typeof o=="object"&&(yield*Vx(o,a))}else{let s=A.asCID(n);s?yield[i.join("/"),s]:yield*Vx(n,i)}}return[]}};u();function GK({repo:r}){async function*e(t={}){for await(let n of r.blocks.queryKeys({},{signal:t.signal}))yield{ref:n.toString()}}return M(e)}u();u();function jK({network:r}){async function e(t={}){let{bitswap:n}=await r.use(t),i=n.getWantlist();return Array.from(i).map(s=>s[1].cid)}return M(e)}u();function WK({network:r}){async function e(t,n={}){let{bitswap:i}=await r.use(n),s=i.wantlistForPeer(t);return Array.from(s).map(o=>o[1].cid)}return M(e)}u();function YK({network:r}){async function e(t,n={}){let{bitswap:i}=await r.use(n);return Array.isArray(t)||(t=[t]),i.unwant(t)}return M(e)}u();function c6({network:r}){async function e(t={}){let n=(await r.use(t)).bitswap,i=n.stat().snapshot;return{provideBufLen:parseInt(i.providesBufferLength.toString()),blocksReceived:BigInt(i.blocksReceived.toString()),wantlist:Array.from(n.getWantlist()).map(s=>s[1].cid),peers:n.peers(),dupBlksReceived:BigInt(i.dupBlksReceived.toString()),dupDataReceived:BigInt(i.dupDataReceived.toString()),dataReceived:BigInt(i.dataReceived.toString()),blocksSent:BigInt(i.blocksSent.toString()),dataSent:BigInt(i.dataSent.toString())}}return M(e)}var l6=class{constructor({network:e}){this.wantlist=jK({network:e}),this.wantlistForPeer=WK({network:e}),this.unwant=YK({network:e}),this.stat=c6({network:e})}};u();u();u();function u6(r){try{return HL.matches(r)}catch{return!1}}function QK({repo:r}){async function e(t,n={}){if(!u6(t))throw new Error(`${t} is not a valid Multiaddr`);let i=await r.config.getAll(n),s=i.Bootstrap||[];return s.push(t.toString()),i.Bootstrap=Array.from(new Set(s)).sort((o,a)=>o.localeCompare(a)),await r.config.replace(i),{Peers:[t]}}return M(e)}u();function XK({repo:r}){async function e(t={}){let n=await r.config.getAll(t),i=n.Bootstrap||[];return n.Bootstrap=[],await r.config.replace(n),{Peers:i.map(s=>se(s))}}return M(e)}u();function ZK({repo:r}){async function e(t={}){return{Peers:(await r.config.get("Bootstrap",t)||[]).map(i=>se(i))}}return M(e)}u();u();var Mc=()=>({Addresses:{Swarm:[],Announce:[],NoAnnounce:[],API:"",Gateway:"",RPC:"",Delegates:["/dns4/node0.delegate.ipfs.io/tcp/443/https","/dns4/node1.delegate.ipfs.io/tcp/443/https","/dns4/node2.delegate.ipfs.io/tcp/443/https","/dns4/node3.delegate.ipfs.io/tcp/443/https"]},Discovery:{MDNS:{Enabled:!1,Interval:10},webRTCStar:{Enabled:!0}},Bootstrap:["/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN","/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb","/dnsaddr/bootstrap.libp2p.io/p2p/QmZa1sAxajnQjVM8WjWXoMbmPd7NsWhfKsPkErzpm9wGkp","/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa","/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt","/dns4/node0.preload.ipfs.io/tcp/443/wss/p2p/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic","/dns4/node1.preload.ipfs.io/tcp/443/wss/p2p/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6","/dns4/node2.preload.ipfs.io/tcp/443/wss/p2p/QmV7gnbW5VTcJ3oyM2Xk1rdFBJ3kTkvxc87UFGsun29STS","/dns4/node3.preload.ipfs.io/tcp/443/wss/p2p/QmY7JB6MQXhxHvq7dBDh4HpbH29v4yE9JRadAVpndvzySN"],Pubsub:{Enabled:!0},Swarm:{ConnMgr:{LowWater:5,HighWater:20},DisableNatPortMap:!0},Routing:{Type:"dhtclient"}});function JK({repo:r}){async function e(t={}){let n=await r.config.getAll(t);return n.Bootstrap=Mc().Bootstrap,await r.config.replace(n),{Peers:Mc().Bootstrap.map(i=>se(i))}}return M(e)}u();function eq({repo:r}){async function e(t,n={}){if(!u6(t))throw new Error(`${t} is not a valid Multiaddr`);let i=await r.config.getAll(n);return i.Bootstrap=(i.Bootstrap||[]).filter(s=>s.toString()!==t.toString()),await r.config.replace(i),{Peers:[t]}}return M(e)}var f6=class{constructor({repo:e}){this.add=QK({repo:e}),this.list=ZK({repo:e}),this.rm=eq({repo:e}),this.clear=XK({repo:e}),this.reset=JK({repo:e})}};u();u();function tq({preload:r,repo:e}){async function t(n,i={}){return i.preload!==!1&&r(n),e.blocks.get(n,i)}return M(t)}u();function rq({codecs:r,hashers:e,repo:t,preload:n}){async function i(s,o={}){let a=o.pin?await t.gcLock.readLock():null;try{let c=o.version!=null?o.version:0,l=o.format||(c===0?"dag-pb":"raw"),h=await(await e.getHasher(o.mhtype||"sha2-256")).digest(s),p=await r.getCodec(l),d=A.create(c,p.code,h);return await t.blocks.put(d,s,{signal:o.signal}),o.preload!==!1&&n(d),o.pin===!0&&await t.pins.pinRecursively(d,{signal:o.signal}),d}finally{a&&a()}}return M(i)}u();var yq=E(V(),1),gq=E(r2(),1),wq=E(Kn(),1),Eq=E(Ai(),1);u();function m6(r){return r instanceof Uint8Array?A.decode(r):A.parse(r.toString())}var r3e=8;function bq({repo:r}){async function*e(t,n={}){Array.isArray(t)||(t=[t]);let i=await r.gcLock.writeLock();try{yield*we(t,s=>(0,wq.default)(s,o=>async()=>{o=m6(o);let a={cid:o};try{if(!await r.blocks.has(o))throw(0,yq.default)(new Error("block not found"),"ERR_BLOCK_NOT_FOUND");await r.blocks.delete(o)}catch(c){n.force||(c.message=`cannot remove ${o}: ${c.message}`,a.error=c)}return a}),s=>(0,gq.default)(s,{concurrency:r3e}),s=>(0,Eq.default)(s,()=>!n.quiet))}finally{i()}}return M(e)}u();function vq({repo:r,preload:e}){async function t(n,i={}){n=m6(n),i.preload!==!1&&e(n);let s=await r.blocks.get(n);return{cid:n,size:s.length}}return M(t)}var y6=class{constructor({codecs:e,hashers:t,preload:n,repo:i}){this.get=tq({preload:n,repo:i}),this.put=rq({codecs:e,hashers:t,preload:n,repo:i}),this.rm=bq({repo:i}),this.stat=vq({preload:n,repo:i})}};u();u();var Bq=E(vi(),1);u();u();var Aq=E(V(),1);var Rq=E(jp(),1),Cq=E(Tq(),1),Pq=E(Wp(),1),Dq=E(Ro(),1),Oq=E(Kn(),1);u();function Us(r){return ArrayBuffer.isView(r)||r instanceof ArrayBuffer}function Uc(r){return r.constructor&&(r.constructor.name==="Blob"||r.constructor.name==="File")&&typeof r.stream=="function"}function n2(r){return typeof r=="object"&&(r.path||r.content)}var Fc=r=>r&&typeof r.getReader=="function";async function*g6(r){yield r}async function w6(r){if(Us(r))return g6(qx(r));if(typeof r=="string"||r instanceof String)return g6(qx(r.toString()));if(Uc(r))return(0,Cq.default)(r);if(Fc(r)&&(r=(0,Rq.default)(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let e=(0,Pq.default)(r),{value:t,done:n}=await e.peek();if(n)return g6(new Uint8Array(0));if(e.push(t),Number.isInteger(t))return g6(Uint8Array.from(await(0,Dq.default)(e)));if(Us(t)||typeof t=="string"||t instanceof String)return(0,Oq.default)(e,qx)}throw(0,Aq.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT")}function qx(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r instanceof ArrayBuffer?new Uint8Array(r):Array.isArray(r)?Uint8Array.from(r):z(r.toString())}u();var b6=E(V(),1),kq=E(jp(),1),Nq=E(Wp(),1);async function*Lq(r,e){if(r==null)throw(0,b6.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT");if(typeof r=="string"||r instanceof String){yield E6(r.toString(),e);return}if(Us(r)||Uc(r)){yield E6(r,e);return}if(Fc(r)&&(r=(0,kq.default)(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let t=(0,Nq.default)(r),{value:n,done:i}=await t.peek();if(i){yield{content:[]};return}if(t.push(n),Number.isInteger(n)||Us(n)||typeof n=="string"||n instanceof String){yield E6(t,e);return}throw(0,b6.default)(new Error("Unexpected input: multiple items passed - if you are using ipfs.add, please use ipfs.addAll instead"),"ERR_UNEXPECTED_INPUT")}if(n2(r)){yield E6(r,e);return}throw(0,b6.default)(new Error('Unexpected input: cannot convert "'+typeof r+'" into ImportCandidate'),"ERR_UNEXPECTED_INPUT")}async function E6(r,e){let{path:t,mode:n,mtime:i,content:s}=r,o={path:t||"",mode:hc(n),mtime:Ll(i)};return s?o.content=await e(s):t||(o.content=await e(r)),o}function v6(r){return Lq(r,w6)}function Mq({addAll:r}){async function e(t,n={}){let i=await(0,Bq.default)(r(v6(t),n));if(i==null)throw Error("Failed to add a file, if you see this please report a bug");return i}return e}u();u();var Bz=E(S6(),1);u();u();var zx=E(qq(),1);function l3e(r){let e=new Array(4);for(let t=0;t<4;t++)e[t]=r&255,r=r>>8;return new Uint8Array(e)}var EVe=Jd({name:"murmur3-32",code:35,encode:r=>l3e(zx.default.x86.hash32(r))}),ih=Jd({name:"murmur3-128",code:34,encode:r=>Fd.fromHex(zx.default.x64.hash128(r))});async function u3e(r){return(await ih.encode(r)).slice(0,8).reverse()}var f3e={chunker:"fixed",strategy:"balanced",rawLeaves:!1,onlyHash:!1,reduceSingleLeafToSelf:!0,hasher:$e,leafType:"file",cidVersion:0,progress:()=>()=>{},shardSplitThreshold:1e3,fileImportConcurrency:50,blockWriteConcurrency:10,minChunkSize:262144,maxChunkSize:262144,avgChunkSize:262144,window:16,polynomial:0x3df305dfb2a804,maxChildrenPerNode:174,layerRepeat:4,wrapWithDirectory:!1,recursive:!1,hidden:!1,timeout:void 0,hamtHashFn:u3e,hamtHashCode:34,hamtBucketBits:8},zq=(r={})=>Qe.bind({ignoreUndefined:!0})(f3e,r);u();u();u();var h3e=async(r,e,t)=>{t.codec||(t.codec=_t),t.hasher||(t.hasher=$e),t.cidVersion===void 0&&(t.cidVersion=1),t.codec===_t&&t.hasher!==$e&&(t.cidVersion=1);let n=await t.hasher.digest(r),i=A.create(t.cidVersion,t.codec.code,n);return t.onlyHash||await e.put(i,r,{signal:t.signal}),i},Co=h3e;var d3e=async(r,e,t)=>{let n=new Je({type:"directory",mtime:r.mtime,mode:r.mode}),i=Xe(Tn({Data:n.marshal()})),s=await Co(i,e,t),o=r.path;return{cid:s,path:o,unixfs:n,size:i.length}},$q=d3e;u();var Jq=E(V(),1);var ez=E(S6(),1);u();var Hq=E(Ro(),1);async function p3e(r,e){return e(await(0,Hq.default)(r))}var Gq=p3e;u();var jq=E(_6(),1);function m3e(r,e,t){return Wq(r,e,t)}async function Wq(r,e,t){let n=[];for await(let i of(0,jq.default)(r,t.maxChildrenPerNode))n.push(await e(i));return n.length>1?Wq(n,e,t):n[0]}var Yq=m3e;u();var Qq=E(_6(),1);async function y3e(r,e,t){let n=new $x(t.layerRepeat),i=0,s=1,o=n;for await(let a of(0,Qq.default)(r,t.maxChildrenPerNode))o.isFull()&&(o!==n&&n.addChild(await o.reduce(e)),i&&i%t.layerRepeat===0&&s++,o=new T6(s,t.layerRepeat,i),i++),o.append(a);return o&&o!==n&&n.addChild(await o.reduce(e)),n.reduce(e)}var Xq=y3e,T6=class{constructor(e,t,n=0){this.maxDepth=e,this.layerRepeat=t,this.currentDepth=1,this.iteration=n,this.root=this.node=this.parent={children:[],depth:this.currentDepth,maxDepth:e,maxChildren:(this.maxDepth-this.currentDepth)*this.layerRepeat}}isFull(){if(!this.root.data)return!1;if(this.currentDepth<this.maxDepth&&this.node.maxChildren)return this._addNextNodeToParent(this.node),!1;let e=this._findParent(this.node,this.currentDepth);return e?(this._addNextNodeToParent(e),!1):!0}_addNextNodeToParent(e){this.parent=e;let t={children:[],depth:e.depth+1,parent:e,maxDepth:this.maxDepth,maxChildren:Math.floor(e.children.length/this.layerRepeat)*this.layerRepeat};e.children.push(t),this.currentDepth=t.depth,this.node=t}append(e){this.node.data=e}reduce(e){return this._reduce(this.root,e)}async _reduce(e,t){let n=[];return e.children.length&&(n=await Promise.all(e.children.filter(i=>i.data).map(i=>this._reduce(i,t)))),t((e.data||[]).concat(n))}_findParent(e,t){let n=e.parent;if(!(!n||n.depth===0))return n.children.length===n.maxChildren||!n.maxChildren?this._findParent(n,t):n}},$x=class extends T6{constructor(e){super(0,e),this.root.depth=0,this.currentDepth=1}addChild(e){this.root.children.push(e)}reduce(e){return e((this.root.data||[]).concat(this.root.children))}};u();async function*g3e(r,e,t){for await(let n of r.content)yield async()=>{t.progress(n.length,r.path);let i,s={codec:_t,cidVersion:t.cidVersion,hasher:t.hasher,onlyHash:t.onlyHash};return t.rawLeaves?(s.codec=bi,s.cidVersion=1):(i=new Je({type:t.leafType,data:n}),n=Xe({Data:i.marshal(),Links:[]})),{cid:await Co(n,e,s),unixfs:i,size:n.length}}}var Zq=g3e;var w3e={flat:Gq,balanced:Yq,trickle:Xq};async function*E3e(r,e,t){let n=-1,i,s;typeof t.bufferImporter=="function"?s=t.bufferImporter:s=Zq;for await(let o of(0,ez.default)(s(r,e,t),t.blockWriteConcurrency)){if(n++,n===0){i=o;continue}else n===1&&i&&(yield i,i=null);yield o}i&&(i.single=!0,yield i)}var b3e=(r,e,t)=>{async function n(i){if(i.length===1&&i[0].single&&t.reduceSingleLeafToSelf){let f=i[0];if(r.mtime!==void 0||r.mode!==void 0){let h=await e.get(f.cid);f.unixfs=new Je({type:"file",mtime:r.mtime,mode:r.mode,data:h}),h=Xe(Tn({Data:f.unixfs.marshal()})),f.cid=await Co(h,e,{...t,codec:_t,hasher:t.hasher,cidVersion:t.cidVersion}),f.size=h.length}return{cid:f.cid,path:r.path,unixfs:f.unixfs,size:f.size}}let s=new Je({type:"file",mtime:r.mtime,mode:r.mode}),o=i.filter(f=>f.cid.code===An&&f.size||f.unixfs&&!f.unixfs.data&&f.unixfs.fileSize()?!0:Boolean(f.unixfs&&f.unixfs.data&&f.unixfs.data.length)).map(f=>f.cid.code===An?(s.addBlockSize(f.size),{Name:"",Tsize:f.size,Hash:f.cid}):(!f.unixfs||!f.unixfs.data?s.addBlockSize(f.unixfs&&f.unixfs.fileSize()||0):s.addBlockSize(f.unixfs.data.length),{Name:"",Tsize:f.size,Hash:f.cid})),a={Data:s.marshal(),Links:o},c=Xe(Tn(a));return{cid:await Co(c,e,t),path:r.path,unixfs:s,size:c.length+a.Links.reduce((f,h)=>f+h.Tsize,0)}}return n};function v3e(r,e,t){let n=w3e[t.strategy];if(!n)throw(0,Jq.default)(new Error(`Unknown importer build strategy name: ${t.strategy}`),"ERR_BAD_STRATEGY");return n(E3e(r,e,t),b3e(r,e,t),t)}var tz=v3e;var Zx=E(V(),1);u();var gz=E(Hx(),1),wz=E(yz(),1),Qx=E(V(),1);async function*A3e(r,e){let t,n,i;if(e.minChunkSize&&e.maxChunkSize&&e.avgChunkSize)i=e.avgChunkSize,t=e.minChunkSize,n=e.maxChunkSize;else if(e.avgChunkSize)i=e.avgChunkSize,t=i/3,n=i+i/2;else throw(0,Qx.default)(new Error("please specify an average chunk size"),"ERR_INVALID_AVG_CHUNK_SIZE");if(t<16)throw(0,Qx.default)(new Error("rabin min must be greater than 16"),"ERR_INVALID_MIN_CHUNK_SIZE");n<t&&(n=t),i<t&&(i=t);let s=Math.floor(Math.log2(i));for await(let o of R3e(r,{min:t,max:n,bits:s,window:e.window,polynomial:e.polynomial}))yield o}var Ez=A3e;async function*R3e(r,e){let t=await(0,wz.create)(e.bits,e.min,e.max,e.window),n=new gz.default;for await(let i of r){n.append(i);let s=t.fingerprint(i);for(let o=0;o<s.length;o++){let a=s[o],c=n.slice(0,a);n.consume(a),yield c}}n.length&&(yield n.slice(0))}u();var I6=E(Hx(),1);async function*C3e(r,e){let t=new I6.default,n=0,i=!1,s=e.maxChunkSize;for await(let o of r)for(t.append(o),n+=o.length;n>=s;)if(yield t.slice(0,s),i=!0,s===t.length)t=new I6.default,n=0;else{let a=new I6.default;a.append(t.shallowSlice(s)),t=a,n-=s}(!i||n)&&(yield t.slice(0,n))}var bz=C3e;u();var Xx=E(V(),1);async function*P3e(r){for await(let e of r){if(e.length===void 0)throw(0,Xx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof e=="string"||e instanceof String)yield z(e.toString());else if(Array.isArray(e))yield Uint8Array.from(e);else if(e instanceof Uint8Array)yield e;else throw(0,Xx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}}var vz=P3e;function D3e(r){return Symbol.iterator in r}function O3e(r){return Symbol.asyncIterator in r}function k3e(r){try{if(r instanceof Uint8Array)return async function*(){yield r}();if(D3e(r))return async function*(){yield*r}();if(O3e(r))return r}catch{throw(0,Zx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,Zx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}async function*N3e(r,e,t){for await(let n of r)if(n.path&&(n.path.substring(0,2)==="./"&&(t.wrapWithDirectory=!0),n.path=n.path.split("/").filter(i=>i&&i!==".").join("/")),n.content){let i;typeof t.chunker=="function"?i=t.chunker:t.chunker==="rabin"?i=Ez:i=bz;let s;typeof t.chunkValidator=="function"?s=t.chunkValidator:s=vz;let o={path:n.path,mtime:n.mtime,mode:n.mode,content:i(s(k3e(n.content),t),t)};yield()=>tz(o,e,t)}else if(n.path){let i={path:n.path,mtime:n.mtime,mode:n.mode};yield()=>$q(i,e,t)}else throw new Error("Import candidate must have content or path or both")}var _z=N3e;u();u();u();var Jx=class{constructor(e,t){this.options=t||{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime,this.cid=void 0,this.size=void 0}async put(e,t){}get(e){return Promise.resolve(this)}async*eachChildSeries(){}async*flush(e){}},fu=Jx;var eT=class extends fu{constructor(e,t){super(e,t),this._children={}}async put(e,t){this.cid=void 0,this.size=void 0,this._children[e]=t}get(e){return Promise.resolve(this._children[e])}childCount(){return Object.keys(this._children).length}directChildrenCount(){return this.childCount()}onlyChild(){return this._children[Object.keys(this._children)[0]]}async*eachChildSeries(){let e=Object.keys(this._children);for(let t=0;t<e.length;t++){let n=e[t];yield{key:n,child:this._children[n]}}}async*flush(e){let t=Object.keys(this._children),n=[];for(let l=0;l<t.length;l++){let f=this._children[t[l]];if(f instanceof fu)for await(let h of f.flush(e))f=h,yield f;f.size!=null&&f.cid&&n.push({Name:t[l],Tsize:f.size,Hash:f.cid})}let i=new Je({type:"directory",mtime:this.mtime,mode:this.mode}),s={Data:i.marshal(),Links:n},o=Xe(Tn(s)),a=await Co(o,e,this.options),c=o.length+s.Links.reduce((l,f)=>l+(f.Tsize==null?0:f.Tsize),0);this.cid=a,this.size=c,yield{cid:a,unixfs:i,path:this.path,size:c}}},c2=eT;u();u();u();u();var Iz=E(Tz(),1);var Cr=class{constructor(e,t,n=0){this._options=e,this._popCount=0,this._parent=t,this._posAtParent=n,this._children=new Iz.default,this.key=null}async put(e,t){let n=await this._findNewBucketAndPos(e);await n.bucket._putAt(n,e,t)}async get(e){let t=await this._findChild(e);if(t!=null)return t.value}async del(e){let t=await this._findPlace(e),n=t.bucket._at(t.pos);n!=null&&n.key===e&&t.bucket._delAt(t.pos)}leafCount(){return this._children.compactArray().reduce((t,n)=>n instanceof Cr?t+n.leafCount():t+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let t of e)t instanceof Cr?yield*t.eachLeafSeries():yield t}serialize(e,t){let n=[];return t(this._children.reduce((i,s,o)=>(s!=null&&(s instanceof Cr?i.push(s.serialize(e,t)):i.push(e(s,o))),i),n))}async asyncTransform(e,t){return await Az(this,e,t)}toJSON(){return this.serialize(F3e,V3e)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let t=await this._findPlace(e),n=t.bucket._at(t.pos);if(!(n instanceof Cr)&&n!=null&&n.key===e)return n}async _findPlace(e){let t=this._options.hash(typeof e=="string"?z(e):e),n=await t.take(this._options.bits),i=this._children.get(n);return i instanceof Cr?await i._findPlace(t):{bucket:this,pos:n,hash:t,existingChild:i}}async _findNewBucketAndPos(e){let t=await this._findPlace(e);if(t.existingChild!=null&&t.existingChild.key!==e){let n=new Cr(this._options,t.bucket,t.pos);t.bucket._putObjectAt(t.pos,n);let i=await n._findPlace(t.existingChild.hash);return i.bucket._putAt(i,t.existingChild.key,t.existingChild.value),await n._findNewBucketAndPos(t.hash)}return t}_putAt(e,t,n){this._putObjectAt(e.pos,{key:t,value:n,hash:e.hash})}_putObjectAt(e,t){this._children.get(e)==null&&this._popCount++,this._children.set(e,t)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(U3e);if(e!=null&&!(e instanceof Cr)){let t=e.hash;t.untake(this._options.bits);let n={pos:this._posAtParent,hash:t,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function U3e(r){return Boolean(r)}function F3e(r,e){return r.key}function V3e(r){return r}async function Az(r,e,t){let n=[];for(let i of r._children.compactArray())if(i instanceof Cr)await Az(i,e,t);else{let s=await e(i);n.push({bitField:r._children.bitField(),children:s})}return await t(n)}u();u();var K3e=[255,254,252,248,240,224,192,128],q3e=[1,3,7,15,31,63,127,255],A6=class{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let t=e,n=0;for(;t>0&&this._haveBits();){let i=this._value[this._currentBytePos],s=this._currentBitPos+1,o=Math.min(s,t),a=z3e(i,s-o,o);n=(n<<o)+a,t-=o,this._currentBitPos-=o,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function z3e(r,e,t){let n=$3e(e,t);return(r&n)>>>e}function $3e(r,e){return K3e[r]&q3e[Math.min(e+r-1,7)]}Mr();function Rz(r){function e(t){return t instanceof R6?t:new R6(t,r)}return e}var R6=class{constructor(e,t){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=t,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let t=e;for(;this._availableBits<t;)await this._produceMoreBits();let n=0;for(;t>0;){let i=this._buffers[this._currentBufferIndex],s=Math.min(i.availableBits(),t),o=i.take(s);n=(n<<s)+o,t-=s,this._availableBits-=s,i.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let t=e;for(;t>0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),t);n.untake(i),t-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?Le([this._value,Uint8Array.from([this._depth])]):this._value,t=await this._hashFn(e),n=new A6(t);this._buffers.push(n),this._availableBits+=n.availableBits()}};function hu(r){if(r==null||r.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:r.bits??8,hash:Rz(r.hashFn)};return new Cr(e)}var tT=class extends fu{constructor(e,t){super(e,t),this._bucket=hu({hashFn:t.hamtHashFn,bits:t.hamtBucketBits})}async put(e,t){await this._bucket.put(e,t)}get(e){return this._bucket.get(e)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:e,value:t}of this._bucket.eachLeafSeries())yield{key:e,child:t}}async*flush(e){for await(let t of Pz(this._bucket,e,this,this.options))yield{...t,path:this.path}}},Cz=tT;async function*Pz(r,e,t,n){let i=r._children,s=[],o=0;for(let d=0;d<i.length;d++){let m=i.get(d);if(!m)continue;let y=d.toString(16).toUpperCase().padStart(2,"0");if(m instanceof Cr){let g;for await(let w of await Pz(m,e,null,n))g=w;if(!g)throw new Error("Could not flush sharded directory, no subshard found");s.push({Name:y,Tsize:g.size,Hash:g.cid}),o+=g.size}else if(typeof m.value.flush=="function"){let g=m.value,w;for await(let S of g.flush(e))w=S,yield w;let b=y+m.key;s.push({Name:b,Tsize:w.size,Hash:w.cid}),o+=w.size}else{let g=m.value;if(!g.cid)continue;let w=y+m.key,b=g.size;s.push({Name:w,Tsize:b,Hash:g.cid}),o+=b}}let a=Uint8Array.from(i.bitField().reverse()),c=new Je({type:"hamt-sharded-directory",data:a,fanout:r.tableSize(),hashType:n.hamtHashCode,mtime:t&&t.mtime,mode:t&&t.mode}),l={Data:c.marshal(),Links:s},f=Xe(Tn(l)),h=await Co(f,e,n),p=f.length+o;yield{cid:h,unixfs:c,size:p}}async function Dz(r,e,t,n){let i=e;e instanceof c2&&e.directChildrenCount()>=t&&(i=await H3e(e,n));let s=i.parent;if(s){if(i!==e){if(r&&(r.parent=i),!i.parentKey)throw new Error("No parent key found");await s.put(i.parentKey,i)}return Dz(i,s,t,n)}return i}async function H3e(r,e){let t=new Cz({root:r.root,dir:!0,parent:r.parent,parentKey:r.parentKey,path:r.path,dirty:r.dirty,flat:!1,mtime:r.mtime,mode:r.mode},e);for await(let{key:n,child:i}of r.eachChildSeries())await t.put(n,i);return t}var Oz=Dz;u();var G3e=(r="")=>(r.trim().match(/([^\\/]|\\\/)+/g)||[]).filter(Boolean),kz=G3e;async function j3e(r,e,t){let n=kz(r.path||""),i=n.length-1,s=e,o="";for(let a=0;a<n.length;a++){let c=n[a];o+=`${o?"/":""}${c}`;let l=a===i;if(s.dirty=!0,s.cid=void 0,s.size=void 0,l)await s.put(c,r),e=await Oz(null,s,t.shardSplitThreshold,t);else{let f=await s.get(c);(!f||!(f instanceof fu))&&(f=new c2({root:!1,dir:!0,parent:s,parentKey:c,path:o,dirty:!0,flat:!0,mtime:f&&f.unixfs&&f.unixfs.mtime,mode:f&&f.unixfs&&f.unixfs.mode},t)),await s.put(c,f),s=f}}return e}async function*Nz(r,e){if(!(r instanceof fu)){r&&r.unixfs&&r.unixfs.isDirectory()&&(yield r);return}yield*r.flush(e)}async function*W3e(r,e,t){let n=new c2({root:!0,dir:!0,path:"",dirty:!0,flat:!0},t);for await(let i of r)!i||(n=await j3e(i,n,t),(!i.unixfs||!i.unixfs.isDirectory())&&(yield i));if(t.wrapWithDirectory)yield*Nz(n,e);else for await(let i of n.eachChildSeries())!i||(yield*Nz(i.child,e))}var Lz=W3e;async function*Yp(r,e,t={}){let n=zq(t),i;typeof t.dagBuilder=="function"?i=t.dagBuilder:i=_z;let s;typeof t.treeBuilder=="function"?s=t.treeBuilder:s=Lz;let o;Symbol.asyncIterator in r||Symbol.iterator in r?o=r:o=[r];for await(let a of s((0,Bz.default)(i(o,e,n),n.fileImportConcurrency),e,n))yield{cid:a.cid,path:a.path,unixfs:a.unixfs,size:a.size}}u();u();var l2=E(V(),1),Mz=E(jp(),1),Uz=E(Wp(),1),nT=E(Kn(),1);async function*C6(r,e){if(typeof r=="string"||r instanceof String||Us(r)||Uc(r)||r._readableState)throw(0,l2.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(Fc(r)&&(r=(0,Mz.default)(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let t=(0,Uz.default)(r),{value:n,done:i}=await t.peek();if(i){yield*[];return}if(t.push(n),Number.isInteger(n))throw(0,l2.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(n._readableState){yield*(0,nT.default)(t,s=>rT({content:s},e));return}if(Us(n)){yield rT({content:t},e);return}if(n2(n)||n[Symbol.iterator]||n[Symbol.asyncIterator]||Fc(n)||Uc(n)){yield*(0,nT.default)(t,s=>rT(s,e));return}}throw n2(r)?(0,l2.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT"):(0,l2.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}async function rT(r,e){let{path:t,mode:n,mtime:i,content:s}=r,o={path:t||"",mode:hc(n),mtime:Ll(i)};return s?o.content=await e(s):t||(o.content=await e(r)),o}function Fz(r){return C6(r,w6)}u();var Vz=r=>{if(r)if(r.startsWith("size-")){let e=r.split("-")[1],t=parseInt(e);if(isNaN(t))throw new Error("Chunker parameter size must be an integer");return{chunker:"fixed",maxChunkSize:t}}else{if(r.startsWith("rabin"))return{chunker:"rabin",...Y3e(r)};throw new Error(`Unrecognized chunker option: ${r}`)}else return{chunker:"fixed"}},Y3e=r=>{let e={},t=r.split("-");switch(t.length){case 1:e.avgChunkSize=262144;break;case 2:e.avgChunkSize=P6(t[1],"avg");break;case 4:e.minChunkSize=P6(t[1],"min"),e.avgChunkSize=P6(t[2],"avg"),e.maxChunkSize=P6(t[3],"max");break;default:throw new Error('Incorrect chunker format (expected "rabin" "rabin-[avg]" or "rabin-[min]-[avg]-[max]"')}return e},P6=(r,e)=>{let t=parseInt(r);if(isNaN(t))throw new Error(`Chunker parameter ${e} must be an integer`);return t};var Q3e=Qe.bind({ignoreUndefined:!0});function Kz({repo:r,preload:e,hashers:t,options:n}){let i=n&&n.sharding;async function*s(o,a={}){let c=Q3e({shardSplitThreshold:i?1e3:1/0,strategy:"balanced"},a,{...Vz(a.chunker)});c.hashAlg&&c.hashAlg!=="sha2-256"&&c.cidVersion!==1&&(c.cidVersion=1),c.trickle&&(c.strategy="trickle"),c.strategy==="trickle"&&(c.leafType="raw",c.reduceSingleLeafToSelf=!1),c.cidVersion>0&&c.rawLeaves===void 0&&(c.rawLeaves=!0),c.hashAlg!==void 0&&c.rawLeaves===void 0&&(c.rawLeaves=!0),delete c.trickle;let l={};if(c.progress){let d=c.progress;c.progress=(m,y)=>{l[y]||(l[y]=0),l[y]+=m,d(l[y],y)}}let f;c.hashAlg!=null&&(f=await t.getHasher(c.hashAlg));let h=we(Fz(o),d=>Yp(d,r.blocks,{...c,hasher:f,pin:!1}),X3e(c),Z3e(e,c),J3e(r,c)),p=await r.gcLock.readLock();try{for await(let d of h){let m=d.path??d.cid.toString();delete l[m],yield{...d,path:m}}}finally{p()}}return M(s)}function X3e(r){async function*e(t){for await(let n of t){let i=n.cid;r.cidVersion===1&&(i=i.toV1());let s=n.path?n.path:i.toString();r.wrapWithDirectory&&!n.path&&(s=""),yield{path:s,cid:i,size:n.size,mode:n.unixfs&&n.unixfs.mode,mtime:n.unixfs&&n.unixfs.mtime}}}return e}function Z3e(r,e){async function*t(n){for await(let i of n)(!i.path||e.wrapWithDirectory?i.path==="":!i.path.includes("/"))&&!e.onlyHash&&e.preload!==!1&&r(i.cid),yield i}return t}function J3e(r,e){async function*t(n){for await(let i of n){let s=!(i.path&&i.path.includes("/"));(e.pin==null?!0:e.pin)&&s&&!e.onlyHash&&await r.pins.pinRecursively(i.cid),yield i}}return t}u();u();var K6=E(V(),1);u();var d$=E(V(),1);u();var V6=E(V(),1);u();var e4e=async function(r){return(await ih.encode(r)).slice(0,8).reverse()},t4e=(r,e,t)=>Promise.all(r.map(n=>{if(n.Name==null)throw new Error("Unexpected Link without a Name");if(n.Name.length===2){let i=parseInt(n.Name,16);return e._putObjectAt(i,new Cr({hash:t._options.hash,bits:t._options.bits},e,i))}return t.put(n.Name.substring(2),!0)})),qz=r=>r.toString(16).toUpperCase().padStart(2,"0").substring(0,2),r4e=r=>{let e=r.bucket,t=[];for(;e._parent;)t.push(e),e=e._parent;return t.push(e),t.reverse()},zz=async(r,e,t,n,i)=>{if(!n){let f=hu({hashFn:e4e});n={rootBucket:f,hamtDepth:1,lastBucket:f}}await t4e(r.Links,n.lastBucket,n.rootBucket);let s=await n.rootBucket._findNewBucketAndPos(e),o=qz(s.pos),a=r4e(s);a.length>n.hamtDepth&&(n.lastBucket=a[n.hamtDepth],o=qz(n.lastBucket._posAtParent));let c=r.Links.find(f=>{if(f.Name==null)return!1;let h=f.Name.substring(0,2),p=f.Name.substring(2);return!(h!==o||p&&p!==e)});if(!c)return null;if(c.Name!=null&&c.Name.substring(2)===e)return c.Hash;n.hamtDepth++;let l=await t.get(c.Hash,i);return r=vt(l),zz(r,e,t,n,i)},$z=zz;u();u();function n4e(r,e,t,n){let i=r.length,s=e+i;return t>=s||n<e?new Uint8Array(0):(n>=e&&n<s&&(r=r.subarray(0,n-e)),t>=e&&t<s&&(r=r.subarray(t-e)),r)}var sh=n4e;u();var D6=E(V(),1),i4e=(r,e,t)=>{if(e||(e=0),e<0)throw(0,D6.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(e>r)throw(0,D6.default)(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(!t&&t!==0&&(t=r-e),t<0)throw(0,D6.default)(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");return e+t>r&&(t=r-e),{offset:e,length:t}},Qp=i4e;var F6=E(V(),1);var e$=E(r2(),1);var t$=E(Kn(),1);u();var Jz=E(Hl(),1);u();var u2=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},iT=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Hz=r=>globalThis.DOMException===void 0?new iT(r):new DOMException(r),Gz=r=>{let e=r.reason===void 0?Hz("This operation was aborted."):r.reason;return e instanceof Error?e:Hz(e)};function sT(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(Gz(c)),c.addEventListener("abort",()=>{a(Gz(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new u2(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function oT(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var oh=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Vc,f2=class{constructor(){Vc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&oh(this,Vc,"f")[this.size-1].priority>=t.priority){oh(this,Vc,"f").push(n);return}let i=oT(oh(this,Vc,"f"),n,(s,o)=>o.priority-s.priority);oh(this,Vc,"f").splice(i,0,n)}dequeue(){let e=oh(this,Vc,"f").shift();return e?.run}filter(e){return oh(this,Vc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return oh(this,Vc,"f").length}};Vc=new WeakMap;var Pr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Se=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Qr,d2,p2,pu,M6,m2,O6,Do,h2,Yi,k6,Qi,y2,du,N6,jz,Wz,Zz,Yz,Qz,Xz,L6,aT,cT,U6,B6,s4e=new u2,lT=class extends Error{},g2=class extends Jz.default{constructor(e){var t,n,i,s;if(super(),Qr.add(this),d2.set(this,void 0),p2.set(this,void 0),pu.set(this,0),M6.set(this,void 0),m2.set(this,void 0),O6.set(this,0),Do.set(this,void 0),h2.set(this,void 0),Yi.set(this,void 0),k6.set(this,void 0),Qi.set(this,0),y2.set(this,void 0),du.set(this,void 0),N6.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:f2,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);Pr(this,d2,e.carryoverConcurrencyCount,"f"),Pr(this,p2,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Pr(this,M6,e.intervalCap,"f"),Pr(this,m2,e.interval,"f"),Pr(this,Yi,new e.queueClass,"f"),Pr(this,k6,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Pr(this,N6,e.throwOnTimeout===!0,"f"),Pr(this,du,e.autoStart===!1,"f")}get concurrency(){return Se(this,y2,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Pr(this,y2,e,"f"),Se(this,Qr,"m",U6).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Pr(this,Qi,(a=Se(this,Qi,"f"),a++,a),"f"),Pr(this,pu,(c=Se(this,pu,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new lT("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):sT(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Se(this,N6,"f"):t.throwOnTimeout)&&i(s4e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Se(this,Qr,"m",Zz).call(this)};Se(this,Yi,"f").enqueue(s,t),Se(this,Qr,"m",L6).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Se(this,du,"f")?(Pr(this,du,!1,"f"),Se(this,Qr,"m",U6).call(this),this):this}pause(){Pr(this,du,!0,"f")}clear(){Pr(this,Yi,new(Se(this,k6,"f")),"f")}async onEmpty(){Se(this,Yi,"f").size!==0&&await Se(this,Qr,"m",B6).call(this,"empty")}async onSizeLessThan(e){Se(this,Yi,"f").size<e||await Se(this,Qr,"m",B6).call(this,"next",()=>Se(this,Yi,"f").size<e)}async onIdle(){Se(this,Qi,"f")===0&&Se(this,Yi,"f").size===0||await Se(this,Qr,"m",B6).call(this,"idle")}get size(){return Se(this,Yi,"f").size}sizeBy(e){return Se(this,Yi,"f").filter(e).length}get pending(){return Se(this,Qi,"f")}get isPaused(){return Se(this,du,"f")}};d2=new WeakMap,p2=new WeakMap,pu=new WeakMap,M6=new WeakMap,m2=new WeakMap,O6=new WeakMap,Do=new WeakMap,h2=new WeakMap,Yi=new WeakMap,k6=new WeakMap,Qi=new WeakMap,y2=new WeakMap,du=new WeakMap,N6=new WeakMap,Qr=new WeakSet,jz=function(){return Se(this,p2,"f")||Se(this,pu,"f")<Se(this,M6,"f")},Wz=function(){return Se(this,Qi,"f")<Se(this,y2,"f")},Zz=function(){var e;Pr(this,Qi,(e=Se(this,Qi,"f"),e--,e),"f"),Se(this,Qr,"m",L6).call(this),this.emit("next")},Yz=function(){this.emit("empty"),Se(this,Qi,"f")===0&&this.emit("idle")},Qz=function(){Se(this,Qr,"m",cT).call(this),Se(this,Qr,"m",aT).call(this),Pr(this,h2,void 0,"f")},Xz=function(){let e=Date.now();if(Se(this,Do,"f")===void 0){let t=Se(this,O6,"f")-e;if(t<0)Pr(this,pu,Se(this,d2,"f")?Se(this,Qi,"f"):0,"f");else return Se(this,h2,"f")===void 0&&Pr(this,h2,setTimeout(()=>{Se(this,Qr,"m",Qz).call(this)},t),"f"),!0}return!1},L6=function(){if(Se(this,Yi,"f").size===0)return Se(this,Do,"f")&&clearInterval(Se(this,Do,"f")),Pr(this,Do,void 0,"f"),Se(this,Qr,"m",Yz).call(this),!1;if(!Se(this,du,"f")){let e=!Se(this,Qr,"a",Xz);if(Se(this,Qr,"a",jz)&&Se(this,Qr,"a",Wz)){let t=Se(this,Yi,"f").dequeue();return t?(this.emit("active"),t(),e&&Se(this,Qr,"m",aT).call(this),!0):!1}}return!1},aT=function(){Se(this,p2,"f")||Se(this,Do,"f")!==void 0||(Pr(this,Do,setInterval(()=>{Se(this,Qr,"m",cT).call(this)},Se(this,m2,"f")),"f"),Pr(this,O6,Date.now()+Se(this,m2,"f"),"f"))},cT=function(){Se(this,pu,"f")===0&&Se(this,Qi,"f")===0&&Se(this,Do,"f")&&(clearInterval(Se(this,Do,"f")),Pr(this,Do,void 0,"f")),Pr(this,pu,Se(this,d2,"f")?Se(this,Qi,"f"):0,"f"),Se(this,Qr,"m",U6).call(this)},U6=function(){for(;Se(this,Qr,"m",L6).call(this););},B6=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};async function r$(r,e,t,n,i,s,o,a){if(e instanceof Uint8Array){t.push(sh(e,n,i,s));return}if(e.Data==null)throw(0,F6.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let c;try{c=Je.unmarshal(e.Data)}catch(f){throw(0,F6.default)(f,"ERR_NOT_UNIXFS")}if(c.data!=null){let f=c.data,h=sh(f,n,i,s);t.push(h),n+=h.byteLength}let l=[];for(let f=0;f<e.Links.length;f++){let h=e.Links[f],p=n,d=p+c.blockSizes[f];if((i>=p&&i<d||s>=p&&s<=d||i<p&&s>d)&&l.push({link:h,blockStart:n}),n=d,n>s)break}await we(l,f=>(0,t$.default)(f,h=>async()=>{let p=await r.get(h.link.Hash,{signal:a.signal});return{...h,block:p}}),f=>(0,e$.default)(f,{ordered:!0}),async f=>{for await(let{link:h,block:p,blockStart:d}of f){let m;switch(h.Hash.code){case at:m=vt(p);break;case An:m=p;break;default:t.end((0,F6.default)(new Error(`Unsupported codec: ${h.Hash.code}`),"ERR_NOT_UNIXFS"));return}o.add(async()=>{await r$(r,m,t,d,i,s,o,a)})}})}var o4e=(r,e,t,n,i,s,o)=>{async function*a(c={}){let l=t.fileSize();if(l===void 0)throw new Error("File was a directory");let{offset:f,length:h}=Qp(l,c.offset,c.length);if(h===0)return;let p=new g2({concurrency:1}),d=ar();p.add(async()=>{await r$(o,e,d,0,f,f+h,p,c)}),p.on("error",y=>{d.end(y)});let m=0;for await(let y of d)y!=null&&(m+=y.byteLength,m===h&&d.end(),yield y)}return a},uT=o4e;u();var a4e=(r,e,t,n,i,s,o)=>{async function*a(c={}){let l=c.offset||0,f=c.length||e.Links.length,h=e.Links.slice(l,f);for(let p of h){let d=await i(p.Hash,p.Name||"",`${n}/${p.Name||""}`,[],s+1,o,c);d.entry&&(yield d.entry)}}return a},n$=a4e;u();var c4e=(r,e,t,n,i,s,o)=>{function a(c={}){return i$(e,n,i,s,o,c)}return a};async function*i$(r,e,t,n,i,s){let o=r.Links;for(let a of o){let c=a.Name!=null?a.Name.substring(2):null;if(c)yield(await t(a.Hash,c,`${e}/${c}`,[],n+1,i,s)).entry;else{let l=await i.get(a.Hash);r=vt(l);for await(let f of i$(r,e,t,n,i,s))yield f}}}var s$=c4e;var l4e=(r,e)=>{let t=r.Links.find(n=>n.Name===e);return t&&t.Hash},u4e={raw:uT,file:uT,directory:n$,"hamt-sharded-directory":s$,metadata:(r,e,t,n,i,s,o)=>()=>[],symlink:(r,e,t,n,i,s,o)=>()=>[]},f4e=async(r,e,t,n,i,s,o,a)=>{let c=await o.get(r,a),l=vt(c),f,h;if(e||(e=r.toString()),l.Data==null)throw(0,V6.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{f=Je.unmarshal(l.Data)}catch(p){throw(0,V6.default)(p,"ERR_NOT_UNIXFS")}if(t||(t=e),n.length){let p;if(f&&f.type==="hamt-sharded-directory"?p=await $z(l,n[0],o):p=l4e(l,n[0]),!p)throw(0,V6.default)(new Error("file does not exist"),"ERR_NOT_FOUND");let d=n.shift(),m=`${t}/${d}`;h={cid:p,toResolve:n,name:d||"",path:m}}return{entry:{type:f.isDirectory()?"directory":"file",name:e,path:t,cid:r,content:u4e[f.type](r,l,f,t,i,s,o),unixfs:f,depth:s,node:l,size:f.fileSize()},next:h}},o$=f4e;u();var a$=E(V(),1);var h4e=r=>{async function*e(t={}){let{offset:n,length:i}=Qp(r.length,t.offset,t.length);yield sh(r,0,n,n+i)}return e},d4e=async(r,e,t,n,i,s,o,a)=>{if(n.length)throw(0,a$.default)(new Error(`No link named ${t} found in raw node ${r}`),"ERR_NOT_FOUND");let c=await o.get(r,a);return{entry:{type:"raw",name:e,path:t,cid:r,content:h4e(c),depth:s,size:c.length,node:c}}},c$=d4e;u();var l$=E(V(),1);var p4e=async(r,e,t,n,i,s,o,a)=>{let c=await o.get(r),l=Df(c),f=l,h=t;for(;n.length;){let p=n[0];if(p in f){n.shift(),h=`${h}/${p}`;let d=A.asCID(f[p]);if(d)return{entry:{type:"object",name:e,path:t,cid:r,node:c,depth:s,size:c.length,content:async function*(){yield l}},next:{cid:d,name:p,path:h,toResolve:n}};f=f[p]}else throw(0,l$.default)(new Error(`No property named ${p} found in cbor node ${r}`),"ERR_NO_PROP")}return{entry:{type:"object",name:e,path:t,cid:r,node:c,depth:s,size:c.length,content:async function*(){yield l}}}},u$=p4e;u();var f$=E(V(),1);var m4e=r=>{async function*e(t={}){let{offset:n,length:i}=Qp(r.length,t.offset,t.length);yield sh(r,0,n,n+i)}return e},y4e=async(r,e,t,n,i,s,o,a)=>{if(n.length)throw(0,f$.default)(new Error(`No link named ${t} found in raw node ${r}`),"ERR_NOT_FOUND");let c=await nr(r.multihash.bytes);return{entry:{type:"identity",name:e,path:t,cid:r,content:m4e(c.digest),depth:s,size:c.digest.length,node:c.digest}}},h$=y4e;var g4e={[at]:o$,[An]:c$,[j1]:u$,[on.code]:h$};function p$(r,e,t,n,i,s,o){let a=g4e[r.code];if(!a)throw(0,d$.default)(new Error(`No resolver for code ${r.code}`),"ERR_NO_RESOLVER");return a(r,e,t,n,p$,i,s,o)}var m$=p$;var y$=E(vi(),1),w4e=(r="")=>(r.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean),E4e=r=>{if(r instanceof Uint8Array)return{cid:A.decode(r),toResolve:[]};let e=A.asCID(r);if(e)return{cid:e,toResolve:[]};if(typeof r=="string"){r.indexOf("/ipfs/")===0&&(r=r.substring(6));let t=w4e(r);return{cid:A.parse(t[0]),toResolve:t.slice(1)}}throw(0,K6.default)(new Error(`Unknown path type ${r}`),"ERR_BAD_PATH")};async function*fT(r,e,t={}){let{cid:n,toResolve:i}=E4e(r),s=n.toString(),o=s,a=i.length;for(;;){let c=await m$(n,s,o,i,a,e,t);if(!c.entry&&!c.next)throw(0,K6.default)(new Error(`Could not resolve ${r}`),"ERR_NOT_FOUND");if(c.entry&&(yield c.entry),!c.next)return;i=c.next.toResolve,n=c.next.cid,s=c.next.name,o=c.next.path}}async function zn(r,e,t={}){let n=await(0,y$.default)(fT(r,e,t));if(!n)throw(0,K6.default)(new Error(`Could not resolve ${r}`),"ERR_NOT_FOUND");return n}async function*q6(r,e,t={}){let n=await zn(r,e,t);if(!n)return;if(yield n,n.type==="directory")for await(let s of i(n,t))yield s;async function*i(s,o){for await(let a of s.content(o))yield a,!(a instanceof Uint8Array)&&a.type==="directory"&&(yield*i(a,o))}}function g$({repo:r,preload:e}){async function*t(n,i={}){if(n=sp(n),i.preload!==!1){let o=n.split("/");e(A.parse(o[0]))}let s=await zn(n,r.blocks,i);if(s.type==="directory")throw new Error("this dag node is a directory");if(!s.content)throw new Error("this dag node has no content");yield*s.content(i)}return M(t)}u();var r0=E(V(),1);u();u();u();function lr(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}u();u();Mr();np();var E$=Symbol.for("@achingbrain/uint8arraylist");function w$(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let i=t+n.byteLength;if(e<i)return{buf:n,index:e-t};t=i}throw new RangeError("index is out of bounds")}function Kc(r){return Boolean(r?.[E$])}var Mt=class{constructor(...e){Object.defineProperty(this,E$,{value:!0}),this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Kc(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Kc(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=w$(this.bufs,e);return t.buf[t.index]}set(e,t){let n=w$(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Kc(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0))for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}slice(e,t){let{bufs:n,length:i}=this._subList(e,t);return Le(n,i)}subarray(e,t){let{bufs:n,length:i}=this._subList(e,t);return n.length===1?n[0]:Le(n,i)}sublist(e,t){let{bufs:n,length:i}=this._subList(e,t),s=new Mt;return s.length=i,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??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(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],i=0;for(let s=0;s<this.bufs.length;s++){let o=this.bufs[s],a=i,c=a+o.byteLength;if(i=c,e>=c)continue;let l=e>=a&&e<c,f=t>a&&t<=c;if(l&&f){if(e===a&&t===c){n.push(o);break}let h=e-a;n.push(o.subarray(h,h+(t-e)));break}if(l){if(e===0){n.push(o);continue}n.push(o.subarray(e-a));continue}if(f){if(t===c){n.push(o);break}n.push(o.subarray(0,t-a));break}n.push(o)}return{bufs:n,length:t-e}}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=ho(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let i=wc(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,n),this.write(i,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let i=wc(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,n),this.write(i,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let i=wc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,n),this.write(i,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=ho(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let i=wc(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,n),this.write(i,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let i=wc(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,n),this.write(i,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let i=wc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,n),this.write(i,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let i=wc(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,n),this.write(i,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let i=wc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof Mt)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!ze(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new Mt;return n.bufs=e,t==null&&(t=e.reduce((i,s)=>i+s.byteLength,0)),n.length=t,n}};u();function ah(r,e){for(let t=0;t<r.byteLength;t++){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1}return r.byteLength>e.byteLength?1:r.byteLength<e.byteLength?-1:0}var fze="0".charCodeAt(0),hze=z("ustar\0","binary"),dze=z("ustar ","binary"),pze=z(" \0","binary");u();u();function hT(r){let e=async function*(){let t=yield,n=new Mt;for await(let i of r){if(t==null){n.append(i),t=yield n,n=new Mt;continue}for(n.append(i);n.length>=t;){let s=n.sublist(0,t);if(n.consume(t),t=yield s,t==null){n.length>0&&(t=yield n,n=new Mt);break}}}if(t!=null)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}u();var x$=E(v$(),1),T$=E(dT(),1);u();var S4e="0000000000000000000",x4e="7777777777777777777",T4e="0".charCodeAt(0),I4e=z("ustar\0","binary"),A4e=z("00","binary"),R4e=parseInt("7777",8),C4e=257,P4e=263,D4e=function(r){switch(r){case"file":return 0;case"link":return 1;case"symlink":return 2;case"character-device":return 3;case"block-device":return 4;case"directory":return 5;case"fifo":return 6;case"contiguous-file":return 7;case"pax-header":return 72;default:return 0}},O4e=function(r){let e=256;for(let t=0;t<148;t++)e+=r[t];for(let t=156;t<512;t++)e+=r[t];return e},mu=function(r,e){let t=r.toString(8);return t.length>e?z(x4e.slice(0,e)+" "):z(S4e.slice(0,e-t.length)+t+" ")},pT=function(r){let e=z(r).byteLength,t=Math.floor(Math.log(e)/Math.log(10))+1;return e+t>=Math.pow(10,t)&&t++,`${e+t}${r}`};function S$(r){let e="";r.name!=null&&(e+=pT(" path="+r.name+`
`)),r.linkname!=null&&(e+=pT(" linkpath="+r.linkname+`
`));let t=r.pax;if(t!=null)for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e+=pT(" "+n+"="+t[n]+`
`));return z(e)}function z6(r){let e=new Uint8Array(512),t=r.name,n="";if(r.typeflag===5&&t[t.length-1]!=="/"&&(t+="/"),z(t).byteLength!==t.length)return null;for(;z(t).byteLength>100;){let i=t.indexOf("/");if(i===-1)return null;n+=n!==""?"/"+t.slice(0,i):t.slice(0,i),t=t.slice(i+1)}return z(t).byteLength>100||z(n).byteLength>155||r.linkname!=null&&z(r.linkname).byteLength>100?null:(e.set(z(t),0),e.set(mu(r.mode&R4e,6),100),e.set(mu(r.uid,6),108),e.set(mu(r.gid,6),116),e.set(mu(r.size,11),124),e.set(mu(r.mtime.getTime()/1e3|0,11),136),e[156]=T4e+D4e(r.type),r.linkname!=null&&e.set(z(r.linkname),157),e.set(I4e,C4e),e.set(A4e,P4e),r.uname!=null&&e.set(z(r.uname),265),r.gname!=null&&e.set(z(r.gname),297),e.set(mu(r.devmajor??0,6),329),e.set(mu(r.devminor??0,6),337),n!=null&&e.set(z(n),345),e.set(mu(O4e(e),6),148),e)}var{S_IFMT:N4e,S_IFBLK:L4e,S_IFCHR:B4e,S_IFDIR:M4e,S_IFIFO:U4e,S_IFLNK:F4e}=x$.default,V4e=parseInt("755",8),K4e=parseInt("644",8),I$=new Uint8Array(1024);function q4e(r=0){switch(r&N4e){case L4e:return"block-device";case B4e:return"character-device";case M4e:return"directory";case U4e:return"fifo";case F4e:return"symlink";default:return"file"}}function yT(r){return r&=511,r!==0?I$.subarray(0,512-r):new Uint8Array(0)}function mT(r){if(r.pax==null){let e=z6(r);if(e!=null)return e}return z4e(r)}function z4e(r){let e=S$(r),t={name:"PaxHeader",mode:r.mode,uid:r.uid,gid:r.gid,size:e.length,mtime:r.mtime,type:"pax-header",linkname:r.linkname,uname:r.uname,gname:r.gname,devmajor:r.devmajor,devminor:r.devminor};return new Mt(z6(t)??new Uint8Array(0),e,yT(e.length),z6({...t,size:r.size,type:r.type})??new Uint8Array(0)).subarray()}function $6(){return async function*(r){for await(let{header:e,body:t}of r){let n={...e,size:e.type==="symlink"?0:e.size??0,type:e.type??q4e(e.mode),mode:e.mode??(e.type==="directory"?V4e:K4e),uid:e.uid??0,gid:e.gid??0,mtime:e.mtime??new Date};if(typeof t=="string"&&(t=z(t)),t instanceof Uint8Array||Kc(t)){n.size=t.length,yield mT(n),yield Kc(t)?t.subarray():t,yield yT(n.size);continue}if(n.type==="symlink"&&n.linkname==null){if(t==null)throw new Error("type was symlink but no linkname or body specified");n.linkname=K(await(0,T$.default)(t)),yield mT(n);continue}if(yield mT(n),n.type!=="file"&&n.type!=="contiguous-file")continue;let i=0;for await(let s of t??[])i+=s.length,yield Kc(s)?s.subarray():s;if(i!==n.size)throw new Error(`size mismatch, wrote ${i} of ${n.size} bytes`);yield yT(n.size)}yield I$}}u();function e0(r){let e=r.length;for(;--e>=0;)r[e]=0}var $4e=0,fH=1,H4e=2,G4e=3,j4e=258,LT=29,O2=256,x2=O2+1+LT,Jp=30,BT=19,hH=2*x2+1,ch=15,gT=16,W4e=7,MT=256,dH=16,pH=17,mH=18,DT=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Q6=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Y4e=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),yH=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Q4e=512,zc=new Array((x2+2)*2);e0(zc);var v2=new Array(Jp*2);e0(v2);var T2=new Array(Q4e);e0(T2);var I2=new Array(j4e-G4e+1);e0(I2);var UT=new Array(LT);e0(UT);var e5=new Array(Jp);e0(e5);function wT(r,e,t,n,i){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=n,this.max_length=i,this.has_stree=r&&r.length}var gH,wH,EH;function ET(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}var bH=r=>r<256?T2[r]:T2[256+(r>>>7)],A2=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},Ci=(r,e,t)=>{r.bi_valid>gT-t?(r.bi_buf|=e<<r.bi_valid&65535,A2(r,r.bi_buf),r.bi_buf=e>>gT-r.bi_valid,r.bi_valid+=t-gT):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},Pa=(r,e,t)=>{Ci(r,t[e*2],t[e*2+1])},vH=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},X4e=r=>{r.bi_valid===16?(A2(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},Z4e=(r,e)=>{let t=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,c=e.stat_desc.max_length,l,f,h,p,d,m,y=0;for(p=0;p<=ch;p++)r.bl_count[p]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<hH;l++)f=r.heap[l],p=t[t[f*2+1]*2+1]+1,p>c&&(p=c,y++),t[f*2+1]=p,!(f>n)&&(r.bl_count[p]++,d=0,f>=a&&(d=o[f-a]),m=t[f*2],r.opt_len+=m*(p+d),s&&(r.static_len+=m*(i[f*2+1]+d)));if(y!==0){do{for(p=c-1;r.bl_count[p]===0;)p--;r.bl_count[p]--,r.bl_count[p+1]+=2,r.bl_count[c]--,y-=2}while(y>0);for(p=c;p!==0;p--)for(f=r.bl_count[p];f!==0;)h=r.heap[--l],!(h>n)&&(t[h*2+1]!==p&&(r.opt_len+=(p-t[h*2+1])*t[h*2],t[h*2+1]=p),f--)}},_H=(r,e,t)=>{let n=new Array(ch+1),i=0,s,o;for(s=1;s<=ch;s++)n[s]=i=i+t[s-1]<<1;for(o=0;o<=e;o++){let a=r[o*2+1];a!==0&&(r[o*2]=vH(n[a]++,a))}},J4e=()=>{let r,e,t,n,i,s=new Array(ch+1);for(t=0,n=0;n<LT-1;n++)for(UT[n]=t,r=0;r<1<<DT[n];r++)I2[t++]=n;for(I2[t-1]=n,i=0,n=0;n<16;n++)for(e5[n]=i,r=0;r<1<<Q6[n];r++)T2[i++]=n;for(i>>=7;n<Jp;n++)for(e5[n]=i<<7,r=0;r<1<<Q6[n]-7;r++)T2[256+i++]=n;for(e=0;e<=ch;e++)s[e]=0;for(r=0;r<=143;)zc[r*2+1]=8,r++,s[8]++;for(;r<=255;)zc[r*2+1]=9,r++,s[9]++;for(;r<=279;)zc[r*2+1]=7,r++,s[7]++;for(;r<=287;)zc[r*2+1]=8,r++,s[8]++;for(_H(zc,x2+1,s),r=0;r<Jp;r++)v2[r*2+1]=5,v2[r*2]=vH(r,5);gH=new wT(zc,DT,O2+1,x2,ch),wH=new wT(v2,Q6,0,Jp,ch),EH=new wT(new Array(0),Y4e,0,BT,W4e)},SH=r=>{let e;for(e=0;e<x2;e++)r.dyn_ltree[e*2]=0;for(e=0;e<Jp;e++)r.dyn_dtree[e*2]=0;for(e=0;e<BT;e++)r.bl_tree[e*2]=0;r.dyn_ltree[MT*2]=1,r.opt_len=r.static_len=0,r.last_lit=r.matches=0},xH=r=>{r.bi_valid>8?A2(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},ewe=(r,e,t,n)=>{xH(r),n&&(A2(r,t),A2(r,~t)),r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},A$=(r,e,t,n)=>{let i=e*2,s=t*2;return r[i]<r[s]||r[i]===r[s]&&n[e]<=n[t]},bT=(r,e,t)=>{let n=r.heap[t],i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&A$(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!A$(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},R$=(r,e,t)=>{let n,i,s=0,o,a;if(r.last_lit!==0)do n=r.pending_buf[r.d_buf+s*2]<<8|r.pending_buf[r.d_buf+s*2+1],i=r.pending_buf[r.l_buf+s],s++,n===0?Pa(r,i,e):(o=I2[i],Pa(r,o+O2+1,e),a=DT[o],a!==0&&(i-=UT[o],Ci(r,i,a)),n--,o=bH(n),Pa(r,o,t),a=Q6[o],a!==0&&(n-=e5[o],Ci(r,n,a)));while(s<r.last_lit);Pa(r,MT,e)},OT=(r,e)=>{let t=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems,o,a,c=-1,l;for(r.heap_len=0,r.heap_max=hH,o=0;o<s;o++)t[o*2]!==0?(r.heap[++r.heap_len]=c=o,r.depth[o]=0):t[o*2+1]=0;for(;r.heap_len<2;)l=r.heap[++r.heap_len]=c<2?++c:0,t[l*2]=1,r.depth[l]=0,r.opt_len--,i&&(r.static_len-=n[l*2+1]);for(e.max_code=c,o=r.heap_len>>1;o>=1;o--)bT(r,t,o);l=s;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],bT(r,t,1),a=r.heap[1],r.heap[--r.heap_max]=o,r.heap[--r.heap_max]=a,t[l*2]=t[o*2]+t[a*2],r.depth[l]=(r.depth[o]>=r.depth[a]?r.depth[o]:r.depth[a])+1,t[o*2+1]=t[a*2+1]=l,r.heap[1]=l++,bT(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],Z4e(r,e),_H(t,c,r.bl_count)},C$=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,c=7,l=4;for(o===0&&(c=138,l=3),e[(t+1)*2+1]=65535,n=0;n<=t;n++)s=o,o=e[(n+1)*2+1],!(++a<c&&s===o)&&(a<l?r.bl_tree[s*2]+=a:s!==0?(s!==i&&r.bl_tree[s*2]++,r.bl_tree[dH*2]++):a<=10?r.bl_tree[pH*2]++:r.bl_tree[mH*2]++,a=0,i=s,o===0?(c=138,l=3):s===o?(c=6,l=3):(c=7,l=4))},P$=(r,e,t)=>{let n,i=-1,s,o=e[0*2+1],a=0,c=7,l=4;for(o===0&&(c=138,l=3),n=0;n<=t;n++)if(s=o,o=e[(n+1)*2+1],!(++a<c&&s===o)){if(a<l)do Pa(r,s,r.bl_tree);while(--a!==0);else s!==0?(s!==i&&(Pa(r,s,r.bl_tree),a--),Pa(r,dH,r.bl_tree),Ci(r,a-3,2)):a<=10?(Pa(r,pH,r.bl_tree),Ci(r,a-3,3)):(Pa(r,mH,r.bl_tree),Ci(r,a-11,7));a=0,i=s,o===0?(c=138,l=3):s===o?(c=6,l=3):(c=7,l=4)}},twe=r=>{let e;for(C$(r,r.dyn_ltree,r.l_desc.max_code),C$(r,r.dyn_dtree,r.d_desc.max_code),OT(r,r.bl_desc),e=BT-1;e>=3&&r.bl_tree[yH[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},rwe=(r,e,t,n)=>{let i;for(Ci(r,e-257,5),Ci(r,t-1,5),Ci(r,n-4,4),i=0;i<n;i++)Ci(r,r.bl_tree[yH[i]*2+1],3);P$(r,r.dyn_ltree,e-1),P$(r,r.dyn_dtree,t-1)},nwe=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return 0;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return 1;for(t=32;t<O2;t++)if(r.dyn_ltree[t*2]!==0)return 1;return 0},D$=!1,iwe=r=>{D$||(J4e(),D$=!0),r.l_desc=new ET(r.dyn_ltree,gH),r.d_desc=new ET(r.dyn_dtree,wH),r.bl_desc=new ET(r.bl_tree,EH),r.bi_buf=0,r.bi_valid=0,SH(r)},TH=(r,e,t,n)=>{Ci(r,($4e<<1)+(n?1:0),3),ewe(r,e,t,!0)},swe=r=>{Ci(r,fH<<1,3),Pa(r,MT,zc),X4e(r)},owe=(r,e,t,n)=>{let i,s,o=0;r.level>0?(r.strm.data_type===2&&(r.strm.data_type=nwe(r)),OT(r,r.l_desc),OT(r,r.d_desc),o=twe(r),i=r.opt_len+3+7>>>3,s=r.static_len+3+7>>>3,s<=i&&(i=s)):i=s=t+5,t+4<=i&&e!==-1?TH(r,e,t,n):r.strategy===4||s===i?(Ci(r,(fH<<1)+(n?1:0),3),R$(r,zc,v2)):(Ci(r,(H4e<<1)+(n?1:0),3),rwe(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),R$(r,r.dyn_ltree,r.dyn_dtree)),SH(r),n&&xH(r)},awe=(r,e,t)=>(r.pending_buf[r.d_buf+r.last_lit*2]=e>>>8&255,r.pending_buf[r.d_buf+r.last_lit*2+1]=e&255,r.pending_buf[r.l_buf+r.last_lit]=t&255,r.last_lit++,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(I2[t]+O2+1)*2]++,r.dyn_dtree[bH(e)*2]++),r.last_lit===r.lit_bufsize-1),cwe=iwe,lwe=TH,uwe=owe,fwe=awe,hwe=swe,dwe={_tr_init:cwe,_tr_stored_block:lwe,_tr_flush_block:uwe,_tr_tally:fwe,_tr_align:hwe},pwe=(r,e,t,n)=>{let i=r&65535|0,s=r>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do i=i+e[n++]|0,s=s+i|0;while(--o);i%=65521,s%=65521}return i|s<<16|0},R2=pwe,mwe=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},ywe=new Uint32Array(mwe()),gwe=(r,e,t,n)=>{let i=ywe,s=n+t;r^=-1;for(let o=n;o<s;o++)r=r>>>8^i[(r^e[o])&255];return r^-1},Nn=gwe,uh={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ph={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:wwe,_tr_stored_block:Ewe,_tr_flush_block:bwe,_tr_tally:bu,_tr_align:vwe}=dwe,{Z_NO_FLUSH:mh,Z_PARTIAL_FLUSH:_we,Z_FULL_FLUSH:Swe,Z_FINISH:vu,Z_BLOCK:O$,Z_OK:Da,Z_STREAM_END:k$,Z_STREAM_ERROR:Fs,Z_DATA_ERROR:xwe,Z_BUF_ERROR:vT,Z_DEFAULT_COMPRESSION:Twe,Z_FILTERED:Iwe,Z_HUFFMAN_ONLY:H6,Z_RLE:Awe,Z_FIXED:Rwe,Z_DEFAULT_STRATEGY:Cwe,Z_UNKNOWN:Pwe,Z_DEFLATED:n5}=ph,Dwe=9,Owe=15,kwe=8,Nwe=29,Lwe=256,kT=Lwe+1+Nwe,Bwe=30,Mwe=19,Uwe=2*kT+1,Fwe=15,St=3,wu=258,Oo=wu+St+1,Vwe=32,i5=42,NT=69,X6=73,Z6=91,J6=103,lh=113,E2=666,vn=1,k2=2,fh=3,t0=4,Kwe=3,Eu=(r,e)=>(r.msg=uh[e],e),N$=r=>(r<<1)-(r>4?9:0),gu=r=>{let e=r.length;for(;--e>=0;)r[e]=0},qwe=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask,_u=qwe,yu=r=>{let e=r.state,t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(r.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},$n=(r,e)=>{bwe(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,yu(r.strm)},Ut=(r,e)=>{r.pending_buf[r.pending++]=e},w2=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},zwe=(r,e,t,n)=>{let i=r.avail_in;return i>n&&(i=n),i===0?0:(r.avail_in-=i,e.set(r.input.subarray(r.next_in,r.next_in+i),t),r.state.wrap===1?r.adler=R2(r.adler,e,i,t):r.state.wrap===2&&(r.adler=Nn(r.adler,e,i,t)),r.next_in+=i,r.total_in+=i,i)},IH=(r,e)=>{let t=r.max_chain_length,n=r.strstart,i,s,o=r.prev_length,a=r.nice_match,c=r.strstart>r.w_size-Oo?r.strstart-(r.w_size-Oo):0,l=r.window,f=r.w_mask,h=r.prev,p=r.strstart+wu,d=l[n+o-1],m=l[n+o];r.prev_length>=r.good_match&&(t>>=2),a>r.lookahead&&(a=r.lookahead);do if(i=e,!(l[i+o]!==m||l[i+o-1]!==d||l[i]!==l[n]||l[++i]!==l[n+1])){n+=2,i++;do;while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<p);if(s=wu-(p-n),n=p-wu,s>o){if(r.match_start=e,o=s,s>=a)break;d=l[n+o-1],m=l[n+o]}}while((e=h[e&f])>c&&--t!==0);return o<=r.lookahead?o:r.lookahead},hh=r=>{let e=r.w_size,t,n,i,s,o;do{if(s=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-Oo)){r.window.set(r.window.subarray(e,e+e),0),r.match_start-=e,r.strstart-=e,r.block_start-=e,n=r.hash_size,t=n;do i=r.head[--t],r.head[t]=i>=e?i-e:0;while(--n);n=e,t=n;do i=r.prev[--t],r.prev[t]=i>=e?i-e:0;while(--n);s+=e}if(r.strm.avail_in===0)break;if(n=zwe(r.strm,r.window,r.strstart+r.lookahead,s),r.lookahead+=n,r.lookahead+r.insert>=St)for(o=r.strstart-r.insert,r.ins_h=r.window[o],r.ins_h=_u(r,r.ins_h,r.window[o+1]);r.insert&&(r.ins_h=_u(r,r.ins_h,r.window[o+St-1]),r.prev[o&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=o,o++,r.insert--,!(r.lookahead+r.insert<St)););}while(r.lookahead<Oo&&r.strm.avail_in!==0)},$we=(r,e)=>{let t=65535;for(t>r.pending_buf_size-5&&(t=r.pending_buf_size-5);;){if(r.lookahead<=1){if(hh(r),r.lookahead===0&&e===mh)return vn;if(r.lookahead===0)break}r.strstart+=r.lookahead,r.lookahead=0;let n=r.block_start+t;if((r.strstart===0||r.strstart>=n)&&(r.lookahead=r.strstart-n,r.strstart=n,$n(r,!1),r.strm.avail_out===0)||r.strstart-r.block_start>=r.w_size-Oo&&($n(r,!1),r.strm.avail_out===0))return vn}return r.insert=0,e===vu?($n(r,!0),r.strm.avail_out===0?fh:t0):(r.strstart>r.block_start&&($n(r,!1),r.strm.avail_out===0),vn)},_T=(r,e)=>{let t,n;for(;;){if(r.lookahead<Oo){if(hh(r),r.lookahead<Oo&&e===mh)return vn;if(r.lookahead===0)break}if(t=0,r.lookahead>=St&&(r.ins_h=_u(r,r.ins_h,r.window[r.strstart+St-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-Oo&&(r.match_length=IH(r,t)),r.match_length>=St)if(n=bu(r,r.strstart-r.match_start,r.match_length-St),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=St){r.match_length--;do r.strstart++,r.ins_h=_u(r,r.ins_h,r.window[r.strstart+St-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=_u(r,r.ins_h,r.window[r.strstart+1]);else n=bu(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(n&&($n(r,!1),r.strm.avail_out===0))return vn}return r.insert=r.strstart<St-1?r.strstart:St-1,e===vu?($n(r,!0),r.strm.avail_out===0?fh:t0):r.last_lit&&($n(r,!1),r.strm.avail_out===0)?vn:k2},Xp=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<Oo){if(hh(r),r.lookahead<Oo&&e===mh)return vn;if(r.lookahead===0)break}if(t=0,r.lookahead>=St&&(r.ins_h=_u(r,r.ins_h,r.window[r.strstart+St-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=St-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-Oo&&(r.match_length=IH(r,t),r.match_length<=5&&(r.strategy===Iwe||r.match_length===St&&r.strstart-r.match_start>4096)&&(r.match_length=St-1)),r.prev_length>=St&&r.match_length<=r.prev_length){i=r.strstart+r.lookahead-St,n=bu(r,r.strstart-1-r.prev_match,r.prev_length-St),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=i&&(r.ins_h=_u(r,r.ins_h,r.window[r.strstart+St-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=St-1,r.strstart++,n&&($n(r,!1),r.strm.avail_out===0))return vn}else if(r.match_available){if(n=bu(r,0,r.window[r.strstart-1]),n&&$n(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return vn}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(n=bu(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<St-1?r.strstart:St-1,e===vu?($n(r,!0),r.strm.avail_out===0?fh:t0):r.last_lit&&($n(r,!1),r.strm.avail_out===0)?vn:k2},Hwe=(r,e)=>{let t,n,i,s,o=r.window;for(;;){if(r.lookahead<=wu){if(hh(r),r.lookahead<=wu&&e===mh)return vn;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=St&&r.strstart>0&&(i=r.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=r.strstart+wu;do;while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);r.match_length=wu-(s-i),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=St?(t=bu(r,1,r.match_length-St),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=bu(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&($n(r,!1),r.strm.avail_out===0))return vn}return r.insert=0,e===vu?($n(r,!0),r.strm.avail_out===0?fh:t0):r.last_lit&&($n(r,!1),r.strm.avail_out===0)?vn:k2},Gwe=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(hh(r),r.lookahead===0)){if(e===mh)return vn;break}if(r.match_length=0,t=bu(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&($n(r,!1),r.strm.avail_out===0))return vn}return r.insert=0,e===vu?($n(r,!0),r.strm.avail_out===0?fh:t0):r.last_lit&&($n(r,!1),r.strm.avail_out===0)?vn:k2};function Ca(r,e,t,n,i){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=n,this.func=i}var b2=[new Ca(0,0,0,0,$we),new Ca(4,4,8,4,_T),new Ca(4,5,16,8,_T),new Ca(4,6,32,32,_T),new Ca(4,4,16,16,Xp),new Ca(8,16,32,32,Xp),new Ca(8,16,128,128,Xp),new Ca(8,32,128,256,Xp),new Ca(32,128,258,1024,Xp),new Ca(32,258,258,4096,Xp)],jwe=r=>{r.window_size=2*r.w_size,gu(r.head),r.max_lazy_match=b2[r.level].max_lazy,r.good_match=b2[r.level].good_length,r.nice_match=b2[r.level].nice_length,r.max_chain_length=b2[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=St-1,r.match_available=0,r.ins_h=0};function Wwe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=n5,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Uwe*2),this.dyn_dtree=new Uint16Array((2*Bwe+1)*2),this.bl_tree=new Uint16Array((2*Mwe+1)*2),gu(this.dyn_ltree),gu(this.dyn_dtree),gu(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Fwe+1),this.heap=new Uint16Array(2*kT+1),gu(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*kT+1),gu(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var AH=r=>{if(!r||!r.state)return Eu(r,Fs);r.total_in=r.total_out=0,r.data_type=Pwe;let e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?i5:lh,r.adler=e.wrap===2?0:1,e.last_flush=mh,wwe(e),Da},RH=r=>{let e=AH(r);return e===Da&&jwe(r.state),e},Ywe=(r,e)=>!r||!r.state||r.state.wrap!==2?Fs:(r.state.gzhead=e,Da),CH=(r,e,t,n,i,s)=>{if(!r)return Fs;let o=1;if(e===Twe&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>Dwe||t!==n5||n<8||n>15||e<0||e>9||s<0||s>Rwe)return Eu(r,Fs);n===8&&(n=9);let a=new Wwe;return r.state=a,a.strm=r,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+St-1)/St),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=(1+2)*a.lit_bufsize,a.level=e,a.strategy=s,a.method=t,RH(r)},Qwe=(r,e)=>CH(r,e,n5,Owe,kwe,Cwe),Xwe=(r,e)=>{let t,n;if(!r||!r.state||e>O$||e<0)return r?Eu(r,Fs):Fs;let i=r.state;if(!r.output||!r.input&&r.avail_in!==0||i.status===E2&&e!==vu)return Eu(r,r.avail_out===0?vT:Fs);i.strm=r;let s=i.last_flush;if(i.last_flush=e,i.status===i5)if(i.wrap===2)r.adler=0,Ut(i,31),Ut(i,139),Ut(i,8),i.gzhead?(Ut(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Ut(i,i.gzhead.time&255),Ut(i,i.gzhead.time>>8&255),Ut(i,i.gzhead.time>>16&255),Ut(i,i.gzhead.time>>24&255),Ut(i,i.level===9?2:i.strategy>=H6||i.level<2?4:0),Ut(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(Ut(i,i.gzhead.extra.length&255),Ut(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(r.adler=Nn(r.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=NT):(Ut(i,0),Ut(i,0),Ut(i,0),Ut(i,0),Ut(i,0),Ut(i,i.level===9?2:i.strategy>=H6||i.level<2?4:0),Ut(i,Kwe),i.status=lh);else{let o=n5+(i.w_bits-8<<4)<<8,a=-1;i.strategy>=H6||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,o|=a<<6,i.strstart!==0&&(o|=Vwe),o+=31-o%31,i.status=lh,w2(i,o),i.strstart!==0&&(w2(i,r.adler>>>16),w2(i,r.adler&65535)),r.adler=1}if(i.status===NT)if(i.gzhead.extra){for(t=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(r.adler=Nn(r.adler,i.pending_buf,i.pending-t,t)),yu(r),t=i.pending,i.pending===i.pending_buf_size));)Ut(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>t&&(r.adler=Nn(r.adler,i.pending_buf,i.pending-t,t)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=X6)}else i.status=X6;if(i.status===X6)if(i.gzhead.name){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(r.adler=Nn(r.adler,i.pending_buf,i.pending-t,t)),yu(r),t=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindex<i.gzhead.name.length?n=i.gzhead.name.charCodeAt(i.gzindex++)&255:n=0,Ut(i,n)}while(n!==0);i.gzhead.hcrc&&i.pending>t&&(r.adler=Nn(r.adler,i.pending_buf,i.pending-t,t)),n===0&&(i.gzindex=0,i.status=Z6)}else i.status=Z6;if(i.status===Z6)if(i.gzhead.comment){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(r.adler=Nn(r.adler,i.pending_buf,i.pending-t,t)),yu(r),t=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindex<i.gzhead.comment.length?n=i.gzhead.comment.charCodeAt(i.gzindex++)&255:n=0,Ut(i,n)}while(n!==0);i.gzhead.hcrc&&i.pending>t&&(r.adler=Nn(r.adler,i.pending_buf,i.pending-t,t)),n===0&&(i.status=J6)}else i.status=J6;if(i.status===J6&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&yu(r),i.pending+2<=i.pending_buf_size&&(Ut(i,r.adler&255),Ut(i,r.adler>>8&255),r.adler=0,i.status=lh)):i.status=lh),i.pending!==0){if(yu(r),r.avail_out===0)return i.last_flush=-1,Da}else if(r.avail_in===0&&N$(e)<=N$(s)&&e!==vu)return Eu(r,vT);if(i.status===E2&&r.avail_in!==0)return Eu(r,vT);if(r.avail_in!==0||i.lookahead!==0||e!==mh&&i.status!==E2){let o=i.strategy===H6?Gwe(i,e):i.strategy===Awe?Hwe(i,e):b2[i.level].func(i,e);if((o===fh||o===t0)&&(i.status=E2),o===vn||o===fh)return r.avail_out===0&&(i.last_flush=-1),Da;if(o===k2&&(e===_we?vwe(i):e!==O$&&(Ewe(i,0,0,!1),e===Swe&&(gu(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),yu(r),r.avail_out===0))return i.last_flush=-1,Da}return e!==vu?Da:i.wrap<=0?k$:(i.wrap===2?(Ut(i,r.adler&255),Ut(i,r.adler>>8&255),Ut(i,r.adler>>16&255),Ut(i,r.adler>>24&255),Ut(i,r.total_in&255),Ut(i,r.total_in>>8&255),Ut(i,r.total_in>>16&255),Ut(i,r.total_in>>24&255)):(w2(i,r.adler>>>16),w2(i,r.adler&65535)),yu(r),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Da:k$)},Zwe=r=>{if(!r||!r.state)return Fs;let e=r.state.status;return e!==i5&&e!==NT&&e!==X6&&e!==Z6&&e!==J6&&e!==lh&&e!==E2?Eu(r,Fs):(r.state=null,e===lh?Eu(r,xwe):Da)},Jwe=(r,e)=>{let t=e.length;if(!r||!r.state)return Fs;let n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==i5||n.lookahead)return Fs;if(i===1&&(r.adler=R2(r.adler,e,t,0)),n.wrap=0,t>=n.w_size){i===0&&(gu(n.head),n.strstart=0,n.block_start=0,n.insert=0);let c=new Uint8Array(n.w_size);c.set(e.subarray(t-n.w_size,t),0),e=c,t=n.w_size}let s=r.avail_in,o=r.next_in,a=r.input;for(r.avail_in=t,r.next_in=0,r.input=e,hh(n);n.lookahead>=St;){let c=n.strstart,l=n.lookahead-(St-1);do n.ins_h=_u(n,n.ins_h,n.window[c+St-1]),n.prev[c&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=c,c++;while(--l);n.strstart=c,n.lookahead=St-1,hh(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=St-1,n.match_available=0,r.next_in=o,r.input=a,r.avail_in=s,n.wrap=i,Da},e6e=Qwe,t6e=CH,r6e=RH,n6e=AH,i6e=Ywe,s6e=Xwe,o6e=Zwe,a6e=Jwe,c6e="pako deflate (from Nodeca project)",_2={deflateInit:e6e,deflateInit2:t6e,deflateReset:r6e,deflateResetKeep:n6e,deflateSetHeader:i6e,deflate:s6e,deflateEnd:o6e,deflateSetDictionary:a6e,deflateInfo:c6e},l6e=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),u6e=function(r){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let t=e.shift();if(!!t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let n in t)l6e(t,n)&&(r[n]=t[n])}}return r},f6e=r=>{let e=0;for(let n=0,i=r.length;n<i;n++)e+=r[n].length;let t=new Uint8Array(e);for(let n=0,i=0,s=r.length;n<s;n++){let o=r[n];t.set(o,i),i+=o.length}return t},s5={assign:u6e,flattenChunks:f6e},PH=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{PH=!1}var C2=new Uint8Array(256);for(let r=0;r<256;r++)C2[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;C2[254]=C2[254]=1;var h6e=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,n,i,s,o=r.length,a=0;for(i=0;i<o;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)t=r.charCodeAt(i),(t&64512)===55296&&i+1<o&&(n=r.charCodeAt(i+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),i++)),t<128?e[s++]=t:t<2048?(e[s++]=192|t>>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e},d6e=(r,e)=>{if(e<65534&&r.subarray&&PH)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let n=0;n<e;n++)t+=String.fromCharCode(r[n]);return t},p6e=(r,e)=>{let t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let n,i,s=new Array(t*2);for(i=0,n=0;n<t;){let o=r[n++];if(o<128){s[i++]=o;continue}let a=C2[o];if(a>4){s[i++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n<t;)o=o<<6|r[n++]&63,a--;if(a>1){s[i++]=65533;continue}o<65536?s[i++]=o:(o-=65536,s[i++]=55296|o>>10&1023,s[i++]=56320|o&1023)}return d6e(s,i)},m6e=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+C2[r[t]]>e?t:e},P2={string2buf:h6e,buf2string:p6e,utf8border:m6e};function y6e(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var DH=y6e,OH=Object.prototype.toString,{Z_NO_FLUSH:g6e,Z_SYNC_FLUSH:w6e,Z_FULL_FLUSH:E6e,Z_FINISH:b6e,Z_OK:t5,Z_STREAM_END:v6e,Z_DEFAULT_COMPRESSION:_6e,Z_DEFAULT_STRATEGY:S6e,Z_DEFLATED:x6e}=ph;function N2(r){this.options=s5.assign({level:_6e,method:x6e,chunkSize:16384,windowBits:15,memLevel:8,strategy:S6e},r||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new DH,this.strm.avail_out=0;let t=_2.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==t5)throw new Error(uh[t]);if(e.header&&_2.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=P2.string2buf(e.dictionary):OH.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=_2.deflateSetDictionary(this.strm,n),t!==t5)throw new Error(uh[t]);this._dict_set=!0}}N2.prototype.push=function(r,e){let t=this.strm,n=this.options.chunkSize,i,s;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?b6e:g6e,typeof r=="string"?t.input=P2.string2buf(r):OH.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),(s===w6e||s===E6e)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=_2.deflate(t,s),i===v6e)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=_2.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===t5;if(t.avail_out===0){this.onData(t.output);continue}if(s>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};N2.prototype.onData=function(r){this.chunks.push(r)};N2.prototype.onEnd=function(r){r===t5&&(this.result=s5.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function FT(r,e){let t=new N2(e);if(t.push(r,!0),t.err)throw t.msg||uh[t.err];return t.result}function T6e(r,e){return e=e||{},e.raw=!0,FT(r,e)}function I6e(r,e){return e=e||{},e.gzip=!0,FT(r,e)}var A6e=N2,R6e=FT,C6e=T6e,P6e=I6e,D6e=ph,O6e={Deflate:A6e,deflate:R6e,deflateRaw:C6e,gzip:P6e,constants:D6e},G6=30,k6e=12,N6e=function(e,t){let n,i,s,o,a,c,l,f,h,p,d,m,y,g,w,b,S,_,I,T,x,P,B,q,Y=e.state;n=e.next_in,B=e.input,i=n+(e.avail_in-5),s=e.next_out,q=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=Y.dmax,l=Y.wsize,f=Y.whave,h=Y.wnext,p=Y.window,d=Y.hold,m=Y.bits,y=Y.lencode,g=Y.distcode,w=(1<<Y.lenbits)-1,b=(1<<Y.distbits)-1;e:do{m<15&&(d+=B[n++]<<m,m+=8,d+=B[n++]<<m,m+=8),S=y[d&w];t:for(;;){if(_=S>>>24,d>>>=_,m-=_,_=S>>>16&255,_===0)q[s++]=S&65535;else if(_&16){I=S&65535,_&=15,_&&(m<_&&(d+=B[n++]<<m,m+=8),I+=d&(1<<_)-1,d>>>=_,m-=_),m<15&&(d+=B[n++]<<m,m+=8,d+=B[n++]<<m,m+=8),S=g[d&b];r:for(;;){if(_=S>>>24,d>>>=_,m-=_,_=S>>>16&255,_&16){if(T=S&65535,_&=15,m<_&&(d+=B[n++]<<m,m+=8,m<_&&(d+=B[n++]<<m,m+=8)),T+=d&(1<<_)-1,T>c){e.msg="invalid distance too far back",Y.mode=G6;break e}if(d>>>=_,m-=_,_=s-o,T>_){if(_=T-_,_>f&&Y.sane){e.msg="invalid distance too far back",Y.mode=G6;break e}if(x=0,P=p,h===0){if(x+=l-_,_<I){I-=_;do q[s++]=p[x++];while(--_);x=s-T,P=q}}else if(h<_){if(x+=l+h-_,_-=h,_<I){I-=_;do q[s++]=p[x++];while(--_);if(x=0,h<I){_=h,I-=_;do q[s++]=p[x++];while(--_);x=s-T,P=q}}}else if(x+=h-_,_<I){I-=_;do q[s++]=p[x++];while(--_);x=s-T,P=q}for(;I>2;)q[s++]=P[x++],q[s++]=P[x++],q[s++]=P[x++],I-=3;I&&(q[s++]=P[x++],I>1&&(q[s++]=P[x++]))}else{x=s-T;do q[s++]=q[x++],q[s++]=q[x++],q[s++]=q[x++],I-=3;while(I>2);I&&(q[s++]=q[x++],I>1&&(q[s++]=q[x++]))}}else if((_&64)===0){S=g[(S&65535)+(d&(1<<_)-1)];continue r}else{e.msg="invalid distance code",Y.mode=G6;break e}break}}else if((_&64)===0){S=y[(S&65535)+(d&(1<<_)-1)];continue t}else if(_&32){Y.mode=k6e;break e}else{e.msg="invalid literal/length code",Y.mode=G6;break e}break}}while(n<i&&s<a);I=m>>3,n-=I,m-=I<<3,d&=(1<<m)-1,e.next_in=n,e.next_out=s,e.avail_in=n<i?5+(i-n):5-(n-i),e.avail_out=s<a?257+(a-s):257-(s-a),Y.hold=d,Y.bits=m},Zp=15,L$=852,B$=592,M$=0,ST=1,U$=2,L6e=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),B6e=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),M6e=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),U6e=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),F6e=(r,e,t,n,i,s,o,a)=>{let c=a.bits,l=0,f=0,h=0,p=0,d=0,m=0,y=0,g=0,w=0,b=0,S,_,I,T,x,P=null,B=0,q,Y=new Uint16Array(Zp+1),re=new Uint16Array(Zp+1),ie=null,Ce=0,Ee,Oe,H;for(l=0;l<=Zp;l++)Y[l]=0;for(f=0;f<n;f++)Y[e[t+f]]++;for(d=c,p=Zp;p>=1&&Y[p]===0;p--);if(d>p&&(d=p),p===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,a.bits=1,0;for(h=1;h<p&&Y[h]===0;h++);for(d<h&&(d=h),g=1,l=1;l<=Zp;l++)if(g<<=1,g-=Y[l],g<0)return-1;if(g>0&&(r===M$||p!==1))return-1;for(re[1]=0,l=1;l<Zp;l++)re[l+1]=re[l]+Y[l];for(f=0;f<n;f++)e[t+f]!==0&&(o[re[e[t+f]]++]=f);if(r===M$?(P=ie=o,q=19):r===ST?(P=L6e,B-=257,ie=B6e,Ce-=257,q=256):(P=M6e,ie=U6e,q=-1),b=0,f=0,l=h,x=s,m=d,y=0,I=-1,w=1<<d,T=w-1,r===ST&&w>L$||r===U$&&w>B$)return 1;for(;;){Ee=l-y,o[f]<q?(Oe=0,H=o[f]):o[f]>q?(Oe=ie[Ce+o[f]],H=P[B+o[f]]):(Oe=32+64,H=0),S=1<<l-y,_=1<<m,h=_;do _-=S,i[x+(b>>y)+_]=Ee<<24|Oe<<16|H|0;while(_!==0);for(S=1<<l-1;b&S;)S>>=1;if(S!==0?(b&=S-1,b+=S):b=0,f++,--Y[l]===0){if(l===p)break;l=e[t+o[f]]}if(l>d&&(b&T)!==I){for(y===0&&(y=d),x+=h,m=l-y,g=1<<m;m+y<p&&(g-=Y[m+y],!(g<=0));)m++,g<<=1;if(w+=1<<m,r===ST&&w>L$||r===U$&&w>B$)return 1;I=b&T,i[I]=d<<24|m<<16|x-s|0}}return b!==0&&(i[x+b]=l-y<<24|64<<16|0),a.bits=d,0},S2=F6e,V6e=0,kH=1,NH=2,{Z_FINISH:F$,Z_BLOCK:K6e,Z_TREES:j6,Z_OK:dh,Z_STREAM_END:q6e,Z_NEED_DICT:z6e,Z_STREAM_ERROR:Vs,Z_DATA_ERROR:LH,Z_MEM_ERROR:BH,Z_BUF_ERROR:$6e,Z_DEFLATED:V$}=ph,MH=1,K$=2,q$=3,z$=4,$$=5,H$=6,G$=7,j$=8,W$=9,Y$=10,r5=11,qc=12,xT=13,Q$=14,TT=15,X$=16,Z$=17,J$=18,eH=19,W6=20,Y6=21,tH=22,rH=23,nH=24,iH=25,sH=26,IT=27,oH=28,aH=29,br=30,UH=31,H6e=32,G6e=852,j6e=592,W6e=15,Y6e=W6e,cH=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function Q6e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var FH=r=>{if(!r||!r.state)return Vs;let e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=MH,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(G6e),e.distcode=e.distdyn=new Int32Array(j6e),e.sane=1,e.back=-1,dh},VH=r=>{if(!r||!r.state)return Vs;let e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,FH(r)},KH=(r,e)=>{let t;if(!r||!r.state)return Vs;let n=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?Vs:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,VH(r))},qH=(r,e)=>{if(!r)return Vs;let t=new Q6e;r.state=t,t.window=null;let n=KH(r,e);return n!==dh&&(r.state=null),n},X6e=r=>qH(r,Y6e),lH=!0,AT,RT,Z6e=r=>{if(lH){AT=new Int32Array(512),RT=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(S2(kH,r.lens,0,288,AT,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;S2(NH,r.lens,0,32,RT,0,r.work,{bits:5}),lH=!1}r.lencode=AT,r.lenbits=9,r.distcode=RT,r.distbits=5},zH=(r,e,t,n)=>{let i,s=r.state;return s.window===null&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(t-n,t-n+i),s.wnext),n-=i,n?(s.window.set(e.subarray(t-n,t),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0},J6e=(r,e)=>{let t,n,i,s,o,a,c,l,f,h,p,d,m,y,g=0,w,b,S,_,I,T,x,P,B=new Uint8Array(4),q,Y,re=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!r||!r.state||!r.output||!r.input&&r.avail_in!==0)return Vs;t=r.state,t.mode===qc&&(t.mode=xT),o=r.next_out,i=r.output,c=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,f=t.bits,h=a,p=c,P=dh;e:for(;;)switch(t.mode){case MH:if(t.wrap===0){t.mode=xT;break}for(;f<16;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(t.wrap&2&&l===35615){t.check=0,B[0]=l&255,B[1]=l>>>8&255,t.check=Nn(t.check,B,2,0),l=0,f=0,t.mode=K$;break}if(t.flags=0,t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){r.msg="incorrect header check",t.mode=br;break}if((l&15)!==V$){r.msg="unknown compression method",t.mode=br;break}if(l>>>=4,f-=4,x=(l&15)+8,t.wbits===0)t.wbits=x;else if(x>t.wbits){r.msg="invalid window size",t.mode=br;break}t.dmax=1<<t.wbits,r.adler=t.check=1,t.mode=l&512?Y$:qc,l=0,f=0;break;case K$:for(;f<16;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(t.flags=l,(t.flags&255)!==V$){r.msg="unknown compression method",t.mode=br;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=br;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&(B[0]=l&255,B[1]=l>>>8&255,t.check=Nn(t.check,B,2,0)),l=0,f=0,t.mode=q$;case q$:for(;f<32;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.head&&(t.head.time=l),t.flags&512&&(B[0]=l&255,B[1]=l>>>8&255,B[2]=l>>>16&255,B[3]=l>>>24&255,t.check=Nn(t.check,B,4,0)),l=0,f=0,t.mode=z$;case z$:for(;f<16;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&(B[0]=l&255,B[1]=l>>>8&255,t.check=Nn(t.check,B,2,0)),l=0,f=0,t.mode=$$;case $$:if(t.flags&1024){for(;f<16;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&(B[0]=l&255,B[1]=l>>>8&255,t.check=Nn(t.check,B,2,0)),l=0,f=0}else t.head&&(t.head.extra=null);t.mode=H$;case H$:if(t.flags&1024&&(d=t.length,d>a&&(d=a),d&&(t.head&&(x=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(s,s+d),x)),t.flags&512&&(t.check=Nn(t.check,n,d,s)),a-=d,s+=d,t.length-=d),t.length))break e;t.length=0,t.mode=G$;case G$:if(t.flags&2048){if(a===0)break e;d=0;do x=n[s+d++],t.head&&x&&t.length<65536&&(t.head.name+=String.fromCharCode(x));while(x&&d<a);if(t.flags&512&&(t.check=Nn(t.check,n,d,s)),a-=d,s+=d,x)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=j$;case j$:if(t.flags&4096){if(a===0)break e;d=0;do x=n[s+d++],t.head&&x&&t.length<65536&&(t.head.comment+=String.fromCharCode(x));while(x&&d<a);if(t.flags&512&&(t.check=Nn(t.check,n,d,s)),a-=d,s+=d,x)break e}else t.head&&(t.head.comment=null);t.mode=W$;case W$:if(t.flags&512){for(;f<16;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(l!==(t.check&65535)){r.msg="header crc mismatch",t.mode=br;break}l=0,f=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=qc;break;case Y$:for(;f<32;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}r.adler=t.check=cH(l),l=0,f=0,t.mode=r5;case r5:if(t.havedict===0)return r.next_out=o,r.avail_out=c,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=f,z6e;r.adler=t.check=1,t.mode=qc;case qc:if(e===K6e||e===j6)break e;case xT:if(t.last){l>>>=f&7,f-=f&7,t.mode=IT;break}for(;f<3;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}switch(t.last=l&1,l>>>=1,f-=1,l&3){case 0:t.mode=Q$;break;case 1:if(Z6e(t),t.mode=W6,e===j6){l>>>=2,f-=2;break e}break;case 2:t.mode=Z$;break;case 3:r.msg="invalid block type",t.mode=br}l>>>=2,f-=2;break;case Q$:for(l>>>=f&7,f-=f&7;f<32;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if((l&65535)!==(l>>>16^65535)){r.msg="invalid stored block lengths",t.mode=br;break}if(t.length=l&65535,l=0,f=0,t.mode=TT,e===j6)break e;case TT:t.mode=X$;case X$:if(d=t.length,d){if(d>a&&(d=a),d>c&&(d=c),d===0)break e;i.set(n.subarray(s,s+d),o),a-=d,s+=d,c-=d,o+=d,t.length-=d;break}t.mode=qc;break;case Z$:for(;f<14;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(t.nlen=(l&31)+257,l>>>=5,f-=5,t.ndist=(l&31)+1,l>>>=5,f-=5,t.ncode=(l&15)+4,l>>>=4,f-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=br;break}t.have=0,t.mode=J$;case J$:for(;t.have<t.ncode;){for(;f<3;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.lens[re[t.have++]]=l&7,l>>>=3,f-=3}for(;t.have<19;)t.lens[re[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,q={bits:t.lenbits},P=S2(V6e,t.lens,0,19,t.lencode,0,t.work,q),t.lenbits=q.bits,P){r.msg="invalid code lengths set",t.mode=br;break}t.have=0,t.mode=eH;case eH:for(;t.have<t.nlen+t.ndist;){for(;g=t.lencode[l&(1<<t.lenbits)-1],w=g>>>24,b=g>>>16&255,S=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(S<16)l>>>=w,f-=w,t.lens[t.have++]=S;else{if(S===16){for(Y=w+2;f<Y;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(l>>>=w,f-=w,t.have===0){r.msg="invalid bit length repeat",t.mode=br;break}x=t.lens[t.have-1],d=3+(l&3),l>>>=2,f-=2}else if(S===17){for(Y=w+3;f<Y;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=w,f-=w,x=0,d=3+(l&7),l>>>=3,f-=3}else{for(Y=w+7;f<Y;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=w,f-=w,x=0,d=11+(l&127),l>>>=7,f-=7}if(t.have+d>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=br;break}for(;d--;)t.lens[t.have++]=x}}if(t.mode===br)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=br;break}if(t.lenbits=9,q={bits:t.lenbits},P=S2(kH,t.lens,0,t.nlen,t.lencode,0,t.work,q),t.lenbits=q.bits,P){r.msg="invalid literal/lengths set",t.mode=br;break}if(t.distbits=6,t.distcode=t.distdyn,q={bits:t.distbits},P=S2(NH,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,q),t.distbits=q.bits,P){r.msg="invalid distances set",t.mode=br;break}if(t.mode=W6,e===j6)break e;case W6:t.mode=Y6;case Y6:if(a>=6&&c>=258){r.next_out=o,r.avail_out=c,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=f,N6e(r,p),o=r.next_out,i=r.output,c=r.avail_out,s=r.next_in,n=r.input,a=r.avail_in,l=t.hold,f=t.bits,t.mode===qc&&(t.back=-1);break}for(t.back=0;g=t.lencode[l&(1<<t.lenbits)-1],w=g>>>24,b=g>>>16&255,S=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(b&&(b&240)===0){for(_=w,I=b,T=S;g=t.lencode[T+((l&(1<<_+I)-1)>>_)],w=g>>>24,b=g>>>16&255,S=g&65535,!(_+w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=_,f-=_,t.back+=_}if(l>>>=w,f-=w,t.back+=w,t.length=S,b===0){t.mode=sH;break}if(b&32){t.back=-1,t.mode=qc;break}if(b&64){r.msg="invalid literal/length code",t.mode=br;break}t.extra=b&15,t.mode=tH;case tH:if(t.extra){for(Y=t.extra;f<Y;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=rH;case rH:for(;g=t.distcode[l&(1<<t.distbits)-1],w=g>>>24,b=g>>>16&255,S=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if((b&240)===0){for(_=w,I=b,T=S;g=t.distcode[T+((l&(1<<_+I)-1)>>_)],w=g>>>24,b=g>>>16&255,S=g&65535,!(_+w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=_,f-=_,t.back+=_}if(l>>>=w,f-=w,t.back+=w,b&64){r.msg="invalid distance code",t.mode=br;break}t.offset=S,t.extra=b&15,t.mode=nH;case nH:if(t.extra){for(Y=t.extra;f<Y;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,f-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=br;break}t.mode=iH;case iH:if(c===0)break e;if(d=p-c,t.offset>d){if(d=t.offset-d,d>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=br;break}d>t.wnext?(d-=t.wnext,m=t.wsize-d):m=t.wnext-d,d>t.length&&(d=t.length),y=t.window}else y=i,m=o-t.offset,d=t.length;d>c&&(d=c),c-=d,t.length-=d;do i[o++]=y[m++];while(--d);t.length===0&&(t.mode=Y6);break;case sH:if(c===0)break e;i[o++]=t.length,c--,t.mode=Y6;break;case IT:if(t.wrap){for(;f<32;){if(a===0)break e;a--,l|=n[s++]<<f,f+=8}if(p-=c,r.total_out+=p,t.total+=p,p&&(r.adler=t.check=t.flags?Nn(t.check,i,p,o-p):R2(t.check,i,p,o-p)),p=c,(t.flags?l:cH(l))!==t.check){r.msg="incorrect data check",t.mode=br;break}l=0,f=0}t.mode=oH;case oH:if(t.wrap&&t.flags){for(;f<32;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(l!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=br;break}l=0,f=0}t.mode=aH;case aH:P=q6e;break e;case br:P=LH;break e;case UH:return BH;case H6e:default:return Vs}return r.next_out=o,r.avail_out=c,r.next_in=s,r.avail_in=a,t.hold=l,t.bits=f,(t.wsize||p!==r.avail_out&&t.mode<br&&(t.mode<IT||e!==F$))&&zH(r,r.output,r.next_out,p-r.avail_out),h-=r.avail_in,p-=r.avail_out,r.total_in+=h,r.total_out+=p,t.total+=p,t.wrap&&p&&(r.adler=t.check=t.flags?Nn(t.check,i,p,r.next_out-p):R2(t.check,i,p,r.next_out-p)),r.data_type=t.bits+(t.last?64:0)+(t.mode===qc?128:0)+(t.mode===W6||t.mode===TT?256:0),(h===0&&p===0||e===F$)&&P===dh&&(P=$6e),P},e5e=r=>{if(!r||!r.state)return Vs;let e=r.state;return e.window&&(e.window=null),r.state=null,dh},t5e=(r,e)=>{if(!r||!r.state)return Vs;let t=r.state;return(t.wrap&2)===0?Vs:(t.head=e,e.done=!1,dh)},r5e=(r,e)=>{let t=e.length,n,i,s;return!r||!r.state||(n=r.state,n.wrap!==0&&n.mode!==r5)?Vs:n.mode===r5&&(i=1,i=R2(i,e,t,0),i!==n.check)?LH:(s=zH(r,e,t,t),s?(n.mode=UH,BH):(n.havedict=1,dh))},n5e=VH,i5e=KH,s5e=FH,o5e=X6e,a5e=qH,c5e=J6e,l5e=e5e,u5e=t5e,f5e=r5e,h5e="pako inflate (from Nodeca project)",$c={inflateReset:n5e,inflateReset2:i5e,inflateResetKeep:s5e,inflateInit:o5e,inflateInit2:a5e,inflate:c5e,inflateEnd:l5e,inflateGetHeader:u5e,inflateSetDictionary:f5e,inflateInfo:h5e};function d5e(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var p5e=d5e,$H=Object.prototype.toString,{Z_NO_FLUSH:m5e,Z_FINISH:y5e,Z_OK:D2,Z_STREAM_END:CT,Z_NEED_DICT:PT,Z_STREAM_ERROR:g5e,Z_DATA_ERROR:uH,Z_MEM_ERROR:w5e}=ph;function L2(r){this.options=s5.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new DH,this.strm.avail_out=0;let t=$c.inflateInit2(this.strm,e.windowBits);if(t!==D2)throw new Error(uh[t]);if(this.header=new p5e,$c.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=P2.string2buf(e.dictionary):$H.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=$c.inflateSetDictionary(this.strm,e.dictionary),t!==D2)))throw new Error(uh[t])}L2.prototype.push=function(r,e){let t=this.strm,n=this.options.chunkSize,i=this.options.dictionary,s,o,a;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?y5e:m5e,$H.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),s=$c.inflate(t,o),s===PT&&i&&(s=$c.inflateSetDictionary(t,i),s===D2?s=$c.inflate(t,o):s===uH&&(s=PT));t.avail_in>0&&s===CT&&t.state.wrap>0&&r[t.next_in]!==0;)$c.inflateReset(t),s=$c.inflate(t,o);switch(s){case g5e:case uH:case PT:case w5e:return this.onEnd(s),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||s===CT))if(this.options.to==="string"){let c=P2.utf8border(t.output,t.next_out),l=t.next_out-c,f=P2.buf2string(t.output,c);t.next_out=l,t.avail_out=n-l,l&&t.output.set(t.output.subarray(c,c+l),0),this.onData(f)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===D2&&a===0)){if(s===CT)return s=$c.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};L2.prototype.onData=function(r){this.chunks.push(r)};L2.prototype.onEnd=function(r){r===D2&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s5.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function VT(r,e){let t=new L2(e);if(t.push(r),t.err)throw t.msg||uh[t.err];return t.result}function E5e(r,e){return e=e||{},e.raw=!0,VT(r,e)}var b5e=L2,v5e=VT,_5e=E5e,S5e=VT,x5e=ph,T5e={Inflate:b5e,inflate:v5e,inflateRaw:_5e,ungzip:S5e,constants:x5e},{Deflate:I5e,deflate:A5e,deflateRaw:R5e,gzip:C5e}=O6e,{Inflate:P5e,inflate:D5e,inflateRaw:O5e,ungzip:k5e}=T5e,N5e=I5e,L5e=A5e,B5e=R5e,M5e=C5e,U5e=P5e,F5e=D5e,V5e=O5e,K5e=k5e,q5e=ph,KT={Deflate:N5e,deflate:L5e,deflateRaw:B5e,gzip:M5e,Inflate:U5e,inflate:F5e,inflateRaw:V5e,ungzip:K5e,constants:q5e};var qT=E(Kn(),1),zT=E(dT(),1),HH=6;function GH({repo:r,preload:e}){async function*t(n,i={}){if(i.compressionLevel!=null&&(i.compressionLevel<-1||i.compressionLevel>9))throw(0,r0.default)(new Error("Compression level must be between -1 and 9"),"ERR_INVALID_PARAMS");if(i.preload!==!1){let a;try{a=sp(n).split("/")}catch(c){throw(0,r0.default)(c,"ERR_INVALID_PATH")}e(A.parse(a[0]))}let s=A.asCID(n)||n,o=await zn(s,r.blocks,i);if(o.type==="file"||o.type==="raw"){let a=[];!i.compress||i.archive===!0?a.push([{header:{name:o.path,mode:o.type==="file"&&o.unixfs.mode,mtime:o.type==="file"&&o.unixfs.mtime?new Date(o.unixfs.mtime.secs*1e3):void 0,size:o.size,type:"file"},body:o.content()}],$6(),c=>(0,qT.default)(c,l=>l.slice())):a.push(o.content),i.compress&&a.push(async function*(c){let l=await(0,zT.default)(c);yield KT.gzip(l,{level:i.compressionLevel||HH})}),yield*we(...a);return}if(o.type==="directory"){let a=[q6(s,r.blocks,i),async function*(c){for await(let l of c){let f={header:{name:l.path,size:l.size}};if(l.type==="file")f.header.type="file",f.header.mode=l.unixfs.mode!=null?l.unixfs.mode:void 0,f.header.mtime=l.unixfs.mtime?new Date(l.unixfs.mtime.secs*1e3):void 0,f.body=l.content();else if(l.type==="raw")f.header.type="file",f.body=l.content();else if(l.type==="directory")f.header.type="directory",f.header.mode=l.unixfs.mode!=null?l.unixfs.mode:void 0,f.header.mtime=l.unixfs.mtime?new Date(l.unixfs.mtime.secs*1e3):void 0;else throw(0,r0.default)(new Error("Not a UnixFS node"),"ERR_NOT_UNIXFS");yield f}},$6(),c=>(0,qT.default)(c,l=>l.slice())];if(i.compress){if(!i.archive)throw(0,r0.default)(new Error("file is not regular"),"ERR_INVALID_PATH");i.compress&&a.push(async function*(c){let l=await(0,zT.default)(c);yield KT.gzip(l,{level:i.compressionLevel||HH})})}yield*we(...a);return}throw(0,r0.default)(new Error("Not a UnixFS node"),"ERR_NOT_UNIXFS")}return M(t)}u();var jH=E(V(),1);function WH({repo:r,preload:e}){async function*t(n,i={}){let s=sp(n),o=s.split("/");i.preload!==!1&&e(A.parse(o[0]));let a=A.asCID(s)||s,c=await zn(a,r.blocks,i);if(c.type==="file"){yield y9(c);return}if(c.type==="directory"){for await(let l of c.content())yield y9(l);return}throw(0,jH.default)(new Error(`Unknown UnixFS type ${c.type}`),"ERR_UNKNOWN_UNIXFS_TYPE")}return M(t)}var o5=class{constructor({preload:e,repo:t,hashers:n,options:i}){let s=Kz({preload:e,repo:t,options:i,hashers:n});this.addAll=s,this.add=Mq({addAll:s}),this.cat=g$({repo:t,preload:e}),this.get=GH({repo:t,preload:e}),this.ls=WH({repo:t,preload:e})}};u();u();var yh="",YH="",QH="";function XH({repo:r}){async function e(t={}){let n=await r.version.get();return{version:yh,commit:YH,repo:`${n}`,"ipfs-core":yh,"interface-ipfs-core":QH}}return M(e)}u();var a5=E(V(),1);var z5e=C("ipfs:components:id");function ZH({peerId:r,network:e}){async function t(n={}){let i=e.try();if(!i){if(n.peerId)throw new gc;if(r.publicKey==null)throw(0,a5.default)(new Error("Public key missing"),"ERR_MISSING_PUBLIC_KEY");return{id:r,publicKey:K(r.publicKey,"base64pad"),addresses:[],agentVersion:`js-ipfs/${yh}`,protocolVersion:"9000",protocols:[]}}let{libp2p:s}=i,o=n.peerId?n.peerId:r,a=await $5e(o,s,n),c=K(a.metadata.get("AgentVersion")||new Uint8Array),l=K(a.metadata.get("ProtocolVersion")||new Uint8Array),f=a.id.toString(),h=a.publicKey?K(a.publicKey,"base64pad"):"";return{id:o,publicKey:h,addresses:(a.addresses||[]).map(p=>{let d=p.toString();return d.endsWith(`/p2p/${f}`)?d:`${d}/p2p/${f}`}).sort().map(p=>se(p)),agentVersion:c,protocolVersion:l,protocols:(a.protocols||[]).sort()}}return M(t)}async function $5e(r,e,t){let n=await e.peerStore.get(r);n||(n=await H5e(r,e,t));let i=r.publicKey?r.publicKey:await e.peerStore.keyBook.get(r);if(i==null)try{i=await e.getPublicKey(r,t)}catch(s){z5e.error("Could not load public key for",r.toString(),s)}return{...n,publicKey:i,metadata:n.metadata||new Map,addresses:n.addresses.map(s=>s.multiaddr)}}async function H5e(r,e,t){if(e.dht==null)throw(0,a5.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");for await(let i of e.dht.findPeer(r,t))if(i.name==="FINAL_PEER")break;let n=await e.peerStore.get(r);if(!n)throw(0,a5.default)(new Error("Could not find peer"),"ERR_NOT_FOUND");return n}u();u();u();var vr=G5e;function G5e(r,e,t){var n,i;if(Array.isArray(e)&&(n=e.slice(0)),typeof e=="string"&&(n=e.split(".")),typeof e=="symbol"&&(n=[e]),!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");if(i=n.pop(),!i)return!1;JH(i);for(var s;s=n.shift();)if(JH(s),typeof r[s]>"u"&&(r[s]={}),r=r[s],!r||typeof r!="object")return!1;return r[i]=t,!0}function JH(r){if(r=="__proto__"||r=="constructor"||r=="prototype")throw new Error("setting of prototype values not supported")}var n0={server:{description:"Recommended for nodes with public IPv4 address (servers, VPSes, etc.), disables host and content discovery and UPnP in local networks.",transform:r=>(vr(r,"Discovery.MDNS.Enabled",!1),vr(r,"Discovery.webRTCStar.Enabled",!1),r.Swarm={...r.Swarm||{},DisableNatPortMap:!0},r)},"local-discovery":{description:"Sets default values to fields affected by `server` profile, enables discovery and UPnP in local networks.",transform:r=>(vr(r,"Discovery.MDNS.Enabled",!0),vr(r,"Discovery.webRTCStar.Enabled",!0),vr(r,"Swarm",{...r.Swarm||{},DisableNatPortMap:!1}),r)},test:{description:"Reduces external interference, useful for running ipfs in test environments. Note that with these settings node won't be able to talk to the rest of the network without manual bootstrap.",transform:r=>{let e=Mc();return vr(r,"Addresses.API",e.Addresses.API?"/ip4/127.0.0.1/tcp/0":""),vr(r,"Addresses.Gateway",e.Addresses.Gateway?"/ip4/127.0.0.1/tcp/0":""),vr(r,"Addresses.Swarm",e.Addresses.Swarm.length?["/ip4/127.0.0.1/tcp/0"]:[]),vr(r,"Addresses.Delegates",[]),vr(r,"Bootstrap",[]),vr(r,"Discovery.MDNS.Enabled",!1),vr(r,"Discovery.webRTCStar.Enabled",!1),vr(r,"Swarm",{...r.Swarm||{},DisableNatPortMap:!0}),r}},"default-networking":{description:"Restores default network settings. Inverse profile of the `test` profile.",transform:r=>{let e=Mc();return vr(r,"Addresses.API",e.Addresses.API),vr(r,"Addresses.Gateway",e.Addresses.Gateway),vr(r,"Addresses.Swarm",e.Addresses.Swarm),vr(r,"Addresses.Delegates",e.Addresses.Delegates),vr(r,"Bootstrap",e.Bootstrap),vr(r,"Discovery.MDNS.Enabled",e.Discovery.MDNS.Enabled),vr(r,"Discovery.webRTCStar.Enabled",e.Discovery.webRTCStar.Enabled),vr(r,"Swarm",{...r.Swarm||{},DisableNatPortMap:!1}),r}},lowpower:{description:"Reduces daemon overhead on the system. May affect node functionality,performance of content discovery and data fetching may be degraded. Recommended for low power systems.",transform:r=>{let e=r.Swarm||{},t=e.ConnMgr||{};return t.LowWater=20,t.HighWater=40,e.ConnMgr=t,r.Swarm=e,r}},"default-power":{description:'Inverse of "lowpower" profile.',transform:r=>{let e=Mc();return r.Swarm=e.Swarm,r}}};var j5e=C("ipfs:core:config");function eG({repo:r}){return{getAll:M(e),get:M(t),set:M(n),replace:M(i),profiles:{apply:M(s),list:M(W5e)}};async function e(o={}){return r.config.getAll(o)}async function t(o,a){return o?r.config.get(o,a):Promise.reject(new Error("key argument is required"))}async function n(o,a,c){return r.config.set(o,a,c)}async function i(o,a){return r.config.replace(o,a)}async function s(o,a={dryRun:!1}){let{dryRun:c}=a,l=n0[o];if(!l)throw new Error(`No profile with name '${o}' exists`);try{let f=await r.config.getAll(a),h=JSON.parse(JSON.stringify(f));return h=l.transform(h),c||await r.config.replace(h,a),delete f.Identity.PrivKey,delete h.Identity.PrivKey,{original:f,updated:h}}catch(f){throw j5e(f),new Error(`Could not apply profile '${o}' to config: ${f.message}`)}}}async function W5e(r){return Object.keys(n0).map(e=>({name:e,description:n0[e].description}))}u();u();u();var c5=({enumerable:r=!0,configurable:e=!1}={})=>({enumerable:r,configurable:e,writable:!1}),$T=function*(r,e){if(r!=null&&!(r instanceof Uint8Array))for(let[t,n]of Object.entries(r)){let i=[...e,t];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let[s,o]of n.entries()){let a=[...i,s],c=A.asCID(o);c?yield[a.join("/"),c]:typeof o=="object"&&(yield*$T(o,a))}else{let s=A.asCID(n);s?yield[i.join("/"),s]:yield*$T(n,i)}}},HT=function*(r,e){if(r!=null)for(let[t,n]of Object.entries(r)){let i=[...e,t];if(yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!A.asCID(n))if(Array.isArray(n))for(let[s,o]of n.entries()){let a=[...i,s];yield a.join("/"),typeof o=="object"&&!A.asCID(o)&&(yield*HT(o,a))}else yield*HT(n,i)}},Y5e=(r,e)=>{let t=r;for(let[n,i]of e.entries()){if(t=t[i],t==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(o=>`[${JSON.stringify(o)}]`).join("")}`);let s=A.asCID(t);if(s)return{value:s,remaining:e.slice(n+1).join("/")}}return{value:t}},GT=class{constructor({cid:e,bytes:t,value:n}){if(!e||!t||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=t,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:c5(),bytes:c5(),value:c5(),asBlock:c5()})}links(){return $T(this.value,[])}tree(){return HT(this.value,[])}get(e="/"){return Y5e(this.value,e.split("/").filter(Boolean))}};var i0=({bytes:r,cid:e,value:t,codec:n})=>{let i=t!==void 0?t:n&&n.decode(r);if(i===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new GT({cid:e,bytes:r,value:i})};u();u();var jT=E(fa(),1);function WT(r){let e=W1({version:1,roots:r}),t=jT.default.encode(e.length),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function tG(r){return{async setRoots(e){let t=WT(e);await r.write(t)},async writeBlock(e){let{cid:t,bytes:n}=e;await r.write(new Uint8Array(jT.default.encode(t.bytes.length+n.length))),await r.write(t.bytes),n.length&&await r.write(n)},async close(){await r.end()}}}u();function l5(){}function rG(){let r=[],e=null,t=l5,n=!1,i=null,s=l5,o=()=>(e||(e=new Promise(l=>{t=()=>{e=null,t=l5,l()}})),e),a={write(l){r.push(l);let f=o();return s(),f},async end(){n=!0;let l=o();s(),await l}},c={async next(){let l=r.shift();return l?(r.length===0&&t(),{done:!1,value:l}):n?(t(),{done:!0,value:void 0}):(i||(i=new Promise(f=>{s=()=>(i=null,s=l5,f(c.next()))})),i)}};return{writer:a,iterator:c}}u();var xu=E(fa(),1);u();var Su={Null:r=>r===null,Int:r=>Number.isInteger(r),Float:r=>typeof r=="number"&&Number.isFinite(r),String:r=>typeof r=="string",Bool:r=>typeof r=="boolean",Bytes:r=>r instanceof Uint8Array,Link:r=>!Su.Null(r)&&typeof r=="object"&&r.asCID===r,List:r=>Array.isArray(r),Map:r=>!Su.Null(r)&&typeof r=="object"&&r.asCID!==r&&!Su.List(r)&&!Su.Bytes(r)},s0={Int:Su.Int,"CarHeader > version":r=>s0.Int(r),"CarHeader > roots (anon) > valueType (anon)":Su.Link,"CarHeader > roots (anon)":r=>Su.List(r)&&Array.prototype.every.call(r,s0["CarHeader > roots (anon) > valueType (anon)"]),"CarHeader > roots":r=>s0["CarHeader > roots (anon)"](r),CarHeader:r=>{let e=r&&Object.keys(r);return Su.Map(r)&&["version"].every(t=>e.includes(t))&&Object.entries(r).every(([t,n])=>s0["CarHeader > "+t]&&s0["CarHeader > "+t](n))}},nG=s0.CarHeader;var YT={SHA2_256:18,LENGTH:32,DAG_PB:112},iG=16+8+8+8;async function u5(r){let e=await r.upTo(8);if(!e.length)throw new Error("Unexpected end of data");let t=xu.default.decode(e);return r.seek(xu.default.decode.bytes),t}async function Q5e(r){let e=await r.exactly(iG),t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,i={version:2,characteristics:[t.getBigUint64(n,!0),t.getBigUint64(n+=8,!0)],dataOffset:Number(t.getBigUint64(n+=8,!0)),dataSize:Number(t.getBigUint64(n+=8,!0)),indexOffset:Number(t.getBigUint64(n+=8,!0))};return r.seek(iG),i}async function f5(r,e){let t=await u5(r);if(t===0)throw new Error("Invalid CAR header (zero length)");let n=await r.exactly(t);r.seek(t);let i=Df(n);if(!nG(i))throw new Error("Invalid CAR header format");if(i.version!==1&&i.version!==2||e!==void 0&&i.version!==e)throw new Error(`Invalid CAR version: ${i.version}${e!==void 0?` (expected ${e})`:""}`);let s=Array.isArray(i.roots);if(i.version===1&&!s||i.version===2&&s)throw new Error("Invalid CAR header format");if(i.version===1)return i;let o=await Q5e(r);r.seek(o.dataOffset-r.pos);let a=await f5(r,1);return Object.assign(a,o)}async function X5e(r){let e=await r.upTo(8);xu.default.decode(e);let t=xu.default.decode.bytes,n=xu.default.decode(e.subarray(xu.default.decode.bytes)),i=xu.default.decode.bytes,s=t+i+n,o=await r.exactly(s);return r.seek(s),o}async function Z5e(r){let e=await r.exactly(2);if(e[0]===YT.SHA2_256&&e[1]===YT.LENGTH){let o=await r.exactly(34);r.seek(34);let a=nr(o);return A.create(0,YT.DAG_PB,a)}let t=await u5(r);if(t!==1)throw new Error(`Unexpected CID version (${t})`);let n=await u5(r),i=await X5e(r),s=nr(i);return A.create(t,n,s)}async function sG(r){let e=r.pos,t=await u5(r);if(t===0)throw new Error("Invalid CAR section (zero length)");t+=r.pos-e;let n=await Z5e(r),i=t-Number(r.pos-e);return{cid:n,length:t,blockLength:i}}async function J5e(r){let{cid:e,blockLength:t}=await sG(r),n=await r.exactly(t);return r.seek(t),{bytes:n,cid:e}}async function e8e(r){let e=r.pos,{cid:t,length:n,blockLength:i}=await sG(r),s={cid:t,length:n,blockLength:i,offset:e,blockOffset:r.pos};return r.seek(s.blockLength),s}function oG(r){let e=(async()=>{let t=await f5(r);if(t.version===2){let n=r.pos-t.dataOffset;r=r8e(r,t.dataSize-n)}return t})();return{header:()=>e,async*blocks(){for(await e;(await r.upTo(8)).length>0;)yield await J5e(r)},async*blocksIndex(){for(await e;(await r.upTo(8)).length>0;)yield await e8e(r)}}}function h5(r){let e=0;return{async upTo(t){return r.subarray(e,e+Math.min(t,r.length-e))},async exactly(t){if(t>r.length-e)throw new Error("Unexpected end of data");return r.subarray(e,e+t)},seek(t){e+=t},get pos(){return e}}}function t8e(r){let e=0,t=0,n=0,i=new Uint8Array(0),s=async o=>{t=i.length-n;let a=[i.subarray(n)];for(;t<o;){let l=await r();if(l==null)break;t<0?l.length>t&&a.push(l.subarray(-t)):a.push(l),t+=l.length}i=new Uint8Array(a.reduce((l,f)=>l+f.length,0));let c=0;for(let l of a)i.set(l,c),c+=l.length;n=0};return{async upTo(o){return i.length-n<o&&await s(o),i.subarray(n,n+Math.min(i.length-n,o))},async exactly(o){if(i.length-n<o&&await s(o),i.length-n<o)throw new Error("Unexpected end of data");return i.subarray(n,n+o)},seek(o){e+=o,n+=o},get pos(){return e}}}function aG(r){let e=r[Symbol.asyncIterator]();async function t(){let n=await e.next();return n.done?null:n.value}return t8e(t)}function r8e(r,e){let t=0;return{async upTo(n){let i=await r.upTo(n);return i.length+t>e&&(i=i.subarray(0,e-t)),i},async exactly(n){let i=await r.exactly(n);if(i.length+t>e)throw new Error("Unexpected end of data");return i},seek(n){t+=n,r.seek(n)},get pos(){return r.pos}}}var gh=class{constructor(e,t){this._encoder=t,this._mutex=t.setRoots(e),this._ended=!1}async put(e){if(!(e.bytes instanceof Uint8Array)||!e.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let t=A.asCID(e.cid);if(!t)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:t,bytes:e.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}static create(e){e=n8e(e);let{encoder:t,iterator:n}=cG(),i=new gh(e,t),s=new d5(n);return{writer:i,out:s}}static createAppender(){let{encoder:e,iterator:t}=cG();e.setRoots=()=>Promise.resolve();let n=new gh([],e),i=new d5(t);return{writer:n,out:i}}static async updateRootsInBytes(e,t){let n=h5(e);await f5(n);let i=WT(t);if(Number(n.pos)!==i.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${i.length} bytes)`);return e.set(i,0),e}},d5=class{constructor(e){this._iterator=e}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function cG(){let r=rG(),{writer:e,iterator:t}=r;return{encoder:tG(e),iterator:t}}function n8e(r){if(r===void 0)return[];if(!Array.isArray(r)){let t=A.asCID(r);if(!t)throw new TypeError("roots must be a single CID or an array of CIDs");return[t]}let e=[];for(let t of r){let n=A.asCID(t);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");e.push(n)}return e}u();var QT=async({cid:r,load:e,seen:t})=>{t=t||new Set;let n=r.toString(Ue);if(t.has(n))return;let i=await e(r);if(t.add(n),i!==null)for(let[,s]of i.links())await QT({cid:s,load:e,seen:t})};var lG=C("ipfs:components:dag:import"),i8e=[An,q_];function uG({repo:r,preload:e,codecs:t}){async function*n(i,s={}){s.preload!==!1&&e(i);let o=A.asCID(i);if(!o)throw new Error(`Unexpected error converting CID type: ${i}`);lG(`Exporting ${o} as car`);let{writer:a,out:c}=await gh.create([o]),l=null;(async()=>{try{let f=s8e(r,a,{signal:s.signal,timeout:s.timeout},t);await QT({cid:o,load:f})}catch(f){l=f}finally{a.close()}})();for await(let f of c){if(l)break;yield f}if(l)throw l}return M(n)}function s8e(r,e,t,n){return async i=>{let s=await n.getCodec(i.code);if(!s)throw new Error(`Can't decode links in block with codec 0x${i.code.toString(16)} to form complete DAG`);let o=await r.blocks.get(i,t);return lG(`Adding block ${i} to car`),await e.put({cid:i,bytes:o}),i8e.includes(i.code)?null:i0({bytes:o,cid:i,codec:s})}}u();var hG=E(Oa(),1),dG=E(vi(),1);var pG=E(V(),1);function mG({codecs:r,repo:e,preload:t}){return M(async function(s,o={}){if(o.preload!==!1&&t(s),o.path){let h=o.localResolve?await(0,hG.default)($l(s,o.path,r,e,o)):await(0,dG.default)($l(s,o.path,r,e,o));if(!h)throw(0,pG.default)(new Error("Not found"),"ERR_NOT_FOUND");return h}let a=await r.getCodec(s.code),c=await e.blocks.get(s,o);return{value:a.decode(c),remainderPath:""}})}u();u();var p5=class{constructor(e,t,n){this._version=e,this._roots=t,this._iterable=n,this._decoded=!1}get version(){return this._version}async getRoots(){return this._roots}},wh=class extends p5{[Symbol.asyncIterator](){if(this._decoded)throw new Error("Cannot decode more than once");if(!this._iterable)throw new Error("Block iterable not found");return this._decoded=!0,this._iterable[Symbol.asyncIterator]()}static async fromBytes(e){let{version:t,roots:n,iterator:i}=await yG(e);return new wh(t,n,i)}static async fromIterable(e){let{version:t,roots:n,iterator:i}=await gG(e);return new wh(t,n,i)}},B2=class extends p5{[Symbol.asyncIterator](){if(this._decoded)throw new Error("Cannot decode more than once");if(!this._iterable)throw new Error("Block iterable not found");this._decoded=!0;let e=this._iterable[Symbol.asyncIterator]();return{async next(){let t=await e.next();return t.done?t:{done:!1,value:t.value.cid}}}}static async fromBytes(e){let{version:t,roots:n,iterator:i}=await yG(e);return new B2(t,n,i)}static async fromIterable(e){let{version:t,roots:n,iterator:i}=await gG(e);return new B2(t,n,i)}};async function yG(r){if(!(r instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return wG(h5(r))}async function gG(r){if(!r||typeof r[Symbol.asyncIterator]!="function")throw new TypeError("fromIterable() requires an async iterable");return wG(aG(r))}async function wG(r){let e=oG(r),{version:t,roots:n}=await e.header();return{version:t,roots:n,iterator:e.blocks()}}var EG=E(Wp(),1),bG=E(fi(),1),vG=E(Kn(),1);var _G=C("ipfs:components:dag:import");function SG({repo:r}){async function*e(t,n={}){let i=await r.gcLock.readLock();try{let s={signal:n.signal,timeout:n.timeout},o=(0,EG.default)(t),{value:a,done:c}=await o.peek();if(c)return;a&&o.push(a);let l;a instanceof Uint8Array?l=[o]:l=o;for await(let f of l){let h=await a8e(r,s,f);if(n.pinRoots!==!1)for(let p of h){let d="";try{await r.blocks.has(p)?(_G(`Pinning root ${p}`),await r.pins.pinRecursively(p)):d="blockstore: block not found"}catch(m){d=m.message}yield{root:{cid:p,pinErrorMsg:d}}}}}finally{i()}}return M(e)}async function a8e(r,e,t){let n=await wh.fromIterable(t),i=await n.getRoots();return await(0,bG.default)(r.blocks.putMany((0,vG.default)(n,({cid:s,bytes:o})=>(_G(`Import block ${s}`),{key:s,value:o})),{signal:e.signal})),i}u();function xG({repo:r,codecs:e,hashers:t,preload:n}){async function i(s,o={}){let a=o.pin?await r.gcLock.readLock():null;try{let c=await e.getCodec(o.storeCodec||"dag-cbor");if(!c)throw new Error(`Unknown storeCodec ${o.storeCodec}, please configure additional BlockCodecs for this IPFS instance`);if(o.inputCodec){if(!(s instanceof Uint8Array))throw new Error("Can only inputCodec on raw bytes that can be decoded");let m=await e.getCodec(o.inputCodec);if(!m)throw new Error(`Unknown inputCodec ${o.inputCodec}, please configure additional BlockCodecs for this IPFS instance`);s=m.decode(s)}let l=o.version!=null?o.version:1,f=await t.getHasher(o.hashAlg||"sha2-256");if(!f)throw new Error(`Unknown hash algorithm ${o.hashAlg}, please configure additional MultihashHashers for this IPFS instance`);let h=c.encode(s),p=await f.digest(h),d=A.create(l,c.code,p);return await r.blocks.put(d,h,{signal:o.signal}),o.pin&&await r.pins.pinRecursively(d),o.preload!==!1&&n(d),d}finally{a&&a()}}return M(i)}u();function TG({repo:r,codecs:e,preload:t}){async function n(i,s={}){let{cid:o}=_c(i);return s.preload!==!1&&t(o),zl(r,e,i,s)}return M(n)}var m5=class{constructor({repo:e,codecs:t,hashers:n,preload:i}){this.export=uG({repo:e,preload:i,codecs:t}),this.get=mG({codecs:t,repo:e,preload:i}),this.import=SG({repo:e}),this.resolve=TG({repo:e,codecs:t,preload:i}),this.put=xG({repo:e,codecs:t,hashers:n,preload:i})}};u();u();var y5=(r,e)=>e,c8e=(r,e,t,n)=>{if(n!=null&&n.assumeHttp===!1)return`tcp://${r}:${e}`;let i="tcp",s=`:${e}`;return t[t.length-1].protocol==="tcp"&&(i=e==="443"?"https":"http",s=e==="443"||e==="80"?"":s),`${i}://${r}${s}`},l8e={ip4:y5,ip6:(r,e,t,n)=>n.length===1&&n[0].protocol==="ip6"?e:`[${e}]`,tcp:(r,e,t,n,i)=>n.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${r}:${e}`:c8e(r,e,n,i),udp:(r,e)=>`udp://${r}:${e}`,dnsaddr:y5,dns4:y5,dns6:y5,ipfs:(r,e)=>`${r}/ipfs/${e}`,p2p:(r,e)=>`${r}/p2p/${e}`,http:r=>`http://${r}`,https:r=>`https://${r}`,ws:r=>`ws://${r}`,wss:r=>`wss://${r}`,"p2p-websocket-star":r=>`${r}/p2p-websocket-star`,"p2p-webrtc-star":r=>`${r}/p2p-webrtc-star`,"p2p-webrtc-direct":r=>`${r}/p2p-webrtc-direct`};function o0(r,e){let t=se(r),n=t.toString().split("/").slice(1);return t.tuples().map(i=>({protocol:n.shift()??"",content:i[1]!=null?n.shift()??"":""})).reduce((i,s,o,a)=>{let c=l8e[s.protocol];if(c==null)throw new Error(`Unsupported protocol ${s.protocol}`);return c(i,s.content,o,a,e)},"")}u();function XT(r){if(!Array.isArray(r))throw new TypeError(`Expected an array, got ${typeof r}`);r=[...r];for(let e=r.length-1;e>0;e--){let t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r}u();var IG=E(cp(),1);var u8e=C("ipfs:preload"),f8e=yo.default?yo.default:yo,h8e=new f8e({concurrency:4});function AG(r,e={}){return u8e(r),h8e.add(async()=>{let n=(await IG.default.post(r,{signal:e.signal})).body.getReader();try{for(;;){let{done:i}=await n.read();if(i)return}}finally{n.releaseLock()}})}var RG=E(op(),1),M2=C("ipfs:preload");function CG(r={}){if(r.enabled=Boolean(r.enabled),r.addresses=r.addresses||[],r.cache=r.cache||1e3,!r.enabled||!r.addresses.length)return M2("preload disabled"),Object.assign(()=>{},{start:()=>{},stop:()=>{}});let e=!0,t=[],n=r.addresses.map(o=>o0(o)),i=(0,RG.default)(r.cache),s=async o=>{try{if(e)throw new Error(`preload ${o} but preloader is not started`);let a=o.toString();if(i.has(a))return;i.set(a,!0);let c=XT(n),l=!1,f=Date.now();for(let h of c){if(e)throw new Error(`preload aborted for ${a}`);let p;try{p=new AbortController,t=t.concat(p),await AG(`${h}/api/v0/refs?r=true&arg=${encodeURIComponent(a)}`,{signal:p.signal}),l=!0}catch(d){d.type!=="aborted"&&M2.error(d)}finally{t=t.filter(d=>d!==p)}if(l)break}M2(`${l?"":"un"}successfully preloaded ${a} in ${Date.now()-f}ms`)}catch(a){M2.error(a)}};return s.start=()=>{e=!1},s.stop=()=>{e=!0,M2(`aborting ${t.length} pending preload request(s)`),t.forEach(o=>o.abort()),t=[]},s}u();var g5=C("ipfs:mfs-preload");function PG({preload:r,files:e,options:t={}}){if(t.interval=t.interval||30*1e3,!t.enabled){g5("MFS preload disabled");let o=async()=>{};return{start:o,stop:o}}let n="",i,s=async()=>{try{let o=await e.stat("/"),a=o.cid.toString();n!==a&&(g5(`preloading updated MFS root ${n} -> ${o.cid}`),await r(o.cid),n=a)}catch(o){g5.error("failed to preload MFS root",o)}finally{i=setTimeout(s,t.interval)}};return{async start(){let o=await e.stat("/");n=o.cid.toString(),g5(`monitoring MFS root ${o.cid}`),i=setTimeout(s,t.interval)},stop(){clearTimeout(i)}}}u();u();u();u();var FG=E(Hl(),1);u();var U2=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},ZT=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},DG=r=>globalThis.DOMException===void 0?new ZT(r):new DOMException(r),OG=r=>{let e=r.reason===void 0?DG("This operation was aborted."):r.reason;return e instanceof Error?e:DG(e)};function JT(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(OG(c)),c.addEventListener("abort",()=>{a(OG(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new U2(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function eI(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var Eh=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Hc,F2=class{constructor(){Hc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Eh(this,Hc,"f")[this.size-1].priority>=t.priority){Eh(this,Hc,"f").push(n);return}let i=eI(Eh(this,Hc,"f"),n,(s,o)=>o.priority-s.priority);Eh(this,Hc,"f").splice(i,0,n)}dequeue(){let e=Eh(this,Hc,"f").shift();return e?.run}filter(e){return Eh(this,Hc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Eh(this,Hc,"f").length}};Hc=new WeakMap;var Dr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},xe=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Xr,K2,q2,Iu,S5,z2,w5,ko,V2,Xi,E5,Zi,$2,Tu,b5,kG,NG,UG,LG,BG,MG,v5,tI,rI,x5,_5,d8e=new U2,nI=class extends Error{},a0=class extends FG.default{constructor(e){var t,n,i,s;if(super(),Xr.add(this),K2.set(this,void 0),q2.set(this,void 0),Iu.set(this,0),S5.set(this,void 0),z2.set(this,void 0),w5.set(this,0),ko.set(this,void 0),V2.set(this,void 0),Xi.set(this,void 0),E5.set(this,void 0),Zi.set(this,0),$2.set(this,void 0),Tu.set(this,void 0),b5.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:F2,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);Dr(this,K2,e.carryoverConcurrencyCount,"f"),Dr(this,q2,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Dr(this,S5,e.intervalCap,"f"),Dr(this,z2,e.interval,"f"),Dr(this,Xi,new e.queueClass,"f"),Dr(this,E5,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Dr(this,b5,e.throwOnTimeout===!0,"f"),Dr(this,Tu,e.autoStart===!1,"f")}get concurrency(){return xe(this,$2,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Dr(this,$2,e,"f"),xe(this,Xr,"m",x5).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Dr(this,Zi,(a=xe(this,Zi,"f"),a++,a),"f"),Dr(this,Iu,(c=xe(this,Iu,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new nI("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):JT(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?xe(this,b5,"f"):t.throwOnTimeout)&&i(d8e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}xe(this,Xr,"m",UG).call(this)};xe(this,Xi,"f").enqueue(s,t),xe(this,Xr,"m",v5).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return xe(this,Tu,"f")?(Dr(this,Tu,!1,"f"),xe(this,Xr,"m",x5).call(this),this):this}pause(){Dr(this,Tu,!0,"f")}clear(){Dr(this,Xi,new(xe(this,E5,"f")),"f")}async onEmpty(){xe(this,Xi,"f").size!==0&&await xe(this,Xr,"m",_5).call(this,"empty")}async onSizeLessThan(e){xe(this,Xi,"f").size<e||await xe(this,Xr,"m",_5).call(this,"next",()=>xe(this,Xi,"f").size<e)}async onIdle(){xe(this,Zi,"f")===0&&xe(this,Xi,"f").size===0||await xe(this,Xr,"m",_5).call(this,"idle")}get size(){return xe(this,Xi,"f").size}sizeBy(e){return xe(this,Xi,"f").filter(e).length}get pending(){return xe(this,Zi,"f")}get isPaused(){return xe(this,Tu,"f")}};K2=new WeakMap,q2=new WeakMap,Iu=new WeakMap,S5=new WeakMap,z2=new WeakMap,w5=new WeakMap,ko=new WeakMap,V2=new WeakMap,Xi=new WeakMap,E5=new WeakMap,Zi=new WeakMap,$2=new WeakMap,Tu=new WeakMap,b5=new WeakMap,Xr=new WeakSet,kG=function(){return xe(this,q2,"f")||xe(this,Iu,"f")<xe(this,S5,"f")},NG=function(){return xe(this,Zi,"f")<xe(this,$2,"f")},UG=function(){var e;Dr(this,Zi,(e=xe(this,Zi,"f"),e--,e),"f"),xe(this,Xr,"m",v5).call(this),this.emit("next")},LG=function(){this.emit("empty"),xe(this,Zi,"f")===0&&this.emit("idle")},BG=function(){xe(this,Xr,"m",rI).call(this),xe(this,Xr,"m",tI).call(this),Dr(this,V2,void 0,"f")},MG=function(){let e=Date.now();if(xe(this,ko,"f")===void 0){let t=xe(this,w5,"f")-e;if(t<0)Dr(this,Iu,xe(this,K2,"f")?xe(this,Zi,"f"):0,"f");else return xe(this,V2,"f")===void 0&&Dr(this,V2,setTimeout(()=>{xe(this,Xr,"m",BG).call(this)},t),"f"),!0}return!1},v5=function(){if(xe(this,Xi,"f").size===0)return xe(this,ko,"f")&&clearInterval(xe(this,ko,"f")),Dr(this,ko,void 0,"f"),xe(this,Xr,"m",LG).call(this),!1;if(!xe(this,Tu,"f")){let e=!xe(this,Xr,"a",MG);if(xe(this,Xr,"a",kG)&&xe(this,Xr,"a",NG)){let t=xe(this,Xi,"f").dequeue();return t?(this.emit("active"),t(),e&&xe(this,Xr,"m",tI).call(this),!0):!1}}return!1},tI=function(){xe(this,q2,"f")||xe(this,ko,"f")!==void 0||(Dr(this,ko,setInterval(()=>{xe(this,Xr,"m",rI).call(this)},xe(this,z2,"f")),"f"),Dr(this,w5,Date.now()+xe(this,z2,"f"),"f"))},rI=function(){xe(this,Iu,"f")===0&&xe(this,Zi,"f")===0&&xe(this,ko,"f")&&(clearInterval(xe(this,ko,"f")),Dr(this,ko,void 0,"f")),Dr(this,Iu,xe(this,K2,"f")?xe(this,Zi,"f"):0,"f"),xe(this,Xr,"m",x5).call(this)},x5=function(){for(;xe(this,Xr,"m",v5).call(this););},_5=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};u();var iI=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},sI=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},VG=r=>globalThis.DOMException===void 0?new sI(r):new DOMException(r),KG=r=>{let e=r.reason===void 0?VG("This operation was aborted."):r.reason;return e instanceof Error?e:VG(e)};function H2(r,e){let{milliseconds:t,fallback:n,message:i,customTimers:s={setTimeout,clearTimeout}}=e,o,a=new Promise((c,l)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t===Number.POSITIVE_INFINITY){c(r);return}if(e.signal){let{signal:f}=e;f.aborted&&l(KG(f)),f.addEventListener("abort",()=>{l(KG(f))})}o=s.setTimeout.call(void 0,()=>{if(n){try{c(n())}catch(p){l(p)}return}let f=typeof i=="string"?i:`Promise timed out after ${t} milliseconds`,h=i instanceof Error?i:new iI(f);typeof r.cancel=="function"&&r.cancel(),l(h)},t),(async()=>{try{c(await r)}catch(f){l(f)}finally{s.clearTimeout.call(void 0,o)}})()});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}u();u();var qG=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");u();var oI="lock:worker:request-read",aI="lock:worker:release-read",cI="lock:master:grant-read",lI="lock:worker:request-write",uI="lock:worker:release-write",fI="lock:master:grant-write";u();var Au={},c0=r=>{r.addEventListener("message",e=>{c0.dispatchEvent("message",r,e)}),r.port!=null&&r.port.addEventListener("message",e=>{c0.dispatchEvent("message",r,e)})};c0.addEventListener=(r,e)=>{Au[r]==null&&(Au[r]=[]),Au[r].push(e)};c0.removeEventListener=(r,e)=>{Au[r]!=null&&(Au[r]=Au[r].filter(t=>t===e))};c0.dispatchEvent=function(r,e,t){Au[r]!=null&&Au[r].forEach(n=>n(e,t))};var hI=c0;var zG=(r,e,t,n,i)=>(s,o)=>{if(o.data.type!==t)return;let a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};r.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:async()=>(s.postMessage({type:i,name:a.name,identifier:a.identifier}),await new Promise(c=>{let l=f=>{if(f==null||f.data==null)return;let h={type:f.data.type,name:f.data.name,identifier:f.data.identifier};h.type===n&&h.identifier===a.identifier&&(s.removeEventListener("message",l),c())};s.addEventListener("message",l)}))}}))},$G=(r,e,t,n)=>async()=>{let i=qG();return globalThis.postMessage({type:e,identifier:i,name:r}),await new Promise(s=>{let o=a=>{if(a==null||a.data==null)return;let c={type:a.data.type,identifier:a.data.identifier};c.type===t&&c.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:n,identifier:i,name:r})}))};globalThis.addEventListener("message",o)})},p8e={singleProcess:!1},HG=r=>{if(r=Object.assign({},p8e,r),Boolean(globalThis.document)||r.singleProcess){let t=new EventTarget;return hI.addEventListener("message",zG(t,"requestReadLock",oI,aI,cI)),hI.addEventListener("message",zG(t,"requestWriteLock",lI,uI,fI)),t}return{isWorker:!0,readLock:t=>$G(t,oI,cI,aI),writeLock:t=>$G(t,lI,fI,uI)}};var bh={},Ru;async function dI(r,e){let t,n=new Promise(i=>{t=i});return r.add(async()=>await H2((async()=>await new Promise(i=>{t(()=>{i()})}))(),{milliseconds:e.timeout})),await n}var m8e=(r,e)=>{if(Ru.isWorker===!0)return{readLock:Ru.readLock(r,e),writeLock:Ru.writeLock(r,e)};let t=new a0({concurrency:1}),n;return{async readLock(){if(n!=null)return await dI(n,e);n=new a0({concurrency:e.concurrency,autoStart:!1});let i=n,s=dI(n,e);return t.add(async()=>(i.start(),await i.onIdle().then(()=>{n===i&&(n=null)}))),await s},async writeLock(){return n=null,await dI(t,e)}}},y8e={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function vh(r){let e=Object.assign({},y8e,r);return Ru==null&&(Ru=HG(e),Ru.isWorker!==!0&&(Ru.addEventListener("requestReadLock",t=>{bh[t.data.name]!=null&&bh[t.data.name].readLock().then(async n=>await t.data.handler().finally(()=>n()))}),Ru.addEventListener("requestWriteLock",async t=>{bh[t.data.name]!=null&&bh[t.data.name].writeLock().then(async n=>await t.data.handler().finally(()=>n()))}))),bh[e.name]==null&&(bh[e.name]=m8e(e.name,e)),bh[e.name]}var T5;function G2(r=!1){if(T5)return T5;let e=vh({singleProcess:r});return T5={readLock:t=>async(...n)=>{let i=await e.readLock();try{return await t.apply(null,n)}finally{i()}},writeLock:t=>async(...n)=>{let i=await e.writeLock();try{return await t.apply(null,n)}finally{i()}}},T5}u();u();u();var pI=E(V(),1);var GG=C("ipfs:mfs:utils:with-mfs-root");async function l0(r,e){if(e&&e.signal&&e.signal.aborted)throw(0,pI.default)(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});await r.repo.datastore.open();let t;try{let n=await r.repo.datastore.get(nm);t=A.decode(n)}catch(n){if(n.code!=="ERR_NOT_FOUND")throw n;GG("Creating new MFS root");let i=Xe({Data:new Je({type:"directory"}).marshal(),Links:[]}),s=await $e.digest(i);if(t=A.createV0(s),await r.repo.blocks.put(t,i),e&&e.signal&&e.signal.aborted)throw(0,pI.default)(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});await r.repo.datastore.put(nm,t.bytes)}return GG(`Loaded MFS root /ipfs/${t}`),t}u();function u0(r=""){return(r.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean)}var yI=E(V(),1);var mI="ipfs",Ur=async(r,e,t)=>{let n=await l0(r,t),i={entryType:"file"},s="";if(A.asCID(e)?s=`/ipfs/${e}`:s=e.toString(),s=s.trim(),s=s.replace(/(\/\/+)/g,"/"),s.endsWith("/")&&s.length>1&&(s=s.substring(0,s.length-1)),!s)throw(0,yI.default)(new Error("paths must not be empty"),"ERR_NO_PATH");if(s.substring(0,1)!=="/")throw(0,yI.default)(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");s.substring(s.length-1)==="/"&&(s=s.substring(0,s.length-1));let o=u0(s);if(o[0]===mI){let c;o.length===2?c=`/${o.join("/")}`:c=`/${o.slice(0,o.length-1).join("/")}`,i={type:"ipfs",depth:o.length-2,entryType:"file",mfsPath:`/${o.join("/")}`,mfsDirectory:c,parts:o,path:`/${o.join("/")}`,name:o[o.length-1]}}else{let c=`/${mI}/${n}${o.length?"/"+o.join("/"):""}`,l=`/${mI}/${n}/${o.slice(0,o.length-1).join("/")}`;i={type:"mfs",depth:o.length,entryType:"file",mfsDirectory:l,mfsPath:c,parts:o,path:`/${o.join("/")}`,name:o[o.length-1]}}let a=i.type==="mfs"?i.mfsPath:i.path;try{let c=await zn(a,r.repo.blocks,t);i.cid=c.cid,i.mfsPath=`/ipfs/${c.path}`,i.entryType=c.type,i.content=c.content,(i.entryType==="file"||i.entryType==="directory")&&(c.type==="file"||c.type==="directory")&&(i.unixfs=c.unixfs)}catch(c){if(c.code!=="ERR_NOT_FOUND")throw c}return i.exists=Boolean(i.cid),i};var WG=E(V(),1);var g8e=Qe.bind({ignoreUndefined:!0}),w8e=C("ipfs:mfs:stat"),E8e={withLocal:!1};function Cu(r){async function e(t,n={}){n=g8e(E8e,n),w8e(`Fetching stats for ${t}`);let{type:i,cid:s,mfsPath:o}=await Ur(r,t,n),a=i==="ipfs"&&s?s:o,c;try{c=await zn(a,r.repo.blocks)}catch(l){throw l.code==="ERR_NOT_FOUND"?(0,WG.default)(new Error(`${t} does not exist`),"ERR_NOT_FOUND"):l}if(!jG[c.type])throw new Error(`Cannot stat codec ${c.cid.code}`);return jG[c.type](c)}return M(e)}var jG={raw:r=>({cid:r.cid,size:r.node.length,cumulativeSize:r.node.length,blocks:0,type:"file",local:void 0,sizeLocal:void 0,withLocality:!1}),file:r=>{let e={cid:r.cid,type:"file",size:r.unixfs.fileSize(),cumulativeSize:Xe(r.node).length+(r.node.Links||[]).reduce((t,n)=>t+(n.Tsize||0),0),blocks:r.unixfs.blockSizes.length,local:void 0,sizeLocal:void 0,withLocality:!1,mode:r.unixfs.mode};return r.unixfs.mtime&&(e.mtime=r.unixfs.mtime),e},directory:r=>{let e={cid:r.cid,type:"directory",size:0,cumulativeSize:Xe(r.node).length+(r.node.Links||[]).reduce((t,n)=>t+(n.Tsize||0),0),blocks:r.node.Links.length,local:void 0,sizeLocal:void 0,withLocality:!1,mode:r.unixfs.mode};return r.unixfs.mtime&&(e.mtime=r.unixfs.mtime),e},object:r=>({cid:r.cid,size:r.node.length,cumulativeSize:r.node.length,type:"file",blocks:0,local:void 0,sizeLocal:void 0,withLocality:!1}),identity:r=>({cid:r.cid,size:r.node.length,cumulativeSize:r.node.length,blocks:0,type:"file",local:void 0,sizeLocal:void 0,withLocality:!1})};u();var m0=E(V(),1);u();var b8e=C("ipfs:mfs:utils:to-trail");async function ka(r,e){b8e(`Creating trail for path ${e}`);let t=[];for await(let n of fT(e,r.repo.blocks))t.push({name:n.name,cid:n.cid,size:n.size,type:n.type});return t}u();u();u();var I5=async(r,e,t)=>{t.codec||(t.codec=_t),t.hasher||(t.hasher=$e),t.cidVersion===void 0&&(t.cidVersion=1),t.codec===_t&&t.hasher!==$e&&(t.cidVersion=1);let n=await t.hasher.digest(r),i=A.create(t.cidVersion,t.codec.code,n);return t.onlyHash||await e.put(i,r,{signal:t.signal}),i};u();var A5=ih.code,R5=8;async function C5(r){return(await ih.encode(r)).slice(0,8).reverse()}var gI=class{constructor(e,t){this.options=t||{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime,this.cid=void 0,this.size=void 0}async put(e,t){}get(e){return Promise.resolve(this)}async*eachChildSeries(){}async*flush(e){}},f0=class extends gI{constructor(e,t){super(e,t),this._bucket=hu({hashFn:C5,bits:R5})}async put(e,t){await this._bucket.put(e,t)}get(e){return this._bucket.get(e)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:e,value:t}of this._bucket.eachLeafSeries())yield{key:e,child:t}}async*flush(e){yield*YG(this._bucket,e,this,this.options)}};async function*YG(r,e,t,n){let i=r._children,s=[],o=0;for(let d=0;d<i.length;d++){let m=i.get(d);if(!m)continue;let y=d.toString(16).toUpperCase().padStart(2,"0");if(m instanceof Cr){let g;for await(let w of await YG(m,e,null,n))g=w;if(!g)throw new Error("Could not flush sharded directory, no subshard found");s.push({Name:y,Tsize:g.size,Hash:g.cid}),o+=g.size}else if(typeof m.value.flush=="function"){let g=m.value,w;for await(let S of g.flush(e))w=S,yield w;let b=y+m.key;s.push({Name:b,Tsize:w.size,Hash:w.cid}),o+=w.size}else{let g=m.value;if(!g.cid)continue;let w=y+m.key,b=g.size;s.push({Name:w,Tsize:b,Hash:g.cid}),o+=b}}let a=Uint8Array.from(i.bitField().reverse()),l={Data:new Je({type:"hamt-sharded-directory",data:a,fanout:r.tableSize(),hashType:A5,mtime:t&&t.mtime,mode:t&&t.mode}).marshal(),Links:s},f=Xe(Tn(l)),h=await I5(f,e,n),p=f.length+o;yield{cid:h,node:l,size:p}}u();var QG=E(vi(),1);var j2=C("ipfs:mfs:core:utils:hamt-utils"),h0=async(r,e,t,n)=>{if(!n.parent.Data)throw new Error("Could not update HAMT directory because parent had no data");let i=Uint8Array.from(t._children.bitField().reverse()),s=Je.unmarshal(n.parent.Data),o=new Je({type:"hamt-sharded-directory",data:i,fanout:t.tableSize(),hashType:A5,mode:s.mode,mtime:s.mtime}),a=await r.hashers.getHasher(n.hashAlg),c={Data:o.marshal(),Links:e.sort((p,d)=>(p.Name||"").localeCompare(d.Name||""))},l=Xe(c),f=await a.digest(l),h=A.create(n.cidVersion,at,f);return n.flush&&await r.repo.blocks.put(h,l),{node:c,cid:h,size:e.reduce((p,d)=>p+(d.Tsize||0),l.length)}},wI=async(r,e,t,n,i)=>{let s=new Cr({hash:t._options.hash,bits:t._options.bits},n,i);return n._putObjectAt(i,s),await W2(r,e,s,t),s},EI=async r=>{let e=hu({hashFn:C5,bits:R5});return await Promise.all(r.map(async t=>{let n=t.Name||"";if(n.length===2){let i=parseInt(n,16),s=new Cr({hash:e._options.hash,bits:e._options.bits},e,i);return e._putObjectAt(i,s),Promise.resolve()}return e.put(n.substring(2),{size:t.Tsize,cid:t.Hash})})),e},W2=async(r,e,t,n)=>{await Promise.all(e.map(async i=>{let s=i.Name||"";if(s.length===2){j2("Populating sub bucket",s);let o=parseInt(s,16),a=await r.repo.blocks.get(i.Hash),c=vt(a),l=new Cr({hash:n._options.hash,bits:n._options.bits},t,o);return t._putObjectAt(o,l),await W2(r,c.Links,l,n),Promise.resolve()}return n.put(s.substring(2),{size:i.Tsize,cid:i.Hash})}))},_h=r=>r.toString(16).toUpperCase().padStart(2,"0").substring(0,2),XG=async(r,e,t)=>{let n=await EI(t.Links),i=await n._findNewBucketAndPos(e),s=[{bucket:i.bucket,prefix:_h(i.pos)}],o=i.bucket;for(;o!==n;)s.push({bucket:o,prefix:_h(o._posAtParent)}),o=o._parent;s.reverse(),s[0].node=t;for(let a=0;a<s.length;a++){let c=s[a];if(!c.node)throw new Error("Could not generate HAMT path");let l=c.node.Links.filter(d=>(d.Name||"").substring(0,2)===c.prefix).pop();if(!l){j2(`Link ${c.prefix}${e} will be added`);continue}if(l.Name===`${c.prefix}${e}`){j2(`Link ${c.prefix}${e} will be replaced`);continue}j2(`Found subshard ${c.prefix}`);let f=await r.repo.blocks.get(l.Hash),h=vt(f);if(!s[a+1]){j2(`Loaded new subshard ${c.prefix}`),await wI(r,h.Links,n,c.bucket,parseInt(c.prefix,16));let d=await n._findNewBucketAndPos(e);s.push({bucket:d.bucket,prefix:_h(d.pos),node:h});continue}let p=s[a+1];await W2(r,h.Links,p.bucket,n),p.node=h}return await n.put(e,!0),s.reverse(),{rootBucket:n,path:s}},ZG=async(r,e,t={})=>{let n=new f0({root:!0,dir:!0,parent:void 0,parentKey:void 0,path:"",dirty:!0,flat:!1,mtime:t.mtime,mode:t.mode},t);for(let s=0;s<e.length;s++)await n._bucket.put(e[s].name,{size:e[s].size,cid:e[s].cid});let i=await(0,QG.default)(n.flush(r.repo.blocks));if(!i)throw new Error("Flushing shard yielded no result");return i};var Na=E(V(),1),JG=E(vi(),1),La=C("ipfs:mfs:core:utils:add-link");async function Ks(r,e){let t=e.parent;if(e.parentCid){let i=A.asCID(e.parentCid);if(i===null)throw(0,Na.default)(new Error("Invalid CID passed to addLink"),"EINVALIDPARENTCID");if(i.code!==at)throw(0,Na.default)(new Error("Unsupported codec. Only DAG-PB is supported"),"EINVALIDPARENTCID");La(`Loading parent node ${i}`);let s=await r.repo.blocks.get(i);t=vt(s)}if(!t)throw(0,Na.default)(new Error("No parent node or CID passed to addLink"),"EINVALIDPARENT");if(!e.cid)throw(0,Na.default)(new Error("No child cid passed to addLink"),"EINVALIDCHILDCID");if(!e.name)throw(0,Na.default)(new Error("No child name passed to addLink"),"EINVALIDCHILDNAME");if(!e.size&&e.size!==0)throw(0,Na.default)(new Error("No child size passed to addLink"),"EINVALIDCHILDSIZE");if(!t.Data)throw(0,Na.default)(new Error("Parent node with no data passed to addLink"),"ERR_INVALID_PARENT");let n=Je.unmarshal(t.Data);return n.type==="hamt-sharded-directory"?(La("Adding link to sharded directory"),S8e(r,{...e,parent:t})):t.Links.length>=e.shardSplitThreshold?(La("Converting directory to sharded directory"),v8e(r,{...e,parent:t,mtime:n.mtime,mode:n.mode})):(La(`Adding ${e.name} (${e.cid}) to regular directory`),_8e(r,{...e,parent:t}))}var v8e=async(r,e)=>{let t=await ZG(r,e.parent.Links.map(n=>({name:n.Name||"",size:n.Tsize||0,cid:n.Hash})).concat({name:e.name,size:e.size,cid:e.cid}),e);return La(`Converted directory to sharded directory ${t.cid}`),t},_8e=async(r,e)=>{let t=e.parent.Links.filter(l=>l.Name!==e.name);if(t.push({Name:e.name,Tsize:e.size,Hash:e.cid}),!e.parent.Data)throw(0,Na.default)(new Error("Parent node with no data passed to addToDirectory"),"ERR_INVALID_PARENT");let n=Je.unmarshal(e.parent.Data),i;if(n.mtime){let l=Date.now(),f=Math.floor(l/1e3);n.mtime={secs:f,nsecs:(l-f*1e3)*1e3},i=n.marshal()}else i=e.parent.Data;e.parent=Tn({Data:i,Links:t});let s=await r.hashers.getHasher(e.hashAlg),o=Xe(e.parent),a=await s.digest(o),c=A.create(e.cidVersion,at,a);return e.flush&&await r.repo.blocks.put(c,o),{node:e.parent,cid:c,size:o.length}},S8e=async(r,e)=>{let{shard:t,path:n}=await x8e(r,e),i=await(0,JG.default)(t.flush(r.repo.blocks));if(!i)throw new Error("No result from flushing shard");let s=await r.repo.blocks.get(i.cid),o=vt(s),a=e.parent.Links.filter(l=>(l.Name||"").substring(0,2)!==n[0].prefix),c=o.Links.find(l=>(l.Name||"").substring(0,2)===n[0].prefix);if(!c)throw new Error(`No link found with prefix ${n[0].prefix}`);return a.push(c),h0(r,a,n[0].bucket,e)},x8e=async(r,e)=>{let t={name:e.name,cid:e.cid,size:e.size};if(!e.parent.Data)throw(0,Na.default)(new Error("Parent node with no data passed to addFileToShardedDirectory"),"ERR_INVALID_PARENT");let n=await EI(e.parent.Links),i=Je.unmarshal(e.parent.Data),s=new f0({root:!0,dir:!0,parent:void 0,parentKey:void 0,path:"",dirty:!0,flat:!1,mode:i.mode},e);s._bucket=n,i.mtime&&(s.mtime={secs:Math.round(Date.now()/1e3)});let o=await n._findNewBucketAndPos(t.name),a=T8e(o);a[0].node=e.parent;let c=0;for(;c<a.length;){let l=a[c];c++;let f=l.node;if(!f)throw new Error("Segment had no node");let h=f.Links.find(y=>(y.Name||"").substring(0,2)===l.prefix);if(!h){La(`Link ${l.prefix}${t.name} will be added`),c=a.length;break}if(h.Name===`${l.prefix}${t.name}`){La(`Link ${l.prefix}${t.name} will be replaced`),c=a.length;break}if((h.Name||"").length>2){La(`Link ${h.Name} ${h.Hash} will be replaced with a subshard`),c=a.length;break}La(`Found subshard ${l.prefix}`);let p=await r.repo.blocks.get(h.Hash),d=vt(p);if(!a[c]){La(`Loaded new subshard ${l.prefix}`),await wI(r,d.Links,n,l.bucket,parseInt(l.prefix,16));let y=await n._findNewBucketAndPos(t.name);a.push({bucket:y.bucket,prefix:_h(y.pos),node:d});break}let m=a[c];await W2(r,d.Links,m.bucket,n),m.node=d}return await s._bucket.put(t.name,{size:t.size,cid:t.cid}),{shard:s,path:a}},T8e=r=>{let e=[{bucket:r.bucket,prefix:_h(r.pos)}],t=r.bucket._parent,n=r.bucket._posAtParent;for(;t;)e.push({bucket:t,prefix:_h(n)}),n=t._posAtParent,t=t._parent;return e.reverse(),e};u();var ej=C("ipfs:mfs:utils:update-tree"),I8e={shardSplitThreshold:1e3};async function Ji(r,e,t){t=Object.assign({},I8e,t),ej("Trail",e),e=e.slice().reverse();let n=0,i;for await(let o of r.repo.blocks.getMany(e.map(a=>a.cid))){let a=vt(o),c=e[n].cid,l=e[n].name;if(n++,!i){i={cid:c,name:l,size:o.length};continue}let f=await Ks(r,{parent:a,name:i.name,cid:i.cid,size:i.size,flush:t.flush,shardSplitThreshold:t.shardSplitThreshold,hashAlg:t.hashAlg,cidVersion:t.cidVersion});i={cid:f.cid,name:l,size:f.size}}let{cid:s}=i;return ej(`Final CID ${s}`),s}u();var tj=E(V(),1),A8e=C("ipfs:mfs:utils:update-mfs-root");async function es(r,e,t){if(t&&t.signal&&t.signal.aborted)throw(0,tj.default)(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});return A8e(`New MFS root will be ${e}`),await r.repo.datastore.put(nm,e.bytes),e}var uj=E(vi(),1);u();u();var Sh=E(V(),1);u();async function rj(r,e,t){let n=new Je({type:e,mode:t.mode,mtime:t.mtime}),i=await r.hashers.getHasher(t.hashAlg),s={Data:n.marshal(),Links:[]},o=Xe(s),a=await i.digest(o),c=A.create(t.cidVersion,at,a);return t.flush&&await r.repo.blocks.put(c,o),{cid:c,node:s}}var R8e=Qe.bind({ignoreUndefined:!0}),nj=C("ipfs:mfs:mkdir"),C8e={parents:!1,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3,flush:!0};function xh(r){async function e(t,n={}){let i=R8e(C8e,n);if(!t)throw new Error("no path given to Mkdir");if(t=t.trim(),t==="/"){if(i.parents)return;throw(0,Sh.default)(new Error("cannot create directory '/': Already exists"),"ERR_INVALID_PATH")}if(t.substring(0,1)!=="/")throw(0,Sh.default)(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");nj(`Creating ${t}`);let s=u0(t);if(s[0]==="ipfs")throw(0,Sh.default)(new Error("path cannot have the prefix 'ipfs'"),"ERR_INVALID_PATH");let o=await l0(r,i),a,c=[],l=await rj(r,"directory",i);for(let h=0;h<=s.length;h++){let p=s.slice(0,h),d=`/ipfs/${o}/${p.join("/")}`;try{if(a=await zn(d,r.repo.blocks),a.type!=="file"&&a.type!=="directory")throw(0,Sh.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");if(h===s.length){if(i.parents)return;throw(0,Sh.default)(new Error("file already exists"),"ERR_ALREADY_EXISTS")}c.push({name:a.name,cid:a.cid})}catch(m){if(m.code==="ERR_NOT_FOUND"){if(h<s.length&&!i.parents)throw(0,Sh.default)(new Error(`Intermediate directory path ${d} does not exist, use the -p flag to create it`),"ERR_NOT_FOUND");await P8e(r,p[p.length-1],l,c[c.length-1],c,i)}else throw m}}let f=await Ji(r,c,i);await es(r,f,i)}return M(e)}var P8e=async(r,e,t,n,i,s)=>{nj(`Adding empty dir called ${e} to ${n.cid}`);let o=await Ks(r,{parent:n.node,parentCid:n.cid,size:0,cid:t.cid,name:e,hashAlg:s.hashAlg,cidVersion:s.cidVersion,flush:s.flush,shardSplitThreshold:s.shardSplitThreshold});i[i.length-1].cid=o.cid,i.push({name:e,cid:t.cid})};var Pu=E(V(),1);var D8e=Qe.bind({ignoreUndefined:!0}),P5=C("ipfs:mfs:cp"),O8e={parents:!1,flush:!0,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3};function d0(r){async function e(t,n,i={}){let s=D8e(O8e,i);Array.isArray(t)||(t=[t]);let o=await Promise.all(t.map(p=>Ur(r,p,s))),a=await Ur(r,n,s);if(!o.length||!a)throw(0,Pu.default)(new Error("Please supply at least one source"),"ERR_INVALID_PARAMS");let c=o.find(p=>!p.exists);if(c)throw(0,Pu.default)(new Error(`${c.path} does not exist`),"ERR_INVALID_PARAMS");let l=ij(a);if(a.exists){if(P5("Destination exists"),o.length===1&&!l)throw(0,Pu.default)(new Error("directory already has entry by that name"),"ERR_ALREADY_EXISTS")}else if(P5("Destination does not exist"),o.length>1){if(!s.parents)throw(0,Pu.default)(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await xh(r)(a.path,s),a=await Ur(r,a.path,s)}else if(a.parts.length>1){let p=`/${a.parts.slice(0,-1).join("/")}`;try{await Cu(r)(p,s)}catch(d){if(d.code!=="ERR_NOT_FOUND")throw d;if(!s.parents)throw(0,Pu.default)(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await xh(r)(p,s),a=await Ur(r,a.path,s)}}let f=ij(a)?a.mfsPath:a.mfsDirectory,h=await ka(r,f);if(o.length===1){let p=o.pop();if(!p)throw(0,Pu.default)(new Error("could not find source"),"ERR_INVALID_PARAMS");let d=l?p.name:a.name;return P5(`Only one source, copying to destination ${l?"directory":"file"} ${d}`),k8e(r,p,d,h,s)}return P5("Multiple sources, wrapping in a directory"),N8e(r,o,a,h,s)}return M(e)}var ij=r=>r.unixfs&&r.unixfs.type&&r.unixfs.type.includes("directory"),k8e=async(r,e,t,n,i)=>{let s=n.pop();if(!s)throw(0,Pu.default)(new Error("destination had no parent"),"ERR_INVALID_PARAMS");s=await sj(r,e,t,s,i),n.push(s);let o=await Ji(r,n,i);await es(r,o,i)},N8e=async(r,e,t,n,i)=>{for(let o=0;o<e.length;o++){let a=e[o];t=await sj(r,a,a.name,t,i)}n[n.length-1]=t;let s=await Ji(r,n,i);await es(r,s,i)},sj=async(r,e,t,n,i)=>{let s=await r.repo.blocks.get(e.cid),{node:o,cid:a,size:c}=await Ks(r,{parentCid:n.cid,size:s.length,cid:e.cid,name:t,hashAlg:i.hashAlg,cidVersion:i.cidVersion,flush:i.flush,shardSplitThreshold:i.shardSplitThreshold});return n.node=o,n.cid=a,n.size=c,n};u();var Y2=E(V(),1);u();var Du=E(V(),1),Ou=C("ipfs:mfs:core:utils:remove-link");async function oj(r,e){let t=e.parent;if(e.parentCid){let i=A.asCID(e.parentCid);if(i===null)throw(0,Du.default)(new Error("Invalid CID passed to removeLink"),"EINVALIDPARENTCID");Ou(`Loading parent node ${i}`);let s=await r.repo.blocks.get(i);t=vt(s)}if(!t)throw(0,Du.default)(new Error("No parent node or CID passed to removeLink"),"EINVALIDPARENT");if(!e.name)throw(0,Du.default)(new Error("No child name passed to removeLink"),"EINVALIDCHILDNAME");if(!t.Data)throw(0,Du.default)(new Error("Parent node had no data"),"ERR_INVALID_NODE");return Je.unmarshal(t.Data).type==="hamt-sharded-directory"?(Ou(`Removing ${e.name} from sharded directory`),B8e(r,{...e,parent:t})):(Ou(`Removing link ${e.name} regular directory`),L8e(r,{...e,parent:t}))}var L8e=async(r,e)=>{e.parent.Links=e.parent.Links.filter(o=>o.Name!==e.name);let t=await Xe(e.parent),i=await(await r.hashers.getHasher(e.hashAlg)).digest(t),s=A.create(e.cidVersion,at,i);return await r.repo.blocks.put(s,t),Ou(`Updated regular directory ${s}`),{node:e.parent,cid:s}},B8e=async(r,e)=>{let{rootBucket:t,path:n}=await XG(r,e.name,e.parent);await t.del(e.name);let{node:i}=await aj(r,n,e.name,e);return h0(r,i.Links,t,e)},aj=async(r,e,t,n)=>{let i=e.pop();if(!i)throw(0,Du.default)(new Error("Could not find parent"),"EINVALIDPARENT");let{bucket:s,prefix:o,node:a}=i;if(!a)throw(0,Du.default)(new Error("Could not find parent"),"EINVALIDPARENT");let c=a.Links.find(d=>(d.Name||"").substring(0,2)===o);if(!c)throw(0,Du.default)(new Error(`No link found with prefix ${o} for file ${t}`),"ERR_NOT_FOUND");if(c.Name===`${o}${t}`){Ou(`Removing existing link ${c.Name}`);let d=a.Links.filter(m=>m.Name!==c.Name);return await s.del(t),h0(r,d,s,n)}Ou(`Descending into sub-shard ${c.Name} for ${o}${t}`);let l=await aj(r,e,t,n),f=l.cid,h=l.size,p=o;if(l.node.Links.length===1){Ou(`Removing subshard for ${o}`);let d=l.node.Links[0];p=`${o}${(d.Name||"").substring(2)}`,f=d.Hash,h=d.Tsize||0}return Ou(`Updating shard ${o} with name ${p}`),M8e(r,s,a,o,p,h,f,n)},M8e=(r,e,t,n,i,s,o,a)=>{let c=t.Links.filter(l=>l.Name!==n);return c.push({Name:i,Tsize:s,Hash:o}),h0(r,c,e,a)};var U8e=Qe.bind({ignoreUndefined:!0}),F8e={recursive:!1,cidVersion:0,hashAlg:"sha2-256",flush:!0,shardSplitThreshold:1e3};function p0(r){async function e(t,n={}){let i=U8e(F8e,n);Array.isArray(t)||(t=[t]);let s=await Promise.all(t.map(o=>Ur(r,o,i)));if(!s.length)throw(0,Y2.default)(new Error("Please supply at least one path to remove"),"ERR_INVALID_PARAMS");s.forEach(o=>{if(o.path==="/")throw(0,Y2.default)(new Error("Cannot delete root"),"ERR_INVALID_PARAMS")});for(let o of s)await V8e(r,o.path,i)}return M(e)}var V8e=async(r,e,t)=>{let n=await Ur(r,e,t),i=await ka(r,n.mfsPath),s=i[i.length-1];i.pop();let o=i[i.length-1];if(!o)throw(0,Y2.default)(new Error(`${e} does not exist`),"ERR_NOT_FOUND");if(s.type==="directory"&&!t.recursive)throw(0,Y2.default)(new Error(`${e} is a directory, use -r to remove directories`),"ERR_WAS_DIR");let{cid:a}=await oj(r,{parentCid:o.cid,name:s.name,hashAlg:t.hashAlg,cidVersion:t.cidVersion,flush:t.flush,shardSplitThreshold:t.shardSplitThreshold});o.cid=a;let c=await Ji(r,i,t);await es(r,c,t)};var K8e=Qe.bind({ignoreUndefined:!0}),q8e=C("ipfs:mfs:touch"),cj={flush:!0,shardSplitThreshold:1e3,hashAlg:"sha2-256",cidVersion:0,recursive:!1};function z8e(r,e,t){let n=0;return(r.includes("x")||r.includes("X")&&(t||e&1||e&8||e&64))&&(n+=1),r.includes("w")&&(n+=2),r.includes("r")&&(n+=4),n}function $8e(r,e){let t=0;return r.includes("u")&&(t+=e<<6),r.includes("g")&&(t+=e<<3),r.includes("o")&&(t+=e),t}function H8e(r,e,t){return e.includes("t")&&(t+=parseInt("1000",8)),e.includes("s")&&(r.includes("u")&&(t+=parseInt("4000",8)),r.includes("g")&&(t+=parseInt("2000",8))),t}function G8e(r,e,t){e||(e=0);let n=r.match(/^(u?g?o?a?)(-?\+?=?)?(r?w?x?X?s?t?)$/);if(!n)throw new Error(`Invalid file mode: ${r}`);let[,i,s,o]=n;(i==="a"||!i)&&(i="ugo");let a=z8e(o,e,t);return a=$8e(i,a),a=H8e(i,o,a),s==="="?(i.includes("u")&&(e=e&parseInt("7077",8),e=e|a),i.includes("g")&&(e=e&parseInt("7707",8),e=e|a),i.includes("o")&&(e=e&parseInt("7770",8),e=e|a),e):s==="+"?a|e:s==="-"?a^e:e}function lj(r,e){if(r instanceof String||typeof r=="string"){let t=`${r}`;t.match(/^\d+$/g)?r=parseInt(t,8):r=0+t.split(",").reduce((n,i)=>G8e(i,n,e.isDirectory()),e.mode||0)}return r}function fj(r){async function e(t,n,i={}){let s=K8e(cj,i);q8e(`Fetching stats for ${t}`);let{cid:o,mfsDirectory:a,name:c}=await Ur(r,t,s);if(o.code!==at)throw(0,m0.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");if(s.recursive){let P=await we(async function*(){for await(let B of q6(o,r.repo.blocks)){if(B.type!=="file"&&B.type!=="directory")throw(0,m0.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");B.unixfs.mode=lj(n,B.unixfs);let q=Tn({Data:B.unixfs.marshal(),Links:B.node.Links});yield{path:B.path,content:q}}},B=>Yp(B,r.repo.blocks,{...s,pin:!1,dagBuilder:async function*(q,Y,re){for await(let ie of q)yield async function(){let Ce=ie.content,Ee=Xe(Ce),Oe=await I5(Ee,Y,re);if(!Ce.Data)throw(0,m0.default)(new Error(`${Oe} had no data`),"ERR_INVALID_NODE");let H=Je.unmarshal(Ce.Data);return{cid:Oe,size:Ee.length,path:ie.path,unixfs:H}}}}),B=>(0,uj.default)(B));if(!P)throw(0,m0.default)(new Error(`Could not chmod ${t}`),"ERR_COULD_NOT_CHMOD");await p0(r)(t,s),await d0(r)(`/ipfs/${P.cid}`,t,s);return}let l=await r.repo.blocks.get(o),f=vt(l);if(!f.Data)throw(0,m0.default)(new Error(`${o} had no data`),"ERR_INVALID_NODE");let h=Je.unmarshal(f.Data);h.mode=lj(n,h);let p=Xe({Data:h.marshal(),Links:f.Links}),d=s.hashAlg||cj.hashAlg,y=await(await r.hashers.getHasher(d)).digest(p),g=A.create(s.cidVersion,at,y);s.flush&&await r.repo.blocks.put(g,p);let w=await ka(r,a),b=w[w.length-1],S=A.decode(b.cid.bytes),_=await r.repo.blocks.get(S),I=vt(_),T=await Ks(r,{parent:I,name:c,cid:g,size:p.length,flush:s.flush,hashAlg:d,cidVersion:o.version,shardSplitThreshold:1/0});b.cid=T.cid;let x=await Ji(r,w,s);await es(r,x,s)}return M(e)}u();var j8e=Qe.bind({ignoreUndefined:!0}),W8e={};function hj(r){async function e(t,n={}){n=j8e(W8e,n);let{cid:i}=await Cu(r)(t,n);return i}return M(e)}u();var Y8e=Qe.bind({ignoreUndefined:!0}),Q8e={parents:!1,flush:!0,cidVersion:0,hashAlg:"sha2-256",shardSplitThreshold:1e3};function dj(r){async function e(t,n,i={}){let s=Y8e(Q8e,i);await d0(r)(t,n,s),await p0(r)(t,{...s,recursive:!0})}return M(e)}u();var bI=E(V(),1);var X8e=Qe.bind({ignoreUndefined:!0}),Z8e=C("ipfs:mfs:touch"),pj={flush:!0,shardSplitThreshold:1e3,cidVersion:0,hashAlg:"sha2-256"};function mj(r){async function e(t,n={}){let i=X8e(pj,n);i.mtime=i.mtime||new Date,Z8e(`Touching ${t} mtime: ${i.mtime}`);let{cid:s,mfsDirectory:o,name:a,exists:c}=await Ur(r,t,i),l=n.hashAlg||pj.hashAlg,f=await r.hashers.getHasher(l),h,p,d=i.cidVersion;if(c){if(s.code!==at)throw(0,bI.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");d=s.version;let I=await r.repo.blocks.get(s),T=vt(I);if(!T.Data)throw(0,bI.default)(new Error(`${t} had no data`),"ERR_INVALID_NODE");let x=Je.unmarshal(T.Data);x.mtime=i.mtime,h=Xe({Data:x.marshal(),Links:T.Links});let P=await f.digest(h);p=A.create(i.cidVersion,at,P),i.flush&&await r.repo.blocks.put(p,h)}else{let I=new Je({type:"file",mtime:i.mtime});h=Xe({Data:I.marshal(),Links:[]});let T=await f.digest(h);p=A.create(i.cidVersion,at,T),i.flush&&await r.repo.blocks.put(p,h)}let m=await ka(r,o),y=m[m.length-1],g=y.cid,w=await r.repo.blocks.get(g),b=vt(w),S=await Ks(r,{parent:b,name:a,cid:p,size:h.length,flush:i.flush,shardSplitThreshold:i.shardSplitThreshold,hashAlg:i.hashAlg,cidVersion:d});y.cid=S.cid;let _=await Ji(r,m,i);await es(r,_,i)}return M(e)}u();var vI=E(V(),1);var J8e=Qe.bind({ignoreUndefined:!0}),eEe={offset:0,length:1/0};function yj(r){function e(t,n={}){return n=J8e(eEe,n),{[Symbol.asyncIterator]:async function*(){let s=await Ur(r,t,n),o=await zn(s.mfsPath,r.repo.blocks);if(o.type!=="file")throw(0,vI.default)(new Error(`${t} was not a file`),"ERR_NOT_FILE");if(!o.content)throw(0,vI.default)(new Error(`Could not load content stream from ${t}`),"ERR_NO_CONTENT");for await(let a of o.content({offset:n.offset,length:n.length}))yield a}}}return M(e)}u();u();var _I=E(V(),1);var Q2=C("ipfs:mfs:utils:to-async-iterator");function gj(r){if(!r)throw(0,_I.default)(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");if((typeof r=="string"||r instanceof String)&&(Q2("Content was a string"),r=z(r.toString())),r.length)return Q2("Content was array-like"),{[Symbol.asyncIterator]:function*(){yield r}};if(r[Symbol.asyncIterator])return Q2("Content was an async iterator"),r;if(r[Symbol.iterator])return Q2("Content was an iterator"),r;if(globalThis.Blob&&r instanceof globalThis.Blob){Q2("Content was an HTML5 Blob");let e=0,t={next:()=>e>r.size?{done:!0}:new Promise((n,i)=>{let s=r.slice(e,im);e+=im;let o=new globalThis.FileReader,a=c=>{if(o.removeEventListener("loadend",a,!1),c.error)return i(c.error);n({done:!1,value:new Uint8Array(o.result)})};o.addEventListener("loadend",a),o.readAsArrayBuffer(s)})};return{[Symbol.asyncIterator]:()=>t}}throw(0,_I.default)(new Error(`Don't know how to convert ${r} into an async iterator`),"ERR_INVALID_PARAMS")}var Ma=E(V(),1);var Ej=E(vi(),1);var tEe=Qe.bind({ignoreUndefined:!0}),Ba=C("ipfs:mfs:write"),rEe={offset:0,length:1/0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",parents:!1,progress:(r,e)=>{},strategy:"trickle",flush:!0,leafType:"raw",shardSplitThreshold:1e3};function bj(r){async function e(t,n,i={}){let s=tEe(rEe,i),o,a,c;if(Ba("Reading source, destination and parent"),await G2().readLock(async()=>{o=await gj(n),a=await Ur(r,t,s),c=await Ur(r,a.mfsDirectory,s)})(),Ba("Read source, destination and parent"),!s.parents&&!c.exists)throw(0,Ma.default)(new Error("directory does not exist"),"ERR_NO_EXIST");if(o==null)throw(0,Ma.default)(new Error("could not create source"),"ERR_NO_SOURCE");if(a==null)throw(0,Ma.default)(new Error("could not create destination"),"ERR_NO_DESTINATION");if(!s.create&&!a.exists)throw(0,Ma.default)(new Error("file does not exist"),"ERR_NO_EXIST");if(a.entryType!=="file")throw(0,Ma.default)(new Error("not a file"),"ERR_NOT_A_FILE");return nEe(r,t,o,a,s)}return M(e)}var nEe=async(r,e,t,n,i)=>{let s=await iEe(r,t,n,i);await G2().writeLock(async()=>{let o=u0(e),a=o.pop();if(a==null)throw(0,Ma.default)(new Error("source does not exist"),"ERR_NO_EXIST");let c=!1;try{await Cu(r)(`/${o.join("/")}`,i),c=!0}catch(g){if(g.code!=="ERR_NOT_FOUND")throw g}c||await xh(r)(`/${o.join("/")}`,i);let l=await Ur(r,e,i),f=await ka(r,l.mfsDirectory),h=f[f.length-1];if(!h)throw(0,Ma.default)(new Error("directory does not exist"),"ERR_NO_EXIST");if(!h.type||!h.type.includes("directory"))throw(0,Ma.default)(new Error(`cannot write to ${h.name}: Not a directory`),"ERR_NOT_A_DIRECTORY");let p=await r.repo.blocks.get(h.cid),d=vt(p),m=await Ks(r,{parent:d,name:a,cid:s.cid,size:s.size,flush:i.flush,shardSplitThreshold:i.shardSplitThreshold,hashAlg:i.hashAlg,cidVersion:i.cidVersion});h.cid=m.cid;let y=await Ji(r,f,i);await es(r,y,i)})()},iEe=async(r,e,t,n)=>{t.exists?Ba(`Overwriting file ${t.cid} offset ${n.offset} length ${n.length}`):Ba(`Writing file offset ${n.offset} length ${n.length}`);let i=[];if(n.offset>0)if(t.unixfs){if(Ba(`Writing first ${n.offset} bytes of original file`),i.push(()=>t.content({offset:0,length:n.offset})),t.unixfs.fileSize()<n.offset){let f=n.offset-t.unixfs.fileSize();Ba(`Writing zeros for extra ${f} bytes`),i.push(wj(f))}}else Ba(`Writing zeros for first ${n.offset} bytes`),i.push(wj(n.offset));i.push(vj(e,n.length));let s=oEe(sEe(i),f=>{if(t.unixfs&&!n.truncate){let h=t.unixfs.fileSize();if(h>f)return Ba(`Writing last ${h-f} of ${h} bytes from original file starting at offset ${f}`),t.content({offset:f});Ba("Not writing last bytes from original file")}return{[Symbol.asyncIterator]:async function*(){}}}),o;n.mode!==void 0&&n.mode!==null?o=hc(n.mode):t&&t.unixfs&&(o=t.unixfs.mode);let a;n.mtime!=null?a=Ll(n.mtime):t&&t.unixfs&&(a=t.unixfs.mtime);let c=await r.hashers.getHasher(n.hashAlg),l=await(0,Ej.default)(Yp([{content:s,mode:o,mtime:a}],r.repo.blocks,{progress:n.progress,hasher:c,cidVersion:n.cidVersion,strategy:n.strategy,rawLeaves:n.rawLeaves,reduceSingleLeafToSelf:n.reduceSingleLeafToSelf,leafType:n.leafType}));if(!l)throw(0,Ma.default)(new Error(`cannot write to ${parent.name}`),"ERR_COULD_NOT_WRITE");return Ba(`Wrote ${l.cid}`),{cid:l.cid,size:l.size}},vj=(r,e)=>async function*(){let n=0;for await(let i of r){if(n+=i.length,n>e){yield i.slice(0,e-n);return}yield i}},wj=(r,e=im)=>{let t=new Uint8Array(e);async function*n(){for(;;)yield t.slice()}return vj(n(),r)},sEe=async function*(r){for(let e=0;e<r.length;e++)yield*r[e]()},oEe=async function*(r,e){let t=0;for await(let n of r)t+=n.length,yield n;for await(let n of e(t))t+=n.length,yield n};u();var Sj=E(Kn(),1),_j=r=>{let e={cid:r.cid,name:r.name,type:r.type==="directory"?"directory":"file",size:r.size};return(r.type==="file"||r.type==="directory")&&(e.mode=r.unixfs.mode,e.mtime=r.unixfs.mtime),e};function xj(r){async function*e(t,n={}){let i=await Ur(r,t,n),s=await zn(i.mfsPath,r.repo.blocks);if(s.type==="directory"){yield*(0,Sj.default)(s.content(n),_j);return}yield _j(s)}return M(e)}var aEe={stat:Cu},cEe={chmod:fj,cp:d0,flush:hj,mkdir:xh,mv:dj,rm:p0,touch:mj},Tj={write:bj,read:yj,ls:xj},Ij=({options:r,mfs:e,operations:t,lock:n})=>{Object.keys(t).forEach(i=>{e[i]=n(t[i](r))})},lEe={repoOwner:!0,repo:null};function uEe(r){let{repoOwner:e}=Object.assign({},lEe||{},r),t=G2(e),n=o=>t.readLock(o),i=o=>t.writeLock(o),s={};return Ij({options:r,mfs:s,operations:aEe,lock:n}),Ij({options:r,mfs:s,operations:cEe,lock:i}),Object.keys(Tj).forEach(o=>{s[o]=Tj[o](r)}),s}function Aj({repo:r,preload:e,hashers:t,options:n}){let i=uEe({repo:r,repoOwner:n.repoOwner!==!1,hashers:t}),s=o=>(...c)=>{let l=c.filter(f=>aB(f)||I4(f));if(l.length){let f=c[c.length-1];f&&f.preload!==!1&&l.forEach(h=>e(h))}return o(...c)};return{...i,chmod:i.chmod,cp:s(i.cp),mkdir:i.mkdir,stat:s(i.stat),rm:i.rm,read:s(i.read),touch:i.touch,write:i.write,mv:s(i.mv),flush:i.flush,ls:s(async function*(...o){for await(let a of i.ls(...o))yield{...a,size:a.size||0}})}}u();u();function Rj({keychain:r}){return M((t,n)=>r.exportKey(t,n))}u();var Cj="Ed25519",Pj=2048;function Dj({keychain:r}){return M((t,n={type:Cj,size:Pj})=>r.createKey(t,n.type||Cj,n.size||Pj))}u();function Oj({keychain:r}){return M((t,n,i)=>r.importKey(t,n,i))}u();function kj({keychain:r}){return M(t=>r.findKeyByName(t))}u();function Nj({keychain:r}){return M(()=>r.listKeys())}u();function Lj({keychain:r}){return M(async(t,n)=>{let i=await r.renameKey(t,n);return{was:t,now:i.name,id:i.id,overwrite:!1}})}u();function Bj({keychain:r}){return M(t=>r.removeKey(t))}var D5=class{constructor({keychain:e}){this.gen=Dj({keychain:e}),this.list=Nj({keychain:e}),this.rm=Bj({keychain:e}),this.rename=Lj({keychain:e}),this.export=Rj({keychain:e}),this.import=Oj({keychain:e}),this.info=kj({keychain:e})}};u();u();u();function Pi({repo:r,preload:e}){async function t(n,i={}){i.preload!==!1&&e(n);let s=await r.blocks.get(n,i);return vt(s)}return M(t)}function Mj({repo:r,preload:e}){let t=Pi({repo:r,preload:e});async function n(i,s={}){return(await t(i,s)).Data||new Uint8Array(0)}return M(n)}u();function SI(r,e=[]){for(let t in r){let n=r[t];if(t==="/"&&Object.keys(r).length===1)try{e.push({Name:"",Tsize:0,Hash:A.parse(n)});continue}catch{}let i=A.asCID(n);if(i){e.push({Name:"",Tsize:0,Hash:i});continue}Array.isArray(n)&&SI(n,e),n&&typeof n=="object"&&SI(n,e)}return e}function Uj({repo:r,codecs:e}){async function t(n,i={}){let s=await e.getCodec(n.code),o=await r.blocks.get(n,i),a=s.decode(o);switch(n.code){case An:return[];case at:return a.Links;case j1:case O_:return SI(a);default:throw new Error(`Cannot resolve links from codec ${n.code}`)}}return M(t)}u();function Fj({repo:r,preload:e}){async function t(n={}){let i;if(n.template)if(n.template==="unixfs-dir")i=new Je({type:"directory"}).marshal();else throw new Error("unknown template");let s=Xe({Data:i,Links:[]}),o=await $e.digest(s),a=A.createV0(o);return await r.blocks.put(a,s,{signal:n.signal}),n.preload!==!1&&e(a),a}return M(t)}u();function Ua({repo:r,preload:e}){async function t(n,i={}){let s=await r.gcLock.readLock();try{let o=Xe(n),a=await $e.digest(o),c=A.createV1(at,a);return await r.blocks.put(c,o,{signal:i.signal}),i.preload!==!1&&e(c),i.pin&&await r.pins.pinRecursively(c,{signal:i.signal}),c}finally{s()}}return M(t)}u();function Vj({repo:r,preload:e}){let t=Pi({repo:r,preload:e});async function n(i,s={}){let o=await t(i,s),c=Xe(o).length,l=o.Links.reduce((f,h)=>f+(h.Tsize||0),0);return{Hash:i,NumLinks:o.Links.length,BlockSize:c,LinksSize:c-(o.Data||[]).length,DataSize:(o.Data||[]).length,CumulativeSize:c+l}}return M(n)}u();u();function Kj({repo:r,preload:e}){let t=Pi({repo:r,preload:e}),n=Ua({repo:r,preload:e});async function i(s,o,a={}){let c=await t(s,a);return n({...c,Links:c.Links.concat([o])},a)}return M(i)}u();Mr();function qj({repo:r,preload:e}){let t=Pi({repo:r,preload:e}),n=Ua({repo:r,preload:e});async function i(s,o,a={}){let c=await t(s,a),l=Le([c.Data||[],o]);return n({...c,Data:l},a)}return M(i)}u();function zj({repo:r,preload:e}){let t=Pi({repo:r,preload:e}),n=Ua({repo:r,preload:e});async function i(s,o,a={}){let c=await t(s,a),l=(typeof o=="string"?o:o.Name)||"";return c.Links=c.Links.filter(f=>f.Name!==l),n(c,a)}return M(i)}u();function $j({repo:r,preload:e}){let t=Pi({repo:r,preload:e}),n=Ua({repo:r,preload:e});async function i(s,o,a={}){let c=await t(s,a);return n({...c,Data:o},a)}return M(i)}var O5=class{constructor({repo:e,preload:t}){this.addLink=Kj({repo:e,preload:t}),this.appendData=qj({repo:e,preload:t}),this.rmLink=zj({repo:e,preload:t}),this.setData=$j({repo:e,preload:t})}};var k5=class{constructor({repo:e,codecs:t,preload:n}){this.data=Mj({repo:e,preload:n}),this.get=Pi({repo:e,preload:n}),this.links=Uj({repo:e,codecs:t}),this.new=Fj({repo:e,preload:n}),this.put=Ua({repo:e,preload:n}),this.stat=Vj({repo:e,preload:n}),this.patch=new O5({repo:e,preload:n})}};u();u();var fEe=C("ipfs:repo:gc");function Hj({repo:r,hashers:e}){async function*t(n={}){let i=Date.now(),s;try{s=await l0({repo:r,hashers:e},n),await r.pins.pinRecursively(s),yield*r.gc()}finally{s&&await r.pins.unpin(s)}fEe(`Complete (${Date.now()-i}ms)`)}return M(t)}u();function N5({repo:r}){async function e(t={}){let n=await r.stat();return{numObjects:BigInt(n.numObjects.toString()),repoSize:BigInt(n.repoSize.toString()),repoPath:n.repoPath,version:`${n.version}`,storageMax:BigInt(n.storageMax.toString())}}return M(e)}u();u();function Gj({repo:r}){async function e(t={}){try{await r._checkInitialized(t)}catch(n){if([/Key not found in database \[\/version\]/,/ENOENT/,/repo is not initialized yet/].some(s=>s.test(n.message)))return 12;throw n}return r.version.get()}return M(e)}var L5=class{constructor({repo:e,hashers:t}){this.gc=Hj({repo:e,hashers:t}),this.stat=N5({repo:e}),this.version=Gj({repo:e}),this.setApiAddr=n=>e.apiAddr.set(n)}};u();u();var Wj=E(V(),1);function jj(r,e){let t;if(r.metrics?e.peer?t=r.metrics.forPeer(e.peer):e.proto?t=r.metrics.forProtocol(e.proto):t=r.metrics.getGlobal():t=void 0,!t)return{totalIn:BigInt(0),totalOut:BigInt(0),rateIn:0,rateOut:0};let n=t.getMovingAverages(),i=t.getSnapshot();return{totalIn:i.dataReceived,totalOut:i.dataSent,rateIn:n.dataReceived[6e4].movingAverage/60,rateOut:n.dataSent[6e4].movingAverage/60}}function Yj({network:r}){return M(async function*(t={}){let{libp2p:n}=await r.use(t);if(!t.poll){yield jj(n,t);return}let i=t.interval||1e3,s=-1;try{if(s=typeof i=="string"?ql(i)||-1:i,!s||s<0)throw new Error("invalid duration")}catch(a){throw(0,Wj.default)(a,"ERR_INVALID_POLL_INTERVAL")}let o;try{for(;;)yield jj(n,t),await new Promise(a=>{o=setTimeout(a,s)})}finally{clearTimeout(o)}})}var B5=class{constructor({repo:e,network:t}){this.repo=N5({repo:e}),this.bw=Yj({network:t}),this.bitswap=c6({network:t})}};u();u();u();u();var Z2=dEe;function dEe(r,e,t){if(!r)return t;var n,i;if(Array.isArray(e)&&(n=e.slice(0)),typeof e=="string"&&(n=e.split(".")),typeof e=="symbol"&&(n=[e]),!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");for(;n.length;)if(i=n.shift(),!r||(r=r[i],r===void 0))return t;return r}var yY=E(Li(),1),Lh=E(V(),1);u();u();u();var Zj=E(Li(),1),Jj=E(J2(),1);var mEe=(0,Zj.default)("ipfs:repo:migrator:migration-8");function eW(r){return r.child?eW(r.child):r}function yEe(r){try{let e=mt.decode(`b${r.toString().toLowerCase().slice(1)}`),t=A.decode(e).multihash.bytes,n=mt.encode(t).slice(1).toUpperCase();return new fe(`/${n}`,!1)}catch{return r}}function gEe(r){try{let e=mt.decode(`b${r.toString().toLowerCase().slice(1)}`),t=nr(e),n=mt.encode(A.createV1(An,t).bytes).slice(1);return new fe(`/${n.toUpperCase()}`,!1)}catch{return r}}async function Xj(r,e,t){let n=r.blocks;await n.open();let i=eW(n),s=await(0,Jj.default)(i.queryKeys({filters:[o=>t(o).toString()!==o.toString()]}));try{let o=0;for await(let a of i.query({})){let c=t(a.key);c.toString()!==a.key.toString()&&(o+=1,mEe(`Migrating Block from ${a.key} to ${c}`,await i.has(a.key)),await i.delete(a.key),await i.put(c,a.value),e(o/s*100,`Migrated Block from ${a.key} to ${c}`))}}finally{await n.close()}}var tW={version:8,description:"Transforms key names into base32 encoding and converts Block store to use bare multihashes encoded as base32",migrate:(r,e=()=>{})=>Xj(r,e,yEe),revert:(r,e=()=>{})=>Xj(r,e,gEe)};u();u();u();var Th=E(ca(),1),rW=Th.default.Reader,wEe=Th.default.Writer,YQe=Th.default.util,M5=Th.default.roots.default||(Th.default.roots.default={}),nW=M5.ipfs=(()=>{let r={};return r.pin=function(){let e={};return e.Set=function(){function t(n){if(n)for(var i=Object.keys(n),s=0;s<i.length;++s)n[i[s]]!=null&&(this[i[s]]=n[i[s]])}return t.prototype.version=0,t.prototype.fanout=0,t.prototype.seed=0,t.encode=function(i,s){return s||(s=wEe.create()),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&s.uint32(8).uint32(i.version),i.fanout!=null&&Object.hasOwnProperty.call(i,"fanout")&&s.uint32(16).uint32(i.fanout),i.seed!=null&&Object.hasOwnProperty.call(i,"seed")&&s.uint32(29).fixed32(i.seed),s},t.decode=function(i,s){i instanceof rW||(i=rW.create(i));for(var o=s===void 0?i.len:i.pos+s,a=new M5.ipfs.pin.Set;i.pos<o;){var c=i.uint32();switch(c>>>3){case 1:a.version=i.uint32();break;case 2:a.fanout=i.uint32();break;case 3:a.seed=i.fixed32();break;default:i.skipType(c&7);break}}return a},t.fromObject=function(i){if(i instanceof M5.ipfs.pin.Set)return i;var s=new M5.ipfs.pin.Set;return i.version!=null&&(s.version=i.version>>>0),i.fanout!=null&&(s.fanout=i.fanout>>>0),i.seed!=null&&(s.seed=i.seed>>>0),s},t.toObject=function(i,s){s||(s={});var o={};return s.defaults&&(o.version=0,o.fanout=0,o.seed=0),i.version!=null&&i.hasOwnProperty("version")&&(o.version=i.version),i.fanout!=null&&i.hasOwnProperty("fanout")&&(o.fanout=i.fanout),i.seed!=null&&i.hasOwnProperty("seed")&&(o.seed=i.seed),o},t.prototype.toJSON=function(){return this.constructor.toObject(this,Th.default.util.toJSONOptions)},t}(),e}(),r})();var aW=E(sW(),1),V5=E(fa(),1);u();var ey=new fe("/local/pins"),F5=256,oW=8192,TI=A.parse("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n"),Ih={direct:"direct",recursive:"recursive"};function II(r){return new fe(`/${mt.encode(r.multihash.bytes).toUpperCase().substring(1)}`)}Mr();var AI=nW.pin.Set;function EEe(r){let e=r.Data;if(!e)throw new Error("No data present");let t=V5.default.decode(e),n=V5.default.decode.bytes;if(n<=0)throw new Error("Invalid Set header length");if(n+t>e.length)throw new Error("Impossibly large set header length");let i=e.slice(n,t+n),s=AI.toObject(AI.decode(i),{defaults:!1,arrays:!0,longs:Number,objects:!1});if(s.version!==1)throw new Error(`Unsupported Set version: ${s.version}`);if(s.fanout>r.Links.length)throw new Error("Impossibly large fanout");return{header:s,data:e.slice(t+n)}}function bEe(r,e){let t=new Uint8Array(4);new DataView(t.buffer).setUint32(0,r,!0);let i=z(e.toString()),s=Le([t,i],t.byteLength+i.byteLength);return(0,aW.default)(K(s))}async function*cW(r,e){let t=EEe(e),n=0;for(let i of e.Links){if(n<t.header.fanout){let s=i.Hash;if(!TI.equals(s)){let o=await r.get(s),a=vt(o);yield*cW(r,a)}}else yield i.Hash;n++}}async function*ty(r,e,t){let n=e.Links.find(o=>o.Name===t);if(!n)throw new Error("No link found with name "+t);let i=await r.get(n.Hash),s=vt(i);yield*cW(r,s)}function vEe(r,e){return t(e,0);async function t(n,i){let s=AI.encode({version:1,fanout:F5,seed:i}).finish(),o=V5.default.encode(s.length),a=Le([o,s]),c=[];for(let f=0;f<F5;f++)c.push({Name:"",Tsize:1,Hash:TI});if(n.length<=oW){let f=n.map(d=>({link:{Name:"",Tsize:1,Hash:d.key},data:d.data||new Uint8Array})).sort((d,m)=>ah(d.link.Hash.bytes,m.link.Hash.bytes)),h=c.concat(f.map(d=>d.link));return{Data:Le([a,...f.map(d=>d.data)]),Links:h}}else{let f=n.reduce((p,d)=>{let m=bEe(i,d.key)%F5;return p[m]=m in p?p[m].concat([d]):[d],p},[]),h=0;for(let p of f){let d=await t(p,i+1);await l(d,h),h++}return{Data:a,Links:c}}async function l(f,h){let p=Xe(f),d=await $e.digest(p),m=A.createV0(d);await r.put(m,p);let y=f.Links.reduce((g,w)=>g+(w.Tsize||0),0)+p.length;c[h]={Name:"",Tsize:y,Hash:m}}}}async function RI(r,e,t){let n=await vEe(r,t.map(c=>({key:c}))),i=Xe(n),s=await $e.digest(i),o=A.createV0(s);await r.put(o,i);let a=n.Links.reduce((c,l)=>c+l.Tsize,0)+i.length;return{Name:e,Tsize:a,Hash:o}}var K5=E(J2(),1);async function SEe(r,e,t,n){if(!await e.has(ey))return;let i=await e.get(ey),s=A.decode(i),o=await r.get(s),a=vt(o),c=0,l=await(0,K5.default)(ty(r,a,Ih.recursive))+await(0,K5.default)(ty(r,a,Ih.direct));for await(let f of ty(r,a,Ih.recursive)){c++;let h={depth:1/0};f.version!==0&&(h.version=f.version),f.code!==at&&(h.codec=f.code),await t.put(II(f),co(h)),n(c/l*100,`Migrated recursive pin ${f}`)}for await(let f of ty(r,a,Ih.direct)){c++;let h={depth:0};f.version!==0&&(h.version=f.version),f.code!==at&&(h.codec=f.code),await t.put(II(f),co(h)),n(c/l*100,`Migrated direct pin ${f}`)}await r.delete(s),await e.delete(ey)}async function xEe(r,e,t,n){let i=[],s=[],o=0,a=await(0,K5.default)(t.queryKeys({}));for await(let{key:p,value:d}of t.query({})){o++;let m=jn(d),y=A.create(m.version||0,m.codec||at,nr(mt.decode("b"+p.toString().toLowerCase().split("/").pop())));m.depth===0?(n(o/a*100,`Reverted direct pin ${y}`),s.push(y)):(n(o/a*100,`Reverted recursive pin ${y}`),i.push(y))}n(100,"Updating pin root");let c={Links:[await RI(r,Ih.direct,s),await RI(r,Ih.recursive,i)]},l=Xe(c),f=await $e.digest(l),h=A.createV0(f);await r.put(h,l),await e.put(ey,h.bytes)}async function lW(r,e,t){let n=r.blocks,i=r.datastore,s=r.pins;await n.open(),await i.open(),await s.open();try{await t(n,i,s,e)}finally{await s.close(),await i.close(),await n.close()}}var uW={version:9,description:"Migrates pins to datastore",migrate:(r,e=()=>{})=>lW(r,e,SEe),revert:(r,e=()=>{})=>lW(r,e,xEe)};u();u();var fW=new fe("/config"),ry=new fe("/version");function ny(r){let e=r;for(;e.db||e.child;)if(e=e.db||e.child,e.type==="level-js"||e.constructor.name==="Level")return e}async function TEe(r,e,t){let n=await e(r);if(n)return n;let i=ny(t);return i?new Promise((s,o)=>{let a=i.store("readonly").get(r.toString());a.transaction.onabort=()=>{o(a.transaction.error)},a.transaction.oncomplete=()=>{s(Boolean(a.result))}}):!1}async function IEe(r,e,t,n){if(await t(r))return e(r);let i=ny(n);if(!i)throw En();return new Promise((s,o)=>{let a=i.store("readonly").get(r.toString());a.transaction.onabort=()=>{o(a.transaction.error)},a.transaction.oncomplete=()=>{if(a.result)return s(a.result);o(En())}})}function q5(r){let e=r.get.bind(r),t=r.has.bind(r);return r.get=n=>IEe(n,e,t,r),r.has=n=>TEe(n,t,r),r}function CI(r){return{...r,root:q5(r.root),datastore:q5(r.datastore),pins:q5(r.pins),keys:q5(r.keys)}}async function AEe(r,e,t=()=>{}){let n=ny(e);if(!n){t(`${r} did not need an upgrade`);return}t(`Upgrading ${r}`),await mW(n,(s,o)=>[{type:"del",key:s},{type:"put",key:z(s),value:o}])}async function REe(r,e,t=()=>{}){let n=ny(e);if(!n){t(`${r} did not need a downgrade`);return}t(`Downgrading ${r}`),await mW(n,(s,o)=>[{type:"del",key:s},{type:"put",key:K(s),value:o}])}function dW(r){return r.child?dW(r.child):r}async function hW(r,e,t){let n=Object.entries(r).map(([o,a])=>({key:o,backend:dW(a)})).filter(({key:o,backend:a})=>a.constructor.name==="LevelDatastore").map(({key:o,backend:a})=>({name:o,store:a}));e(0,`Migrating ${n.length} dbs`);let i=0,s=o=>{e(Math.round(i/n.length*100),o)};for(let{name:o,store:a}of n){await a.open();try{await t(o,a,s)}finally{i++,await a.close()}}e(100,`Migrated ${n.length} dbs`)}var pW={version:10,description:"Migrates datastore-level keys to binary",migrate:(r,e=()=>{})=>hW(r,e,AEe),revert:(r,e=()=>{})=>hW(r,e,REe)};function mW(r,e){function t(n,i){let s=r.store("readwrite"),o=s.transaction,a=0,c;o.onabort=()=>i(c||o.error||new Error("aborted by user")),o.oncomplete=()=>i();function l(){let f=n[a++],h=f.key,p;try{p=f.type==="del"?s.delete(h):s.put(f.value,h)}catch(d){c=d,o.abort();return}a<n.length&&(p.onsuccess=l)}l()}return new Promise((n,i)=>{let s=r.iterator(),o=c=>c;s._deserializeKey=s._deserializeValue=o,a();function a(){let c=(l,f,h)=>{if(l||f===void 0){let p=d=>{if(d){i(d);return}n()};s.end(p);return}t(e(f,h),a)};s.next(c)}})}u();var ku=new fe("/local/filesroot");async function CEe(r,e=()=>{}){if(e(100,"Migrating MFS root to repo datastore"),await r.root.open(),await r.datastore.open(),await r.root.has(ku)){let t=await r.root.get(ku);await r.datastore.put(ku,t),await r.root.delete(ku)}await r.datastore.close(),await r.root.close(),e(100,"Stored MFS root in repo datastore")}async function PEe(r,e=()=>{}){if(e(100,"Migrating MFS root to repo root datastore"),await r.root.open(),await r.datastore.open(),await r.datastore.has(ku)){let t=await r.datastore.get(ku);await r.root.put(ku,t),await r.datastore.delete(ku)}await r.datastore.close(),await r.root.close(),e(100,"Stored MFS root in repo root datastore")}var yW={version:11,description:"Store mfs root in the datastore",migrate:CEe,revert:PEe};u();var LI=E(ca(),1);u();var Ah=E(ca(),1),gW=Ah.default.Reader,DEe=Ah.default.Writer,OEe=Ah.default.util,z5=Ah.default.roots.default||(Ah.default.roots.default={}),PI=z5.Protocols=(()=>{function r(e){if(this.protocols=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.protocols=OEe.emptyArray,r.encode=function(t,n){if(n||(n=DEe.create()),t.protocols!=null&&t.protocols.length)for(var i=0;i<t.protocols.length;++i)n.uint32(10).string(t.protocols[i]);return n},r.decode=function(t,n){t instanceof gW||(t=gW.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new z5.Protocols;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.protocols&&s.protocols.length||(s.protocols=[]),s.protocols.push(t.string());break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof z5.Protocols)return t;var n=new z5.Protocols;if(t.protocols){if(!Array.isArray(t.protocols))throw TypeError(".Protocols.protocols: array expected");n.protocols=[];for(var i=0;i<t.protocols.length;++i)n.protocols[i]=String(t.protocols[i])}return n},r.toObject=function(t,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.protocols=[]),t.protocols&&t.protocols.length){i.protocols=[];for(var s=0;s<t.protocols.length;++s)i.protocols[s]=t.protocols[s]}return i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Ah.default.util.toJSONOptions)},r})();u();var Gc=E(ca(),1),y0=Gc.default.Reader,DI=Gc.default.Writer,_r=Gc.default.util,Ln=Gc.default.roots.default||(Gc.default.roots.default={}),OI=Ln.Addresses=(()=>{function r(e){if(this.addrs=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.addrs=_r.emptyArray,r.prototype.certifiedRecord=null,r.encode=function(t,n){if(n||(n=DI.create()),t.addrs!=null&&t.addrs.length)for(var i=0;i<t.addrs.length;++i)Ln.Addresses.Address.encode(t.addrs[i],n.uint32(10).fork()).ldelim();return t.certifiedRecord!=null&&Object.hasOwnProperty.call(t,"certifiedRecord")&&Ln.Addresses.CertifiedRecord.encode(t.certifiedRecord,n.uint32(18).fork()).ldelim(),n},r.decode=function(t,n){t instanceof y0||(t=y0.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Ln.Addresses;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.addrs&&s.addrs.length||(s.addrs=[]),s.addrs.push(Ln.Addresses.Address.decode(t,t.uint32()));break;case 2:s.certifiedRecord=Ln.Addresses.CertifiedRecord.decode(t,t.uint32());break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof Ln.Addresses)return t;var n=new Ln.Addresses;if(t.addrs){if(!Array.isArray(t.addrs))throw TypeError(".Addresses.addrs: array expected");n.addrs=[];for(var i=0;i<t.addrs.length;++i){if(typeof t.addrs[i]!="object")throw TypeError(".Addresses.addrs: object expected");n.addrs[i]=Ln.Addresses.Address.fromObject(t.addrs[i])}}if(t.certifiedRecord!=null){if(typeof t.certifiedRecord!="object")throw TypeError(".Addresses.certifiedRecord: object expected");n.certifiedRecord=Ln.Addresses.CertifiedRecord.fromObject(t.certifiedRecord)}return n},r.toObject=function(t,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.addrs=[]),n.defaults&&(i.certifiedRecord=null),t.addrs&&t.addrs.length){i.addrs=[];for(var s=0;s<t.addrs.length;++s)i.addrs[s]=Ln.Addresses.Address.toObject(t.addrs[s],n)}return t.certifiedRecord!=null&&t.hasOwnProperty("certifiedRecord")&&(i.certifiedRecord=Ln.Addresses.CertifiedRecord.toObject(t.certifiedRecord,n)),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Gc.default.util.toJSONOptions)},r.Address=function(){function e(n){if(n)for(var i=Object.keys(n),s=0;s<i.length;++s)n[i[s]]!=null&&(this[i[s]]=n[i[s]])}e.prototype.multiaddr=_r.newBuffer([]),e.prototype.isCertified=null;let t;return Object.defineProperty(e.prototype,"_isCertified",{get:_r.oneOfGetter(t=["isCertified"]),set:_r.oneOfSetter(t)}),e.encode=function(i,s){return s||(s=DI.create()),i.multiaddr!=null&&Object.hasOwnProperty.call(i,"multiaddr")&&s.uint32(10).bytes(i.multiaddr),i.isCertified!=null&&Object.hasOwnProperty.call(i,"isCertified")&&s.uint32(16).bool(i.isCertified),s},e.decode=function(i,s){i instanceof y0||(i=y0.create(i));for(var o=s===void 0?i.len:i.pos+s,a=new Ln.Addresses.Address;i.pos<o;){var c=i.uint32();switch(c>>>3){case 1:a.multiaddr=i.bytes();break;case 2:a.isCertified=i.bool();break;default:i.skipType(c&7);break}}return a},e.fromObject=function(i){if(i instanceof Ln.Addresses.Address)return i;var s=new Ln.Addresses.Address;return i.multiaddr!=null&&(typeof i.multiaddr=="string"?_r.base64.decode(i.multiaddr,s.multiaddr=_r.newBuffer(_r.base64.length(i.multiaddr)),0):i.multiaddr.length&&(s.multiaddr=i.multiaddr)),i.isCertified!=null&&(s.isCertified=Boolean(i.isCertified)),s},e.toObject=function(i,s){s||(s={});var o={};return s.defaults&&(s.bytes===String?o.multiaddr="":(o.multiaddr=[],s.bytes!==Array&&(o.multiaddr=_r.newBuffer(o.multiaddr)))),i.multiaddr!=null&&i.hasOwnProperty("multiaddr")&&(o.multiaddr=s.bytes===String?_r.base64.encode(i.multiaddr,0,i.multiaddr.length):s.bytes===Array?Array.prototype.slice.call(i.multiaddr):i.multiaddr),i.isCertified!=null&&i.hasOwnProperty("isCertified")&&(o.isCertified=i.isCertified,s.oneofs&&(o._isCertified="isCertified")),o},e.prototype.toJSON=function(){return this.constructor.toObject(this,Gc.default.util.toJSONOptions)},e}(),r.CertifiedRecord=function(){function e(t){if(t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}return e.prototype.seq=_r.Long?_r.Long.fromBits(0,0,!0):0,e.prototype.raw=_r.newBuffer([]),e.encode=function(n,i){return i||(i=DI.create()),n.seq!=null&&Object.hasOwnProperty.call(n,"seq")&&i.uint32(8).uint64(n.seq),n.raw!=null&&Object.hasOwnProperty.call(n,"raw")&&i.uint32(18).bytes(n.raw),i},e.decode=function(n,i){n instanceof y0||(n=y0.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Ln.Addresses.CertifiedRecord;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.seq=n.uint64();break;case 2:o.raw=n.bytes();break;default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof Ln.Addresses.CertifiedRecord)return n;var i=new Ln.Addresses.CertifiedRecord;return n.seq!=null&&(_r.Long?(i.seq=_r.Long.fromValue(n.seq)).unsigned=!0:typeof n.seq=="string"?i.seq=parseInt(n.seq,10):typeof n.seq=="number"?i.seq=n.seq:typeof n.seq=="object"&&(i.seq=new _r.LongBits(n.seq.low>>>0,n.seq.high>>>0).toNumber(!0))),n.raw!=null&&(typeof n.raw=="string"?_r.base64.decode(n.raw,i.raw=_r.newBuffer(_r.base64.length(n.raw)),0):n.raw.length&&(i.raw=n.raw)),i},e.toObject=function(n,i){i||(i={});var s={};if(i.defaults){if(_r.Long){var o=new _r.Long(0,0,!0);s.seq=i.longs===String?o.toString():i.longs===Number?o.toNumber():o}else s.seq=i.longs===String?"0":0;i.bytes===String?s.raw="":(s.raw=[],i.bytes!==Array&&(s.raw=_r.newBuffer(s.raw)))}return n.seq!=null&&n.hasOwnProperty("seq")&&(typeof n.seq=="number"?s.seq=i.longs===String?String(n.seq):n.seq:s.seq=i.longs===String?_r.Long.prototype.toString.call(n.seq):i.longs===Number?new _r.LongBits(n.seq.low>>>0,n.seq.high>>>0).toNumber(!0):n.seq),n.raw!=null&&n.hasOwnProperty("raw")&&(s.raw=i.bytes===String?_r.base64.encode(n.raw,0,n.raw.length):i.bytes===Array?Array.prototype.slice.call(n.raw):n.raw),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Gc.default.util.toJSONOptions)},e}(),r})();u();var jc=E(ca(),1),g0=jc.default.Reader,kI=jc.default.Writer,Wt=jc.default.util,fn=jc.default.roots.default||(jc.default.roots.default={}),NI=fn.Peer=(()=>{function r(t){if(this.addresses=[],this.protocols=[],this.metadata=[],t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}r.prototype.addresses=Wt.emptyArray,r.prototype.protocols=Wt.emptyArray,r.prototype.metadata=Wt.emptyArray,r.prototype.pubKey=null,r.prototype.peerRecordEnvelope=null;let e;return Object.defineProperty(r.prototype,"_pubKey",{get:Wt.oneOfGetter(e=["pubKey"]),set:Wt.oneOfSetter(e)}),Object.defineProperty(r.prototype,"_peerRecordEnvelope",{get:Wt.oneOfGetter(e=["peerRecordEnvelope"]),set:Wt.oneOfSetter(e)}),r.encode=function(n,i){if(i||(i=kI.create()),n.addresses!=null&&n.addresses.length)for(var s=0;s<n.addresses.length;++s)fn.Address.encode(n.addresses[s],i.uint32(10).fork()).ldelim();if(n.protocols!=null&&n.protocols.length)for(var s=0;s<n.protocols.length;++s)i.uint32(18).string(n.protocols[s]);if(n.metadata!=null&&n.metadata.length)for(var s=0;s<n.metadata.length;++s)fn.Metadata.encode(n.metadata[s],i.uint32(26).fork()).ldelim();return n.pubKey!=null&&Object.hasOwnProperty.call(n,"pubKey")&&i.uint32(34).bytes(n.pubKey),n.peerRecordEnvelope!=null&&Object.hasOwnProperty.call(n,"peerRecordEnvelope")&&i.uint32(42).bytes(n.peerRecordEnvelope),i},r.decode=function(n,i){n instanceof g0||(n=g0.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new fn.Peer;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.addresses&&o.addresses.length||(o.addresses=[]),o.addresses.push(fn.Address.decode(n,n.uint32()));break;case 2:o.protocols&&o.protocols.length||(o.protocols=[]),o.protocols.push(n.string());break;case 3:o.metadata&&o.metadata.length||(o.metadata=[]),o.metadata.push(fn.Metadata.decode(n,n.uint32()));break;case 4:o.pubKey=n.bytes();break;case 5:o.peerRecordEnvelope=n.bytes();break;default:n.skipType(a&7);break}}return o},r.fromObject=function(n){if(n instanceof fn.Peer)return n;var i=new fn.Peer;if(n.addresses){if(!Array.isArray(n.addresses))throw TypeError(".Peer.addresses: array expected");i.addresses=[];for(var s=0;s<n.addresses.length;++s){if(typeof n.addresses[s]!="object")throw TypeError(".Peer.addresses: object expected");i.addresses[s]=fn.Address.fromObject(n.addresses[s])}}if(n.protocols){if(!Array.isArray(n.protocols))throw TypeError(".Peer.protocols: array expected");i.protocols=[];for(var s=0;s<n.protocols.length;++s)i.protocols[s]=String(n.protocols[s])}if(n.metadata){if(!Array.isArray(n.metadata))throw TypeError(".Peer.metadata: array expected");i.metadata=[];for(var s=0;s<n.metadata.length;++s){if(typeof n.metadata[s]!="object")throw TypeError(".Peer.metadata: object expected");i.metadata[s]=fn.Metadata.fromObject(n.metadata[s])}}return n.pubKey!=null&&(typeof n.pubKey=="string"?Wt.base64.decode(n.pubKey,i.pubKey=Wt.newBuffer(Wt.base64.length(n.pubKey)),0):n.pubKey.length&&(i.pubKey=n.pubKey)),n.peerRecordEnvelope!=null&&(typeof n.peerRecordEnvelope=="string"?Wt.base64.decode(n.peerRecordEnvelope,i.peerRecordEnvelope=Wt.newBuffer(Wt.base64.length(n.peerRecordEnvelope)),0):n.peerRecordEnvelope.length&&(i.peerRecordEnvelope=n.peerRecordEnvelope)),i},r.toObject=function(n,i){i||(i={});var s={};if((i.arrays||i.defaults)&&(s.addresses=[],s.protocols=[],s.metadata=[]),n.addresses&&n.addresses.length){s.addresses=[];for(var o=0;o<n.addresses.length;++o)s.addresses[o]=fn.Address.toObject(n.addresses[o],i)}if(n.protocols&&n.protocols.length){s.protocols=[];for(var o=0;o<n.protocols.length;++o)s.protocols[o]=n.protocols[o]}if(n.metadata&&n.metadata.length){s.metadata=[];for(var o=0;o<n.metadata.length;++o)s.metadata[o]=fn.Metadata.toObject(n.metadata[o],i)}return n.pubKey!=null&&n.hasOwnProperty("pubKey")&&(s.pubKey=i.bytes===String?Wt.base64.encode(n.pubKey,0,n.pubKey.length):i.bytes===Array?Array.prototype.slice.call(n.pubKey):n.pubKey,i.oneofs&&(s._pubKey="pubKey")),n.peerRecordEnvelope!=null&&n.hasOwnProperty("peerRecordEnvelope")&&(s.peerRecordEnvelope=i.bytes===String?Wt.base64.encode(n.peerRecordEnvelope,0,n.peerRecordEnvelope.length):i.bytes===Array?Array.prototype.slice.call(n.peerRecordEnvelope):n.peerRecordEnvelope,i.oneofs&&(s._peerRecordEnvelope="peerRecordEnvelope")),s},r.prototype.toJSON=function(){return this.constructor.toObject(this,jc.default.util.toJSONOptions)},r})(),TXe=fn.Address=(()=>{function r(t){if(t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}r.prototype.multiaddr=Wt.newBuffer([]),r.prototype.isCertified=null;let e;return Object.defineProperty(r.prototype,"_isCertified",{get:Wt.oneOfGetter(e=["isCertified"]),set:Wt.oneOfSetter(e)}),r.encode=function(n,i){return i||(i=kI.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),n.isCertified!=null&&Object.hasOwnProperty.call(n,"isCertified")&&i.uint32(16).bool(n.isCertified),i},r.decode=function(n,i){n instanceof g0||(n=g0.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new fn.Address;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.multiaddr=n.bytes();break;case 2:o.isCertified=n.bool();break;default:n.skipType(a&7);break}}return o},r.fromObject=function(n){if(n instanceof fn.Address)return n;var i=new fn.Address;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?Wt.base64.decode(n.multiaddr,i.multiaddr=Wt.newBuffer(Wt.base64.length(n.multiaddr)),0):n.multiaddr.length&&(i.multiaddr=n.multiaddr)),n.isCertified!=null&&(i.isCertified=Boolean(n.isCertified)),i},r.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.multiaddr="":(s.multiaddr=[],i.bytes!==Array&&(s.multiaddr=Wt.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?Wt.base64.encode(n.multiaddr,0,n.multiaddr.length):i.bytes===Array?Array.prototype.slice.call(n.multiaddr):n.multiaddr),n.isCertified!=null&&n.hasOwnProperty("isCertified")&&(s.isCertified=n.isCertified,i.oneofs&&(s._isCertified="isCertified")),s},r.prototype.toJSON=function(){return this.constructor.toObject(this,jc.default.util.toJSONOptions)},r})(),IXe=fn.Metadata=(()=>{function r(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.key="",r.prototype.value=Wt.newBuffer([]),r.encode=function(t,n){return n||(n=kI.create()),t.key!=null&&Object.hasOwnProperty.call(t,"key")&&n.uint32(10).string(t.key),t.value!=null&&Object.hasOwnProperty.call(t,"value")&&n.uint32(18).bytes(t.value),n},r.decode=function(t,n){t instanceof g0||(t=g0.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new fn.Metadata;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.key=t.string();break;case 2:s.value=t.bytes();break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof fn.Metadata)return t;var n=new fn.Metadata;return t.key!=null&&(n.key=String(t.key)),t.value!=null&&(typeof t.value=="string"?Wt.base64.decode(t.value,n.value=Wt.newBuffer(Wt.base64.length(t.value)),0):t.value.length&&(n.value=t.value)),n},r.toObject=function(t,n){n||(n={});var i={};return n.defaults&&(i.key="",n.bytes===String?i.value="":(i.value=[],n.bytes!==Array&&(i.value=Wt.newBuffer(i.value)))),t.key!=null&&t.hasOwnProperty("key")&&(i.key=t.key),t.value!=null&&t.hasOwnProperty("value")&&(i.value=n.bytes===String?Wt.base64.encode(t.value,0,t.value.length):n.bytes===Array?Array.prototype.slice.call(t.value):t.value),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,jc.default.util.toJSONOptions)},r})();u();var Rh=E(ca(),1),wW=Rh.default.Reader,kEe=Rh.default.Writer,Sr=Rh.default.util,$5=Rh.default.roots.default||(Rh.default.roots.default={}),EW=$5.Envelope=(()=>{function r(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.publicKey=Sr.newBuffer([]),r.prototype.payloadType=Sr.newBuffer([]),r.prototype.payload=Sr.newBuffer([]),r.prototype.signature=Sr.newBuffer([]),r.encode=function(t,n){return n||(n=kEe.create()),t.publicKey!=null&&Object.hasOwnProperty.call(t,"publicKey")&&n.uint32(10).bytes(t.publicKey),t.payloadType!=null&&Object.hasOwnProperty.call(t,"payloadType")&&n.uint32(18).bytes(t.payloadType),t.payload!=null&&Object.hasOwnProperty.call(t,"payload")&&n.uint32(26).bytes(t.payload),t.signature!=null&&Object.hasOwnProperty.call(t,"signature")&&n.uint32(42).bytes(t.signature),n},r.decode=function(t,n){t instanceof wW||(t=wW.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new $5.Envelope;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.publicKey=t.bytes();break;case 2:s.payloadType=t.bytes();break;case 3:s.payload=t.bytes();break;case 5:s.signature=t.bytes();break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof $5.Envelope)return t;var n=new $5.Envelope;return t.publicKey!=null&&(typeof t.publicKey=="string"?Sr.base64.decode(t.publicKey,n.publicKey=Sr.newBuffer(Sr.base64.length(t.publicKey)),0):t.publicKey.length&&(n.publicKey=t.publicKey)),t.payloadType!=null&&(typeof t.payloadType=="string"?Sr.base64.decode(t.payloadType,n.payloadType=Sr.newBuffer(Sr.base64.length(t.payloadType)),0):t.payloadType.length&&(n.payloadType=t.payloadType)),t.payload!=null&&(typeof t.payload=="string"?Sr.base64.decode(t.payload,n.payload=Sr.newBuffer(Sr.base64.length(t.payload)),0):t.payload.length&&(n.payload=t.payload)),t.signature!=null&&(typeof t.signature=="string"?Sr.base64.decode(t.signature,n.signature=Sr.newBuffer(Sr.base64.length(t.signature)),0):t.signature.length&&(n.signature=t.signature)),n},r.toObject=function(t,n){n||(n={});var i={};return n.defaults&&(n.bytes===String?i.publicKey="":(i.publicKey=[],n.bytes!==Array&&(i.publicKey=Sr.newBuffer(i.publicKey))),n.bytes===String?i.payloadType="":(i.payloadType=[],n.bytes!==Array&&(i.payloadType=Sr.newBuffer(i.payloadType))),n.bytes===String?i.payload="":(i.payload=[],n.bytes!==Array&&(i.payload=Sr.newBuffer(i.payload))),n.bytes===String?i.signature="":(i.signature=[],n.bytes!==Array&&(i.signature=Sr.newBuffer(i.signature)))),t.publicKey!=null&&t.hasOwnProperty("publicKey")&&(i.publicKey=n.bytes===String?Sr.base64.encode(t.publicKey,0,t.publicKey.length):n.bytes===Array?Array.prototype.slice.call(t.publicKey):t.publicKey),t.payloadType!=null&&t.hasOwnProperty("payloadType")&&(i.payloadType=n.bytes===String?Sr.base64.encode(t.payloadType,0,t.payloadType.length):n.bytes===Array?Array.prototype.slice.call(t.payloadType):t.payloadType),t.payload!=null&&t.hasOwnProperty("payload")&&(i.payload=n.bytes===String?Sr.base64.encode(t.payload,0,t.payload.length):n.bytes===Array?Array.prototype.slice.call(t.payload):t.payload),t.signature!=null&&t.hasOwnProperty("signature")&&(i.signature=n.bytes===String?Sr.base64.encode(t.signature,0,t.signature.length):n.bytes===Array?Array.prototype.slice.call(t.signature):t.signature),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Rh.default.util.toJSONOptions)},r})();u();var Nu=E(ca(),1),H5=Nu.default.Reader,bW=Nu.default.Writer,Fr=Nu.default.util,No=Nu.default.roots.default||(Nu.default.roots.default={}),vW=No.PeerRecord=(()=>{function r(e){if(this.addresses=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.peerId=Fr.newBuffer([]),r.prototype.seq=Fr.Long?Fr.Long.fromBits(0,0,!0):0,r.prototype.addresses=Fr.emptyArray,r.encode=function(t,n){if(n||(n=bW.create()),t.peerId!=null&&Object.hasOwnProperty.call(t,"peerId")&&n.uint32(10).bytes(t.peerId),t.seq!=null&&Object.hasOwnProperty.call(t,"seq")&&n.uint32(16).uint64(t.seq),t.addresses!=null&&t.addresses.length)for(var i=0;i<t.addresses.length;++i)No.PeerRecord.AddressInfo.encode(t.addresses[i],n.uint32(26).fork()).ldelim();return n},r.decode=function(t,n){t instanceof H5||(t=H5.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new No.PeerRecord;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.peerId=t.bytes();break;case 2:s.seq=t.uint64();break;case 3:s.addresses&&s.addresses.length||(s.addresses=[]),s.addresses.push(No.PeerRecord.AddressInfo.decode(t,t.uint32()));break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof No.PeerRecord)return t;var n=new No.PeerRecord;if(t.peerId!=null&&(typeof t.peerId=="string"?Fr.base64.decode(t.peerId,n.peerId=Fr.newBuffer(Fr.base64.length(t.peerId)),0):t.peerId.length&&(n.peerId=t.peerId)),t.seq!=null&&(Fr.Long?(n.seq=Fr.Long.fromValue(t.seq)).unsigned=!0:typeof t.seq=="string"?n.seq=parseInt(t.seq,10):typeof t.seq=="number"?n.seq=t.seq:typeof t.seq=="object"&&(n.seq=new Fr.LongBits(t.seq.low>>>0,t.seq.high>>>0).toNumber(!0))),t.addresses){if(!Array.isArray(t.addresses))throw TypeError(".PeerRecord.addresses: array expected");n.addresses=[];for(var i=0;i<t.addresses.length;++i){if(typeof t.addresses[i]!="object")throw TypeError(".PeerRecord.addresses: object expected");n.addresses[i]=No.PeerRecord.AddressInfo.fromObject(t.addresses[i])}}return n},r.toObject=function(t,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.addresses=[]),n.defaults)if(n.bytes===String?i.peerId="":(i.peerId=[],n.bytes!==Array&&(i.peerId=Fr.newBuffer(i.peerId))),Fr.Long){var s=new Fr.Long(0,0,!0);i.seq=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.seq=n.longs===String?"0":0;if(t.peerId!=null&&t.hasOwnProperty("peerId")&&(i.peerId=n.bytes===String?Fr.base64.encode(t.peerId,0,t.peerId.length):n.bytes===Array?Array.prototype.slice.call(t.peerId):t.peerId),t.seq!=null&&t.hasOwnProperty("seq")&&(typeof t.seq=="number"?i.seq=n.longs===String?String(t.seq):t.seq:i.seq=n.longs===String?Fr.Long.prototype.toString.call(t.seq):n.longs===Number?new Fr.LongBits(t.seq.low>>>0,t.seq.high>>>0).toNumber(!0):t.seq),t.addresses&&t.addresses.length){i.addresses=[];for(var o=0;o<t.addresses.length;++o)i.addresses[o]=No.PeerRecord.AddressInfo.toObject(t.addresses[o],n)}return i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Nu.default.util.toJSONOptions)},r.AddressInfo=function(){function e(t){if(t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}return e.prototype.multiaddr=Fr.newBuffer([]),e.encode=function(n,i){return i||(i=bW.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),i},e.decode=function(n,i){n instanceof H5||(n=H5.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new No.PeerRecord.AddressInfo;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.multiaddr=n.bytes();break;default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof No.PeerRecord.AddressInfo)return n;var i=new No.PeerRecord.AddressInfo;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?Fr.base64.decode(n.multiaddr,i.multiaddr=Fr.newBuffer(Fr.base64.length(n.multiaddr)),0):n.multiaddr.length&&(i.multiaddr=n.multiaddr)),i},e.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.multiaddr="":(s.multiaddr=[],i.bytes!==Array&&(s.multiaddr=Fr.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?Fr.base64.encode(n.multiaddr,0,n.multiaddr.length):i.bytes===Array?Array.prototype.slice.call(n.multiaddr):n.multiaddr),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Nu.default.util.toJSONOptions)},e}(),r})();LI.default.util.Long=void 0;LI.default.configure();async function NEe(r,e=()=>{}){e(0,"Storing each peerstore key under a single datastore key"),await r.datastore.open();let t={},n=[];for await(let{key:i,value:s}of r.datastore.query({prefix:"/peers"})){n.push(i);let o=i.toString(),[a,c,l,f,h]=o.split("/");if(c==="peers"&&!!["protos","addrs","metadata","keys"].includes(l)&&!!f)if(t[f]=t[f]||{addresses:[],protocols:[],metadata:[]},l==="protos"){let p=PI.decode(s);t[f].protocols=p.protocols.sort()}else if(l==="addrs"){let p=OI.decode(s);t[f].addresses=p.addrs.sort((d,m)=>se(d.multiaddr).toString().localeCompare(se(m.multiaddr).toString())),p.certifiedRecord&&p.certifiedRecord.raw&&(t[f].peerRecordEnvelope=p.certifiedRecord.raw)}else l==="metadata"?t[f].metadata.push({key:h,value:s}):l==="keys"&&(t[f].pubKey=s)}e(33,"Read peer data from store");for(let i of n)await r.datastore.delete(i);e(66,"Removed existing peer data from store");for(let i of Object.keys(t)){let s=t[i];s.metadata=s.metadata.sort((a,c)=>a.key.localeCompare(c.key));let o=NI.encode(s).finish();await r.datastore.put(new fe(`/peers/${i}`),o)}await r.datastore.close(),e(100,"Stored each peerstore key under a single datastore key")}async function LEe(r,e=()=>{}){e(0,"Storing each peerstore key under a multiple datastore keys"),await r.datastore.open();let t={},n=[];for await(let{key:i,value:s}of r.datastore.query({prefix:"/peers"})){n.push(i);let o=i.toString(),[a,c,l]=o.split("/");t[l]=NI.decode(s)}e(33,"Read peer data from store");for(let i of n)await r.datastore.delete(i);e(66,"Removed existing peer data from store");for(let[i,s]of Object.entries(t)){if(s.protocols&&s.protocols.length>0&&await r.datastore.put(new fe(`/peers/protos/${i}`),PI.encode({protocols:s.protocols}).finish()),s.addresses&&s.addresses.length>0){let o=s.peerRecordEnvelope,a;if(o){let c=EW.decode(o),l=vW.decode(c.payload);a={raw:o,seq:l.seq}}await r.datastore.put(new fe(`/peers/addrs/${i}`),OI.encode({addrs:s.addresses,certifiedRecord:a}).finish())}if(s.metadata&&s.metadata.length>0)for(let{key:o,value:a}of s.metadata)await r.datastore.put(new fe(`/peers/metadata/${i}/${o}`),a);s.pubKey&&await r.datastore.put(new fe(`/peers/keys/${i}`),s.pubKey)}await r.datastore.close(),e(100,"Stored each peerstore key under multiple datastore keys")}var _W={version:12,description:"Store each peerstore peer under a single datastore key",migrate:NEe,revert:LEe};var Ch={description:"Empty migration.",migrate:()=>{},revert:()=>{},empty:!0},G5=[Object.assign({version:1},Ch),Object.assign({version:2},Ch),Object.assign({version:3},Ch),Object.assign({version:4},Ch),Object.assign({version:5},Ch),Object.assign({version:6},Ch),Object.assign({version:7},Ch),tW,uW,pW,yW,_W];u();u();var SW=E(Li(),1);var BI={};Kt(BI,{InvalidValueError:()=>b0,MissingRepoOptionsError:()=>Fa,NonReversibleMigrationError:()=>w0,NotInitializedRepoError:()=>Lu,RequiredParameterError:()=>E0});u();var w0=class extends Error{constructor(e){super(e),this.name="NonReversibleMigrationError",this.code=w0.code,this.message=e}};w0.code="ERR_NON_REVERSIBLE_MIGRATION";var Lu=class extends Error{constructor(e){super(e),this.name="NotInitializedRepoError",this.code=Lu.code,this.message=e}};Lu.code="ERR_NOT_INITIALIZED_REPO";var E0=class extends Error{constructor(e){super(e),this.name="RequiredParameterError",this.code=E0.code,this.message=e}};E0.code="ERR_REQUIRED_PARAMETER";var b0=class extends Error{constructor(e){super(e),this.name="InvalidValueError",this.code=b0.code,this.message=e}};b0.code="ERR_INVALID_VALUE";var Fa=class extends Error{constructor(e){super(e),this.name="MissingRepoOptionsError",this.code=Fa.code,this.message=e}};Fa.code="ERR_MISSING_REPO_OPTIONS";var MI=(0,SW.default)("ipfs:repo:migrator:repo:init");async function xW(r){if(!r)throw new Fa("Please pass repo options when trying to open a repo");let e=r.root;try{await e.open();let t=await e.has(ry),n=await e.has(fW);return!t||!n?(MI(`Version entry present: ${t}`),MI(`Config entry present: ${n}`),!1):!0}catch(t){return MI("While checking if repo is initialized error was thrown: "+t.message),!1}finally{if(e!==void 0)try{await e.close()}catch{}}}async function UI(r){if(!await xW(r))throw new Lu("Repo is not initialized!");let e=r.root;await e.open();try{return parseInt(K(await e.get(ry)))}finally{await e.close()}}async function iy(r,e){if(!e)throw new Fa("Please pass repo options when trying to open a repo");let t=e.root;await t.open(),await t.put(ry,z(String(r))),await t.close()}var TW=E(Li(),1),Lo=(0,TW.default)("ipfs:repo:migrator");function MEe(r){return r=r||G5,!Array.isArray(r)||r.length===0?0:r[r.length-1].version}async function IW(r,e,t,n,i={}){let s=i.ignoreLock??!1,o=i.onProgress,a=i.isDryRun??!1,c=i.migrations??G5;if(!r)throw new qs.RequiredParameterError("Path argument is required!");if(!t)throw new qs.RequiredParameterError("repoOptions argument is required!");if(!n)throw new qs.RequiredParameterError("toVersion argument is required!");if(!Number.isInteger(n)||n<=0)throw new qs.InvalidValueError("Version has to be positive integer!");e=CI(e);let l=await UI(e);if(l===n){Lo("Nothing to migrate.");return}if(l>n)throw new qs.InvalidValueError(`Current repo's version (${l}) is higher then toVersion (${n}), you probably wanted to revert it?`);RW(c,l,n);let f;!a&&!s&&(f=await t.repoLock.lock(r));try{for(let h of c){if(n!==void 0&&h.version>n)break;if(!(h.version<=l)){Lo(`Migrating version ${h.version}`);try{if(!a){let p=()=>{};o&&(p=(d,m)=>o(h.version,d.toFixed(2),m)),await h.migrate(e,p)}}catch(p){let d=h.version-1;throw Lo(`An exception was raised during execution of migration. Setting the repo's version to last successfully migrated version: ${d}`),await iy(d,e),new Error(`During migration to version ${h.version} exception was raised: ${p.stack||p.message||p}`)}Lo(`Migrating to version ${h.version} finished`)}}a||await iy(n||MEe(c),e),Lo("Repo successfully migrated",n!==void 0?`to version ${n}!`:"to latest version!")}finally{!a&&!s&&f&&await f.close()}}async function AW(r,e,t,n,i={}){let s=i.ignoreLock??!1,o=i.onProgress,a=i.isDryRun??!1,c=i.migrations??G5;if(!r)throw new qs.RequiredParameterError("Path argument is required!");if(!t)throw new qs.RequiredParameterError("repoOptions argument is required!");if(!n)throw new qs.RequiredParameterError("When reverting migrations, you have to specify to which version to revert!");if(!Number.isInteger(n)||n<=0)throw new qs.InvalidValueError("Version has to be positive integer!");e=CI(e);let l=await UI(e);if(l===n){Lo("Nothing to revert.");return}if(l<n)throw new qs.InvalidValueError(`Current repo's version (${l}) is lower then toVersion (${n}), you probably wanted to migrate it?`);RW(c,n,l,!0);let f;!a&&!s&&(f=await t.repoLock.lock(r)),Lo(`Reverting from version ${l} to ${n}`);try{let h=c.slice().reverse();for(let p of h){if(p.version<=n)break;if(!(p.version>l)){Lo(`Reverting migration version ${p.version}`);try{if(!a){let d=()=>{};o&&(d=(m,y)=>o(p.version,m.toFixed(2),y)),await p.revert(e,d)}}catch(d){let m=p.version;throw Lo(`An exception was raised during execution of migration. Setting the repo's version to last successfully reverted version: ${m}`),await iy(m,e),d.message=`During reversion to version ${p.version} exception was raised: ${d.message}`,d}Lo(`Reverting to version ${p.version} finished`)}}a||await iy(n,e),Lo(`All migrations successfully reverted to version ${n}!`)}finally{!a&&!s&&f&&await f.close()}}function RW(r,e,t,n=!1){let i=0;for(let s of r){if(s.version>t)break;if(s.version>e){if(n&&!s.revert)throw new qs.NonReversibleMigrationError(`It is not possible to revert to version ${e} because migration version ${s.version} is not reversible. Cancelling reversion.`);i++}}if(i!==t-e)throw new qs.InvalidValueError(`The ipfs-repo-migrations package does not have all migration to migrate from version ${e} to ${t}`)}var qs=BI;var gY=E(DW(),1);u();var LW=E(Li(),1);u();u();var Ph=class extends Error{constructor(e){super(e),this.name="LockExistsError",this.code=Ph.code}};Ph.code="ERR_LOCK_EXISTS";var ts=class extends Error{constructor(e){super(e),this.name="NotFoundError",this.code=ts.code}};ts.code="ERR_NOT_FOUND";var Dh=class extends Error{constructor(e){super(e),this.name="InvalidRepoVersionError",this.code=Dh.code}};Dh.code="ERR_INVALID_REPO_VERSION";var Oh="ERR_REPO_NOT_INITIALIZED",OW="ERR_REPO_ALREADY_OPEN",kW="ERR_REPO_ALREADY_CLOSED";async function W5(r,e,t){let n=await e(r);if(n)return n;let i=NW(t);return i?new Promise((s,o)=>{let a=i.store("readonly").get(r.toString());a.transaction.onabort=()=>{o(a.transaction.error)},a.transaction.oncomplete=()=>{s(Boolean(a.result))}}):!1}async function Y5(r,e,t,n){if(await t(r))return e(r);let i=NW(n);if(!i)throw new ts;return new Promise((s,o)=>{let a=i.store("readonly").get(r.toString());a.transaction.onabort=()=>{o(a.transaction.error)},a.transaction.oncomplete=()=>{if(a.result)return s(a.result);o(new ts)}})}function NW(r){let e=r;for(;e.db||e.child;)if(e=e.db||e.child,e.type==="level-js"||e.constructor.name==="Level")return e}var $Ee=(0,LW.default)("ipfs:repo:version"),FI=new fe("version");function BW(r){return{async exists(){return W5(FI,r.has.bind(r),r)},async get(){let e=await Y5(FI,r.get.bind(r),r.has.bind(r),r);return parseInt(K(e),10)},set(e){return r.put(FI,z(String(e)))},async check(e){let t=await this.get();return $Ee("comparing version: %s and %s",t,e),t===e||(t===6&&e===7||e===6&&t===7)}}}u();u();var HW=E(Hl(),1);u();var sy=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},VI=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},MW=r=>globalThis.DOMException===void 0?new VI(r):new DOMException(r),UW=r=>{let e=r.reason===void 0?MW("This operation was aborted."):r.reason;return e instanceof Error?e:MW(e)};function KI(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(UW(c)),c.addEventListener("abort",()=>{a(UW(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new sy(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function qI(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var kh=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Wc,oy=class{constructor(){Wc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&kh(this,Wc,"f")[this.size-1].priority>=t.priority){kh(this,Wc,"f").push(n);return}let i=qI(kh(this,Wc,"f"),n,(s,o)=>o.priority-s.priority);kh(this,Wc,"f").splice(i,0,n)}dequeue(){let e=kh(this,Wc,"f").shift();return e?.run}filter(e){return kh(this,Wc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return kh(this,Wc,"f").length}};Wc=new WeakMap;var Or=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Te=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Zr,cy,ly,Uu,t8,uy,Q5,Bo,ay,rs,X5,ns,fy,Mu,Z5,FW,VW,$W,KW,qW,zW,J5,zI,$I,r8,e8,HEe=new sy,HI=class extends Error{},Nh=class extends HW.default{constructor(e){var t,n,i,s;if(super(),Zr.add(this),cy.set(this,void 0),ly.set(this,void 0),Uu.set(this,0),t8.set(this,void 0),uy.set(this,void 0),Q5.set(this,0),Bo.set(this,void 0),ay.set(this,void 0),rs.set(this,void 0),X5.set(this,void 0),ns.set(this,0),fy.set(this,void 0),Mu.set(this,void 0),Z5.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:oy,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);Or(this,cy,e.carryoverConcurrencyCount,"f"),Or(this,ly,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Or(this,t8,e.intervalCap,"f"),Or(this,uy,e.interval,"f"),Or(this,rs,new e.queueClass,"f"),Or(this,X5,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Or(this,Z5,e.throwOnTimeout===!0,"f"),Or(this,Mu,e.autoStart===!1,"f")}get concurrency(){return Te(this,fy,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Or(this,fy,e,"f"),Te(this,Zr,"m",r8).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Or(this,ns,(a=Te(this,ns,"f"),a++,a),"f"),Or(this,Uu,(c=Te(this,Uu,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new HI("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):KI(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Te(this,Z5,"f"):t.throwOnTimeout)&&i(HEe)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Te(this,Zr,"m",$W).call(this)};Te(this,rs,"f").enqueue(s,t),Te(this,Zr,"m",J5).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Te(this,Mu,"f")?(Or(this,Mu,!1,"f"),Te(this,Zr,"m",r8).call(this),this):this}pause(){Or(this,Mu,!0,"f")}clear(){Or(this,rs,new(Te(this,X5,"f")),"f")}async onEmpty(){Te(this,rs,"f").size!==0&&await Te(this,Zr,"m",e8).call(this,"empty")}async onSizeLessThan(e){Te(this,rs,"f").size<e||await Te(this,Zr,"m",e8).call(this,"next",()=>Te(this,rs,"f").size<e)}async onIdle(){Te(this,ns,"f")===0&&Te(this,rs,"f").size===0||await Te(this,Zr,"m",e8).call(this,"idle")}get size(){return Te(this,rs,"f").size}sizeBy(e){return Te(this,rs,"f").filter(e).length}get pending(){return Te(this,ns,"f")}get isPaused(){return Te(this,Mu,"f")}};cy=new WeakMap,ly=new WeakMap,Uu=new WeakMap,t8=new WeakMap,uy=new WeakMap,Q5=new WeakMap,Bo=new WeakMap,ay=new WeakMap,rs=new WeakMap,X5=new WeakMap,ns=new WeakMap,fy=new WeakMap,Mu=new WeakMap,Z5=new WeakMap,Zr=new WeakSet,FW=function(){return Te(this,ly,"f")||Te(this,Uu,"f")<Te(this,t8,"f")},VW=function(){return Te(this,ns,"f")<Te(this,fy,"f")},$W=function(){var e;Or(this,ns,(e=Te(this,ns,"f"),e--,e),"f"),Te(this,Zr,"m",J5).call(this),this.emit("next")},KW=function(){this.emit("empty"),Te(this,ns,"f")===0&&this.emit("idle")},qW=function(){Te(this,Zr,"m",$I).call(this),Te(this,Zr,"m",zI).call(this),Or(this,ay,void 0,"f")},zW=function(){let e=Date.now();if(Te(this,Bo,"f")===void 0){let t=Te(this,Q5,"f")-e;if(t<0)Or(this,Uu,Te(this,cy,"f")?Te(this,ns,"f"):0,"f");else return Te(this,ay,"f")===void 0&&Or(this,ay,setTimeout(()=>{Te(this,Zr,"m",qW).call(this)},t),"f"),!0}return!1},J5=function(){if(Te(this,rs,"f").size===0)return Te(this,Bo,"f")&&clearInterval(Te(this,Bo,"f")),Or(this,Bo,void 0,"f"),Te(this,Zr,"m",KW).call(this),!1;if(!Te(this,Mu,"f")){let e=!Te(this,Zr,"a",zW);if(Te(this,Zr,"a",FW)&&Te(this,Zr,"a",VW)){let t=Te(this,rs,"f").dequeue();return t?(this.emit("active"),t(),e&&Te(this,Zr,"m",zI).call(this),!0):!1}}return!1},zI=function(){Te(this,ly,"f")||Te(this,Bo,"f")!==void 0||(Or(this,Bo,setInterval(()=>{Te(this,Zr,"m",$I).call(this)},Te(this,uy,"f")),"f"),Or(this,Q5,Date.now()+Te(this,uy,"f"),"f"))},$I=function(){Te(this,Uu,"f")===0&&Te(this,ns,"f")===0&&Te(this,Bo,"f")&&(clearInterval(Te(this,Bo,"f")),Or(this,Bo,void 0,"f")),Or(this,Uu,Te(this,cy,"f")?Te(this,ns,"f"):0,"f"),Te(this,Zr,"m",r8).call(this)},r8=function(){for(;Te(this,Zr,"m",J5).call(this););},e8=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var n8=E(V(),1);var GEe=Nh.default?Nh.default:Nh,GI=new fe("config");function GW(r){let e=new GEe({concurrency:1}),t={async getAll(s={}){let o=await Y5(GI,r.get.bind(r),r.has.bind(r),r);return JSON.parse(K(o))},async get(s,o={}){if(s==null)throw new ts(`Key ${s} does not exist in config`);let a=await this.getAll(o),c=Z2(a,s);if(c===void 0)throw new ts(`Key ${s} does not exist in config`);return c},set(s,o,a={}){if(typeof s!="string"&&!(s instanceof String))throw(0,n8.default)(new Error("Invalid key type: "+typeof s),"ERR_INVALID_KEY");if(o===void 0||o instanceof Uint8Array)throw(0,n8.default)(new Error("Invalid value type: "+typeof o),"ERR_INVALID_VALUE");return e.add(()=>n({key:s,value:o},a.signal))},replace(s,o={}){if(!s||s instanceof Uint8Array)throw(0,n8.default)(new Error("Invalid value type: "+typeof s),"ERR_INVALID_VALUE");return e.add(()=>n({key:void 0,value:s},o.signal))},async exists(){return W5(GI,r.has.bind(r),r)}};return t;async function n(s,o){if(o&&o.aborted)return;let a=s.key,c=s.value;if(a){let l=await t.getAll();return typeof l=="object"&&l!==null&&vr(l,a,c),i(l)}return i(c)}function i(s){let o=z(JSON.stringify(s,null,2));return r.put(GI,o)}}u();u();u();function hy(r){if(typeof r!="object"||r===null)return!1;let e=Object.getPrototypeOf(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)}function jI(r,e={}){if(!hy(r)&&!Array.isArray(r))throw new TypeError("Expected a plain object or array");let{deep:t,compare:n}=e,i=[],s=[],o=c=>{let l=i.indexOf(c);if(l!==-1)return s[l];let f=[];return i.push(c),s.push(f),f.push(...c.map(h=>Array.isArray(h)?o(h):hy(h)?a(h):h)),f},a=c=>{let l=i.indexOf(c);if(l!==-1)return s[l];let f={},h=Object.keys(c).sort(n);i.push(c),s.push(f);for(let p of h){let d=c[p],m;t&&Array.isArray(d)?m=o(d):m=t&&hy(d)?a(d):d,Object.defineProperty(f,p,{...Object.getOwnPropertyDescriptor(c,p),value:m})}return f};return Array.isArray(r)?t?o(r):r.slice():a(r)}var WI=new fe("datastore_spec");function jW(r){return{exists(){return r.has(WI)},async get(){let e=await r.get(WI);return JSON.parse(K(e))},async set(e){return r.put(WI,z(JSON.stringify(jI(e,{deep:!0}))))}}}u();var YI=new fe("api");function WW(r){return{async get(){let e=await r.get(YI);return e&&e.toString()},set(e){return r.put(YI,z(e.toString()))},delete(){return r.delete(YI)}}}u();var YW=E(Ai(),1);var QW=E(fi(),1);var XW=E(V(),1);function ZW(r){return{open(){return r.open()},close(){return r.close()},query(e,t){return r.query(e,t)},queryKeys(e,t){return r.queryKeys(e,t)},async get(e,t){let n=Fu(e);return n.isIdentity?Promise.resolve(n.digest):r.get(e,t)},async*getMany(e,t){for await(let n of e)yield this.get(n,t)},async put(e,t,n){let{isIdentity:i}=Fu(e);i||await r.put(e,t,n)},async*putMany(e,t){let n=ar({objectMode:!0});(globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.setImmediate||globalThis.setTimeout)(async()=>{try{await(0,QW.default)(r.putMany(async function*(){for await(let{key:s,value:o}of e)Fu(s).isIdentity||(yield{key:s,value:o}),n.push({key:s,value:o})}())),n.end()}catch(s){n.end(s)}}),yield*n},has(e,t){let{isIdentity:n}=Fu(e);return n?Promise.resolve(!0):r.has(e,t)},delete(e,t){let{isIdentity:n}=Fu(e);return n?Promise.resolve():r.delete(e,t)},deleteMany(e,t){return r.deleteMany((0,YW.default)(e,n=>!Fu(n).isIdentity),t)},batch(){let e=r.batch();return{put(t,n){let{isIdentity:i}=Fu(t);i||e.put(t,n)},delete(t){let{isIdentity:n}=Fu(t);n||e.delete(t)},commit:t=>e.commit(t)}}}}function Fu(r){let e=A.asCID(r);if(e==null)throw(0,XW.default)(new Error("Not a valid cid"),"ERR_INVALID_CID");return e.multihash.code!==on.code?{isIdentity:!1}:{isIdentity:!0,digest:e.multihash.digest}}u();u();var JW=E(Li(),1),eY=(0,JW.default)("ipfs:repo:lock:memory"),tY="repo.lock",dy={};async function jEe(r){let e=r+"/"+tY;if(eY("locking %s",e),dy[e]===!0)throw new Ph(`Lock already being held for file: ${e}`);return dy[e]=!0,{async close(){dy[e]&&delete dy[e]}}}async function WEe(r){let e=r+"/"+tY;return eY(`checking lock: ${e}`),Boolean(dy[e])}var i8={lock:jEe,locked:WEe};var rY={autoMigrate:!0,onMigrationProgress:()=>{},repoOwner:!0,repoLock:i8};u();var QI={Spec:{type:"mount",mounts:[{mountpoint:"/blocks",type:"measure",prefix:"flatfs.datastore",child:{type:"flatfs",path:"blocks",sync:!0,shardFunc:"/repo/flatfs/shard/v1/next-to-last/2"}},{mountpoint:"/",type:"measure",prefix:"leveldb.datastore",child:{type:"levelds",path:"datastore",compression:"none"}}]}};u();var sY=E(V(),1),oY=E(Li(),1),ZI=E(Oa(),1);u();var nY=E(V(),1);function py(r){let e=A.asCID(r);if(e==null)throw(0,nY.default)(new Error("Not a valid cid"),"ERR_INVALID_CID");let t=mt.encode(e.multihash.bytes);return new fe("/"+t.slice(1).toUpperCase(),!1)}function XI(r){return nr(mt.decode(`b${r.toString().toLowerCase().substring(1)}`))}u();var iY=E(Li(),1);var YEe=(0,iY.default)("ipfs:repo:utils:walk-dag");async function*v0(r,e,t,n){try{let i=await e.get(r,n),s=await t(r.code),o=i0({bytes:i,cid:r,codec:s});for(let[,a]of o.links())yield a,yield*v0(a,e,t,n)}catch(i){throw YEe("Could not walk DAG for CID",r.toString(),i),i}}u();var my=class extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction=="function")for(let[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return typeof t.expiry=="number"&&t.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){let n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield e)}for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield e)}}get(e){if(this.cache.has(e)){let t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){let t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){let i=typeof n=="number"&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;this.cache.has(e)?this.cache.set(e,{value:t,expiry:i}):this._set(e,{value:t,expiry:i})}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){let t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");let t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache){let[t,n]=e;this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}for(let e of this.oldCache){let[t,n]=e;this.cache.has(t)||this._deleteIfExpired(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){let n=e[t],[i,s]=n;this._deleteIfExpired(i,s)===!1&&(yield[i,s.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){let n=e[t],[i,s]=n;this.cache.has(i)||this._deleteIfExpired(i,s)===!1&&(yield[i,s.value])}}*entriesAscending(){for(let[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(let t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,i]of this.entriesAscending())e.call(t,i,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};var QEe=2048;function XEe(r){let e=`Invalid type '${r}', must be one of {direct, indirect, recursive, all}`;return(0,sY.default)(new Error(e),"ERR_INVALID_PIN_TYPE")}var s8=class{constructor({pinstore:e,blockstore:t,loadCodec:n}){this.pinstore=e,this.blockstore=t,this.loadCodec=n,this.log=(0,oY.default)("ipfs:repo:pin"),this.directPins=new Set,this.recursivePins=new Set}async pinDirectly(e,t={}){await this.blockstore.get(e,t);let n={depth:0};return e.version!==0&&(n.version=e.version),e.code!==at&&(n.codec=e.code),t.metadata&&(n.metadata=t.metadata),this.pinstore.put(py(e),co(n))}unpin(e,t){return this.pinstore.delete(py(e),t)}async pinRecursively(e,t={}){await this.fetchCompleteDag(e,t);let n={depth:1/0};e.version!==0&&(n.version=e.version),e.code!==at&&(n.codec=e.code),t.metadata&&(n.metadata=t.metadata),await this.pinstore.put(py(e),co(n))}async*directKeys(e){for await(let t of this.pinstore.query({filters:[n=>jn(n.value).depth===0]})){let n=jn(t.value),i=n.version||0,s=n.codec!=null?n.codec:at,o=XI(t.key);yield{cid:A.create(i,s,o),metadata:n.metadata}}}async*recursiveKeys(e){for await(let t of this.pinstore.query({filters:[n=>jn(n.value).depth===1/0]})){let n=jn(t.value),i=n.version||0,s=n.codec!=null?n.codec:at,o=XI(t.key);yield{cid:A.create(i,s,o),metadata:n.metadata}}}async*indirectKeys(e){for await(let{cid:t}of this.recursiveKeys())for await(let n of v0(t,this.blockstore,this.loadCodec,e)){let i=[yt.recursive];(await this.isPinnedWithType(n,i)).pinned||(yield n)}}async isPinnedWithType(e,t,n){Array.isArray(t)||(t=[t]);let i=t.includes(yt.all),s=t.includes(yt.direct),o=t.includes(yt.recursive),a=t.includes(yt.indirect);if(o||s||i){let f=await(0,ZI.default)(this.pinstore.query({prefix:py(e).toString(),filters:[h=>{if(i)return!0;let p=jn(h.value);return t.includes(p.depth===0?yt.direct:yt.recursive)}],limit:1}));if(f){let h=jn(f.value);return{cid:e,pinned:!0,reason:h.depth===0?yt.direct:yt.recursive,metadata:h.metadata}}}let c=this;async function*l(f,h){for await(let{cid:p}of h)for await(let d of v0(p,c.blockstore,c.loadCodec))if(d.equals(f)){yield p;return}}if(i||a){let f=await(0,ZI.default)(l(e,this.recursiveKeys()));if(f)return{cid:e,pinned:!0,reason:yt.indirect,parent:f}}return{cid:e,pinned:!1}}async fetchCompleteDag(e,t={}){let n=new my({maxSize:t.cidCacheMaxSize??QEe}),i=async(s,o)=>{if(n.has(s.toString()))return;n.set(s.toString(),!0);let a=await this.blockstore.get(s,o),c=await this.loadCodec(s.code),l=i0({bytes:a,cid:s,codec:c});await Promise.all([...l.links()].map(([,f])=>i(f,o)))};await i(e,t)}static checkPinType(e){if(typeof e!="string"||!Object.keys(yt).includes(e))throw XEe(e);return!0}};u();var cY=E(Kn(),1),lY=E(V(),1);function uY(r,e){return{open(){return e.open()},close(){return e.close()},query(t,n){return e.query(t,n)},queryKeys(t,n){return e.queryKeys(t,n)},async get(t,n){return e.get(t,n)},async*getMany(t,n){yield*e.getMany(t,n)},async put(t,n,i){await e.put(t,n,i)},async*putMany(t,n){yield*e.putMany(t,n)},has(t,n){return e.has(t,n)},async delete(t,n){return await aY(t,r),e.delete(t,n)},deleteMany(t,n){return e.deleteMany((0,cY.default)(t,async i=>(await aY(i,r),i)),n)},batch(){return e.batch()}}}async function aY(r,e){let{pinned:t,reason:n}=await e.isPinnedWithType(r,yt.all);if(t)throw(0,lY.default)(new Error(`pinned: ${n}`),"ERR_BLOCK_PINNED")}u();var fY=E(Li(),1);var hY=E(S6(),1);var JI=E(Bc(),1),o8=E(Kn(),1),dY=E(Ai(),1);var yy=(0,fY.default)("ipfs:repo:gc"),ZEe=En().code,JEe=256,ebe=new fe("/local/filesroot");function pY({gcLock:r,pins:e,blockstore:t,root:n,loadCodec:i}){async function*s(){let o=Date.now();yy("Creating set of marked blocks");let a=await r.writeLock();try{let c=await tbe({pins:e,blockstore:t,root:n,loadCodec:i}),l=t.queryKeys({});yield*rbe({blockstore:t},c,l),yy(`Complete (${Date.now()-o}ms)`)}finally{a()}}return s}async function tbe({pins:r,blockstore:e,loadCodec:t,root:n}){let i=async function*(){let a;try{a=await n.get(ebe)}catch(l){if(l.code===ZEe){yy("No blocks in MFS");return}throw l}let c=A.decode(a);yield c,yield*v0(c,e,t)}(),s=(0,JI.default)((0,o8.default)(r.recursiveKeys(),({cid:a})=>a),r.indirectKeys(),(0,o8.default)(r.directKeys(),({cid:a})=>a),i),o=new Set;for await(let a of(0,JI.default)(s,i))o.add(mt.encode(a.multihash.bytes));return o}async function*rbe({blockstore:r},e,t){let n=0,i=0;yield*we((0,hY.default)((0,o8.default)(t,async o=>async function(){n++;try{let c=mt.encode(o.multihash.bytes);if(e.has(c))return null;try{await r.delete(o),i++}catch(l){return{err:new Error(`Could not delete block with CID ${o}: ${l.message}`)}}return{cid:o}}catch(c){let l=`Could delete block with CID ${o}`;return yy(l,c),{err:new Error(l+`: ${c.message}`)}}}),JEe),o=>(0,dY.default)(o,Boolean)),yy(`Marked set has ${e.size} unique blocks. Blockstore has ${n} blocks. Deleted ${i} blocks.`)}var Di=(0,yY.default)("ipfs:repo"),nbe=Number.MAX_SAFE_INTEGER,ibe="repoAutoMigrate",eA=class{constructor(e,t,n,i){if(typeof e!="string")throw new Error("missing repo path");if(typeof t!="function")throw new Error("missing codec loader");this.options=Qe(rY,i),this.closed=!0,this.path=e,this.root=n.root,this.datastore=n.datastore,this.keys=n.keys;let s=n.blocks,o=n.pins;this.pins=new s8({pinstore:o,blockstore:s,loadCodec:t});let a=uY(this.pins,s);this.blocks=ZW(a),this.version=BW(this.root),this.config=GW(this.root),this.spec=jW(this.root),this.apiAddr=WW(this.root),this.gcLock=vh({name:e,singleProcess:this.options.repoOwner!==!1}),this.gc=pY({gcLock:this.gcLock,pins:this.pins,blockstore:this.blocks,root:this.root,loadCodec:t})}async init(e){Di("initializing at: %s",this.path),await this._openRoot(),await this.config.replace(sbe(e)),await this.spec.set(obe(e)),await this.version.set(12)}async isInitialized(){if(!this.closed)return!0;try{return await this._openRoot(),await this._checkInitialized(),await this.root.close(),!0}catch{return!1}}async open(){if(!this.closed)throw(0,Lh.default)(new Error("repo is already open"),OW);Di("opening at: %s",this.path);try{if(await this._openRoot(),await this._checkInitialized(),this._lockfile=await this._openLock(),Di("acquired repo.lock"),!await this.version.check(12))if(await this._isAutoMigrationEnabled())await this._migrate(12,{root:this.root,datastore:this.datastore,pins:this.pins.pinstore,blocks:this.pins.blockstore,keys:this.keys});else throw new Dh("Incompatible repo versions. Automatic migrations disabled. Please migrate the repo manually.");Di("creating datastore"),await this.datastore.open(),Di("creating blocks"),await this.blocks.open(),Di("creating keystore"),await this.keys.open(),Di("creating pins"),await this.pins.pinstore.open(),this.closed=!1,Di("all opened")}catch(e){if(this._lockfile)try{await this._closeLock(),this._lockfile=null}catch(t){Di("error removing lock",t)}throw e}}async _openRoot(){try{await this.root.open()}catch(e){if(e.message!=="Already open")throw e}}async _openLock(){let e=await this.options.repoLock.lock(this.path);if(typeof e.close!="function")throw(0,Lh.default)(new Error("Locks must have a close method"),"ERR_NO_CLOSE_FUNCTION");return e}_closeLock(){return this._lockfile&&this._lockfile.close()}async _checkInitialized(){Di("init check");let e;try{[e]=await Promise.all([this.config.exists(),this.spec.exists(),this.version.exists()])}catch(t){throw t.code==="ERR_NOT_FOUND"?(0,Lh.default)(new Error("repo is not initialized yet"),Oh,{path:this.path}):t}if(!e)throw(0,Lh.default)(new Error("repo is not initialized yet"),Oh,{path:this.path})}async close(){if(this.closed)throw(0,Lh.default)(new Error("repo is already closed"),kW);Di("closing at: %s",this.path);try{await this.apiAddr.delete()}catch(e){if(e.code!==Oh&&!e.message.startsWith("ENOENT"))throw e}await Promise.all([this.root,this.blocks,this.keys,this.datastore,this.pins.pinstore].map(e=>e&&e.close())),Di("unlocking"),this.closed=!0,await this._closeLock()}exists(){return this.version.exists()}async stat(){if(this.datastore&&this.keys){let[e,t,n,i,s]=await Promise.all([this._storageMaxStat(),this._blockStat(),this.version.get(),mY(this.datastore),mY(this.keys)]),o=t.size+i+s;return{repoPath:this.path,storageMax:e,version:n,numObjects:t.count,repoSize:o}}throw(0,Lh.default)(new Error("repo is not initialized yet"),Oh,{path:this.path})}async _isAutoMigrationEnabled(){if(this.options.autoMigrate!==void 0)return this.options.autoMigrate;let e;try{e=await this.config.get(ibe)}catch(t){if(t.code===ts.code)e=!0;else throw t}return e}async _migrate(e,t){return await this.version.get()>e?(Di(`reverting to version ${e}`),AW(this.path,t,this.options,e,{ignoreLock:!0,onProgress:this.options.onMigrationProgress})):(Di(`migrating to version ${e}`),IW(this.path,t,this.options,e,{ignoreLock:!0,onProgress:this.options.onMigrationProgress}))}async _storageMaxStat(){try{let e=await this.config.get("Datastore.StorageMax");return BigInt((0,gY.default)(e))}catch{return BigInt(nbe)}}async _blockStat(){let e=BigInt(0),t=BigInt(0);if(this.blocks)for await(let{key:n,value:i}of this.blocks.query({}))e+=BigInt(1),t+=BigInt(i.byteLength),t+=BigInt(n.bytes.byteLength);return{count:e,size:t}}};async function mY(r){let e=BigInt(0);for await(let t of r.query({}))e+=BigInt(t.value.byteLength),e+=BigInt(t.key.uint8Array().byteLength);return e}function wY(r,e,t,n){return new eA(r,e,t,n)}function sbe(r){return r.Datastore=Object.assign({},QI,Z2(r,"datastore")),r}function obe(r){let e={...QI.Spec,...Z2(r,"Datastore.Spec")};return{type:e.type,mounts:e.mounts.map(t=>({mountpoint:t.mountpoint,type:t.child.type,path:t.child.path,shardFunc:t.child.shardFunc}))}}u();var Uy=E(Ai(),1),SQ=E(Kn(),1),HA=E(Kp(),1),GA=E(gy(),1),xQ=E(_Q(),1),Yu=class extends Ri{constructor(e,t={}){super(),this.db=typeof e=="string"?new xQ.Level(e,{...t,keyEncoding:"utf8",valueEncoding:"view"}):e,this.opts={createIfMissing:!0,compression:!1,...t}}async open(){try{await this.db.open(this.opts)}catch(e){throw qi.dbOpenFailedError(e)}}async put(e,t){try{await this.db.put(e.toString(),t)}catch(n){throw qi.dbWriteFailedError(n)}}async get(e){let t;try{t=await this.db.get(e.toString())}catch(n){throw n.notFound?qi.notFoundError(n):qi.dbWriteFailedError(n)}return t}async has(e){try{await this.db.get(e.toString())}catch(t){if(t.notFound)return!1;throw t}return!0}async delete(e){try{await this.db.del(e.toString())}catch(t){throw qi.dbDeleteFailedError(t)}}close(){return this.db&&this.db.close()}batch(){let e=[];return{put:(t,n)=>{e.push({type:"put",key:t.toString(),value:n})},delete:t=>{e.push({type:"del",key:t.toString()})},commit:()=>this.db.batch(e)}}query(e){let t=this._query({values:!0,prefix:e.prefix});Array.isArray(e.filters)&&(t=e.filters.reduce((s,o)=>(0,Uy.default)(s,o),t)),Array.isArray(e.orders)&&(t=e.orders.reduce((s,o)=>(0,GA.default)(s,o),t));let{offset:n,limit:i}=e;if(n){let s=0;t=(0,Uy.default)(t,()=>s++>=n)}return i&&(t=(0,HA.default)(t,i)),t}queryKeys(e){let t=(0,SQ.default)(this._query({values:!1,prefix:e.prefix}),({key:s})=>s);Array.isArray(e.filters)&&(t=e.filters.reduce((s,o)=>(0,Uy.default)(s,o),t)),Array.isArray(e.orders)&&(t=e.orders.reduce((s,o)=>(0,GA.default)(s,o),t));let{offset:n,limit:i}=e;if(n){let s=0;t=(0,Uy.default)(t,()=>s++>=n)}return i&&(t=(0,HA.default)(t,i)),t}_query(e){let t={keys:!0,keyEncoding:"buffer",values:e.values};if(e.prefix!=null){let i=e.prefix.toString();t.gte=i,t.lt=i+"\xFF"}let n=this.db.iterator(t);if(n[Symbol.asyncIterator])return c7e(n);if(n.next!=null&&n.end!=null)return l7e(n);throw new Error("Level returned incompatible iterator")}};async function*c7e(r){for await(let[e,t]of r)yield{key:new fe(e,!1),value:t};await r.close()}function l7e(r){return{[Symbol.asyncIterator](){return{next:()=>new Promise((e,t)=>{r.next((n,i,s)=>{if(n)return t(n);if(i==null)return r.end(o=>{if(o)return t(o);e({done:!0,value:void 0})});e({done:!1,value:{key:new fe(i,!1),value:s}})})}),return:()=>new Promise((e,t)=>{r.end(n=>{if(n)return t(n);e({done:!0,value:void 0})})})}}}}u();var YA=E(fi(),1);var AQ=E(V(),1);u();var jA=E(fi(),1),Qh=E(Ai(),1),WA=E(Kp(),1),IQ=E(Ro(),1),TQ=(r,e)=>async function*(){yield*(await(0,IQ.default)(r)).sort(e)}(),za=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,n){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"))}async*putMany(e,t={}){for await(let{key:n,value:i}of e)await this.put(n,i,t),yield{key:n,value:i}}async*getMany(e,t={}){for await(let n of e)yield this.get(n,t)}async*deleteMany(e,t={}){for await(let n of e)await this.delete(n,t),yield n}batch(){let e=[],t=[];return{put(n,i){e.push({key:n,value:i})},delete(n){t.push(n)},commit:async n=>{await(0,jA.default)(this.putMany(e,n)),e=[],await(0,jA.default)(this.deleteMany(t,n)),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 n=this._all(e,t);if(e.prefix!=null&&(n=(0,Qh.default)(n,i=>i.key.toString().startsWith(e.prefix||""))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Qh.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>TQ(i,s),n)),e.offset!=null){let i=0;n=(0,Qh.default)(n,()=>i++>=(e.offset||0))}return e.limit!=null&&(n=(0,WA.default)(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(e.prefix!=null&&(n=(0,Qh.default)(n,i=>i.toString().startsWith(e.prefix||""))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Qh.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>TQ(i,s),n)),e.offset!=null){let i=0;n=(0,Qh.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,WA.default)(n,e.limit)),n}};function O0(r){let e=A.asCID(r);if(!e)throw(0,AQ.default)(new Error("Not a valid cid"),"ERR_INVALID_CID");return new fe("/"+mt.encode(e.multihash.bytes).slice(1).toUpperCase(),!1)}function Qu(r){return A.createV1(An,nr(mt.decode("b"+r.toString().slice(1).toLowerCase())))}function QA(r){let e=r.substring(0,1);if(e==="/")return QA(r.substring(1));let t;e.toLowerCase()==="b"?t=s=>mt.decode(s.toLowerCase()).subarray(2):e.toLowerCase()==="c"?t=s=>Hv.decode(s.toLowerCase()).subarray(2):e==="z"?t=s=>Ue.decode(s).subarray(2):e==="Q"?t=s=>Ue.decode("z"+s):t=s=>mt.decode("b"+s.toLowerCase()).subarray(2);let n;for(let s=1;s<r.length;s++)try{n=t(r.substring(0,s))}catch(o){if(o.message!=="Unexpected end of data")throw o}let i="/C";return n&&(i=`/${mt.encode(n).slice(1,-1).toUpperCase()||"C"}`),i}function u7e(r){return{...r,prefix:r.prefix?QA(r.prefix):void 0,filters:r.filters?r.filters.map(e=>t=>e({key:Qu(t.key),value:t.value})):void 0,orders:r.orders?r.orders.map(e=>(t,n)=>e({key:Qu(t.key),value:t.value},{key:Qu(n.key),value:n.value})):void 0}}function f7e(r){return{...r,prefix:r.prefix?QA(r.prefix):void 0,filters:r.filters?r.filters.map(e=>t=>e(Qu(t))):void 0,orders:r.orders?r.orders.map(e=>(t,n)=>e(Qu(t),Qu(n))):void 0}}var O8=class extends za{constructor(e){super(),this.child=e}open(){return this.child.open()}close(){return this.child.close()}async*query(e,t){for await(let{key:n,value:i}of this.child.query(u7e(e),t))yield{key:Qu(n),value:i}}async*queryKeys(e,t){for await(let n of this.child.queryKeys(f7e(e),t))yield Qu(n)}async get(e,t){return this.child.get(O0(e),t)}async*getMany(e,t){for await(let n of e)yield this.get(n,t)}async put(e,t,n){await this.child.put(O0(e),t,n)}async*putMany(e,t){let n=ar({objectMode:!0});(globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.setImmediate||globalThis.setTimeout)(async()=>{try{let s=this.child;await(0,YA.default)(this.child.putMany(async function*(){for await(let o of e){let a=O0(o.key);await s.has(a,t)||(yield{key:a,value:o.value}),n.push(o)}}())),n.end()}catch(s){n.end(s)}}),yield*n}has(e,t){return this.child.has(O0(e),t)}delete(e,t){return this.child.delete(O0(e),t)}deleteMany(e,t){let n=ar({objectMode:!0});return(0,YA.default)(this.child.deleteMany(async function*(){for await(let i of e)yield O0(i),n.push(i);n.end()}(),t)).catch(i=>{n.end(i)}),n}};function RQ(r,e,t){let n=t.path||"ipfs";return wY(n,i=>e.getCodec(i),{root:new Yu(n,{prefix:"",version:2}),blocks:new O8(new Yu(`${n}/blocks`,{prefix:"",version:2})),datastore:new Yu(`${n}/datastore`,{prefix:"",version:2}),keys:new Yu(`${n}/keys`,{prefix:"",version:2}),pins:new Yu(`${n}/pins`,{prefix:"",version:2})},{autoMigrate:t.autoMigrate,onMigrationProgress:t.onMigrationProgress||r,repoLock:i8})}u();var Ht=E(Zw(),1);var jce=E(V(),1);u();u();u();u();var DQ=E(V(),1);u();var CQ={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};u();var Fy;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.publicKey!=null)n.uint32(10),n.bytes(t.publicKey);else throw new Error('Protocol error: required field "publicKey" was not found in object');if(t.payloadType!=null)n.uint32(18),n.bytes(t.payloadType);else throw new Error('Protocol error: required field "payloadType" was not found in object');if(t.payload!=null)n.uint32(26),n.bytes(t.payload);else throw new Error('Protocol error: required field "payload" was not found in object');if(t.signature!=null)n.uint32(42),n.bytes(t.signature);else throw new Error('Protocol error: required field "signature" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.publicKey=t.bytes();break;case 2:i.payloadType=t.bytes();break;case 3:i.payload=t.bytes();break;case 5:i.signature=t.bytes();break;default:t.skipType(o&7);break}}if(i.publicKey==null)throw new Error('Protocol error: value for required field "publicKey" was not found in protobuf');if(i.payloadType==null)throw new Error('Protocol error: value for required field "payloadType" was not found in protobuf');if(i.payload==null)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');if(i.signature==null)throw new Error('Protocol error: value for required field "signature" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(Fy||(Fy={}));u();u();u();function k8(r){return r instanceof Uint8Array?{get(e){return r[e]},set(e,t){r[e]=t}}:{get(e){return r.get(e)},set(e,t){r.set(e,t)}}}var PQ=4294967296,as=class{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(e===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),t=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new as(n,t)}zzEncode(){let e=this.hi>>31,t=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new as(t,n)}toBytes(e,t=0){let n=k8(e);for(;this.hi>0;)n.set(t++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(t++,this.lo&127|128),this.lo=this.lo>>>7;n.set(t++,this.lo)}static fromBigInt(e){if(e===0n)return new as;let t=e<0;t&&(e=-e);let n=Number(e>>32n)|0,i=Number(e-(BigInt(n)<<32n))|0;return t&&(n=~n>>>0,i=~i>>>0,++i>PQ&&(i=0,++n>PQ&&(n=0))),new as(n,i)}static fromNumber(e){if(e===0)return new as;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new as(i,n)}static fromBytes(e,t=0){let n=k8(e),i=new as,s=0;if(e.length-t>4){for(;s<4;++s)if(i.lo=(i.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return i;if(i.lo=(i.lo|(n.get(t)&127)<<28)>>>0,i.hi=(i.hi|(n.get(t)&127)>>4)>>>0,n.get(t++)<128)return i;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.lo=(i.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return i}if(e.length-t>4){for(;s<5;++s)if(i.hi=(i.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return i}else if(t<e.byteLength)for(;s<5;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return i}throw RangeError("invalid varint encoding")}};np();var h7e=Math.pow(2,7),d7e=Math.pow(2,14),p7e=Math.pow(2,21),m7e=Math.pow(2,28),y7e=Math.pow(2,35),g7e=Math.pow(2,42),w7e=Math.pow(2,49),E7e=Math.pow(2,56),b7e=Math.pow(2,63),Vo={encodingLength(r){return r<h7e?1:r<d7e?2:r<p7e?3:r<m7e?4:r<y7e?5:r<g7e?6:r<w7e?7:r<E7e?8:r<b7e?9:10},encode(r,e,t=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=ho(Vo.encodingLength(r))),as.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return as.fromBytes(r,e).toNumber(!0)}};var v7e,Jr=class{constructor(e){let{peerId:t,payloadType:n,payload:i,signature:s}=e;this.peerId=t,this.payloadType=n,this.payload=i,this.signature=s}marshal(){if(this.peerId.publicKey==null)throw new Error("Missing public key");return this.marshaled==null&&(this.marshaled=Fy.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return ze(this.marshal(),e.marshal())}async validate(e){let t=OQ(e,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return await Ti(this.peerId.publicKey).verify(t.subarray(),this.signature)}};v7e=Jr;Jr.createFromProtobuf=async r=>{let e=Fy.decode(r),t=await ln(e.publicKey);return new Jr({peerId:t,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};Jr.seal=async(r,e)=>{if(e.privateKey==null)throw new Error("Missing private key");let t=r.domain,n=r.codec,i=r.marshal(),s=OQ(t,n,i),a=await(await kn(e.privateKey)).sign(s.subarray());return new Jr({peerId:e,payloadType:n,payload:i,signature:a})};Jr.openAndCertify=async(r,e)=>{let t=await Jr.createFromProtobuf(r);if(!await t.validate(e))throw(0,DQ.default)(new Error("envelope signature is not valid for the given domain"),CQ.ERR_SIGNATURE_NOT_VALID);return t};var OQ=(r,e,t)=>{let n=z(r),i=Vo.encode(n.byteLength),s=Vo.encode(e.length),o=Vo.encode(t.length);return new Mt(i,n,s,e,o,t)};u();u();function kQ(r,e){let t=(n,i)=>n.toString().localeCompare(i.toString());return r.length!==e.length?!1:(e.sort(t),r.sort(t).every((n,i)=>e[i].equals(n)))}u();var Vy;(function(r){let e;(function(n){let i;n.codec=()=>(i==null&&(i=Et((s,o,a={})=>{if(a.lengthDelimited!==!1&&o.fork(),s.multiaddr!=null)o.uint32(10),o.bytes(s.multiaddr);else throw new Error('Protocol error: required field "multiaddr" was not found in object');a.lengthDelimited!==!1&&o.ldelim()},(s,o)=>{let a={multiaddr:new Uint8Array(0)},c=o==null?s.len:s.pos+o;for(;s.pos<c;){let l=s.uint32();switch(l>>>3){case 1:a.multiaddr=s.bytes();break;default:s.skipType(l&7);break}}if(a.multiaddr==null)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return a})),i),n.encode=s=>wt(s,n.codec()),n.decode=s=>gt(s,n.codec())})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=Et((n,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),n.peerId!=null)i.uint32(10),i.bytes(n.peerId);else throw new Error('Protocol error: required field "peerId" was not found in object');if(n.seq!=null)i.uint32(16),i.uint64(n.seq);else throw new Error('Protocol error: required field "seq" was not found in object');if(n.addresses!=null)for(let o of n.addresses)i.uint32(26),r.AddressInfo.codec().encode(o,i);else throw new Error('Protocol error: required field "addresses" was not found in object');s.lengthDelimited!==!1&&i.ldelim()},(n,i)=>{let s={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=i==null?n.len:n.pos+i;for(;n.pos<o;){let a=n.uint32();switch(a>>>3){case 1:s.peerId=n.bytes();break;case 2:s.seq=n.uint64();break;case 3:s.addresses.push(r.AddressInfo.codec().decode(n,n.uint32()));break;default:n.skipType(a&7);break}}if(s.peerId==null)throw new Error('Protocol error: value for required field "peerId" was not found in protobuf');if(s.seq==null)throw new Error('Protocol error: value for required field "seq" was not found in protobuf');return s})),t),r.encode=n=>wt(n,r.codec()),r.decode=n=>gt(n,r.codec())})(Vy||(Vy={}));u();var NQ="libp2p-peer-record",LQ=Uint8Array.from([3,1]);var hn=class{constructor(e){this.domain=hn.DOMAIN,this.codec=hn.CODEC;let{peerId:t,multiaddrs:n,seqNumber:i}=e;this.peerId=t,this.multiaddrs=n??[],this.seqNumber=i??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=Vy.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this.marshaled}equals(e){return!(!(e instanceof hn)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!kQ(this.multiaddrs,e.multiaddrs))}};hn.createFromProtobuf=r=>{let e=Vy.decode(r),t=Ir(e.peerId),n=(e.addresses??[]).map(s=>se(s.multiaddr)),i=e.seq;return new hn({peerId:t,multiaddrs:n,seqNumber:i})};hn.DOMAIN=NQ;hn.CODEC=LQ;u();u();var N8=Symbol.for("@libp2p/topology");function BQ(r){return r!=null&&Boolean(r[N8])}var MQ=()=>{},XA=class{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??MQ,this.onDisconnect=e.onDisconnect??MQ}get[Symbol.toStringTag](){return N8.toString()}get[N8](){return!0}async setRegistrar(e){this.registrar=e}disconnect(e){this.onDisconnect(e)}};function k0(r){return new XA(r)}u();var Xh=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},rl,We=class extends EventTarget{constructor(){super(...arguments),rl.set(this,new Map)}listenerCount(e){let t=Xh(this,rl,"f").get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=Xh(this,rl,"f").get(e);i==null&&(i=[],Xh(this,rl,"f").set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=Xh(this,rl,"f").get(e);i!=null&&(i=i.filter(({callback:s})=>s!==t),Xh(this,rl,"f").set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=Xh(this,rl,"f").get(e.type);return n==null||(n=n.filter(({once:i})=>!i),Xh(this,rl,"f").set(e.type,n)),t}};rl=new WeakMap;var ZA=class extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}},ne=globalThis.CustomEvent??ZA;u();var L8=class{constructor(e,t,n){this.gossip=e,this.msgs=new Map,this.history=[],this.msgIdToStrFn=n;for(let i=0;i<t;i++)this.history[i]=[]}get size(){return this.msgs.size}put(e,t,n=!1){let{msgIdStr:i}=e;return this.msgs.has(i)?!1:(this.msgs.set(i,{message:t,validated:n,originatingPeers:new Set,iwantCounts:new Map}),this.history[0].push({...e,topic:t.topic}),!0)}observeDuplicate(e,t){let n=this.msgs.get(e);n&&!n.validated&&n.originatingPeers.add(t)}get(e){return this.msgs.get(this.msgIdToStrFn(e))?.message}getWithIWantCount(e,t){let n=this.msgs.get(e);if(!n)return null;let i=(n.iwantCounts.get(t)??0)+1;return n.iwantCounts.set(t,i),{msg:n.message,count:i}}getGossipIDs(e){let t=new Map;for(let n=0;n<this.gossip;n++)this.history[n].forEach(i=>{let s=this.msgs.get(i.msgIdStr);if(s&&s.validated&&e.has(i.topic)){let o=t.get(i.topic);o||(o=[],t.set(i.topic,o)),o.push(i.msgId)}});return t}validate(e){let t=this.msgs.get(e);if(!t)return null;let{message:n,originatingPeers:i}=t;return t.validated=!0,t.originatingPeers=new Set,{message:n,originatingPeers:i}}shift(){this.history[this.history.length-1].forEach(t=>{this.msgs.delete(t.msgIdStr)}),this.history.pop(),this.history.unshift([])}remove(e){let t=this.msgs.get(e);return t?(this.msgs.delete(e),t):null}};u();var gX=E(yX(),1),{RPC:N0}=gX.default;u();var fR="/floodsub/1.0.0",hR="/meshsub/1.0.0",dR="/meshsub/1.1.0";var wX="ERR_TOPIC_VALIDATOR_REJECT",EX="ERR_TOPIC_VALIDATOR_IGNORE";u();u();function Ga(r=[],e){return{subscriptions:[],messages:r,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}u();function ja(r){if(r.length<=1)return r;let e=()=>Math.floor(Math.random()*Math.floor(r.length));for(let t=0;t<r.length;t++){let n=e(),i=r[t];r[t]=r[n],r[n]=i}return r}u();function bX(r){return K(r,"base64")}u();u();var ed="StrictSign",L0="StrictNoSign";u();var vX;(function(r){r.StrictSign="StrictSign",r.StrictNoSign="StrictNoSign"})(vX||(vX={}));var ef;(function(r){r[r.Signing=0]="Signing",r[r.Anonymous=1]="Anonymous"})(ef||(ef={}));var Wa;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Wa||(Wa={}));var hi;(function(r){r.Error="error",r.Ignore="ignore",r.Reject="reject",r.Blacklisted="blacklisted"})(hi||(hi={}));var ei;(function(r){r.InvalidSignature="invalid_signature",r.InvalidSeqno="invalid_seqno",r.InvalidPeerId="invalid_peerid",r.SignaturePresent="signature_present",r.SeqnoPresent="seqno_present",r.FromPresent="from_present",r.TransformFailed="transform_failed"})(ei||(ei={}));var Gs;(function(r){r.duplicate="duplicate",r.invalid="invalid",r.valid="valid"})(Gs||(Gs={}));function pR(r){switch(r){case Wa.Ignore:return hi.Ignore;case Wa.Reject:return hi.Reject}}async function mR(r,e){switch(r){case ed:{if(!e)throw Error("Must provide PeerId");if(e.privateKey==null)throw Error("Cannot sign message, no private key present");if(e.publicKey==null)throw Error("Cannot sign message, no public key present");let t=await kn(e.privateKey);return{type:ef.Signing,author:e,key:e.publicKey,privateKey:t}}case L0:return{type:ef.Anonymous};default:throw new Error(`Unknown signature policy "${r}"`)}}u();u();u();var Xt="ERR_INVALID_PEER_SCORE_PARAMS";var Zt=E(V(),1),P7e={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:3600*1e3},D7e={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 _X(r={}){return{...P7e,...r,topics:r.topics?Object.entries(r.topics).reduce((e,[t,n])=>(e[t]=O7e(n),e),{}):{}}}function O7e(r={}){return{...D7e,...r}}function SX(r){for(let[e,t]of Object.entries(r.topics))try{k7e(t)}catch(n){throw(0,Zt.default)(new Error(`invalid score parameters for topic ${e}: ${n.message}`),Xt)}if(r.topicScoreCap<0)throw(0,Zt.default)(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),Xt);if(r.appSpecificScore===null||r.appSpecificScore===void 0)throw(0,Zt.default)(new Error("missing application specific score function"),Xt);if(r.IPColocationFactorWeight>0)throw(0,Zt.default)(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Xt);if(r.IPColocationFactorWeight!==0&&r.IPColocationFactorThreshold<1)throw(0,Zt.default)(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Xt);if(r.behaviourPenaltyWeight>0)throw(0,Zt.default)(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Xt);if(r.behaviourPenaltyWeight!==0&&(r.behaviourPenaltyDecay<=0||r.behaviourPenaltyDecay>=1))throw(0,Zt.default)(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Xt);if(r.decayInterval<1e3)throw(0,Zt.default)(new Error("invalid DecayInterval; must be at least 1s"),Xt);if(r.decayToZero<=0||r.decayToZero>=1)throw(0,Zt.default)(new Error("invalid DecayToZero; must be between 0 and 1"),Xt)}function k7e(r){if(r.topicWeight<0)throw(0,Zt.default)(new Error("invalid topic weight; must be >= 0"),Xt);if(r.timeInMeshQuantum===0)throw(0,Zt.default)(new Error("invalid TimeInMeshQuantum; must be non zero"),Xt);if(r.timeInMeshWeight<0)throw(0,Zt.default)(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Xt);if(r.timeInMeshWeight!==0&&r.timeInMeshQuantum<=0)throw(0,Zt.default)(new Error("invalid TimeInMeshQuantum; must be positive"),Xt);if(r.timeInMeshWeight!==0&&r.timeInMeshCap<=0)throw(0,Zt.default)(new Error("invalid TimeInMeshCap; must be positive"),Xt);if(r.firstMessageDeliveriesWeight<0)throw(0,Zt.default)(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Xt);if(r.firstMessageDeliveriesWeight!==0&&(r.firstMessageDeliveriesDecay<=0||r.firstMessageDeliveriesDecay>=1))throw(0,Zt.default)(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Xt);if(r.firstMessageDeliveriesWeight!==0&&r.firstMessageDeliveriesCap<=0)throw(0,Zt.default)(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Xt);if(r.meshMessageDeliveriesWeight>0)throw(0,Zt.default)(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Xt);if(r.meshMessageDeliveriesWeight!==0&&(r.meshMessageDeliveriesDecay<=0||r.meshMessageDeliveriesDecay>=1))throw(0,Zt.default)(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Xt);if(r.meshMessageDeliveriesWeight!==0&&r.meshMessageDeliveriesCap<=0)throw(0,Zt.default)(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Xt);if(r.meshMessageDeliveriesWeight!==0&&r.meshMessageDeliveriesThreshold<=0)throw(0,Zt.default)(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Xt);if(r.meshMessageDeliveriesWindow<0)throw(0,Zt.default)(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Xt);if(r.meshMessageDeliveriesWeight!==0&&r.meshMessageDeliveriesActivation<1e3)throw(0,Zt.default)(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Xt);if(r.meshFailurePenaltyWeight>0)throw(0,Zt.default)(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Xt);if(r.meshFailurePenaltyWeight!==0&&(r.meshFailurePenaltyDecay<=0||r.meshFailurePenaltyDecay>=1))throw(0,Zt.default)(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Xt);if(r.invalidMessageDeliveriesWeight>0)throw(0,Zt.default)(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Xt);if(r.invalidMessageDeliveriesDecay<=0||r.invalidMessageDeliveriesDecay>=1)throw(0,Zt.default)(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Xt)}u();var N7e=E(V(),1),L7e={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function xX(r={}){return{...L7e,...r}}u();u();function TX(r,e,t,n){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{let c=t.topics[o];if(c===void 0)return;let l=0;if(a.inMesh){let d=a.meshTime/c.timeInMeshQuantum;d>c.timeInMeshCap&&(d=c.timeInMeshCap),l+=d*c.timeInMeshWeight}let f=a.firstMessageDeliveries;if(f>c.firstMessageDeliveriesCap&&(f=c.firstMessageDeliveriesCap),l+=f*c.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries<c.meshMessageDeliveriesThreshold){let d=c.meshMessageDeliveriesThreshold-a.meshMessageDeliveries;l+=d*d*c.meshMessageDeliveriesWeight}l+=a.meshFailurePenalty*c.meshFailurePenaltyWeight,l+=a.invalidMessageDeliveries*a.invalidMessageDeliveries*c.invalidMessageDeliveriesWeight,i+=l*c.topicWeight}),t.topicScoreCap>0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(r)*t.appSpecificWeight,e.ips.forEach(o=>{if(t.IPColocationFactorWhitelist.has(o))return;let a=n.get(o),c=a?a.size:0;if(c>t.IPColocationFactorThreshold){let l=c-t.IPColocationFactorThreshold;i+=l*l*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){let o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}u();var RX=E(AX(),1),di;(function(r){r[r.unknown=0]="unknown",r[r.valid=1]="valid",r[r.invalid=2]="invalid",r[r.ignored=3]="ignored"})(di||(di={}));var U8=class{constructor(){this.records=new Map,this.queue=new RX.default}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:di.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);let n={msgId:e,expire:Date.now()+12e4};return this.queue.push(n),t}gc(){let e=Date.now(),t=this.queue.peekFront();for(;t&&t.expire<e;)this.records.delete(t.msgId),this.queue.shift(),t=this.queue.peekFront()}clear(){this.records.clear(),this.queue.clear()}};u();var pi=E(V(),1);u();function nl(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}function _n(r){return r!=null&&typeof r.init=="function"}var je=class{constructor(e={}){this.started=!1,e.peerId!=null&&this.setPeerId(e.peerId),e.addressManager!=null&&this.setAddressManager(e.addressManager),e.peerStore!=null&&this.setPeerStore(e.peerStore),e.upgrader!=null&&this.setUpgrader(e.upgrader),e.metrics!=null&&this.setMetrics(e.metrics),e.registrar!=null&&this.setRegistrar(e.registrar),e.connectionManager!=null&&this.setConnectionManager(e.connectionManager),e.transportManager!=null&&this.setTransportManager(e.transportManager),e.connectionGater!=null&&this.setConnectionGater(e.connectionGater),e.contentRouting!=null&&this.setContentRouting(e.contentRouting),e.peerRouting!=null&&this.setPeerRouting(e.peerRouting),e.datastore!=null&&this.setDatastore(e.datastore),e.connectionProtector!=null&&this.setConnectionProtector(e.connectionProtector),e.dht!=null&&this.setDHT(e.dht),e.pubsub!=null&&this.setPubSub(e.pubsub)}isStarted(){return this.started}async beforeStart(){await Promise.all(Object.values(this).filter(e=>nl(e)).map(async e=>{e.beforeStart!=null&&await e.beforeStart()}))}async start(){await Promise.all(Object.values(this).filter(e=>nl(e)).map(async e=>{await e.start()})),this.started=!0}async afterStart(){await Promise.all(Object.values(this).filter(e=>nl(e)).map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async beforeStop(){await Promise.all(Object.values(this).filter(e=>nl(e)).map(async e=>{e.beforeStop!=null&&await e.beforeStop()}))}async stop(){await Promise.all(Object.values(this).filter(e=>nl(e)).map(async e=>{await e.stop()})),this.started=!1}async afterStop(){await Promise.all(Object.values(this).filter(e=>nl(e)).map(async e=>{e.afterStop!=null&&await e.afterStop()}))}setPeerId(e){return this.peerId=e,e}getPeerId(){if(this.peerId==null)throw(0,pi.default)(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,_n(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,_n(e)&&e.init(this),e}getAddressManager(){if(this.addressManager==null)throw(0,pi.default)(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,_n(e)&&e.init(this),e}getPeerStore(){if(this.peerStore==null)throw(0,pi.default)(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,_n(e)&&e.init(this),e}getUpgrader(){if(this.upgrader==null)throw(0,pi.default)(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,_n(e)&&e.init(this),e}getRegistrar(){if(this.registrar==null)throw(0,pi.default)(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,_n(e)&&e.init(this),e}getConnectionManager(){if(this.connectionManager==null)throw(0,pi.default)(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,_n(e)&&e.init(this),e}getTransportManager(){if(this.transportManager==null)throw(0,pi.default)(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,_n(e)&&e.init(this),e}getConnectionGater(){if(this.connectionGater==null)throw(0,pi.default)(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,_n(e)&&e.init(this),e}getContentRouting(){if(this.contentRouting==null)throw(0,pi.default)(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,_n(e)&&e.init(this),e}getPeerRouting(){if(this.peerRouting==null)throw(0,pi.default)(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,_n(e)&&e.init(this),e}getDatastore(){if(this.datastore==null)throw(0,pi.default)(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,_n(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,_n(e)&&e.init(this),e}getDHT(){if(this.dht==null)throw(0,pi.default)(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,_n(e)&&e.init(this),e}getPubSub(){if(this.pubsub==null)throw(0,pi.default)(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,_n(e)&&e.init(this),e}getDialer(){if(this.dialer==null)throw(0,pi.default)(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}};var B0=C("libp2p:gossipsub:score"),F8=class{constructor(e,t,n){this.params=e,this.metrics=t,this.peerStats=new Map,this.peerIPs=new Map,this.scoreCache=new Map,this.deliveryRecords=new U8,this.components=new je,SX(e),this.scoreCacheValidityMs=n.scoreCacheValidityMs,this.computeScore=n.computeScore??TX}init(e){this.components=e}get size(){return this.peerStats.size}start(){if(this._backgroundInterval){B0("Peer score already running");return}this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),B0("started")}stop(){if(!this._backgroundInterval){B0("Peer score already stopped");return}clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),B0("stopped")}background(){this.refreshScores(),this.updateIPs(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([e,t])=>[e,t]))}refreshScores(){let e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach((n,i)=>{if(!n.connected){e>n.expire&&(this.removeIPs(i,n.ips),this.peerStats.delete(i),this.scoreCache.delete(i));return}Object.entries(n.topics).forEach(([s,o])=>{let a=this.params.topics[s];a!==void 0&&(o.firstMessageDeliveries*=a.firstMessageDeliveriesDecay,o.firstMessageDeliveries<t&&(o.firstMessageDeliveries=0),o.meshMessageDeliveries*=a.meshMessageDeliveriesDecay,o.meshMessageDeliveries<t&&(o.meshMessageDeliveries=0),o.meshFailurePenalty*=a.meshFailurePenaltyDecay,o.meshFailurePenalty<t&&(o.meshFailurePenalty=0),o.invalidMessageDeliveries*=a.invalidMessageDeliveriesDecay,o.invalidMessageDeliveries<t&&(o.invalidMessageDeliveries=0),o.inMesh&&(o.meshTime=e-o.graftTime,o.meshTime>a.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),n.behaviourPenalty*=this.params.behaviourPenaltyDecay,n.behaviourPenalty<t&&(n.behaviourPenalty=0)})}score(e){this.metrics?.scoreFnCalls.inc();let t=this.peerStats.get(e);if(!t)return 0;let n=Date.now(),i=this.scoreCache.get(e);if(i&&i.cacheUntil>n)return i.score;this.metrics?.scoreFnRuns.inc();let s=this.computeScore(e,t,this.params,this.peerIPs),o=n+this.scoreCacheValidityMs;return i?(this.metrics?.scoreCachedDelta.observe(Math.abs(s-i.score)),i.score=s,i.cacheUntil=o):this.scoreCache.set(e,{score:s,cacheUntil:o}),s}addPenalty(e,t,n){let i=this.peerStats.get(e);i&&(i.behaviourPenalty+=t,this.metrics?.onScorePenalty(n))}addPeer(e){let t={connected:!0,expire:0,topics:{},ips:[],behaviourPenalty:0};this.peerStats.set(e,t);let n=this.getIPs(e);this.setIPs(e,n,t.ips),t.ips=n}removePeer(e){let t=this.peerStats.get(e);if(!!t){if(this.score(e)>0){this.removeIPs(e,t.ips),this.peerStats.delete(e);return}Object.entries(t.topics).forEach(([n,i])=>{i.firstMessageDeliveries=0;let s=this.params.topics[n].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveries<s){let o=s-i.meshMessageDeliveries;i.meshFailurePenalty+=o*o}i.inMesh=!1,i.meshMessageDeliveriesActive=!1}),t.connected=!1,t.expire=Date.now()+this.params.retainScore}}graft(e,t){let n=this.peerStats.get(e);if(n){let i=this.getPtopicStats(n,t);i&&(i.inMesh=!0,i.graftTime=Date.now(),i.meshTime=0,i.meshMessageDeliveriesActive=!1)}}prune(e,t){let n=this.peerStats.get(e);if(n){let i=this.getPtopicStats(n,t);if(i){let s=this.params.topics[t].meshMessageDeliveriesThreshold;if(i.meshMessageDeliveriesActive&&i.meshMessageDeliveries<s){let o=s-i.meshMessageDeliveries;i.meshFailurePenalty+=o*o}i.meshMessageDeliveriesActive=!1,i.inMesh=!1}}}validateMessage(e){this.deliveryRecords.ensureRecord(e)}deliverMessage(e,t,n){this.markFirstMessageDelivery(e,n);let i=this.deliveryRecords.ensureRecord(t),s=Date.now();if(i.status!==di.unknown){B0("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,di[i.status]);return}i.status=di.valid,i.validated=s,i.peers.forEach(o=>{o!==e.toString()&&this.markDuplicateMessageDelivery(o,n)})}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,n,i){switch(i){case hi.Error:this.markInvalidMessageDelivery(e,n);return;case hi.Blacklisted:return}let s=this.deliveryRecords.ensureRecord(t);if(s.status!==di.unknown){B0("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,di[s.status]);return}if(i===hi.Ignore){s.status=di.ignored,s.peers.clear();return}s.status=di.invalid,this.markInvalidMessageDelivery(e,n),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,n)}),s.peers.clear()}duplicateMessage(e,t,n){let i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case di.unknown:i.peers.add(e);break;case di.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,n,i.validated);break;case di.invalid:this.markInvalidMessageDelivery(e,n);break;case di.ignored:break}}markInvalidMessageDelivery(e,t){let n=this.peerStats.get(e);if(n){let i=this.getPtopicStats(n,t);i&&(i.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){let n=this.peerStats.get(e);if(n){let i=this.getPtopicStats(n,t);if(i){let s=this.params.topics[t].firstMessageDeliveriesCap;i.firstMessageDeliveries=Math.min(s,i.firstMessageDeliveries+1),i.inMesh&&(s=this.params.topics[t].meshMessageDeliveriesCap,i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,n){let i=this.peerStats.get(e);if(i){let s=n!==void 0?Date.now():0,o=this.getPtopicStats(i,t);if(o&&o.inMesh){let a=this.params.topics[t];if(n!==void 0){let l=s-n,f=l>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,l,f),f)return}let c=a.meshMessageDeliveriesCap;o.meshMessageDeliveries=Math.min(c,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(pe(e)).map(t=>t.remoteAddr.toOptions().host)}setIPs(e,t,n){e:for(let i of t){for(let o of n)if(i===o)continue e;let s=this.peerIPs.get(i);s||(s=new Set,this.peerIPs.set(i,s)),s.add(e)}e:for(let i of n){for(let o of t)if(i===o)continue e;let s=this.peerIPs.get(i);!s||(s.delete(e),s.size||this.peerIPs.delete(i))}}removeIPs(e,t){t.forEach(n=>{let i=this.peerIPs.get(n);!i||(i.delete(e),i.size||this.peerIPs.delete(n))})}updateIPs(){this.peerStats.forEach((e,t)=>{let n=this.getIPs(t);this.setIPs(t,n,e.ips),e.ips=n})}getPtopicStats(e,t){let n=e.topics[t];return n!==void 0?n:this.params.topics[t]!==void 0?(n={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=n,n):null}};u();var V8=class{constructor(e,t,n){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=n,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){let n=Math.floor(Math.random()*t.length),i=t[n],s=this.msgIdToStrFn(i),o=this.promises.get(s);o||(o=new Map,this.promises.set(s,o));let a=Date.now();o.has(e)||(o.set(e,a+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(s)||this.requestMsByMsg.set(s,a)))}getBrokenPromises(){let e=Date.now(),t=new Map,n=0;return this.promises.forEach((i,s)=>{i.forEach((o,a)=>{o<e&&(t.set(a,(t.get(a)??0)+1),i.delete(a),n++)}),i.size||this.promises.delete(s)}),this.metrics?.iwantPromiseBroken.inc(n),t}deliverMessage(e){this.trackMessage(e);let t=this.promises.get(e);t&&(this.promises.delete(e),this.metrics&&(this.metrics.iwantPromiseResolved.inc(1),this.metrics.iwantPromiseResolvedPeers.inc(t.size)))}rejectMessage(e,t){switch(this.trackMessage(e),t){case hi.Error:return}this.promises.delete(e)}clear(){this.promises.clear()}prune(){let e=Date.now()-this.requestMsByMsgExpire;for(let[t,n]of this.requestMsByMsg.entries())if(n<e)this.requestMsByMsg.delete(t);else break}trackMessage(e){if(this.metrics){let t=this.requestMsByMsg.get(e);t!==void 0&&(this.metrics.iwantPromiseDeliveryTime.observe((Date.now()-t)/1e3),this.requestMsByMsg.delete(e))}}};u();var M0=class{constructor(e){this.entries=new Map,this.validityMs=e.validityMs}get size(){return this.entries.size}put(e,t){this.entries.set(e,{value:t,validUntilMs:Date.now()+this.validityMs})}prune(){let e=Date.now();for(let[t,n]of this.entries.entries())if(n.validUntilMs<e)this.entries.delete(t);else break}has(e){return this.entries.has(e)}get(e){let t=this.entries.get(e);return t&&t.validUntilMs>=Date.now()?t.value:void 0}clear(){this.entries.clear()}};u();var CX;(function(r){r.forward="forward",r.publish="publish"})(CX||(CX={}));var il;(function(r){r.Fanout="fanout",r.Random="random",r.Subscribed="subscribed",r.Outbound="outbound",r.NotEnough="not_enough",r.Opportunistic="opportunistic"})(il||(il={}));var td;(function(r){r.Dc="disconnected",r.BadScore="bad_score",r.Prune="prune",r.Unsub="unsubscribed",r.Excess="excess"})(td||(td={}));var F0;(function(r){r.GraftBackoff="graft_backoff",r.BrokenPromise="broken_promise",r.MessageDeficit="message_deficit",r.IPColocation="IP_colocation"})(F0||(F0={}));var V0;(function(r){r.LowScore="low_score",r.MaxIhave="max_ihave",r.MaxIasked="max_iasked"})(V0||(V0={}));var U0;(function(r){r.graylist="graylist",r.publish="publish",r.gossip="gossip",r.mesh="mesh"})(U0||(U0={}));function PX(r,e,t){return{protocolsEnabled:r.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:r.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:r.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:r.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEvents:r.gauge({name:"gossipsub_mesh_peer_inclusion_events_total",help:"Number of times we include peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),meshPeerChurnEvents:r.gauge({name:"gossipsub_peer_churn_events_total",help:"Number of times we remove peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),peersPerProtocol:r.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:r.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:r.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),asyncValidationResult:r.gauge({name:"gossipsub_async_validation_result_total",help:"Message validation result for each topic",labelNames:["topic","acceptance"]}),asyncValidationMcacheHit:r.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),rpcRecvBytes:r.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:r.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:r.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:r.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:r.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:r.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:r.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:r.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:r.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcRecvNotAccepted:r.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:r.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:r.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:r.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:r.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:r.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:r.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:r.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:r.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:r.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:r.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeers:r.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),msgPublishPeersByGroup:r.gauge({name:"gossipsub_msg_publish_peers_by_group",help:"Total count of peers (by group) that we publish a msg to",labelNames:["topic","peerGroup"]}),msgPublishBytes:r.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgForwardCount:r.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:r.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:r.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedStatus:r.gauge({name:"gossipsub_msg_received_status_total",help:"Tracks distribution of recv msgs by duplicate, invalid, valid",labelNames:["topic","status"]}),msgReceivedInvalid:r.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["topic","error"]}),duplicateMsgDeliveryDelay:r.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*t.maxMeshMessageDeliveriesWindowSec,.5*t.maxMeshMessageDeliveriesWindowSec,1*t.maxMeshMessageDeliveriesWindowSec,2*t.maxMeshMessageDeliveriesWindowSec,4*t.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:r.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),scoreFnCalls:r.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:r.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:r.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:r.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:r.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores",labelNames:["topic","p"]}),scoreWeights:r.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:r.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:r.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:r.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*t.behaviourPenaltyThreshold,.5*t.behaviourPenaltyThreshold,1*t.behaviourPenaltyThreshold,2*t.behaviourPenaltyThreshold,4*t.behaviourPenaltyThreshold]}),ihaveRcvIgnored:r.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:r.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:r.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:r.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:r.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:r.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:r.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedPeers:r.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:r.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantPromiseDeliveryTime:r.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*t.gossipPromiseExpireSec,1*t.gossipPromiseExpireSec,2*t.gossipPromiseExpireSec,4*t.gossipPromiseExpireSec]}),cacheSize:r.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:r.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),topicStrToLabel:e,toTopic(n){return this.topicStrToLabel.get(n)??n},onJoin(n){this.topicSubscriptionStatus.set({topicStr:n},1),this.meshPeerCounts.set({topicStr:n},0)},onLeave(n){this.topicSubscriptionStatus.set({topicStr:n},0),this.meshPeerCounts.set({topicStr:n},0)},onAddToMesh(n,i,s){let o=this.toTopic(n);this.meshPeerInclusionEvents.inc({topic:o,reason:i},s)},onRemoveFromMesh(n,i,s){let o=this.toTopic(n);this.meshPeerChurnEvents.inc({topic:o,reason:i},s)},onReportValidationMcacheHit(n){this.asyncValidationMcacheHit.inc({hit:n?"hit":"miss"})},onReportValidation(n,i){let s=this.toTopic(n);this.asyncValidationResult.inc({topic:s,acceptance:i})},onScorePenalty(n){this.scoringPenalties.inc({penalty:n},1)},onIhaveRcv(n,i,s){let o=this.toTopic(n);this.ihaveRcvMsgids.inc({topic:o},i),this.ihaveRcvNotSeenMsgids.inc({topic:o},s)},onIwantRcv(n,i){for(let[s,o]of n){let a=this.toTopic(s);this.iwantRcvMsgids.inc({topic:a},o)}this.iwantRcvDonthaveMsgids.inc(i)},onForwardMsg(n,i){let s=this.toTopic(n);this.msgForwardCount.inc({topic:s},1),this.msgForwardPeers.inc({topic:s},i)},onPublishMsg(n,i,s,o){let a=this.toTopic(n);this.msgPublishCount.inc({topic:a},1),this.msgPublishBytes.inc({topic:a},s*o),this.msgPublishPeers.inc({topic:a},s),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"direct"},i.direct),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"floodsub"},i.floodsub),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"mesh"},i.mesh),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"fanout"},i.fanout)},onMsgRecvPreValidation(n){let i=this.toTopic(n);this.msgReceivedPreValidation.inc({topic:i},1)},onMsgRecvResult(n,i){let s=this.toTopic(n);this.msgReceivedStatus.inc({topic:s,status:i})},onMsgRecvInvalid(n,i){let s=this.toTopic(n),o=i.reason===hi.Error?i.error:i.reason;this.msgReceivedInvalid.inc({topic:s,error:o},1)},onDuplicateMsgDelivery(n,i,s){if(this.duplicateMsgDeliveryDelay.observe(i/1e3),s){let o=this.toTopic(n);this.duplicateMsgLateDelivery.inc({topic:o},1)}},onRpcRecv(n,i){this.rpcRecvBytes.inc(i),this.rpcRecvCount.inc(1),n.subscriptions&&this.rpcRecvSubscription.inc(n.subscriptions.length),n.messages&&this.rpcRecvMessage.inc(n.messages.length),n.control&&(this.rpcRecvControl.inc(1),n.control.ihave&&this.rpcRecvIHave.inc(n.control.ihave.length),n.control.iwant&&this.rpcRecvIWant.inc(n.control.iwant.length),n.control.graft&&this.rpcRecvGraft.inc(n.control.graft.length),n.control.prune&&this.rpcRecvPrune.inc(n.control.prune.length))},onRpcSent(n,i){if(this.rpcSentBytes.inc(i),this.rpcSentCount.inc(1),n.subscriptions&&this.rpcSentSubscription.inc(n.subscriptions.length),n.messages&&this.rpcSentMessage.inc(n.messages.length),n.control){let s=n.control.ihave?.length??0,o=n.control.iwant?.length??0,a=n.control.graft?.length??0,c=n.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),c>0&&this.rpcSentPrune.inc(c),(s>0||o>0||a>0||c>0)&&this.rpcSentControl.inc(1)}},registerScores(n,i){let s=0,o=0,a=0,c=0;for(let l of n)l>=i.graylistThreshold&&s++,l>=i.publishThreshold&&o++,l>=i.gossipThreshold&&a++,l>=0&&c++;this.peersByScoreThreshold.set({threshold:U0.graylist},s),this.peersByScoreThreshold.set({threshold:U0.publish},o),this.peersByScoreThreshold.set({threshold:U0.gossip},a),this.peersByScoreThreshold.set({threshold:U0.mesh},c),this.score.set(n)},registerScoreWeights(n){for(let[i,s]of n.byTopic)this.scoreWeights.set({topic:i,p:"p1"},s.p1w),this.scoreWeights.set({topic:i,p:"p2"},s.p2w),this.scoreWeights.set({topic:i,p:"p3"},s.p3w),this.scoreWeights.set({topic:i,p:"p3b"},s.p3bw),this.scoreWeights.set({topic:i,p:"p4"},s.p4w);this.scoreWeights.set({p:"p5"},n.p5w),this.scoreWeights.set({p:"p6"},n.p6w),this.scoreWeights.set({p:"p7"},n.p7w)},registerScorePerMesh(n,i){let s=new Map;n.forEach((o,a)=>{let c=this.topicStrToLabel.get(a)??"unknown",l=s.get(c);l||(l=new Set,s.set(c,l)),o.forEach(f=>l?.add(f))});for(let[o,a]of s){let c=[];a.forEach(l=>{c.push(i.get(l)??0)}),this.scorePerMesh.set({topic:o},c)}}}}u();Mr();u();u();u();var art=E(vp(),1),M7e=E(ft(),1);u();var F7e=E(V(),1);u();var OX=E(DS(),1),kX=E(sr(),1),NX=E(V(),1),DX={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function Hy(r,e,t,n,i){if(i!=="sha1"&&i!=="sha2-256"&&i!=="sha2-512"){let a=Object.keys(DX).join(" / ");throw(0,NX.default)(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}let s=DX[i],o=(0,OX.default)(r,e,t,n,s);return kX.default.encode64(o,null)}var LX=z("libp2p-pubsub:");async function BX(r,e,t,n){switch(r.type){case ef.Signing:{let i={from:r.author.toBytes(),data:n,seqno:Si(8),topic:e,signature:void 0,key:void 0},s=Le([LX,N0.Message.encode(i).finish()]);i.signature=await r.privateKey.sign(s),i.key=r.key;let o={type:"signed",from:r.author,data:t,sequenceNumber:BigInt(`0x${K(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key};return{raw:i,msg:o}}case ef.Anonymous:return{raw:{from:void 0,data:n,seqno:void 0,topic:e,signature:void 0,key:void 0},msg:{type:"unsigned",data:t,topic:e}}}}async function MX(r,e){switch(r){case L0:return e.signature!=null?{valid:!1,error:ei.SignaturePresent}:e.seqno!=null?{valid:!1,error:ei.SeqnoPresent}:e.key!=null?{valid:!1,error:ei.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case ed:{if(e.seqno==null)return{valid:!1,error:ei.InvalidSeqno};if(e.seqno.length!==8)return{valid:!1,error:ei.InvalidSeqno};if(e.signature==null)return{valid:!1,error:ei.InvalidSignature};if(e.from==null)return{valid:!1,error:ei.InvalidPeerId};let t;try{t=Ir(e.from)}catch{return{valid:!1,error:ei.InvalidPeerId}}let n;if(e.key){if(n=Ti(e.key),t.publicKey!==void 0&&!ze(n.bytes,t.publicKey))return{valid:!1,error:ei.InvalidPeerId}}else{if(t.publicKey==null)return{valid:!1,error:ei.InvalidPeerId};n=Ti(t.publicKey)}let i={from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0},s=Le([LX,N0.Message.encode(i).finish()]);return await n.verify(s,e.signature)?{valid:!0,message:{type:"signed",from:t,data:e.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${K(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??zm(n)}}:{valid:!1,error:ei.InvalidSignature}}}}u();u();u();var K7e=E(V(),1);var UX=(r,e)=>{let t=z(e.toString(16).padStart(16,"0"),"base16"),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n};function FX(r){if(r.type!=="signed")throw new Error("expected signed message type");if(r.sequenceNumber==null)throw Error("missing seqno field");return UX(r.from.toBytes(),r.sequenceNumber)}async function VX(r){return await $e.encode(r.data)}u();function q7e(r,e,t,n,i){let s=0,o=new Map;if(Object.entries(e.topics).forEach(([p,d])=>{let m=i.get(p)??"unknown",y=t.topics[p];if(y===void 0)return;let g=o.get(m);g||(g={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(m,g));let w=0,b=0,S=0,_=0,I=0;d.inMesh&&(w+=Math.max(d.meshTime/y.timeInMeshQuantum,y.timeInMeshCap)*y.timeInMeshWeight);let T=d.firstMessageDeliveries;if(T>y.firstMessageDeliveriesCap&&(T=y.firstMessageDeliveriesCap),b+=T*y.firstMessageDeliveriesWeight,d.meshMessageDeliveriesActive&&d.meshMessageDeliveries<y.meshMessageDeliveriesThreshold){let B=y.meshMessageDeliveriesThreshold-d.meshMessageDeliveries;S+=B*B*y.meshMessageDeliveriesWeight}_+=d.meshFailurePenalty*y.meshFailurePenaltyWeight,I+=d.invalidMessageDeliveries*d.invalidMessageDeliveries*y.invalidMessageDeliveriesWeight,s+=(w+b+S+_+I)*y.topicWeight,g.p1w+=w,g.p2w+=b,g.p3w+=S,g.p3bw+=_,g.p4w+=I}),t.topicScoreCap>0&&s>t.topicScoreCap){s=t.topicScoreCap;let p=t.topicScoreCap/s;for(let d of o.values())d.p1w*=p,d.p2w*=p,d.p3w*=p,d.p3bw*=p,d.p4w*=p}let a=0,c=0,l=0;return a+=t.appSpecificScore(r)*t.appSpecificWeight,e.ips.forEach(p=>{if(t.IPColocationFactorWhitelist.has(p))return;let d=n.get(p),m=d?d.size:0;if(m>t.IPColocationFactorThreshold){let y=m-t.IPColocationFactorThreshold;c+=y*y*t.IPColocationFactorWeight}}),l+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+c+l,{byTopic:o,p5w:a,p6w:c,p7w:l,score:s}}function KX(r,e,t,n,i){let s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(let o of r){let a=e.get(o);if(a){let c=q7e(o,a,t,n,i);for(let[l,f]of c.byTopic){let h=s.byTopic.get(l);h||(h={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(l,h)),h.p1w.push(f.p1w),h.p2w.push(f.p2w),h.p3w.push(f.p3w),h.p3bw.push(f.p3bw),h.p4w.push(f.p4w)}s.p5w.push(c.p5w),s.p6w.push(c.p6w),s.p7w.push(c.p7w),s.score.push(c.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}u();function K8(r,e,t=()=>!0){let n=new Set;if(e<=0)return n;for(let i of r){if(n.size>=e)break;t(i)&&(n.add(i),r.delete(i))}return n}function qX(r,e){return K8(r,e,()=>!0)}u();u();u();var tf=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};u();function zX(r){if(r!=null){if(typeof r[Symbol.iterator]=="function")return r[Symbol.iterator]();if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r.next=="function")return r}throw new Error("argument is not an iterator or iterable")}function Kr(r,e,t){let n=t??{},i=zX(r);async function*s(){let o,a=()=>{o?.()};for(e.addEventListener("abort",a);;){let c;try{if(e.aborted){let{abortMessage:f,abortCode:h}=n;throw new tf(f,h)}let l=new Promise((f,h)=>{o=()=>{let{abortMessage:p,abortCode:d}=n;h(new tf(p,d))}});c=await Promise.race([l,i.next()]),o=null}catch(l){e.removeEventListener("abort",a);let f=l.type==="aborted"&&e.aborted;if(f&&n.onAbort!=null&&await n.onAbort(r),typeof i.return=="function")try{let h=i.return();h instanceof Promise&&h.catch(p=>{n.onReturnError!=null&&n.onReturnError(p)})}catch(h){n.onReturnError!=null&&n.onReturnError(h)}if(f&&n.returnOnAbort===!0)return;throw l}if(c.done===!0)break;yield c.value}e.removeEventListener("abort",a)}return s()}function z7e(r,e,t){return n=>r(Kr(n,e,t))}function ti(r,e,t){return{sink:z7e(r.sink,e,{...t,onAbort:void 0}),source:Kr(r.source,e,t)}}u();u();u();function $X(r){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var q8=r=>{let e=Vo.encodingLength(r),t=$X(e);return Vo.encode(r,t),q8.bytes=e,t};q8.bytes=0;function mr(r){r=r??{};let e=r.lengthEncoder??q8;return async function*(n){for await(let i of n){let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}}}mr.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??q8;return new Mt(t(r.byteLength),r)};u();var Gy=E(V(),1),$7e=8,H7e=1024*1024*4,rd;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(rd||(rd={}));var yR=r=>{let e=Vo.decode(r);return yR.bytes=Vo.encodingLength(e),e};yR.bytes=0;function yr(r){return async function*(t){let n=new Mt,i=rd.LENGTH,s=-1,o=r?.lengthDecoder??yR,a=r?.maxLengthLength??$7e,c=r?.maxDataLength??H7e;for await(let l of t)for(n.append(l);n.byteLength>0;){if(i===rd.LENGTH)try{if(s=o(n),s<0)throw(0,Gy.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>c)throw(0,Gy.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let f=o.bytes;n.consume(f),r?.onLength!=null&&r.onLength(s),i=rd.DATA}catch(f){if(f instanceof RangeError){if(n.byteLength>a)throw(0,Gy.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw f}if(i===rd.DATA){if(n.byteLength<s)break;let f=n.sublist(0,s);n.consume(s),r?.onData!=null&&r.onData(f),yield f,i=rd.LENGTH}}if(n.byteLength>0)throw(0,Gy.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}yr.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:s,value:o}=await r.next(t);if(s===!0)return;o!=null&&(yield o)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{t=1}}();return yr({...e??{},onLength:s=>{t=s}})(n)};var z8=class{constructor(e,t,n){this.rawStream=e,this.pushable=ar({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=n.maxBufferSize??1/0,we(Kr(this.pushable,this.closeController.signal,{returnOnAbort:!0}),mr(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}},$8=class{constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=Kr(we(this.rawStream,yr()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}};var cs;(function(r){r[r.started=0]="started",r[r.stopped=1]="stopped"})(cs||(cs={}));var jy=class extends We{constructor(e={}){super(),this.multicodecs=[dR,hR],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=ar({objectMode:!0}),this.direct=new Set,this.floodsubPeers=new Set,this.acceptFromWhitelist=new Map,this.topics=new Map,this.subscriptions=new Set,this.mesh=new Map,this.fanout=new Map,this.fanoutLastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.topicValidators=new Map,this.heartbeatTicks=0,this.components=new je,this.directPeerInitial=null,this.status={code:cs.stopped},this.heartbeatTimer=null,this.runHeartbeat=()=>{let n=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(i=>{this.log("Error running heartbeat",i)}).finally(()=>{if(n?.(),this.status.code===cs.started){clearTimeout(this.status.heartbeatTimeout);let i=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;i<this.opts.heartbeatInterval*.25&&(i+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,i)}})};let t={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,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...e,scoreParams:_X(e.scoreParams),scoreThresholds:xX(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??ed,t.fallbackToFloodsub&&this.multicodecs.push(fR),this.log=C(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(n=>n.id.toString())),this.seenCache=new M0({validityMs:t.seenTTL}),this.publishedMessageIds=new M0({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case ed:this.msgIdFn=FX;break;case L0:this.msgIdFn=VX;break}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new M0({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??bX,this.mcache=e.messageCache||new L8(t.mcacheGossip,t.mcacheLength,this.msgIdToStrFn),e.dataTransform&&(this.dataTransform=e.dataTransform),e.metricsRegister){if(!e.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");let n=Math.max(...Object.values(t.scoreParams.topics).map(s=>s.meshMessageDeliveriesWindow),1e3),i=PX(e.metricsRegister,e.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:t.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:n/1e3});i.mcacheSize.addCollect(()=>this.onScrapeMetrics(i));for(let s of this.multicodecs)i.protocolsEnabled.set({protocol:s},1);this.metrics=i}else this.metrics=null;this.gossipTracer=new V8(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new F8(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>pe(e))}isStarted(){return this.status.code===cs.started}async init(e){this.components=e,this.score.init(e)}async start(){if(this.isStarted())return;this.log("starting"),this.publishConfig=await mR(this.globalSignaturePolicy,this.components.getPeerId()),this.outboundInflightQueue=ar({objectMode:!0}),we(this.outboundInflightQueue,async s=>{for await(let{peerId:o,connection:a}of s)await this.createOutboundStream(o,a)}).catch(s=>this.log.error("outbound inflight queue error",s)),await Promise.all(this.opts.directPeers.map(async s=>{await this.components.getPeerStore().addressBook.add(s.id,s.addrs)}));let e=this.components.getRegistrar();await Promise.all(this.multicodecs.map(s=>e.handle(s,this.onIncomingStream.bind(this),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams})));let t=k0({onConnect:this.onPeerConnected.bind(this),onDisconnect:this.onPeerDisconnected.bind(this)}),n=await Promise.all(this.multicodecs.map(s=>e.register(s,t))),i=setTimeout(this.runHeartbeat,100);this.status={code:cs.started,registrarTopologyIds:n,heartbeatTimeout:i,hearbeatStartMs:Date.now()+100},this.score.start(),this.directPeerInitial=setTimeout(()=>{Promise.resolve().then(async()=>{await Promise.all(Array.from(this.direct).map(async s=>await this.connect(s)))}).catch(s=>{this.log(s)})},1e3),this.log("started")}async stop(){if(this.log("stopping"),this.status.code!==cs.started)return;let{registrarTopologyIds:e}=this.status;this.status={code:cs.stopped};let t=this.components.getRegistrar();e.forEach(n=>t.unregister(n)),this.outboundInflightQueue.end();for(let n of this.streamsOutbound.values())n.close();this.streamsOutbound.clear();for(let n of this.streamsInbound.values())n.close();this.streamsInbound.clear(),this.peers.clear(),this.subscriptions.clear(),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(),this.fastMsgIdCache&&this.fastMsgIdCache.clear(),this.directPeerInitial&&clearTimeout(this.directPeerInitial),this.log("stopped")}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream({stream:e,connection:t}){if(!this.isStarted())return;let n=t.remotePeer;this.addPeer(n,t.stat.direction),this.createInboundStream(n,e),this.outboundInflightQueue.push({peerId:n,connection:t})}onPeerConnected(e,t){!this.isStarted()||(this.addPeer(e,t.stat.direction),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;let n=e.toString();if(!!this.peers.has(n)&&!this.streamsOutbound.has(n))try{let i=new z8(await t.newStream(this.multicodecs),o=>this.log.error("outbound pipe error",o),{maxBufferSize:this.opts.maxOutboundBufferSize});this.log("create outbound stream %p",e),this.streamsOutbound.set(n,i);let s=i.protocol;s===fR&&this.floodsubPeers.add(n),this.metrics?.peersPerProtocol.inc({protocol:s},1),this.subscriptions.size>0&&(this.log("send subscriptions to",n),this.sendSubscriptions(n,Array.from(this.subscriptions),!0))}catch(i){this.log.error("createOutboundStream error",i)}}async createInboundStream(e,t){if(!this.isStarted())return;let n=e.toString();if(!this.peers.has(n))return;let i=this.streamsInbound.get(n);i!==void 0&&(this.log("replacing existing inbound steam %s",n),i.close()),this.log("create inbound stream %s",n);let s=new $8(t);this.streamsInbound.set(n,s),this.pipePeerReadStream(e,s.source).catch(o=>this.log(o))}addPeer(e,t){let n=e.toString();this.peers.has(n)||(this.log("new peer %p",e),this.peers.add(n),this.score.addPeer(n),this.outbound.has(n)||this.outbound.set(n,t==="outbound"))}removePeer(e){let t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);let n=this.streamsOutbound.get(t),i=this.streamsInbound.get(t);n&&this.metrics?.peersPerProtocol.inc({protocol:n.protocol},-1),n?.close(),i?.close(),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(let s of this.topics.values())s.delete(t);for(let[s,o]of this.mesh)o.delete(t)===!0&&this.metrics?.onRemoveFromMesh(s,td.Dc,1);for(let 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===cs.started}getMeshPeers(e){let t=this.mesh.get(e);return t?Array.from(t):[]}getSubscribers(e){let t=this.topics.get(e);return(t?Array.from(t):[]).map(n=>pe(n))}getTopics(){return Array.from(this.subscriptions)}async pipePeerReadStream(e,t){try{await we(t,async n=>{for await(let i of n)try{let s=i.subarray(),o=N0.decode(s);this.metrics?.onRpcRecv(o,s.length),this.opts.awaitRpcHandler?await this.handleReceivedRpc(e,o):this.handleReceivedRpc(e,o).catch(a=>this.log(a))}catch(s){this.log(s)}})}catch(n){this.log.error(n),this.onPeerDisconnected(e)}}async handleReceivedRpc(e,t){if(!this.acceptFrom(e.toString())){this.log("received message from unacceptable peer %p",e),this.metrics?.rpcRecvNotAccepted.inc();return}if(this.log("rpc from %p",e),t.subscriptions&&t.subscriptions.length>0&&(t.subscriptions.forEach(n=>{this.handleReceivedSubscription(e,n)}),this.dispatchEvent(new ne("subscription-change",{detail:{peerId:e,subscriptions:t.subscriptions.filter(n=>n.topic!==null).map(n=>({topic:n.topic??"",subscribe:Boolean(n.subscribe)}))}}))),t.messages)for(let n of t.messages){let i=this.handleReceivedMessage(e,n).catch(s=>this.log(s));this.opts.awaitRpcMessageHandler&&await i}t.control&&await this.handleControlMessage(e.toString(),t.control)}handleReceivedSubscription(e,t){if(t.topic==null)return;this.log("subscription update from %p topic %s",e,t.topic);let n=this.topics.get(t.topic);n==null&&(n=new Set,this.topics.set(t.topic,n)),t.subscribe?n.add(e.toString()):n.delete(e.toString())}async handleReceivedMessage(e,t){this.metrics?.onMsgRecvPreValidation(t.topic);let n=await this.validateReceivedMessage(e,t);switch(this.metrics?.onMsgRecvResult(t.topic,n.code),n.code){case Gs.duplicate:this.score.duplicateMessage(e.toString(),n.msgIdStr,t.topic),this.mcache.observeDuplicate(n.msgIdStr,e.toString());return;case Gs.invalid:if(n.msgIdStr){let i=n.msgIdStr;this.score.rejectMessage(e.toString(),i,t.topic,n.reason),this.gossipTracer.rejectMessage(i,n.reason)}else this.score.rejectInvalidMessage(e.toString(),t.topic);this.metrics?.onMsgRecvInvalid(t.topic,n);return;case Gs.valid:this.score.validateMessage(n.messageId.msgIdStr),this.gossipTracer.deliverMessage(n.messageId.msgIdStr),this.mcache.put(n.messageId,t,!this.opts.asyncValidation),this.subscriptions.has(t.topic)&&(!this.components.getPeerId().equals(e)||this.opts.emitSelf)&&(super.dispatchEvent(new ne("gossipsub:message",{detail:{propagationSource:e,msgId:n.messageId.msgIdStr,msg:n.msg}})),super.dispatchEvent(new ne("message",{detail:n.msg}))),this.opts.asyncValidation||this.forwardMessage(n.messageId.msgIdStr,t,e.toString())}}async validateReceivedMessage(e,t){let n=this.fastMsgIdFn?.(t),i=n?this.fastMsgIdCache?.get(n):void 0;if(i)return{code:Gs.duplicate,msgIdStr:i};let s=await MX(this.globalSignaturePolicy,t);if(!s.valid)return{code:Gs.invalid,reason:hi.Error,error:s.error};let o=s.message;try{this.dataTransform&&(o.data=this.dataTransform.inboundTransform(t.topic,o.data))}catch(h){return this.log("Invalid message, transform failed",h),{code:Gs.invalid,reason:hi.Error,error:ei.TransformFailed}}let a=await this.msgIdFn(o),c=this.msgIdToStrFn(a),l={msgId:a,msgIdStr:c};if(n&&this.fastMsgIdCache?.put(n,c),this.seenCache.has(c))return{code:Gs.duplicate,msgIdStr:c};this.seenCache.put(c);let f=this.topicValidators.get(t.topic);if(f!=null){let h;try{h=await f(o.topic,o,e)}catch(p){let d=p.code;d===EX&&(h=Wa.Ignore),d===wX?h=Wa.Reject:h=Wa.Ignore}if(h!==Wa.Accept)return{code:Gs.invalid,reason:pR(h),msgIdStr:c}}return{code:Gs.valid,messageId:l,msg:o}}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,n){this.sendRpc(e,{subscriptions:t.map(i=>({topic:i,subscribe:n})),messages:[]})}async handleControlMessage(e,t){if(t===void 0)return;let n=t.ihave?this.handleIHave(e,t.ihave):[],i=t.iwant?this.handleIWant(e,t.iwant):[],s=t.graft?await this.handleGraft(e,t.graft):[];t.prune&&await this.handlePrune(e,t.prune),!(!n.length&&!i.length&&!s.length)&&this.sendRpc(e,Ga(i,{iwant:n,prune:s}))}acceptFrom(e){if(this.direct.has(e))return!0;let t=Date.now(),n=this.acceptFromWhitelist.get(e);if(n&&n.messagesAccepted<128&&n.acceptUntil>=t)return n.messagesAccepted+=1,!0;let i=this.score.score(e);return i>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),i>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(!t.length)return[];let n=this.score.score(e);if(n<this.opts.scoreThresholds.gossipThreshold)return this.log("IHAVE: ignoring peer %s with score below threshold [ score = %d ]",e,n),this.metrics?.ihaveRcvIgnored.inc({reason:V0.LowScore}),[];let i=(this.peerhave.get(e)??0)+1;if(this.peerhave.set(e,i),i>10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:V0.MaxIhave}),[];let s=this.iasked.get(e)??0;if(s>=5e3)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:V0.MaxIasked}),[];let o=new Map;if(t.forEach(({topicID:l,messageIDs:f})=>{if(!l||!f||!this.mesh.has(l))return;let h=0;f.forEach(p=>{let d=this.msgIdToStrFn(p);this.seenCache.has(d)||(o.set(d,p),h++)}),this.metrics?.onIhaveRcv(l,f.length,h)}),!o.size)return[];let a=o.size;a+s>5e3&&(a=5e3-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let c=Array.from(o.values());return ja(c),c=c.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,c),[{messageIDs:c}]}handleIWant(e,t){if(!t.length)return[];let 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),[];let i=new Map,s=new Map,o=0;return t.forEach(({messageIDs:a})=>{a&&a.forEach(c=>{let l=this.msgIdToStrFn(c),f=this.mcache.getWithIWantCount(l,e);if(f==null){o++;return}if(s.set(f.msg.topic,1+(s.get(f.msg.topic)??0)),f.count>3){this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,c);return}i.set(l,f.msg)})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}async handleGraft(e,t){let n=[],i=this.score.score(e),s=Date.now(),o=this.opts.doPX;return t.forEach(({topicID:a})=>{if(!a)return;let c=this.mesh.get(a);if(!c){o=!1;return}if(c.has(e))return;if(this.direct.has(e)){this.log("GRAFT: ignoring request from direct peer %s",e),n.push(a),o=!1;return}let l=this.backoff.get(a)?.get(e);if(typeof l=="number"&&s<l){this.log("GRAFT: ignoring backed off peer %s",e),this.score.addPenalty(e,1,F0.GraftBackoff),o=!1;let f=l+this.opts.graftFloodThreshold-this.opts.pruneBackoff;s<f&&this.score.addPenalty(e,1,F0.GraftBackoff),this.addBackoff(e,a),n.push(a);return}if(i<0){this.log("GRAFT: ignoring peer %s with negative score: score=%d, topic=%s",e,i,a),n.push(a),o=!1,this.addBackoff(e,a);return}if(c.size>=this.opts.Dhi&&!this.outbound.get(e)){n.push(a),this.addBackoff(e,a);return}this.log("GRAFT: Add mesh link from %s in %s",e,a),this.score.graft(e,a),c.add(e),this.metrics?.onAddToMesh(a,il.Subscribed,1)}),n.length?await Promise.all(n.map(a=>this.makePrune(e,a,o))):[]}async handlePrune(e,t){let n=this.score.score(e);for(let{topicID:i,backoff:s,peers:o}of t){if(i==null)continue;let a=this.mesh.get(i);if(!a)return;if(this.log("PRUNE: Remove mesh link to %s in %s",e,i),this.score.prune(e,i),a.has(e)&&(a.delete(e),this.metrics?.onRemoveFromMesh(i,td.Unsub,1)),typeof s=="number"&&s>0?this.doAddBackoff(e,i,s*1e3):this.addBackoff(e,i),o&&o.length){if(n<this.opts.scoreThresholds.acceptPXThreshold){this.log("PRUNE: ignoring PX from peer %s with insufficient score [score = %d, topic = %s]",e,n,i);continue}await this.pxConnect(o)}}}addBackoff(e,t){this.doAddBackoff(e,t,this.opts.pruneBackoff)}doAddBackoff(e,t,n){let i=this.backoff.get(t);i||(i=new Map,this.backoff.set(t,i));let s=Date.now()+n;(i.get(e)??0)<s&&i.set(e,s)}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,F0.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%15!==0)return;let e=Date.now();this.backoff.forEach((t,n)=>{t.forEach((i,s)=>{i<e&&t.delete(s)}),t.size===0&&this.backoff.delete(n)})}async directConnect(){let e=[];this.direct.forEach(t=>{this.streamsOutbound.has(t)||e.push(t)}),await Promise.all(e.map(async t=>await this.connect(t)))}async pxConnect(e){e.length>this.opts.prunePeers&&(ja(e),e=e.slice(0,this.opts.prunePeers));let t=[];await Promise.all(e.map(async n=>{if(!n.peerID)return;let i=Ir(n.peerID).toString();if(!this.peers.has(i)){if(!n.signedPeerRecord){t.push(i);return}try{let s=await Jr.openAndCertify(n.signedPeerRecord,"libp2p-peer-record"),o=s.peerId;if(!s.peerId.equals(i)){this.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",o,i);return}if(!await this.components.getPeerStore().addressBook.consumePeerRecord(s)){this.log("bogus peer record obtained through px: could not add peer record to address book");return}t.push(i)}catch{this.log("bogus peer record obtained through px: invalid signature or not a peer record")}}})),t.length&&await Promise.all(t.map(async n=>await this.connect(n)))}async connect(e){this.log("Initiating connection with %s",e);let t=pe(e),n=await this.components.getConnectionManager().openConnection(t);for(let i of this.multicodecs)for(let s of this.components.getRegistrar().getTopologies(i))s.onConnect(t,n)}subscribe(e){if(this.status.code!==cs.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(let t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==cs.started)throw new Error("Pubsub is not started");let t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(let n of this.peers.keys())this.sendSubscriptions(n,[e],!1);this.leave(e).catch(n=>{this.log(n)})}join(e){if(this.status.code!==cs.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),this.metrics?.onJoin(e);let t=new Set,n=this.fanout.get(e);if(n&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),n.forEach(i=>{!this.direct.has(i)&&this.score.score(i)>=0&&t.add(i)}),this.metrics?.onAddToMesh(e,il.Fanout,t.size)),t.size<this.opts.D){let i=t.size;this.getRandomGossipPeers(e,this.opts.D,o=>!t.has(o)&&!this.direct.has(o)&&this.score.score(o)>=0).forEach(o=>{t.add(o)}),this.metrics?.onAddToMesh(e,il.Random,t.size-i)}this.mesh.set(e,t),t.forEach(i=>{this.log("JOIN: Add mesh link to %s in %s",i,e),this.sendGraft(i,e)})}async leave(e){if(this.status.code!==cs.started)throw new Error("Gossipsub has not started");this.log("LEAVE %s",e),this.metrics?.onLeave(e);let t=this.mesh.get(e);t&&(await Promise.all(Array.from(t).map(async n=>(this.log("LEAVE: Remove mesh link to %s in %s",n,e),await this.sendPrune(n,e)))),this.mesh.delete(e))}selectPeersToForward(e,t,n){let i=new Set,s=this.topics.get(e);s&&(this.direct.forEach(a=>{s.has(a)&&t!==a&&!n?.has(a)&&i.add(a)}),this.floodsubPeers.forEach(a=>{s.has(a)&&t!==a&&!n?.has(a)&&this.score.score(a)>=this.opts.scoreThresholds.publishThreshold&&i.add(a)}));let o=this.mesh.get(e);return o&&o.size>0&&o.forEach(a=>{t!==a&&!n?.has(a)&&i.add(a)}),i}selectPeersToPublish(e){let t=new Set,n={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach(s=>{this.direct.has(s)?(t.add(s),n.direct++):this.score.score(s)>=this.opts.scoreThresholds.publishThreshold&&(t.add(s),n.floodsub++)});else{this.direct.forEach(o=>{i.has(o)&&(t.add(o),n.direct++)}),this.floodsubPeers.forEach(o=>{i.has(o)&&this.score.score(o)>=this.opts.scoreThresholds.publishThreshold&&(t.add(o),n.floodsub++)});let s=this.mesh.get(e);if(s&&s.size>0)s.forEach(o=>{t.add(o),n.mesh++});else{let o=this.fanout.get(e);if(o&&o.size>0)o.forEach(a=>{t.add(a),n.fanout++});else{let a=this.getRandomGossipPeers(e,this.opts.D,c=>this.score.score(c)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(c=>{t.add(c),n.fanout++}))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:n}}forwardMessage(e,t,n,i){n&&this.score.deliverMessage(n,e,t.topic);let s=this.selectPeersToForward(t.topic,n,i),o=Ga([t]);s.forEach(a=>{this.sendRpc(a,o)}),this.metrics?.onForwardMsg(t.topic,s.size)}async publish(e,t){let n=this.dataTransform?this.dataTransform.outboundTransform(e,t):t;if(this.publishConfig==null)throw Error("PublishError.Uninitialized");let{raw:i,msg:s}=await BX(this.publishConfig,e,t,n),o=await this.msgIdFn(s),a=this.msgIdToStrFn(o);if(this.seenCache.has(a))throw Error("PublishError.Duplicate");let{tosend:c,tosendCount:l}=this.selectPeersToPublish(e),f=this.opts.emitSelf===!0&&this.subscriptions.has(e);if(c.size===0&&!this.opts.allowPublishToZeroPeers&&!f)throw Error("PublishError.InsufficientPeers");this.seenCache.put(a),this.mcache.put({msgId:o,msgIdStr:a},i,!0),this.publishedMessageIds.put(a);let h=Ga([i]);for(let p of c)this.sendRpc(p,h)||c.delete(p);return this.metrics?.onPublishMsg(e,l,c.size,i.data!=null?i.data.length:0),f&&(c.add(this.components.getPeerId().toString()),super.dispatchEvent(new ne("gossipsub:message",{detail:{propagationSource:this.components.getPeerId(),msgId:a,msg:s}})),super.dispatchEvent(new ne("message",{detail:s}))),{recipients:Array.from(c.values()).map(p=>pe(p))}}reportMessageValidationResult(e,t,n){if(n===Wa.Accept){let i=this.mcache.validate(e);if(this.metrics?.onReportValidationMcacheHit(i!==null),i!=null){let{message:s,originatingPeers:o}=i;this.score.deliverMessage(t.toString(),e,s.topic),this.forwardMessage(e,i.message,t.toString(),o),this.metrics?.onReportValidation(s.topic,n)}}else{let i=this.mcache.remove(e);if(this.metrics?.onReportValidationMcacheHit(i!==null),i){let s=pR(n),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(let c of a)this.score.rejectMessage(c,e,o.topic,s);this.metrics?.onReportValidation(o.topic,n)}}}sendGraft(e,t){let i=Ga([],{graft:[{topicID:t}]});this.sendRpc(e,i)}async sendPrune(e,t){let n=[await this.makePrune(e,t,this.opts.doPX)],i=Ga([],{prune:n});this.sendRpc(e,i)}sendRpc(e,t){let n=this.streamsOutbound.get(e);if(!n)return this.log(`Cannot send RPC to ${e} as there is no open stream to it available`),!1;let i=this.control.get(e);i&&(this.piggybackControl(e,t,i),this.control.delete(e));let s=this.gossip.get(e);s&&(this.piggybackGossip(e,t,s),this.gossip.delete(e));let o=N0.encode(t).finish();try{n.push(o)}catch(a){return this.log.error(`Cannot send rpc to ${e}`,a),i&&this.control.set(e,i),s&&this.gossip.set(e,s),!1}return this.metrics?.onRpcSent(t,o.length),!0}piggybackControl(e,t,n){let i=(n.graft||[]).filter(({topicID:o})=>(o&&this.mesh.get(o)||new Set).has(e)),s=(n.prune||[]).filter(({topicID:o})=>!(o&&this.mesh.get(o)||new Set).has(e));!i.length&&!s.length||(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(s)):t.control={graft:i,prune:s,ihave:[],iwant:[]})}piggybackGossip(e,t,n){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=n}async sendGraftPrune(e,t,n){let i=this.opts.doPX;for(let[s,o]of e){let a=o.map(h=>({topicID:h})),c=[],l=t.get(s);l&&(c=await Promise.all(l.map(async h=>await this.makePrune(s,h,i&&!(n.get(s)??!1)))),t.delete(s));let f=Ga([],{graft:a,prune:c});this.sendRpc(s,f)}for(let[s,o]of t){let a=await Promise.all(o.map(async l=>await this.makePrune(s,l,i&&!(n.get(s)??!1)))),c=Ga([],{prune:a});this.sendRpc(s,c)}}emitGossip(e){let t=this.mcache.getGossipIDs(new Set(e.keys()));for(let[n,i]of e)this.doEmitGossip(n,i,t.get(n)??[])}doEmitGossip(e,t,n){if(!n.length||(ja(n),n.length>5e3&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",n.length),!t.size))return;let i=this.opts.Dlazy,s=.25*t.size,o=t;s>i&&(i=s),i>o.size?i=o.size:o=ja(Array.from(o)).slice(0,i),o.forEach(a=>{let c=n;n.length>5e3&&(c=ja(c.slice()).slice(0,5e3)),this.pushGossip(a,{topicID:e,messageIDs:c})})}flush(){for(let[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,Ga([],{ihave:t}));for(let[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,Ga([],{graft:t.graft,prune:t.prune}))}pushGossip(e,t){this.log("Add gossip to %s",e);let n=this.gossip.get(e)||[];this.gossip.set(e,n.concat(t))}async makePrune(e,t,n){if(this.score.prune(e,t),this.streamsOutbound.get(e).protocol===hR)return{topicID:t,peers:[]};let i=this.opts.pruneBackoff/1e3;if(!n)return{topicID:t,peers:[],backoff:i};let s=this.getRandomGossipPeers(t,this.opts.prunePeers,a=>a!==e&&this.score.score(a)>=0),o=await Promise.all(Array.from(s).map(async a=>{let c=pe(a);return{peerID:c.toBytes(),signedPeerRecord:await this.components.getPeerStore().addressBook.getRawEnvelope(c)}}));return{topicID:t,peers:o,backoff:i}}async heartbeat(){let{D:e,Dlo:t,Dhi:n,Dscore:i,Dout:s,fanoutTTL:o}=this.opts;this.heartbeatTicks++;let a=new Map,c=m=>{let y=a.get(m);return y===void 0&&(y=this.score.score(m),a.set(m,y)),y},l=new Map,f=new Map,h=new Map;this.clearBackoff(),this.peerhave.clear(),this.metrics?.cacheSize.set({cache:"iasked"},this.iasked.size),this.iasked.clear(),this.applyIwantPenalties(),this.heartbeatTicks%this.opts.directConnectTicks===0&&await this.directConnect(),this.fastMsgIdCache?.prune(),this.seenCache.prune(),this.gossipTracer.prune(),this.publishedMessageIds.prune();let p=new Map;this.mesh.forEach((m,y)=>{let g=this.topics.get(y),w=new Set,b=new Set;if(p.set(y,b),g){let I=ja(Array.from(g)),T=this.backoff.get(y);for(let x of I){let P=this.streamsOutbound.get(x);if(P&&this.multicodecs.includes(P.protocol)&&!m.has(x)&&!this.direct.has(x)){let B=c(x);(!T||!T.has(x))&&B>=0&&w.add(x),B>=this.opts.scoreThresholds.gossipThreshold&&b.add(x)}}}let S=(I,T)=>{this.log("HEARTBEAT: Remove mesh link to %s in %s",I,y),this.addBackoff(I,y),m.delete(I),c(I)>=this.opts.scoreThresholds.gossipThreshold&&b.add(I),this.metrics?.onRemoveFromMesh(y,T,1);let x=f.get(I);x?x.push(y):f.set(I,[y])},_=(I,T)=>{this.log("HEARTBEAT: Add mesh link to %s in %s",I,y),this.score.graft(I,y),m.add(I),b.delete(I),this.metrics?.onAddToMesh(y,T,1);let x=l.get(I);x?x.push(y):l.set(I,[y])};if(m.forEach(I=>{let T=c(I);T<0&&(this.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",I,T,y),S(I,td.BadScore),h.set(I,!0))}),m.size<t){let I=e-m.size;qX(w,I).forEach(x=>{_(x,il.NotEnough)})}if(m.size>n){let I=Array.from(m);I.sort((x,P)=>c(P)-c(x)),I=I.slice(0,i).concat(ja(I.slice(i)));let T=0;if(I.slice(0,e).forEach(x=>{this.outbound.get(x)&&T++}),T<s){let x=B=>{let q=I[B];for(let Y=B;Y>0;Y--)I[Y]=I[Y-1];I[0]=q};if(T>0){let B=T;for(let q=1;q<e&&B>0;q++)this.outbound.get(I[q])&&(x(q),B--)}let P=e-T;for(let B=e;B<I.length&&P>0;B++)this.outbound.get(I[B])&&(x(B),P--)}I.slice(e).forEach(x=>{S(x,td.Excess)})}if(m.size>=t){let I=0;if(m.forEach(T=>{this.outbound.get(T)&&I++}),I<s){let T=s-I;K8(w,T,P=>this.outbound.get(P)===!0).forEach(P=>{_(P,il.Outbound)})}}if(this.heartbeatTicks%this.opts.opportunisticGraftTicks===0&&m.size>1){let I=Array.from(m).sort((P,B)=>c(P)-c(B)),T=Math.floor(m.size/2),x=c(I[T]);if(x<this.opts.scoreThresholds.opportunisticGraftThreshold){let P=this.opts.opportunisticGraftPeers,B=K8(w,P,q=>c(q)>x);for(let q of B)this.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",q,y),_(q,il.Opportunistic)}}});let d=Date.now();this.fanoutLastpub.forEach((m,y)=>{m+o<d&&(this.fanout.delete(y),this.fanoutLastpub.delete(y))}),this.fanout.forEach((m,y)=>{let g=this.topics.get(y);m.forEach(_=>{(!g.has(_)||c(_)<this.opts.scoreThresholds.publishThreshold)&&m.delete(_)});let w=this.topics.get(y),b=[],S=new Set;if(p.set(y,S),w){let _=ja(Array.from(w));for(let I of _){let T=this.streamsOutbound.get(I);if(T&&this.multicodecs.includes(T.protocol)&&!m.has(I)&&!this.direct.has(I)){let x=c(I);x>=this.opts.scoreThresholds.publishThreshold&&b.push(I),x>=this.opts.scoreThresholds.gossipThreshold&&S.add(I)}}}if(m.size<e){let _=e-m.size;b.slice(0,_).forEach(I=>{m.add(I),S?.delete(I)})}}),this.emitGossip(p),await this.sendGraftPrune(l,f,h),this.flush(),this.mcache.shift(),this.dispatchEvent(new ne("gossipsub:heartbeat"))}getRandomGossipPeers(e,t,n=()=>!0){let i=this.topics.get(e);if(!i)return new Set;let s=[];return i.forEach(o=>{let a=this.streamsOutbound.get(o);!a||this.multicodecs.includes(a.protocol)&&n(o)&&s.push(o)}),s=ja(s),t>0&&s.length>t&&(s=s.slice(0,t)),new Set(s)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??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 t=0;for(let o of this.backoff.values())t+=o.size;e.cacheSize.set({cache:"backoff"},t);for(let[o,a]of this.topics)e.topicPeersCount.set({topicStr:o},a.size);for(let[o,a]of this.mesh)e.meshPeerCounts.set({topicStr:o},a.size);let n=[],i=new Map;e.behaviourPenalty.reset();for(let o of this.peers.keys()){let a=this.score.score(o);n.push(a),i.set(o,a),e.behaviourPenalty.observe(this.score.peerStats.get(o)?.behaviourPenalty??0)}e.registerScores(n,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,i);let s=KX(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}};jy.multicodec=dR;var GX=()=>({gossipsub:new jy({allowPublishToZeroPeers:!0,fallbackToFloodsub:!0,emitSelf:!0,maxInboundStreams:64,maxOutboundStreams:128})});u();u();var tZ=E(Hl(),1);u();var Wy=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},gR=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},jX=r=>globalThis.DOMException===void 0?new gR(r):new DOMException(r),WX=r=>{let e=r.reason===void 0?jX("This operation was aborted."):r.reason;return e instanceof Error?e:jX(e)};function wR(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(WX(c)),c.addEventListener("abort",()=>{a(WX(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new Wy(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function ER(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var nd=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},sl,Yy=class{constructor(){sl.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&nd(this,sl,"f")[this.size-1].priority>=t.priority){nd(this,sl,"f").push(n);return}let i=ER(nd(this,sl,"f"),n,(s,o)=>o.priority-s.priority);nd(this,sl,"f").splice(i,0,n)}dequeue(){let e=nd(this,sl,"f").shift();return e?.run}filter(e){return nd(this,sl,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return nd(this,sl,"f").length}};sl=new WeakMap;var kr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ie=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},tn,Xy,Zy,sf,Q8,Jy,H8,qo,Qy,ls,G8,us,eg,nf,j8,YX,QX,eZ,XX,ZX,JX,W8,bR,vR,X8,Y8,Eve=new Wy,_R=class extends Error{},tg=class extends tZ.default{constructor(e){var t,n,i,s;if(super(),tn.add(this),Xy.set(this,void 0),Zy.set(this,void 0),sf.set(this,0),Q8.set(this,void 0),Jy.set(this,void 0),H8.set(this,0),qo.set(this,void 0),Qy.set(this,void 0),ls.set(this,void 0),G8.set(this,void 0),us.set(this,0),eg.set(this,void 0),nf.set(this,void 0),j8.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Yy,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);kr(this,Xy,e.carryoverConcurrencyCount,"f"),kr(this,Zy,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),kr(this,Q8,e.intervalCap,"f"),kr(this,Jy,e.interval,"f"),kr(this,ls,new e.queueClass,"f"),kr(this,G8,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,kr(this,j8,e.throwOnTimeout===!0,"f"),kr(this,nf,e.autoStart===!1,"f")}get concurrency(){return Ie(this,eg,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);kr(this,eg,e,"f"),Ie(this,tn,"m",X8).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;kr(this,us,(a=Ie(this,us,"f"),a++,a),"f"),kr(this,sf,(c=Ie(this,sf,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new _R("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):wR(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Ie(this,j8,"f"):t.throwOnTimeout)&&i(Eve)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Ie(this,tn,"m",eZ).call(this)};Ie(this,ls,"f").enqueue(s,t),Ie(this,tn,"m",W8).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Ie(this,nf,"f")?(kr(this,nf,!1,"f"),Ie(this,tn,"m",X8).call(this),this):this}pause(){kr(this,nf,!0,"f")}clear(){kr(this,ls,new(Ie(this,G8,"f")),"f")}async onEmpty(){Ie(this,ls,"f").size!==0&&await Ie(this,tn,"m",Y8).call(this,"empty")}async onSizeLessThan(e){Ie(this,ls,"f").size<e||await Ie(this,tn,"m",Y8).call(this,"next",()=>Ie(this,ls,"f").size<e)}async onIdle(){Ie(this,us,"f")===0&&Ie(this,ls,"f").size===0||await Ie(this,tn,"m",Y8).call(this,"idle")}get size(){return Ie(this,ls,"f").size}sizeBy(e){return Ie(this,ls,"f").filter(e).length}get pending(){return Ie(this,us,"f")}get isPaused(){return Ie(this,nf,"f")}};Xy=new WeakMap,Zy=new WeakMap,sf=new WeakMap,Q8=new WeakMap,Jy=new WeakMap,H8=new WeakMap,qo=new WeakMap,Qy=new WeakMap,ls=new WeakMap,G8=new WeakMap,us=new WeakMap,eg=new WeakMap,nf=new WeakMap,j8=new WeakMap,tn=new WeakSet,YX=function(){return Ie(this,Zy,"f")||Ie(this,sf,"f")<Ie(this,Q8,"f")},QX=function(){return Ie(this,us,"f")<Ie(this,eg,"f")},eZ=function(){var e;kr(this,us,(e=Ie(this,us,"f"),e--,e),"f"),Ie(this,tn,"m",W8).call(this),this.emit("next")},XX=function(){this.emit("empty"),Ie(this,us,"f")===0&&this.emit("idle")},ZX=function(){Ie(this,tn,"m",vR).call(this),Ie(this,tn,"m",bR).call(this),kr(this,Qy,void 0,"f")},JX=function(){let e=Date.now();if(Ie(this,qo,"f")===void 0){let t=Ie(this,H8,"f")-e;if(t<0)kr(this,sf,Ie(this,Xy,"f")?Ie(this,us,"f"):0,"f");else return Ie(this,Qy,"f")===void 0&&kr(this,Qy,setTimeout(()=>{Ie(this,tn,"m",ZX).call(this)},t),"f"),!0}return!1},W8=function(){if(Ie(this,ls,"f").size===0)return Ie(this,qo,"f")&&clearInterval(Ie(this,qo,"f")),kr(this,qo,void 0,"f"),Ie(this,tn,"m",XX).call(this),!1;if(!Ie(this,nf,"f")){let e=!Ie(this,tn,"a",JX);if(Ie(this,tn,"a",YX)&&Ie(this,tn,"a",QX)){let t=Ie(this,ls,"f").dequeue();return t?(this.emit("active"),t(),e&&Ie(this,tn,"m",bR).call(this),!0):!1}}return!1},bR=function(){Ie(this,Zy,"f")||Ie(this,qo,"f")!==void 0||(kr(this,qo,setInterval(()=>{Ie(this,tn,"m",vR).call(this)},Ie(this,Jy,"f")),"f"),kr(this,H8,Date.now()+Ie(this,Jy,"f"),"f"))},vR=function(){Ie(this,sf,"f")===0&&Ie(this,us,"f")===0&&Ie(this,qo,"f")&&(clearInterval(Ie(this,qo,"f")),kr(this,qo,void 0,"f")),kr(this,sf,Ie(this,Xy,"f")?Ie(this,us,"f"):0,"f"),Ie(this,tn,"m",X8).call(this)},X8=function(){for(;Ie(this,tn,"m",W8).call(this););},Y8=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var nZ=E(V(),1),SR=E(ai(),1);var id=C("libp2p-delegated-peer-routing"),rZ=3e4,bve=4,Z8=class{constructor(e){if(e==null)throw new Error("missing ipfs http client");this.client=e,this.started=!1,this.abortController=new AbortController,this.httpQueue=new tg({concurrency:bve});let{protocol:t,host:n,port:i}=e.getEndpointConfig();id(`enabled DelegatedPeerRouting via ${t}://${n}:${i}`)}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.abortController.abort(),this.abortController=new AbortController,this.started=!1}async findPeer(e,t={}){id("findPeer starts: %p",e),t.timeout=t.timeout??rZ,t.signal=(0,SR.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[]));let n=lr(),i=lr();this.httpQueue.add(async()=>(n.resolve(),await i.promise));try{await n.promise;for await(let s of this.client.dht.findPeer(e,t))if(s.name==="FINAL_PEER")return{id:s.peer.id,multiaddrs:s.peer.multiaddrs,protocols:[]}}catch(s){throw id.error("findPeer errored: %o",s),s}finally{i.resolve(),id("findPeer finished: %p",e)}throw(0,nZ.default)(new Error("Not found"),"ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){let n,i=A.asCID(e);i!=null?n=i:n=Ir(e),id("getClosestPeers starts: %s",n),t.timeout=t.timeout??rZ,t.signal=(0,SR.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[]));let s=lr(),o=lr();this.httpQueue.add(async()=>(s.resolve(),await o.promise));try{await s.promise;for await(let a of this.client.dht.query(n,t))a.name==="PEER_RESPONSE"&&(yield*a.closer.map(c=>({id:c.id,multiaddrs:c.multiaddrs,protocols:[]})))}catch(a){throw id.error("getClosestPeers errored:",a),a}finally{o.resolve(),id("getClosestPeers finished: %b",e)}}};u();var PR=E(fi(),1);u();var hZ=E(Hl(),1);u();var rg=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},xR=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},iZ=r=>globalThis.DOMException===void 0?new xR(r):new DOMException(r),sZ=r=>{let e=r.reason===void 0?iZ("This operation was aborted."):r.reason;return e instanceof Error?e:iZ(e)};function TR(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(sZ(c)),c.addEventListener("abort",()=>{a(sZ(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new rg(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function IR(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var sd=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},ol,ng=class{constructor(){ol.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&sd(this,ol,"f")[this.size-1].priority>=t.priority){sd(this,ol,"f").push(n);return}let i=IR(sd(this,ol,"f"),n,(s,o)=>o.priority-s.priority);sd(this,ol,"f").splice(i,0,n)}dequeue(){let e=sd(this,ol,"f").shift();return e?.run}filter(e){return sd(this,ol,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return sd(this,ol,"f").length}};ol=new WeakMap;var Nr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Ae=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},rn,sg,og,af,iE,ag,J8,zo,ig,fs,eE,hs,cg,of,tE,oZ,aZ,fZ,cZ,lZ,uZ,rE,AR,RR,sE,nE,vve=new rg,CR=class extends Error{},q0=class extends hZ.default{constructor(e){var t,n,i,s;if(super(),rn.add(this),sg.set(this,void 0),og.set(this,void 0),af.set(this,0),iE.set(this,void 0),ag.set(this,void 0),J8.set(this,0),zo.set(this,void 0),ig.set(this,void 0),fs.set(this,void 0),eE.set(this,void 0),hs.set(this,0),cg.set(this,void 0),of.set(this,void 0),tE.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:ng,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);Nr(this,sg,e.carryoverConcurrencyCount,"f"),Nr(this,og,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Nr(this,iE,e.intervalCap,"f"),Nr(this,ag,e.interval,"f"),Nr(this,fs,new e.queueClass,"f"),Nr(this,eE,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Nr(this,tE,e.throwOnTimeout===!0,"f"),Nr(this,of,e.autoStart===!1,"f")}get concurrency(){return Ae(this,cg,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Nr(this,cg,e,"f"),Ae(this,rn,"m",sE).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Nr(this,hs,(a=Ae(this,hs,"f"),a++,a),"f"),Nr(this,af,(c=Ae(this,af,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new CR("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):TR(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Ae(this,tE,"f"):t.throwOnTimeout)&&i(vve)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Ae(this,rn,"m",fZ).call(this)};Ae(this,fs,"f").enqueue(s,t),Ae(this,rn,"m",rE).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Ae(this,of,"f")?(Nr(this,of,!1,"f"),Ae(this,rn,"m",sE).call(this),this):this}pause(){Nr(this,of,!0,"f")}clear(){Nr(this,fs,new(Ae(this,eE,"f")),"f")}async onEmpty(){Ae(this,fs,"f").size!==0&&await Ae(this,rn,"m",nE).call(this,"empty")}async onSizeLessThan(e){Ae(this,fs,"f").size<e||await Ae(this,rn,"m",nE).call(this,"next",()=>Ae(this,fs,"f").size<e)}async onIdle(){Ae(this,hs,"f")===0&&Ae(this,fs,"f").size===0||await Ae(this,rn,"m",nE).call(this,"idle")}get size(){return Ae(this,fs,"f").size}sizeBy(e){return Ae(this,fs,"f").filter(e).length}get pending(){return Ae(this,hs,"f")}get isPaused(){return Ae(this,of,"f")}};sg=new WeakMap,og=new WeakMap,af=new WeakMap,iE=new WeakMap,ag=new WeakMap,J8=new WeakMap,zo=new WeakMap,ig=new WeakMap,fs=new WeakMap,eE=new WeakMap,hs=new WeakMap,cg=new WeakMap,of=new WeakMap,tE=new WeakMap,rn=new WeakSet,oZ=function(){return Ae(this,og,"f")||Ae(this,af,"f")<Ae(this,iE,"f")},aZ=function(){return Ae(this,hs,"f")<Ae(this,cg,"f")},fZ=function(){var e;Nr(this,hs,(e=Ae(this,hs,"f"),e--,e),"f"),Ae(this,rn,"m",rE).call(this),this.emit("next")},cZ=function(){this.emit("empty"),Ae(this,hs,"f")===0&&this.emit("idle")},lZ=function(){Ae(this,rn,"m",RR).call(this),Ae(this,rn,"m",AR).call(this),Nr(this,ig,void 0,"f")},uZ=function(){let e=Date.now();if(Ae(this,zo,"f")===void 0){let t=Ae(this,J8,"f")-e;if(t<0)Nr(this,af,Ae(this,sg,"f")?Ae(this,hs,"f"):0,"f");else return Ae(this,ig,"f")===void 0&&Nr(this,ig,setTimeout(()=>{Ae(this,rn,"m",lZ).call(this)},t),"f"),!0}return!1},rE=function(){if(Ae(this,fs,"f").size===0)return Ae(this,zo,"f")&&clearInterval(Ae(this,zo,"f")),Nr(this,zo,void 0,"f"),Ae(this,rn,"m",cZ).call(this),!1;if(!Ae(this,of,"f")){let e=!Ae(this,rn,"a",uZ);if(Ae(this,rn,"a",oZ)&&Ae(this,rn,"a",aZ)){let t=Ae(this,fs,"f").dequeue();return t?(this.emit("active"),t(),e&&Ae(this,rn,"m",AR).call(this),!0):!1}}return!1},AR=function(){Ae(this,og,"f")||Ae(this,zo,"f")!==void 0||(Nr(this,zo,setInterval(()=>{Ae(this,rn,"m",RR).call(this)},Ae(this,ag,"f")),"f"),Nr(this,J8,Date.now()+Ae(this,ag,"f"),"f"))},RR=function(){Ae(this,af,"f")===0&&Ae(this,hs,"f")===0&&Ae(this,zo,"f")&&(clearInterval(Ae(this,zo,"f")),Nr(this,zo,void 0,"f")),Nr(this,af,Ae(this,sg,"f")?Ae(this,hs,"f"):0,"f"),Ae(this,rn,"m",sE).call(this)},sE=function(){for(;Ae(this,rn,"m",rE).call(this););},nE=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var dZ=E(V(),1),lg=E(ai(),1),Ya=C("libp2p:delegated-content-routing"),oE=3e4,_ve=4,Sve=2,aE=class{constructor(e){if(e==null)throw new Error("missing ipfs http client");this.client=e,this.started=!1,this.abortController=new AbortController,this.httpQueue=new q0({concurrency:_ve}),this.httpQueueRefs=new q0({concurrency:Sve});let{protocol:t,host:n,port:i}=e.getEndpointConfig();Ya(`enabled DelegatedContentRouting via ${t}://${n}:${i}`)}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.httpQueueRefs.clear(),this.abortController.abort(),this.abortController=new AbortController,this.started=!1}async*findProviders(e,t={}){Ya("findProviders starts: %c",e),t.timeout=t.timeout??oE,t.signal=(0,lg.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[]));let n=lr(),i=lr();this.httpQueue.add(async()=>(n.resolve(),await i.promise));try{await n.promise;for await(let s of this.client.dht.findProvs(e,t))s.name==="PROVIDER"&&(yield*s.providers.map(o=>({id:o.id,protocols:[],multiaddrs:o.multiaddrs})))}catch(s){throw Ya.error("findProviders errored:",s),s}finally{i.resolve(),Ya("findProviders finished: %c",e)}}async provide(e,t={}){Ya("provide starts: %c",e),t.timeout=t.timeout??oE,t.signal=(0,lg.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[])),await this.httpQueueRefs.add(async()=>{await this.client.block.stat(e,t),await(0,PR.default)(this.client.dht.provide(e,t))}),Ya("provide finished: %c",e)}async put(e,t,n={}){Ya("put value start: %b",e),n.timeout=n.timeout??oE,n.signal=(0,lg.default)([this.abortController.signal].concat(n.signal!=null?[n.signal]:[])),await this.httpQueue.add(async()=>{await(0,PR.default)(this.client.dht.put(e,t,n))}),Ya("put value finished: %b",e)}async get(e,t={}){return Ya("get value start: %b",e),t.timeout=t.timeout??oE,t.signal=(0,lg.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[])),await this.httpQueue.add(async()=>{for await(let n of this.client.dht.get(e,t))if(n.name==="VALUE")return Ya("get value finished: %b",e),n.value;throw(0,dZ.default)(new Error("Not found"),"ERR_NOT_FOUND")})}};u();u();var xve=r=>Promise.reject(new Error(`No base found for "${r}"`)),z0=class{constructor(e){this._basesByName={},this._basesByPrefix={},this._loadBase=e.loadBase||xve;for(let t of e.bases)this.addBase(t)}addBase(e){if(this._basesByName[e.name]||this._basesByPrefix[e.prefix])throw new Error(`Codec already exists for codec "${e.name}"`);this._basesByName[e.name]=e,this._basesByPrefix[e.prefix]=e}removeBase(e){delete this._basesByName[e.name],delete this._basesByPrefix[e.prefix]}async getBase(e){if(this._basesByName[e])return this._basesByName[e];if(this._basesByPrefix[e])return this._basesByPrefix[e];let t=await this._loadBase(e);return this._basesByName[t.name]==null&&this._basesByPrefix[t.prefix]==null&&this.addBase(t),t}listBases(){return Object.values(this._basesByName)}};u();var Tve=r=>Promise.reject(new Error(`No codec found for "${r}"`)),$0=class{constructor(e){this._codecsByName={},this._codecsByCode={},this._loadCodec=e.loadCodec||Tve;for(let t of e.codecs)this.addCodec(t)}addCodec(e){if(this._codecsByName[e.name]||this._codecsByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._codecsByName[e.name]=e,this._codecsByCode[e.code]=e}removeCodec(e){delete this._codecsByName[e.name],delete this._codecsByCode[e.code]}async getCodec(e){let t=typeof e=="string"?this._codecsByName:this._codecsByCode;if(t[e])return t[e];let n=await this._loadCodec(e);return t[e]==null&&this.addCodec(n),n}listCodecs(){return Object.values(this._codecsByName)}};u();var Ive=r=>Promise.reject(new Error(`No hasher found for "${r}"`)),H0=class{constructor(e){this._hashersByName={},this._hashersByCode={},this._loadHasher=e.loadHasher||Ive;for(let t of e.hashers)this.addHasher(t)}addHasher(e){if(this._hashersByName[e.name]||this._hashersByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._hashersByName[e.name]=e,this._hashersByCode[e.code]=e}removeHasher(e){delete this._hashersByName[e.name],delete this._hashersByCode[e.code]}async getHasher(e){let t=typeof e=="string"?this._hashersByName:this._hashersByCode;if(t[e])return t[e];let n=await this._loadHasher(e);return t[e]==null&&this.addHasher(n),n}listHashers(){return Object.values(this._hashersByName)}};u();u();u();u();var Qa=E(Nv(),1);var od=E(cp(),1);u();function DR(r){try{r=o0(se(r))}catch{}return r=r.toString(),r}u();var pZ=()=>{};var mZ=C("ipfs-http-client:lib:error-handler"),Ave=Qe.bind({ignoreUndefined:!0}),Rve=Qa.isBrowser||Qa.isWebWorker?location.protocol:"http",Cve=Qa.isBrowser||Qa.isWebWorker?location.hostname:"localhost",Pve=Qa.isBrowser||Qa.isWebWorker?location.port:"5001",Dve=(r={})=>{let e,t={},n;if(typeof r=="string"||Ec(r))e=new URL(DR(r));else if(r instanceof URL)e=r;else if(typeof r.url=="string"||Ec(r.url))e=new URL(DR(r.url)),t=r;else if(r.url instanceof URL)e=r.url,t=r;else{t=r||{};let i=(t.protocol||Rve).replace(":",""),s=(t.host||Cve).split(":")[0],o=t.port||Pve;e=new URL(`${i}://${s}:${o}`)}if(t.apiPath?e.pathname=t.apiPath:(e.pathname==="/"||e.pathname===void 0)&&(e.pathname="api/v0"),Qa.isNode){let i=pZ(e);n=t.agent||new i({keepAlive:!0,maxSockets:6})}return{...t,host:e.host,protocol:e.protocol.replace(":",""),port:Number(e.port),apiPath:e.pathname,url:e,agent:n}},Ove=async r=>{let e;try{if((r.headers.get("Content-Type")||"").startsWith("application/json")){let n=await r.json();mZ(n),e=n.Message||n.message}else e=await r.text()}catch(n){mZ("Failed to parse error response",n),e=n.message}let t=new od.default.HTTPError(r);throw e&&(e.includes("deadline has elapsed")&&(t=new od.default.TimeoutError),e&&e.includes("context deadline exceeded")&&(t=new od.default.TimeoutError)),e&&e.includes("request timed out")&&(t=new od.default.TimeoutError),e&&(t.message=e),t},kve=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,yZ=r=>r.replace(kve,function(e){return"-"+e.toLowerCase()}),Nve=r=>typeof r=="string"?ql(r):r,cf=class extends od.default{constructor(e={}){let t=Dve(e);super({timeout:Nve(t.timeout||0)||void 0,headers:t.headers,base:`${t.url}`,handleError:Ove,transformSearchParams:i=>{let s=new URLSearchParams;for(let[o,a]of i)a!=="undefined"&&a!=="null"&&o!=="signal"&&s.append(yZ(o),a),o==="timeout"&&!isNaN(a)&&s.append(yZ(o),a);return s},agent:t.agent}),delete this.get,delete this.put,delete this.delete,delete this.options;let n=this.fetch;this.fetch=(i,s={})=>(typeof i=="string"&&!i.startsWith("/")&&(i=`${t.url}/${i}`),n.call(this,i,Ave(s,{method:"POST"})))}},bit=od.default.HTTPError;var D=r=>e=>r(new cf(e),e);u();u();function cE(r){if(r!=null)return typeof r=="string"?r:r.toString(8).padStart(4,"0")}u();var gZ=E(V(),1);function lE(r){if(r==null)return;let e;if(r.secs!=null&&(e={secs:r.secs,nsecs:r.nsecs}),r.Seconds!=null&&(e={secs:r.Seconds,nsecs:r.FractionalNanoseconds}),Array.isArray(r)&&(e={secs:r[0],nsecs:r[1]}),r instanceof Date){let t=r.getTime(),n=Math.floor(t/1e3);e={secs:n,nsecs:(t-n*1e3)*1e3}}if(!!Object.prototype.hasOwnProperty.call(e,"secs")){if(e!=null&&e.nsecs!=null&&(e.nsecs<0||e.nsecs>999999999))throw(0,gZ.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}function k({arg:r,searchParams:e,hashAlg:t,mtime:n,mode:i,...s}={}){e&&(s={...s,...e}),t&&(s.hash=t),n!=null&&(n=lE(n),s.mtime=n.secs,s.mtimeNsecs=n.nsecs),i!=null&&(s.mode=cE(i)),s.timeout&&!isNaN(s.timeout)&&(s.timeout=`${s.timeout}ms`),r==null?r=[]:Array.isArray(r)||(r=[r]);let o=new URLSearchParams(s);return r.forEach(a=>o.append("arg",a)),o}var wZ=D(r=>{async function e(t={}){return((await(await r.post("bitswap/wantlist",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()).Keys||[]).map(i=>A.parse(i["/"]))}return e});u();var EZ=D(r=>{async function e(t,n={}){return((await(await r.post("bitswap/wantlist",{signal:n.signal,searchParams:k({...n,peer:t.toString()}),headers:n.headers})).json()).Keys||[]).map(s=>A.parse(s["/"]))}return e});u();var uE=D(r=>{async function e(t={}){let n=await r.post("bitswap/stat",{searchParams:k(t),signal:t.signal,headers:t.headers});return Lve(await n.json())}return e});function Lve(r){return{provideBufLen:r.ProvideBufLen,wantlist:(r.Wantlist||[]).map(e=>A.parse(e["/"])),peers:(r.Peers||[]).map(e=>pe(e)),blocksReceived:BigInt(r.BlocksReceived),dataReceived:BigInt(r.DataReceived),blocksSent:BigInt(r.BlocksSent),dataSent:BigInt(r.DataSent),dupBlksReceived:BigInt(r.DupBlksReceived),dupDataReceived:BigInt(r.DupDataReceived)}}u();var bZ=D(r=>{async function e(t,n={}){return(await r.post("bitswap/unwant",{signal:n.signal,searchParams:k({arg:t.toString(),...n}),headers:n.headers})).json()}return e});function vZ(r){return{wantlist:wZ(r),wantlistForPeer:EZ(r),unwant:bZ(r),stat:uE(r)}}u();u();var fE=D(r=>{async function e(t,n={}){let i=await r.post("block/get",{signal:n.signal,searchParams:k({arg:t.toString(),...n}),headers:n.headers});return new Uint8Array(await i.arrayBuffer())}return e});u();u();u();u();var SZ=E(V(),1),xZ=E(Wp(),1),TZ=E(jp(),1),IZ=E(Ro(),1);async function AZ(r){if(Us(r))return new Blob([r]);if(typeof r=="string"||r instanceof String)return new Blob([r.toString()]);if(Uc(r))return r;if(Fc(r)&&(r=(0,TZ.default)(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let e=(0,xZ.default)(r),{value:t,done:n}=await e.peek();if(n)return _Z(e);if(e.push(t),Number.isInteger(t))return new Blob([Uint8Array.from(await(0,IZ.default)(e))]);if(Us(t)||typeof t=="string"||t instanceof String)return _Z(e)}throw(0,SZ.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT")}async function _Z(r){let e=[];for await(let t of r)e.push(t);return new Blob(e)}function RZ(r){return C6(r,AZ,!0)}u();function CZ(r){if(r!=null)return typeof r=="string"?r:r.toString(8).padStart(4,"0")}async function dn(r,e,t={}){let n=[],i=new FormData,s=0,o=0;for await(let{content:a,path:c,mode:l,mtime:f}of RZ(r)){let h="",p=a?"file":"dir";s>0&&(h=`-${s}`);let d=p+h,m=[];if(l!=null&&m.push(`mode=${CZ(l)}`),f!=null){let{secs:y,nsecs:g}=f;m.push(`mtime=${y}`),g!=null&&m.push(`mtime-nsecs=${g}`)}if(m.length&&(d=`${d}?${m.join("&")}`),a){i.set(d,a,c!=null?encodeURIComponent(c):void 0);let y=o+a.size;n.push({name:c,start:o,end:y}),o=y}else if(c!=null)i.set(d,new File([""],encodeURIComponent(c),{type:"application/x-directory"}));else throw new Error("path or content or both must be set");s++}return{total:o,parts:n,headers:t,body:i}}u();var PZ=E(ai(),1);function Bve(r){return r.filter(Boolean)}function pn(...r){return(0,PZ.anySignal)(Bve(r))}var DZ=D(r=>{async function e(t,n={}){let i=new AbortController,s=pn(i.signal,n.signal),o;try{o=await(await r.post("block/put",{signal:s,searchParams:k(n),...await dn([t],i,n.headers)})).json()}catch(a){if(n.format==="dag-pb")return e(t,{...n,format:"protobuf"});if(n.format==="dag-cbor")return e(t,{...n,format:"cbor"});throw a}return A.parse(o.Key)}return e});u();var OZ=D(r=>{async function*e(t,n={}){Array.isArray(t)||(t=[t]);let i=await r.post("block/rm",{signal:n.signal,searchParams:k({arg:t.map(s=>s.toString()),"stream-channels":!0,...n}),headers:n.headers});for await(let s of i.ndjson())yield Mve(s)}return e});function Mve(r){let e={cid:A.parse(r.Hash)};return r.Error&&(e.error=new Error(r.Error)),e}u();var kZ=D(r=>{async function e(t,n={}){let s=await(await r.post("block/stat",{signal:n.signal,searchParams:k({arg:t.toString(),...n}),headers:n.headers})).json();return{cid:A.parse(s.Key),size:s.Size}}return e});function NZ(r){return{get:fE(r),put:DZ(r),rm:OZ(r),stat:kZ(r)}}u();u();var LZ=D(r=>{async function e(t,n={}){let i=await r.post("bootstrap/add",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers}),{Peers:s}=await i.json();return{Peers:s.map(o=>se(o))}}return e});u();var BZ=D(r=>{async function e(t={}){let n=await r.post("bootstrap/rm",{signal:t.signal,searchParams:k({...t,all:!0}),headers:t.headers}),{Peers:i}=await n.json();return{Peers:i.map(s=>se(s))}}return e});u();var MZ=D(r=>{async function e(t={}){let n=await r.post("bootstrap/list",{signal:t.signal,searchParams:k(t),headers:t.headers}),{Peers:i}=await n.json();return{Peers:i.map(s=>se(s))}}return e});u();var UZ=D(r=>{async function e(t={}){let n=await r.post("bootstrap/add",{signal:t.signal,searchParams:k({...t,default:!0}),headers:t.headers}),{Peers:i}=await n.json();return{Peers:i.map(s=>se(s))}}return e});u();var FZ=D(r=>{async function e(t,n={}){let i=await r.post("bootstrap/rm",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers}),{Peers:s}=await i.json();return{Peers:s.map(o=>se(o))}}return e});function VZ(r){return{add:LZ(r),clear:BZ(r),list:MZ(r),reset:UZ(r),rm:FZ(r)}}u();u();u();var KZ=D(r=>{async function e(t,n={}){let s=await(await r.post("config/profile/apply",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json();return{original:s.OldCfg,updated:s.NewCfg}}return e});u();u();function bt(r){if(r==null)return r;let e=/^[A-Z]+$/,t={};return Object.keys(r).reduce((n,i)=>(e.test(i)?n[i.toLowerCase()]=r[i]:e.test(i[0])?n[i[0].toLowerCase()+i.slice(1)]=r[i]:n[i]=r[i],n),t)}var qZ=D(r=>{async function e(t={}){return(await(await r.post("config/profile/list",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()).map(s=>bt(s))}return e});function zZ(r){return{apply:KZ(r),list:qZ(r)}}u();var $Z=D(r=>async(t,n={})=>{if(!t)throw new Error("key argument is required");return(await(await r.post("config",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json()).Value});u();var HZ=D(r=>async(t={})=>await(await r.post("config/show",{signal:t.signal,searchParams:k({...t}),headers:t.headers})).json());u();var GZ=D(r=>async(t,n={})=>{let i=new AbortController,s=pn(i.signal,n.signal);await(await r.post("config/replace",{signal:s,searchParams:k(n),...await dn([z(JSON.stringify(t))],i,n.headers)})).text()});u();var jZ=D(r=>async(t,n,i={})=>{if(typeof t!="string")throw new Error("Invalid key type");let s={...i,...Uve(t,n)};await(await r.post("config",{signal:i.signal,searchParams:k(s),headers:i.headers})).text()}),Uve=(r,e)=>{switch(typeof e){case"boolean":return{arg:[r,e.toString()],bool:!0};case"string":return{arg:[r,e]};default:return{arg:[r,JSON.stringify(e)],json:!0}}};function WZ(r){return{getAll:HZ(r),get:$Z(r),set:jZ(r),replace:GZ(r),profiles:zZ(r)}}u();u();var YZ=D(r=>{async function*e(t,n={}){yield*(await r.post("dag/export",{signal:n.signal,searchParams:k({arg:t.toString()}),headers:n.headers})).iterator()}return e});u();u();var OR=E(V(),1);async function*kR(r,e,t,n,i){let s=async l=>{let f=await t.getCodec(l.code),h=await n(l,i);return f.decode(h)},o=e.split("/").filter(Boolean),a=await s(r),c=r;for(;o.length;){let l=o.shift();if(!l)throw(0,OR.default)(new Error(`Could not resolve path "${e}"`),"ERR_INVALID_PATH");if(Object.prototype.hasOwnProperty.call(a,l))a=a[l],yield{value:a,remainderPath:o.join("/")};else throw(0,OR.default)(new Error(`no link named "${l}" under ${c}`),"ERR_NO_LINK");let f=A.asCID(a);f&&(c=f,a=await s(a))}yield{value:a,remainderPath:""}}var QZ=E(Oa(),1),XZ=E(vi(),1),ZZ=E(V(),1);var JZ=(r,e)=>D((n,i)=>{let s=fE(i);return async(a,c={})=>{if(c.path){let d=c.localResolve?await(0,QZ.default)(kR(a,c.path,r,s,c)):await(0,XZ.default)(kR(a,c.path,r,s,c));if(!d)throw(0,ZZ.default)(new Error("Not found"),"ERR_NOT_FOUND");return d}let l=await r.getCodec(a.code),f=await s(a,c);return{value:l.decode(f),remainderPath:""}}})(e);u();var eJ=D(r=>{async function*e(t,n={}){let i=new AbortController,s=pn(i.signal,n.signal),{headers:o,body:a}=await dn(t,i,n.headers),c=await r.post("dag/import",{signal:s,headers:o,body:a,searchParams:k({"pin-roots":n.pinRoots})});for await(let{Root:l}of c.ndjson())if(l!==void 0){let{Cid:{"/":f},PinErrorMsg:h}=l;yield{root:{cid:A.parse(f),pinErrorMsg:h}}}}return e});u();var hE=(r,e)=>D(n=>async(s,o={})=>{let a={storeCodec:"dag-cbor",hashAlg:"sha2-256",...o},c;if(a.inputCodec){if(!(s instanceof Uint8Array))throw new Error("Can only inputCodec on raw bytes that can be decoded");c=s}else c=(await r.getCodec(a.storeCodec)).encode(s),a.inputCodec=a.storeCodec;let l=new AbortController,f=pn(l.signal,a.signal),p=await(await n.post("dag/put",{timeout:a.timeout,signal:f,searchParams:k(a),...await dn([c],l,a.headers)})).json();return A.parse(p.Cid["/"])})(e);u();var tJ=D(r=>async(t,n={})=>{let s=await(await r.post("dag/resolve",{signal:n.signal,searchParams:k({arg:`${t}${n.path?`/${n.path}`.replace(/\/[/]+/g,"/"):""}`,...n}),headers:n.headers})).json();return{cid:A.parse(s.Cid["/"]),remainderPath:s.RemPath}});function rJ(r,e){return{export:YZ(e),get:JZ(r,e),import:eJ(e),put:hE(r,e),resolve:tJ(e)}}u();u();u();u();var js=r=>{if(r.Type===0)return{name:"SENDING_QUERY",type:r.Type};if(r.Type===1)return{from:pe(r.ID),name:"PEER_RESPONSE",type:r.Type,messageType:0,messageName:"PUT_VALUE",closer:(r.Responses||[]).map(({ID:e,Addrs:t})=>({id:pe(e),multiaddrs:t.map(n=>se(n)),protocols:[]})),providers:(r.Responses||[]).map(({ID:e,Addrs:t})=>({id:pe(e),multiaddrs:t.map(n=>se(n)),protocols:[]}))};if(r.Type===2){let e={id:r.ID??pe(r.ID),multiaddrs:[],protocols:[]};return r.Responses&&r.Responses.length&&(e={id:pe(r.Responses[0].ID),multiaddrs:r.Responses[0].Addrs.map(t=>se(t)),protocols:[]}),{name:"FINAL_PEER",type:r.Type,peer:e}}if(r.Type===3)return{name:"QUERY_ERROR",type:r.Type,error:new Error(r.Extra)};if(r.Type===4)return{name:"PROVIDER",type:r.Type,providers:r.Responses.map(({ID:e,Addrs:t})=>({id:pe(e),multiaddrs:t.map(n=>se(n)),protocols:[]}))};if(r.Type===5)return{name:"VALUE",type:r.Type,value:z(r.Extra,"base64pad")};if(r.Type===6){let e=r.Responses.map(({ID:t})=>pe(t));if(!e.length)throw new Error("No peer found");return{name:"ADDING_PEER",type:r.Type,peer:e[0]}}if(r.Type===7)return{name:"DIALING_PEER",type:r.Type,peer:pe(r.ID)};throw new Error("Unknown DHT event type")};var nJ=D(r=>{async function*e(t,n={}){let i=await r.post("dht/findpeer",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers});for await(let s of i.ndjson())yield js(s)}return e});u();var iJ=D(r=>{async function*e(t,n={}){let i=await r.post("dht/findprovs",{signal:n.signal,searchParams:k({arg:t.toString(),...n}),headers:n.headers});for await(let s of i.ndjson())yield js(s)}return e});u();var sJ=D(r=>{async function*e(t,n={}){let i=await r.post("dht/get",{signal:n.signal,searchParams:k({arg:t instanceof Uint8Array?K(t):t.toString(),...n}),headers:n.headers});for await(let s of i.ndjson())yield js(s)}return e});u();var oJ=D(r=>{async function*e(t,n={recursive:!1}){let i=Array.isArray(t)?t:[t],s=await r.post("dht/provide",{signal:n.signal,searchParams:k({arg:i.map(o=>o.toString()),...n}),headers:n.headers});for await(let o of s.ndjson())yield js(o)}return e});u();var aJ=D(r=>{async function*e(t,n,i={}){let s=new AbortController,o=pn(s.signal,i.signal),a=await r.post("dht/put",{signal:o,searchParams:k({arg:t instanceof Uint8Array?K(t):t.toString(),...i}),...await dn([n],s,i.headers)});for await(let c of a.ndjson())yield js(c)}return e});u();var cJ=D(r=>{async function*e(t,n={}){let i=await r.post("dht/query",{signal:n.signal,searchParams:k({arg:t.toString(),...n}),headers:n.headers});for await(let s of i.ndjson())yield js(s)}return e});function lJ(r){return{findPeer:nJ(r),findProvs:iJ(r),get:sJ(r),provide:oJ(r),put:aJ(r),query:cJ(r)}}u();u();var uJ=D(r=>{async function e(t={}){return(await r.post("diag/cmds",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()}return e});u();var fJ=D(r=>{async function e(t={}){return(await r.post("diag/net",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()}return e});u();var hJ=D(r=>{async function e(t={}){return(await r.post("diag/sys",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()}return e});function dJ(r){return{cmds:uJ(r),net:fJ(r),sys:hJ(r)}}u();u();var pJ=D(r=>{async function e(t,n,i={}){await(await r.post("files/chmod",{signal:i.signal,searchParams:k({arg:t,mode:n,...i}),headers:i.headers})).text()}return e});u();var mJ=D(r=>{async function e(t,n,i={}){let s=Array.isArray(t)?t:[t];await(await r.post("files/cp",{signal:i.signal,searchParams:k({arg:s.concat(n).map(a=>A.asCID(a)?`/ipfs/${a}`:a),...i}),headers:i.headers})).text()}return e});u();var yJ=D(r=>{async function e(t,n={}){if(!t||typeof t!="string")throw new Error("ipfs.files.flush requires a path");let s=await(await r.post("files/flush",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json();return A.parse(s.Cid)}return e});u();u();function ug(r){let e=bt(r);return Object.prototype.hasOwnProperty.call(e,"mode")&&(e.mode=parseInt(e.mode,8)),Object.prototype.hasOwnProperty.call(e,"mtime")&&(e.mtime={secs:e.mtime,nsecs:e.mtimeNsecs||0},delete e.mtimeNsecs),e}var wJ=D(r=>{async function*e(t,n={}){if(!t)throw new Error("ipfs.files.ls requires a path");let i=await r.post("files/ls",{signal:n.signal,searchParams:k({arg:A.asCID(t)?`/ipfs/${t}`:t,long:!0,...n,stream:!0}),headers:n.headers});for await(let s of i.ndjson())if("Entries"in s)for(let o of s.Entries||[])yield gJ(ug(o));else yield gJ(ug(s))}return e});function gJ(r){return r.hash&&(r.cid=A.parse(r.hash)),delete r.hash,r.type=r.type===1?"directory":"file",r}u();var EJ=D(r=>{async function e(t,n={}){await(await r.post("files/mkdir",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).text()}return e});u();var bJ=D(r=>{async function e(t,n,i={}){Array.isArray(t)||(t=[t]),await(await r.post("files/mv",{signal:i.signal,searchParams:k({arg:t.concat(n),...i}),headers:i.headers})).text()}return e});u();var SJ=E(_J(),1),xJ=D(r=>{async function*e(t,n={}){let i=await r.post("files/read",{signal:n.signal,searchParams:k({arg:t,count:n.length,...n}),headers:n.headers});yield*(0,SJ.default)(i.body)}return e});u();var TJ=E(cp(),1),IJ=D(r=>{async function e(t,n={}){let i=await r.post("files/rm",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers}),s=await i.text();if(s!==""){let o=new TJ.default.HTTPError(i);throw o.message=s,o}}return e});u();var dE=D(r=>{async function e(t,n={}){let s=await(await r.post("files/stat",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json();return s.WithLocality=s.WithLocality||!1,jve(ug(s))}return e});function jve(r){return r.cid=A.parse(r.hash),delete r.hash,r}u();var AJ=D(r=>{async function e(t,n={}){await(await r.post("files/touch",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).text()}return e});u();var RJ=D(r=>{async function e(t,n,i={}){let s=new AbortController,o=pn(s.signal,i.signal);await(await r.post("files/write",{signal:o,searchParams:k({arg:t,streamChannels:!0,count:i.length,...i}),...await dn([{content:n,path:"arg",mode:cE(i.mode),mtime:lE(i.mtime)}],s,i.headers)})).text()}return e});function CJ(r){return{chmod:pJ(r),cp:mJ(r),flush:yJ(r),ls:wJ(r),mkdir:EJ(r),mv:bJ(r),read:xJ(r),rm:IJ(r),stat:dE(r),touch:AJ(r),write:RJ(r)}}u();u();var PJ=E(V(),1),DJ=D(r=>async(t,n,i={})=>{throw(0,PJ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});u();var OJ=D(r=>{async function e(t,n={type:"Ed25519"}){let s=await(await r.post("key/gen",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json();return bt(s)}return e});u();var kJ=D(r=>{async function e(t,n,i,s={}){let a=await(await r.post("key/import",{signal:s.signal,searchParams:k({arg:t,pem:n,password:i,...s}),headers:s.headers})).json();return bt(a)}return e});u();var NJ=E(V(),1),LJ=D(r=>async(t,n={})=>{throw(0,NJ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});u();var BJ=D(r=>{async function e(t={}){return((await(await r.post("key/list",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()).Keys||[]).map(s=>bt(s))}return e});u();var MJ=D(r=>{async function e(t,n,i={}){let s=await r.post("key/rename",{signal:i.signal,searchParams:k({arg:[t,n],...i}),headers:i.headers});return bt(await s.json())}return e});u();var UJ=D(r=>{async function e(t,n={}){let s=await(await r.post("key/rm",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json();return bt(s.Keys[0])}return e});function FJ(r){return{export:DJ(r),gen:OJ(r),import:kJ(r),info:LJ(r),list:BJ(r),rename:MJ(r),rm:UJ(r)}}u();u();var VJ=D(r=>{async function e(t,n,i={}){let s=await r.post("log/level",{signal:i.signal,searchParams:k({arg:[t,n],...i}),headers:i.headers});return bt(await s.json())}return e});u();var KJ=D(r=>{async function e(t={}){return(await(await r.post("log/ls",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()).Strings}return e});u();var qJ=D(r=>{async function*e(t={}){yield*(await r.post("log/tail",{signal:t.signal,searchParams:k(t),headers:t.headers})).ndjson()}return e});function zJ(r){return{level:VJ(r),ls:KJ(r),tail:qJ(r)}}u();u();var $J=D(r=>{async function e(t,n={}){let i=await r.post("name/publish",{signal:n.signal,searchParams:k({arg:`${t}`,...n}),headers:n.headers});return bt(await i.json())}return e});u();var HJ=D(r=>{async function*e(t,n={}){let i=await r.post("name/resolve",{signal:n.signal,searchParams:k({arg:t,stream:!0,...n}),headers:n.headers});for await(let s of i.ndjson())yield s.Path}return e});u();u();var GJ=D(r=>{async function e(t,n={}){let i=await r.post("name/pubsub/cancel",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers});return bt(await i.json())}return e});u();var jJ=D(r=>{async function e(t={}){let n=await r.post("name/pubsub/state",{signal:t.signal,searchParams:k(t),headers:t.headers});return bt(await n.json())}return e});u();var WJ=D(r=>{async function e(t={}){return(await(await r.post("name/pubsub/subs",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()).Strings||[]}return e});function YJ(r){return{cancel:GJ(r),state:jJ(r),subs:WJ(r)}}function QJ(r){return{publish:$J(r),resolve:HJ(r),pubsub:YJ(r)}}u();u();var XJ=D(r=>{async function e(t,n={}){let s=await(await r.post("object/data",{signal:n.signal,searchParams:k({arg:`${t instanceof Uint8Array?A.decode(t):t}`,...n}),headers:n.headers})).arrayBuffer();return new Uint8Array(s,0,s.byteLength)}return e});u();var ZJ=D(r=>{async function e(t,n={}){let s=await(await r.post("object/get",{signal:n.signal,searchParams:k({arg:`${t instanceof Uint8Array?A.decode(t):t}`,dataEncoding:"base64",...n}),headers:n.headers})).json();return{Data:z(s.Data,"base64pad"),Links:(s.Links||[]).map(o=>({Name:o.Name,Hash:A.parse(o.Hash),Tsize:o.Size}))}}return e});u();var JJ=D(r=>{async function e(t,n={}){return((await(await r.post("object/links",{signal:n.signal,searchParams:k({arg:`${t instanceof Uint8Array?A.decode(t):t}`,...n}),headers:n.headers})).json()).Links||[]).map(o=>({Name:o.Name,Tsize:o.Size,Hash:A.parse(o.Hash)}))}return e});u();var eee=D(r=>{async function e(t={}){let n=await r.post("object/new",{signal:t.signal,searchParams:k({arg:t.template,...t}),headers:t.headers}),{Hash:i}=await n.json();return A.parse(i)}return e});u();var tee=(r,e)=>D(n=>{let i=hE(r,e);async function s(o,a={}){return i(o,{...a,storeCodec:"dag-pb",hashAlg:"sha2-256",version:1})}return s})(e);u();var ree=D(r=>{async function e(t,n={}){let s=await(await r.post("object/stat",{signal:n.signal,searchParams:k({arg:`${t}`,...n}),headers:n.headers})).json();return{...s,Hash:A.parse(s.Hash)}}return e});u();u();var nee=D(r=>{async function e(t,n,i={}){let s=await r.post("object/patch/add-link",{signal:i.signal,searchParams:k({arg:[`${t}`,n.Name||n.name||"",(n.Hash||n.cid||"").toString()||null],...i}),headers:i.headers}),{Hash:o}=await s.json();return A.parse(o)}return e});u();var iee=D(r=>{async function e(t,n,i={}){let s=new AbortController,o=pn(s.signal,i.signal),a=await r.post("object/patch/append-data",{signal:o,searchParams:k({arg:`${t}`,...i}),...await dn([n],s,i.headers)}),{Hash:c}=await a.json();return A.parse(c)}return e});u();var see=D(r=>{async function e(t,n,i={}){let s=await r.post("object/patch/rm-link",{signal:i.signal,searchParams:k({arg:[`${t}`,n.Name||n.name||null],...i}),headers:i.headers}),{Hash:o}=await s.json();return A.parse(o)}return e});u();var oee=D(r=>{async function e(t,n,i={}){let s=new AbortController,o=pn(s.signal,i.signal),a=await r.post("object/patch/set-data",{signal:o,searchParams:k({arg:[`${t}`],...i}),...await dn([n],s,i.headers)}),{Hash:c}=await a.json();return A.parse(c)}return e});function aee(r){return{addLink:nee(r),appendData:iee(r),rmLink:see(r),setData:oee(r)}}function cee(r,e){return{data:XJ(e),get:ZJ(e),links:JJ(e),new:eee(e),put:tee(r,e),stat:ree(e),patch:aee(e)}}u();u();var pE=D(r=>{async function*e(t,n={}){for await(let{path:i,recursive:s,metadata:o}of pa(t)){let a=await r.post("pin/add",{signal:n.signal,searchParams:k({...n,arg:i,recursive:s,metadata:o?JSON.stringify(o):void 0,stream:!0}),headers:n.headers});for await(let c of a.ndjson()){if(c.Pins){for(let l of c.Pins)yield A.parse(l);continue}yield A.parse(c)}}}return e});u();var lee=E(vi(),1);function uee(r){let e=pE(r);return D(()=>{async function t(n,i={}){return(0,lee.default)(e([{path:n,...i}],i))}return t})(r)}u();function fee(r,e,t){let n={type:r,cid:A.parse(e)};return t&&(n.metadata=t),n}var hee=D(r=>{async function*e(t={}){let n=[];t.paths&&(n=Array.isArray(t.paths)?t.paths:[t.paths]);let i=await r.post("pin/ls",{signal:t.signal,searchParams:k({...t,arg:n.map(s=>`${s}`),stream:!0}),headers:t.headers});for await(let s of i.ndjson()){if(s.Keys){for(let o of Object.keys(s.Keys))yield fee(s.Keys[o].Type,o,s.Keys[o].Metadata);return}yield fee(s.Type,s.Cid,s.Metadata)}}return e});u();var mE=D(r=>{async function*e(t,n={}){for await(let{path:i,recursive:s}of pa(t)){let o=new URLSearchParams(n.searchParams);o.append("arg",`${i}`),s!=null&&o.set("recursive",String(s));let a=await r.post("pin/rm",{signal:n.signal,headers:n.headers,searchParams:k({...n,arg:`${i}`,recursive:s})});for await(let c of a.ndjson()){if(c.Pins){yield*c.Pins.map(l=>A.parse(l));continue}yield A.parse(c)}}}return e});u();var dee=E(vi(),1);var pee=r=>{let e=mE(r);return D(()=>{async function t(n,i={}){return(0,dee.default)(e([{path:n,...i}],i))}return t})(r)};u();u();u();var yE=({Name:r,Status:e,Cid:t})=>({cid:A.parse(t),name:r,status:e}),mee=r=>{if(typeof r=="string"&&r!=="")return r;throw new TypeError("service name must be passed")},yee=r=>{if(A.asCID(r))return r.toString();throw new TypeError(`CID instance expected instead of ${typeof r}`)},G0=({service:r,cid:e,name:t,status:n,all:i})=>{let s=k({service:mee(r),name:t,force:i?!0:void 0});if(e)for(let o of e)s.append("cid",yee(o));if(n)for(let o of n)s.append("status",o);return s},gee=({cid:r,service:e,background:t,name:n,origins:i})=>{let s=k({arg:yee(r),service:mee(e),name:n,background:t?!0:void 0});if(i)for(let o of i)s.append("origin",o.toString());return s};function wee(r){async function e(t,{timeout:n,signal:i,headers:s,...o}){let a=await r.post("pin/remote/add",{timeout:n,signal:i,headers:s,searchParams:gee({cid:t,...o})});return yE(await a.json())}return e}u();function Eee(r){async function*e({timeout:t,signal:n,headers:i,...s}){let o=await r.post("pin/remote/ls",{timeout:t,signal:n,headers:i,searchParams:G0(s)});for await(let a of o.ndjson())yield yE(a)}return e}u();function bee(r){async function e({timeout:t,signal:n,headers:i,...s}){await r.post("pin/remote/rm",{timeout:t,signal:n,headers:i,searchParams:G0({...s,all:!1})})}return e}u();function vee(r){async function e({timeout:t,signal:n,headers:i,...s}){await r.post("pin/remote/rm",{timeout:t,signal:n,headers:i,searchParams:G0({...s,all:!0})})}return e}u();u();u();function _ee(r){let e=String(r);if(e==="undefined")throw Error("endpoint is required");return e[e.length-1]==="/"?e.slice(0,-1):e}function See(r){return{service:r.Service,endpoint:new URL(r.ApiEndpoint),...r.Stat&&{stat:Wve(r.Stat)}}}function Wve(r){switch(r.Status){case"valid":{let{Pinning:e,Pinned:t,Queued:n,Failed:i}=r.PinCount;return{status:"valid",pinCount:{queued:n,pinning:e,pinned:t,failed:i}}}case"invalid":return{status:"invalid"};default:return{status:r.Status}}}function xee(r){async function e(t,n){let{endpoint:i,key:s,headers:o,timeout:a,signal:c}=n;await r.post("pin/remote/service/add",{timeout:a,signal:c,searchParams:k({arg:[t,_ee(i),s]}),headers:o})}return e}u();function Tee(r){async function e(t={}){let{stat:n,headers:i,timeout:s,signal:o}=t,a=await r.post("pin/remote/service/ls",{timeout:s,signal:o,headers:i,searchParams:n===!0?k({stat:n}):void 0}),{RemoteServices:c}=await a.json();return c.map(See)}return e}u();function Iee(r){async function e(t,n={}){await r.post("pin/remote/service/rm",{signal:n.signal,headers:n.headers,searchParams:k({arg:t})})}return e}function Aee(r){let e=new cf(r);return{add:xee(e),ls:Tee(e),rm:Iee(e)}}function Ree(r){let e=new cf(r);return{add:wee(e),ls:Eee(e),rm:bee(e),rmAll:vee(e),service:Aee(r)}}function Cee(r){return{addAll:pE(r),add:uee(r),ls:hee(r),rmAll:mE(r),rm:pee(r),remote:Ree(r)}}u();u();u();var Pee=r=>Array.isArray(r)?r.map(gE):r,gE=r=>K(j0(r)),j0=r=>Ol.decode(r),Dee=r=>BigInt(`0x${K(Ol.decode(r),"base16")}`),W0=r=>Ol.encode(z(r));var Oee=D(r=>{async function e(t={}){let{Strings:n}=await(await r.post("pubsub/ls",{signal:t.signal,searchParams:k(t),headers:t.headers})).json();return Pee(n)||[]}return e});u();var kee=D(r=>{async function e(t,n={}){let i=await r.post("pubsub/peers",{signal:n.signal,searchParams:k({arg:W0(t),...n}),headers:n.headers}),{Strings:s}=await i.json();return s||[]}return e});u();var Nee=D(r=>{async function e(t,n,i={}){let s=k({arg:W0(t),...i}),o=new AbortController,a=pn(o.signal,i.signal);await(await r.post("pubsub/pub",{signal:a,searchParams:s,...await dn([n],o,i.headers)})).text()}return e});u();var Yve=C("ipfs-http-client:pubsub:subscribe"),Lee=(r,e)=>D(t=>{async function n(i,s,o={}){o.signal=e.subscribe(i,s,o.signal);let a,c,l=new Promise((h,p)=>{a=h,c=p}),f=setTimeout(()=>a(),1e3);return t.post("pubsub/sub",{signal:o.signal,searchParams:k({arg:W0(i),...o}),headers:o.headers}).catch(h=>{e.unsubscribe(i,s),c(h)}).then(h=>{clearTimeout(f),h&&(Qve(h,{onMessage:p=>{if(!!s){if(typeof s=="function"){s(p);return}typeof s.handleEvent=="function"&&s.handleEvent(p)}},onEnd:()=>e.unsubscribe(i,s),onError:o.onError}),a())}),l}return n})(r);async function Qve(r,{onMessage:e,onEnd:t,onError:n}){n=n||Yve;try{for await(let i of r.ndjson())try{if(!i.from)continue;i.from!=null&&i.seqno!=null?e({type:"signed",from:pe(i.from),data:j0(i.data),sequenceNumber:Dee(i.seqno),topic:gE(i.topicIDs[0]),key:j0(i.key??"u"),signature:j0(i.signature??"u")}):e({type:"unsigned",data:j0(i.data),topic:gE(i.topicIDs[0])})}catch(s){s.message=`Failed to parse pubsub message: ${s.message}`,n(s,!1,i)}}catch(i){Xve(i)||n(i,!0)}finally{t()}}var Xve=r=>{switch(r.type){case"aborted":return!0;case"abort":return!0;default:return r.name==="AbortError"}};u();var Bee=(r,e)=>{async function t(n,i){e.unsubscribe(n,i)}return t};u();var wE=class{constructor(){this._subs=new Map}subscribe(e,t,n){let i=this._subs.get(e)||[];if(i.find(o=>o.handler===t))throw new Error(`Already subscribed to ${e} with this handler`);let s=new AbortController;return this._subs.set(e,[{handler:t,controller:s}].concat(i)),n&&n.addEventListener("abort",()=>this.unsubscribe(e,t)),s.signal}unsubscribe(e,t){let n=this._subs.get(e)||[],i;t?(this._subs.set(e,n.filter(s=>s.handler!==t)),i=n.filter(s=>s.handler===t)):(this._subs.set(e,[]),i=n),(this._subs.get(e)||[]).length||this._subs.delete(e),i.forEach(s=>s.controller.abort())}};function Mee(r){let e=new wE;return{ls:Oee(r),peers:kee(r),publish:Nee(r),subscribe:Lee(r,e),unsubscribe:Bee(r,e)}}u();u();var Uee=D(r=>{async function*e(t={}){yield*(await r.post("refs/local",{signal:t.signal,transform:bt,searchParams:k(t),headers:t.headers})).ndjson()}return e});var Fee=D((r,e)=>Object.assign(async function*(n,i={}){let s=Array.isArray(n)?n:[n];yield*(await r.post("refs",{signal:i.signal,searchParams:k({arg:s.map(a=>`${a instanceof Uint8Array?A.decode(a):a}`),...i}),headers:i.headers,transform:bt})).ndjson()},{local:Uee(e)}));u();u();var Vee=D(r=>{async function*e(t={}){yield*(await r.post("repo/gc",{signal:t.signal,searchParams:k(t),headers:t.headers,transform:i=>({err:i.Error?new Error(i.Error):null,cid:(i.Key||{})["/"]?A.parse(i.Key["/"]):null})})).ndjson()}return e});u();var EE=D(r=>{async function e(t={}){let i=await(await r.post("repo/stat",{signal:t.signal,searchParams:k(t),headers:t.headers})).json();return{numObjects:BigInt(i.NumObjects),repoSize:BigInt(i.RepoSize),repoPath:i.RepoPath,version:i.Version,storageMax:BigInt(i.StorageMax)}}return e});u();var Kee=D(r=>{async function e(t={}){return(await(await r.post("repo/version",{signal:t.signal,searchParams:k(t),headers:t.headers})).json()).Version}return e});function qee(r){return{gc:Vee(r),stat:EE(r),version:Kee(r)}}u();u();var zee=D(r=>{async function*e(t={}){yield*(await r.post("stats/bw",{signal:t.signal,searchParams:k(t),headers:t.headers,transform:i=>({totalIn:BigInt(i.TotalIn),totalOut:BigInt(i.TotalOut),rateIn:parseFloat(i.RateIn),rateOut:parseFloat(i.RateOut)})})).ndjson()}return e});function $ee(r){return{bitswap:uE(r),repo:EE(r),bw:zee(r)}}u();u();var Hee=D(r=>{async function e(t={}){let n=await r.post("swarm/addrs",{signal:t.signal,searchParams:k(t),headers:t.headers}),{Addrs:i}=await n.json();return Object.keys(i).map(s=>({id:pe(s),addrs:(i[s]||[]).map(o=>se(o))}))}return e});u();var Gee=D(r=>{async function e(t,n={}){let i=await r.post("swarm/connect",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers}),{Strings:s}=await i.json();return s||[]}return e});u();var jee=D(r=>{async function e(t,n={}){let i=await r.post("swarm/disconnect",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers}),{Strings:s}=await i.json();return s||[]}return e});u();var Wee=D(r=>{async function e(t={}){let n=await r.post("swarm/addrs/local",{signal:t.signal,searchParams:k(t),headers:t.headers}),{Strings:i}=await n.json();return(i||[]).map(s=>se(s))}return e});u();var Yee=D(r=>{async function e(t={}){let n=await r.post("swarm/peers",{signal:t.signal,searchParams:k(t),headers:t.headers}),{Peers:i}=await n.json();return(i||[]).map(s=>({addr:se(s.Addr),peer:pe(s.Peer),muxer:s.Muxer,latency:s.Latency,streams:s.Streams,direction:s.Direction==null?void 0:s.Direction===0?"inbound":"outbound"}))}return e});function Qee(r){return{addrs:Hee(r),connect:Gee(r),disconnect:jee(r),localAddrs:Wee(r),peers:Yee(r)}}u();u();var bE=D(r=>{async function*e(t,n={}){let i=new AbortController,s=pn(i.signal,n.signal),{headers:o,body:a,total:c,parts:l}=await dn(t,i,n.headers),[f,h]=typeof n.progress=="function"?Zve(c,l,n.progress):[void 0,void 0],p=await r.post("add",{searchParams:k({"stream-channels":!0,...n,progress:Boolean(f)}),onUploadProgress:h,signal:s,headers:o,body:a});for await(let d of p.ndjson())d=bt(d),d.hash!==void 0?yield e_e(d):f&&f(d.bytes||0,d.name)}return e}),Zve=(r,e,t)=>e?[void 0,Jve(r,e,t)]:[t,void 0],Jve=(r,e,t)=>{let n=0,i=e.length;return({loaded:s,total:o})=>{let a=Math.floor(s/o*r);for(;n<i;){let{start:c,end:l,name:f}=e[n];if(a<l){t(a-c,f);break}else t(l-c,f),n+=1}}};function e_e({name:r,hash:e,size:t,mode:n,mtime:i,mtimeNsecs:s}){let o={path:r,cid:A.parse(e),size:parseInt(t)};return n!=null&&(o.mode=parseInt(n,8)),i!=null&&(o.mtime={secs:i,nsecs:s||0}),o}var Xee=E(vi(),1);function Zee(r){let e=bE(r);return D(()=>{async function t(n,i={}){return await(0,Xee.default)(e(v6(n),i))}return t})(r)}u();var Jee=D(r=>{async function*e(t,n={}){yield*(await r.post("cat",{signal:n.signal,searchParams:k({arg:t.toString(),...n}),headers:n.headers})).iterator()}return e});u();var ete=D(r=>async(t={})=>(await r.post("commands",{signal:t.signal,searchParams:k(t),headers:t.headers})).json());u();var tte=D(r=>async(t,n={})=>(await(await r.post("dns",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers})).json()).Path);u();var rte=D(r=>()=>{let e=new URL(r.opts.base||"");return{host:e.hostname,port:e.port,protocol:e.protocol,pathname:e.pathname,"api-path":e.pathname}});u();var nte=D(r=>{async function*e(t,n={}){let i={arg:`${t instanceof Uint8Array?A.decode(t):t}`,...n};i.compressionLevel&&(i["compression-level"]=i.compressionLevel,delete i.compressionLevel),yield*(await r.post("get",{signal:n.signal,searchParams:k(i),headers:n.headers})).iterator()}return e});u();var vE=D(r=>{async function e(t={}){let i=await(await r.post("id",{signal:t.signal,searchParams:k({arg:t.peerId?t.peerId.toString():void 0,...t}),headers:t.headers})).json(),s={...bt(i)};return s.id=pe(s.id),s.addresses&&(s.addresses=s.addresses.map(o=>se(o))),s}return e});u();var ite=r=>{let e=vE(r);async function t(n={}){let i=await e(n);return Boolean(i&&i.addresses&&i.addresses.length)}return t};u();var ste=D((r,e)=>{async function*t(n,i={}){let s=`${n instanceof Uint8Array?A.decode(n):n}`;async function o(c){let l=c.Hash;if(l.includes("/")){let h=l.startsWith("/ipfs/")?l:`/ipfs/${l}`;l=(await dE(e)(h)).cid}else l=A.parse(l);let f={name:c.Name,path:s+(c.Name?`/${c.Name}`:""),size:c.Size,cid:l,type:t_e(c)};return c.Mode&&(f.mode=parseInt(c.Mode,8)),c.Mtime!==void 0&&c.Mtime!==null&&(f.mtime={secs:c.Mtime},c.MtimeNsecs!==void 0&&c.MtimeNsecs!==null&&(f.mtime.nsecs=c.MtimeNsecs)),f}let a=await r.post("ls",{signal:i.signal,searchParams:k({arg:s,...i}),headers:i.headers});for await(let c of a.ndjson()){if(c=c.Objects,!c)throw new Error("expected .Objects in results");if(c=c[0],!c)throw new Error("expected one array in results.Objects");let l=c.Links;if(!Array.isArray(l))throw new Error("expected one array in results.Objects[0].Links");if(!l.length){yield o(c);return}yield*l.map(o)}}return t});function t_e(r){switch(r.Type){case 1:case 5:return"dir";case 2:return"file";default:return"file"}}u();var ote=D(r=>{async function e(t={}){let n=await r.post("dns",{signal:t.signal,searchParams:k(t),headers:t.headers});return bt(await n.json())}return e});u();var ate=D(r=>{async function*e(t,n={}){yield*(await r.post("ping",{signal:n.signal,searchParams:k({arg:`${t}`,...n}),headers:n.headers,transform:bt})).ndjson()}return e});u();var cte=D(r=>{async function e(t,n={}){let i=await r.post("resolve",{signal:n.signal,searchParams:k({arg:t,...n}),headers:n.headers}),{Path:s}=await i.json();return s}return e});u();var lte=E(V(),1),ute=D(r=>async(t={})=>{throw(0,lte.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});u();var fte=D(r=>{async function e(t={}){await(await r.post("shutdown",{signal:t.signal,searchParams:k(t),headers:t.headers})).text()}return e});u();var hte=D(r=>{async function e(t={}){let n=await r.post("version",{signal:t.signal,searchParams:k(t),headers:t.headers});return{...bt(await n.json()),"ipfs-http-client":"1.0.0"}}return e});var s_e=E(NR(),1),o_e=E(LR(),1);function pte(r={}){let e={name:on.name,code:on.code,encode:l=>l,decode:l=>l},t=Object.values(As);(r.ipld&&r.ipld.bases?r.ipld.bases:[]).forEach(l=>t.push(l));let n=new z0({bases:t,loadBase:r.ipld&&r.ipld.loadBase}),i=Object.values(f4);[_t,mc,tp,Y1,e].concat(r.ipld&&r.ipld.codecs||[]).forEach(l=>i.push(l));let s=new $0({codecs:i,loadCodec:r.ipld&&r.ipld.loadCodec}),o=Object.values(u4);(r.ipld&&r.ipld.hashers?r.ipld.hashers:[]).forEach(l=>o.push(l));let a=new H0({hashers:o,loadHasher:r.ipld&&r.ipld.loadHasher});return{add:Zee(r),addAll:bE(r),bitswap:vZ(r),block:NZ(r),bootstrap:VZ(r),cat:Jee(r),commands:ete(r),config:WZ(r),dag:rJ(s,r),dht:lJ(r),diag:dJ(r),dns:tte(r),files:CJ(r),get:nte(r),getEndpointConfig:rte(r),id:vE(r),isOnline:ite(r),key:FJ(r),log:zJ(r),ls:ste(r),mount:ote(r),name:QJ(r),object:cee(s,r),pin:Cee(r),ping:ate(r),pubsub:Mee(r),refs:Fee(r),repo:qee(r),resolve:cte(r),start:ute(r),stats:$ee(r),stop:fte(r),swarm:Qee(r),version:hte(r),bases:n,codecs:s,hashers:a}}u();u();var BE=E(V(),1);u();u();var nre=E(V(),1);u();u();u();u();u();u();u();u();u();u();var $o=Object.create(null);$o.open="0";$o.close="1";$o.ping="2";$o.pong="3";$o.message="4";$o.upgrade="5";$o.noop="6";var fg=Object.create(null);Object.keys($o).forEach(r=>{fg[$o[r]]=r});var mte={type:"error",data:"parser error"};var a_e=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",c_e=typeof ArrayBuffer=="function",l_e=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,u_e=({type:r,data:e},t,n)=>a_e&&e instanceof Blob?t?n(e):yte(e,n):c_e&&(e instanceof ArrayBuffer||l_e(e))?t?n(e):yte(new Blob([e]),n):n($o[r]+(e||"")),yte=(r,e)=>{let t=new FileReader;return t.onload=function(){let n=t.result.split(",")[1];e("b"+n)},t.readAsDataURL(r)},_E=u_e;u();u();var gte="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hg=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<gte.length;r++)hg[gte.charCodeAt(r)]=r;var wte=r=>{let e=r.length*.75,t=r.length,n,i=0,s,o,a,c;r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);let l=new ArrayBuffer(e),f=new Uint8Array(l);for(n=0;n<t;n+=4)s=hg[r.charCodeAt(n)],o=hg[r.charCodeAt(n+1)],a=hg[r.charCodeAt(n+2)],c=hg[r.charCodeAt(n+3)],f[i++]=s<<2|o>>4,f[i++]=(o&15)<<4|a>>2,f[i++]=(a&3)<<6|c&63;return l};var f_e=typeof ArrayBuffer=="function",h_e=(r,e)=>{if(typeof r!="string")return{type:"message",data:Ete(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:d_e(r.substring(1),e)}:fg[t]?r.length>1?{type:fg[t],data:r.substring(1)}:{type:fg[t]}:mte},d_e=(r,e)=>{if(f_e){let t=wte(r);return Ete(t,e)}else return{base64:!0,data:r}},Ete=(r,e)=>{switch(e){case"blob":return r instanceof ArrayBuffer?new Blob([r]):r;case"arraybuffer":default:return r}},SE=h_e;var bte=String.fromCharCode(30),vte=(r,e)=>{let t=r.length,n=new Array(t),i=0;r.forEach((s,o)=>{_E(s,!1,a=>{n[o]=a,++i===t&&e(n.join(bte))})})},_te=(r,e)=>{let t=r.split(bte),n=[];for(let i=0;i<t.length;i++){let s=SE(t[i],e);if(n.push(s),s.type==="error")break}return n},BR=4;u();function ur(r){if(r)return p_e(r)}function p_e(r){for(var e in ur.prototype)r[e]=ur.prototype[e];return r}ur.prototype.on=ur.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};ur.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};ur.prototype.off=ur.prototype.removeListener=ur.prototype.removeAllListeners=ur.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,i=0;i<t.length;i++)if(n=t[i],n===e||n.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+r],this};ur.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,i=t.length;n<i;++n)t[n].apply(this,e)}return this};ur.prototype.emitReserved=ur.prototype.emit;ur.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};ur.prototype.hasListeners=function(r){return!!this.listeners(r).length};u();u();var Ws=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function xE(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var m_e=setTimeout,y_e=clearTimeout;function al(r,e){e.useNativeTimers?(r.setTimeoutFn=m_e.bind(Ws),r.clearTimeoutFn=y_e.bind(Ws)):(r.setTimeoutFn=setTimeout.bind(Ws),r.clearTimeoutFn=clearTimeout.bind(Ws))}var g_e=1.33;function Ste(r){return typeof r=="string"?w_e(r):Math.ceil((r.byteLength||r.size)*g_e)}function w_e(r){let e=0,t=0;for(let n=0,i=r.length;n<i;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}var MR=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}},ad=class extends ur{constructor(e){super(),this.writable=!1,al(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new MR(e,t,n)),this}open(){return(this.readyState==="closed"||this.readyState==="")&&(this.readyState="opening",this.doOpen()),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=SE(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}};u();var Ate="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),UR=64,E_e={},xte=0,TE=0,Tte;function Ite(r){let e="";do e=Ate[r%UR]+e,r=Math.floor(r/UR);while(r>0);return e}function IE(){let r=Ite(+new Date);return r!==Tte?(xte=0,Tte=r):r+"."+Ite(xte++)}for(;TE<UR;TE++)E_e[Ate[TE]]=TE;u();function AE(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Rte(r){let e={},t=r.split("&");for(let n=0,i=t.length;n<i;n++){let s=t[n].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}u();u();var Cte=!1;try{Cte=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Pte=Cte;function FR(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Pte))return new XMLHttpRequest}catch{}if(!e)try{return new Ws[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function b_e(){}var v_e=function(){return new FR({xdomain:!1}).responseType!=null}(),RE=class extends ad{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){let n=location.protocol==="https:",i=location.port;i||(i=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port,this.xs=e.secure!==n}let t=e&&e.forceBase64;this.supportsBinary=v_e&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};_te(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){let e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,vte(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{},t=this.opts.secure?"https":"http",n="";this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=IE()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.opts.port&&(t==="https"&&Number(this.opts.port)!==443||t==="http"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port);let i=AE(e),s=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(s?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(i.length?"?"+i:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new Ys(this.uri(),e)}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(i,s)=>{this.onError("xhr post error",i,s)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}},Ys=class extends ur{constructor(e,t){super(),al(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=t.async!==!1,this.data=t.data!==void 0?t.data:null,this.create()}create(){let e=xE(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;let t=this.xhr=new FR(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&t.setRequestHeader(n,this.opts.extraHeaders[n])}}catch{}if(this.method==="POST")try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{t.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{t.readyState===4&&(t.status===200||t.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof t.status=="number"?t.status:0)},0))},t.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},0);return}typeof document<"u"&&(this.index=Ys.requestsCount++,Ys.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=b_e,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Ys.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};Ys.requestsCount=0;Ys.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Dte);else if(typeof addEventListener=="function"){let r="onpagehide"in Ws?"pagehide":"unload";addEventListener(r,Dte,!1)}}function Dte(){for(let r in Ys.requests)Ys.requests.hasOwnProperty(r)&&Ys.requests[r].abort()}u();u();var Ote=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),dg=Ws.WebSocket||Ws.MozWebSocket,CE=!0,kte="arraybuffer";var Nte=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",PE=class extends ad{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,n=Nte?{}:xE(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=CE&&!Nte?t?new dg(e,t):new dg(e):new dg(e,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType||kte,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],i=t===e.length-1;_E(n,this.supportsBinary,s=>{let o={};CE||(n.options&&(o.compress=n.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{CE?this.ws.send(s):this.ws.send(s,o)}catch{}i&&Ote(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{},t=this.opts.secure?"wss":"ws",n="";this.opts.port&&(t==="wss"&&Number(this.opts.port)!==443||t==="ws"&&Number(this.opts.port)!==80)&&(n=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=IE()),this.supportsBinary||(e.b64=1);let i=AE(e),s=this.opts.hostname.indexOf(":")!==-1;return t+"://"+(s?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(i.length?"?"+i:"")}check(){return!!dg}};var VR={websocket:PE,polling:RE};u();var __e=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,S_e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Y0(r){let e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let i=__e.exec(r||""),s={},o=14;for(;o--;)s[S_e[o]]=i[o]||"";return t!=-1&&n!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=x_e(s,s.path),s.queryKey=T_e(s,s.query),s}function x_e(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.substr(0,1)=="/"||e.length===0)&&n.splice(0,1),e.substr(e.length-1,1)=="/"&&n.splice(n.length-1,1),n}function T_e(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,s){i&&(t[i]=s)}),t}var ds=class extends ur{constructor(e,t={}){super(),e&&typeof e=="object"&&(t=e,e=null),e?(e=Y0(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=Y0(t.host).host),al(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+"/",typeof this.opts.query=="string"&&(this.opts.query=Rte(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&addEventListener("beforeunload",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=BR,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new VR[e](n)}open(){let e;if(this.opts.rememberUpgrade&&ds.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),n=!1;ds.priorWebsocketSuccess=!1;let i=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",h=>{if(!n)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;ds.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(f(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function s(){n||(n=!0,f(),t.close(),t=null)}let o=h=>{let p=new Error("probe error: "+h);p.transport=t.name,s(),this.emitReserved("upgradeError",p)};function a(){o("transport closed")}function c(){o("socket closed")}function l(h){t&&h.name!==t.name&&s()}let f=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",l)};t.once("open",i),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()}onOpen(){if(this.readyState="open",ds.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade&&this.transport.pause){let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){let i=this.writeBuffer[n].data;if(i&&(t+=Ste(i)),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,i){if(typeof t=="function"&&(i=t,t=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let s={type:e,data:t,options:n};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),i&&this.once("flush",i),this.flush()}close(){let e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){ds.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],n=0,i=e.length;for(;n<i;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};ds.protocol=BR;var wmt=ds.protocol;function Lte(r,e="",t){let n=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),n=Y0(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let s=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+s+":"+n.port+e,n.href=n.protocol+"://"+s+(t&&t.port===n.port?"":":"+n.port),n}u();u();var HR={};Kt(HR,{Decoder:()=>yg,Encoder:()=>zR,PacketType:()=>xt,protocol:()=>Fte});u();u();u();var I_e=typeof ArrayBuffer=="function",A_e=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Bte=Object.prototype.toString,R_e=typeof Blob=="function"||typeof Blob<"u"&&Bte.call(Blob)==="[object BlobConstructor]",C_e=typeof File=="function"||typeof File<"u"&&Bte.call(File)==="[object FileConstructor]";function mg(r){return I_e&&(r instanceof ArrayBuffer||A_e(r))||R_e&&r instanceof Blob||C_e&&r instanceof File}function pg(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if(pg(r[t]))return!0;return!1}if(mg(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return pg(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&pg(r[t]))return!0;return!1}function Mte(r){let e=[],t=r.data,n=r;return n.data=KR(t,e),n.attachments=e.length,{packet:n,buffers:e}}function KR(r,e){if(!r)return r;if(mg(r)){let t={_placeholder:!0,num:e.length};return e.push(r),t}else if(Array.isArray(r)){let t=new Array(r.length);for(let n=0;n<r.length;n++)t[n]=KR(r[n],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=KR(r[n],e));return t}return r}function Ute(r,e){return r.data=qR(r.data,e),r.attachments=void 0,r}function qR(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=qR(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=qR(r[t],e));return r}var Fte=5,xt;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(xt||(xt={}));var zR=class{constructor(e){this.replacer=e}encode(e){return(e.type===xt.EVENT||e.type===xt.ACK)&&pg(e)?(e.type=e.type===xt.EVENT?xt.BINARY_EVENT:xt.BINARY_ACK,this.encodeAsBinary(e)):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===xt.BINARY_EVENT||e.type===xt.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Mte(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}},yg=class extends ur{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e),t.type===xt.BINARY_EVENT||t.type===xt.BINARY_ACK?(this.reconstructor=new $R(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(mg(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,n={type:Number(e.charAt(0))};if(xt[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===xt.BINARY_EVENT||n.type===xt.BINARY_ACK){let s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(s,t)}else n.nsp="/";let i=e.charAt(t+1);if(i!==""&&Number(i)==i){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}n.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(yg.isPayloadValid(n.type,s))n.data=s;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case xt.CONNECT:return typeof t=="object";case xt.DISCONNECT:return t===void 0;case xt.CONNECT_ERROR:return typeof t=="string"||typeof t=="object";case xt.EVENT:case xt.BINARY_EVENT:return Array.isArray(t)&&t.length>0;case xt.ACK:case xt.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}},$R=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=Ute(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};u();function ps(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var P_e=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Q0=class extends ur{constructor(e,t,n){super(),this.connected=!1,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ps(e,"open",this.onopen.bind(this)),ps(e,"packet",this.onpacket.bind(this)),ps(e,"error",this.onerror.bind(this)),ps(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(P_e.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');t.unshift(e);let n={type:xt.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++,a=t.pop();this._registerAckCallback(o,a),n.id=o}let i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout;if(n===void 0){this.acks[e]=t;return}let i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===e&&this.sendBuffer.splice(s,1);t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...s)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...s])}}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this.packet({type:xt.CONNECT,data:e})}):this.packet({type:xt.CONNECT,data:this.auth})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case xt.CONNECT:if(e.data&&e.data.sid){let i=e.data.sid;this.onconnect(i)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case xt.EVENT:case xt.BINARY_EVENT:this.onevent(e);break;case xt.ACK:case xt.BINARY_ACK:this.onack(e);break;case xt.DISCONNECT:this.ondisconnect();break;case xt.CONNECT_ERROR:this.destroy();let n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e)}ack(e){let t=this,n=!1;return function(...i){n||(n=!0,t.packet({type:xt.ACK,id:e,data:i}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e){this.id=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:xt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};u();function cd(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}cd.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=(Math.floor(e*10)&1)==0?r-t:r+t}return Math.min(r,this.max)|0};cd.prototype.reset=function(){this.attempts=0};cd.prototype.setMin=function(r){this.ms=r};cd.prototype.setMax=function(r){this.max=r};cd.prototype.setJitter=function(r){this.jitter=r};var X0=class extends ur{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,al(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new cd({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let i=t.parser||HR;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new ds(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let i=ps(t,"open",function(){n.onopen(),e&&e()}),s=ps(t,"error",o=>{n.cleanup(),n._readyState="closed",this.emitReserved("error",o),e?e(o):n.maybeReconnectOnOpen()});if(this._timeout!==!1){let o=this._timeout;o===0&&i();let a=this.setTimeoutFn(()=>{i(),t.close(),t.emit("error",new Error("timeout"))},o);this.opts.autoUnref&&a.unref(),this.subs.push(function(){clearTimeout(a)})}return this.subs.push(i),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ps(e,"ping",this.onping.bind(this)),ps(e,"data",this.ondata.bind(this)),ps(e,"error",this.onerror.bind(this)),ps(e,"close",this.onclose.bind(this)),ps(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch{this.onclose("parse error")}}ondecoded(e){this.emitReserved("packet",e)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n||(n=new Q0(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(function(){clearTimeout(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var gg={};function wg(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=Lte(r,e.path||"/socket.io"),n=t.source,i=t.id,s=t.path,o=gg[i]&&s in gg[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?c=new X0(n,e):(gg[i]||(gg[i]=new X0(n,e)),c=gg[i]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(wg,{Manager:X0,Socket:Q0,io:wg,connect:wg});u();u();u();var Eg=E(V(),1),Gte=E(DE(),1);u();var qte=E(V(),1);var Kte=64*1024,O_e=5*1e3,OE=class{constructor(e,t){this.label=e.label,this.open=lr(),this.channel=e,this.channel.binaryType="arraybuffer",this.log=t.log,typeof this.channel.bufferedAmountLowThreshold=="number"&&(this.channel.bufferedAmountLowThreshold=Kte),e.addEventListener("message",i=>{t.onMessage(i)}),e.addEventListener("bufferedamountlow",()=>{this.log("stop backpressure: bufferedAmount %d",this.channel.bufferedAmount),this.open.resolve()}),e.addEventListener("open",()=>{this.open.resolve(),t.onOpen()}),e.addEventListener("close",()=>{t.onClose()}),e.addEventListener("error",i=>{if(i.error?.message==="Transport channel closed")return this.close();t.log.error('channel encounter an error in state "%s" message: "%s" detail: "%s',e.readyState,i.error?.message,i.error?.errorDetail);let s=i.error instanceof Error?i.error:new Error(`datachannel error: ${i.error?.message} ${i.error?.errorDetail}`);t.onError((0,qte.default)(s,"ERR_DATA_CHANNEL"))});let n=!1;this.closingInterval=setInterval(()=>{e.readyState==="closing"?(n&&t.onClose(),n=!0):n=!1},O_e)}async send(e){await this.open.promise,this.channel.send(e),this.channel.bufferedAmount>Kte&&(this.log("start backpressure: bufferedAmount %d",this.channel.bufferedAmount),this.open=lr())}close(){clearInterval(this.closingInterval),this.channel.close()}get bufferedAmount(){return this.channel.bufferedAmount}};var jte=E(WR(),1),N_e={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}]};function L_e(){if(typeof globalThis>"u")throw(0,Eg.default)(new Error("No WebRTC support detected"),"ERR_WEBRTC_SUPPORT");let r={RTCPeerConnection:globalThis.RTCPeerConnection??globalThis.mozRTCPeerConnection??globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription??globalThis.mozRTCSessionDescription??globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate??globalThis.mozRTCIceCandidate??globalThis.webkitRTCIceCandidate};if(r.RTCPeerConnection==null)throw(0,Eg.default)(new Error("No WebRTC support detected"),"ERR_WEBRTC_SUPPORT");return r}var ld=class extends We{constructor(e){super(),this.id=e.id??K((0,Gte.default)(4),"hex").slice(0,7),this.log=C(`libp2p:webrtc-peer:${e.logPrefix}:${this.id}`),this.wrtc=e.wrtc??L_e(),this.peerConnection=new this.wrtc.RTCPeerConnection(Object.assign({},N_e,e.peerConnectionConfig)),this.closed=!1,this.connected=lr(),this.source=ar(),this.sink=async t=>{if(await this.connected.promise,this.channel==null)throw(0,Eg.default)(new Error("Connected but no channel?!"),"ERR_DATA_CHANNEL");for await(let n of t)await this.channel.send(n);await this.close()}}handleDataChannelEvent(e){let t=e.channel;if(t==null){this.close((0,Eg.default)(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL")).catch(n=>{this.log("Error closing after event channel was found to be null",n)});return}this.channel=new OE(t,{log:this.log,onMessage:n=>{this.source.push(new Uint8Array(n.data))},onOpen:()=>{this.connected.resolve(),this.dispatchEvent(new ne("ready"))},onClose:()=>{this.close().catch(n=>{this.log("error closing connection after channel close",n)})},onError:n=>{this.close(n).catch(i=>{this.log("error closing connection after channel error",i)})}})}async close(e){if(this.closed=!0,e==null&&this.channel!=null)for(;this.channel.bufferedAmount>0;)await(0,jte.default)(100);this.channel?.close(),this.peerConnection.close(),this.source.end(e),this.dispatchEvent(new ne("close"))}};u();var Wte=E(V(),1),Z0=class extends We{constructor(e){super(),this.log=e.log,this.peerConnection=e.peerConnection,this.wrtc=e.wrtc,this.status="idle",this.peerConnection.addEventListener("negotiationneeded",()=>{this.log("peer connection negotiation needed"),this.handleRenegotiate({type:"renegotiate"}).catch(t=>{this.log.error("could not renegotiate %o",t)})})}async handleSignal(e){if(this.log('incoming signal "%s"',e.type),e.type==="offer")return await this.handleOffer(e);if(e.type==="answer")return await this.handleAnswer(e);if(e.type==="candidate")return await this.handleCandidate(e);if(e.type==="renegotiate")return await this.handleRenegotiate(e);if(e.type==="goodbye")return await this.handleGoodye(e);this.log(`Unknown signal type ${e.type}`)}async handleOffer(e){}async handleAnswer(e){}async handleRenegotiate(e){}async handleGoodye(e){this.peerConnection.close()}async handleCandidate(e){let t=new this.wrtc.RTCIceCandidate(e.candidate);try{await this.peerConnection.addIceCandidate(t)}catch(n){if(t.address==null||t.address.endsWith(".local"))this.log("ignoring unsupported ICE candidate.");else throw(0,Wte.default)(n,"ERR_ADD_ICE_CANDIDATE")}}};var Yte=C("libp2p:webrtc-peer:receiver"),bg=class extends ld{constructor(e={}){super({...e,logPrefix:"receiver"}),this.handshake=new YR({log:this.log,peerConnection:this.peerConnection,wrtc:this.wrtc,answerOptions:e.answerOptions}),this.handshake.addEventListener("signal",t=>this.dispatchEvent(new ne("signal",{detail:t.detail}))),this.peerConnection.addEventListener("datachannel",t=>{this.handleDataChannelEvent(t)})}handleSignal(e){this.handshake.handleSignal(e).catch(t=>{this.log("error handling signal %o %o",e,t)})}},YR=class extends Z0{constructor(e){super(e),this.options=e,this.status="idle",this.iceCandidates=[]}async handleRenegotiate(){Yte.trace("renegotiate"),this.dispatchEvent(new ne("signal",{detail:{type:"renegotiate"}}))}async handleOffer(e){await this.peerConnection.setRemoteDescription(new this.wrtc.RTCSessionDescription(e));for(let n of this.iceCandidates)await this.handleCandidate(n);this.iceCandidates=[];let t=await this.peerConnection.createAnswer(this.options.answerOptions);await this.peerConnection.setLocalDescription(t),Yte.trace("handle offer",this.peerConnection.localDescription),this.dispatchEvent(new ne("signal",{detail:this.peerConnection.localDescription??t}))}async handleCandidate(e){if(this.peerConnection.remoteDescription==null||this.peerConnection.remoteDescription.type==null){this.iceCandidates.push(e);return}await super.handleCandidate(e)}};u();var Jte=E(DE(),1);u();u();var kE=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},QR=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Qte=r=>globalThis.DOMException===void 0?new QR(r):new DOMException(r),Xte=r=>{let e=r.reason===void 0?Qte("This operation was aborted."):r.reason;return e instanceof Error?e:Qte(e)};function XR(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(Xte(c)),c.addEventListener("abort",()=>{a(Xte(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new kE(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}var B_e=r=>{let e=r.on||r.addListener||r.addEventListener,t=r.off||r.removeListener||r.removeEventListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function M_e(r,e,t){let n,i=new Promise((s,o)=>{if(t={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");let a=[e].flat(),c=[],{addListener:l,removeListener:f}=B_e(r),h=(...d)=>{let m=t.multiArgs?d:d[0];t.filter&&!t.filter(m)||(c.push(m),t.count===c.length&&(n(),s(c)))},p=d=>{n(),o(d)};n=()=>{for(let d of a)f(d,h);for(let d of t.rejectionEvents)f(d,p)};for(let d of a)l(d,h);for(let d of t.rejectionEvents)l(d,p);t.resolveImmediately&&s(c)});if(i.cancel=n,typeof t.timeout=="number"){let s=XR(i,t.timeout);return s.cancel=n,s}return i}function Zte(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=M_e(r,e,t),i=n.then(s=>s[0]);return i.cancel=n.cancel,i}var ere=E(WR(),1);var ZR=C("libp2p:webrtc-peer:initator"),U_e=1e3,vg=class extends ld{constructor(e={}){super({...e,logPrefix:"initiator"}),this.handleDataChannelEvent({channel:this.peerConnection.createDataChannel(e.dataChannelLabel??K((0,Jte.default)(20),"hex").slice(0,7),e.dataChannelInit)}),this.handshake=new JR({log:this.log,peerConnection:this.peerConnection,wrtc:this.wrtc,offerOptions:e.offerOptions}),this.handshake.addEventListener("signal",t=>{this.dispatchEvent(new ne("signal",{detail:t.detail}))})}handleSignal(e){this.handshake.handleSignal(e).catch(t=>{this.log("error handling signal %o %o",e,t)})}},JR=class extends Z0{constructor(e){super(e),this.options=e,this.status="idle",this.peerConnection.addEventListener("icecandidate",t=>{if(t.candidate==null)return;let n={type:"candidate",candidate:{candidate:t.candidate.candidate,sdpMLineIndex:t.candidate.sdpMLineIndex,sdpMid:t.candidate.sdpMid}};ZR.trace("create candidate",n),this.dispatchEvent(new ne("signal",{detail:n})),this.dispatchEvent(new ne("ice-candidate"))})}async handleRenegotiate(){if(this.status==="negotiating"){this.log("already negotiating, queueing");return}this.status="negotiating";let e=await this.peerConnection.createOffer(this.options.offerOptions);await this.peerConnection.setLocalDescription(e),await Zte(this,"ice-candidate"),await(0,ere.default)(U_e),ZR.trace("renegotiate",this.peerConnection.localDescription),this.dispatchEvent(new ne("signal",{detail:this.peerConnection.localDescription??e}))}async handleAnswer(e){ZR.trace("handle answer",e),await this.peerConnection.setRemoteDescription(new this.wrtc.RTCSessionDescription(e)),this.status="idle"}};u();var eC=C("libp2p:webrtc-star:socket");function NE(r,e){let{sink:t,source:n}=r,i={remoteAddr:e.remoteAddr,async sink(s){e.signal!=null&&(s=Kr(s,e.signal));try{await t(s)}catch(o){o.type!=="aborted"&&eC.error(o)}},source:e.signal!=null?Kr(n,e.signal):n,timeline:{open:Date.now()},async close(){if(r.closed)return;let s=Date.now(),o=setTimeout(()=>{if(i.remoteAddr!=null){let{host:a,port:c}=i.remoteAddr.toOptions();eC("timeout closing socket to %s:%s after %dms, destroying it manually",a,c,Date.now()-s)}r.closed||r.close().catch(a=>{eC.error("could not close socket",a)})},2e3);try{await r.close()}finally{clearTimeout(o)}}};return r.addEventListener("close",()=>{i.timeline.close==null&&(i.timeline.close=Date.now())},{once:!0}),i}u();function LE(r){let e=r.toString().split("/"),t=r.protos()[1].name,n=r.protos()[2].name,i=r.stringTuples()[1][1];if(t!=="tcp"||n!=="ws"&&n!=="wss")throw new Error(`invalid multiaddr: ${r.toString()}`);if(!VL(r))return`http://${e[2]}:${e[4]}`;if(n==="ws")return`http://${e[2]}${i==null||i==="80"?"":`:${i}`}`;if(n==="wss")return`https://${e[2]}${i==null||i==="443"?"":`:${i}`}`;throw new Error("invalid multiaddr: "+r.toString())}function tre(r){let e="/libp2p-webrtc-star";if(r.startsWith(e)){r=r.substring(e.length,r.length);let t=se(r),n=t.stringTuples().filter(i=>i[0]===421)[0];if(n[1]==null)throw new Error("invalid multiaddr: "+r);t=t.decapsulate("p2p"),t=t.encapsulate("/p2p-webrtc-star"),t=t.encapsulate(`/p2p/${n[1]}`),r=t.toString()}return r}var ri=C("libp2p:webrtc-star:listener"),V_e={transports:["websocket"],path:"/socket.io-next/"},tC=class extends We{constructor(e,t,n,i,s){super(),this.signallingAddr=t,this.socket=wg(e,V_e),this.connections=[],this.channels=new Map,this.pendingSignals=new Map,this.upgrader=n,this.handler=i,this.channelOptions=s,this.handleWsHandshake=this.handleWsHandshake.bind(this);let o=!1;this.socket.on("connect_error",a=>{o&&a.type==="TransportError"||this.dispatchEvent(new ne("error",{detail:a}))}),this.socket.on("error",a=>{this.dispatchEvent(new ne("error",{detail:a}))}),this.socket.on("ws-handshake",this.handleWsHandshake),this.socket.on("ws-peer",a=>{this.dispatchEvent(new ne("peer",{detail:a}))}),this.socket.on("connect",()=>{this.socket.emit("ss-join",this.signallingAddr.toString()),o&&this.dispatchEvent(new ne("reconnect"))}),this.socket.once("connect",()=>{o=!0,this.dispatchEvent(new ne("listening"))}),this.socket.on("disconnect",()=>{this.dispatchEvent(new ne("disconnect"))})}_createChannel(e,t,n){let i={...this.channelOptions},s=new bg(i),o=a=>{let c=a.detail;ri.error("incoming connection errored",c)};return s.addEventListener("error",o),s.addEventListener("close",()=>{s.removeEventListener("error",o)},{once:!0}),s.addEventListener("signal",a=>{let c=a.detail;this.socket.emit("ss-handshake",{intentId:e,srcMultiaddr:t,dstMultiaddr:n,answer:!0,signal:c})}),s.addEventListener("ready",()=>{let a=NE(s,{remoteAddr:this.signallingAddr});ri("new inbound connection %s",a.remoteAddr);try{this.upgrader.upgradeInbound(a).then(c=>{ri("inbound connection %s upgraded",a.remoteAddr),this.connections.push(a);let l=()=>{this.connections=this.connections.filter(f=>f!==a),this.channels.delete(e),this.pendingSignals.delete(e)};s.addEventListener("close",l,{once:!0}),this.dispatchEvent(new ne("connection",{detail:c})),this.handler(c)}).catch(c=>{ri.error("inbound connection failed to upgrade",c),a.close().catch(l=>{ri.error("inbound connection failed to close after failing to upgrade",l)})})}catch(c){ri.error("inbound connection failed to upgrade",c),a.close().catch(l=>{ri.error("inbound connection failed to close after failing to upgrade",l)})}},{once:!0}),s}handleWsHandshake(e){if(ri('incoming handshake. signal type "%s" is answer %s',e.signal.type,e.answer),e.answer===!0||e.err!=null||e.intentId==null)return;let t=e.intentId,n=this.pendingSignals.get(t);n==null&&(n=[],this.pendingSignals.set(t,n)),n.push(e);let i=this.channels.get(t);if(i==null){if(e.signal.type!=="offer"){ri("handshake is not an offer and channel does not exist, buffering until we receive an offer");return}ri("creating new channel to handle offer handshake"),i=this._createChannel(e.intentId,e.srcMultiaddr,e.dstMultiaddr),this.channels.set(t,i)}else ri("channel already exists, using it to handle handshake");for(;n.length>0;){let s=n.shift();s?.signal!=null&&i.handleSignal(s.signal)}}async close(){this.socket.emit("ss-leave",this.signallingAddr.toString()),this.socket.removeAllListeners(),this.socket.close(),await Promise.all([...this.connections.map(async e=>await e.close()),...Array.from(this.channels.values()).map(async e=>await e.close())]),this.dispatchEvent(new ne("close"))}},rC=class extends We{constructor(e,t,n,i,s){super(),this.upgrader=e,this.handler=t,this.peerId=n,this.transport=i,this.options=s}async listen(e){if(this.listeningAddr!=null)throw(0,nre.default)(new Error("listener already in use"),"ERR_ALREADY_LISTENING");let t=lr();this.listeningAddr=e;let n;e.protoCodes().includes(421)?n=e:n=e.encapsulate(`/p2p/${this.peerId.toString()}`);let i=this.signallingUrl=LE(e);ri("connecting to signalling server on: %s",this.signallingUrl);let s=new tC(this.signallingUrl,n,this.upgrader,this.handler,this.options.channelOptions);return s.addEventListener("error",o=>{let a=o.detail;ri("error connecting to signalling server %o",a),s.close().catch(c=>{ri.error("error closing server after error",c)}),t.reject(a)}),s.addEventListener("listening",()=>{ri("connected to signalling server"),this.dispatchEvent(new ne("listening")),t.resolve()}),s.addEventListener("peer",o=>{this.transport.peerDiscovered(o.detail)}),s.addEventListener("connection",o=>{let a=o.detail;if(a.remoteAddr==null)try{a.remoteAddr=e.decapsulateCode(421).encapsulate(`/p2p/${a.remotePeer.toString()}`)}catch(c){ri.error("could not determine remote address",c)}this.dispatchEvent(new ne("connection",{detail:a}))}),s.addEventListener("disconnect",()=>{this.transport.sigServers.delete(i)}),s.addEventListener("reconnect",()=>{this.transport.sigServers.set(i,s)}),this.transport.sigServers.set(this.signallingUrl,s),await t.promise}async close(){if(this.signallingUrl!=null){let e=this.transport.sigServers.get(this.signallingUrl);e!=null&&(await e.close(),this.transport.sigServers.delete(this.signallingUrl))}this.dispatchEvent(new ne("close")),this.listeningAddr=void 0}getAddrs(){return this.listeningAddr!=null?[this.listeningAddr]:[]}};function ire(r,e,t,n,i){return new rC(r,e,t,n,i)}var sre=E(DE(),1);u();Mr();u();np();function cl(r,e){if(r.length!==e.length)throw new Error("Inputs should have the same length");let t=ho(r.length);for(let n=0;n<r.length;n++)t[n]=r[n]^e[n];return t}u();var J0=Symbol.for("@libp2p/transport");u();var Xa=Symbol.for("@libp2p/peer-discovery");var q_e="RTCPeerConnection"in globalThis,ud=C("libp2p:webrtc-star"),z_e=()=>{},nC=class extends We{constructor(){super(...arguments),this.started=!1}get[Xa](){return!0}get[Symbol.toStringTag](){return"@libp2p/webrtc-star-discovery"}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}dispatchEvent(e){return this.isStarted()?super.dispatchEvent(e):!1}},ME=class{constructor(e){this.components=new je,e?.wrtc!=null&&(this.wrtc=e.wrtc),this.sigServers=new Map,this.discovery=new nC,this.peerDiscovered=this.peerDiscovered.bind(this)}get[J0](){return!0}get[Symbol.toStringTag](){return"@libp2p/webrtc-star"}init(e){this.components=e}async dial(e,t){let n=await this._connect(e,t),i=NE(n,{remoteAddr:e,signal:t.signal});ud("new outbound connection %s",i.remoteAddr);let s=await t.upgrader.upgradeOutbound(i);return ud("outbound connection %s upgraded",i.remoteAddr),s}async _connect(e,t){if(t.signal?.aborted===!0)throw new tf;let n={...t.channelOptions??{}};this.wrtc!=null&&(n.wrtc=this.wrtc);let i=e.toOptions(),s=K((0,sre.default)(36),"hex");return await new Promise((o,a)=>{let c=this.sigServers.get(LE(e));if(c?.socket==null)return a((0,BE.default)(new Error("unknown signal server to use"),"ERR_UNKNOWN_SIGNAL_SERVER"));let l=!1;ud("dialing %s:%s",i.host,i.port);let f=new vg(n),h=y=>{let g=y.detail;if(!l){let w=`connection error ${i.host}:${i.port}: ${g.message}`;ud.error(w),m(g)}},p=()=>{l=!0,ud("connection opened %s:%s",i.host,i.port),m()},d=()=>{ud.error("connection aborted %s:%s",i.host,i.port),f.close().finally(()=>{m(new tf)})},m=y=>{f.removeEventListener("ready",p),t.signal?.removeEventListener("abort",d),y==null?o(f):a(y)};f.addEventListener("ready",p,{once:!0}),f.addEventListener("close",()=>{f.removeEventListener("error",h)}),t.signal?.addEventListener("abort",d),f.addEventListener("signal",y=>{let g=y.detail;c.socket.emit("ss-handshake",{intentId:s,srcMultiaddr:c.signallingAddr.toString(),dstMultiaddr:e.toString(),signal:g})}),c.socket.on("ws-handshake",y=>{y.intentId===s&&y.err!=null&&f.close().finally(()=>{a((0,BE.default)(new Error(y.err),"ERR_SIGNALLING_FAILED"))}),!(y.intentId!==s||y.answer==null||f.closed)&&f.handleSignal(y.signal)})})}createListener(e){if(!q_e&&this.wrtc==null)throw(0,BE.default)(new Error("no WebRTC support"),"ERR_NO_WEBRTC_SUPPORT");return e.channelOptions=e.channelOptions??{},this.wrtc!=null&&(e.channelOptions.wrtc=this.wrtc),ire(e.upgrader,e.handler??z_e,this.components.getPeerId(),this,e)}filter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>t.protoCodes().includes(290)?!1:v4.matches(t))}peerDiscovered(e){ud("peer discovered: %s",e),e=tre(e);let t=se(e),n=t.getPeerId();if(n==null)return;let i=pe(n);this.discovery.dispatchEvent(new ne("peer",{detail:{id:i,multiaddrs:[t],protocols:[]}}))}};function ore(){let r=new ME;return{transports:[r],peerDiscovery:[r.discovery],connectionManager:{maxParallelDials:150,maxDialsPerPeer:4,dialTimeout:1e4,autoDial:!0},nat:{enabled:!1},metrics:{enabled:!0}}}u();u();u();var Sg=E(V(),1);u();var pt;(function(r){r.NOT_STARTED_YET="The libp2p node is not started yet",r.DHT_DISABLED="DHT is not available",r.PUBSUB_DISABLED="PubSub is not available",r.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",r.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",r.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",r.NOT_FOUND="Not found"})(pt||(pt={}));var F;(function(r){r.DHT_DISABLED="ERR_DHT_DISABLED",r.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",r.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",r.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",r.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",r.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",r.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",r.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",r.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",r.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",r.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",r.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",r.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",r.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",r.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",r.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",r.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",r.ERR_DIALED_SELF="ERR_DIALED_SELF",r.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",r.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",r.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",r.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",r.ERR_INVALID_KEY="ERR_INVALID_KEY",r.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",r.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",r.ERR_INVALID_PEER="ERR_INVALID_PEER",r.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",r.ERR_NOT_FOUND="ERR_NOT_FOUND",r.ERR_TIMEOUT="ERR_TIMEOUT",r.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",r.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",r.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",r.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",r.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",r.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",r.ERR_FIND_SELF="ERR_FIND_SELF",r.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",r.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",r.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",r.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",r.ERR_INVALID_CMS="ERR_INVALID_CMS",r.ERR_MISSING_KEYS="ERR_MISSING_KEYS",r.ERR_NO_KEY="ERR_NO_KEY",r.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",r.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",r.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",r.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",r.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",r.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",r.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",r.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",r.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",r.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",r.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",r.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",r.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",r.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",r.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",r.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",r.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",r.ERR_INVALID_RECORD="ERR_INVALID_RECORD",r.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",r.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",r.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",r.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS"})(F||(F={}));u();var are=E(V(),1),cre=E(Ai(),1),lre=E(Kn(),1);async function*_g(r,e){yield*(0,lre.default)(r,async t=>(await e.addressBook.add(t.id,t.multiaddrs),t))}function UE(r){let e=new Set;return(0,cre.default)(r,t=>e.has(t.id.toString())?!1:(e.add(t.id.toString()),!0))}async function*FE(r,e=1){let t=0;for await(let n of r)t++,yield n;if(t<e)throw(0,are.default)(new Error("not found"),"NOT_FOUND")}var hre=E(an(),1),sC=E(Bc(),1);var dre=E(Oa(),1),pre=E(fi(),1),mre=E(Ai(),1),KE=E(iC(),1),yre=E(bn(),1),fre=C("libp2p:peer-routing"),VE=class{constructor(e,t){this.components=e,this.routers=t.routers,this.refreshManagerInit=t.refreshManager??{},this.started=!1,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}isStarted(){return this.started}async start(){this.started||this.routers.length===0||this.timeoutId!=null||this.refreshManagerInit.enabled===!1||(this.timeoutId=(0,KE.setDelayedInterval)(this._findClosestPeersTask,this.refreshManagerInit.interval,this.refreshManagerInit.bootDelay),this.started=!0)}async _findClosestPeersTask(){if(this.abortController==null)try{this.abortController=new hre.TimeoutController(this.refreshManagerInit.timeout??1e4);try{(0,yre.setMaxListeners)?.(1/0,this.abortController.signal)}catch{}await(0,pre.default)(this.getClosestPeers(this.components.getPeerId().toBytes(),{signal:this.abortController.signal}))}catch(e){fre.error(e)}finally{this.abortController?.clear(),this.abortController=void 0}}async stop(){(0,KE.clearDelayedInterval)(this.timeoutId),this.abortController?.abort(),this.started=!1}async findPeer(e,t){if(this.routers.length===0)throw(0,Sg.default)(new Error("No peer routers available"),F.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.getPeerId().toString())throw(0,Sg.default)(new Error("Should not try to find self"),F.ERR_FIND_SELF);let n=await we((0,sC.default)(...this.routers.map(i=>async function*(){try{yield await i.findPeer(e,t)}catch(s){fre.error(s)}}())),i=>(0,mre.default)(i,Boolean),i=>_g(i,this.components.getPeerStore()),async i=>await(0,dre.default)(i));if(n!=null)return n;throw(0,Sg.default)(new Error(pt.NOT_FOUND),F.ERR_NOT_FOUND)}async*getClosestPeers(e,t){if(this.routers.length===0)throw(0,Sg.default)(new Error("No peer routers available"),F.ERR_NO_ROUTERS_AVAILABLE);yield*we((0,sC.default)(...this.routers.map(n=>n.getClosestPeers(e,t))),n=>_g(n,this.components.getPeerStore()),n=>UE(n),n=>FE(n))}};u();var lf=E(V(),1);var gre=E(fi(),1),wre=E(Bc(),1);var qE=class{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(e,t={}){if(this.routers.length===0)throw(0,lf.default)(new Error("No content this.routers available"),F.ERR_NO_ROUTERS_AVAILABLE);yield*we((0,wre.default)(...this.routers.map(n=>n.findProviders(e,t))),n=>_g(n,this.components.getPeerStore()),n=>UE(n),n=>FE(n))}async provide(e,t={}){if(this.routers.length===0)throw(0,lf.default)(new Error("No content routers available"),F.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>await n.provide(e,t)))}async put(e,t,n){if(!this.isStarted())throw(0,lf.default)(new Error(pt.NOT_STARTED_YET),F.DHT_NOT_STARTED);let i=this.components.getDHT();i!=null&&await(0,gre.default)(i.put(e,t,n))}async get(e,t){if(!this.isStarted())throw(0,lf.default)(new Error(pt.NOT_STARTED_YET),F.DHT_NOT_STARTED);let n=this.components.getDHT();if(n!=null){for await(let i of n.get(e,t))if(i.name==="VALUE")return i.value}throw(0,lf.default)(new Error(pt.NOT_FOUND),F.ERR_NOT_FOUND)}async*getMany(e,t,n){if(!this.isStarted())throw(0,lf.default)(new Error(pt.NOT_STARTED_YET),F.DHT_NOT_STARTED);if(t==null||t===0)return;let i=0,s=this.components.getDHT();if(s!=null){for await(let o of s.get(e,n))if(o.name==="VALUE"&&(yield{from:o.from,val:o.value},i++,i===t))break}if(i===0)throw(0,lf.default)(new Error(pt.NOT_FOUND),F.ERR_NOT_FOUND)}};u();var oC=E(V(),1);function W_e(r){let e=r.getPeerId();if(e==null)throw(0,oC.default)(new Error(`${r.toString()} does not have a valid peer type`),F.ERR_INVALID_MULTIADDR);try{return pe(e)}catch{throw(0,oC.default)(new Error(`${r.toString()} is not a valid peer type`),F.ERR_INVALID_MULTIADDR)}}function fd(r){if(Rs(r))return{id:r,multiaddrs:[],protocols:[]};typeof r=="string"&&(r=se(r));let e;return Ec(r)&&(e=r,r=W_e(r)),{id:r,multiaddrs:e!=null?[e]:[],protocols:[]}}u();var Y_e=r=>r,zE=class extends We{constructor(e,t){super();let{listen:n=[],announce:i=[]}=t;this.components=e,this.listen=new Set(n.map(s=>s.toString())),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=t.announceFilter??Y_e}getListenAddrs(){return Array.from(this.listen).map(e=>se(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>se(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>se(e))}addObservedAddr(e){let t=se(e),n=t.getPeerId();n!=null&&pe(n).equals(this.components.getPeerId())&&(t=t.decapsulate(se(`/p2p/${this.components.getPeerId().toString()}`)));let i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new ne("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(n=>n.toString());e.length===0&&(e=this.components.getTransportManager().getAddrs().map(n=>n.toString())),e=e.concat(this.getObservedAddrs().map(n=>n.toString()));let t=new Set(e);return this.announceFilter(Array.from(t).map(n=>se(n))).map(n=>n.getPeerId()===this.components.getPeerId().toString()?n:n.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}};u();var uC=E(V(),1);u();u();var Ere=C("libp2p:connection-manager:latency-monitor:visibility-change-emitter"),$E=class extends We{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",globalThis.document!=null&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",t="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",t="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",t="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",t="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",t="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=t}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?Ere("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(!(this.hidden===void 0||document[this.hidden]===void 0))return document[this.hidden]==null}_handleVisibilityChange(){let e=globalThis.document[this.hidden]===!1;Ere(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new ne("visibilityChange",{detail:e}))}};var ll=C("libp2p:connection-manager:latency-monitor"),HE=class extends We{constructor(e={}){super();let{latencyCheckIntervalMs:t,dataEmitIntervalMs:n,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=t??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=2*(this.latencyRandomPercentage/100)*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=n===null||n===0?void 0:n??5*1e3,ll("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),this.dataEmitIntervalMs!=null?ll("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):ll("Not emitting summaries"),this.asyncTestFn=i,globalThis.process?.hrtime!=null?(ll("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{let a=this.now(o);return a[0]*1e3+a[1]/1e6}):typeof window<"u"&&window.performance?.now!=null?(ll("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(ll("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){Q_e()&&(this.visibilityChangeEmitter=new $E,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{let{detail:t}=e;t?this._startTimers():(this._emitSummary(),this._stopTimers())})),this.visibilityChangeEmitter?.isVisible()===!0&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){this.checkLatencyID==null&&(this.checkLatency(),this.dataEmitIntervalMs!=null&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),typeof this.emitIntervalID.unref=="function"&&this.emitIntervalID.unref()))}_stopTimers(){this.checkLatencyID!=null&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),this.emitIntervalID!=null&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){let e=this.getSummary();e.events>0&&this.dispatchEvent(new ne("data",{detail:e}))}getSummary(){let e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),ll.trace("Summary: %O",e),e}checkLatency(){let e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,t={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},n=()=>{if(this.checkLatencyID==null)return;let i=this.getDeltaMS(t.startTime)-t.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,ll.trace("MS: %s Data: %O",i,this.latencyData)};ll.trace("localData: %O",t),this.checkLatencyID=setTimeout(()=>{this.asyncTestFn!=null?(t.deltaOffset=0,t.startTime=this.now(),this.asyncTestFn(n)):(t.deltaOffset-=1,n())},t.deltaOffset),typeof this.checkLatencyID.unref=="function"&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}};function Q_e(){return typeof globalThis.window<"u"}var fC=E(Q1(),1);var WE=E(bn(),1);u();var GE="OPEN",aC="CLOSING",jE="CLOSED";u();u();u();function ul(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let n=r.next(),i=n.value;return n.done===!0||i==null?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return t}var xg=class{constructor(e){if(this.map=new Map,e!=null)for(let[t,n]of e.entries())this.map.set(t.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return ul(this.map.entries(),e=>[pe(e[0]),e[1]])}forEach(e){this.map.forEach((t,n)=>{e(t,pe(n),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 ul(this.map.keys(),e=>pe(e))}values(){return this.map.values()}get size(){return this.map.size}};u();var Tg=class{constructor(e){if(this.set=new Set,e!=null)for(let 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 ul(this.set.entries(),e=>{let t=pe(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=pe(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return ul(this.set.values(),e=>pe(e))}};u();var t1=class{constructor(e){if(this.list=[],e!=null)for(let t of e)this.list.push(t.toString())}[Symbol.iterator](){return ul(this.list.entries(),e=>pe(e[1]))}concat(e){let t=new t1(this);for(let n of e)t.push(n);return t}entries(){return ul(this.list.entries(),e=>[e[0],pe(e[1])])}every(e){return this.list.every((t,n)=>e(pe(t),n,this))}filter(e){let t=new t1;return this.list.forEach((n,i)=>{let s=pe(n);e(s,i,this)&&t.push(s)}),t}find(e){let t=this.list.find((n,i)=>e(pe(n),i,this));if(t!=null)return pe(t)}findIndex(e){return this.list.findIndex((t,n)=>e(pe(t),n,this))}forEach(e){this.list.forEach((t,n)=>{e(pe(t),n,this)})}includes(e){return this.list.includes(e.toString())}indexOf(e){return this.list.indexOf(e.toString())}pop(){let e=this.list.pop();if(e!=null)return pe(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return pe(e)}unshift(...e){let t=this.list.length;for(let n=e.length-1;n>-1;n--)t=this.list.unshift(e[n].toString());return t}get length(){return this.list.length}};var hC=E(an(),1);u();var bre="keep-alive";var ni=C("libp2p:connection-manager"),Z_e={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},cC="libp2p",lC="connection-manager",J_e=6e4,YE=class extends We{constructor(e){if(super(),this.components=new je,this.opts=Qe.call({ignoreUndefined:!0},Z_e,e),this.opts.maxConnections<this.opts.minConnections)throw(0,uC.default)(new Error("Connection Manager maxConnections must be greater than minConnections"),F.ERR_INVALID_PARAMETERS);ni("options: %o",this.opts),this.connections=new Map,this.started=!1,this._checkMetrics=this._checkMetrics.bind(this),this.latencyMonitor=new HE({latencyCheckIntervalMs:e.pollInterval,dataEmitIntervalMs:e.pollInterval});try{(0,WE.setMaxListeners)?.(1/0,this)}catch{}this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.startupReconnectTimeout=e.startupReconnectTimeout??J_e,this.dialTimeout=e.dialTimeout??3e4}init(e){this.components=e,this.components.getMetrics()?.updateComponentMetric({system:cC,component:lC,metric:"connections",label:"direction",value:()=>{let t={inbound:0,outbound:0};for(let n of this.connections.values())for(let i of n)i.stat.direction==="inbound"?t.inbound++:t.outbound++;return t}}),this.components.getMetrics()?.updateComponentMetric({system:cC,component:lC,metric:"protocol-streams-total",label:"protocol",value:()=>{let t={};for(let n of this.connections.values())for(let i of n)for(let s of i.streams){let o=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;t[o]=(t[o]??0)+1}return t}}),this.components.getMetrics()?.updateComponentMetric({system:cC,component:lC,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{let t={};for(let i of this.connections.values())for(let s of i){let o={};for(let a of s.streams){let c=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[c]=(o[c]??0)+1}for(let[a,c]of Object.entries(o))t[a]=t[a]??[],t[a].push(c)}let n={};for(let[i,s]of Object.entries(t)){s=s.sort((a,c)=>a-c);let o=Math.floor(s.length*.9);n[i]=s[o]}return n}})}isStarted(){return this.started}async start(){this.components.getMetrics()!=null&&(this.timer=this.timer??(0,fC.default)(this._checkMetrics,this.opts.pollInterval)),this.latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this.latencyMonitor.addEventListener("data",this._onLatencyMeasure),this.started=!0,ni("started")}async afterStart(){this.components.getUpgrader().addEventListener("connection",this.onConnect),this.components.getUpgrader().addEventListener("connectionEnd",this.onDisconnect),Promise.resolve().then(async()=>{let e=[];for(let t of await this.components.getPeerStore().all())(await this.components.getPeerStore().getTags(t.id)).filter(s=>s.name===bre).length>0&&e.push(t.id);this.connectOnStartupController?.clear(),this.connectOnStartupController=new hC.TimeoutController(this.startupReconnectTimeout);try{(0,WE.setMaxListeners)?.(1/0,this.connectOnStartupController.signal)}catch{}await Promise.all(e.map(async t=>{await this.openConnection(t,{signal:this.connectOnStartupController?.signal}).catch(n=>{ni.error(n)})}))}).catch(e=>{ni.error(e)}).finally(()=>{this.connectOnStartupController?.clear()})}async beforeStop(){this.connectOnStartupController?.abort(),this.components.getUpgrader().removeEventListener("connection",this.onConnect),this.components.getUpgrader().removeEventListener("connectionEnd",this.onDisconnect)}async stop(){this.timer?.clear(),this.latencyMonitor.removeEventListener("data",this._onLatencyMeasure),this.latencyMonitor.stop(),this.started=!1,await this._close(),ni("stopped")}async _close(){let e=[];for(let t of this.connections.values())for(let n of t)e.push((async()=>{try{await n.close()}catch(i){ni.error(i)}})());ni("closing %d connections",e.length),await Promise.all(e),this.connections.clear()}async _checkMetrics(){let e=this.components.getMetrics();if(e!=null)try{let t=e.getGlobal().getMovingAverages(),n=t.dataReceived[this.opts.movingAverageInterval].movingAverage;await this._checkMaxLimit("maxReceivedData",n);let i=t.dataSent[this.opts.movingAverageInterval].movingAverage;await this._checkMaxLimit("maxSentData",i);let s=n+i;await this._checkMaxLimit("maxData",s),ni.trace("metrics update",s)}finally{this.timer=(0,fC.default)(this._checkMetrics,this.opts.pollInterval)}}onConnect(e){this._onConnect(e).catch(t=>{ni.error(t)})}async _onConnect(e){let{detail:t}=e;if(!this.started){await t.close();return}let n=t.remotePeer,i=n.toString(),s=this.connections.get(i);s!=null?s.push(t):this.connections.set(i,[t]),n.publicKey!=null&&await this.components.getPeerStore().keyBook.set(n,n.publicKey);let o=this.getConnections().length,a=o-this.opts.maxConnections;await this._checkMaxLimit("maxConnections",o,a),this.dispatchEvent(new ne("peer:connect",{detail:t}))}onDisconnect(e){let{detail:t}=e;if(!this.started)return;let n=t.remotePeer.toString(),i=this.connections.get(n);i!=null&&i.length>1?(i=i.filter(s=>s.id!==t.id),this.connections.set(n,i)):i!=null&&(this.connections.delete(n),this.dispatchEvent(new ne("peer:disconnect",{detail:t})),this.components.getMetrics()?.onPeerDisconnected(t.remotePeer))}getConnections(e){if(e!=null)return this.connections.get(e.toString())??[];let t=[];for(let n of this.connections.values())t=t.concat(n);return t}async openConnection(e,t={}){ni("dial to %p",e);let n=this.getConnections(e);if(n.length>0)return ni("had an existing connection to %p",e),n[0];let i;if(t?.signal==null){i=new hC.TimeoutController(this.dialTimeout),t.signal=i.signal;try{(0,WE.setMaxListeners)?.(1/0,i.signal)}catch{}}try{let s=await this.components.getDialer().dial(e,t),o=this.connections.get(e.toString());o==null&&(o=[],this.connections.set(e.toString(),o));let a=!1;for(let c of o)c.id===s.id&&(a=!0);return a||o.push(s),s}finally{i?.clear()}}async closeConnections(e){let t=this.connections.get(e.toString())??[];await Promise.all(t.map(async n=>await n.close()))}getAll(e){if(!Rs(e))throw(0,uC.default)(new Error("peerId must be an instance of peer-id"),F.ERR_INVALID_PARAMETERS);let t=e.toString(),n=this.connections.get(t);return n!=null?n.filter(i=>i.stat.status===GE):[]}_onLatencyMeasure(e){let{detail:t}=e;this._checkMaxLimit("maxEventLoopDelay",t.avgMs,1).catch(n=>{ni.error(n)})}async _checkMaxLimit(e,t,n=1){let i=this.opts[e];ni.trace("checking limit of %s. current value: %d of %d",e,t,i),t>i&&(ni("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",this.components.getPeerId(),e,t,i,n),await this._maybePruneConnections(n))}async _maybePruneConnections(e){let t=this.getConnections();if(t.length<=this.opts.minConnections||e<1)return;let n=new xg;for(let o of t){let a=o.remotePeer;if(n.has(a))continue;let c=await this.components.getPeerStore().getTags(a);n.set(a,c.reduce((l,f)=>l+f.value,0))}let i=t.sort((o,a)=>{let c=n.get(o.remotePeer)??0,l=n.get(a.remotePeer)??0;return c>l?1:c<l?-1:0}),s=[];for(let o of i)if(ni("too many connections open - closing a connection to %p",o.remotePeer),s.push(o),s.length===e)break;await Promise.all(s.map(async o=>{try{await o.close()}catch(a){ni.error(a)}this.onDisconnect(new ne("connectionEnd",{detail:o}))}))}};u();var dC=E(Q1(),1),vre=E(Ro(),1);var _re=E(Ai(),1),Sre=E(gy(),1),uf=C("libp2p:connection-manager:auto-dialler"),e9e={enabled:!0,minConnections:0,autoDialInterval:1e4},QE=class{constructor(e,t){this.components=e,this.options=Qe.call({ignoreUndefined:!0},e9e,t),this.running=!1,this._autoDial=this._autoDial.bind(this),uf("options: %j",this.options)}isStarted(){return this.running}async start(){if(!this.options.enabled){uf("not enabled");return}this.running=!0,this._autoDial().catch(e=>{uf.error("could start autodial",e)}),uf("started")}async stop(){if(!this.options.enabled){uf("not enabled");return}this.running=!1,this.autoDialTimeout!=null&&this.autoDialTimeout.clear(),uf("stopped")}async _autoDial(){this.autoDialTimeout!=null&&this.autoDialTimeout.clear();let e=this.options.minConnections;if(this.components.getConnectionManager().getConnections().length>=e){this.autoDialTimeout=(0,dC.default)(this._autoDial,this.options.autoDialInterval);return}let t=await this.components.getPeerStore().all(),n=await we(t.sort(()=>Math.random()>.5?1:-1),i=>(0,_re.default)(i,s=>!s.id.equals(this.components.getPeerId())),i=>(0,Sre.default)(i,(s,o)=>o.protocols.length>s.protocols.length||o.id.publicKey!=null&&s.id.publicKey==null?1:-1),async i=>await(0,vre.default)(i));for(let i=0;this.running&&i<n.length&&this.components.getConnectionManager().getConnections().length<e;i++){if(!this.running)return;let s=n[i];if(this.components.getConnectionManager().getConnections(s.id).length===0){uf("connecting to a peerStore stored peer %p",s.id);try{await this.components.getConnectionManager().openConnection(s.id)}catch(o){uf.error("could not connect to peerStore stored peer",o)}}}!this.running||(this.autoDialTimeout=(0,dC.default)(this._autoDial,this.options.autoDialInterval))}};u();var Ore=E(V(),1);u();var tt;(function(r){let e;(function(a){a.SUCCESS="SUCCESS",a.HOP_SRC_ADDR_TOO_LONG="HOP_SRC_ADDR_TOO_LONG",a.HOP_DST_ADDR_TOO_LONG="HOP_DST_ADDR_TOO_LONG",a.HOP_SRC_MULTIADDR_INVALID="HOP_SRC_MULTIADDR_INVALID",a.HOP_DST_MULTIADDR_INVALID="HOP_DST_MULTIADDR_INVALID",a.HOP_NO_CONN_TO_DST="HOP_NO_CONN_TO_DST",a.HOP_CANT_DIAL_DST="HOP_CANT_DIAL_DST",a.HOP_CANT_OPEN_DST_STREAM="HOP_CANT_OPEN_DST_STREAM",a.HOP_CANT_SPEAK_RELAY="HOP_CANT_SPEAK_RELAY",a.HOP_CANT_RELAY_TO_SELF="HOP_CANT_RELAY_TO_SELF",a.STOP_SRC_ADDR_TOO_LONG="STOP_SRC_ADDR_TOO_LONG",a.STOP_DST_ADDR_TOO_LONG="STOP_DST_ADDR_TOO_LONG",a.STOP_SRC_MULTIADDR_INVALID="STOP_SRC_MULTIADDR_INVALID",a.STOP_DST_MULTIADDR_INVALID="STOP_DST_MULTIADDR_INVALID",a.STOP_RELAY_REFUSED="STOP_RELAY_REFUSED",a.MALFORMED_MESSAGE="MALFORMED_MESSAGE"})(e=r.Status||(r.Status={}));let t;(function(a){a[a.SUCCESS=100]="SUCCESS",a[a.HOP_SRC_ADDR_TOO_LONG=220]="HOP_SRC_ADDR_TOO_LONG",a[a.HOP_DST_ADDR_TOO_LONG=221]="HOP_DST_ADDR_TOO_LONG",a[a.HOP_SRC_MULTIADDR_INVALID=250]="HOP_SRC_MULTIADDR_INVALID",a[a.HOP_DST_MULTIADDR_INVALID=251]="HOP_DST_MULTIADDR_INVALID",a[a.HOP_NO_CONN_TO_DST=260]="HOP_NO_CONN_TO_DST",a[a.HOP_CANT_DIAL_DST=261]="HOP_CANT_DIAL_DST",a[a.HOP_CANT_OPEN_DST_STREAM=262]="HOP_CANT_OPEN_DST_STREAM",a[a.HOP_CANT_SPEAK_RELAY=270]="HOP_CANT_SPEAK_RELAY",a[a.HOP_CANT_RELAY_TO_SELF=280]="HOP_CANT_RELAY_TO_SELF",a[a.STOP_SRC_ADDR_TOO_LONG=320]="STOP_SRC_ADDR_TOO_LONG",a[a.STOP_DST_ADDR_TOO_LONG=321]="STOP_DST_ADDR_TOO_LONG",a[a.STOP_SRC_MULTIADDR_INVALID=350]="STOP_SRC_MULTIADDR_INVALID",a[a.STOP_DST_MULTIADDR_INVALID=351]="STOP_DST_MULTIADDR_INVALID",a[a.STOP_RELAY_REFUSED=390]="STOP_RELAY_REFUSED",a[a.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE"})(t||(t={})),function(a){a.codec=()=>Hi(t)}(e=r.Status||(r.Status={}));let n;(function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"})(n=r.Type||(r.Type={}));let i;(function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"})(i||(i={})),function(a){a.codec=()=>Hi(i)}(n=r.Type||(r.Type={}));let s;(function(a){let c;a.codec=()=>(c==null&&(c=Et((l,f,h={})=>{if(h.lengthDelimited!==!1&&f.fork(),l.id!=null)f.uint32(10),f.bytes(l.id);else throw new Error('Protocol error: required field "id" was not found in object');if(l.addrs!=null)for(let p of l.addrs)f.uint32(18),f.bytes(p);else throw new Error('Protocol error: required field "addrs" was not found in object');h.lengthDelimited!==!1&&f.ldelim()},(l,f)=>{let h={},p=f==null?l.len:l.pos+f;for(;l.pos<p;){let d=l.uint32();switch(d>>>3){case 1:h.id=l.bytes();break;case 2:h.addrs=h.addrs??[],h.addrs.push(l.bytes());break;default:l.skipType(d&7);break}}if(h.addrs=h.addrs??[],h.id==null)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(h.addrs==null)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return h})),c),a.encode=l=>wt(l,a.codec()),a.decode=l=>gt(l,a.codec())})(s=r.Peer||(r.Peer={}));let o;r.codec=()=>(o==null&&(o=Et((a,c,l={})=>{l.lengthDelimited!==!1&&c.fork(),a.type!=null&&(c.uint32(8),r.Type.codec().encode(a.type,c)),a.srcPeer!=null&&(c.uint32(18),r.Peer.codec().encode(a.srcPeer,c)),a.dstPeer!=null&&(c.uint32(26),r.Peer.codec().encode(a.dstPeer,c)),a.code!=null&&(c.uint32(32),r.Status.codec().encode(a.code,c)),l.lengthDelimited!==!1&&c.ldelim()},(a,c)=>{let l={},f=c==null?a.len:a.pos+c;for(;a.pos<f;){let h=a.uint32();switch(h>>>3){case 1:l.type=r.Type.codec().decode(a);break;case 2:l.srcPeer=r.Peer.codec().decode(a,a.uint32());break;case 3:l.dstPeer=r.Peer.codec().decode(a,a.uint32());break;case 4:l.code=r.Status.codec().decode(a);break;default:a.skipType(h&7);break}}return l})),o),r.encode=a=>wt(a,r.codec()),r.decode=a=>gt(a,r.codec())})(tt||(tt={}));u();var t9e=C("libp2p:stream:converter");function pC(r,e={}){let{stream:t,remoteAddr:n}=r,{sink:i,source:s}=t,o=async function*(){for await(let l of s)yield*l}(),a={async sink(l){e.signal!=null&&(l=Kr(l,e.signal));try{await i(l),await c()}catch(f){f.type!=="aborted"&&t9e(f)}},source:e.signal!=null?Kr(o,e.signal):o,remoteAddr:n,timeline:{open:Date.now(),close:void 0},async close(){await i(async function*(){yield new Uint8Array(0)}()),await c()}};async function c(){return a.timeline.close==null&&(a.timeline.close=Date.now()),await Promise.resolve()}return a}u();var fl="/libp2p/circuit/relay/0.1.0";u();function xre(r){let e=new Map;async function t(s){let o=s.toString().split("/p2p-circuit").find(p=>p!==""),a=se(o),c=a.getPeerId();if(c==null)throw new Error("Could not determine relay peer from multiaddr");let l=pe(c);await r.peerStore.addressBook.add(l,[a]);let f=await r.connectionManager.openConnection(l),h=f.remoteAddr.encapsulate("/p2p-circuit");e.set(f.remotePeer.toString(),h),i.dispatchEvent(new ne("listening"))}function n(){let s=[];for(let o of e.values())s.push(o);return s}let i=Object.assign(new We,{close:async()=>await Promise.resolve(),listen:t,getAddrs:n});return r.connectionManager.addEventListener("peer:disconnect",s=>{let{detail:o}=s;e.delete(o.remotePeer.toString())&&i.dispatchEvent(new ne("close"))}),i}u();var mC=E(V(),1);u();function Tre(r,e){r.write({type:tt.Type.STATUS,code:e})}function XE(r,e){try{r.dstPeer?.addrs!=null&&r.dstPeer.addrs.forEach(t=>se(t))}catch(t){throw Tre(e,r.type===tt.Type.HOP?tt.Status.HOP_DST_MULTIADDR_INVALID:tt.Status.STOP_DST_MULTIADDR_INVALID),t}try{r.srcPeer?.addrs!=null&&r.srcPeer.addrs.forEach(t=>se(t))}catch(t){throw Tre(e,r.type===tt.Type.HOP?tt.Status.HOP_SRC_MULTIADDR_INVALID:tt.Status.STOP_SRC_MULTIADDR_INVALID),t}}u();u();function ff(r){let e=ar(),t=hT(r.source),n=lr(),i,s=r.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{i=a}),{reader:t,writer:e,stream:{sink:async a=>i!=null?await Promise.reject(i):(n.resolve(a),await s),source:t},rest:()=>e.end(),write:e.push,read:async()=>{let a=await t.next();if(a.value!=null)return a.value}}}var Ig=C("libp2p:circuit:stream-handler"),hl=class{constructor(e){let{stream:t,maxLength:n=4096}=e;this.stream=t,this.shake=ff(this.stream),this.decoder=yr.fromReader(this.shake.reader,{maxDataLength:n})}async read(){let e=await this.decoder.next();if(e.value!=null){let t=tt.decode(e.value);return Ig("read message type",t.type),t}Ig("read received no value, closing stream"),this.close()}write(e){Ig("write message type %s",e.type),this.shake.write(mr.single(tt.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Ig("closing the stream"),this.rest().sink([]).catch(e=>{Ig.error(e)})}};u();var Ag=C("libp2p:circuit:stop");function Ire(r){let{connection:e,request:t,streamHandler:n}=r;try{XE(t,n)}catch(i){Ag.error("invalid stop request via peer %p %o",e.remotePeer,i);return}return Ag("stop request is valid"),n.write({type:tt.Type.STATUS,code:tt.Status.SUCCESS}),n.rest()}async function Are(r){let{connection:e,request:t,signal:n}=r,i=await e.newStream(fl,{signal:n});Ag("starting stop request to %p",e.remotePeer);let s=new hl({stream:i});s.write(t);let o=await s.read();if(o==null){s.close();return}if(o.code===tt.Status.SUCCESS)return Ag("stop request to %p was successful",e.remotePeer),s.rest();Ag("stop request failed with code %d",o.code),s.close()}var Qs=C("libp2p:circuit:hop");async function Rre(r){let{connection:e,request:t,streamHandler:n,circuit:i,connectionManager:s}=r;if(!i.hopEnabled())return Qs("HOP request received but we are not acting as a relay"),n.end({type:tt.Type.STATUS,code:tt.Status.HOP_CANT_SPEAK_RELAY});try{XE(t,n)}catch(h){Qs.error("invalid hop request via peer %p %o",e.remotePeer,h);return}if(t.dstPeer==null){Qs("HOP request received but we do not receive a dstPeer");return}let o=Ir(t.dstPeer.id),a=s.getConnections(o);if(a.length===0&&!i.hopActive())return Qs("HOP request received but we are not connected to the destination peer"),n.end({type:tt.Type.STATUS,code:tt.Status.HOP_NO_CONN_TO_DST});if(a.length===0)return Qs("did not have connection to remote peer"),n.end({type:tt.Type.STATUS,code:tt.Status.HOP_NO_CONN_TO_DST});let c={type:tt.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer},l;try{Qs("performing STOP request");let h=await Are({connection:a[0],request:c});if(h==null)throw new Error("Could not stop");l=h}catch(h){Qs.error(h);return}Qs("hop request from %p is valid",e.remotePeer),n.write({type:tt.Type.STATUS,code:tt.Status.SUCCESS});let f=n.rest();return Qs("creating related connections"),await we(f,l,f)}async function Cre(r){let{connection:e,request:t,signal:n}=r,i=await e.newStream(fl,{signal:n}),s=new hl({stream:i});s.write(t);let o=await s.read();if(o==null)throw(0,mC.default)(new Error("HOP request had no response"),F.ERR_HOP_REQUEST_FAILED);if(o.code===tt.Status.SUCCESS)return Qs("hop request was successful"),s.rest();throw Qs("hop request failed with code %d, closing stream",o.code),s.close(),(0,mC.default)(new Error(`HOP request failed with code "${o.code??"unknown"}"`),F.ERR_HOP_REQUEST_FAILED)}async function Pre(r){let{connection:e,signal:t}=r,n=await e.newStream(fl,{signal:t}),i=new hl({stream:n});i.write({type:tt.Type.CAN_HOP});let s=await i.read();return await i.close(),!(s==null||s.code!==tt.Status.SUCCESS)}function Dre(r){let{connection:e,streamHandler:t,circuit:n}=r,i=n.hopEnabled();Qs("can hop (%s) request from %p",i,e.remotePeer),t.end({type:tt.Type.STATUS,code:i?tt.Status.SUCCESS:tt.Status.HOP_CANT_SPEAK_RELAY})}var kre=E(an(),1),Nre=E(bn(),1),Xs=C("libp2p:circuit"),ZE=class{constructor(e){this.components=new je,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle(fl,t=>{this._onProtocol(t).catch(n=>{Xs.error(n)})}).catch(t=>{Xs.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[J0](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}async _onProtocol(e){let{connection:t,stream:n}=e,i=new kre.TimeoutController(this._init.hop.timeout);try{(0,Nre.setMaxListeners)?.(1/0,i.signal)}catch{}try{let s=ti(n,i.signal),o=new hl({stream:{...n,...s}}),a=await o.read();if(a==null){Xs("request was invalid, could not read from stream"),o.write({type:tt.Type.STATUS,code:tt.Status.MALFORMED_MESSAGE}),o.close();return}let c;switch(a.type){case tt.Type.CAN_HOP:{Xs("received CAN_HOP request from %p",t.remotePeer),await Dre({circuit:this,connection:t,streamHandler:o});break}case tt.Type.HOP:{Xs("received HOP request from %p",t.remotePeer),await Rre({connection:t,request:a,streamHandler:o,circuit:this,connectionManager:this.components.getConnectionManager()});break}case tt.Type.STOP:{Xs("received STOP request from %p",t.remotePeer),c=await Ire({connection:t,request:a,streamHandler:o});break}default:{Xs("Request of type %s not supported",a.type),o.write({type:tt.Type.STATUS,code:tt.Status.MALFORMED_MESSAGE}),o.close();return}}if(c!=null){let l=t.remoteAddr.encapsulate("/p2p-circuit").encapsulate(se(a.dstPeer?.addrs[0])),f=se(a.srcPeer?.addrs[0]),h=pC({stream:c,remoteAddr:l,localAddr:f}),p=a.type===tt.Type.HOP?"relay":"inbound";Xs("new %s connection %s",p,h.remoteAddr);let d=await this.components.getUpgrader().upgradeInbound(h);Xs("%s connection %s upgraded",p,h.remoteAddr),this.handler!=null&&this.handler(d)}}finally{i.clear()}}async dial(e,t={}){let n=e.toString().split("/p2p-circuit"),i=se(n[0]),s=se(n[n.length-1]),o=i.getPeerId(),a=s.getPeerId();if(o==null||a==null){let d="Circuit relay dial failed as addresses did not have peer id";throw Xs.error(d),(0,Ore.default)(new Error(d),F.ERR_RELAYED_DIAL)}let c=pe(o),l=pe(a),f=!1,p=this.components.getConnectionManager().getConnections(c)[0];p==null&&(await this.components.getPeerStore().addressBook.add(c,[i]),p=await this.components.getConnectionManager().openConnection(c,t),f=!0);try{let d=await Cre({...t,connection:p,request:{type:tt.Type.HOP,srcPeer:{id:this.components.getPeerId().toBytes(),addrs:this.components.getAddressManager().getAddresses().map(g=>g.bytes)},dstPeer:{id:l.toBytes(),addrs:[se(s).bytes]}}}),m=i.encapsulate(`/p2p-circuit/p2p/${this.components.getPeerId().toString()}`),y=pC({stream:d,remoteAddr:e,localAddr:m});return Xs("new outbound connection %s",y.remoteAddr),await this.components.getUpgrader().upgradeOutbound(y)}catch(d){throw Xs.error("Circuit relay dial failed",d),f&&await p.close(),d}}createListener(e){return this.handler=e.handler,xre({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>Nf.matches(t))}};u();var ob=E(iC(),1);u();u();async function JE(r){let e=new TextEncoder().encode(r),t=await $e.digest(e);return A.createV0(t)}u();var yC="hop_relay",gC="true",eb="/libp2p/relay";var Wre=E(gy(),1),Yre=E(Ro(),1);u();u();var jre=E(nb(),1);function vC(r){let{address:e}=r.nodeAddress();return Boolean((0,jre.default)(e))}function n1(r,e){let t=vC(r.multiaddr),n=vC(e.multiaddr);return t&&!n?1:!t&&n||r.isCertified&&!e.isCertified?-1:!r.isCertified&&e.isCertified?1:0}var Pg=C("libp2p:auto-relay"),d9e=()=>{},ib=class{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??n1,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??d9e,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",n=>{this._onProtocolChange(n).catch(i=>{Pg.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}async _onProtocolChange(e){let{peerId:t,protocols:n}=e.detail,i=t.toString();if(n.find(o=>o===fl)==null){this.listenRelays.has(i)&&await this._removeListenRelay(i);return}if(!this.listenRelays.has(i))try{let o=this.components.getConnectionManager().getConnections(t);if(o.length===0)return;let a=o[0];if(a.remoteAddr.protoCodes().includes(290)){Pg(`relayed connection to ${i} will not be used to hop on`);return}await Pre({connection:a})&&(await this.components.getPeerStore().metadataBook.setValue(t,yC,z(gC)),await this._addListenRelay(a,i))}catch(o){this.onError(o)}}_onPeerDisconnected(e){let i=e.detail.remotePeer.toString();!this.listenRelays.has(i)||this._removeListenRelay(i).catch(s=>{Pg.error(s)})}async _addListenRelay(e,t){try{if(this.listenRelays.size>=this.maxListeners)return;let n=await we(await this.components.getPeerStore().addressBook.get(e.remotePeer),s=>(0,Wre.default)(s,this.addressSorter),async s=>await(0,Yre.default)(s));(await Promise.all(n.map(async s=>{try{let o=s.multiaddr;return o.getPeerId()==null&&(o=o.encapsulate(`/p2p/${e.remotePeer.toString()}`)),o=o.encapsulate("/p2p-circuit"),await this.components.getTransportManager().listen([o]),!0}catch(o){Pg.error("error listening on circuit address",o),this.onError(o)}return!1}))).includes(!0)&&this.listenRelays.add(t)}catch(n){this.onError(n),this.listenRelays.delete(t)}}async _removeListenRelay(e){this.listenRelays.delete(e)&&await this._listenOnAvailableHopRelays([e])}async _listenOnAvailableHopRelays(e=[]){if(this.listenRelays.size>=this.maxListeners)return;let t=[],n=await this.components.getPeerStore().all();for(let{id:i,metadata:s}of n){let o=i.toString();if(this.listenRelays.has(o)||e.includes(o))continue;let a=s.get(yC);if(a==null||K(a)!==gC)continue;let c=this.components.getConnectionManager().getConnections(i);if(c.length===0){t.push(i);continue}if(await this._addListenRelay(c[0],o),this.listenRelays.size>=this.maxListeners)return}for(let i of t)if(await this._tryToListenOnRelay(i),this.listenRelays.size>=this.maxListeners)return;try{let i=await JE(eb);for await(let s of this.components.getContentRouting().findProviders(i)){if(s.multiaddrs.length===0)continue;let o=s.id;if(!o.equals(this.components.getPeerId())&&(await this.components.getPeerStore().addressBook.add(o,s.multiaddrs),await this._tryToListenOnRelay(o),this.listenRelays.size>=this.maxListeners))return}}catch(i){this.onError(i)}}async _tryToListenOnRelay(e){try{let t=await this.components.getConnectionManager().openConnection(e);await this._addListenRelay(t,e.toString())}catch(t){Pg.error("Could not use %p as relay",e,t),this.onError(t,`could not connect and listen on known hop relay ${e.toString()}`)}}};var Qre=C("libp2p:relay"),sb=class{constructor(e,t){this.components=e,this.autoRelay=t.autoRelay?.enabled!==!1?new ib(e,{addressSorter:t.addressSorter,...t.autoRelay}):void 0,this.started=!1,this.init=t,this._advertiseService=this._advertiseService.bind(this)}isStarted(){return this.started}async start(){this.init.hop.enabled!==!1&&this.init.advertise.enabled!==!1&&(this.timeout=(0,ob.setDelayedInterval)(this._advertiseService,this.init.advertise.ttl,this.init.advertise.bootDelay)),this.started=!0}async stop(){this.timeout!=null&&(0,ob.clearDelayedInterval)(this.timeout),this.started=!1}async _advertiseService(){try{let e=await JE(eb);await this.components.getContentRouting().provide(e)}catch(e){e.code===F.ERR_NO_ROUTERS_AVAILABLE?(Qre.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),await this.stop()):Qre.error(e)}}};u();var Rne=E(sne(),1);u();var n4t=E(Sne(),1),i4t=E(KS(),1),dl=E(ft(),1);u();var t4t=E(SC(),1),Tne=E(ft(),1),xne=Tne.default.pki,Ine=(r,e)=>{let t=xne.rsa.setPublicKey(e.n,e.e),n=xne.createCertificate();n.publicKey=t,n.serialNumber="01",n.validity.notBefore=new Date,n.validity.notAfter=new Date,n.validity.notAfter.setFullYear(n.validity.notBefore.getFullYear()+10);let i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:r.id}];return n.setSubject(i),n.setIssuer(i),n.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),n.sign(e),n};async function Ane(r,e){let t=r.map(e),i=(await Promise.all(t)).findIndex(s=>s);return r[i]}var pl=E(V(),1);var z9e=C("libp2p:keychain:cms"),IC=new WeakMap,ub=class{constructor(e,t){if(e==null)throw(0,pl.default)(new Error("keychain is required"),F.ERR_KEYCHAIN_REQUIRED);this.keychain=e,IC.set(this,{dek:t})}async encrypt(e,t){if(!(t instanceof Uint8Array))throw(0,pl.default)(new Error("Plain data must be a Uint8Array"),F.ERR_INVALID_PARAMETERS);let n=await this.keychain.findKeyByName(e),i=await this.keychain.getPrivateKey(e),s=IC.get(this);if(s==null)throw(0,pl.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let o=s.dek,a=dl.default.pki.decryptRsaPrivateKey(i,o),c=await Ine(n,a),l=dl.default.pkcs7.createEnvelopedData();l.addRecipient(c),l.content=dl.default.util.createBuffer(t),l.encrypt();let f=dl.default.asn1.toDer(l.toAsn1()).getBytes();return z(f,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw(0,pl.default)(new Error("CMS data is required"),F.ERR_INVALID_PARAMETERS);let t;try{let f=dl.default.util.createBuffer(K(e,"ascii")),h=dl.default.asn1.fromDer(f);t=dl.default.pkcs7.messageFromAsn1(h)}catch(f){throw z9e.error(f),(0,pl.default)(new Error("Invalid CMS"),F.ERR_INVALID_CMS)}let n=t.recipients.filter(f=>f.issuer.find(h=>h.shortName==="O"&&h.value==="ipfs")).filter(f=>f.issuer.find(h=>h.shortName==="CN")).map(f=>({recipient:f,keyId:f.issuer.find(h=>h.shortName==="CN").value})),i=await Ane(n,async f=>{try{if(await this.keychain.findKeyById(f.keyId)!=null)return!0}catch{return!1}return!1});if(i==null){let f=n.map(h=>h.keyId);throw(0,pl.default)(new Error(`Decryption needs one of the key(s): ${f.join(", ")}`),F.ERR_MISSING_KEYS,{missingKeys:f})}let s=await this.keychain.findKeyById(i.keyId);if(s==null)throw(0,pl.default)(new Error("No key available to decrypto"),F.ERR_NO_KEY);let o=await this.keychain.getPrivateKey(s.name),a=IC.get(this);if(a==null)throw(0,pl.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let c=a.dek,l=dl.default.pki.decryptRsaPrivateKey(o,c);return t.decrypt(i.recipient,l),z(t.content.getBytes(),"ascii")}};var Ft=E(V(),1);var fb=C("libp2p:keychain"),$9e="/pkcs8/",Cne="/info/",pf=new WeakMap,pd={minKeyLength:112/8,minSaltLength:128/8,minIterationCount:1e3},AC={dek:{keyLength:512/8,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function ml(r){return r==null||typeof r!="string"?!1:r===(0,Rne.default)(r.trim())&&r.length>0}async function Jt(){let t=Math.random()*800+200;await new Promise(n=>setTimeout(n,t))}function Za(r){return new fe($9e+r)}function yl(r){return new fe(Cne+r)}var Dg=class{constructor(e,t){if(this.components=e,this.init=Qe(AC,t),this.init.pass!=null&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(this.init.dek?.keyLength!=null&&this.init.dek.keyLength<pd.minKeyLength)throw new Error(`dek.keyLength must be least ${pd.minKeyLength} bytes`);if(this.init.dek?.salt?.length!=null&&this.init.dek.salt.length<pd.minSaltLength)throw new Error(`dek.saltLength must be least ${pd.minSaltLength} bytes`);if(this.init.dek?.iterationCount!=null&&this.init.dek.iterationCount<pd.minIterationCount)throw new Error(`dek.iterationCount must be least ${pd.minIterationCount}`);let n=this.init.pass!=null&&this.init.dek?.salt!=null?Hy(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";pf.set(this,{dek:n}),this.started=!1}isStarted(){return this.started}async start(){let e=yl("self");await this.components.getDatastore().has(e)||await this.importPeer("self",this.components.getPeerId()),this.started=!0}stop(){this.started=!1}get cms(){let e=pf.get(this);if(e==null)throw(0,Ft.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let t=e.dek;return new ub(this,t)}static generateOptions(){let e=Object.assign({},AC),t=Math.ceil(pd.minSaltLength/3)*3;return e.dek.salt=K(Si(t),"base64"),e}static get options(){return AC}async createKey(e,t,n=2048){if(!ml(e)||e==="self")throw await Jt(),(0,Ft.default)(new Error("Invalid key name"),F.ERR_INVALID_KEY_NAME);if(typeof t!="string")throw await Jt(),(0,Ft.default)(new Error("Invalid key type"),F.ERR_INVALID_KEY_TYPE);let i=Za(e);if(await this.components.getDatastore().has(i))throw await Jt(),(0,Ft.default)(new Error("Key name already exists"),F.ERR_KEY_ALREADY_EXISTS);switch(t.toLowerCase()){case"rsa":if(!Number.isSafeInteger(n)||n<2048)throw await Jt(),(0,Ft.default)(new Error("Invalid RSA key size"),F.ERR_INVALID_KEY_SIZE);break;default:break}let o;try{let a=await Mp(t,n),c=await a.id(),l=pf.get(this);if(l==null)throw(0,Ft.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let f=l.dek,h=await a.export(f);o={name:e,id:c};let p=this.components.getDatastore().batch();p.put(i,z(h)),p.put(yl(e),z(JSON.stringify(o))),await p.commit()}catch(a){throw await Jt(),a}return o}async listKeys(){let e={prefix:Cne},t=[];for await(let n of this.components.getDatastore().query(e))t.push(JSON.parse(K(n.value)));return t}async findKeyById(e){try{return(await this.listKeys()).find(n=>n.id===e)}catch(t){throw await Jt(),t}}async findKeyByName(e){if(!ml(e))throw await Jt(),(0,Ft.default)(new Error(`Invalid key name '${e}'`),F.ERR_INVALID_KEY_NAME);let t=yl(e);try{let n=await this.components.getDatastore().get(t);return JSON.parse(K(n))}catch(n){throw await Jt(),fb.error(n),(0,Ft.default)(new Error(`Key '${e}' does not exist.`),F.ERR_KEY_NOT_FOUND)}}async removeKey(e){if(!ml(e)||e==="self")throw await Jt(),(0,Ft.default)(new Error(`Invalid key name '${e}'`),F.ERR_INVALID_KEY_NAME);let t=Za(e),n=await this.findKeyByName(e),i=this.components.getDatastore().batch();return i.delete(t),i.delete(yl(e)),await i.commit(),n}async renameKey(e,t){if(!ml(e)||e==="self")throw await Jt(),(0,Ft.default)(new Error(`Invalid old key name '${e}'`),F.ERR_OLD_KEY_NAME_INVALID);if(!ml(t)||t==="self")throw await Jt(),(0,Ft.default)(new Error(`Invalid new key name '${t}'`),F.ERR_NEW_KEY_NAME_INVALID);let n=Za(e),i=Za(t),s=yl(e),o=yl(t);if(await this.components.getDatastore().has(i))throw await Jt(),(0,Ft.default)(new Error(`Key '${t}' already exists`),F.ERR_KEY_ALREADY_EXISTS);try{let c=await this.components.getDatastore().get(n),l=await this.components.getDatastore().get(s),f=JSON.parse(K(l));f.name=t;let h=this.components.getDatastore().batch();return h.put(i,c),h.put(o,z(JSON.stringify(f))),h.delete(n),h.delete(s),await h.commit(),f}catch(c){throw await Jt(),c}}async exportKey(e,t){if(!ml(e))throw await Jt(),(0,Ft.default)(new Error(`Invalid key name '${e}'`),F.ERR_INVALID_KEY_NAME);if(t==null)throw await Jt(),(0,Ft.default)(new Error("Password is required"),F.ERR_PASSWORD_REQUIRED);let n=Za(e);try{let i=await this.components.getDatastore().get(n),s=K(i),o=pf.get(this);if(o==null)throw(0,Ft.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let a=o.dek;return await(await Nc(s,a)).export(t)}catch(i){throw await Jt(),i}}async importKey(e,t,n){if(!ml(e)||e==="self")throw await Jt(),(0,Ft.default)(new Error(`Invalid key name '${e}'`),F.ERR_INVALID_KEY_NAME);if(t==null)throw await Jt(),(0,Ft.default)(new Error("PEM encoded key is required"),F.ERR_PEM_REQUIRED);let i=Za(e);if(await this.components.getDatastore().has(i))throw await Jt(),(0,Ft.default)(new Error(`Key '${e}' already exists`),F.ERR_KEY_ALREADY_EXISTS);let o;try{o=await Nc(t,n)}catch{throw await Jt(),(0,Ft.default)(new Error("Cannot read the key, most likely the password is wrong"),F.ERR_CANNOT_READ_KEY)}let a;try{a=await o.id();let f=pf.get(this);if(f==null)throw(0,Ft.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let h=f.dek;t=await o.export(h)}catch(f){throw await Jt(),f}let c={name:e,id:a},l=this.components.getDatastore().batch();return l.put(i,z(t)),l.put(yl(e),z(JSON.stringify(c))),await l.commit(),c}async importPeer(e,t){try{if(!ml(e))throw(0,Ft.default)(new Error(`Invalid key name '${e}'`),F.ERR_INVALID_KEY_NAME);if(t==null)throw(0,Ft.default)(new Error("PeerId is required"),F.ERR_MISSING_PRIVATE_KEY);if(t.privateKey==null)throw(0,Ft.default)(new Error("PeerId.privKey is required"),F.ERR_MISSING_PRIVATE_KEY);let n=await kn(t.privateKey),i=Za(e);if(await this.components.getDatastore().has(i))throw await Jt(),(0,Ft.default)(new Error(`Key '${e}' already exists`),F.ERR_KEY_ALREADY_EXISTS);let o=pf.get(this);if(o==null)throw(0,Ft.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let a=o.dek,c=await n.export(a),l={name:e,id:t.toString()},f=this.components.getDatastore().batch();return f.put(i,z(c)),f.put(yl(e),z(JSON.stringify(l))),await f.commit(),l}catch(n){throw await Jt(),n}}async getPrivateKey(e){if(!ml(e))throw await Jt(),(0,Ft.default)(new Error(`Invalid key name '${e}'`),F.ERR_INVALID_KEY_NAME);try{let t=Za(e),n=await this.components.getDatastore().get(t);return K(n)}catch(t){throw await Jt(),fb.error(t),(0,Ft.default)(new Error(`Key '${e}' does not exist.`),F.ERR_KEY_NOT_FOUND)}}async rotateKeychainPass(e,t){if(typeof e!="string")throw await Jt(),(0,Ft.default)(new Error(`Invalid old pass type '${typeof e}'`),F.ERR_INVALID_OLD_PASS_TYPE);if(typeof t!="string")throw await Jt(),(0,Ft.default)(new Error(`Invalid new pass type '${typeof t}'`),F.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw await Jt(),(0,Ft.default)(new Error(`Invalid pass length ${t.length}`),F.ERR_INVALID_PASS_LENGTH);fb("recreating keychain");let n=pf.get(this);if(n==null)throw(0,Ft.default)(new Error("dek missing"),F.ERR_INVALID_PARAMETERS);let i=n.dek;this.init.pass=t;let s=t!=null&&this.init.dek?.salt!=null?Hy(t,this.init.dek.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";pf.set(this,{dek:s});let o=await this.listKeys();for(let a of o){let c=await this.components.getDatastore().get(Za(a.name)),l=K(c),f=await Nc(l,i),h=s.toString(),p=await f.export(h),d=this.components.getDatastore().batch(),m={name:a.name,id:a.id};d.put(Za(a.name),z(p)),d.put(yl(a.name),z(JSON.stringify(m))),await d.commit()}fb("keychain reconstructed")}};u();var DC=E(RC(),1),kne=E(op(),1);u();var Dne={computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50};u();u();var CC=class{constructor(e){if(typeof e!="number")throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");this.timespan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timespan)}push(e,t){if(this.previousTime!=null){let n=this.alpha(e,this.previousTime),i=t-this.movingAverage,s=n*i;this.movingAverage=n*t+(1-n)*this.movingAverage,this.variance=(1-n)*(this.variance+i*s),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+n*i}else this.movingAverage=t;this.previousTime=e}};function PC(r){return new CC(r)}var One=E(Q1(),1),a1=class extends We{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t<e.initialCounters.length;t++){let n=e.initialCounters[t];this.stats[n]=0n,this.movingAverages[n]=[];for(let i=0;i<this.movingAverageIntervals.length;i++){let s=this.movingAverageIntervals[i];(this.movingAverages[n][s]=PC(s)).push(this.frequencyLastTime,0)}}}start(){!this.enabled||this.queue.length>0&&this._resetComputeTimeout()}stop(){this.timeout!=null&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=(0,One.default)(this._update,this._nextTimeout())}_nextTimeout(){let e=this.queue.length/this.computeThrottleMaxQueueSize;return Math.max(this.computeThrottleTimeout*(1-e),0)}_update(){if(this.timeout=null,this.queue.length>0){let e=["",0,0];for(e of this.queue)this._applyOp(e);this.queue=[],e.length>2&&e[0]!==""&&this._updateFrequency(e[2]),this.dispatchEvent(new ne("update",{detail:this.stats}))}}_updateFrequency(e){let t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,n){let i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;let o=i/(t??1)*1e3,a=this.movingAverages[e];a==null&&(a=this.movingAverages[e]=[]);let c=this.movingAverageIntervals;for(let l=0;l<c.length;l++){let f=c[l],h=a[f];h==null&&(h=a[f]=PC(f)),h.push(n,o)}}_applyOp(e){let t=e[0],n=e[1];if(typeof n!="number")throw new Error("invalid increment number");let i;Object.prototype.hasOwnProperty.call(this.stats,t)?i=this.stats[t]:i=this.stats[t]=0n,this.stats[t]=i+BigInt(n),this.frequencyAccumulators[t]==null&&(this.frequencyAccumulators[t]=0),this.frequencyAccumulators[t]+=n}};var j9e=["dataReceived","dataSent"],W9e={in:"dataReceived",out:"dataSent"},hb=class{constructor(e){this.enabled=e.enabled,this.statsInit={...e,initialCounters:j9e},this.globalStats=new a1(this.statsInit),this.peerStats=new Map,this.protocolStats=new Map,this.oldPeers=(0,kne.default)(e.maxOldPeersRetention??Dne.maxOldPeersRetention),this.running=!1,this._onMessage=this._onMessage.bind(this),this.systems=new Map}isStarted(){return this.running}async start(){!this.enabled||(this.running=!0)}async stop(){if(!!this.running){this.running=!1,this.globalStats.stop();for(let e of this.peerStats.values())e.stop();for(let e of this.protocolStats.values())e.stop()}}getGlobal(){return this.globalStats}getPeers(){return Array.from(this.peerStats.keys())}getComponentMetrics(){return this.systems}updateComponentMetric(e){let{system:t="libp2p",component:n,metric:i,value:s,label:o,help:a}=e;this.systems.has(t)||this.systems.set(t,new Map);let c=this.systems.get(t);if(c==null)throw new Error("Unknown metric system");c.has(n)||c.set(n,new Map);let l=c.get(n);if(l==null)throw new Error("Unknown metric component");l.set(i,{label:o,help:a,calculate:typeof s!="function"?()=>s:s})}forPeer(e){let t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){let t=e.toString(),n=this.peerStats.get(t);n!=null&&(n.stop(),this.peerStats.delete(t),this.oldPeers.set(t,n))}_onMessage(e){if(!this.running)return;let{remotePeer:t,protocol:n,direction:i,dataLength:s}=e,o=W9e[i],a=this.forPeer(t);if(a==null){let c=new a1(this.statsInit);this.peerStats.set(t.toString(),c),a=c}if(a.push(o,s),this.globalStats.push(o,s),n!=null){let c=this.forProtocol(n);if(c==null){let l=new a1(this.statsInit);this.protocolStats.set(n,l),c=l}c.push(o,s)}}updatePlaceholder(e,t){if(!this.running)return;let n=e.toString(),i=this.peerStats.get(n)??this.oldPeers.get(n),s=t.toString(),o=this.peerStats.get(s)??this.oldPeers.get(s),a=i;o!=null&&(a=Y9e(o,a),this.oldPeers.remove(s)),this.peerStats.delete(e.toString()),this.peerStats.set(s,a),a.start()}trackStream(e){let{stream:t,remotePeer:n,protocol:i}=e;if(!this.running)return;let s=t.source;t.source=(0,DC.default)(s,a=>this._onMessage({remotePeer:n,protocol:i,direction:"in",dataLength:a.byteLength}));let o=t.sink;t.sink=async a=>await we(a,c=>(0,DC.default)(c,l=>{this._onMessage({remotePeer:n,protocol:i,direction:"out",dataLength:l.byteLength})}),o)}};function Y9e(r,e){return r.stop(),e.stop(),r.queue=[...r.queue,...e.queue],r}u();u();u();async function Og(r){try{let e=await r;return{status:"fulfilled",value:e,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}u();u();var OC=class{value;next;constructor(e){this.value=e}},kg=class{#e;#t;#r;constructor(){this.clear()}enqueue(e){let t=new OC(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#r++}dequeue(){let e=this.#e;if(!!e)return this.#e=this.#e.next,this.#r--,e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}};function kC(r){if(!((Number.isInteger(r)||r===Number.POSITIVE_INFINITY)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new kg,t=0,n=()=>{t--,e.size>0&&e.dequeue()()},i=async(a,c,l)=>{t++;let f=(async()=>a(...l))();c(f);try{await f}catch{}n()},s=(a,c,l)=>{e.enqueue(i.bind(void 0,a,c,l)),(async()=>(await Promise.resolve(),t<r&&e.size>0&&e.dequeue()()))()},o=(a,...c)=>new Promise(l=>{s(a,l,c)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}async function NC(r,e={}){let{concurrency:t=Number.POSITIVE_INFINITY}=e,n=kC(t);return Promise.all(r.map(i=>i&&typeof i.then=="function"?Og(i):typeof i=="function"?Og(n(()=>i())):Og(Promise.resolve(i))))}var c1=E(V(),1);u();var LC=class extends Map{constructor(e){super();let{system:t,component:n,metric:i,metrics:s}=e;this.system=t??"libp2p",this.component=n,this.metric=i,this.metrics=s,this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){let t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metrics.updateComponentMetric({system:this.system,component:this.component,metric:this.metric,value:this.size})}};function ii(r){let{system:e,component:t,metric:n,metrics:i}=r,s;return i!=null?s=new LC({system:e,component:t,metric:n,metrics:i}):s=new Map,s}var md=C("libp2p:transports"),db=class extends We{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=ii({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??yd.FATAL_ALL}add(e){let t=e[Symbol.toStringTag];if(t==null)throw(0,c1.default)(new Error("Transport must have a valid tag"),F.ERR_INVALID_KEY);if(this.transports.has(t))throw(0,c1.default)(new Error("There is already a transport with this tag"),F.ERR_DUPLICATE_TRANSPORT);md("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}async start(){let e=this.components.getAddressManager().getListenAddrs();await this.listen(e),this.started=!0}async stop(){let e=[];for(let[t,n]of this.listeners)for(md("closing listeners for %s",t);n.length>0;){let i=n.pop();i!=null&&e.push(i.close())}await Promise.all(e),md("all listeners closed");for(let t of this.listeners.keys())this.listeners.set(t,[]);this.started=!1}async dial(e,t){let n=this.transportForMultiaddr(e);if(n==null)throw(0,c1.default)(new Error(`No transport available for address ${String(e)}`),F.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(e,{...t,upgrader:this.components.getUpgrader()})}catch(i){throw i.code==null&&(i.code=F.ERR_TRANSPORT_DIAL_FAILED),i}}getAddrs(){let e=[];for(let t of this.listeners.values())for(let n of t)e=[...e,...n.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}transportForMultiaddr(e){for(let t of this.transports.values())if(t.filter([e]).length>0)return t}async listen(e){if(e==null||e.length===0){md("no addresses were provided for listening, this node is dial only");return}let t=[];for(let[n,i]of this.transports.entries()){let s=i.filter(e),o=[];for(let l of s){md("creating listener for %s on %s",n,l);let f=i.createListener({upgrader:this.components.getUpgrader()}),h=this.listeners.get(n);h==null&&(h=[],this.listeners.set(n,h)),h.push(f),f.addEventListener("listening",()=>{this.dispatchEvent(new ne("listener:listening",{detail:f}))}),f.addEventListener("close",()=>{this.dispatchEvent(new ne("listener:close",{detail:f}))}),o.push(f.listen(l))}if(o.length===0){t.push(n);continue}if((await NC(o)).find(l=>l.isFulfilled)==null&&this.faultTolerance!==yd.NO_FATAL)throw(0,c1.default)(new Error(`Transport (${n}) could not listen on any available address`),F.ERR_NO_VALID_ADDRESSES)}if(t.length===this.transports.size){let n=`no valid addresses were provided for transports [${t.join(", ")}]`;if(this.faultTolerance===yd.FATAL_ALL)throw(0,c1.default)(new Error(n),F.ERR_NO_VALID_ADDRESSES);md(`libp2p in dial mode only: ${n}`)}}async remove(e){md("removing %s",e);for(let t of this.listeners.get(e)??[])await t.close();this.transports.delete(e),this.listeners.delete(e)}async removeAll(){let e=[];for(let t of this.transports.keys())e.push(this.remove(t));await Promise.all(e)}},yd;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(yd||(yd={}));u();var Hn=E(V(),1);u();u();var gl="/multistream/1.0.0";u();var Une=E(V(),1);u();var BC=E(V(),1);var Nne=E(Oa(),1);var Lne=z(`
`);function pb(r){let e=new Mt(r,Lne);return mr.single(e)}function gd(r,e,t={}){let n=pb(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function Bne(r,e,t={}){let n=new Mt;for(let i of e)n.append(pb(i));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function Q9e(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>await r.next(t)},i=n;e?.signal!=null&&(i=Kr(n,e.signal));let o=await we(i,yr({onLength:a=>{t=a}}),async a=>await(0,Nne.default)(a));if(o==null)throw(0,BC.default)(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==Lne[0])throw(0,BC.default)(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}async function l1(r,e){let t=await Q9e(r,e);return K(t.subarray())}var Ng=C("libp2p:mss:select");async function Lg(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:i,rest:s,stream:o}=ff(r),a=e.shift();if(a==null)throw new Error("At least one protocol must be specified");Ng('select: write ["%s", "%s"]',gl,a);let c=z(gl),l=z(a);Bne(i,[c,l],t);let f=await l1(n,t);if(Ng('select: read "%s"',f),f===gl&&(f=await l1(n,t),Ng('select: read "%s"',f)),f===a)return s(),{stream:o,protocol:a};for(let h of e){Ng('select: write "%s"',h),gd(i,z(h),t);let p=await l1(n,t);if(Ng('select: read "%s" for "%s"',p,h),p===h)return s(),{stream:o,protocol:h}}throw s(),(0,Une.default)(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}u();var Bg=C("libp2p:mss:handle");async function Mg(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:i,rest:s,stream:o}=ff(r);for(;;){let a=await l1(i,t);if(Bg('read "%s"',a),a===gl){Bg('respond with "%s" for "%s"',gl,a),gd(n,z(gl),t);continue}if(e.includes(a))return gd(n,z(a),t),Bg('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};if(a==="ls"){gd(n,new Mt(...e.map(c=>pb(z(c)))),t),Bg('respond with "%s" for %s',e,a);continue}gd(n,z("na"),t),Bg('respond with "na" for "%s"',a)}}var KC=E(Vne(),1);u();var MC=E(V(),1);u();var Kne=Symbol.for("@libp2p/connection");var J9e=C("libp2p:connection"),UC=class{constructor(e){let{remoteAddr:t,remotePeer:n,newStream:i,close:s,getStreams:o,stat:a}=e;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=n,this.stat={...a,status:GE},this._newStream=i,this._close=s,this._getStreams=o,this.tags=[],this._closing=!1}get[Symbol.toStringTag](){return"Connection"}get[Kne](){return!0}get streams(){return this._getStreams()}async newStream(e,t){if(this.stat.status===aC)throw(0,MC.default)(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===jE)throw(0,MC.default)(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);let n=await this._newStream(e,t);return n.stat.direction="outbound",n}addStream(e){e.stat.direction="inbound"}removeStream(e){}async close(){if(!(this.stat.status===jE||this._closing)){this.stat.status=aC;try{this.streams.forEach(e=>e.close())}catch(e){J9e.error(e)}this._closing=!0,await this._close(),this._closing=!1,this.stat.timeline.close=Date.now(),this.stat.status=jE}}};function qne(r){return new UC(r)}u();var mb=E(V(),1);var zne=C("libp2p:registrar"),FC=32,VC=64,yb=class{constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onProtocolChange=this._onProtocolChange.bind(this),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onDisconnect),this.components.getPeerStore().addEventListener("change:protocols",this._onProtocolChange)}getProtocols(){return Array.from(new Set([...this.topologies.keys(),...this.handlers.keys()])).sort()}getHandler(e){let t=this.handlers.get(e);if(t==null)throw(0,mb.default)(new Error(`No handler registered for protocol ${e}`),F.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){let t=this.topologies.get(e);return t==null?[]:[...t.values()]}async handle(e,t,n){if(this.handlers.has(e))throw(0,mb.default)(new Error(`Handler already registered for protocol ${e}`),F.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);let i=Qe.bind({ignoreUndefined:!0})({maxInboundStreams:FC,maxOutboundStreams:VC},n);this.handlers.set(e,{handler:t,options:i}),await this.components.getPeerStore().protoBook.add(this.components.getPeerId(),[e])}async unhandle(e){let t=Array.isArray(e)?e:[e];t.forEach(n=>{this.handlers.delete(n)}),await this.components.getPeerStore().protoBook.remove(this.components.getPeerId(),t)}async register(e,t){if(!BQ(t))throw zne.error("topology must be an instance of interfaces/topology"),(0,mb.default)(new Error("topology must be an instance of interfaces/topology"),F.ERR_INVALID_PARAMETERS);let n=`${(Math.random()*1e9).toString(36)}${Date.now()}`,i=this.topologies.get(e);return i==null&&(i=new Map,this.topologies.set(e,i)),i.set(n,t),await t.setRegistrar(this),n}unregister(e){for(let[t,n]of this.topologies.entries())n.has(e)&&(n.delete(e),n.size===0&&this.topologies.delete(t))}_onDisconnect(e){let t=e.detail;this.components.getPeerStore().protoBook.get(t.remotePeer).then(n=>{for(let i of n){let s=this.topologies.get(i);if(s!=null)for(let o of s.values())o.onDisconnect(t.remotePeer)}}).catch(n=>{zne.error(n)})}_onProtocolChange(e){let{peerId:t,protocols:n,oldProtocols:i}=e.detail,s=i.filter(a=>!n.includes(a)),o=n.filter(a=>!i.includes(a));for(let a of s){let c=this.topologies.get(a);if(c!=null)for(let l of c.values())l.onDisconnect(t)}for(let a of o){let c=this.topologies.get(a);if(c!=null)for(let l of c.values()){let f=this.components.getConnectionManager().getConnections(t)[0];f!=null&&l.onConnect(t,f)}}}};var qC=E(an(),1);var zC=E(bn(),1),fr=C("libp2p:upgrader");function eSe(r,e){try{let{options:t}=e.getHandler(r);return t.maxInboundStreams}catch(t){if(t.code!==F.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return FC}function tSe(r,e){try{let{options:t}=e.getHandler(r);return t.maxOutboundStreams}catch(t){if(t.code!==F.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return VC}function $ne(r,e,t){let n=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===r&&n++}),n}var gb=class extends We{constructor(e,t){super(),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,t.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout}async upgradeInbound(e){let t,n,i,s,o,a,c,l=this.components.getMetrics(),f=new qC.TimeoutController(this.inboundUpgradeTimeout);try{(0,zC.setMaxListeners)?.(1/0,f.signal)}catch{}try{let h=ti(e,f.signal);if(e.source=h.source,e.sink=h.sink,await this.components.getConnectionGater().denyInboundConnection(e))throw(0,Hn.default)(new Error("The multiaddr connection is blocked by gater.acceptConnection"),F.ERR_CONNECTION_INTERCEPTED);if(l!=null){({setTarget:a,proxy:c}=(0,KC.default)());let m=`${(Math.random()*1e9).toString(36)}${Date.now()}`;a({toString:()=>m}),l.trackStream({stream:e,remotePeer:c})}fr("starting the inbound connection upgrade");let p=e,d=this.components.getConnectionProtector();d!=null&&(fr("protecting the inbound connection"),p=await d.protect(e));try{if({conn:t,remotePeer:n,protocol:o}=await this._encryptInbound(p),await this.components.getConnectionGater().denyInboundEncryptedConnection(n,{...p,...t}))throw(0,Hn.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),F.ERR_CONNECTION_INTERCEPTED);if(this.muxers.size>0){let m=await this._multiplexInbound({...p,...t},this.muxers);s=m.muxerFactory,i=m.stream}else i=t}catch(m){throw fr.error("Failed to upgrade inbound connection",m),await e.close(m),m}if(await this.components.getConnectionGater().denyInboundUpgradedConnection(n,{...p,...t}))throw(0,Hn.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),F.ERR_CONNECTION_INTERCEPTED);return l!=null&&(l.updatePlaceholder(c,n),a(n)),fr("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:s,remotePeer:n})}finally{f.clear()}}async upgradeOutbound(e){let t=e.remoteAddr.getPeerId();if(t==null)throw(0,Hn.default)(new Error("outbound connection must have a peer id"),F.ERR_INVALID_MULTIADDR);let n=pe(t);if(await this.components.getConnectionGater().denyOutboundConnection(n,e))throw(0,Hn.default)(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),F.ERR_CONNECTION_INTERCEPTED);let i,s,o,a,c,l,f,h=this.components.getMetrics();if(h!=null){({setTarget:l,proxy:f}=(0,KC.default)());let m=`${(Math.random()*1e9).toString(36)}${Date.now()}`;l({toB58String:()=>m}),h.trackStream({stream:e,remotePeer:f})}fr("Starting the outbound connection upgrade");let p=e,d=this.components.getConnectionProtector();d!=null&&(p=await d.protect(e));try{if({conn:i,remotePeer:s,protocol:a}=await this._encryptOutbound(p,n),await this.components.getConnectionGater().denyOutboundEncryptedConnection(s,{...p,...i}))throw(0,Hn.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),F.ERR_CONNECTION_INTERCEPTED);if(this.muxers.size>0){let m=await this._multiplexOutbound({...p,...i},this.muxers);c=m.muxerFactory,o=m.stream}else o=i}catch(m){throw fr.error("Failed to upgrade outbound connection",m),await e.close(m),m}if(await this.components.getConnectionGater().denyOutboundUpgradedConnection(s,{...p,...i}))throw(0,Hn.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),F.ERR_CONNECTION_INTERCEPTED);return h!=null&&(h.updatePlaceholder(f,s),l(s)),fr("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:a,direction:"outbound",maConn:e,upgradedConn:o,muxerFactory:c,remotePeer:s})}_createConnection(e){let{cryptoProtocol:t,direction:n,maConn:i,upgradedConn:s,remotePeer:o,muxerFactory:a}=e,c,l,f;a!=null&&(c=a.createStreamMuxer({direction:n,onIncomingStream:d=>{f!=null&&Promise.resolve().then(async()=>{let m=this.components.getRegistrar().getProtocols(),{stream:y,protocol:g}=await Mg(d,m);fr("%s: incoming stream opened on %s",n,g);let w=this.components.getMetrics();if(w?.trackStream({stream:y,remotePeer:o,protocol:g}),f==null)return;let b=eSe(g,this.components.getRegistrar());if($ne(g,"inbound",f)===b){d.abort((0,Hn.default)(new Error(`Too many inbound protocol streams for protocol "${g}" - limit ${b}`),F.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS));return}d.source=y.source,d.sink=y.sink,d.stat.protocol=g,this.components.getPeerStore().protoBook.add(o,[g]).catch(_=>fr.error(_)),f.addStream(d),this._onStream({connection:f,stream:d,protocol:g})}).catch(m=>{fr.error(m),d.stat.timeline.close==null&&d.close()})},onStreamEnd:d=>{f?.removeStream(d.id)}}),_n(c)&&c.init(this.components),l=async(d,m={})=>{if(c==null)throw(0,Hn.default)(new Error("Stream is not multiplexed"),F.ERR_MUXER_UNAVAILABLE);fr("%s: starting new stream on %s",n,d);let y=c.newStream(),g=this.components.getMetrics(),w;try{if(m.signal==null){fr("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",d),w=new qC.TimeoutController(3e4),m.signal=w.signal;try{(0,zC.setMaxListeners)?.(1/0,w.signal)}catch{}}let{stream:b,protocol:S}=await Lg(y,d,m);g?.trackStream({stream:b,remotePeer:o,protocol:S});let _=tSe(S,this.components.getRegistrar());if($ne(S,"outbound",f)===_){let T=(0,Hn.default)(new Error(`Too many outbound protocol streams for protocol "${S}" - limit ${_}`),F.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw y.abort(T),T}return this.components.getPeerStore().protoBook.add(o,[S]).catch(T=>fr.error(T)),y.source=b.source,y.sink=b.sink,y.stat.protocol=S,y}catch(b){throw fr.error("could not create new stream",b),y.stat.timeline.close==null&&y.close(),b.code!=null?b:(0,Hn.default)(b,F.ERR_UNSUPPORTED_PROTOCOL)}finally{w?.clear()}},we(s,c,s).catch(fr.error));let h=i.timeline;i.timeline=new Proxy(h,{set:(...d)=>(f!=null&&d[1]==="close"&&d[2]!=null&&h.close==null&&(async()=>{try{f.stat.status==="OPEN"&&await f.close()}catch(m){fr.error(m)}finally{this.dispatchEvent(new ne("connectionEnd",{detail:f}))}})().catch(m=>{fr.error(m)}),Reflect.set(...d))}),i.timeline.upgraded=Date.now();let p=()=>{throw(0,Hn.default)(new Error("connection is not multiplexed"),F.ERR_CONNECTION_NOT_MULTIPLEXED)};return f=qne({remoteAddr:i.remoteAddr,remotePeer:o,stat:{status:"OPEN",direction:n,timeline:i.timeline,multiplexer:c?.protocol,encryption:t},newStream:l??p,getStreams:()=>c!=null?c.streams:p(),close:async()=>{await i.close(),c?.close()}}),this.dispatchEvent(new ne("connection",{detail:f})),f}_onStream(e){let{connection:t,stream:n,protocol:i}=e,{handler:s}=this.components.getRegistrar().getHandler(i);s({connection:t,stream:n})}async _encryptInbound(e){let t=Array.from(this.connectionEncryption.keys());fr("handling inbound crypto protocol selection",t);try{let{stream:n,protocol:i}=await Mg(e,t,{writeBytes:!0}),s=this.connectionEncryption.get(i);if(s==null)throw new Error(`no crypto module found for ${i}`);return fr("encrypting inbound connection..."),{...await s.secureInbound(this.components.getPeerId(),n),protocol:i}}catch(n){throw(0,Hn.default)(n,F.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){let n=Array.from(this.connectionEncryption.keys());fr("selecting outbound crypto protocol",n);try{let{stream:i,protocol:s}=await Lg(e,n,{writeBytes:!0}),o=this.connectionEncryption.get(s);if(o==null)throw new Error(`no crypto module found for ${s}`);return fr("encrypting outbound connection to %p",t),{...await o.secureOutbound(this.components.getPeerId(),i,t),protocol:s}}catch(i){throw(0,Hn.default)(i,F.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){let n=Array.from(t.keys());fr("outbound selecting muxer %s",n);try{let{stream:i,protocol:s}=await Lg(e,n,{writeBytes:!0});fr("%s selected as muxer protocol",s);let o=t.get(s);return{stream:i,muxerFactory:o}}catch(i){throw fr.error("error multiplexing outbound stream",i),(0,Hn.default)(i,F.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){let n=Array.from(t.keys());fr("inbound handling muxers %s",n);try{let{stream:i,protocol:s}=await Mg(e,n,{writeBytes:!0}),o=t.get(s);return{stream:i,muxerFactory:o}}catch(i){throw fr.error("error multiplexing inbound stream",i),(0,Hn.default)(i,F.ERR_MUXER_UNAVAILABLE)}}};u();var Ed=E(V(),1);var HC=E(fi(),1),GC=E(Oa(),1);u();var wd;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.protocolVersion!=null&&(n.uint32(42),n.string(t.protocolVersion)),t.agentVersion!=null&&(n.uint32(50),n.string(t.agentVersion)),t.publicKey!=null&&(n.uint32(10),n.bytes(t.publicKey)),t.listenAddrs!=null)for(let s of t.listenAddrs)n.uint32(18),n.bytes(s);else throw new Error('Protocol error: required field "listenAddrs" was not found in object');if(t.observedAddr!=null&&(n.uint32(34),n.bytes(t.observedAddr)),t.protocols!=null)for(let s of t.protocols)n.uint32(26),n.string(s);else throw new Error('Protocol error: required field "protocols" was not found in object');t.signedPeerRecord!=null&&(n.uint32(66),n.bytes(t.signedPeerRecord)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 5:i.protocolVersion=t.string();break;case 6:i.agentVersion=t.string();break;case 1:i.publicKey=t.bytes();break;case 2:i.listenAddrs=i.listenAddrs??[],i.listenAddrs.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols=i.protocols??[],i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(o&7);break}}if(i.listenAddrs=i.listenAddrs??[],i.protocols=i.protocols??[],i.listenAddrs==null)throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf');if(i.protocols==null)throw new Error('Protocol error: value for required field "protocols" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(wd||(wd={}));u();u();var wb="0.0.0",Hne="libp2p";var $C=`js-libp2p/${wb}`;var Gne="0.1.0",jne="id",Wne="id/push",Yne="1.0.0",Qne="1.0.0";var Ug=E(an(),1);var Fg=E(bn(),1),rr=C("libp2p:identify"),Xne=1024*8,u1=class{constructor(e,t){this.components=e,this.started=!1,this.init=t,this.identifyProtocolStr=`/${t.protocolPrefix}/${jne}/${Yne}`,this.identifyPushProtocolStr=`/${t.protocolPrefix}/${Wne}/${Qne}`,this.host={protocolVersion:`${t.protocolPrefix}/${Gne}`,...t.host},this.components.getConnectionManager().addEventListener("peer:connect",n=>{let i=n.detail;this.identify(i).catch(rr.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",n=>{let{peerId:i}=n.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>rr.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",n=>{let{peerId:i}=n.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>rr.error(s))})}isStarted(){return this.started}async start(){this.started||(await this.components.getPeerStore().metadataBook.setValue(this.components.getPeerId(),"AgentVersion",z(this.host.agentVersion)),await this.components.getPeerStore().metadataBook.setValue(this.components.getPeerId(),"ProtocolVersion",z(this.host.protocolVersion)),await this.components.getRegistrar().handle(this.identifyProtocolStr,e=>{this._handleIdentify(e).catch(t=>{rr.error(t)})},{maxInboundStreams:this.init.maxInboundStreams,maxOutboundStreams:this.init.maxOutboundStreams}),await this.components.getRegistrar().handle(this.identifyPushProtocolStr,e=>{this._handlePush(e).catch(t=>{rr.error(t)})},{maxInboundStreams:this.init.maxPushIncomingStreams,maxOutboundStreams:this.init.maxPushOutgoingStreams}),this.started=!0)}async stop(){await this.components.getRegistrar().unhandle(this.identifyProtocolStr),await this.components.getRegistrar().unhandle(this.identifyPushProtocolStr),this.started=!1}async push(e){let t=await this.components.getPeerStore().addressBook.getRawEnvelope(this.components.getPeerId()),n=this.components.getAddressManager().getAddresses().map(o=>o.bytes),i=await this.components.getPeerStore().protoBook.get(this.components.getPeerId()),s=e.map(async o=>{let a,c=new Ug.TimeoutController(this.init.timeout);try{(0,Fg.setMaxListeners)?.(1/0,c.signal)}catch{}try{a=await o.newStream([this.identifyPushProtocolStr],{signal:c.signal});let l=ti(a,c.signal);await we([wd.encode({listenAddrs:n,signedPeerRecord:t,protocols:i})],mr(),l,HC.default)}catch(l){rr.error("could not push identify update to peer",l)}finally{a?.close(),c.clear()}});await Promise.all(s)}async pushToPeerStore(){if(!this.isStarted())return;let e=[];for(let t of this.components.getConnectionManager().getConnections()){let n=t.remotePeer;!(await this.components.getPeerStore().get(n)).protocols.includes(this.identifyPushProtocolStr)||e.push(t)}await this.push(e)}async _identify(e,t={}){let n,i=t.signal,s;if(i==null){n=new Ug.TimeoutController(this.init.timeout),i=n.signal;try{(0,Fg.setMaxListeners)?.(1/0,n.signal)}catch{}}try{s=await e.newStream([this.identifyProtocolStr],{signal:i});let o=ti(s,i),a=await we([],o,yr({maxDataLength:this.init.maxIdentifyMessageSize??Xne}),async c=>await(0,GC.default)(c));if(a==null)throw(0,Ed.default)(new Error("No data could be retrieved"),F.ERR_CONNECTION_ENDED);try{return wd.decode(a)}catch(c){throw(0,Ed.default)(c,F.ERR_INVALID_MESSAGE)}}finally{n?.clear(),s?.close()}}async identify(e,t={}){let n=await this._identify(e,t),{publicKey:i,listenAddrs:s,protocols:o,observedAddr:a,signedPeerRecord:c,agentVersion:l,protocolVersion:f}=n;if(i==null)throw(0,Ed.default)(new Error("public key was missing from identify message"),F.ERR_MISSING_PUBLIC_KEY);let h=await ln(i);if(!e.remotePeer.equals(h))throw(0,Ed.default)(new Error("identified peer does not match the expected peer"),F.ERR_INVALID_PEER);if(this.components.getPeerId().equals(h))throw(0,Ed.default)(new Error("identified peer is our own peer id?"),F.ERR_INVALID_PEER);let p=u1.getCleanMultiaddr(a);if(c!=null){rr("received signed peer record from %p",h);try{let d=await Jr.openAndCertify(c,hn.DOMAIN);if(!d.peerId.equals(h))throw(0,Ed.default)(new Error("identified peer does not match the expected peer"),F.ERR_INVALID_PEER);if(await this.components.getPeerStore().addressBook.consumePeerRecord(d)){await this.components.getPeerStore().protoBook.set(h,o),l!=null&&await this.components.getPeerStore().metadataBook.setValue(h,"AgentVersion",z(l)),f!=null&&await this.components.getPeerStore().metadataBook.setValue(h,"ProtocolVersion",z(f)),rr("identify completed for peer %p and protocols %o",h,o);return}}catch(d){rr("received invalid envelope, discard it and fallback to listenAddrs is available",d)}}else rr("no signed peer record received from %p",h);rr("falling back to legacy addresses from %p",h);try{await this.components.getPeerStore().addressBook.set(h,s.map(d=>se(d)))}catch(d){rr.error("received invalid addrs",d)}await this.components.getPeerStore().protoBook.set(h,o),l!=null&&await this.components.getPeerStore().metadataBook.setValue(h,"AgentVersion",z(l)),f!=null&&await this.components.getPeerStore().metadataBook.setValue(h,"ProtocolVersion",z(f)),rr("identify completed for peer %p and protocols %o",h,o),rr("received observed address of %s",p?.toString())}async _handleIdentify(e){let{connection:t,stream:n}=e,i=new Ug.TimeoutController(this.init.timeout);try{(0,Fg.setMaxListeners)?.(1/0,i.signal)}catch{}try{let s=this.components.getPeerId().publicKey??new Uint8Array(0),o=await this.components.getPeerStore().get(this.components.getPeerId()),a=this.components.getAddressManager().getAddresses().map(h=>h.decapsulateCode(Yt("p2p").code)),c=o.peerRecordEnvelope;if(a.length>0&&c==null){let h=new hn({peerId:this.components.getPeerId(),multiaddrs:a}),p=await Jr.seal(h,this.components.getPeerId());await this.components.getPeerStore().addressBook.consumePeerRecord(p),c=p.marshal().subarray()}let l=wd.encode({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:s,listenAddrs:a.map(h=>h.bytes),signedPeerRecord:c,observedAddr:t.remoteAddr.bytes,protocols:o.protocols}),f=ti(n,i.signal);await we([l],mr(),f,HC.default)}catch(s){rr.error("could not respond to identify request",s)}finally{n.close(),i.clear()}}async _handlePush(e){let{connection:t,stream:n}=e,i=new Ug.TimeoutController(this.init.timeout);try{(0,Fg.setMaxListeners)?.(1/0,i.signal)}catch{}let s;try{let a=ti(n,i.signal),c=await we([],a,yr({maxDataLength:this.init.maxIdentifyMessageSize??Xne}),async l=>await(0,GC.default)(l));c!=null&&(s=wd.decode(c))}catch(a){return rr.error("received invalid message",a)}finally{n.close(),i.clear()}if(s==null)return rr.error("received invalid message");let o=t.remotePeer;if(this.components.getPeerId().equals(o)){rr("received push from ourselves?");return}if(rr("received push from %p",o),s.signedPeerRecord!=null){rr("received signedPeerRecord in push");try{let a=await Jr.openAndCertify(s.signedPeerRecord,hn.DOMAIN);if(await this.components.getPeerStore().addressBook.consumePeerRecord(a)){rr("consumed signedPeerRecord sent in push"),await this.components.getPeerStore().protoBook.set(o,s.protocols);return}else rr("failed to consume signedPeerRecord sent in push")}catch(a){rr("received invalid envelope, discard it and fallback to listenAddrs is available",a)}}else rr("did not receive signedPeerRecord in push");try{await this.components.getPeerStore().addressBook.set(o,s.listenAddrs.map(a=>se(a)))}catch(a){rr.error("received invalid addrs",a)}try{await this.components.getPeerStore().protoBook.set(o,s.protocols)}catch(a){rr.error("received invalid protocols",a)}rr("handled push from %p",o)}static getCleanMultiaddr(e){if(e!=null&&e.length>0)try{return se(e)}catch{}}};u();var f1=E(V(),1);u();var Vg;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.identifier!=null)n.uint32(10),n.string(t.identifier);else throw new Error('Protocol error: required field "identifier" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.identifier=t.string();break;default:t.skipType(o&7);break}}if(i.identifier==null)throw new Error('Protocol error: value for required field "identifier" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(Vg||(Vg={}));var Go;(function(r){let e;(function(i){i.OK="OK",i.NOT_FOUND="NOT_FOUND",i.ERROR="ERROR"})(e=r.StatusCode||(r.StatusCode={}));let t;(function(i){i[i.OK=0]="OK",i[i.NOT_FOUND=1]="NOT_FOUND",i[i.ERROR=2]="ERROR"})(t||(t={})),function(i){i.codec=()=>Hi(t)}(e=r.StatusCode||(r.StatusCode={}));let n;r.codec=()=>(n==null&&(n=Et((i,s,o={})=>{if(o.lengthDelimited!==!1&&s.fork(),i.status!=null)s.uint32(8),r.StatusCode.codec().encode(i.status,s);else throw new Error('Protocol error: required field "status" was not found in object');if(i.data!=null)s.uint32(18),s.bytes(i.data);else throw new Error('Protocol error: required field "data" was not found in object');o.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let o={},a=s==null?i.len:i.pos+s;for(;i.pos<a;){let c=i.uint32();switch(c>>>3){case 1:o.status=r.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(c&7);break}}if(o.status==null)throw new Error('Protocol error: value for required field "status" was not found in protobuf');if(o.data==null)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),n),r.encode=i=>wt(i,r.codec()),r.decode=i=>gt(i,r.codec())})(Go||(Go={}));u();var Zne="0.0.1",Jne="fetch";var jC=E(Oa(),1),tie=E(an(),1),rie=E(bn(),1),eie=C("libp2p:fetch"),Eb=class{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/${Jne}/${Zne}`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}async start(){await this.components.getRegistrar().handle(this.protocol,e=>{this.handleMessage(e).catch(t=>{eie.error(t)}).finally(()=>{e.stream.close()})},{maxInboundStreams:this.init.maxInboundStreams,maxOutboundStreams:this.init.maxOutboundStreams}),this.started=!0}async stop(){await this.components.getRegistrar().unhandle(this.protocol),this.started=!1}isStarted(){return this.started}async fetch(e,t,n={}){eie("dialing %s to %p",this.protocol,e);let i=await this.components.getConnectionManager().openConnection(e,n),s,o=n.signal,a;if(o==null){s=new tie.TimeoutController(this.init.timeout),o=s.signal;try{(0,rie.setMaxListeners)?.(1/0,s.signal)}catch{}}try{a=await i.newStream([this.protocol],{signal:o});let c=ti(a,o);return await we([Vg.encode({identifier:t})],mr(),c,yr(),async function(f){let h=await(0,jC.default)(f);if(h==null)throw(0,f1.default)(new Error("No data received"),F.ERR_INVALID_MESSAGE);let p=Go.decode(h);switch(p.status){case Go.StatusCode.OK:return p.data;case Go.StatusCode.NOT_FOUND:return null;case Go.StatusCode.ERROR:{let d=new TextDecoder().decode(p.data);throw(0,f1.default)(new Error("Error in fetch protocol response: "+d),F.ERR_INVALID_PARAMETERS)}default:throw(0,f1.default)(new Error("Unknown response status"),F.ERR_INVALID_MESSAGE)}})??null}finally{s?.clear(),a?.close()}}async handleMessage(e){let{stream:t}=e,n=this;await we(t,yr(),async function*(i){let s=await(0,jC.default)(i);if(s==null)throw(0,f1.default)(new Error("No data received"),F.ERR_INVALID_MESSAGE);let o=Vg.decode(s),a,c=n._getLookupFunction(o.identifier);if(c!=null){let l=await c(o.identifier);l!=null?a={status:Go.StatusCode.OK,data:l}:a={status:Go.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{let l=new TextEncoder().encode("No lookup function registered for key: "+o.identifier);a={status:Go.StatusCode.ERROR,data:l}}yield Go.encode(a)},mr(),t)}_getLookupFunction(e){for(let t of this.lookupFunctions.keys())if(e.startsWith(t))return this.lookupFunctions.get(t)}registerLookupFunction(e,t){if(this.lookupFunctions.has(e))throw(0,f1.default)(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),F.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){t!=null&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}};u();var oie=E(V(),1);var aie=E(Oa(),1);u();var nie="1.0.0",iie="ping";var cie=E(an(),1),lie=E(bn(),1),sie=C("libp2p:ping"),bb=class{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/${iie}/${nie}`,this.init=t}async start(){await this.components.getRegistrar().handle(this.protocol,this.handleMessage,{maxInboundStreams:this.init.maxInboundStreams,maxOutboundStreams:this.init.maxOutboundStreams}),this.started=!0}async stop(){await this.components.getRegistrar().unhandle(this.protocol),this.started=!1}isStarted(){return this.started}handleMessage(e){let{stream:t}=e;we(t,t).catch(n=>{sie.error(n)})}async ping(e,t={}){sie("dialing %s to %p",this.protocol,e);let n=Date.now(),i=Si(32),s=await this.components.getConnectionManager().openConnection(e,t),o,a=t.signal,c;if(a==null){o=new cie.TimeoutController(this.init.timeout),a=o.signal;try{(0,lie.setMaxListeners)?.(1/0,o.signal)}catch{}}try{c=await s.newStream([this.protocol],{signal:a});let l=ti(c,a),f=await we([i],l,async p=>await(0,aie.default)(p)),h=Date.now();if(f==null||!ze(i,f.subarray()))throw(0,oie.default)(new Error("Received wrong ping ack"),F.ERR_WRONG_PING_ACK);return h-n}finally{o?.clear(),c?.close()}}};u();u();async function uie(){throw new Error("Not supported in browsers")}u();var fie=E(kv(),1),WC=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,vb=(0,fie.default)(),bd=WC&&!vb,hie=vb&&!WC,die=vb&&WC,pie=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!vb,_b=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,p6t=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",mie=typeof navigator<"u"&&navigator.product==="ReactNative";var wie=E(nb(),1);var Eie=E(V(),1);u();u();function yie(r){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(r)||/^::1$/.test(r)}function gie(r){let{address:e}=r.nodeAddress();return yie(e)}var YC=C("libp2p:nat"),QC=7200;function iSe(r=1024,e=65535){return Math.floor(Math.random()*(e-r+1)+r)}var Sb=class{constructor(e,t){if(this.components=e,this.started=!1,this.enabled=t.enabled,this.externalAddress=t.externalAddress,this.localAddress=t.localAddress,this.description=t.description??`${Hne}@${wb} ${this.components.getPeerId().toString()}`,this.ttl=t.ttl??QC,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<QC)throw(0,Eie.default)(new Error(`NatManager ttl should be at least ${QC} seconds`),F.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){bd||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{YC.error(e)}))}async _start(){let e=this.components.getTransportManager().getAddrs();for(let t of e){let{family:n,host:i,port:s,transport:o}=t.toOptions();if(!t.isThinWaistAddress()||o!=="tcp"||gie(t)||n!==4)continue;let a=await this._getClient(),c=this.externalAddress??await a.externalIp();if((0,wie.default)(c))throw new Error(`${c} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);let l=iSe();YC(`opening uPnP connection from ${c}:${l} to ${i}:${s}`),await a.map({publicPort:l,localPort:s,localAddress:this.localAddress,protocol:o.toUpperCase()==="TCP"?"TCP":"UDP"}),this.components.getAddressManager().addObservedAddr(FL({family:4,address:c,port:l},o))}}async _getClient(){return this.client!=null?this.client:(this.client=await uie({description:this.description,ttl:this.ttl,keepAlive:this.keepAlive,gateway:this.gateway}),this.client)}async stop(){if(!(bd||this.client==null))try{await this.client.close(),this.client=void 0}catch(e){YC.error(e)}}};u();var sSe=C("libp2p:peer-record-updater"),xb=class{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}async start(){this.started=!0,this.components.getTransportManager().addEventListener("listener:listening",this.update),this.components.getTransportManager().addEventListener("listener:close",this.update),this.components.getAddressManager().addEventListener("change:addresses",this.update)}async stop(){this.started=!1,this.components.getTransportManager().removeEventListener("listener:listening",this.update),this.components.getTransportManager().removeEventListener("listener:close",this.update),this.components.getAddressManager().removeEventListener("change:addresses",this.update)}update(){Promise.resolve().then(async()=>{let e=new hn({peerId:this.components.getPeerId(),multiaddrs:this.components.getAddressManager().getAddresses().map(n=>n.decapsulateCode(Yt("p2p").code))}),t=await Jr.seal(e,this.components.getPeerId());await this.components.getPeerStore().addressBook.consumePeerRecord(t)}).catch(e=>{sSe.error("Could not update self peer record: %o",e)})}};u();var bie=E(V(),1);var Tb=class{constructor(e){this.dht=e}async findPeer(e,t={}){for await(let n of this.dht.findPeer(e,t))if(n.name==="FINAL_PEER")return n.peer;throw(0,bie.default)(new Error(pt.NOT_FOUND),F.ERR_NOT_FOUND)}async*getClosestPeers(e,t={}){for await(let n of this.dht.getClosestPeers(e,t))n.name==="PEER_RESPONSE"&&(yield*n.closer)}};u();u();var Ab=E(V(),1);u();var lt={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_NOT_FOUND:"ERR_NOT_FOUND"};var vie=E(Ro(),1),_ie=E(Ai(),1),Sie=E(Kn(),1),xie=E(RC(),1);var er=C("libp2p:peer-store:address-book"),Ib="change:multiaddrs";async function oSe(){return!0}var Rb=class{constructor(e,t,n){this.dispatchEvent=e,this.store=t,this.addressFilter=n??oSe}async consumePeerRecord(e){er.trace("consumePeerRecord await write lock");let t=await this.store.lock.writeLock();er.trace("consumePeerRecord got write lock");let n,i,s;try{let o;try{o=hn.createFromProtobuf(e.payload)}catch{return er.error("invalid peer record received"),!1}n=o.peerId;let a=o.multiaddrs;if(!n.equals(e.peerId))return er("signing key does not match PeerId in the PeerRecord"),!1;if(a==null||a.length===0)return!1;if(await this.store.has(n)&&(i=await this.store.load(n),i.peerRecordEnvelope!=null)){let l=await Jr.createFromProtobuf(i.peerRecordEnvelope),f=hn.createFromProtobuf(l.payload);if(f.seqNumber>=o.seqNumber)return er("sequence number was lower or equal to existing sequence number - stored: %d received: %d",f.seqNumber,o.seqNumber),!1}let c=await XC(n,a,this.addressFilter,!0);s=await this.store.patchOrCreate(n,{addresses:c,peerRecordEnvelope:e.marshal().subarray()}),er("stored provided peer record for %p",o.peerId)}finally{er.trace("consumePeerRecord release write lock"),t()}return this.dispatchEvent(new ne(Ib,{detail:{peerId:n,multiaddrs:s.addresses.map(({multiaddr:o})=>o),oldMultiaddrs:i==null?[]:i.addresses.map(({multiaddr:o})=>o)}})),!0}async getRawEnvelope(e){er.trace("getRawEnvelope await read lock");let t=await this.store.lock.readLock();er.trace("getRawEnvelope got read lock");try{return(await this.store.load(e)).peerRecordEnvelope}catch(n){if(n.code!==lt.ERR_NOT_FOUND)throw n}finally{er.trace("getRawEnvelope release read lock"),t()}}async getPeerRecord(e){let t=await this.getRawEnvelope(e);if(t!=null)return await Jr.createFromProtobuf(t)}async get(e){e=jr(e),er.trace("get wait for read lock");let t=await this.store.lock.readLock();er.trace("get got read lock");try{return(await this.store.load(e)).addresses}catch(n){if(n.code!==lt.ERR_NOT_FOUND)throw n}finally{er.trace("get release read lock"),t()}return[]}async set(e,t){if(e=jr(e),!Array.isArray(t))throw er.error("multiaddrs must be an array of Multiaddrs"),(0,Ab.default)(new Error("multiaddrs must be an array of Multiaddrs"),lt.ERR_INVALID_PARAMETERS);er.trace("set await write lock");let n=await this.store.lock.writeLock();er.trace("set got write lock");let i=!1,s,o;try{let a=await XC(e,t,this.addressFilter);if(a.length===0)return;try{if(s=await this.store.load(e),i=!0,new Set([...a.map(({multiaddr:c})=>c.toString()),...s.addresses.map(({multiaddr:c})=>c.toString())]).size===s.addresses.length&&a.length===s.addresses.length)return}catch(c){if(c.code!==lt.ERR_NOT_FOUND)throw c}o=await this.store.patchOrCreate(e,{addresses:a}),er("set multiaddrs for %p",e)}finally{er.trace("set multiaddrs for %p",e),er("set release write lock"),n()}this.dispatchEvent(new ne(Ib,{detail:{peerId:e,multiaddrs:o.addresses.map(a=>a.multiaddr),oldMultiaddrs:s==null?[]:s.addresses.map(({multiaddr:a})=>a)}})),i||this.dispatchEvent(new ne("peer",{detail:{id:e,multiaddrs:o.addresses.map(a=>a.multiaddr),protocols:o.protocols}}))}async add(e,t){if(e=jr(e),!Array.isArray(t))throw er.error("multiaddrs must be an array of Multiaddrs"),(0,Ab.default)(new Error("multiaddrs must be an array of Multiaddrs"),lt.ERR_INVALID_PARAMETERS);er.trace("add await write lock");let n=await this.store.lock.writeLock();er.trace("add got write lock");let i,s,o;try{let a=await XC(e,t,this.addressFilter);if(a.length===0)return;try{if(s=await this.store.load(e),i=!0,new Set([...a.map(({multiaddr:c})=>c.toString()),...s.addresses.map(({multiaddr:c})=>c.toString())]).size===s.addresses.length)return}catch(c){if(c.code!==lt.ERR_NOT_FOUND)throw c}o=await this.store.mergeOrCreate(e,{addresses:a}),er("added multiaddrs for %p",e)}finally{er.trace("set release write lock"),n()}this.dispatchEvent(new ne(Ib,{detail:{peerId:e,multiaddrs:o.addresses.map(a=>a.multiaddr),oldMultiaddrs:s==null?[]:s.addresses.map(({multiaddr:a})=>a)}})),i===!0&&this.dispatchEvent(new ne("peer",{detail:{id:e,multiaddrs:o.addresses.map(a=>a.multiaddr),protocols:o.protocols}}))}async delete(e){e=jr(e),er.trace("delete await write lock");let t=await this.store.lock.writeLock();er.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i}await this.store.patchOrCreate(e,{addresses:[]})}finally{er.trace("delete release write lock"),t()}n!=null&&this.dispatchEvent(new ne(Ib,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:n==null?[]:n.addresses.map(({multiaddr:i})=>i)}}))}};async function XC(r,e,t,n=!1){return await we(e,i=>(0,xie.default)(i,s=>{if(!Ec(s))throw er.error("multiaddr must be an instance of Multiaddr"),(0,Ab.default)(new Error("multiaddr must be an instance of Multiaddr"),lt.ERR_INVALID_PARAMETERS)}),i=>(0,_ie.default)(i,async s=>await t(r,s)),i=>(0,Sie.default)(i,s=>({multiaddr:s,isCertified:n})),async i=>await(0,vie.default)(i))}u();var Iie=E(V(),1);var Ja=C("libp2p:peer-store:key-book"),Tie="change:pubkey",Cb=class{constructor(e,t){this.dispatchEvent=e,this.store=t}async set(e,t){if(e=jr(e),!(t instanceof Uint8Array))throw Ja.error("publicKey must be an instance of Uint8Array to store data"),(0,Iie.default)(new Error("publicKey must be an instance of PublicKey"),lt.ERR_INVALID_PARAMETERS);Ja.trace("set await write lock");let n=await this.store.lock.writeLock();Ja.trace("set got write lock");let i=!1,s;try{try{if(s=await this.store.load(e),s.pubKey!=null&&ze(s.pubKey,t))return}catch(o){if(o.code!==lt.ERR_NOT_FOUND)throw o}await this.store.patchOrCreate(e,{pubKey:t}),i=!0}finally{Ja.trace("set release write lock"),n()}i&&this.dispatchEvent(new ne(Tie,{detail:{peerId:e,publicKey:t,oldPublicKey:s?.pubKey}}))}async get(e){e=jr(e),Ja.trace("get await write lock");let t=await this.store.lock.readLock();Ja.trace("get got write lock");try{return(await this.store.load(e)).pubKey}catch(n){if(n.code!==lt.ERR_NOT_FOUND)throw n}finally{Ja("get release write lock"),t()}}async delete(e){e=jr(e),Ja.trace("delete await write lock");let t=await this.store.lock.writeLock();Ja.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i}await this.store.patchOrCreate(e,{pubKey:void 0})}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i}finally{Ja.trace("delete release write lock"),t()}this.dispatchEvent(new ne(Tie,{detail:{peerId:e,publicKey:void 0,oldPublicKey:n?.pubKey}}))}};u();var ZC=E(V(),1);var yn=C("libp2p:peer-store:metadata-book"),Pb="change:metadata",Db=class{constructor(e,t){this.dispatchEvent=e,this.store=t}async get(e){e=jr(e),yn.trace("get await read lock");let t=await this.store.lock.readLock();yn.trace("get got read lock");try{return(await this.store.load(e)).metadata}catch(n){if(n.code!==lt.ERR_NOT_FOUND)throw n}finally{yn.trace("get release read lock"),t()}return new Map}async getValue(e,t){e=jr(e),yn.trace("getValue await read lock");let n=await this.store.lock.readLock();yn.trace("getValue got read lock");try{return(await this.store.load(e)).metadata.get(t)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i}finally{yn.trace("getValue release write lock"),n()}}async set(e,t){if(e=jr(e),!(t instanceof Map))throw yn.error("valid metadata must be provided to store data"),(0,ZC.default)(new Error("valid metadata must be provided"),lt.ERR_INVALID_PARAMETERS);yn.trace("set await write lock");let n=await this.store.lock.writeLock();yn.trace("set got write lock");let i;try{try{i=await this.store.load(e)}catch(s){if(s.code!==lt.ERR_NOT_FOUND)throw s}await this.store.mergeOrCreate(e,{metadata:t})}finally{yn.trace("set release write lock"),n()}this.dispatchEvent(new ne(Pb,{detail:{peerId:e,metadata:t,oldMetadata:i==null?new Map:i.metadata}}))}async setValue(e,t,n){if(e=jr(e),typeof t!="string"||!(n instanceof Uint8Array))throw yn.error("valid key and value must be provided to store data"),(0,ZC.default)(new Error("valid key and value must be provided"),lt.ERR_INVALID_PARAMETERS);yn.trace("setValue await write lock");let i=await this.store.lock.writeLock();yn.trace("setValue got write lock");let s,o;try{try{s=await this.store.load(e);let a=s.metadata.get(t);if(a!=null&&ze(n,a))return}catch(a){if(a.code!==lt.ERR_NOT_FOUND)throw a}o=await this.store.mergeOrCreate(e,{metadata:new Map([[t,n]])})}finally{yn.trace("setValue release write lock"),i()}this.dispatchEvent(new ne(Pb,{detail:{peerId:e,metadata:o.metadata,oldMetadata:s==null?new Map:s.metadata}}))}async delete(e){e=jr(e),yn.trace("delete await write lock");let t=await this.store.lock.writeLock();yn.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i}n!=null&&await this.store.patch(e,{metadata:new Map})}finally{yn.trace("delete release write lock"),t()}n!=null&&this.dispatchEvent(new ne(Pb,{detail:{peerId:e,metadata:new Map,oldMetadata:n.metadata}}))}async deleteValue(e,t){e=jr(e),yn.trace("deleteValue await write lock");let n=await this.store.lock.writeLock();yn.trace("deleteValue got write lock");let i,s;try{s=await this.store.load(e),i=s.metadata,i.delete(t),await this.store.patch(e,{metadata:i})}catch(o){if(o.code!==lt.ERR_NOT_FOUND)throw o}finally{yn.trace("deleteValue release write lock"),n()}i!=null&&this.dispatchEvent(new ne(Pb,{detail:{peerId:e,metadata:i,oldMetadata:s==null?new Map:s.metadata}}))}};u();var kb=E(V(),1);var gn=C("libp2p:peer-store:proto-book"),Ob="change:protocols",Nb=class{constructor(e,t){this.dispatchEvent=e,this.store=t}async get(e){gn.trace("get wait for read lock");let t=await this.store.lock.readLock();gn.trace("get got read lock");try{return(await this.store.load(e)).protocols}catch(n){if(n.code!==lt.ERR_NOT_FOUND)throw n}finally{gn.trace("get release read lock"),t()}return[]}async set(e,t){if(e=jr(e),!Array.isArray(t))throw gn.error("protocols must be provided to store data"),(0,kb.default)(new Error("protocols must be provided"),lt.ERR_INVALID_PARAMETERS);gn.trace("set await write lock");let n=await this.store.lock.writeLock();gn.trace("set got write lock");let i,s;try{try{if(i=await this.store.load(e),new Set([...t]).size===i.protocols.length)return}catch(o){if(o.code!==lt.ERR_NOT_FOUND)throw o}s=await this.store.patchOrCreate(e,{protocols:t}),gn("stored provided protocols for %p",e)}finally{gn.trace("set release write lock"),n()}this.dispatchEvent(new ne(Ob,{detail:{peerId:e,protocols:s.protocols,oldProtocols:i==null?[]:i.protocols}}))}async add(e,t){if(e=jr(e),!Array.isArray(t))throw gn.error("protocols must be provided to store data"),(0,kb.default)(new Error("protocols must be provided"),lt.ERR_INVALID_PARAMETERS);gn.trace("add await write lock");let n=await this.store.lock.writeLock();gn.trace("add got write lock");let i,s;try{try{if(i=await this.store.load(e),new Set([...i.protocols,...t]).size===i.protocols.length)return}catch(o){if(o.code!==lt.ERR_NOT_FOUND)throw o}s=await this.store.mergeOrCreate(e,{protocols:t}),gn("added provided protocols for %p",e)}finally{gn.trace("add release write lock"),n()}this.dispatchEvent(new ne(Ob,{detail:{peerId:e,protocols:s.protocols,oldProtocols:i==null?[]:i.protocols}}))}async remove(e,t){if(e=jr(e),!Array.isArray(t))throw gn.error("protocols must be provided to store data"),(0,kb.default)(new Error("protocols must be provided"),lt.ERR_INVALID_PARAMETERS);gn.trace("remove await write lock");let n=await this.store.lock.writeLock();gn.trace("remove got write lock");let i,s;try{try{i=await this.store.load(e);let o=new Set(i.protocols);for(let a of t)o.delete(a);if(i.protocols.length===o.size)return;t=Array.from(o)}catch(o){if(o.code!==lt.ERR_NOT_FOUND)throw o}s=await this.store.patchOrCreate(e,{protocols:t})}finally{gn.trace("remove release write lock"),n()}this.dispatchEvent(new ne(Ob,{detail:{peerId:e,protocols:s.protocols,oldProtocols:i==null?[]:i.protocols}}))}async delete(e){e=jr(e),gn.trace("delete await write lock");let t=await this.store.lock.writeLock();gn.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i}await this.store.patchOrCreate(e,{protocols:[]})}finally{gn.trace("delete release write lock"),t()}n!=null&&this.dispatchEvent(new ne(Ob,{detail:{peerId:e,protocols:[],oldProtocols:n.protocols}}))}};u();var JC=E(V(),1);u();var Kg;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.addresses!=null)for(let s of t.addresses)n.uint32(10),Lb.codec().encode(s,n);else throw new Error('Protocol error: required field "addresses" was not found in object');if(t.protocols!=null)for(let s of t.protocols)n.uint32(18),n.string(s);else throw new Error('Protocol error: required field "protocols" was not found in object');if(t.metadata!=null)for(let s of t.metadata)n.uint32(26),Bb.codec().encode(s,n);else throw new Error('Protocol error: required field "metadata" was not found in object');t.pubKey!=null&&(n.uint32(34),n.bytes(t.pubKey)),t.peerRecordEnvelope!=null&&(n.uint32(42),n.bytes(t.peerRecordEnvelope)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={addresses:[],protocols:[],metadata:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.addresses.push(Lb.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(Bb.codec().decode(t,t.uint32()));break;case 4:i.pubKey=t.bytes();break;case 5:i.peerRecordEnvelope=t.bytes();break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(Kg||(Kg={}));var Lb;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.multiaddr!=null)n.uint32(10),n.bytes(t.multiaddr);else throw new Error('Protocol error: required field "multiaddr" was not found in object');t.isCertified!=null&&(n.uint32(16),n.bool(t.isCertified)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={multiaddr:new Uint8Array(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.multiaddr=t.bytes();break;case 2:i.isCertified=t.bool();break;default:t.skipType(o&7);break}}if(i.multiaddr==null)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(Lb||(Lb={}));var Bb;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.key!=null)n.uint32(10),n.string(t.key);else throw new Error('Protocol error: required field "key" was not found in object');if(t.value!=null)n.uint32(18),n.bytes(t.value);else throw new Error('Protocol error: required field "value" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={key:"",value:new Uint8Array(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.key=t.string();break;case 2:i.value=t.bytes();break;default:t.skipType(o&7);break}}if(i.key==null)throw new Error('Protocol error: value for required field "key" was not found in protobuf');if(i.value==null)throw new Error('Protocol error: value for required field "value" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(Bb||(Bb={}));var Aie=C("libp2p:peer-store:store"),Rie="/peers/",Mb=class{constructor(){this.components=new je,this.lock=vh({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(e.type==null)throw Aie.error("peerId must be an instance of peer-id to store data"),(0,JC.default)(new Error("peerId must be an instance of peer-id"),lt.ERR_INVALID_PARAMETERS);let t=e.toCID().toString();return new fe(`${Rie}${t}`)}async has(e){return await this.components.getDatastore().has(this._peerIdToDatastoreKey(e))}async delete(e){await this.components.getDatastore().delete(this._peerIdToDatastoreKey(e))}async load(e){let t=await this.components.getDatastore().get(this._peerIdToDatastoreKey(e)),n=Kg.decode(t),i=new Map;for(let s of n.metadata)i.set(s.key,s.value);return{...n,id:e,addresses:n.addresses.map(({multiaddr:s,isCertified:o})=>({multiaddr:se(s),isCertified:o??!1})),metadata:i,pubKey:n.pubKey??void 0,peerRecordEnvelope:n.peerRecordEnvelope??void 0}}async save(e){if(e.pubKey!=null&&e.id.publicKey!=null&&!ze(e.pubKey,e.id.publicKey))throw Aie.error("peer publicKey bytes do not match peer id publicKey bytes"),(0,JC.default)(new Error("publicKey bytes do not match peer id publicKey bytes"),lt.ERR_INVALID_PARAMETERS);let t=new Set,n=e.addresses.filter(o=>t.has(o.multiaddr.toString())?!1:(t.add(o.multiaddr.toString()),!0)).sort((o,a)=>o.multiaddr.toString().localeCompare(a.multiaddr.toString())).map(({multiaddr:o,isCertified:a})=>({multiaddr:o.bytes,isCertified:a})),i=[];[...e.metadata.keys()].sort().forEach(o=>{let a=e.metadata.get(o);a!=null&&i.push({key:o,value:a})});let s=Kg.encode({addresses:n,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:i,peerRecordEnvelope:e.peerRecordEnvelope});return await this.components.getDatastore().put(this._peerIdToDatastoreKey(e.id),s.subarray()),await this.load(e.id)}async patch(e,t){let n=await this.load(e);return await this._patch(e,t,n)}async patchOrCreate(e,t){let n;try{n=await this.load(e)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i;n={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._patch(e,t,n)}async _patch(e,t,n){return await this.save({...n,...t,id:e})}async merge(e,t){let n=await this.load(e);return await this._merge(e,t,n)}async mergeOrCreate(e,t){let n;try{n=await this.load(e)}catch(i){if(i.code!==lt.ERR_NOT_FOUND)throw i;n={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._merge(e,t,n)}async _merge(e,t,n){let i=new Map;return n.addresses.forEach(s=>{i.set(s.multiaddr.toString(),s.isCertified)}),(t.addresses??[]).forEach(s=>{let o=s.multiaddr.toString(),c=Boolean(i.get(o))||s.isCertified;i.set(o,c)}),await this.save({id:e,addresses:Array.from(i.entries()).map(([s,o])=>({multiaddr:se(s),isCertified:o})),protocols:Array.from(new Set([...n.protocols??[],...t.protocols??[]])),metadata:new Map([...n.metadata?.entries()??[],...t.metadata?.entries()??[]]),pubKey:t.pubKey??n?.pubKey,peerRecordEnvelope:t.peerRecordEnvelope??n?.peerRecordEnvelope})}async*all(){for await(let e of this.components.getDatastore().queryKeys({prefix:Rie})){let t=e.toString().split("/")[2],n=mt.decode(t);yield this.load(Ir(n))}}};var eP=E(V(),1);u();var wl;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.tags!=null)for(let s of t.tags)n.uint32(10),Ub.codec().encode(s,n);else throw new Error('Protocol error: required field "tags" was not found in object');i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={tags:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.tags.push(Ub.codec().decode(t,t.uint32()));break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(wl||(wl={}));var Ub;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.name!=null)n.uint32(10),n.string(t.name);else throw new Error('Protocol error: required field "name" was not found in object');t.value!=null&&(n.uint32(16),n.uint32(t.value)),t.expiry!=null&&(n.uint32(24),n.uint64(t.expiry)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={name:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.name=t.string();break;case 2:i.value=t.uint32();break;case 3:i.expiry=t.uint64();break;default:t.skipType(o&7);break}}if(i.name==null)throw new Error('Protocol error: value for required field "name" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(Ub||(Ub={}));var Js=C("libp2p:peer-store"),Fb=class extends We{constructor(e={}){super(),this.components=new je,this.store=new Mb,this.addressBook=new Rb(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new Cb(this.dispatchEvent.bind(this),this.store),this.metadataBook=new Db(this.dispatchEvent.bind(this),this.store),this.protoBook=new Nb(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}async forEach(e){Js.trace("getPeers await read lock");let t=await this.store.lock.readLock();Js.trace("getPeers got read lock");try{for await(let n of this.store.all())n.id.equals(this.components.getPeerId())||e(n)}finally{Js.trace("getPeers release read lock"),t()}}async all(){let e=[];return await this.forEach(t=>{e.push(t)}),e}async delete(e){Js.trace("delete await write lock");let t=await this.store.lock.writeLock();Js.trace("delete got write lock");try{await this.store.delete(e)}finally{Js.trace("delete release write lock"),t()}}async get(e){Js.trace("get await read lock");let t=await this.store.lock.readLock();Js.trace("get got read lock");try{return await this.store.load(e)}finally{Js.trace("get release read lock"),t()}}async has(e){Js.trace("has await read lock");let t=await this.store.lock.readLock();Js.trace("has got read lock");try{return await this.store.has(e)}finally{Js.trace("has release read lock"),t()}}async tagPeer(e,t,n={}){let i=n.value??0,s=Math.round(i),o=n.ttl??void 0;if(s!==i||s<0||s>100)throw(0,eP.default)(new Error("Tag value must be between 0-100"),"ERR_TAG_VALUE_OUT_OF_BOUNDS");let a=await this.metadataBook.getValue(e,"tags"),c=[];a!=null&&(c=wl.decode(a).tags);for(let l of c)if(l.name===t)throw(0,eP.default)(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");c.push({name:t,value:s,expiry:o==null?void 0:BigInt(Date.now()+o)}),await this.metadataBook.setValue(e,"tags",wl.encode({tags:c}).subarray())}async unTagPeer(e,t){let n=await this.metadataBook.getValue(e,"tags"),i=[];n!=null&&(i=wl.decode(n).tags),i=i.filter(s=>s.name!==t),await this.metadataBook.setValue(e,"tags",wl.encode({tags:i}).subarray())}async getTags(e){let t=await this.metadataBook.getValue(e,"tags"),n=[];t!=null&&(n=wl.decode(t).tags);let i=BigInt(Date.now()),s=n.filter(o=>o.expiry==null||o.expiry>i);return s.length!==n.length&&await this.metadataBook.setValue(e,"tags",wl.encode({tags:s}).subarray()),s.map(o=>({name:o.name,value:o.value??0}))}};u();var tP=E(fi(),1),Cie=E(V(),1),Vb=class{constructor(e){this.dht=e}async provide(e){await(0,tP.default)(this.dht.provide(e))}async*findProviders(e,t={}){for await(let n of this.dht.findProviders(e,t))n.name==="PROVIDER"&&(yield*n.providers)}async put(e,t,n){await(0,tP.default)(this.dht.put(e,t,n))}async get(e,t){for await(let n of this.dht.get(e,t))if(n.name==="VALUE")return n.value;throw(0,Cie.default)(new Error("Not found"),"ERR_NOT_FOUND")}};u();var Die=E(an(),1),Oie=E(bn(),1),Pie=C("libp2p:dialer:auto-dialer"),Kb=class{constructor(e,t){this.components=e,this.enabled=t.enabled,this.minConnections=t.minConnections,this.dialTimeout=t.dialTimeout}handle(e){let{detail:t}=e;if(!this.enabled)return;if(this.components.getConnectionManager().getConnections(t.id).length===0){let i=this.minConnections??0,s=this.components.getConnectionManager().getConnections();if(i>s.length){Pie("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);let o=new Die.TimeoutController(this.dialTimeout);try{(0,Oie.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{Pie.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}};u();u();u();u();var nP=E(Li(),1),iP=E(Lie(),1);u();u();var Bie=globalThis.fetch,Mie=globalThis.Headers,k5t=globalThis.Request,N5t=globalThis.Response;function qb(r,e,t){return`${r}?name=${e}&type=${t}`}async function Uie(r,e){return await(await Bie(r,{headers:new Mie({accept:"application/dns-json"}),signal:e})).json()}function vd(r,e){return`${e}_${r}`}var rP=Object.assign((0,nP.default)("dns-over-http-resolver"),{error:(0,nP.default)("dns-over-http-resolver:error")}),sP=class{constructor(e={}){this._cache=new iP.default({max:e?.maxCache??100}),this._TXTcache=new iP.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??Uie,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){let e=[...this._servers];for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*t),i=e[t];e[t]=e[n],e[n]=i}return e}setServers(e){this._servers=e}async resolve(e,t="A"){switch(t){case"A":return await this.resolve4(e);case"AAAA":return await this.resolve6(e);case"TXT":return await this.resolveTxt(e);default:throw new Error(`${t} is not supported`)}}async resolve4(e){let t="A",n=this._cache.get(vd(e,t));if(n!=null)return n;let i=!1;for(let s of this._getShuffledServers()){let o=new AbortController;this._abortControllers.push(o);try{let a=await this._request(qb(s,e,t),o.signal),c=a.Answer.map(f=>f.data),l=Math.min(...a.Answer.map(f=>f.TTL));return this._cache.set(vd(e,t),c,{ttl:l}),c}catch{o.signal.aborted&&(i=!0),rP.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==o)}}throw i?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolve6(e){let t="AAAA",n=this._cache.get(vd(e,t));if(n!=null)return n;let i=!1;for(let s of this._getShuffledServers()){let o=new AbortController;this._abortControllers.push(o);try{let a=await this._request(qb(s,e,t),o.signal),c=a.Answer.map(f=>f.data),l=Math.min(...a.Answer.map(f=>f.TTL));return this._cache.set(vd(e,t),c,{ttl:l}),c}catch{o.signal.aborted&&(i=!0),rP.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==o)}}throw i?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolveTxt(e){let t="TXT",n=this._TXTcache.get(vd(e,t));if(n!=null)return n;let i=!1;for(let s of this._getShuffledServers()){let o=new AbortController;this._abortControllers.push(o);try{let a=await this._request(qb(s,e,t),o.signal),c=a.Answer.map(f=>[f.data.replace(/['"]+/g,"")]),l=Math.min(...a.Answer.map(f=>f.TTL));return this._TXTcache.set(vd(e,t),c,{ttl:l}),c}catch{o.signal.aborted&&(i=!0),rP.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==o)}}throw i?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}},Fie=sP;var Vie=Fie;var{code:fSe}=Yt("dnsaddr");async function Kie(r,e={}){let t=new Vie;e.signal!=null&&e.signal.addEventListener("abort",()=>{t.cancel()});let n=r.getPeerId(),[,i]=r.stringTuples().find(([a])=>a===fSe)??[];if(i==null)throw new Error("No hostname found in multiaddr");let o=(await t.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return n!=null&&(o=o.filter(a=>a.includes(n))),o}var zb=E(V(),1);var mSe={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:r=>r},connectionManager:{maxConnections:300,minConnections:50,autoDial:!0,autoDialInterval:1e4,maxParallelDials:100,maxDialsPerPeer:4,dialTimeout:3e4,inboundUpgradeTimeout:3e4,resolvers:{dnsaddr:Kie},addressSorter:n1},connectionGater:{},transportManager:{faultTolerance:yd.FATAL_ALL},metrics:{enabled:!1,computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[60*1e3,5*60*1e3,15*60*1e3],maxOldPeersRetention:50},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0},relay:{enabled:!0,advertise:{bootDelay:9e5,enabled:!1,ttl:18e5},hop:{enabled:!1,active:!1,timeout:3e4},autoRelay:{enabled:!1,maxListeners:2}},identify:{protocolPrefix:"ipfs",host:{agentVersion:$C},timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1},ping:{protocolPrefix:"ipfs",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4},fetch:{protocolPrefix:"libp2p",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4}};function qie(r){let e=Qe(mSe,r);if(e.transports==null||e.transports.length<1)throw(0,zb.default)(new Error(pt.ERR_TRANSPORTS_REQUIRED),F.ERR_TRANSPORTS_REQUIRED);if(e.connectionEncryption==null||e.connectionEncryption.length===0)throw(0,zb.default)(new Error(pt.CONN_ENCRYPTION_REQUIRED),F.CONN_ENCRYPTION_REQUIRED);if(e.connectionProtector===null&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw(0,zb.default)(new Error(pt.ERR_PROTECTOR_REQUIRED),F.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===$C&&(pie||hie?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(bd||_b||die||mie)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}u();u();var lP;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.id!=null)n.uint32(10),n.bytes(t.id);else throw new Error('Protocol error: required field "id" was not found in object');t.pubKey!=null&&(n.uint32(18),n.bytes(t.pubKey)),t.privKey!=null&&(n.uint32(26),n.bytes(t.privKey)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={id:new Uint8Array(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.id=t.bytes();break;case 2:i.pubKey=t.bytes();break;case 3:i.privKey=t.bytes();break;default:t.skipType(o&7);break}}if(i.id==null)throw new Error('Protocol error: value for required field "id" was not found in protobuf');return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(lP||(lP={}));var $b=async()=>{let r=await Mp("Ed25519"),e=await $ie(r);if(e.type==="Ed25519")return e;throw new Error(`Generated unexpected PeerId type "${e.type}"`)};var zie=async r=>{let e=await Mp("RSA",r?.bits??2048),t=await $ie(e);if(t.type==="RSA")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function $ie(r){return await ln(zm(r.public),gx(r))}Mr();var zg=E(V(),1);u();var eo=E(V(),1);var Hb=class extends We{get[Xa](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}get lan(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}get(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}findProviders(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}findPeer(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}getClosestPeers(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}provide(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}put(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}async getMode(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}async setMode(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}async refreshRoutingTable(){throw(0,eo.default)(new Error(pt.DHT_DISABLED),F.DHT_DISABLED)}};u();var El=E(V(),1);var Gb=class extends We{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}get multicodecs(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}getPeers(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}getTopics(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}subscribe(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}unsubscribe(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}getSubscribers(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}async publish(){throw(0,El.default)(new Error(pt.PUBSUB_DISABLED),F.ERR_PUBSUB_DISABLED)}};u();var tse=E(Ro(),1),rse=E(Ai(),1);var h1=E(V(),1);var nse=E(an(),1);u();var ec=class extends Error{constructor(e="The operation was aborted"){super(e),this.code=ec.code,this.type=ec.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}};var ise=E(ai(),1),sse=E(bn(),1);u();var qg=E(V(),1),Zie=E(ai(),1),Jie=E(Qie(),1),uP=E(bn(),1);var Xie=C("libp2p:dialer:dial-request"),jb=class{constructor(e){let{addrs:t,dialAction:n,dialer:i}=e;this.addrs=t,this.dialer=i,this.dialAction=n}async run(e={}){let t=this.dialer.getTokens(this.addrs.length);if(t.length<1)throw(0,qg.default)(new Error("No dial tokens available"),F.ERR_NO_DIAL_TOKENS);let n=new Jie.default;for(let a of t)n.push(a).catch(c=>{Xie.error(c)});let i=this.addrs.map(()=>{let a=new AbortController;try{(0,uP.setMaxListeners)?.(1/0,a.signal)}catch{}return a});if(e.signal!=null)try{(0,uP.setMaxListeners)?.(1/0,e.signal)}catch{}let s=0,o=!1;try{return await Promise.any(this.addrs.map(async(a,c)=>{let l=await n.shift();if(o)throw this.dialer.releaseToken(t.splice(t.indexOf(l),1)[0]),(0,qg.default)(new Error("dialAction already succeeded"),F.ERR_ALREADY_SUCCEEDED);let f=i[c];if(f==null)throw(0,qg.default)(new Error("dialAction did not come with an AbortController"),F.ERR_INVALID_PARAMETERS);let h;try{let p=f.signal;h=await this.dialAction(a,{...e,signal:e.signal!=null?(0,Zie.anySignal)([p,e.signal]):p}),i[c]=void 0}finally{s++,this.addrs.length-s>=t.length?n.push(l).catch(p=>{Xie.error(p)}):this.dialer.releaseToken(t.splice(t.indexOf(l),1)[0])}if(h==null)throw(0,qg.default)(new Error("dialAction led to empty object"),F.ERR_TRANSPORT_DIAL_FAILED);return o=!0,h}))}finally{i.forEach(a=>{a!==void 0&&a.abort()}),t.forEach(a=>this.dialer.releaseToken(a))}}};var ose=E(gy(),1),ase=E(Kn(),1),jo=C("libp2p:dialer"),ese="dialler",wSe="pending-dials",ESe="pending-dial-targets",Wb=class{constructor(e,t={}){this.started=!1,this.addressSorter=t.addressSorter??n1,this.maxAddrsToDial=t.maxAddrsToDial??25,this.timeout=t.dialTimeout??3e4,this.maxDialsPerPeer=t.maxDialsPerPeer??4,this.tokens=[...new Array(t.maxParallelDials??100)].map((n,i)=>i),this.components=e,this.pendingDials=ii({component:ese,metric:wSe,metrics:t.metrics}),this.pendingDialTargets=ii({component:ese,metric:ESe,metrics:e.getMetrics()});for(let[n,i]of Object.entries(t.resolvers??{}))l9.set(n,i)}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1;for(let e of this.pendingDials.values())try{e.controller.abort()}catch(t){jo.error(t)}this.pendingDials.clear();for(let e of this.pendingDialTargets.values())e.reject(new ec("Dialer was destroyed"));this.pendingDialTargets.clear()}async dial(e,t={}){let{id:n,multiaddrs:i}=fd(e);if(this.components.getPeerId().equals(n))throw(0,h1.default)(new Error("Tried to dial self"),F.ERR_DIALED_SELF);if(jo("check multiaddrs %p",n),i!=null&&i.length>0&&(jo("storing multiaddrs %p",n,i),await this.components.getPeerStore().addressBook.add(n,i)),await this.components.getConnectionGater().denyDialPeer(n))throw(0,h1.default)(new Error("The dial request is blocked by gater.allowDialPeer"),F.ERR_PEER_DIAL_INTERCEPTED);jo("creating dial target for %p",n);let s=await this._createCancellableDialTarget(n,t);if(s.addrs.length===0)throw(0,h1.default)(new Error("The dial request has no valid addresses"),F.ERR_NO_VALID_ADDRESSES);let o=this.pendingDials.get(s.id)??this._createPendingDial(s,t);try{let a=await o.promise;return jo("dial succeeded to %s",s.id),a}catch(a){throw jo("dial failed to %s",s.id,a),o.controller.signal.aborted&&(a.code=F.ERR_TIMEOUT),jo.error(a),a}finally{o.destroy()}}async _createCancellableDialTarget(e,t){let n=`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`,i=new Promise((s,o)=>{this.pendingDialTargets.set(n,{resolve:s,reject:o})});try{return await Promise.race([this._createDialTarget(e,t),i])}finally{this.pendingDialTargets.delete(n)}}async _createDialTarget(e,t){let n=await we(await this.components.getPeerStore().addressBook.get(e),o=>(0,rse.default)(o,async a=>!await this.components.getConnectionGater().denyDialMultiaddr(e,a.multiaddr)),o=>(0,ose.default)(o,this.addressSorter),o=>(0,ase.default)(o,a=>{let c=a.multiaddr;return e.toString()===c.getPeerId()?c:c.encapsulate(`/p2p/${e.toString()}`)}),async o=>await(0,tse.default)(o)),i=[];for(let o of n)(await this._resolve(o,t)).forEach(c=>i.push(c));let s=i.filter(o=>this.components.getTransportManager().transportForMultiaddr(o));if(s.length>this.maxAddrsToDial)throw await this.components.getPeerStore().delete(e),(0,h1.default)(new Error("dial with more addresses than allowed"),F.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:s}}_createPendingDial(e,t={}){let n=async(l,f={})=>{if(f.signal?.aborted===!0)throw(0,h1.default)(new Error("already aborted"),F.ERR_ALREADY_ABORTED);return await this.components.getTransportManager().dial(l,f).catch(h=>{throw jo.error("dial to %s failed",l,h),h})},i=new jb({addrs:e.addrs,dialAction:n,dialer:this}),s=new nse.TimeoutController(this.timeout),o=[s.signal];t.signal!=null&&o.push(t.signal);let a=(0,ise.anySignal)(o);try{(0,sse.setMaxListeners)?.(1/0,a)}catch{}let c={dialRequest:i,controller:s,promise:i.run({...t,signal:a}),destroy:()=>{s.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,c),c}getTokens(e){let t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),n=this.tokens.splice(0,t);return jo("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),n}releaseToken(e){this.tokens.includes(e)||(jo("token %d released",e),this.tokens.push(e))}async _resolve(e,t){if(!e.protoNames().includes("dnsaddr"))return[e];let i=await this._resolveRecord(e,t);return(await Promise.all(i.map(async a=>await this._resolve(a,t)))).flat().reduce((a,c)=>(a.find(l=>l.equals(c))==null&&a.push(c),a),[])}async _resolveRecord(e,t){try{return e=se(e.toString()),await e.resolve(t)}catch(n){return jo.error(`multiaddr ${e.toString()} could not be resolved`,n),[]}}};var bl=C("libp2p"),fP=class extends We{constructor(e){super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new je({peerId:e.peerId,datastore:e.datastore??new Zm,connectionGater:{denyDialPeer:async()=>await Promise.resolve(!1),denyDialMultiaddr:async()=>await Promise.resolve(!1),denyInboundConnection:async()=>await Promise.resolve(!1),denyOutboundConnection:async()=>await Promise.resolve(!1),denyInboundEncryptedConnection:async()=>await Promise.resolve(!1),denyOutboundEncryptedConnection:async()=>await Promise.resolve(!1),denyInboundUpgradedConnection:async()=>await Promise.resolve(!1),denyOutboundUpgradedConnection:async()=>await Promise.resolve(!1),filterMultiaddrForPeer:async()=>await Promise.resolve(!0),...e.connectionGater}}),this.components.setPeerStore(new Fb({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new hb(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{let{detail:a}=o;this.dispatchEvent(new ne("peer:discovery",{detail:a}))}),e.connectionProtector!=null&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new gb(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o)),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o)),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout})),this.components.setDialer(new Wb(this.components,e.connectionManager)),this.connectionManager=this.components.setConnectionManager(new YE(e.connectionManager)),this.registrar=this.components.setRegistrar(new yb(this.components)),this.components.setTransportManager(new db(this.components,e.transportManager)),this.components.setAddressManager(new zE(this.components,e.addresses)),this.configureComponent(new xb(this.components)),this.configureComponent(new QE(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));let t=Dg.generateOptions();this.keychain=this.configureComponent(new Dg(this.components,{...t,...e.keychain})),this.services.push(new Sb(this.components,e.nat)),e.transports.forEach(o=>{this.components.getTransportManager().add(this.configureComponent(o))}),e.streamMuxers!=null&&e.streamMuxers.length>0&&(this.identifyService=new u1(this.components,{...e.identify}),this.configureComponent(this.identifyService)),e.dht!=null?this.dht=this.components.setDHT(e.dht):this.dht=new Hb,e.pubsub!=null?this.pubsub=this.components.setPubSub(e.pubsub):this.pubsub=new Gb;let n=(e.peerRouters??[]).map(o=>this.configureComponent(o));e.dht!=null&&(n.push(this.configureComponent(new Tb(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new VE(this.components,{...e.peerRouting,routers:n})));let i=(e.contentRouters??[]).map(o=>this.configureComponent(o));e.dht!=null&&i.push(this.configureComponent(new Vb(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new qE(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new ZE(e.relay))),this.configureComponent(new sb(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new Eb(this.components,{...e.fetch})),this.pingService=this.configureComponent(new bb(this.components,{...e.ping}));let s=this.configureComponent(new Kb(this.components,{enabled:e.connectionManager.autoDial!==!1,minConnections:e.connectionManager.minConnections,dialTimeout:e.connectionManager.dialTimeout??3e4}));this.addEventListener("peer:discovery",o=>{!this.isStarted()||s.handle(o)});for(let o of e.peerDiscovery??[])this.configureComponent(o),o.addEventListener("peer",a=>{this.onDiscoveryPeer(a)})}configureComponent(e){return nl(e)&&this.services.push(e),_n(e)&&this.initializables.push(e),e}async start(){if(!this.started){this.started=!0,bl("libp2p is starting");try{this.initializables.forEach(e=>{e.init(this.components)}),await Promise.all(this.services.map(async e=>{e.beforeStart!=null&&await e.beforeStart()})),await Promise.all(this.services.map(e=>e.start())),await Promise.all(this.services.map(async e=>{e.afterStart!=null&&await e.afterStart()})),bl("libp2p has started")}catch(e){throw bl.error("An error occurred starting libp2p",e),await this.stop(),e}}}async stop(){!this.started||(bl("libp2p is stopping"),this.started=!1,await Promise.all(this.services.map(async e=>{e.beforeStop!=null&&await e.beforeStop()})),await Promise.all(this.services.map(e=>e.stop())),await Promise.all(this.services.map(async e=>{e.afterStop!=null&&await e.afterStop()})),bl("libp2p has stopped"))}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){let e=new Tg;for(let t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e,t={}){let{id:n,multiaddrs:i}=fd(e);return await this.components.getPeerStore().addressBook.add(n,i),await this.components.getConnectionManager().openConnection(n,t)}async dialProtocol(e,t,n={}){if(t==null)throw(0,zg.default)(new Error("no protocols were provided to open a stream"),F.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(t=Array.isArray(t)?t:[t],t.length===0)throw(0,zg.default)(new Error("no protocols were provided to open a stream"),F.ERR_INVALID_PROTOCOLS_FOR_STREAM);return await(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.getAddressManager().getAddresses()}async hangUp(e){let{id:t}=fd(e);await this.components.getConnectionManager().closeConnections(t)}async getPublicKey(e,t={}){if(bl("getPublicKey %p",e),e.publicKey!=null)return e.publicKey;let n=await this.peerStore.get(e);if(n.pubKey!=null)return n.pubKey;if(this.dht==null)throw(0,zg.default)(new Error("Public key was not in the peer store and the DHT is not enabled"),F.ERR_NO_ROUTERS_AVAILABLE);let i=Le([z("/pk/"),e.multihash.digest]);for await(let s of this.dht.get(i,t))if(s.name==="VALUE"){let o=Ti(s.value);return await this.peerStore.keyBook.set(e,s.value),o.bytes}throw(0,zg.default)(new Error(`Node not responding with its public key: ${e.toString()}`),F.ERR_INVALID_RECORD)}async fetch(e,t,n={}){let{id:i,multiaddrs:s}=fd(e);return s!=null&&await this.components.getPeerStore().addressBook.add(i,s),await this.fetchService.fetch(i,t,n)}async ping(e,t={}){let{id:n,multiaddrs:i}=fd(e);return i.length>0&&await this.components.getPeerStore().addressBook.add(n,i),await this.pingService.ping(n,t)}async handle(e,t,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async i=>{await this.components.getRegistrar().handle(i,t,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async t=>{await this.components.getRegistrar().unhandle(t)}))}onDiscoveryPeer(e){let{detail:t}=e;if(t.id.toString()===this.peerId.toString()){bl.error(new Error(F.ERR_DISCOVERED_SELF));return}t.multiaddrs.length>0&&this.components.getPeerStore().addressBook.add(t.id,t.multiaddrs).catch(n=>bl.error(n)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(n=>bl.error(n)),this.dispatchEvent(new ne("peer:discovery",{detail:t}))}};async function cse(r){return r.peerId==null&&(r.peerId=await $b()),new fP(qie(r))}async function lse(r){return await cse(r)}u();u();u();var Use=E(yse(),1);u();Mr();var gP=E(nb(),1);u();var gse="/lan",wse="/ipfs",Ese="/kad/1.0.0",bse="/dht/record",yP="/dht/provider";var vse=Number(3e5),_se=Number(30*1e3),Sse=Number(5*6e4),xse=Number(30*1e3),Tse=Number(30*1e3);var ISe=z("/pk/");function p1(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();return t!==4&&t!==6||n==null?!1:!(0,gP.default)(n)})}}function m1(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();return t!==4&&t!==6||n==null?!1:(0,gP.default)(n)})}}async function rc(r){return(await $e.digest(r)).digest}async function ms(r){return await rc(r.toBytes())}function vl(r){return new fe(`${bse}/${K(r,"base32")}`,!1)}function Ise(r){return Le([ISe,r.toBytes()])}function Ase(r){return K(r.subarray(0,4))==="/pk/"}function Rse(r){return Ir(r.subarray(4))}function wP(r,e){let t=new Date;return new Rr(r,e,t).serialize()}u();var Mse=E(Hl(),1);u();var Hg=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},bP=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Cse=r=>globalThis.DOMException===void 0?new bP(r):new DOMException(r),Pse=r=>{let e=r.reason===void 0?Cse("This operation was aborted."):r.reason;return e instanceof Error?e:Cse(e)};function vP(r,e,t,n){let i,s=new Promise((o,a)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){o(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&a(Pse(c)),c.addEventListener("abort",()=>{a(Pse(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{o(t())}catch(f){a(f)}return}let c=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,l=t instanceof Error?t:new Hg(c);typeof r.cancel=="function"&&r.cancel(),a(l)},e),(async()=>{try{o(await r)}catch(c){a(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return s.clear=()=>{clearTimeout(i),i=void 0},s}u();u();function _P(r,e,t){let n=0,i=r.length;for(;i>0;){let s=Math.trunc(i/2),o=n+s;t(r[o],e)<=0?(n=++o,i-=s+1):i=s}return n}var Sd=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},_l,Gg=class{constructor(){_l.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Sd(this,_l,"f")[this.size-1].priority>=t.priority){Sd(this,_l,"f").push(n);return}let i=_P(Sd(this,_l,"f"),n,(s,o)=>o.priority-s.priority);Sd(this,_l,"f").splice(i,0,n)}dequeue(){let e=Sd(this,_l,"f").shift();return e?.run}filter(e){return Sd(this,_l,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Sd(this,_l,"f").length}};_l=new WeakMap;var Lr=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},Re=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},nn,Wg,Yg,gf,r7,Qg,Xb,Wo,jg,ys,Zb,gs,Xg,yf,Jb,Dse,Ose,Bse,kse,Nse,Lse,e7,SP,xP,n7,t7,ASe=new Hg,TP=class extends Error{},Sl=class extends Mse.default{constructor(e){var t,n,i,s;if(super(),nn.add(this),Wg.set(this,void 0),Yg.set(this,void 0),gf.set(this,0),r7.set(this,void 0),Qg.set(this,void 0),Xb.set(this,0),Wo.set(this,void 0),jg.set(this,void 0),ys.set(this,void 0),Zb.set(this,void 0),gs.set(this,0),Xg.set(this,void 0),yf.set(this,void 0),Jb.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Gg,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);Lr(this,Wg,e.carryoverConcurrencyCount,"f"),Lr(this,Yg,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Lr(this,r7,e.intervalCap,"f"),Lr(this,Qg,e.interval,"f"),Lr(this,ys,new e.queueClass,"f"),Lr(this,Zb,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Lr(this,Jb,e.throwOnTimeout===!0,"f"),Lr(this,yf,e.autoStart===!1,"f")}get concurrency(){return Re(this,Xg,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Lr(this,Xg,e,"f"),Re(this,nn,"m",n7).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Lr(this,gs,(a=Re(this,gs,"f"),a++,a),"f"),Lr(this,gf,(c=Re(this,gf,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new TP("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):vP(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Re(this,Jb,"f"):t.throwOnTimeout)&&i(ASe)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Re(this,nn,"m",Bse).call(this)};Re(this,ys,"f").enqueue(s,t),Re(this,nn,"m",e7).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Re(this,yf,"f")?(Lr(this,yf,!1,"f"),Re(this,nn,"m",n7).call(this),this):this}pause(){Lr(this,yf,!0,"f")}clear(){Lr(this,ys,new(Re(this,Zb,"f")),"f")}async onEmpty(){Re(this,ys,"f").size!==0&&await Re(this,nn,"m",t7).call(this,"empty")}async onSizeLessThan(e){Re(this,ys,"f").size<e||await Re(this,nn,"m",t7).call(this,"next",()=>Re(this,ys,"f").size<e)}async onIdle(){Re(this,gs,"f")===0&&Re(this,ys,"f").size===0||await Re(this,nn,"m",t7).call(this,"idle")}get size(){return Re(this,ys,"f").size}sizeBy(e){return Re(this,ys,"f").filter(e).length}get pending(){return Re(this,gs,"f")}get isPaused(){return Re(this,yf,"f")}};Wg=new WeakMap,Yg=new WeakMap,gf=new WeakMap,r7=new WeakMap,Qg=new WeakMap,Xb=new WeakMap,Wo=new WeakMap,jg=new WeakMap,ys=new WeakMap,Zb=new WeakMap,gs=new WeakMap,Xg=new WeakMap,yf=new WeakMap,Jb=new WeakMap,nn=new WeakSet,Dse=function(){return Re(this,Yg,"f")||Re(this,gf,"f")<Re(this,r7,"f")},Ose=function(){return Re(this,gs,"f")<Re(this,Xg,"f")},Bse=function(){var e;Lr(this,gs,(e=Re(this,gs,"f"),e--,e),"f"),Re(this,nn,"m",e7).call(this),this.emit("next")},kse=function(){this.emit("empty"),Re(this,gs,"f")===0&&this.emit("idle")},Nse=function(){Re(this,nn,"m",xP).call(this),Re(this,nn,"m",SP).call(this),Lr(this,jg,void 0,"f")},Lse=function(){let e=Date.now();if(Re(this,Wo,"f")===void 0){let t=Re(this,Xb,"f")-e;if(t<0)Lr(this,gf,Re(this,Wg,"f")?Re(this,gs,"f"):0,"f");else return Re(this,jg,"f")===void 0&&Lr(this,jg,setTimeout(()=>{Re(this,nn,"m",Nse).call(this)},t),"f"),!0}return!1},e7=function(){if(Re(this,ys,"f").size===0)return Re(this,Wo,"f")&&clearInterval(Re(this,Wo,"f")),Lr(this,Wo,void 0,"f"),Re(this,nn,"m",kse).call(this),!1;if(!Re(this,yf,"f")){let e=!Re(this,nn,"a",Lse);if(Re(this,nn,"a",Dse)&&Re(this,nn,"a",Ose)){let t=Re(this,ys,"f").dequeue();return t?(this.emit("active"),t(),e&&Re(this,nn,"m",SP).call(this),!0):!1}}return!1},SP=function(){Re(this,Yg,"f")||Re(this,Wo,"f")!==void 0||(Lr(this,Wo,setInterval(()=>{Re(this,nn,"m",xP).call(this)},Re(this,Qg,"f")),"f"),Lr(this,Xb,Date.now()+Re(this,Qg,"f"),"f"))},xP=function(){Re(this,gf,"f")===0&&Re(this,gs,"f")===0&&Re(this,Wo,"f")&&(clearInterval(Re(this,Wo,"f")),Lr(this,Wo,void 0,"f")),Lr(this,gf,Re(this,Wg,"f")?Re(this,gs,"f"):0,"f"),Re(this,nn,"m",n7).call(this)},n7=function(){for(;Re(this,nn,"m",e7).call(this););},t7=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var Fse=E(an(),1);var IP="routing-table-size",RSe="ping-queue-size",CSe="ping-running",i7=class{constructor(e){this.components=new je;let{kBucketSize:t,pingTimeout:n,lan:i,pingConcurrency:s,protocol:o}=e;this.log=C(`libp2p:kad-dht:${i?"lan":"wan"}:routing-table`),this.kBucketSize=t??20,this.pingTimeout=n??1e4,this.pingConcurrency=s??10,this.lan=i,this.running=!1,this.protocol=o;let a=()=>{this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:RSe,value:this.pingQueue.size}),this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:CSe,value:this.pingQueue.pending})};this.pingQueue=new Sl({concurrency:this.pingConcurrency}),this.pingQueue.addListener("add",a),this.pingQueue.addListener("next",a),this._onPing=this._onPing.bind(this)}init(e){this.components=e}isStarted(){return this.running}async start(){this.running=!0;let e=new Use.default({localNodeId:await ms(this.components.getPeerId()),numberOfNodesPerKBucket:this.kBucketSize,numberOfNodesToPing:1});e.on("ping",this._onPing),this.kb=e}async stop(){this.running=!1,this.pingQueue.clear(),this.kb=void 0}_onPing(e,t){this.pingQueue.add(async()=>{if(!this.running)return;let n=0;try{await Promise.all(e.map(async i=>{let s;try{s=new Fse.TimeoutController(this.pingTimeout);let o={signal:s.signal};this.log("pinging old contact %p",i.peer),(await(await this.components.getConnectionManager().openConnection(i.peer,o)).newStream(this.protocol,o)).close(),n++}catch(o){this.running&&this.kb!=null&&(this.log.error("could not ping peer %p",i.peer,o),this.log("evicting old contact after ping failed %p",i),this.kb.remove(i.id))}finally{s?.clear(),this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:IP,value:this.size})}})),this.running&&n<e.length&&this.kb!=null&&(this.log("adding new contact %p",t.peer),this.kb.add(t))}catch(i){this.log.error("could not process k-bucket ping event",i)}}).catch(n=>{this.log.error("could not process k-bucket ping event",n)})}get size(){return this.kb==null?0:this.kb.count()}async find(e){let t=await ms(e),n=this.closestPeer(t);if(n!=null&&e.equals(n))return n}closestPeer(e){let t=this.closestPeers(e,1);if(t.length>0)return t[0]}closestPeers(e,t=this.kBucketSize){return this.kb==null?[]:this.kb.closest(e,t).map(i=>i.peer)}async add(e){if(this.kb==null)throw new Error("RoutingTable is not started");let t=await ms(e);this.kb.add({id:t,peer:e}),this.log("added %p with kad id %b",e,t),this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:IP,value:this.size})}async remove(e){if(this.kb==null)throw new Error("RoutingTable is not started");let t=await ms(e);this.kb.remove(t),this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:IP,value:this.size})}};u();u();var Vse=[77591,22417,43971,28421,740,29829,71467,228973,196661,78537,27689,36431,44415,14362,19456,106025,96308,2882,49509,21149,87173,131409,75844,23676,121838,30291,17492,2953,7564,110620,129477,127283,53113,72417,165166,109690,21200,102125,24049,71504,90342,25307,72039,26812,26715,32264,133800,71161,88956,171987,51779,24425,16671,30251,186294,247761,14202,2121,8465,35024,4876,85917,169730,3638,256836,96184,943,18678,6583,52907,35807,112254,214097,18796,11595,9243,23554,887,268203,382004,24590,111335,11625,16619,29039,102425,69006,97976,92362,32552,63717,41433,128974,137630,59943,10019,13986,35430,33665,108037,43799,43280,38195,29078,58629,18265,14425,46832,235538,40830,77881,110717,58937,3463,325358,51300,47623,117252,19007,10170,20540,91237,294813,4951,79841,56232,36270,128547,69209,66275,100156,32063,73531,34439,80937,28892,44466,88595,216307,32583,49620,16605,82127,45807,21630,78726,20235,40163,111007,96926,5567,72083,21665,58844,39419,179767,48328,42662,51550,5251,37811,49608,81056,50854,55513,20922,18891,197409,164656,32593,71449,220474,58919,85682,67854,13758,35066,3565,61905,214793,119572,141419,21504,10302,27354,67003,46131,32668,15165,64871,34450,17821,2757,11452,34189,5160,12257,85523,560,53385,65887,119549,135620,312353,115979,122356,10867,193231,124537,54783,90675,120791,4715,142253,50943,17271,43358,25331,4917,120566,34580,12878,33786,160528,32523,4869,301307,104817,81491,23276,8832,97911,31265,52065,7998,49622,9715,43998,34091,84587,20664,69041,29419,53205,10838,58288,116145,6185,5154,141795,35924,21307,144738,43730,12085,8279,10002,119,133779,199668,72938,31768,39176,67875,38453,9700,44144,4121,116048,41733,12868,82669,92308,128,34262,11332,7712,90764,36141,13553,71312,77470,117314,96549,49135,23602,54468,28605,6327,62308,17171,67531,21319,14105,894,107722,46157,8503,51069,100472,45138,15246,14577,35609,191464,1757,13364,161349,32067,91705,81144,52339,5408,91066,21983,14157,100545,4372,26630,129112,1423,29676,213626,4397,88436,99190,6877,49958,26122,114348,60661,29818,293118,50042,179738,16400,163423,89627,31040,43973,36638,45952,5153,1894,109322,1898,134021,12402,112077,68309,190269,69866,31938,107383,11522,105232,11248,14868,39852,71707,186525,16530,38162,106212,11700,5130,16608,26998,59586,108399,230033,43683,48135,82179,2073,5015,196684,189293,16378,23452,8301,35640,11632,214551,29240,57644,33137,91949,55157,52384,117313,5090,17717,89668,49363,82238,241035,66216,29066,184088,97206,62820,26595,4241,135635,173672,8202,459,71355,146294,29587,3008,135385,141203,14803,6634,45094,69362,50925,546,51884,62011,83296,234584,44515,56050,89476,87751,19373,12691,149923,19794,13833,35846,87557,58339,2884,19145,25647,12224,11024,77338,64608,122297,53025,7205,36189,36294,170779,21750,7739,173883,75192,35664,224240,113121,30181,26267,27036,117827,92015,106516,55628,203549,67949,60462,60844,35911,20457,1820,920,19773,8738,73173,181993,38521,98254,76257,46008,92796,5384,26868,151566,22124,2411,15919,186872,180021,28099,152961,78811,80237,62352,102653,74259,184890,16792,123702,224945,29940,19512,75283,14059,112691,92811,233329,20411,138569,53341,109802,50600,134528,66747,5529,166531,31578,64732,67189,1596,126357,967,167999,206598,109752,119431,207825,78791,91938,10301,27311,24233,252343,28831,32812,66002,112267,90895,8786,8095,16824,22866,21813,60507,174833,19549,130985,117051,52110,6938,81923,123864,38061,919,18680,53534,46739,112893,161529,85429,26761,11900,81121,91968,15390,217947,56524,1713,6654,37089,85630,138866,61850,16491,75577,16884,98296,73523,6140,44645,6062,36366,29844,57946,37932,42472,5266,20834,19309,33753,127182,134259,35810,41805,45878,312001,14881,47757,49251,120050,44252,3708,25856,107864,120347,1228,36550,41682,34496,47025,8393,173365,246526,12894,161607,35670,90785,126572,2095,124731,157033,58694,554,12786,9642,4817,16136,47864,174698,66992,4639,69284,10625,40710,27763,51738,30404,264105,137904,109882,52487,42824,57514,2740,10479,146799,107390,16586,88038,174951,9410,16185,44158,5568,40658,46108,12763,97385,26175,108859,664,230732,67470,46663,14395,50750,141320,93140,15361,47997,55784,6791,307840,118569,107326,18056,58281,260415,54691,8790,73332,45633,7511,45674,143373,14031,11799,94491,35646,96544,14560,26049,32983,25791,83814,42094,231370,63955,139212,2359,169908,3108,183486,105867,28197,32941,124968,26402,88267,149768,23053,3078,19091,52924,25383,19209,111548,97361,3959,24880,235061,9099,24921,161254,151405,20508,7159,34381,20133,11434,74036,19974,34769,36585,1076,22454,17354,38727,235160,111547,96454,117448,156940,91330,37299,7310,26915,117060,51369,22620,61861,322264,106850,111694,15091,2624,40345,300446,177064,1707,27389,54792,327783,132669,183543,59003,17744,20603,151134,106923,53084,71803,279424,319816,11579,21946,16728,38274,72711,5085,83391,88646,40159,25027,34680,10752,12988,54126,30365,18338,100445,230674,44874,84974,143877,123253,139372,28082,91477,144002,13096,219729,46016,50029,42377,14601,6660,58244,58978,23918,88206,113611,64452,17541,41032,10942,12021,49189,10978,40175,37156,10947,71709,106894,112538,57007,137486,150608,152719,40615,7746,279716,13101,19524,28708,40578,72320,1096,182051,94527,51275,22833,45164,81917,77519,48508,5421,140302,37845,149830,5587,27579,5357,428725,248187,6326,206760,39814,32585,89923,44341,288753,284443,96368,31201,94189,119504,20359,52073,103216,179,27934,32801,96035,34111,34309,101326,18198,20704,210266,37643,27880,141873,106e3,19414,56614,167714,66483,107885,86602,4379,20796,75467,4987,5017,118857,26003,34308,114428,29198,6686,29697,73632,3739,69795,16798,41504,7207,30722,21436,36735,28067,28545,3239,11221,36031,41889,100010,19247,317673,29495,174554,6424,129725,53845,94986,7955,59676,2604,191497,19735,102214,62954,23844,11872,179525,261436,34492,428,78404,142035,16747,17246,27578,37021,33672,57944,26056,135760,2369,61674,122066,31327,19374,157065,40553,130982,69619,71290,38855,72100,92903,95940,51422,165999,65713,57873,50726,7288,20272,2081,42326,22624,81120,57914,79352,19447,1684,72302,11774,302559,161481,96396,13692,414988,3721,79066,56627,46883,21150,11747,12184,5856,113458,176117,84416,52079,27933,3354,59765,141359,2212,216309,2555,23458,196722,142463,45701,44548,28798,19418,215,29916,9396,10574,114226,84475,13520,18694,34056,4524,90302,62930,13539,19407,77209,7728,38088,9535,2263,23875,183945,17750,26274,67172,10585,28042,22199,7478,51331,66030,26774,192929,31434,25850,50197,52926,178158,4679,181256,70184,229600,9959,105594,72158,73974,2726,35085,78087,23284,35568,51713,155676,5401,27254,11966,17569,223253,71993,103357,111477,55722,30504,26034,46774,35392,36285,214814,41143,163465,1051,16094,81044,6636,76489,179102,20712,39178,35683,125177,54219,30617,52994,25324,50123,2543,87529,58995,10688,125199,12388,60158,125481,131646,7642,133350,65874,3438,97277,101450,10075,56344,116821,50778,60547,98016,106135,13859,14255,16300,77373,173521,8285,45932,37426,4054,114295,55947,7703,39114,52,51119,128135,19714,60715,9554,50492,88180,2823,118271,52993,122625,97919,23859,37895,25040,33614,32102,20431,3577,9275,15686,43031,157741,110358,1884,40291,125391,13736,5008,64881,87336,77381,70711,43032,49155,118587,70494,4318,10168,30126,12580,10524,280104,104001,145413,2862,84140,6603,106005,13566,12780,11251,42830,571,179910,82443,13146,469,42714,32591,265217,424024,92553,54721,134100,6007,15242,114681,59030,16718,85465,200214,85982,55174,165013,23493,56964,82529,109150,32706,27568,82442,5350,14976,13165,44890,60021,21343,33978,17264,4655,22328,27819,75730,16567,55483,14510,17926,45827,150609,3704,7385,272531,161543,76904,122163,52405,2039,19165,41623,14423,228354,3369,176360,85491,7122,35789,303724,4465,13628,2233,55311,118771,20713,10006,221519,45115,71021,35650,29775,7337,10864,20665,21142,1746,15080,1624,32449,10905,105743,229797,7701,3940,22997,178467,57208,389057,39683,59403,63344,63125,54847,69691,18336,56448,3362,37202,18282,29648,138224,35867,10495,5911,28814,26653,31514,176702,26550,45621,11734,4525,40543,73944,121080,27858,155561,14887,44670,30742,8796,107455,113472,56369,75581,183777,240095,133699,153299,8768,160464,26058,49078,103971,21875,71486,44888,17156,9678,89541,123019,102337,3972,83930,21245,87852,109660,287918,183019,686,10100,39177,283941,11274,24736,26793,26214,25995,77011,141580,4070,23742,46285,46632,30700,26669,19056,35951,115575,174034,56097,35463,87425,24575,44245,38701,82317,85922,281616,100333,147697,61503,7730,84330,8530,59917,61597,17173,9092,32658,90288,193136,39023,20381,56654,31132,7779,1919,1375,117128,30819,11169,40938,23935,115201,101155,151034,4835,11231,74550,89388,59951,91704,107312,167882,115062,12732,72738,88703,464019,158267,57995,60496,737,14371,123867,4174,243339,159946,7568,16025,134556,110916,38103,191,80226,88794,29688,27230,10454,76308,57647,77409,113483,66864,14745,19808,12023,46583,84805,16015,17102,2231,20611,3547,95740,250131,34559,108894,8498,15853,159169,148920,20942,2813,93160,45188,210613,45531,52587,149062,39782,28194,57849,60965,84954,89766,84453,100927,16501,27658,165311,103841,54192,207341,19558,20084,319622,5672,205467,98462,61849,36279,13609,147177,24726,165015,209489,59591,31157,6551,117580,75060,141146,277310,21072,22023,106474,63041,137443,122965,68371,5383,42146,98961,113467,30863,23794,4843,99630,30392,82679,13699,241612,33601,93146,24319,18643,32155,95669,40440,15333,34089,67799,142144,58245,38633,114531,117400,77861,188726,5507,2568,8853,10987,107222,2663,2421,11530,13345,30075,41785,118661,104786,17459,12490,16281,71936,193555,17431,5944,71758,26485,77317,20803,367167,158,7362,93430,11735,172445,46002,11532,54482,930,62911,2235,23004,179236,4764,101859,208113,22477,55163,95579,14098,67320,162556,90709,156949,3826,57492,4025,34092,87442,104565,6718,186015,28214,14209,10039,107186,233912,58877,81637,55265,39828,6194,145813,50831,105849,4974,88319,122296,10272,197216,95714,51540,72418,23324,91555,8743,140452,250249,51666,34124,7229,38592,129641,78169,174242,22464,149964,51450,14034,10026,95376,26190,120062,14401,8700,265,31386,143573,7203,229889,61567,4227,140981,2466,72052,10787,10062,30958,6099,38471,30103,23202,208101,70847,467,58934,32271,32984,36637,24107,30771,17109,73353,13650,2098,157040,67366,66904,106018,265380,107238,18535,44025,32681,144983,62505,91295,56120,3082,77508,10322,63023,36700,81885,224127,16721,45023,239261,111272,13852,7866,149243,204199,32309,22084,42029,38316,126644,104973,14406,43454,67322,61310,15789,40285,24026,181047,6301,70927,23319,115823,27248,66693,115875,278566,63007,146844,56841,59007,87368,180001,22370,42114,80605,12022,10374,308,25079,14689,12618,63368,7936,264973,212291,136713,95999,105801,18965,32075,48700,52230,35119,96912,32992,8586,16606,101333,101812,14969,39930,759,193090,27387,42914,12937,5058,62646,64528,38624,25743,37502,3716,4435,30352,178687,26461,132611,42002,138442,35833,59582,16345,8048,60319,49349,309,47800,49739,90482,26405,34470,63786,32479,85028,39866,47846,11649,23934,29466,2816,42864,31828,7410,74885,49632,47629,111801,90749,19536,18767,105764,59606,21223,10746,76298,22220,39408,7190,79654,64856,11602,82156,272765,17079,70089,245473,51813,184407,384678,1576,122249,5064,27481,6188,25790,74361,27541,318284,45430,31488,620,93579,45723,192118,22670,51913,4162,70244,35966,26397,16199,50899,209613,121702,287507,2993,36101,132229,67345,33062,76295,118628,78705,52316,34375,107083,107454,44863,127561,33964,3073,154010,190914,55967,39074,6272,31047,5550,41123,26154,98638,47110,19998,148091,50229,31329,59900,195442,19106,61347,73497,70015,682,45850,25776,38022,148951,6288,37411,232526,109277,27286,32342,9262,5220,16651,23175,46740,129438,78614,121925,66914,88710,127952,5563,21500,34521,10739,14863,191006,62956,17359,16749,67027,56284,69134,43301,35039,58883,54466,60823,404451,75743,59856,86979,7923,34273,83785,32142,7693,268986,197428,282681,17049,22346,22990,92245,107180,3357,37104,96724,49153,7683,31197,43267,82231,164276,23696,20848,188364,22309,24821,158707,1018,22514,70922,27792,45589,59709,10765,736,35218,63479,51987,24275,63588,55361,92929,81964,4658,20122,12330,44058,13065,311456,72224,8337,211229,38979,22590,138478,52757,32595,133600,8838,31549,94412,43391,90056,1585,94802,127271,6223,31889,137038,132910,2165,57616,230152,6080,10748,36737,74579,134062,50525,180532,119270,34556,76155,82394,52595,29258,31435,87820,67996,26943,183878,38007,2410,13526,180297,69856,3503,187396,167700,7838,16701,9199,56267,3661,37407,65994,23767,5708,62508,221700,67088,86978,46776,84434,32088,5612,9149,88244,21685,95151,46750,189612,2979,506311,2594,3628,40074,105039,78243,28523,6651,38058,71999,30992,12764,68261,108991,6165,26450,61961,13400,22426,7490,60890,109623,2070,12958,50355,67979,257096,7213,42578,52121,35716,65461,7516,124758,39268,302,64712,14977,1467,219452,2840,34229,11121,21602,19270,63574,8024,1532,17331,79839,78885,52029,180767,57957,6069,91265,61380,55767,8927,32881,287603,22149,35029,68876,6428,199567,46926,13412,104132,21434,366616,45060,110046,81924,128910,45886,52821,130416,29416,77342,21762,67329,121432,79924,11724,38625,81006,102033,28338,13326,3250,82056,82526,38212,21112,12382,111495,3263,7414,86274,93490,40844,30224,45212,24019,48411,71367,24941,76729,57776,3769,38114,202019,197745,31953,237533,33270,201580,255648,100798,44741,32241,98468,106931,10085,15090,170358,33154,66787,18819,69760,25061,234005,82660,6295,131975,16874,9076,4094,25005,17740,40908,19533,220019,44330,99792,50040,19619,13950,55228,24423,31253,95308,103177,184795,28590,82285,5059,3210,75525,49894,70007,56178,10580,36051,139681,21617,98736,3555,106306,164189,37352,63915,47824,24883,145530,61904,28444,11483,19837,145446,30420,112972,85939,11835,191233,2262,20705,58630,1753,148334,1197,144714,6887,11223,107667,60879,77914,4151,57417,81594,96681,169430,1784,20444,95138,254041,27038,596,7117,72808,13759,3353,126776,21074,55322,27081,36942,39547,139830,179275,4453,713,8722,71399,19204,25785,22794,23923,104114,11291,25458,102309,88396,75288,230440,206396,104551,58447,130857,37247,94734,31548,176529,226077,65159,20104,10096,66881,94191,237909,27109,37404,1520,27421,25220,113003,23423,24884,50585,6286,231877,150800,11789,3226,90004,60642,5053,202400,61442,132531,175329,57138,30116,103847,9973,75367,16452,32360,59119,21246,10191,164804,23305,61051,37348,154530,13214,5468,50403,66754,130976,50559,80515,14436,155492,84017,5472,43107,41240,2890,90431,70188,382,76234,48040,50211,281038,237007,32115,142178,1536,22761,96429,1811,31243,1679,49143,55209,17402,235054,61494,7462,77030,34925,87609,78002,9499,9027,73289,201078,101379,63544,27666,5469,10642,30029,49816,132979,95620,58086,351930,116300,2110,2043,30845,6154,11279,16727,4122,2277,27281,4971,3650,39060,61970,65951,39674,75686,38151,11370,130809,177895,32665,63725,122267,7857,39618,118483,44792,157755,178624,136994,24260,41308,22471,12404,21707,12486,30473,52781,50246,20247,39065,909,56825,103158,128603,31542,1089,41935,32744,12428,37963,84420,33134,72921,208449,42622,168151,127335,147107,46699,38216,12591,94342,85814,31423,24944,2605,87542,67473,192551,4496,56321,91819,17630,6300,256183,114569,202090,33209,35289,34897,24967,40520,43470,5344,10199,34810,14283,10381,10017,62923,49924,23233,64539,13051,35686,19698,11570,135555,120868,44924,87065,52318,52335,47586,140906,245885,109834,78668,9065,46990,25258,72022,61243,40838,4545,146387,10537,11557,17470,36930,68104,46711,24264,79401,81043,18225,120488,24746,84338,81652,28266,13776,21878,46973,1047,230465,73357,95777,24973,210160,62210,58404,110633,169651,6937,41870,9909,26822,191062,76553,27519,96256,239070,2478,205678,67955,58532,20601,50120,19148,78501,195724,110740,8249,109665,27446,30568,57631,31425,49752,32820,65504,50079,3663,102256,219898,23849,211315,14645,4359,91767,9528,12449,49366,7941,49763,107848,8930,27086,50686,9744,10447,81935,39513,46514,1670,29229,6172,22312,137280,97759,9806,14445,22976,56458,73391,34983,93760,174219,52573,33149,59747,2429,136277,75123,165263,91040,7446,57632,48633,97140,246081,84766,151684,79918,93268,120346,54059,54875,77858,32996,103590,45276,11968,19600,25849,17159,132907,42828,16817,4913,99462,103303,27395,5737,74184,20749,21160,14377,77062,131403,158735,10999,27799,77785,9320,34366,51593,61070,33746,47048,29268,36675,30262,53297,9832,82e3,20188,122292,39917,7331,18160,68301,185935,134830,15031,4935,10004,165845,185534,46923,30109,44134,122631,18874,22903,112790,26561,18549,348902,82871,140345,255565,135390,63556,103747,145055,179600,145662,296111,61661,211987,23952,52342,126343,48450,32919,44277,82185,9591,62139,205363,376969,394874,108461,18040,120885,14798,39863,16571,16794,58271,81025,55206,14640,118656,6361,44092,85970,6262,153863,108244,180200,72264,79947,38044,10050,5735,61221,80712,5471,115689,11391,11661,184257,20010,60116,30320,19327,134598,45455,27542,18004,125092,452272,1549,91523,46567,180063,156026,2608,11174,58848,37788,65907,80194,30490,5786,40775,119519,106241,11323,156297,8425,61495,2617,29675,2425,59886,112582,49142,59618,4863,50597,86710,50650,168632,27693,85641,83643,18993,25768,84284,28090,93592,36627,312804,43381,9887,9402,100931,97165,3311,173330,66805,28935,4963,184460,3201,78102,19126,21607,37496,24938,22615,16153,32862,134792,153318,61120,6067,2812,12826,12792,23825,37559,64662,202250,102694,155488,85881,149193,46233,65383,15521,106982,11358,176786,25752,39717,34208,24510,32464,77742,39371,72028,138229,60688,71386,102834,132477,2208,11548,63670,271279,28351,30338,38620,32491,99845,143885,152266,13252,2825,178663,108097,1775,78201,14897,113573,163346,62292,171129,22183,96598,38733,64971,166776,117445,9968,146393,44677,74867,20908,97328,12761,25656,26785,9148,112344,26115,99176,110121,22437,49547,6180,79320,5835,31392,43328,33377,75870,119860,69497,80273,7325,155219,43167,111173,28347,20222,3763,71752,55041,47252,14618,28088,15012,97805,194698,54636,2036,41349,6173,96604,61530,51859,43782,13361,24334,22668,24792,7070,23441,16789,3209,36211,208475,26242,32880,122181,182407,21444,31060,88459,29929,77907,12716,10934,97005,20599,31690,8403,58445,30303,22700,10336,86731,103115,337709,72556,46788,112566,47684,67089,53548,36874,56487,41387,125985,26893,40071,106683,73712,18787,40105,72992,67246,137276,50802,36790,70328,138827,22466,39263,183295,29858,50975,9322,57397,10654,24364,30383,55799,41600,23584,127295,296610,129078,143558,244131,86397,36049,1085,80677,3820,108139,5476,34767,24683,7758,13060,7239,131671,250593,59556,103392,29810,4188,252323,39404,116877,7651,43600,40338,13554,157253,39196,25978,144387,61211,234,50104,6129,10449,93777,9240,356378,274148,4439,72970,3724,147770,78680,62570,115877,40027,40547,36817,224392,64609,34795,165027,67440,2477,37206,23431,50754,164797,46018,94995,170982,27051,7957,22767,3674,27900,56419,18930,60701,41302,2692,84749,339721,61996,111094,80221,50129,1045,8153,62945,19202,8250,37208,37418,32560,79477,41106,88569,33963,36693,5892,30570,1581,66471,49647,11922,160717,29442,5643,114865,82962,95982,132098,22633,22838,94726,54556,28566,205039,162340,33216,16849,35847,221339,94851,26533,71469,1805,3804,12935,45483,71020,36310,65381,192960,34240,35165,59773,1248,46954,155332,96864,4246,388800,16129,57133,74592,44807,442014,38203,42574,80818,91592,26377,36424,65760,977,77387,22628,147610,28018,30561,98454,6969,119628,63648,18170,36854,26601,64018,22027,37279,51395,152934,21153,9430,58760,194742,5330,55115,34158,28917,174111,13171,122326,1526,43896,66094,25325,4234,148354,11450,275,18999,112191,44365,22723,68409,8733,57746,96565,75007,14196,108844,29475,88599,177563,100792,106156,86323,93726,14248,135341,194131,40126,47099,14779,8272,39597,95983,171398,65882,28052,10393,47213,40689,22120,72212,106829,34964,109146,753,648,21660,30047,17527,181025,5619,145357,4085,216883,9359,186951,24779,53931,24545,36197,223296,62628,168101,4243,107313,30321,26642,13049,51059,31027,107912,807,73550,26551,84369,122422,165872,49754,74213,234264,33151,52014,33100,87183,22365,52500,40013,23302,5652,72723,21404,26107,48434,587,94049,168493,96418,32871,70860,31709,25128,443,71597,166253,15670,70994,26341,133675,28280,75491,54756,47955,56028,26182,11952,113272,472197,64640,110753,17919,337,50642,22576,142,87371,53391,93210,126694,15285,19642,85667,14148,1506,42092,52962,33243,11970,20734,135843,57044,58880,13002,219134,22876,64754,232519,4257,43120,321573,24799,64526,124728,52579,81472,70831,276848,17403,74359,23021,182101,74597,23744,148267,12055,7976,5349,11772,67540,167347,65318,18720,127832,108238,22828,90233,9987,259080,118185,73209,79270,13775,90100,137742,90799,70569,15699,19961,9087,67475,57872,39731,8810,134897,131868,146849,19898,3334,2281,167061,91073,60356,467742,74712,188,53179,137679,92769,29241,9537,132595,80119,1041,88962,5976,40171,44911,102859,139059,104558,98987,47761,19272,71472,113864,175377,73338,10857,23402,23758,1591,139864,5644,4076,118760,16427,134198,18853,20291,100849,37423,22038,36677,19071,195521,57445,11069,31869,55718,66882,148490,44,41296,75242,49704,166810,9906,20943,122258,49112,105667,15969,10344,6408,187694,21399,72742,58970,14867,14376,81889,41856,23225,15042,56993,16074,131389,74276,72407,53875,383108,53597,37363,68993,44854,122548,430927,198279,38430,80409,12245,2981,628,2818,17760,37437,238229,7968,46892,2200,3730,34190,65983,37959,112291,87850,70827,6522,20750,73913,111621,41652,19587,2780,58668,25916,85259,18200,168962,95781,42445,102050,7776,57662,103313,47742,96358,41964,66174,100396,29069,204735,19679,27978,7479,40264,22534,61183,36081,107436,58223,14680,23002,101311,24716,124108,12908,5646,31750,40380,14215,232799,102772,14122,96775,61398,50917,12096,149880,67833,598749,124194,155871,49216,790,14677,65319,56917,7440,145744,95701,12206,49405,129269,76199,45732,9767,11058,9047,210885,11051,7392,26307,2130,8132,147526,20802,232698,115660,50060,59789,57344,107623,80343,112676,23291,9866,160971,34032,118291,15719,59730,164911,28975,2659,58046,78480,21854,66209,53863,109085,116045,29021,46481,107552,22130,18764,70254,31272,11300,52460,43933,84738,20721,53869,190840,79673,105300,7561,321817,66924,13940,33281,101046,183181,32176,71878,5678,62924,79535,56646,40303,19559,27703,93042,73368,42187,3670,37376,46440,7023,36816,109628,20680,5940,276440,275233,170848,112093,136996,14984,20226,111441,77693,112960,48577,39370,55707,50314,123404,26570,54281,61372,123391,4857,35928,246740,132507,106646,44241,7196,92258,9825,37688,51197,303141,5590,15476,132986,10955,85782,34486,26696,7991,28813,18858,39546,11703,11365,38185,5716,93555,11925,40121,60002,6985,10976,171384,3887,43394,13337,56346,6381,252336,39573,75042,53711,1028,31781,44295,95925,131713,7214,68125,43571,70954,213234,1628,8760,13391,65485,17320,56038,1710,25248,60803,57399,19839,3870,326,281556,50945,72400,21460,316244,75619,56246,98775,481,13513,55765,50427,7388,123519,32929,57908,27124,61316,101097,57467,30228,48792,10788,20402,37318,50526,155730,34456,158065,145305,17832,43733,64052,4506,35072,205355,177028,184004,187081,68616,35938,83703,10367,36892,93186,260137,51934,89970,4985,23445,26755,21558,7948,78741,23376,124405,85594,68596,57536,49351,12619,56593,132668,99924,109728,71844,71935,196018,65464,17617,14987,89701,143773,33997,8687,22701,33258,2914,4436,72108,85610,9671,49067,2327,82988,1361,1672,44033,35777,30269,24057,10605,82236,616,15793,13919,47249,112086,116698,9484,80207,90574,33304,68624,93127,56101,42210,160929,4827,38995,38095,4701,125119,5027,33680,9236,231236,14135,87837,23318,70261,78893,30151,81482,14332,1084,74256,27532,46644,79185,3148,62615,6981,55672,31668,36825,1849,14536,37446,14738,23779,43058,162749,72199,1168,21346,5592,85932,85302,9668,18351,57135,150360,2080,228015,77953,34670,119302,151751,31009,106725,84265,45214,59289,74178,113071,263206,111009,4021,44449,188119,192629,123592,392506,292847,114487,12831,205858,9852,20780,79648,75767,357014,97721,18166,21005,67950,33226,204009,16536,2987,11335,66717,144910,47950,17262,55060,15063,2934,51038,26775,178497,66008,3427,49433,128592,20036,157553,63861,3089,23015,51210,28696,35933,49942,71135,231518,99620,17248,21835,176536,20676,16944,38700,165831,233253,295625,36723,13023,52745,10907,19423,67972,125868,95473,82875,1183,108455,52685,33417,64095,21433,52438,33191,127809,44505,211823,7810,2752,95548,162031,7185,91196,47563,61721,33359,17897,23682,42806,178101,22874,49707,199897,75419,82456,8618,11171,79712,116847,18783,44190,46564,5346,59046,95032,7893,14916,3214,26800,24172,121453,34362,10250,17408,18888,4840,68696,22831,13162,36005,32512,14800,62357,41723,45046,27247,37486,5372,2564,34261,298500,66509,133920,89138,31305,117697,19097,108304,81386,84106,23802,46411,63304,946,51417,41777,41041,19501,115864,60743,294354,37955,94165,18116,1156,17937,20645,57114,90804,58042,48643,92288,9861,2557,88546,61333,101008,12853,5148,87856,4152,144503,73841,18718,9789,147565,10846,42085,12789,30223,8993,56352,67203,2448,28215,6052,23540,126319,75933,36689,80235,23231,23561,21383,38800,77548,102798,21234,31468,158608,46188,63960,191679,8051,67014,11185,170078,42186,28827,34777,41930,212079,12421,34750,24111,110344,73918,45171,70826,141949,40063,23979,24254,37309,26724,27179,24718,83648,54938,14591,17425,29525,102675,48975,48654,12316,8929,60640,41709,50168,63264,89812,50716,48632,38755,138583,160123,55579,71829,24230,233277,46322,39650,166388,34718,24108,98252,7031,106695,62498,18258,35062,217827,78731,34824,33354,19520,60852,2432,60224,8587,2836,62955,702,20227,42285,40560,95592,62486,11094,53035,143291,18842,46177,77994,1770,9657,107422,172915,32655,128716,25886,25164,156740,119928,165875,85817,11007,89110,33956,12652,65156,180266,8494,36889,19958,20955,96,1264,118288,135769,44754,86671,5632,19026,168220,289120,33569,93821,66144,70635,7687,5642,2714,55445,56636,71545,184182,93133,7332,37389,12643,52315,22729,11014,158742,17050,152889,50178,34601,41945,52136,9948,26914,63548,95721,115951,40759,8960,158258,38938,49232,48325,42234,81523,253019,66128,40978,20048,238048,38760,62928,122560,118532,43687,137472,163689,26680,9878,17448,51035,16211,60834,36749,29178,14241,59868,150086,2305,26477,42422,34342,165341,83279,33894,14257,29928,12743,13957,125571,89134,66712,10952,16507,147839,30146,7249,16565,45399,39874,114565,215780,31990,230881,171477,102,196546,44538,10880,84948,281705,86651,10617,31395,2342,453658,43569,60561,132901,21845,17727,58556,258242,22262,58728,4008,77997,11806,37431,30599,81375,109137,185787,114085,217292,97453,169085,30593,60212,11544,102056,65580,2384,91655,4855,95725,7295,157994,16228,20669,53276,141590,105246,17334,25440,76067,17967,39321,38911,11362,28559,63807,21627,26468,85816,40120,1025,15234,58319,69516,66512,124548,75845,78873,22137,46681,51242,85683,32909,76747,35555,43396,101465,1765,73094,1077,2962,39028,66777,57831,42048,15828,13962,36041,63657,52412,5242,58846,2141,5506,219012,134451,3936,182230,17558,17153,152237,22621,49377,170216,35257,68233,65374,6510,11126,212151,7184,2480,22517,3437,33073,30156,16557,3768,55067,86829,91e3,12350,148650,66017,79424,70885,49066,28250,21369,51213,34533,11510,3258,18176,18465,84413,6315,36411,163765,4346,356,107618,598,13727,285026,162695,8749,14583,7132,63521,184253,32378,25991,5604,30961,53675,4874,84693,5086,34811,26978,56564,7904,33519,51221,113942,69253,6664,125563,22055,220680,102008,742,51930,19494,176108,44424,35123,13025,75685,11759,74335,22250,181453,131147,16984,132115,154311,11991,76452,52609,85351,196,30969,9198,74919,2529,56838,71779,29187,116304,3504,62330,41190,86153,28393,254926,104228,105189,13264,84359,3574,12415,8534,57147,10175,188174,59504,60932,66318,16407,107921,17638,99103,49278,28403,39786,145865,8462,3558,43406,142271,29139,21989,36552,93955,72365,7176,13556,106185,37957,321774,17782,129017,51154,27938,24952,1935,39366,2791,33489,41582,56078,24558,9311,5449,218786,27808,190429,68013,36020,86003,29735,3404,87348,119357,115714,2324,86796,81973,40992,43376,93621,28784,16808,36367,2517,2909,191926,24978,55303,53308,205724,60068,3098,21375,64784,23949,26579,63121,12319,80145,39967,97861,6757,70143,67642,37082,34698,69140,122883,46151,62187,80934,429,19437,135071,137885,222647,13331,154065,327,61778,74257,40116,37493,14855,85079,237641,42342,102164,199965,71204,4662,29368,5042,113914,122214,8955,13149,102503,43173,5659,163787,69003,307084,63392,171080,21390,81918,86666,36622,24126,28887,5736,28054,207170,163428,79891,346467,95363,38980,111806,80828,9200,19288,294896,114468,87405,111715,141705,7015,72754,68463,48738,243147,33397,101210,37051,98801,82847,20397,4940,185559,18716,54718,83491,11725,40803,1128,12128,23060,5174,7745,67007,46701,1571,27807,180186,256996,18975,16837,7877,212758,250379,15440,87954,57755,24719,124057,83461,258,50864,8874,29038,71289,31627,15429,9005,4061,113851,107716,82819,13651,79656,117851,17539,111446,12938,39724,190787,4352,15402,21070,62708,8539,23777,73853,13552,38810,86117,16285,56400,1718,75342,142863,29033,378,110113,180321,32586,23606,26393,160984,207987,23783,8406,16904,24596,47274,11693,46539,60524,78595,48423,31718,20170,9009,146268,15183,191060,172765,1349,138436,37365,10970,40509,225817,20021,70394,152138,21541,66559,66544,89352,2725,17258,91345,7313,3815,115868,8660,40362,4071,103524,39388,118275,21950,6549,38226,32754,209574,29201,43495,18028,20296,40597,18370,47520,202450,24134,2219,8195,69545,38041,136934,46374,19041,159811,84865,58620,846,98749,13569,30714,97246,32186,4479,27355,92973,35214,151491,75963,37631,1561,27200,238083,23182,60756,12291,25766,39355,102333,87362,65741,59906,19538,201575,48772,102938,24438,292580,39964,66366,9004,61379,50548,37622,38732,28379,68180,76622,17488,69849,5963,7219,48143,43413,55358,540,58691,29506,19245,52193,48621,5518,13048,118625,44755,191081,42061,89197,2259,60665,66994,71210,51232,3585,142096,55024,7892,8345,58653,463307,65658,64319,137941,136323,53499,12746,43492,6978,95163,29925,60175,5128,7352,41463,184756,121146,20473,18426,4598,5309,54580,14277,121151,10691,56711,43880,63409,76682,11830,172218,264898,32632,66536,81062,31649,25788,92774,60222,11100,63159,9432,224657,25240,53613,152,138620,163829,2397,85345,12501,37507,64932,38575,43522,65789,80198,78796,35226,3851,108891,73311,3060,28391,93671,39663,46142,30982,66041,37281,68157,26553,71872,81142,211527,39747,118119,22695,2859,11066,20232,168911,7933,197005,17066,111071,44434,133994,120798,12766,227798,45756,132852,29917,36076,55352,65281,129800,41958,18944,84678,18580,168093,132621,39997,54092,27740,32354,3770,114118,103242,43918,15899,18574,145944,3190,123469,219903,24169,100571,62403,16776,92779,14535,17168,16475,14304,37231,1712,28218,242754,61688,28980,1318,51359,222657,99200,67989,31772,23932,35351,201251,49041,27306,19128,40135,3986,77333,19649,120683,151927,21081,7076,78375,77501,101599,8011,89585,96715,58179,5378,102138,106793,26051,217276,4197,16297,27014,46721,13322,22806,5278,29629,70632,9647,71519,58818,40603,128530,8903,36770,56900,31483,26935,43845,34265,34920,87658,6114,84767,64250,47318,50720,19264,162514,33357,13117,6705,46696,75032,71054,87004,42035,69138,11903,99854,102328,19611,34525,69312,6431,49842,101600,133178,108751,41829,89939,225664,48916,99556,9195,130387,5960,36857,116724,53518,94002,39077,53996,6945,22261,64291,8314,152785,57588,16522,9091,5048,87671,35441,39509,1945,12423,158923,178413,37549,14095,1475,73188,62878,4819,24012,68534,42606,4010,120809,57497,59564,101758,103718,32701,80116,12345,95834,46918,21468,53213,15665,31200,3867,5140,96013,250744,21016,10069,13968,35449,180829,27683,39704,59956,22893,3115,26293,32785,75934,62445,141162,62720,2018,83638,19949,114012,95006,3330,99829,130935,309272,9565,55874,121727,37017,23586,319858,40970,27602,8625,112329,61060,100088,118525,25922,16232,1907,60671,51583,44553,80993,5262,94679,8676,940,20736,11823,3020,16476,12340,152600,97416,3703,25744,66826,16245,16876,46446,84798,74227,176020,45192,61955,75496,23946,23626,40372,26036,6149,11822,30582,16541,41914,82385,232823,40921,80773,14930,3631,7517,39619,4348,36180,126106,138939,62611,1477,113512,47321,25052,14546,118881,29060,23589,128322,36795,18401,137921,104699,267929,36194,172791,18113,4766,188215,30083,332586,94089,5805,77909,22194,68234,154976,43220,40660,70001,184893,138095,11128,103010,22663,5108,212615,8485,5565,49222,54614,26530,42639,16319,55062,152662,105595,21114,22216,10294,68158,10436,86950,7206,62115,3977,3657,59874,456,118617,18156,106663,112229,80992,17442,8217,55551,5133,34344,251927,51153,39364,201321,7816,66803,23057,156724,145664,14276,95705,979,2796,6875,13429,212525,50602,26276,28284,3424,19465,52397,46963,31420,51399,206476,92317,48851,637,100820,83349,10317,60227,21972,6908,282439,32857,224767,95629,83882,42106,87338,69757,29840,68709,37665,45244,114577,49188,175943,54009,186746,106158,70168,3358,234002,50555,9221,129338,9562,20118,32923,78479,118280,65752,4977,10474,102174,60947,129006,10570,83451,8598,8078,159367,123785,80438,16742,5905,5281,181513,42402,6977,163136,93179,42191,14968,50421,112401,105440,33456,57347,121611,4221,94954,36517,24046,27796,6255,33394,72990,135408,116627,1233,57874,25654,95419,68156,401399,313338,55208,45573,93124,119251,47200,38196,11909,130667,45391,73904,64964,167846,4137,115606,52036,62214,7969,160925,7187,1132,134835,40309,73195,64494,80472,444841,61111,26500,45323,40743,53625,52797,22659,15631,29739,36706,28841,39147,102836,26794,10536,14845,87305,45874,12241,127587,83833,57183,79722,30844,41304,84655,20825,92500,3722,25655,27811,10157,81634,31362,34088,92487,70123,22190,185100,72658,139035,192523,88241,2078,230490,44528,85638,100198,22088,29982,291233,241062,13865,4445,137791,37835,107218,31726,19718,38234,72528,23046,19177,66695,5109,17251,28077,5617,21554,47839,72425,133825,1486,73065,181275,141508,21768,62971,63082,2512,34200,9904,120309,6392,91243,68416,268253,41199,116757,138551,185526,41246,28986,4093,19057,17295,4148,245766,122360,35356,112075,20301,75441,10998,7977,19769,62922,937,63547,100196,26427,157820,20983,236696,22935,8140,90315,156004,47204,140973,7726,45097,52725,22636,23436,257282,105247,522,88389,216031,202204,46812,211666,19693,68828,81691,45925,11256,30292,372,5236,167826,88328,232776,151611,5360,82104,18841,80393,25465,18285,20320,72377,31730,33160,45803,38715,27705,37379,24163,18360,103586,4015,32305,269494,91252,20080,36567,54650,7797,57073,12650,31164,42209,6375,261663,105528,81661,106002,2800,5375,17247,43151,4442,15727,194619,100855,144898,62320,78465,39929,16454,1967,28311,61363,17219,9395,8745,121445,76939,80385,162380,22009,54191,44248,16299,122830,48151,74429,78291,64755,14238,44966,2511,17712,67954,93583,829,105899,49935,84750,11591,33185,85447,42717,27409,208542,28965,62052,52525,5597,25694,65594,16343,63224,276188,12475,9331,127507,38522,57287,24128,133161,79723,105548,133695,48917,27558,43278,46520,13778,141954,110785,83366,17715,46317,105763,66298,147013,41086,94180,16478,220447,44611,730,19722,78975,117889,125643,26254,16574,18480,65006,15806,38549,246418,46052,36056,8440,34984,30170,3163,59800,4458,115442,4283,41970,33507,104078,1653,22,121158,276486,3655,6338,24048,133421,23641,2161,24422,36006,8086,10675,181474,12307,29514,59143,14729,52509,87128,122470,19446,80852,33314,24573,119864,14237,9652,57779,6612,51851,15284,98871,90581,124466,156831,21190,22015,71380,161906,87247,69201,18392,17908,108470,72962,40719,14338,17911,95260,43339,20610,78916,20710,72451,11315,31448,17263,58853,178878,48111,116002,45497,80506,82605,85880,36300,121755,25215,36118,301929,88728,405223,276136,553,34704,212438,49970,78329,922,20711,25036,257130,38295,145369,18128,15385,30829,55656,48345,8012,3561,28004,122041,192900,58338,112508,41085,29976,87040,47117,23905,4336,92061,138880,97407,42083,172121,6256,25192,172671,5,93568,1420,12677,31605,56743,40620,6015,78415,231077,31298,80026,13902,19048,24924,170586,32955,176119,87859,36731,6773,27711,24658,26475,115216,133207,93250,95820,88522,8317,5714,124047,55219,86860,19677,23961,22928,162209,8904,225992,359835,56084,96201,29392,96558,86071,93643,55114,13347,8183,95129,82012,2017,123336,34219,115554,157159,47747,101684,41008,18735,193781,104151,226906,7552,179874,124113,31159,21162,44010,14771,51268,166128,31382,73124,77438,92830,205709,12113,1292,38937,13114,1334,2118,15597,69581,14449,21934,76618,48728,67038,14967,51495,24243,87736,147249,26720,11119,46063,43749,5843,44147,152629,133428,65703,14269,45604,57982,28672,55616,45957,8438,95433,37698,220862,132034,39456,61870,4161,26501,73560,56418,9845,4654,20916,10456,88920,119358,9015,65931,96507,48029,38534,21676,109081,43078,34943,25089,6131,28766,23665,5477,10255,16695,67,45778,42443,42770,29534,23733,100513,62617,42630,48746,14191,43753,50295,26007,8792,57243,43119,54725,164253,58250,112304,131796,25165,4651,3188,24831,47748,3705,19540,13211,102095,5593,18699,23666,32005,117571,33541,60584,74573,86311,99443,25172,27222,168938,7143,11853,53560,18834,19960,86522,28217,53266,117700,72989,34323,18721,66450,34346,74056,47217,202002,46269,9429,68582,75458,37823,82843,96652,32549,145144,27958,19820,158086,31955,201406,135379,31207,192545,12950,51704,9094,248263,76147,64028,110009,79407,89345,99284,223492,47966,26848,15359,201137,2861,110507,71231,72297,31851,118777,71039,151051,240855,16333,50766,14727,7939,4149,80908,418780,88378,59276,1327,7284,38576,79814,65820,42199,84860,49574,62596,12396,70598,40117,8648,7994,16836,7630,14047,359699,106878,525,29037,28064,13380,11675,50669,74216,103539,180314,27449,56299,172344,19274,7301,246099,32043,19422,36506,129317,6806,30140,4614,46639,66926,932,86600,6322,27847,233103,10541,39025,34887,3517,12972,26220,2031,66561,115015,48658,47596,12714,33845,3893,16165,35237,89983,14769,11962,147224,47018,29977,27979,5552,82338,86023,131368,1218,24853,237840,132193,15455,40873,3668,65351,53388,15229,59889,272245,47934,11858,34347,18038,90853,86981,300602,19343,114181,29362,84921,6095,106059,79472,38015,1206,48741,6208,8e4,21916,17423,6002,108083,24479,34931,56661,9511,26995,100694,163853,35997,81254,58321,18919,171890,86877,91341,74503,70477,53412,7027,59281,39892,131302,5864,15947,61301,67466,162369,47956,27874,35624,282324,21270,111847,102548,41482,30955,116737,28264,8592,55458,22301,75090,29821,30697,51709,3041,19208,8038,24634,30467,87509,126428,19389,18814,152686,20701,83474,45832,80891,105808,11378,153223,120770,98186,150633,49838,9141,12755,30962,5260,74490,21256,31678,65062,33326,289838,187831,20595,89768,2805,58535,10844,70085,12090,2451,138068,98544,24461,4511,6754,41684,28203,3383,65355,82833,30161,83924,234361,128424,28921,222594,33975,125491,34069,11508,67464,144226,41850,98703,34371,7901,21254,38398,65651,23549,53883,213340,123269,12028,71764,177701,28758,2623,68395,11549,15232,68603,9660,63116,36079,57093,31198,20475,48467,89984,35619,186847,107469,31389,43631,73867,41949,68841,114250,1605,30564,63403,17588,27680,99533,12641,70325,50428,73426,78379,11855,91651,72081,91720,60198,15743,12065,83398,140046,6761,46598,45900,5068,886,62448,148968,37347,19405,9680,15819,43496,63370,75667,163700,37639,3633,22774,34341,183131,134335,37200,23915,7054,14194,12970,26438,13350,285521,25594,8219,104410,91039,168804,138480,149734,15907,33818,61132,60082,4622,110187,56736,13551,73571,3945,73463,65498,17758,263266,17593,2710,27585,54469,38200,45367,63754,28881,3473,12791,98287,31895,65787,4463,94536,24951,36332,59901,28803,52130,86403,7668,181822,74831,18977,9850,177206,145485,109798,7292,31421,26280,77211,58511,12507,127004,11113,147,8729,56208,43066,79926,129937,31345,83947,39915,46146,98763,42566,1337,13192,18323,105163,80570,117753,16555,72883,11077,159438,40764,70933,83329,26066,12276,72059,21655,173836,126713,69454,153482,91585,70644,102558,110483,6764,127864,190133,3961,101798,20945,71138,82402,90884,69669,44753,923,16939,59700,164258,25969,27082,31399,43846,6306,246093,51342,6153,151581,202801,182731,56475,162188,89426,141356,14355,121815,27536,28023,65257,77523,106668,127314,24947,12790,38796,169698,23555,10725,44573,183083,42088,62716,43265,105958,32050,44067,50118,1668,3874,6243,318411,16599,1691,94999,52378,28671,216728,123258,2059,34969,69225,5913,136280,171443,141515,91662,22175,135282,80020,92270,1663,4808,4482,3495,34691,5226,109830,108512,17342,107488,11606,123190,100247,29666,146527,113014,15794,30894,13224,39585,243192,22351,9903,7836,47699,11078,25468,122291,48821,26780,122679,75521,81450,630,4895,92900,55074,74293,17441,3563,111657,103102,51613,12318,52370,36191,68245,34269,40445,41354,122901,168604,182500,62012,42557,11259,24428,115113,86345,12362,3909,78430,86852,134602,20459,47853,93879,22577,7659,3688,38555,13349,17381,56715,91639,12493,10895,92438,3142,37057,28928,2004,36427,32268,34222,209974,10432,67436,41989,173518,107930,27079,62729,30908,55558,5828,45031,14902,53546,8204,144263,60255,14520,88212,86582,109589,69356,8064,47449,8505,66558,16886,4844,52817,111260,215129,12941,91118,650,20770,6273,73089,40618,62790,2873,35002,14023,97208,19386,102646,36993,143736,135457,35385,113601,17893,32627,84439,100619,56016,6581,57264,172160,45452,111710,203627,70131,24100,322787,1996,35665,70078,22358,90922,83658,4097,63200,58499,14542,99153,52159,6615,12414,63415,31986,16823,1579,65405,137809,8841,16898,48082,259,33014,42375,12260,179850,73667,91389,98882,29532,17311,326251,41092,5928,20742,44964,48019,43505,9317,49265,6643,192712,48424,163487,19861,20113,70848,31928,105333,23685,78563,14638,54755,7158,24142,44018,20774,125255,20331,24280,10163,1285,2336,39851,4299,117269,46714,63816,87779,159624,11731,9971,990,137317,108831,50994,74554,162680,23640,131597,146962,170620,34829,91205,21184,1913,63616,18427,93136,156592,17519,67565,115882,138220,78622,88535,18115,2711,33554,109492,54298,971,24914,25863,36363,45715,27099,194995,14299,178181,111488,72395,322385,157719,130787,11897,81843,83999,11369,49280,118604,40922,61332,110343,53407,75639,40582,300440,54722,25637,13694,48248,48278,194521,56203,52779,48783,72627,10953,376,16733,280238,26351,230789,15132,25168,137270,3588,63704,73376,94031,74284,19443,159557,9697,39901,13351,119050,15406,146455,3460,29556,75195,37673,102524,92329,47289,98413,15311,100684,56345,7116,95480,11590,7200,167,23610,58426,17730,136656,27944,53151,2701,8824,103124,3017,90744,113588,53216,79736,65940,26931,498,29568,80540,143543,21292,1740,59268,16561,180816,42323,50174,40890,52866,10703,57169,4700,17191,4424,93511,49698,166650,26972,48631,165169,82879,69326,202970,4007,2376,231325,139592,22119,62851,37504,68816,58345,67398,186643,43331,277416,53749,15746,23102,17432,4793,151138,48822,54265,48203,198688,14305,54287,2291,18018,113378,123260,7180,97549,87027,120085,2920,76080,8190,102005,5641,64580,14955,59802,54028,58884,19367,81779,412567,85957,97053,103637,78871,29364,27637,141728,4767,30686,112738,130146,42745,12730,105040,14844,232,210944,36581,152317,135543,29744,3129,55647,58149,46319,27265,17499,28005,59948,7170,34138,5702,293047,110892,408,91760,218674,18469,46095,81403,14389,4610,35672,73060,11006,74848,104820,118143,190357,20043,105358,141735,5115,27093,45924,123073,52599,29433,9616,238350,78610,24851,58858,26769,31969,24613,18294,4982,32735,39639,143563,112073,202205,12567,4873,88601,44897,81503,101648,81362,34662,85277,17574,48173,21435,221188,40215,39576,80786,26544,64668,81841,10731,37733,247986,149188,127703,495,18382,54388,72446,43071,30974,198723,89608,41360,190,33045,8386,31658,19992,237838,119015,137622,50890,100913,6460,116233,267230,26621,104129,65114,14190,41542,14888,85962,23342,23041,26453,43725,71809,45186,4770,46452,53894,56616,221286,18973,9038,109299,55365,19366,26863,18808,60909,69353,41738,83463,12100,68561,72860,3980,13796,49340,12332,31311,27418,4255,53430,18976,45523,510,14224,30477,26581,4530,3651,101663,139840,22709,150861,31996,63923,120623,262522,3076,10528,2929,14672,130238,18087,9816,121894,100308,25085,55111,14565,18952,53293,2042,369988,23674,61789,133529,28783,108293,35477,47119,36448,71049,40015,33055,78598,198442,1833,159937,40654,77444,189245,113153,8621,18599,38553,35223,166072,2375,11659,21786,89523,6032,12116,63046,159398,18454,3678,32521,47626,11411,103527,38896,42946,15696,26370,10185,8413,37080,165583,4331,63555,14907,72220,50056,6623,62236,36565,49783,10049,17503,100581,55951,146244,24724,9626,17969,25524,109300,173965,99994,101056,46459,43647,53737,277968,8347,123521,74858,33829,44762,77574,877,81377,222525,123532,30602,43881,53145,2973,16284,81940,61281,127044,63620,9875,14756,114829,19032,9202,52759,119141,23928,120551,19607,3599,33401,76821,73233,117430,39968,36539,7071,5446,121735,194059,15206,45283,6706,15603,65615,1207,165723,92275,34773,104447,8396,32353,205240,164323,13600,60555,79205,25532,22907,33410,57480,107111,69630,32137,47832,70913,33161,20321,2371,117348,10714,86246,1625,11763,17900,268,78457,99175,97940,101092,86660,32221,14041,128504,125080,53744,124263,31017,13897,403,31859,21964,5633,111630,5547,77329,17961,18241,84995,25984,12983,67491,62168,47262,5241,297,51191,7351,8967,147212,82060,16821,782,11033,82431,62957,5026,43459,77963,203477,53528,6247,191852,87774,74164,215654,13467,1522,219964,28589,244104,16242,117821,67725,72570,156792,17186,15979,26990,44128,193014,35276,57125,16212,166451,68017,6905,77608,16364,53777,75921,76426,37975,26203,269296,64099,84122,12077,38533,830,4407,20139,963,43028,38902,42911,37503,83343,85045,16979,1165,60835,137387,58380,86990,110066,134540,56331,193845,81238,17922,163093,38744,110641,12502,56404,34862,26865,125964,12965,111648,25547,7771,27196,136980,9555,29551,107158,57885,18831,37705,35505,101742,13970,102109,62548,124657,23328,11124,89592,146376,248050,6241,22033,18337,80685,29898,11908,216623,67721,106162,146610,21377,15085,91552,42041,62560,122532,125336,102365,121537,142559,29693,223919,11515,110495,18776,22494,5895,185059,103592,229351,51220,100102,37027,257855,29359,54123,36066,106493,12244,79258,32002,432,56205,94836,90182,6726,14762,29391,48938,26864,38083,60364,3310,60192,14766,205567,57504,110760,22649,24666,46333,21517,3430,13135,28873,27052,158809,11597,20529,6695,23138,22960,37137,45574,6545,305877,43423,26153,24769,59844,14501,10430,134352,56169,13213,103432,49523,35181,13435,12408,129475,64620,230854,77390,51990,15653,83248,33466,44571,117828,51481,2187,10559,68019,18021,54895,48247,18354,33737,4554,108595,37288,39767,116707,9175,3726,108877,21616,83684,49862,1938,8543,276466,20134,108498,48770,102254,31914,131520,185291,100559,51890,209,19526,76471,50544,71814,99351,8172,198526,28816,20419,9109,98389,136777,76479,75596,30635,165417,48216,120220,25955,211071,39314,24308,32164,2559,146280,43403,9233,17947,90585,1786,86920,125662,2457,64741,32152,32918,122882,78538,44001,31723,56426,23375,103172,88177,145697,52506,49319,68016,31664,41488,18486,110400,7030,28241,986,109199,19900,42147,56864,65287,49183,7858,24e3,30453,840,16673,25907,68916,89927,6309,158335,36407,199737,130464,13137,59603,201778,195292,21015,42466,179062,172561,89492,11075,180407,31868,72493,20998,60217,9865,19530,39274,130266,54539,21623,12535,13505,40641,73375,4087,85633,2153,3117,70680,55788,92096,47509,98493,37490,271936,151475,3032,16171,96642,34106,78425,125761,19591,3366,19316,54508,24183,50786,194248,91528,33253,34622,108355,41741,705,3814,3883,108929,13203,67831,10142,59754,68208,29128,84820,56880,38794,24972,48571,40821,40476,18137,164254,24064,236309,79181,11282,395,39169,2013,51587,28551,9645,701,109513,115899,113566,12762,62045,58322,103726,41343,40866,244102,143816,2490,70346,40973,52618,15412,30720,104315,38917,42027,93676,17513,107418,20706,123890,13399,97727,24044,87962,65606,44250,98044,65276,74790,101473,19350,91570,1326,87790,172042,7577,100813,86896,85891,41512,108130,27794,14875,71431,12835,156250,58135,3759,22476,42176,115873,34686,56523,73643,108505,51491,20838,12721,32863,45700,29496,13700,34294,55360,29206,155942,123812,7706,163234,203,132720,49358,144431,8130,175788,35818,3270,76832,25710,54095,97274,28779,94621,74396,19092,128242,58067,20885,14670,93255,15107,63291,23654,126900,129421,59294,262659,9798,3251,67344,28600,44629,50672,29072,26999,31526,23183,49175,165843,175455,17282,175411,32022,45989,30298,90690,78118,83156,23749,35636,31317,7069,80381,94561,133756,14960,97404,6138,41065,78041,32843,16601,34123,9559,146529,123377,96395,54441,42012,84257,123541,10745,22139,106459,11720,150883,172651,154996,110538,4728,53447,25704,2009,71152,119354,21166,66604,1429,216162,8637,122250,63520,27180,29172,36124,276428,107787,77184,4680,14952,104903,24418,14793,51561,52931,8371,26342,48526,7118,92066,67280,40653,8847,34597,105438,14198,50163,61188,146286,50315,41205,170829,161496,585,197359,95056,1687,365794,91349,48507,5804,49263,5146,104902,96365,117343,132222,46084,96919,16875,8073,262381,79982,52663,13928,16056,153908,15145,109256,132308,18763,24904,167644,13618,40750,18686,147124,114709,150038,52849,2938,12568,48617,8778,5459,44202,44591,74914,17183,248689,13878,7822,80060,23116,194037,18487,2067,7798,43077,33678,244028,31320,74273,2794,19466,8218,36280,183997,48124,19416,29656,19280,98734,7715,18311,30701,133602,150307,126956,7378,2933,79903,13178,12593,86571,26604,92446,13574,44205,65699,427599,21118,8245,14407,27877,47936,33542,7916,26460,117762,21596,37818,2249,127359,209394,60044,47677,308089,36791,154971,31417,6998,150042,174360,12255,43009,29335,48739,3912,101398,53340,2580,146939,151295,45360,125275,15273,45383,27456,48761,23314,8750,60801,85823,104759,27894,123685,66968,39480,26917,55290,83305,2696,98390,57569,145853,340733,4919,20024,52268,30884,7413,203685,70989,112855,4129,50536,349518,68205,332641,159581,135361,236026,37563,176404,64899,6578,122033,63871,1850,85234,82089,66124,74145,121098,107351,12687,36881,117334,13136,14698,85933,93866,18047,32620,310,15094,46e3,88451,23632,36645,27940,87618,80520,58892,20976,27702,140090,96075,67841,103292,238964,87778,107338,17019,83427,67522,7302,8261,47570,116787,8730,80484,61772,174422,56005,131193,52875,14588,28471,59817,9586,15720,158155,51307,109734,15196,11025,59331,3884,52626,102602,84797,25158,27314,4437,20488,76214,189248,35023,114952,157376,2827,62439,102878,129749,36405,10329,109339,108633,36662,1254,13267,5470,87105,58004,15397,10434,159667,21864,52022,179464,3013,32147,31496,116832,18494,105502,129227,107267,50033,13481,9954,24267,22141,16257,116154,36185,950,115685,11305,176708,2048,178671,112573,287867,162328,497663,95170,50979,193861,50987,30368,136257,31830,46549,15119,169876,23788,17462,249887,57377,1949,35448,14791,43769,210091,3783,34612,282103,88380,245190,5457,20491,98908,11402,86899,117916,16028,162584,60644,320177,156096,31065,55876,22e3,77655,9992,23397,13757,317623,63978,215255,2443,17648,93231,27388,104529,93807,55505,140477,12046,112040,70887,40152,94365,112353,25063,114679,266061,71248,119555,15589,2244,617,14129,211431,70110,100652,7777,4383,85911,89221,21010,120615,58357,86405,37554,41647,18,15143,69662,60491,14714,186134,148344,42347,5410,168175,44535,42449,343894,129417,99682,20659,27272,140483,63455,222159,17536,13722,42637,62324,11976,114691,148109,2283,32057,182393,4295,147364,33705,2075,44303,30274,28331,63740,69740,29148,10346,44862,33716,73937,153333,12930,38784,247159,2515,41053,20256,83368,256189,54639,115240,5096,24661,175419,153552,26516,141,138176,63885,34115,47222,55709,2765,28479,38875,236608,12229,22921,77291,54426,45388,2860,57787,114579,295139,105782,17826,71066,19119,54364,69385,16568,12323,28057,33346,34919,124763,155533,101386,31644,8627,49001,303600,29868,63213,9103,77280,71333,9696,138789,37059,24823,5057,21352,32368,114208,56803,19424,10445,58514,8661,209508,26187,171838,10460,63454,14016,122504,41328,21329,46618,32493,38225,7855,31763,7945,29876,8734,6438,24205,97490,139977,130740,47323,33195,85390,57194,13813,60600,21313,96251,7699,27584,170521,139271,1363,4402,336738,129223,84983,69150,13147,3590,163929,207225,155260,55916,20288,4503,8398,98490,11773,27512,37113,84976,86558,28365,11756,116005,182148,13733,115313,47644,67208,85069,9347,14995,226141,14704,101835,41159,35314,13113,63526,214039,29978,50446,83339,17440,129441,72522,118641,97816,24907,73844,15717,118884,167255,96509,162793,30847,36849,51297,78974,77793,10427,1873,2972,9999,35074,28190,64297,146836,46298,60038,163007,108919,61219,2403,75022,127339,4233,110389,69022,9833,128097,88016,79390,222936,22570,94657,28462,56956,38803,81536,30474,152794,19566,16481,147408,74574,81895,20731,1918,1366,76367,187321,54494,24366,21690,61696,33283,107477,77499,31112,414383,74362,18463,218441,120929,59848,258629,201924,69269,454,19989,13054,59894,3623,58908,20681,35723,78523,102680,38988,184112,108087,50944,132704,52966,21699,18860,96349,201411,82697,85395,95658,5093,6427,177894,44191,32755,26961,155739,6249,31310,81030,26574,84311,120155,86730,113535,7424,48888,13516,45747,98098,20077,183995,81945,43210,26704,40420,75831,45648,11180,6855,57927,65528,124096,34851,2598,156633,107572,127352,38169,123845,60142,62722,105584,232364,23211,68120,1601,22169,89299,747,258039,80572,7258,152249,11862,101204,8834,121434,33761,19175,133142,46343,40178,48723,3589,41977,30210,38868,62257,10087,82658,87827,90646,16415,47552,351723,28298,72225,91146,272760,1701,11295,1652,109651,300747,51863,198800,29446,11794,32345,37538,22356,33102,37590,113544,37970,11478,179743,25454,103417,59905,221970,105196,145604,7817,164809,102360,16974,75840,255333,56902,6659,1954,645,59400,67769,7689,18675,5215,13793,20536,27852,3387,29523,259718,16860,94625,43143,29245,15848,233581,22685,63631,78557,22836,133302,84513,1348,51826,47129,98836,58284,1830,1749,94642,10933,6145,12506,10975,13879,103781,144434,10268,28409,32346,52968,121567,107374,77268,23686,35097,10501,155275,15303,47136,21102,168741,55332,90385,15996,84817,681,137803,25054,142275,6163,38175,8056,124296,240642,65621,4934,178205,16101,62803,60964,18230,100622,76465,44689,14545,9543,47514,16852,93380,28048,12047,107106,37575,101485,77047,57326,34819,96137,76916,6469,46264,115983,75768,87668,69942,13027,165,8373,114231,26434,52844,42799,182044,23580,146254,38081,43236,33883,146220,382894,14606,46035,36481,166621,35417,95382,2957,59384,60428,36358,66343,75378,22267,22950,83528,17577,56474,25285,4619,179691,75355,95836,53295,34588,171410,4487,14679,84208,44015,18562,109133,54101,11531,86052,174479,303157,28095,9953,35642,14564,39802,16145,77606,117406,53038,121117,53624,22062,1212,7632,127157,237292,189087,10478,127345,102515,181997,86752,87623,10966,121602,68783,68681,83042,114380,138349,191305,67176,50085,39016,1427,42384,1412,67118,122616,72389,25260,2237,13576,137346,19938,20304,2191,68759,5373,61364,238507,75814,23931,69565,38993,131741,38364,12528,87762,5679,129853,5310,186831,32653,90338,260176,389531,108118,26843,43985,50175,30563,25106,56965,18130,140428,4542,165503,117991,24219,229605,1819,129663,1240,3797,76093,18398,71339,51919,93043,27175,47060,216257,6483,35051,1217,16512,80798,129064,13225,69339,8548,237079,72298,2575,34280,51379,117910,55671,53345,247552,29486,39328,140821,34681,57045,60177,5004,90269,78522,2479,322607,48474,61296,13057,31558,4678,59271,6699,27044,31988,35944,12503,83480,4389,136508,3781,114121,70279,4488,155829,42214,2898,68191,75695,305850,45041,74344,106509,30087,17429,93292,12477,290,23080,114802,35714,18751,26554,105424,17775,2144,2412,100610,65192,113975,52975,180272,135050,129815,76238,106483,21440,63186,4260,46189,9711,28249,4169,23429,23390,8324,141585,63809,67668,38457,38063,39226,59972,1189,203916,62368,14403,16949,61767,85801,1739,40147,35049,76757,33124,62102,15780,103593,103009,53484,22952,67973,114645,6566,5245,50462,7601,8288,3513,194571,80276,1908,54592,5124,58571,2513,6800,273997,193904,1119,17991,117245,2508,129156,82366,26278,71465,63341,56943,39662,106116,94966,156875,9736,2204,122308,94418,27134,1280,24539,49022,45314,3764,50904,46424,30699,28087,293839,9400,33646,40165,822,147499,50263,116179,29085,11863,31314,5578,17797,5104,12454,1604,15342,219206,10232,67800,94261,25872,13565,90339,78971,75377,26649,41184,47695,11514,35369,20767,14227,41953,309396,148270,147938,33074,14453,27499,109019,39018,25738,240196,158931,52820,8612,95853,21524,137010,84901,70869,70021,116794,48404,38771,6732,1070,70990,187297,49140,5238,576,3564,253975,16027,16483,2811,37775,19034,25259,4053,2e3,70083,95774,19713,33431,92703,91314,42381,288770,48194,95985,3991,77418,13406,241328,245086,56533,35275,62725,9246,51924,70181,95331,16163,31410,79016,39312,120878,119371,275987,80124,27712,9186,220,23598,146167,85209,68238,282190,57048,31273,30555,80913,17594,75779,59160,135002,101219,189377,29225,96735,60126,62522,104e3,27620,86814,17240,147533,11001,5425,43682,410,49460,87270,69480,46315,59448,1816,76201,9431,11788,87960,29063,65539,47347,11678,33846,7008,196704,9895,6753,8633,120892,59970,572824,115934,6646,202559,892,48351,37611,251282,57823,67263,57750,26527,34485,90747,7685,88370,6144,64182,1709,41969,21458,62327,181657,49247,225330,122600,114574,107124,85361,111833,63243,71420,15655,191178,72430,18063,51425,54002,12364,53225,86557,18193,97580,41232,138398,67821,128724,8944,233212,101353,52099,42127,14006,120107,32789,32132,3498,18123,33758,56058,5779,128760,59888,98869,18445,84702,51911,13234,218379,20093,39031,8074,70195,20708,23462,24355,131384,60189,26390,10403,41060,7140,10781,49410,42261,87202,82566,41663,43105,60276,2768,5733,74176,28329,2297,145430,131632,83615,122915,105441,655,224102,5284,136426,67763,16294,188511,32538,61049,27893,3394,13951,159099,28542,17930,145360,9492,190122,32285,78855,26440,13570,58648,73908,4239,124561,2444,74172,53131,11468,10794,73566,11623,35343,64710,30481,4163,10328,38309,29901,10538,154377,76132,92405,24839,11679,3465,13449,11637,7824,2337,57754,1260,14458,41118,19878,38661,13416,159180,37074,163164,54137,28627,52134,184900,8520,40385,29546,30502,22386,66527,107458,6850,24022,47983,30603,35083,8934,304066,39500,9,28261,33026,77251,9374,44833,116312,34990,29236,63563,125639,135405,165398,159055,55690,88141,69643,236964,31983,25572,20436,36746,60896,31850,16179,11828,5888,3043,66368,9750,31167,7915,53111,36430,1333,64344,93659,20061,60596,180191,51630,6792,30244,43509,101058,22409,420,44210,109783,43223,27030,72477,72831,32679,29235,7675,47556,12258,39907,149412,84926,118247,24692,71717,105038,86009,45941,41189,89453,29856,52543,30627,226798,67303,59230,67415,34408,1367,99685,16867,128419,52147,4111,125381,117881,16173,44093,102224,31575,23234,24870,83790,127407,239098,3200,994,1255,100903,242275,117266,55116,38205,16140,29662,11307,40414,208793,123355,56470,4862,75600,30119,58218,70828,24075,26974,7802,192353,4851,5475,78720,66596,3409,28573,64396,30381,30690,59859,88256,5406,99945,103064,34463,37727,24238,86643,60088,4057,23741,5967,162904,38240,28356,93858,25510,122879,6897,3278,7057,11971,4400,35461,211413,21395,59615,39471,87233,55795,128426,3051,22470,41950,14705,3974,180108,80476,78442,204996,91987,15634,67610,139015,142373,35611,51134,10387,4353,153456,57749,181039,14183,68447,151532,21107,36452,20551,3186,46247,46383,129666,88736,140662,146243,2066,8360,7978,64818,106963,17896,47801,10723,114821,223295,74192,3293,3393,16987,74064,11277,91622,4270,29828,27951,387869,103235,1374,61988,120083,477,145892,128378,11779,211263,61354,18221,17869,46530,83061,108538,157981,90608,67199,95080,49064,195814,12302,66307,10348,231346,160732,112859,63633,146558,21271,31037,198802,47622,12862,95710,3910,77850,73961,85585,34752,61e3,4082,24595,103679,71107,8208,79568,150019,16615,24961,139857,32664,197366,4559,54735,32696,4126,162019,75698,13916,70108,159638,19834,9349,24675,175560,49643,18206,52459,27992,10809,88865,401975,133172,29e3,34558,30915,3658,25834,42430,36562,125265,18182,10155,40149,97082,208980,19575,60853,90529,66545,9600,789,46420,2317,88593,55595,98980,115302,5742,169155,1073,177901,3472,11189,63711,78643,65472,50459,127979,93,42202,67053,21720,157650,11145,141378,42033,22824,85705,79114,35584,15974,1510,54172,28562,12451,104226,19190,97151,73024,20948,5151,81741,21499,29006,84183,198074,54003,45120,170125,26240,35177,28389,64863,79974,60778,176915,232183,45342,2038,80253,41564,40703,32689,5430,100689,5366,23007,134279,14266,26712,73993,24934,64242,52113,102887,61801,46415,201049,54251,62133,122757,164883,30815,139966,2319,30842,766,13362,10287,134518,86111,81665,82440,28333,43019,18963,8804,161944,23439,102144,101145,80029,39052,248708,30350,117340,11878,128467,974,138625,63961,5237,74778,61834,67040,43814,13690,65947,33809,232476,115258,181745,28824,94013,9510,10246,93722,81976,7217,114383,3493,16014,69045,72692,12145,80981,9507,6692,1620,60820,330444,35474,33962,4797,7053,295463,46445,27026,12491,77988,49524,35675,90947,29114,166705,101385,133782,32704,6186,84595,176031,185623,45966,151302,63069,1699,107491,947,15458,74452,196212,6046,10498,12163,10239,35191,243951,9277,9090,29539,54460,22820,26514,112549,60372,51753,48756,21812,70861,260326,41,44222,10441,16961,48148,138771,216194,5914,52153,53400,212036,56519,26245,10117,45888,15294,138019,90913,26368,43842,42111,23348,6082,194845,161089,156206,51546,11647,30759,302912,262094,8635,78876,26535,35283,54183,31183,85484,147873,12989,5197,6356,72894,65347,20150,27370,73787,1493,45918,12366,190217,20724,13858,10981,67449,81213,7553,14115,72242,271517,11842,48310,88743,143726,22177,3290,243231,58452,62937,12592,1654,40066,33477,13751,9921,128442,15868,7106,75236,83773,10775,36938,10482,170465,17368,17469,161508,32752,98340,800,19824,264456,3901,87319,2867,26782,9630,113102,185815,24197,44584,86366,40224,3636,140916,31731,267731,9567,53678,72984,29389,27963,17106,50282,284911,60170,8322,12608,23374,89652,5268,39044,229766,8869,151350,31436,177342,12269,183212,120418,116270,2843,78888,69192,7865,184099,1086,129897,18383,70508,20242,18508,229924,124569,35749,50589,55626,9884,83115,40971,30671,18135,14452,38861,17844,201826,5549,26413,17189,13561,38539,10679,143331,3314,36785,171194,49685,187713,67506,4618,104039,17060,195080,50648,33159,19238,67559,134840,28599,157523,17130,38064,117398,94355,31918,13575,34538,40326,13997,3494,348283,62481,26862,3603,104426,244363,153709,112487,304612,199674,41239,35545,54869,293005,28223,26277,26899,4533,18518,15492,38587,80488,70485,160395,263,60162,11382,222152,4696,250751,51921,182609,10707,48463,46243,1227,49111,111564,46502,33342,56846,68541,63559,858,139927,16654,229375,76759,26478,33205,95828,23399,92945,2637,35630,28470,143992,50214,14174,21456,166191,65665,1711,21594,78019,97599,111701,36,147151,110246,189022,43021,30397,40757,131935,42065,73335,48039,26596,28984,15102,2361,7421,202167,69744,43766,52826,3642,83304,33873,75140,63169,192389,36551,92748,13039,123959,233220,21738,84447,77230,20228,187852,19095,25799,92136,108774,29237,53947,2299,118106,2687,8830,42331,202924,33667,2023,73763,30704,19363,19779,16737,35629,48081,24068,101013,162338,291912,13749,24745,328289,167679,70086,48299,23306,16732,17801,43322,54589,3586,63653,43624,53474,925,109177,251316,43805,13082,19511,86565,142182,92461,17117,101033,103319,64589,4022,4351,235897,5352,82705,107142,46391,156084,5860,61365,10558,13045,7717,18357,33922,12590,33065,6928,46993,783,46937,67846,8952,26295,6107,119656,18799,17458,50747,4229,179559,112727,118080,20683,41464,125468,51560,49749,44231,7359,35339,62988,136487,67015,5208,29150,24956,105186,48858,6143,18097,6972,16404,73489,58742,97196,36357,164616,5834,32267,13746,147733,15113,132091,34127,106298,39729,106426,22294,9780,15602,36213,71502,42808,66802,599,60755,5851,39120,67363,108623,126368,72770,91263,32486,30596,151717,7951,52002,43103,11768,68942,40901,39344,24037,127500,116890,48403,16926,86750,17745,48648,159545,34460,58419,5634,114317,67865,31462,23352,24010,98185,125708,69686,68337,13610,26271,70691,2980,4768,27225,102402,75453,28106,8104,6931,1176,6274,6475,112635,22498,6176,238686,26832,28893,90319,14441,15682,15087,39517,45270,109134,104440,45965,47645,81772,7876,52683,87720,12898,4505,185665,2769,113401,15664,57592,105229,137381,97059,119268,6876,43309,33886,128363,35476,144249,67013,143587,83367,25703,91436,59347,53236,2289,16519,19844,46309,58558,99834,23313,218816,231303,36388,51333,183535,109792,139277,54306,90139,18235,8275,32710,37677,82464,86025,92204,88842,117723,37570,128723,234242,76350,73795,34896,148247,58424,11105,11744,45746,63372,17118,49772,199520,81902,38004,22911,33752,3125,1995,53792,4689,26909,108150,146062,69674,41811,161444,84855,8999,28561,16731,93937,3189,21967,24890,22943,1356,145300,51569,28802,517,118679,31703,40607,48098,108854,25003,10233,73969,177495,5248,24516,215347,146192,48712,60626,69188,40735,5866,586,101541,6509,47590,52129,5969,222045,110933,25733,24223,65339,62812,2414,155418,35819,16022,78423,43138,20995,128255,240673,46745,236093,72176,57085,97841,61248,107,36068,193177,105427,55726,215229,20446,47228,100420,87091,14429,121708,23605,21157,187721,21880,2997,203976,99166,95068,25877,7724,98925,83401,4829,13182,18229,13718,239662,38653,116505,153497,30589,89029,38962,181302,43853,78872,180301,4786,248240,7401,106136,112590,77745,19731,60880,77789,125748,135487,5975,48627,34084,12419,215770,47557,254582,10364,106495,21856,67539,88981,38805,21428,48732,42316,12149,16078,52808,25327,51322,33850,51147,12253,122354,46077,56483,254553,115417,81834,150991,94662,86668,7381,12841,100650,18218,15741,22372,68294,50705,15535,84660,61887,22553,72299,31361,24824,17743,46820,64288,31582,77006,111674,116384,30760,80920,86149,77192,51979,79691,60342,122805,103800,240873,160744,233114,78962,54920,8608,3484,316104,72548,24337,5088,230040,21926,10172,36838,26,86221,83458,102176,12062,17571,41929,41170,28428,68239,41750,103930,2634,18313,53019,34825,97837,63115,24606,73157,152474,14715,91439,37033,109806,140259,30668,174760,380,135597,95673,136073,65073,134249,13829,17279,122305,4420,46444,10237,64848,203623,70728,10349,182885,65075,24519,25783,40318,34139,22222,63394,55266,102764,41422,20126,65100,90408,53640,35128,48932,11192,38935,96839,34782,39492,19396,41332,6250,5511,19492,51304,25936,104466,54099,73771,86115,5080,7669,30891,111700,13931,25276,72289,135447,14820,258641,25265,31005,281179,75286,393,95359,14623,13584,6680,101227,80173,44933,76666,54542,13244,39348,458,25379,109451,134348,81143,6959,65554,12027,51311,8716,57589,140731,28467,23316,17272,30458,25980,55229,77197,83798,28302,114784,7428,34548,26241,14712,39336,103304,18928,54080,12870,334,87722,15208,16895,142098,114262,39820,83913,57817,28682,7721,14900,108672,11250,62246,42849,415188,1724,26555,24549,25505,26443,107450,145899,61035,43528,6901,60726,65906,267741,21338,147590,42079,18924,73017,135236,15393,5206,4026,84185,1531,5988,113890,82647,303391,7386,69844,71611,189865,76523,31877,13315,19314,198575,32821,1928,67641,25913,104475,103489,3297,70391,18406,15446,113347,19295,93790,27856,1792,167471,116449,8541,4408,41757,63233,25765,86680,64501,27034,24816,34975,6079,4486,49693,36229,16917,21581,62426,27862,11612,54284,35702,194034,355,24277,48262,87411,70504,310164,118018,12516,47559,43502,57433,107139,9290,66533,80863,14634,34312,91725,28606,21342,67241,72355,43244,375789,37402,174015,105070,8342,44167,67494,1890,16365,11723,271002,1865,47918,8350,45564,27742,25110,125803,8553,49504,81925,62211,4534,15491,19011,80373,206920,667,102405,128623,245524,5553,113309,192739,65766,19567,22832,261958,29679,21293,71134,20962,105123,24721,860,21752,33448,18372,157167,94822,35770,173224,232737,75729,28937,46828,28062,25453,5207,140366,36665,30652,6169,67920,150458,92040,23186,184604,92330,20891,176492,49427,27828,38305,42495,143982,49560,25503,90043,29747,65328,47830,12932,11068,77721,9003,25213,94205,140426,46090,89945,138173,192691,33329,112232,129905,35709,27514,1841,19957,31411,127476,53572,17497,173549,55063,175135,19841,69314,5192,237921,117660,150697,4060,273045,50414,98940,65348,153665,164423,58804,156695,48994,213928,86036,28608,8355,39574,34540,16927,135680,18374,151587,10830,53805,16878,16623,4282,48030,8537,14986,46102,13062,72897,72,33050,108227,39451,45935,651,113320,40535,95176,57450,48843,5003,19019,10407,211163,3848,1068,4988,32091,30095,41692,15099,43602,107434,50744,7627,171349,16313,150832,352665,207750,33937,38256,51091,156e3,87889,90663,84175,24908,114900,50365,31494,83829,5398,169342,47521,54818,18935,8356,43094,41212,174536,10082,92550,6678,60614,23355,69721,14796,34149,128830,58187,3179,208,40325,28399,225029,401412,51150,31580,207268,6657,10993,69818,64282,289845,23308,12961,38447,6681,52944,31855,2572,47646,120728,179148,37240,45196,218274,4816,3695,21961,50084,35209,18073,51452,27004,6100,33941,1377,84831,171214,85,141510,9078,99227,32610,6417,11718,49868,65579,87902,73018,49062,46280,61742,21512,40862,107733,15941,29168,157765,144919,14487,5767,158014,140070,7241,573,71584,16921,223566,40331,179473,35081,47926,140885,41508,52104,59180,42310,32811,29048,123517,102413,80208,10104,14746,12649,153641,126022,37965,113017,4171,83,142592,2809,6362,50416,71323,116894,260776,16204,1524,5760,30351,12658,20703,54403,36083,45408,74772,4946,14485,50759,111222,10890,2195,167147,92962,130534,16283,177256,35016,15472,210156,151187,73922,117691,43250,52051,37392,24811,24358,30830,5775,818,21969,1476,127322,151783,58392,31021,106913,65215,89407,90802,28531,11690,20234,95249,44602,37256,18707,11928,5161,4410,26571,51903,49768,22008,25252,65780,209499,68769,203726,13249,137363,48845,86823,6658,5674,31881,1083,1823,108676,34518,166752,13791,14287,91576,91429,8665,11529,26401,16191,91972,30964,5254,28486,54697,79613,66520,18447,22870,45203,194466,22822,51703,12278,76716,44595,73455,33546,12235,144843,36154,51247,11116,33040,3180,225753,60864,1972,28469,12891,28879,10338,144157,56294,353058,38302,41447,87532,110616,27065,168438,6557,1213,50804,144643,24817,2390,136531,38174,247513,16190,4059,122791,131994,137430,39506,57650,16305,5188,54309,106128,20628,88071,67394,395446,250285,66176,91254,1399,114196,43915,60230,44853,27206,106353,43013,18733,345105,226453,51202,16607,57106,117175,35492,10476,89598,127439,15187,39624,13688,61570,10615,31111,59370,6238,175252,32143,224492,41388,95408,34384,148238,78307,38959,9340,160091,61443,15737,11216,41244,170,38299,102443,113097,26382,14027,33707,3957,76300,66160,19431,18900,6952,1717,108656,82206,188021,257335,27295,43999,41210,31777,46956,57457,12657,11489,15697,48060,204748,53583,82422,284790,30503,137341,8120,19615,220311,15991,10217,63424,9808,67431,70976,98221,4491,15177,28535,144789,751,13230,2394,1504,33977,132104,30316,22230,931,97193,185240,24826,22687,174322,15307,22988,1390,188745,180325,29580,59068,74903,18994,29195,79,15436,7622,38462,11566,138710,44828,45774,37768,99236,68137,84083,19282,22698,17134,74807,126662,173497,46248,16938,119735,3212,28292,213652,49013,9975,32180,45660,86250,4801,68788,95490,77482,113751,11994,44624,94452,46839,128497,100316,5798,58588,73184,202987,65417,37790,88524,1606,43156,97964,105717,34947,11203,100060,37742,130074,93653,107799,94311,196106,41347,8035,10780,16390,27883,118236,167395,1979,25006,19375,31628,18916,144723,78502,114047,103107,86492,107686,5844,20934,206963,23556,22591,16562,146333,20167,10471,117434,33085,2863,9740,36669,41849,37271,22790,18209,28979,8231,12952,54408,21731,25130,45208,55748,138120,75826,414,29593,9925,292865,25999,683,123149,7036,92159,86055,61827,103680,23176,54918,58466,57578,13305,5709,86479,16697,31064,17660,200919,10770,49793,33423,32370,52047,16488,62555,6459,8426,83493,7763,59725,82812,18628,67760,79405,68557,9612,7673,28102,56517,69620,171797,32458,29541,15870,81109,32080,207644,71495,21202,11039,91036,61230,2810,130800,32260,4613,60590,37112,75214,33979,126402,155062,30642,63875,12810,194463,82799,47664,16725,36685,43367,61099,449,172150,102867,21691,301838,36745,7130,18671,57316,34852,38034,54182,35578,65900,99486,19771,3456,2658,16914,99866,28390,28109,8262,21147,34353,20006,4228,137085,1675,203023,283196,198286,214375,163329,290603,152574,40471,83506,30068,14730,23177,131539,34759,27668,32178,71896,104799,116305,85430,119262,42860,25160,8911,23428,49437,105322,6519,16203,6349,74711,1230,38045,8540,75165,44736,25909,51026,317034,4984,32281,91312,27060,44431,17817,45363,155937,239085,35697,59784,91993,29531,126740,213757,76560,167776,285273,24262,8237,65030,41160,74437,48804,118916,13159,37842,1031,75349,1478,11655,108777,23435,277425,101734,67469,70231,124711,43532,28514,65526,54956,1e3,21882,17728,25302,40952,52214,149632,1999,2111,3259,63362,89961,220561,39777,26335,9063,10572,12416,34551,34623,38604,24723,5947,15588,69927,66252,119177,69173,46629,28714,70715,212408,20521,406913,74380,11716,50659,50862,37009,88460,130101,7210,53853,538,65120,151950,55806,163748,52837,13153,21100,16674,64536,6091,138201,44837,58547,3723,163,2177,32288,85454,34033,8497,14282,25742,10535,10741,79559,117493,243787,49337,100718,79495,40139,42956,7551,55433,15421,31509,23034,45081,547,61176,53434,328001,8470,36263,30145,4519,74173,53935,11845,73774,60211,78025,3,4102,73782,109293,315332,48412,26683,13714,6865,20128,18490,104141,325,39470,171970,115860,15707,7268,73301,74336,31370,2368,111827,107757,136231,142844,97138,96638,84053,38691,23801,1588,10573,122098,77039,240,186135,146101,11996,18143,112963,46171,155836,348769,47795,121213,116266,132515,3344,144804,31286,99187,255838,129694,35894,48779,55235,148582,71967,65282,15174,13920,47080,6147,108242,157593,125025,7136,1286,28957,127956,28402,98813,20805,7532,109417,40610,5041,32958,15142,18408,108596,33543,50517,27748,80114,233434,91447,487,37094,100048,30541,43477,10639,89862,155868,37667,8726,60684,237903,73408,99589,12190,38739,97348,3914,13594,2680,149016,13907,30171,28343,23530,115225,61104,35821,147679,14337,4297,244282,24085,326976,56428,7851,21303,131620,71446,83253,68692,111870,5224,15813,38197,49026,45057,13660,3306,76345,40671,27905,91072,996,68527,62085,91351,122634,55109,168209,2024,27560,112707,17352,8306,167115,169921,166958,5031,46020,11844,67284,19130,76185,6920,32849,5450,14610,22451,21002,17392,31872,66682,84796,13709,40210,59898,12029,8719,53564,21462,91884,21647,88379,194428,12754,37797,132826,160016,22567,54383,53186,77611,31107,8339,4694,19185,90355,23597,17222,140675,28442,23668,55977,9128,61555,28774,155229,17658,9390,24379,69357,15752,127381,239631,62460,93181,55913,45133,140155,18676,25249,33164,29581,82837,67223,22362,29975,7317,52813,1943,29613,20012,207130,49617,49651,5636,15334,36313,29226,28084,95247,72072,19e3,224932,15811,114,32127,38097,37508,88507,37225,27359,91626,12193,69279,20608,11055,88156,92808,2152,57259,55275,72789,24475,104414,1708,9882,3818,48661,66897,1631,34806,227930,85815,87753,18321,250664,72733,25107,206797,50891,8082,196411,92596,96764,152823,65514,22819,387277,62176,51225,40329,15563,189,3659,73670,64357,51793,275136,33482,86653,74615,67058,11318,125720,15388,22388,8267,1730,102663,170910,40784,7144,85373,13040,7088,94309,583,44224,140424,77439,18496,164026,36578,4722,9151,5824,63365,26510,35199,40500,79277,32495,44614,35233,9566,203293,152144,7097,2330,183480,98629,13423,330887,44130,68600,30939,97829,31012,345465,56747,94879,4939,160027,149761,99423,46099,32251,15332,8761,96094,128555,5763,235318,222223,55729,30241,55420,201746,3987,81382,8259,49325,23287,7719,24633,251100,92311,18591,110533,64759,170260,393860,7175,21144,132887,3593,75346,101277,91109,16387,259187,11627,57459,173829,44694,55780,49797,89192,120443,62622,3904,14814,23887,1027,112258,64955,99800,11132,66353,36202,48624,18158,88481,96882,43059,11040,2455,7077,21651,181159,99126,100434,61388,68186,19161,110468,120052,8819,55324,41494,7014,37689,3618,87729,92615,207943,9823,128657,12587,15857,6379,67628,51216,71775,157617,63244,1503,3864,218754,110864,5769,21492,7243,1192,87921,85529,31512,18537,42698,35350,73510,84474,34301,8991,21013,35034,566,38832,19838,35586,37216,39413,55006,12178,59742,856,84563,6900,25632,17437,49786,30723,13847,70845,4044,7843,23944,235976,55530,48942,6518,20939,73769,192653,52936,95207,23895,132542,142982,22632,87452,48042,54018,178468,10728,26230,23559,363,81269,142012,5718,346258,31456,84333,246476,51018,66692,101804,120570,39962,30373,70593,2864,60541,19425,54209,104092,7201,31545,48018,25865,15442,46257,40443,8328,6451,111782,47527,97754,33046,470,245116,31095,39,91934,87208,73470,36708,36521,12801,70624,36272,8892,79768,12427,55454,103756,5908,52390,62962,22720,141138,94634,41689,128402,126390,6628,106394,35527,134394,82727,254651,194502,148064,89549,3202,28359,957,21954,27906,49840,142747,8307,24206,48978,1186,71728,133038,71474,91306,6333,110959,74600,70387,18983,62609,56057,22970,1147,135850,1321,28834,3578,59715,102227,32827,81415,99952,55636,257598,390,22702,35701,85872,402916,39216,189795,14929,19467,10112,144422,61514,5279,63421,134686,41436,8424,51925,10598,132295,124416,4604,194739,210929,57866,31829,51626,50007,9976,91878,61906,56168,81906,60918,61859,40017,23059,16887,40927,62064,12785,32893,32913,21782,93965,20169,44387,79084,38463,11457,93950,27127,157050,2697,337088,5116,54128,48255,33279,8821,27352,25515,124022,65710,28906,38557,33390,1722,104435,72215,38551,12094,30978,25113,6671,37355,175109,42862,98024,65406,221276,59624,118012,64637,78760,86697,21426,1639,40350,12584,67193,84144,31396,7863,143011,69629,63112,9454,28666,65798,46372,134721,6314,51402,30837,151922,2847,38676,38008,92823,136245,17540,5504,109295,205242,37606,5211,214892,1586,20670,208711,137743,19328,40652,16995,20023,14657,154919,34422,12996,13918,38221,47690,16398,2959,37680,89122,6721,198469,91876,172043,83898,101992,26084,94570,3635,76958,22853,76497,38266,176590,168403,44464,142840,79180,184594,1984,41806,83147,11985,6546,366068,59732,24533,271505,8736,39084,222992,93429,28962,58985,86665,8432,30028,14548,32439,54424,165029,55175,27458,69046,121277,46168,33732,20661,24581,135574,123110,37556,79260,72611,16957,12939,46162,58238,44907,72936,253758,41324,32518,96480,11949,124438,65280,43256,34107,53533,43531,37037,28366,45970,32741,173438,6121,194202,62969,26355,30314,58370,28455,1848,50519,82830,90393,21761,295490,10936,256940,133568,44050,20269,4089,27457,21610,219460,36743,14821,101388,52005,13124,30979,140816,167362,26054,18458,60789,34917,40447,26606,33422,9066,3452,83614,5761,20263,137238,25038,91310,101,52322,74548,42572,38084,214054,186568,31802,17665,30620,141936,37730,14420,4265,187218,49640,188208,51441,55388,96452,66659,40869,42039,60967,221027,19234,178581,29105,96050,9165,196118,157335,3738,40354,117436,2965,34136,59659,15570,50843,230035,31444,71260,43886,18316,5387,38500,168508,17406,32174,8828,103373,143806,90367,3560,18719,122310,16508,26719,2541,105429,6645,37998,73190,10591,235916,49737,87112,233941,53188,32193,79154,4544,52905,126477,7580,63501,57314,3216,31337,6541,103083,60846,49,9756,15481,1355,43840,14319,13743,27486,10222,73114,230718,418644,16706,6674,279748,23058,45273,295831,86306,2743,5535,88773,21829,35253,120938,31153,3169,16839,42847,8751,80974,33942,36867,35514,16485,26474,77775,56877,5391,48346,3882,108713,31403,27804,55248,26235,43821,136104,40118,175507,28034,203908,18732,1788,34030,106427,36958,54359,7251,44936,15356,69139,455,157915,22173,140291,50348,43275,82066,49621,54952,15216,36226,96695,66855,6936,1987,8227,196087,4631,68827,99004,47541,110265,17953,147605,110242,58520,31312,38724,329975,642,3155,34497,75937,6207,73843,6120,17249,51429,117746,3218,910,68961,319671,14938,29555,34700,1649,66673,72268,9655,76800,153087,6941,210168,27130,35398,1780,73242,3135,56689,19556,165307,8765,35967,121458,13333,70453,17350,117253,22265,13340,44265,39869,441,3742,135025,23581,33309,16543,17731,13291,157637,283005,21408,101360,63887,52312,83873,5338,233779,23759,186949,34531,177320,38069,156465,91004,19353,59852,68160,14891,1338,1072,29823,1950,28901,81407,313445,73038,84807,162348,240257,37162,138934,16111,58013,41253,102951,16457,96056,19541,56402,67217,41638,94381,89674,29481,37456,80815,151579,13937,13683,132537,19699,134545,67020,29816,222341,141235,427578,48868,129557,233342,23077,87871,16213,18728,16184,9469,37913,19680,2798,171356,178328,13216,50049,72690,71904,124644,55455,7504,29052,41036,266546,19899,30391,188755,8659,59469,16,104298,112943,53865,76203,138226,68857,139953,14125,107625,119795,173133,4398,50273,48808,54390,16466,122086,31835,67035,50971,48859,7508,46427,66477,73021,84615,39985,83076,46779,201569,53336,36443,60865,168164,143810,51393,25548,169307,32896,24485,38424,21837,29087,275813,51674,6714,64883,46169,187369,55186,76192,12852,12018,62134,31067,118303,16542,12125,10579,4928,26291,43854,7091,10946,253716,109062,39283,17261,113012,258512,47764,125126,32646,55892,80279,201623,149872,3192,385,1208,48750,5376,58738,22335,5427,82416,47811,32435,143086,38930,94128,59975,156037,37977,38224,62485,7698,50405,71027,16462,21559,136153,34131,107506,162069,63703,3101,215029,40407,4178,3774,9187,80019,17880,97926,67579,2600,18405,8351,47924,86638,70820,92206,86453,29610,42241,119200,3198,15466,67813,57863,35454,4779,99518,4649,104641,144269,33730,38073,65864,6838,109456,193298,154007,5623,45741,30846,182578,25573,157224,1543,58575,138703,146140,44971,49356,18275,59064,20300,13122,11848,24453,11973,9797,86843,2919,25530,49210,1130,161220,76788,75373,85604,34926,36014,17777,17255,51533,11676,92226,51845,119859,21525,5936,18507,28050,1140,31418,14857,34207,47859,10750,36382,32079,106909,59426,87757,38393,110042,15965,97104,33757,35344,97993,53979,33651,45407,41884,82515,173089,7177,58371,35365,47543,51927,35587,10670,23544,29306,84233,39976,76076,62097,9007,8668,28119,78281,120790,19835,143020,54968,18670,64959,20649,34469,42570,33001,136570,87796,120044,1106,58700,63951,127623,12805,83057,40212,31773,49850,7361,54336,347524,101314,23751,19569,48791,29174,49369,20467,7465,75842,38281,623,112457,60210,28849,51003,94720,6426,90047,85560,43761,3579,85105,34607,90410,118528,7224,42907,111163,18168,6960,161135,191298,5247,100584,127552,171568,20121,91173,12636,54615,20199,63730,98105,2396,40387,14438,125012,4765,33235,12865,45299,37728,82098,77872,114037,59253,19675,24838,398016,102561,11446,17069,57508,178277,65836,99941,26114,2585,271882,136866,50126,11027,155648,118367,14585,8910,123015,335383,40434,41016,53021,14439,87098,176860,201543,121888,2358,9286,5739,22666,54270,37884,169381,33984,93859,16124,89364,72207,51639,76366,99029,65812,2198,12147,174891,194289,6986,30252,88822,21284,11445,288337,160821,33034,100869,43852,25761,52882,1144,103809,1924,84458,86079,43411,13542,139276,18141,34978,41298,7276,26481,173800,33210,17951,142652,33616,33677,2210,19941,98568,2486,192414,80136,12058,235883,50963,249638,29572,27221,47034,6124,72107,63346,97620,158513,299699,40388,23235,37176,224244,198386,121323,67992,23827,63170,17838,106622,158590,26807,5345,23489,91891,55474,74834,37981,13058,5977,72552,34706,26828,145172,19904,21367,34043,960,77092,91381,4733,47446,7680,41697,5170,16960,14741,46101,13656,473,51842,37433,11103,11551,121951,13191,97536,165932,50397,51628,129028,9069,44885,6590,59195,47045,32940,225472,90345,21833,13303,29407,96615,141951,5198,6028,18395,7181,3861,14966,156358,167182,36529,55253,25942,173153,30959,27261,50691,150176,162201,38467,48462,80602,42163,118482,168,108756,26011,17166,54149,456538,22512,91374,13816,90358,131615,18132,226707,1824,28139,26860,42253,93877,77351,65575,8980,80574,22020,27948,40422,91324,76376,13528,39281,91685,82215,122541,144066,1983,193851,17283,26320,2739,194978,4790,26845,42627,61300,65815,174612,55133,4200,191130,79771,158321,52280,166796,221620,62461,11278,4067,88152,83409,31717,121367,13522,47325,37945,10406,174348,249321,154101,64912,29938,51775,17220,15776,166138,78890,84425,54121,42861,16368,24572,291647,10197,32073,22651,11677,97509,26952,35787,18424,41910,71614,94977,72318,41594,70024,275419,37702,60199,7335,39107,61315,18271,18394,33768,87884,104277,123724,7277,56288,71981,189803,49320,3352,6798,14240,8954,69220,94433,57372,28620,68863,193727,85575,42309,41667,67689,42081,22543,44824,12719,28540,114236,101553,27638,27296,4300,5353,4663,19379,94098,3758,95888,95144,80344,87320,28447,259518,12718,71391,152731,37063,24132,31911,104896,15672,103782,1521,4945,72541,23717,122632,15619,87175,206120,29428,189780,61416,28350,44457,972,1175,47233,198738,95789,41907,21953,97034,59341,22864,53713,16873,32971,20693,20954,31336,21477,16169,38370,16412,9019,3841,24599,21938,17085,6484,81198,76413,5849,72514,12320,65247,276175,37234,59796,52642,16312,57349,198507,94148,46134,18958,125552,1747,18725,151873,14901,5490,68287,29470,3689,64794,40814,26018,25692,54450,2703,88278,124886,173087,174e3,24159,179477,24276,46004,201876,209202,445,52876,31948,30206,157610,39180,18439,44124,50469,5774,96278,222758,200216,50290,45486,20435,46986,46276,140133,142326,15569,13363,47522,92583,2182,7135,16853,22998,30272,4952,63263,35623,39096,53789,44864,20053,110392,124213,4630,16087,28221,127787,25839,77481,44693,13464,113146,6983,27069,55717,50102,4760,7107,26186,66507,59145,36032,104182,71328,29425,64317,50781,47465,94298,69706,74899,22754,120756,25108,93077,56834,73286,39928,16218,41699,176763,7555,70819,50083,26895,23315,26014,16773,123079,41712,5719,31516,90427,158540,85051,183128,40864,27505,55392,9058,45224,96857,30901,136622,96557,56304,120061,11501,151448,5773,89743,7769,86069,2935,18471,41628,10114,33660,110170,49479,26745,92846,33221,26731,18795,87076,8550,2100,29972,120289,3077,72490,33784,2630,208722,50861,63483,79029,6419,39467,14302,45286,64207,9686,67513,44170,1050,77246,59266,17055,53801,7150,11111,42432,4278,94579,362117,36175,42902,41933,39002,98489,22913,74161,84773,57036,17556,162288,74485,178760,93867,73635,128860,50362,261,67455,80001,46080,35662,4368,25247,19230,74393,22588,1822,27682,235324,13798,85998,13194,235067,23514,71669,147632,23191,134748,214683,105101,1518,25489,247114,7380,54842,26922,3971,26361,20844,68642,170517,77339,123255,8963,77818,150998,48466,36806,2732,23261,11741,236162,18243,126216,28690,50546,16385,92760,197383,246558,201295,88255,67588,71687,176076,172653,169058,33906,63747,24835,157621,43338,30050,46152,132741,2770,51371,94835,6614,15112,11749,56936,1250,19027,399017,58036,100215,23388,55815,308768,124152,94803,9521,64186,8971,28,30427,62163,7616,103838,35079,29203,131235,7743,17389,10882,37420,61460,228512,85363,41581,131077,62822,119647,10130,54445,26925,19968,29016,24446,74028,24176,61448,67185,9254,8563,119129,9771,99184,37716,39514,10532,221512,258753,218630,55980,23394,32141,61924,66749,32411,3741,36475,26678,77010,44946,91203,128749,116953,20476,49625,53116,13735,102335,29376,51946,83407,67892,59212,34685,21083,1546,112982,32972,74397,1078,190545,16082,86140,58591,89611,101531,10061,105104,76319,20035,17551,52611,169061,190842,100780,23907,90413,115619,9675,34710,193435,49443,129734,11183,258877,16318,136182,126808,44635,27304,192375,2599,125648,47051,12091,23814,721,58800,40137,66726,97930,60877,74487,7942,54326,9841,41428,13762,8211,85383,6950,99177,79806,201786,296464,124087,13144,29741,41721,47634,55088,254286,106408,17041,99064,12942,64086,45233,14005,2612,55827,255,7984,13980,38574,12776,46654,73499,249951,2101,26676,25996,132326,116415,119062,50449,31033,23038,11589,179252,20007,14860,129270,21143,17796,144715,60106,70758,69842,34674,282133,44014,16774,57268,38528,24053,46373,201667,28327,471023,51889,102667,21193,114909,84132,69317,96723,67969,16134,68145,15058,28765,32035,2524,101089,98664,25045,76571,14957,86040,118506,262428,154764,81573,39681,283900,73287,127825,544,80448,52347,38512,175971,15180,45467,33086,46552,48894,81107,43213,36672,54025,76703,8053,7608,13299,56619,20752,238099,54164,105133,1444,32942,953,37564,8e3,66316,119463,106817,404,13667,149108,128597,31267,10269,49836,106150,1484,52330,76965,160486,171648,38456,31263,22424,37738,66245,67467,143369,60471,75610,20895,115528,86070,60854,40796,49347,18989,15030,11371,37578,15779,79867,10187,86462,46402,155626,93200,40229,7090,57547,108053,99598,11088,47505,41218,206017,2173,20988,30219,22919,80563,57566,42369,93141,41675,2407,182519,120495,27154,16702,29456,14349,7958,16688,117177,140375,42467,261919,74916,153569,10836,34742,49526,7621,105997,12212,2270,392377,7755,17959,25086,232152,138791,33847,13860,35316,5811,1344,71259,50452,207539,92635,50359,5821,33674,30255,2086,2587,96264,17543,42,6029,9580,43007,139248,82831,12917,29607,25786,51467,42137,85161,100698,31561,88989,121990,278500,3602,109344,37982,15279,116442,28936,30880,87894,58079,128661,126731,67392,28051,146885,4861,16216,97344,42827,147561,153948,22684,21335,47685,1853,43349,15185,59642,10229,25520,187921,108972,5579,98037,24945,6697,19193,63734,137934,75056,89740,19767,224268,56138,63643,151661,39313,70618,84031,89723,84074,13703,85626,35460,8867,64845,3439,57906,99776,63968,49270,81130,34356,16210,23547,36446,34090,140028,72439,2221,22163,57058,363492,113754,18913,95451,48663,54464,54037,176097,68425,3023,34906,29482,117389,341780,80431,58330,16753,92616,60907,94846,147486,4498,48646,7773,46801,7778,18946,464978,47558,33223,177444,7328,15626,63337,94700,11743,9351,255024,39098,16447,42647,96230,39769,58840,10068,63439,35800,65843,58823,413844,9156,51258,7434,61791,85018,6872,3692,28096,7121,33024,6009,75532,31997,192535,9661,3304,9547,14753,31987,25314,55689,15896,20430,39472,31340,99744,25398,115569,54883,28719,205423,23071,57855,64638,149867,25671,82403,37616,20668,39989,77996,74948,140555,175248,64810,36515,46595,4958,248773,24045,28728,136673,168704,20804,114833,100325,27135,21205,96151,153134,45992,7093,13992,76047,1980,19432,145001,75159,87462,17710,1013,45556,34297,144882,20648,26061,11319,129567,108555,18872,464580,33386,22717,65948,167189,5603,135042,79542,8801,202632,18114,91882,5973,5239,67315,4431,60916,47819,71693,32597,32606,18183,45072,80329,76385,24749,51305,40314,156514,14693,130345,13168,66214,18029,12858,34801,27628,14544,10823,40522,40185,33739,148694,23548,9923,61012,28859,17933,19442,34364,99849,164107,141167,30629,21054,6744,36491,8096,42474,41706,155060,30650,10600,163442,1143,96655,61390,52359,7559,51568,64256,203854,4467,22453,14504,436398,7878,6980,8293,63610,293747,16167,35763,19627,147603,15419,18032,110744,51346,33681,54571,40472,48615,39073,21604,13754,173027,92560,11083,47299,63062,11813,52007,29883,9734,139722,15953,1550,20651,13616,49306,16113,90089,92326,7584,30712,72424,164858,6831,152871,55746,197721,34167,196442,6022,112107,55215,7538,123381,4920,43539,77165,8939,50392,34192,20225,79762,22505,58667,40770,29788,97180,82835,4568,8579,13273,363569,35898,49983,436,36598,3237,131691,62418,35591,8101,4073,379438,65218,76072,33887,2968,27573,212619,288680,68278,72851,150504,217896,6913,121339,22017,35340,51072,43616,75043,31437,10833,81487,4364,22968,41454,106687,85446,19863,109625,149241,524,141850,214404,54376,657,237023,9401,108137,53800,32474,49712,53334,126876,27337,45552,177696,8269,15036,12097,42240,2328,125374,119295,99715,2500,19624,39441,27220,102691,60957,94543,39101,18566,67362,13975,78230,25017,34017,239007,90027,39351,41681,35354,43822,1043,916,58587,141983,94818,38799,75459,41114,67432,16195,36606,59568,22272,126769,31424,68659,12287,134302,257977,5756,207285,95637,47248,117689,19583,77451,22373,12200,54993,117118,34244,29386,34562,53819,71267,64172,77665,49368,7716,59301,25749,45426,194789,17297,2650,1766,32501,45198,20403,20984,6600,14171,94604,19037,5402,29896,9938,59935,109708,88081,145182,44844,39167,352626,164173,35374,45982,6122,154,73419,220487,53834,53601,17992,8609,229321,5610,68098,66815,71012,95069,140968,27396,8957,134489,24656,86659,56598,134852,17316,123838,255436,6613,41610,138033,81452,32023,32396,123687,63398,8693,29712,30407,19296,121188,3551,36099,20032,111948,56624,16547,27453,35916,15378,52039,56849,13489,22214,73177,53097,277349,2157,14029,187886,10260,141743,246460,91880,50869,3788,49486,133566,54950,33120,129337,53768,18333,9525,26902,312251,10297,9020,70759,16647,112432,59260,84609,9818,82766,73569,468,46001,75780,55028,52106,11498,43645,108069,17150,17753,29417,16705,31799,9606,289,122254,115975,8620,6133,255357,56908,14456,133464,43554,79224,11247,29630,160,12756,25464,65960,350428,62521,321796,100359,67358,35169,46172,113128,48988,88868,31094,33266,6847,60887,98188,49659,69117,92977,220228,13947,80181,35103,62170,97351,13475,2440,199768,19498,36597,46971,25234,67806,62881,84717,73648,181966,10488,94149,21550,26655,63436,48375,14405,165650,9621,24439,28043,42735,4490,29963,56674,45373,1934,262446,50855,67098,26898,5261,52696,40644,33900,9440,180286,87162,22940,19704,26936,69769,10254,101759,27406,12243,48e3,73926,113215,54935,5726,192787,4312,106216,9366,11550,52949,23457,212271,277152,133895,108374,6191,96477,29980,218916,58024,54696,40853,91124,65894,91170,65908,252552,6793,29212,15389,44516,122515,52617,35058,9017,103536,39510,49136,19242,130652,662077,74699,47024,31422,8517,73351,24399,13867,128360,4810,4434,61779,111983,61036,17798,110240,59722,102960,39688,10001,23803,23039,176498,56659,44814,134295,17188,77577,74466,226175,102472,154333,63900,111747,18062,41171,79669,32773,408933,42562,28931,30907,107388,43487,2946,240310,23938,24354,319,184983,7927,6488,1422,10790,68809,68209,64775,4361,202,17123,59634,51200,44391,18188,17843,2619,74278,3230,9540,47187,21702,36274,56894,43907,16310,34790,16866,6150,5561,13587,107545,108873,126867,86986,28640,33427,19017,5762,80637,17430,46903,2047,131055,25958,13558,5444,47152,13900,44563,122857,45348,70863,39593,54332,38068,33637,318,40310,143467,18502,24520,11377,62013,28942,27246,28269,83545,17999,59015,90707,30065,15161,34720,1263,37008,2012,6060,98575,92933,5721,299,199555,24578,29223,2985,743,115825,109523,136657,47454,26378,53586,3733,174945,93340,244456,5693,37386,28782,89767,27545,23573,18798,136425,34320,84778,20041,48453,38215,7477,71958,40621,8773,5874,187927,105965,51100,43533,18083,8443,10180,43597,2003,183999,69689,12216,129696,146188,62389,34044,68410,12765,43273,26949,266807,3345,34477,79197,5688,47539,213110,21634,22257,50092,32222,42346,39530,63668,98,134978,74022,5152,59088,174145,37220,9934,9545,118937,5724,87240,19875,15784,40143,23263,87513,181654,285152,37881,263241,4966,43934,10433,186657,6470,74416,225854,25908,142677,246262,32280,6192,75890,45546,143264,135305,29742,47013,77787,11732,126658,8763,37950,21806,57557,113464,89465,108995,164574,23894,22996,23169,15369,23117,17642,130607,40503,36239,280990,44666,9981,40427,147487,26869,168452,32886,32991,46798,240839,15111,70502,65697,88548,44145,28701,48767,31139,206777,35659,181164,166262,14554,171445,31786,66523,76607,17956,6507,31279,90476,116611,167918,6560,1243,115324,80128,41867,55897,187323,37069,32596,189444,145931,13390,105530,65709,26805,6999,55714,41300,22915,68951,22138,21120,22264,10058,19945,33635,56123,99085,10032,5818,6016,46649,57476,35264,94413,112522,262288,93686,83038,14341,23204,28807,66084,77987,6101,126673,7133,38126,5923,122091,170240,97772,46874,215746,43948,41622,3272,55596,8332,146411,251315,13533,8561,81521,115449,48616,175175,2063,186556,3036,134537,75772,29728,82360,22973,186559,86348,89100,38388,82297,45610,2613,87082,9986,177812,57884,23591,47485,42543,33582,44713,74439,257444,252451,31825,35631,38540,33066,5147,13973,4343,51830,70378,22827,26448,95560,36896,241741,48067,203953,298860,61620,20450,3220,67272,6586,107662,100160,108684,6929,57226,4762,7457,1320,40404,77204,99309,62750,208653,59977,44e3,74315,34332,5819,172217,64904,114077,18147,84012,1791,98456,90930,21446,116669,103938,7422,85140,59713,5768,326211,16239,75411,13229,29398,10758,236107,1539,112472,95979,152154,151294,306,21196,38146,10700,6891,84282,109646,56492,40539,6589,119491,51354,30685,140209,136906,29622,73617,49553,70525,51671,166869,139616,74395,37439,49595,45678,11959,33211,86560,52434,9282,62690,112155,130810,5243,108261,99970,265613,72551,80049,6391,33365,90721,66737,69872,87011,1860,9032,112544,60905,37371,89015,140351,19076,850,373531,2802,36725,218795,72062,28990,16550,24614,7815,6187,26336,33373,32162,42791,73555,32062,23386,10244,56392,49442,27076,136262,12412,14883,1134,33675,97153,199281,15608,100152,74072,47942,254301,36451,16026,10687,65067,56708,254030,30290,50490,13864,57941,259331,35588,23485,43486,24869,21620,92971,22072,88645,1048,182050,13343,32452,14825,19509,3325,216938,45740,99716,189082,53740,78245,25609,24311,176777,47340,308354,40669,66085,14102,125339,9225,128709,97207,1271,200933,78439,113451,88975,18324,46521,11819,18570,141756,72512,170020,52754,63550,118515,103073,93330,32736,50499,14722,31600,68452,398867,29316,172786,18417,104924,2606,5670,84818,16288,67106,59580,82929,607401,291,85829,359,15897,35830,50696,65630,52672,22115,356968,29895,40837,231192,34024,38957,26722,406,23335,124952,72068,68804,13268,147101,164740,276569,162596,66943,11569,26654,66358,4777,23229,102127,5848,978,2921,59666,5371,28212,90108,42938,39320,2499,4271,108792,33510,125072,71653,65239,38250,66357,38577,13964,86251,35708,50755,36010,29448,12209,3844,38222,206337,100876,67827,137088,14167,252225,84163,195270,1306,5703,54198,779,46802,22028,51124,86759,70560,113164,35685,162145,45471,34561,422,2611,6464,47486,19223,38246,9191,18331,89942,243642,212364,15893,17518,22617,6409,30046,126182,59716,36560,104428,18846,26592,19458,50793,147333,30826,1388,27647,10922,14495,33545,19269,135828,39727,41601,46931,233379,49169,131130,182112,16276,82381,118209,142445,128310,19672,28740,82907,33436,3118,102206,28723,24819,41937,38854,5157,3881,111491,1142,9776,421673,152241,29309,14961,87854,6054,15424,3796,82656,54996,2108,55367,239450,154525,9643,118103,106041,64601,68549,48707,30266,25772,18740,9462,229669,91798,112152,191327,14493,72828,8175,66636,236474,25817,87351,129027,76653,20422,22983,71240,27846,44661,12399,46158,77704,53101,35032,11072,17300,109294,33638,24408,1895,11241,760,17584,82479,125877,63150,141075,34259,23274,81698,15732,43577,48340,91584,14688,16379,24481,150280,96420,262050,48635,43727,61819,56268,72003,88178,17281,79912,13218,122519,125295,166396,11811,2171,118930,67746,17636,178278,174656,95661,173039,83845,79689,17473,98555,127696,203415,54730,22925,232239,9309,12136,175026,20740,180188,10747,39816,314017,266131,10040,175732,112550,220651,31974,37393,888,23008,86799,4303,64905,148467,75337,251,3284,370102,50264,9835,5438,23655,4481,29851,329,12855,7162,64931,78141,12804,42372,296771,83547,18624,34874,86271,3360,48665,77735,88767,11463,63527,28889,22258,29140,194315,113924,25499,6406,31334,1845,4802,49184,43455,35469,127594,92970,61038,115005,38840,87761,106838,8811,20572,55637,11162,96721,132425,108925,2948,125457,36356,3502,75270,27622,127192,2561,123095,49394,61155,16897,110064,9699,89448,53356,19628,220310,21622,83036,9885,112214,6087,26713,17901,161912,91492,3440,68594,9266,92238,8087,6866,150194,72175,80701,13459,31836,43243,239700,95846,44749,50647,21945,230538,120612,132371,244604,5193,105637,34661,41341,68775,85393,1874,8771,33718,49672,77403,595452,99507,6490,58895,128742,7704,39239,73217,43816,62824,37804,199976,22361,80005,87514,94832,14089,4574,139975,59142,75523,100268,43906,53442,15152,2547,186002,17011,19513,204282,3343,60568,128318,119250,4298,51871,41336,71759,21921,45074,98169,145889,99427,11350,1237,5520,28799,7803,53702,21026,136352,38293,128690,12158,90132,44600,10184,26957,39459,126025,78904,82999,59373,39301,150198,120529,153042,20177,50089,14764,271571,30530,123161,38975,101562,22941,5648,124654,109243,69817,71675,49162,106884,21241,107795,30258,16572,188262,141456,7688,60718,8271,11044,32440,104608,103419,236109,93156,43293,128929,42107,67180,25201,115254,185488,130954,72813,167547,20537,39969,38432,22582,184022,1139,27199,5655,17767,97412,122606,209377,27070,35871,326617,188954,42680,73512,80911,22629,3011,95021,315242,157737,383,41821,41808,19335,27950,15674,25677,110950,35375,76835,59108,57370,35262,16569,160415,37706,78086,32041,49691,137143,9782,172080,50148,77917,6323,10110,69172,17711,21795,59511,76184,135114,31046,132319,59105,157578,20549,80778,57649,158421,65143,4575,72235,21899,10797,92745,34035,106079,80159,4508,78304,25350,75457,46458,32937,25623,47,8531,104751,84953,8138,36508,187199,66310,115274,13253,32461,38536,1916,42007,187160,35055,26325,84394,35963,94216,45590,97782];var Kse=E(J2(),1),qse=E(an(),1);var s7=15,o7=class{constructor(e){let{peerRouting:t,routingTable:n,refreshInterval:i,refreshQueryTimeout:s,lan:o}=e;this.log=C(`libp2p:kad-dht:${o?"lan":"wan"}:routing-table:refresh`),this.peerRouting=t,this.routingTable=n,this.refreshInterval=i??Sse,this.refreshQueryTimeout=s??xse,this.commonPrefixLengthRefreshedAt=[],this.refreshTable=this.refreshTable.bind(this)}init(e){}async start(){this.log(`refreshing routing table every ${this.refreshInterval}ms`),this.refreshTable(!0)}async stop(){this.refreshTimeoutId!=null&&clearTimeout(this.refreshTimeoutId)}refreshTable(e=!1){this.log("refreshing routing table");let t=this._maxCommonPrefix(),n=this._getTrackedCommonPrefixLengthsForRefresh(t);this.log(`max common prefix length ${t}`),this.log(`tracked CPLs [ ${n.map(i=>i.toISOString()).join(", ")} ]`),Promise.all(n.map(async(i,s)=>{try{if(await this._refreshCommonPrefixLength(s,i,e),this._numPeersForCpl(t)===0){let o=Math.min(2*(s+1),n.length-1);for(let a=s+1;a<o+1;a++)try{await this._refreshCommonPrefixLength(a,i,e)}catch(c){this.log.error(c)}}}catch(o){this.log.error(o)}})).catch(i=>{this.log.error(i)}).then(()=>{this.refreshTimeoutId=setTimeout(this.refreshTable,this.refreshInterval),this.refreshTimeoutId.unref!=null&&this.refreshTimeoutId.unref()}).catch(i=>{this.log.error(i)})}async _refreshCommonPrefixLength(e,t,n){if(!n&&t.getTime()>Date.now()-this.refreshInterval){this.log("not running refresh for cpl %s as time since last refresh not above interval",e);return}let i=await this._generateRandomPeerId(e);this.log("starting refreshing cpl %s with key %p (routing table size was %s)",e,i,this.routingTable.size);let s=new qse.TimeoutController(this.refreshQueryTimeout);try{let o=await(0,Kse.default)(this.peerRouting.getClosestPeers(i.toBytes(),{signal:s.signal}));this.log(`found ${o} peers that were close to imaginary peer %p`,i),this.log("finished refreshing cpl %s with key %p (routing table size is now %s)",e,i,this.routingTable.size)}finally{s.clear()}}_getTrackedCommonPrefixLengthsForRefresh(e){e>s7&&(e=s7);let t=[];for(let n=0;n<=e;n++)t[n]=this.commonPrefixLengthRefreshedAt[n]??new Date;return t}async _generateRandomPeerId(e){if(this.routingTable.kb==null)throw new Error("Routing table not started");let t=Si(2),n=(t[1]<<8)+t[0],i=await this._makePeerId(this.routingTable.kb.localNodeId,n,e);return Ir(i)}async _makePeerId(e,t,n){if(n>s7)throw new Error(`Cannot generate peer ID for common prefix length greater than ${s7}`);let o=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1)^32768>>n,a=65535<<16-(n+1),c=o&a|t&~a,l=Vse[c],f=new ArrayBuffer(34),h=new DataView(f,0,f.byteLength);return h.setUint8(0,$e.code),h.setUint8(1,32),h.setUint32(2,l,!1),new Uint8Array(h.buffer,h.byteOffset,h.byteLength)}_maxCommonPrefix(){let e=0;for(let t of this._prefixLengths())t>e&&(e=t);return e}_numPeersForCpl(e){let t=0;for(let n of this._prefixLengths())n===e&&t++;return t}*_prefixLengths(){if(this.routingTable.kb!=null)for(let{id:e}of this.routingTable.kb.toIterable()){let t=cl(this.routingTable.kb.localNodeId,e),n=0;for(let i of t)if(i===0)n++;else break;yield n}}};u();var jse=E(V(),1);var Wse=E(fi(),1),Yse=E(Oa(),1);u();u();var zse;(function(r){let e;r.codec=()=>(e==null&&(e=Et((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.key!=null&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),t.author!=null&&(n.uint32(26),n.bytes(t.author)),t.signature!=null&&(n.uint32(34),n.bytes(t.signature)),t.timeReceived!=null&&(n.uint32(42),n.string(t.timeReceived)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.key=t.bytes();break;case 2:i.value=t.bytes();break;case 3:i.author=t.bytes();break;case 4:i.signature=t.bytes();break;case 5:i.timeReceived=t.string();break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>wt(t,r.codec()),r.decode=t=>gt(t,r.codec())})(zse||(zse={}));var wf;(function(r){let e;(function(a){a.PUT_VALUE="PUT_VALUE",a.GET_VALUE="GET_VALUE",a.ADD_PROVIDER="ADD_PROVIDER",a.GET_PROVIDERS="GET_PROVIDERS",a.FIND_NODE="FIND_NODE",a.PING="PING"})(e=r.MessageType||(r.MessageType={}));let t;(function(a){a[a.PUT_VALUE=0]="PUT_VALUE",a[a.GET_VALUE=1]="GET_VALUE",a[a.ADD_PROVIDER=2]="ADD_PROVIDER",a[a.GET_PROVIDERS=3]="GET_PROVIDERS",a[a.FIND_NODE=4]="FIND_NODE",a[a.PING=5]="PING"})(t||(t={})),function(a){a.codec=()=>Hi(t)}(e=r.MessageType||(r.MessageType={}));let n;(function(a){a.NOT_CONNECTED="NOT_CONNECTED",a.CONNECTED="CONNECTED",a.CAN_CONNECT="CAN_CONNECT",a.CANNOT_CONNECT="CANNOT_CONNECT"})(n=r.ConnectionType||(r.ConnectionType={}));let i;(function(a){a[a.NOT_CONNECTED=0]="NOT_CONNECTED",a[a.CONNECTED=1]="CONNECTED",a[a.CAN_CONNECT=2]="CAN_CONNECT",a[a.CANNOT_CONNECT=3]="CANNOT_CONNECT"})(i||(i={})),function(a){a.codec=()=>Hi(i)}(n=r.ConnectionType||(r.ConnectionType={}));let s;(function(a){let c;a.codec=()=>(c==null&&(c=Et((l,f,h={})=>{if(h.lengthDelimited!==!1&&f.fork(),l.id!=null&&(f.uint32(10),f.bytes(l.id)),l.addrs!=null)for(let p of l.addrs)f.uint32(18),f.bytes(p);else throw new Error('Protocol error: required field "addrs" was not found in object');l.connection!=null&&(f.uint32(24),r.ConnectionType.codec().encode(l.connection,f)),h.lengthDelimited!==!1&&f.ldelim()},(l,f)=>{let h={addrs:[]},p=f==null?l.len:l.pos+f;for(;l.pos<p;){let d=l.uint32();switch(d>>>3){case 1:h.id=l.bytes();break;case 2:h.addrs.push(l.bytes());break;case 3:h.connection=r.ConnectionType.codec().decode(l);break;default:l.skipType(d&7);break}}return h})),c),a.encode=l=>wt(l,a.codec()),a.decode=l=>gt(l,a.codec())})(s=r.Peer||(r.Peer={}));let o;r.codec=()=>(o==null&&(o=Et((a,c,l={})=>{if(l.lengthDelimited!==!1&&c.fork(),a.type!=null&&(c.uint32(8),r.MessageType.codec().encode(a.type,c)),a.clusterLevelRaw!=null&&(c.uint32(80),c.int32(a.clusterLevelRaw)),a.key!=null&&(c.uint32(18),c.bytes(a.key)),a.record!=null&&(c.uint32(26),c.bytes(a.record)),a.closerPeers!=null)for(let f of a.closerPeers)c.uint32(66),r.Peer.codec().encode(f,c);else throw new Error('Protocol error: required field "closerPeers" was not found in object');if(a.providerPeers!=null)for(let f of a.providerPeers)c.uint32(74),r.Peer.codec().encode(f,c);else throw new Error('Protocol error: required field "providerPeers" was not found in object');l.lengthDelimited!==!1&&c.ldelim()},(a,c)=>{let l={closerPeers:[],providerPeers:[]},f=c==null?a.len:a.pos+c;for(;a.pos<f;){let h=a.uint32();switch(h>>>3){case 1:l.type=r.MessageType.codec().decode(a);break;case 10:l.clusterLevelRaw=a.int32();break;case 2:l.key=a.bytes();break;case 3:l.record=a.bytes();break;case 8:l.closerPeers.push(r.Peer.codec().decode(a,a.uint32()));break;case 9:l.providerPeers.push(r.Peer.codec().decode(a,a.uint32()));break;default:a.skipType(h&7);break}}return l})),o),r.encode=a=>wt(a,r.codec()),r.decode=a=>gt(a,r.codec())})(wf||(wf={}));var sn=wf.MessageType,PSe=wf.ConnectionType,Gse=Object.keys(sn),xr=class{constructor(e,t,n){if(!(t instanceof Uint8Array))throw new Error("Key must be a Uint8Array");this.type=e,this.key=t,this.clusterLevelRaw=n,this.closerPeers=[],this.providerPeers=[],this.record=void 0}get clusterLevel(){let e=this.clusterLevelRaw-1;return e<0?0:e}set clusterLevel(e){this.clusterLevelRaw=e}serialize(){return wf.encode({key:this.key,type:this.type,clusterLevelRaw:this.clusterLevelRaw,closerPeers:this.closerPeers.map($se),providerPeers:this.providerPeers.map($se),record:this.record==null?void 0:this.record.serialize().subarray()})}static deserialize(e){let t=wf.decode(e),n=new xr(t.type??wf.MessageType.PUT_VALUE,t.key??Uint8Array.from([]),t.clusterLevelRaw??0);return n.closerPeers=t.closerPeers.map(Hse),n.providerPeers=t.providerPeers.map(Hse),t.record?.length!=null&&(n.record=Rr.deserialize(t.record)),n}};function $se(r){return{id:r.id.toBytes(),addrs:(r.multiaddrs??[]).map(t=>t.bytes),connection:PSe.CONNECTED}}function Hse(r){if(r.id==null)throw new Error("Invalid peer in message");return{id:Ir(r.id),multiaddrs:(r.addrs??[]).map(e=>se(e)),protocols:[]}}u();function AP(r){return{...r,name:"SENDING_QUERY",type:0,messageName:r.type,messageType:Gse.indexOf(r.type.toString())}}function Zg(r){return{...r,name:"PEER_RESPONSE",type:1,messageName:r.messageType,closer:r.closer!=null?r.closer:[],providers:r.providers!=null?r.providers:[]}}function Jg(r){return{...r,name:"FINAL_PEER",type:2}}function yi(r){return{...r,name:"QUERY_ERROR",type:3}}function RP(r){return{...r,name:"PROVIDER",type:4}}function e3(r){return{...r,name:"VALUE",type:5}}function CP(r){return{...r,name:"DIALING_PEER",type:7}}var a7=class extends We{constructor(e){super(),this.components=new je;let{protocol:t,lan:n}=e;this.log=C(`libp2p:kad-dht:${n?"lan":"wan"}:network`),this.running=!1,this.protocol=t}init(e){this.components=e}async start(){this.running||(this.running=!0)}async stop(){this.running=!1}isStarted(){return this.running}async*sendRequest(e,t,n={}){if(!this.running)return;this.log("sending %s to %p",t.type,e),yield CP({peer:e}),yield AP({to:e,type:t.type});let i;try{let o=await(await this.components.getConnectionManager().openConnection(e,n)).newStream(this.protocol,n),a=await this._writeReadMessage(o,t.serialize(),n);yield Zg({from:e,messageType:a.type,closer:a.closerPeers,providers:a.providerPeers,record:a.record})}catch(s){yield yi({from:e,error:s})}finally{i?.close()}}async*sendMessage(e,t,n={}){if(!this.running)return;this.log("sending %s to %p",t.type,e),yield CP({peer:e}),yield AP({to:e,type:t.type});let i;try{let o=await(await this.components.getConnectionManager().openConnection(e,n)).newStream(this.protocol,n);await this._writeMessage(o,t.serialize(),n),yield Zg({from:e,messageType:t.type})}catch(s){yield yi({from:e,error:s})}finally{i?.close()}}async _writeMessage(e,t,n){n.signal!=null&&(e=ti(e,n.signal)),await we([t],mr(),e,Wse.default)}async _writeReadMessage(e,t,n){n.signal!=null&&(e=ti(e,n.signal));let i=await we([t],mr(),e,yr(),async o=>{let a=await(0,Yse.default)(o);if(a!=null)return a;throw(0,jse.default)(new Error("No message received"),"ERR_NO_MESSAGE_RECEIVED")}),s=xr.deserialize(i);return s.closerPeers.forEach(o=>{this.dispatchEvent(new ne("peer",{detail:o}))}),s.providerPeers.forEach(o=>{this.dispatchEvent(new ne("peer",{detail:o}))}),s}};u();var l7=E(V(),1);u();var y1=E(V(),1);function g1(r,e){let t=e.key,i=K(t).split("/");if(i.length<3)return;let s=r[i[1].toString()];if(s==null){let o="Invalid record keytype";throw(0,y1.default)(new Error(o),"ERR_INVALID_RECORD_KEY_TYPE")}return s(t,e.value)}var DSe=async(r,e)=>{if(!(r instanceof Uint8Array))throw(0,y1.default)(new Error('"key" must be a Uint8Array'),"ERR_INVALID_RECORD_KEY_NOT_BUFFER");if(r.byteLength<5)throw(0,y1.default)(new Error("invalid public key record"),"ERR_INVALID_RECORD_KEY_TOO_SHORT");if(K(r.subarray(0,4))!=="/pk/")throw(0,y1.default)(new Error("key was not prefixed with /pk/"),"ERR_INVALID_RECORD_KEY_BAD_PREFIX");let n=r.slice(4),i=await $e.digest(e);if(!ze(n,i.bytes))throw(0,y1.default)(new Error("public key does not match passed in key"),"ERR_INVALID_RECORD_HASH_MISMATCH")},Qse={pk:DSe};u();var c7=E(V(),1);function Xse(r,e,t){if(t.length===0){let o="No records given";throw(0,c7.default)(new Error(o),"ERR_NO_RECORDS_RECEIVED")}let i=K(e).split("/");if(i.length<3){let o="Record key does not have a selector function";throw(0,c7.default)(new Error(o),"ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")}let s=r[i[1].toString()];if(s==null){let o=`Unrecognized key prefix: ${i[1]}`;throw(0,c7.default)(new Error(o),"ERR_UNRECOGNIZED_KEY_PREFIX")}return t.length===1?0:s(e,t)}function OSe(r,e){return 0}var Zse={pk:OSe};var Jse=E(r2(),1),eoe=E(Kn(),1);var u7=class{constructor(e){this.components=new je;let{validators:t,selectors:n,peerRouting:i,queryManager:s,routingTable:o,network:a,lan:c}=e;this.log=C(`libp2p:kad-dht:${c?"lan":"wan"}:content-fetching`),this.validators=t,this.selectors=n,this.peerRouting=i,this.queryManager=s,this.routingTable=o,this.network=a}init(e){this.components=e}async putLocal(e,t){let n=vl(e);await this.components.getDatastore().put(n,t)}async getLocal(e){this.log("getLocal %b",e);let t=vl(e);this.log("fetching record for key %k",t);let n=await this.components.getDatastore().get(t);this.log("found %k in local datastore",t);let i=Rr.deserialize(n);return await g1(this.validators,i),i}async*sendCorrectionRecord(e,t,n,i={}){this.log("sendCorrection for %b",e);let s=await wP(e,n);for(let{value:o,from:a}of t){if(ze(o,n)){this.log("record was ok");continue}if(this.components.getPeerId().equals(a)){try{let f=vl(e);this.log(`Storing corrected record for key ${f.toString()}`),await this.components.getDatastore().put(f,s.subarray())}catch(f){this.log.error("Failed error correcting self",f)}continue}let c=!1,l=new xr(sn.PUT_VALUE,e,0);l.record=Rr.deserialize(s);for await(let f of this.network.sendRequest(a,l,i))f.name==="PEER_RESPONSE"&&f.record!=null&&ze(f.record.value,Rr.deserialize(s).value)&&(c=!0),yield f;c||(yield yi({from:a,error:(0,l7.default)(new Error("value not put correctly"),"ERR_PUT_VALUE_INVALID")})),this.log.error("Failed error correcting entry")}}async*put(e,t,n={}){this.log("put key %b value %b",e,t);let i=await wP(e,t),s=vl(e);this.log(`storing record for key ${s.toString()}`),await this.components.getDatastore().put(s,i.subarray()),yield*we(this.peerRouting.getClosestPeers(e,{signal:n.signal}),o=>(0,eoe.default)(o,a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[],l=new xr(sn.PUT_VALUE,e,0);l.record=Rr.deserialize(i),this.log("send put to %p",a.peer.id);for await(let f of this.network.sendRequest(a.peer.id,l,n))c.push(f),f.name==="PEER_RESPONSE"&&(f.record!=null&&ze(f.record.value,Rr.deserialize(i).value)||c.push(yi({from:a.peer.id,error:(0,l7.default)(new Error("value not put correctly"),"ERR_PUT_VALUE_INVALID")})));return c}),o=>(0,Jse.default)(o,{ordered:!1,concurrency:3}),async function*(o){for await(let a of o)yield*a})}async*get(e,t={}){this.log("get %b",e);let n=[];for await(let a of this.getMany(e,t))a.name==="VALUE"&&n.push(a),yield a;if(n.length===0)return;let i=n.map(a=>a.value),s=0;try{s=Xse(this.selectors,e,i)}catch(a){if(a.code!=="ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")throw a}let o=i[s];if(this.log("GetValue %b %b",e,o),o==null)throw(0,l7.default)(new Error("best value was not found"),"ERR_NOT_FOUND");yield*this.sendCorrectionRecord(e,n,o,t),yield n[s]}async*getMany(e,t={}){this.log("getMany values for %b",e);try{let a=await this.getLocal(e);yield e3({value:a.value,from:this.components.getPeerId()})}catch(a){this.log("error getting local value for %b",e,a)}let n=await rc(e),i=this.routingTable.closestPeers(n);this.log("found %d peers in routing table",i.length);let s=this,o=async function*({peer:a,signal:c}){for await(let l of s.peerRouting.getValueOrPeers(a,e,{signal:c}))yield l,l.name==="PEER_RESPONSE"&&l.record!=null&&(yield e3({from:a,value:l.record.value}))};yield*this.queryManager.run(e,i,o,t)}};u();var toe=E(r2(),1),roe=E(Kn(),1);var f7=class{constructor(e){this.components=new je;let{network:t,peerRouting:n,queryManager:i,routingTable:s,providers:o,lan:a}=e;this.log=C(`libp2p:kad-dht:${a?"lan":"wan"}:content-routing`),this.network=t,this.peerRouting=n,this.queryManager=i,this.routingTable=s,this.providers=o}init(e){this.components=e}async*provide(e,t,n={}){this.log("provide %s",e),await this.providers.addProvider(e,this.components.getPeerId());let i=new xr(sn.ADD_PROVIDER,e.bytes,0);i.providerPeers=[{id:this.components.getPeerId(),multiaddrs:t,protocols:[]}];let s=0,o=a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[];this.log("putProvider %s to %p",e,a.peer.id);try{this.log("sending provider record for %s to %p",e,a.peer.id);for await(let l of this.network.sendMessage(a.peer.id,i,n))l.name==="PEER_RESPONSE"&&(this.log("sent provider record for %s to %p",e,a.peer.id),s++),c.push(l)}catch(l){this.log.error("error sending provide record to peer %p",a.peer.id,l),c.push(yi({from:a.peer.id,error:l}))}return c};yield*we(this.peerRouting.getClosestPeers(e.multihash.bytes,n),a=>(0,roe.default)(a,c=>o(c)),a=>(0,toe.default)(a,{ordered:!1,concurrency:3}),async function*(a){for await(let c of a)yield*c}),this.log("sent provider records to %d peers",s)}async*findProviders(e,t){let n=this.routingTable.kBucketSize,i=e.multihash.bytes,s=await rc(i),o=this;this.log("findProviders %c",e);let a=await this.providers.getProviders(e);if(a.length>0){let f=[];for(let h of a.slice(0,n))f.push({id:h,multiaddrs:(await this.components.getPeerStore().addressBook.get(h)??[]).map(p=>p.multiaddr),protocols:[]});yield Zg({from:this.components.getPeerId(),messageType:sn.GET_PROVIDERS,providers:f}),yield RP({from:this.components.getPeerId(),providers:f})}if(a.length>=n)return;let c=async function*({peer:f,signal:h}){let p=new xr(sn.GET_PROVIDERS,i,0);yield*o.network.sendRequest(f,p,{signal:h})},l=new Set(a.map(f=>f.toString()));for await(let f of this.queryManager.run(i,this.routingTable.closestPeers(s),c,t))if(yield f,f.name==="PEER_RESPONSE"){this.log("Found %d provider entries for %c and %d closer peers",f.providers.length,e,f.closer.length);let h=[];for(let p of f.providers)l.has(p.id.toString())||(l.add(p.id.toString()),h.push(p));if(h.length>0&&(yield RP({from:f.from,providers:h})),l.size===n)return}}};u();var xd=E(V(),1);u();var h7=class{constructor(e,t){this.originDhtKey=e,this.capacity=t,this.peerDistances=[]}get length(){return this.peerDistances.length}get peers(){return this.peerDistances.map(e=>e.peerId)}async add(e){if(this.peerDistances.find(i=>i.peerId.equals(e))!=null)return;let t=await ms(e),n={peerId:e,distance:cl(this.originDhtKey,t)};this.peerDistances.push(n),this.peerDistances.sort((i,s)=>ah(i.distance,s.distance)),this.peerDistances=this.peerDistances.slice(0,this.capacity)}async anyCloser(e){if(e.length===0)return!1;if(this.length===0)return!0;let t=await Promise.all(e.map(ms)),n=this.peerDistances[this.peerDistances.length-1].distance;for(let i of t){let s=cl(this.originDhtKey,i);if(ah(s,n)<0)return!0}return!1}};var d7=class{constructor(e){this.components=new je;let{routingTable:t,network:n,validators:i,queryManager:s,lan:o}=e;this.routingTable=t,this.network=n,this.validators=i,this.queryManager=s,this.log=C(`libp2p:kad-dht:${o?"lan":"wan"}:peer-routing`)}init(e){this.components=e}async findPeerLocal(e){let t,n=await this.routingTable.find(e);if(n!=null){this.log("findPeerLocal found %p in routing table",e);try{t=await this.components.getPeerStore().get(n)}catch(i){if(i.code!=="ERR_NOT_FOUND")throw i}}if(t==null)try{t=await this.components.getPeerStore().get(e)}catch(i){if(i.code!=="ERR_NOT_FOUND")throw i}if(t!=null)return this.log("findPeerLocal found %p in peer store",e),{id:t.id,multiaddrs:t.addresses.map(i=>i.multiaddr),protocols:[]}}async*_getValueSingle(e,t,n={}){let i=new xr(sn.GET_VALUE,t,0);yield*this.network.sendRequest(e,i,n)}async*getPublicKeyFromNode(e,t={}){let n=Ise(e);for await(let i of this._getValueSingle(e,n,t))if(yield i,i.name==="PEER_RESPONSE"&&i.record!=null){let s=await ln(qw.marshalPublicKey({bytes:i.record.value}));if(!s.equals(e))throw(0,xd.default)(new Error("public key does not match id"),"ERR_PUBLIC_KEY_DOES_NOT_MATCH_ID");if(s.publicKey==null)throw(0,xd.default)(new Error("public key missing"),"ERR_PUBLIC_KEY_MISSING");yield e3({from:e,value:s.publicKey})}throw(0,xd.default)(new Error(`Node not responding with its public key: ${e.toString()}`),"ERR_INVALID_RECORD")}async*findPeer(e,t={}){this.log("findPeer %p",e);let n=await this.findPeerLocal(e);if(n!=null){this.log("found local"),yield Jg({from:this.components.getPeerId(),peer:n});return}let i=await ms(e),s=this.routingTable.closestPeers(i);if(s.find(f=>f.equals(e))!=null)try{let f=await this.components.getPeerStore().get(e);this.log("found in peerStore"),yield Jg({from:this.components.getPeerId(),peer:{id:f.id,multiaddrs:f.addresses.map(h=>h.multiaddr),protocols:[]}});return}catch(f){if(f.code!=="ERR_NOT_FOUND")throw f}let a=this,c=async function*({peer:f,signal:h}){let p=new xr(sn.FIND_NODE,e.toBytes(),0);for await(let d of a.network.sendRequest(f,p,{signal:h}))if(yield d,d.name==="PEER_RESPONSE"){let m=d.closer.find(y=>y.id.equals(e));m!=null&&(yield Jg({from:d.from,peer:m}))}},l=!1;for await(let f of this.queryManager.run(e.toBytes(),s,c,t))f.name==="FINAL_PEER"&&(l=!0),yield f;l||(yield yi({from:this.components.getPeerId(),error:(0,xd.default)(new Error("Not found"),"ERR_NOT_FOUND")}))}async*getClosestPeers(e,t={}){this.log("getClosestPeers to %b",e);let n=await rc(e),i=this.routingTable.closestPeers(n),s=this,o=new h7(n,this.routingTable.kBucketSize);await Promise.all(i.map(async c=>await o.add(c)));let a=async function*({peer:c,signal:l}){s.log("closerPeersSingle %s from %p",K(e,"base32"),c);let f=new xr(sn.FIND_NODE,e,0);yield*s.network.sendRequest(c,f,{signal:l})};for await(let c of this.queryManager.run(e,i,a,t))yield c,c.name==="PEER_RESPONSE"&&await Promise.all(c.closer.map(async l=>await o.add(l.id)));this.log("found %d peers close to %b",o.length,e);for(let c of o.peers)yield Jg({from:this.components.getPeerId(),peer:{id:c,multiaddrs:(await this.components.getPeerStore().addressBook.get(c)??[]).map(l=>l.multiaddr),protocols:[]}})}async*getValueOrPeers(e,t,n={}){for await(let i of this._getValueSingle(e,t,n)){if(i.name==="PEER_RESPONSE"&&i.record!=null)try{await this._verifyRecordOnline(i.record)}catch{let o="invalid record received, discarded";this.log(o),yield yi({from:i.from,error:(0,xd.default)(new Error(o),"ERR_INVALID_RECORD")});continue}yield i}}async _verifyRecordOnline(e){if(e.timeReceived==null)throw(0,xd.default)(new Error("invalid record received"),"ERR_INVALID_RECORD");await g1(this.validators,new Rr(e.key,e.value,e.timeReceived))}async getCloserPeersOffline(e,t){let n=await rc(e),i=this.routingTable.closestPeers(n),s=[];for(let o of i)if(!o.equals(t))try{let a=await this.components.getPeerStore().addressBook.get(o),c=await this.components.getPeerStore().protoBook.get(o);s.push({id:o,multiaddrs:a.map(l=>l.multiaddr),protocols:c})}catch(a){if(a.code!=="ERR_NOT_FOUND")throw a}return s.length>0?this.log("getCloserPeersOffline found %d peer(s) closer to %b than %p",s.length,e,t):this.log("getCloserPeersOffline could not find peer closer to %b than %p",e,t),s}};u();var noe=E(op(),1),PP=E(fa(),1);var xl=C("libp2p:kad-dht:providers"),p7=class{constructor(e={}){this.components=new je;let{cacheSize:t,cleanupInterval:n,provideValidity:i}=e;this.cleanupInterval=n??36e5,this.provideValidity=i??864e5,this.cache=(0,noe.default)(t??256),this.syncQueue=new Sl({concurrency:1}),this.started=!1}init(e){this.components=e}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cleaner=setInterval(()=>{this._cleanup().catch(e=>{xl.error(e)})},this.cleanupInterval))}async stop(){this.started=!1,this.cleaner!=null&&(clearInterval(this.cleaner),this.cleaner=void 0)}async _cleanup(){return await this.syncQueue.add(async()=>{let e=Date.now(),t=0,n=0,i=new Map,s=this.components.getDatastore().batch(),o=this.components.getDatastore().query({prefix:yP});for await(let a of o)try{let{cid:c,peerId:l}=ioe(a.key),f=soe(a.value).getTime(),h=Date.now(),p=h-f,d=p>this.provideValidity;if(xl("comparing: %d - %d = %d > %d %s",h,f,p,this.provideValidity,d?"(expired)":""),d){n++,s.delete(a.key);let m=i.get(c)??new Set;m.add(l),i.set(c,m)}t++}catch(c){xl.error(c.message)}i.size>0?(xl("deleting %d / %d entries",n,t),await s.commit()):xl("nothing to delete");for(let[a,c]of i){let l=t3(a),f=this.cache.get(l);if(f!=null){for(let h of c)f.delete(h);f.size===0?this.cache.remove(l):this.cache.set(l,f)}}xl("Cleanup successful (%dms)",Date.now()-e)})}async _getProvidersMap(e){let t=t3(e),n=this.cache.get(t);return n==null&&(n=await MSe(this.components.getDatastore(),e),this.cache.set(t,n)),n}async addProvider(e,t){return await this.syncQueue.add(async()=>{xl("%p provides %s",t,e);let n=await this._getProvidersMap(e);xl("loaded %s provs",n.size);let i=new Date;n.set(t.toString(),i);let s=t3(e);this.cache.set(s,n),await BSe(this.components.getDatastore(),e,t,i)})}async getProviders(e){return await this.syncQueue.add(async()=>(xl("get providers for %s",e),[...(await this._getProvidersMap(e)).keys()].map(n=>pe(n))))}};function t3(r){let e=typeof r=="string"?r:K(r.multihash.bytes,"base32");return`${yP}/${e}`}async function BSe(r,e,t,n){let i=[t3(e),"/",t.toString()].join(""),s=new fe(i),o=Uint8Array.from(PP.default.encode(n.getTime()));return await r.put(s,o)}function ioe(r){let e=r.toString().split("/");if(e.length!==5)throw new Error(`incorrectly formatted provider entry key in datastore: ${r.toString()}`);return{cid:e[3],peerId:e[4]}}async function MSe(r,e){let t=new Map,n=r.query({prefix:t3(e)});for await(let i of n){let{peerId:s}=ioe(i.key);t.set(s,soe(i.value))}return t}function soe(r){return new Date(PP.default.decode(r))}u();var foe=E(an(),1),hoe=E(ai(),1);u();var ooe=E(V(),1);var aoe=E(an(),1),coe=E(ai(),1);var USe=BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");async function*loe(r){let{key:e,startingPeer:t,ourPeerId:n,signal:i,query:s,alpha:o,pathIndex:a,numPaths:c,cleanUp:l,queryFuncTimeout:f,log:h}=r,p=new Sl({concurrency:o}),d=await rc(e),m=new Set;function y(g,w){if(g==null)return;m.add(g.toString());let b=BigInt("0x"+K(cl(w,d),"base16"));p.add(async()=>{let S,_=[i];f!=null&&(S=new aoe.TimeoutController(f),_.push(S.signal));let I=(0,coe.anySignal)(_);try{for await(let T of s({key:e,peer:g,signal:I,pathIndex:a,numPaths:c})){if(I.aborted)return;if(T.name==="PEER_RESPONSE")for(let x of T.closer){if(m.has(x.id.toString())){h("already seen %p in query",x.id);continue}if(n.equals(x.id)){h("not querying ourselves");continue}let P=await ms(x.id);if(BigInt("0x"+K(cl(P,d),"base16"))>b){h("skipping %p as they are not closer to %b than %p",x.id,e,g);continue}h("querying closer peer %p",x.id),y(x.id,P)}p.emit("completed",T)}S?.clear()}catch(T){i.aborted?p.emit("error",T):p.emit("completed",yi({from:g,error:T}))}finally{S?.clear()}},{priority:USe-b}).catch(S=>{h.error(S)})}y(t,await ms(t)),yield*FSe(p,i,l,h)}async function*FSe(r,e,t,n){let i=lr(),s=!0,o=[],a=()=>{!s||(n("clean up queue, results %d, queue size %d, pending tasks %d",o.length,r.size,r.pending),s=!1,r.clear(),o.splice(0,o.length))};for(r.on("completed",c=>{o.push(c),i.resolve()}),r.on("error",c=>{n("queue error",c),a(),i.reject(c)}),r.on("idle",()=>{n("queue idle"),s=!1,i.resolve()}),e.addEventListener("abort",()=>{n("abort queue");let c=s;a(),c&&i.reject((0,ooe.default)(new Error("Query aborted"),"ERR_QUERY_ABORTED"))}),t.addEventListener("cleanup",()=>{a(),i.resolve()});s;)for(await i.promise,i=lr();o.length>0;){let c=o.shift();c!=null&&(yield c)}yield*o}var doe=E(Bc(),1),r3=E(bn(),1);var uoe="running-queries",y7=class{constructor(e){this.components=new je;let{lan:t=!1,disjointPaths:n=20,alpha:i=3}=e;this.disjointPaths=n??20,this.controllers=new Set,this.running=!1,this.alpha=i??3,this.lan=t,this.queries=0}init(e){this.components=e}isStarted(){return this.running}async start(){this.running=!0}async stop(){this.running=!1;for(let e of this.controllers)e.abort();this.controllers.clear()}async*run(e,t,n,i={}){if(!this.running)throw new Error("QueryManager not started");let s;if(i.signal==null){s=new foe.TimeoutController(Tse),i.signal=s.signal;try{r3.setMaxListeners!=null&&(0,r3.setMaxListeners)(1/0,s.signal)}catch{}}let o=new AbortController;this.controllers.add(o);let a=[o.signal];i.signal!=null&&a.push(i.signal);let c=(0,hoe.anySignal)(a);try{r3.setMaxListeners!=null&&(0,r3.setMaxListeners)(1/0,c)}catch{}let l=C(`libp2p:kad-dht:${this.lan?"lan":"wan"}:query:`+K(e,"base58btc")),f=t.slice(0,Math.min(this.disjointPaths,t.length)),h=Date.now(),p=new We;try{if(l("query:start"),this.queries++,this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:uoe,value:this.queries}),t.length===0){l.error("Running query with no peers");return}let d=f.map((m,y)=>loe({key:e,startingPeer:m,ourPeerId:this.components.getPeerId(),signal:c,query:n,pathIndex:y,numPaths:f.length,alpha:this.alpha,cleanUp:p,queryFuncTimeout:i.queryFuncTimeout,log:l}));for await(let m of(0,doe.default)(...d))yield m,m.name==="QUERY_ERROR"&&l("error",m.error)}catch(d){if(!(!this.running&&d.code==="ERR_QUERY_ABORTED"))throw d}finally{this.controllers.delete(o),s?.clear(),this.queries--,this.components.getMetrics()?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:uoe,value:this.queries}),p.dispatchEvent(new ne("cleanup")),l("query:done in %dms",Date.now()-h)}}};u();u();var DP=E(V(),1);var n3=C("libp2p:kad-dht:rpc:handlers:add-provider"),g7=class{constructor(e){let{providers:t}=e;this.providers=t}init(){}async handle(e,t){if(n3("start"),t.key==null||t.key.length===0)throw(0,DP.default)(new Error("Missing key"),"ERR_MISSING_KEY");let n;try{n=A.decode(t.key)}catch{throw(0,DP.default)(new Error("Invalid CID"),"ERR_INVALID_CID")}(t.providerPeers==null||t.providerPeers.length===0)&&n3.error("no providers found in message"),await Promise.all(t.providerPeers.map(async i=>{if(!i.id.equals(e)){n3("invalid provider peer %p from %p",i.id,e);return}if(i.multiaddrs.length<1){n3("no valid addresses for provider %p. Ignore",e);return}n3("received provider %p for %s (addrs %s)",e,n,i.multiaddrs.map(s=>s.toString())),await this.providers.addProvider(n,i.id)}))}};u();var poe=C("libp2p:kad-dht:rpc:handlers:find-node"),w7=class{constructor(e){this.components=new je;let{peerRouting:t,lan:n}=e;this.peerRouting=t,this.lan=Boolean(n)}init(e){this.components=e}async handle(e,t){poe("incoming request from %p for peers closer to %b",e,t.key);let n=[];ze(this.components.getPeerId().toBytes(),t.key)?n=[{id:this.components.getPeerId(),multiaddrs:this.components.getAddressManager().getAddresses().map(s=>s.decapsulateCode(Yt("p2p").code)),protocols:[]}]:n=await this.peerRouting.getCloserPeersOffline(t.key,e),n=n.map(this.lan?m1:p1).filter(({multiaddrs:s})=>s.length);let i=new xr(t.type,new Uint8Array(0),t.clusterLevel);return n.length>0?i.closerPeers=n:poe("could not find any peers closer to %b than %p",t.key,e),i}};u();var yoe=E(V(),1);var moe=C("libp2p:kad-dht:rpc:handlers:get-providers"),E7=class{constructor(e){this.components=new je;let{peerRouting:t,providers:n,lan:i}=e;this.peerRouting=t,this.providers=n,this.lan=Boolean(i)}init(e){this.components=e}async handle(e,t){let n;try{n=A.decode(t.key)}catch{throw(0,yoe.default)(new Error("Invalid CID"),"ERR_INVALID_CID")}moe("%p asking for providers for %s",e,n);let[i,s]=await Promise.all([this.providers.getProviders(n),this.peerRouting.getCloserPeersOffline(t.key,e)]),o=await this._getPeers(i),a=await this._getPeers(s.map(({id:l})=>l)),c=new xr(t.type,t.key,t.clusterLevel);return o.length>0&&(c.providerPeers=o),a.length>0&&(c.closerPeers=a),moe("got %s providers %s closerPeers",o.length,a.length),c}async _getAddresses(e){return(await this.components.getPeerStore().addressBook.get(e)).map(n=>n.multiaddr)}async _getPeers(e){let t=[],n=this.lan?m1:p1;for(let i of e){let s=n({id:i,multiaddrs:await this._getAddresses(i),protocols:[]});s.multiaddrs.length>0&&t.push(s)}return t}};u();var b7=E(V(),1);var E1=C("libp2p:kad-dht:rpc:handlers:get-value"),v7=class{constructor(e){this.components=new je;let{peerRouting:t}=e;this.peerRouting=t}init(e){this.components=e}async handle(e,t){let n=t.key;if(E1("%p asked for key %b",e,n),n==null||n.length===0)throw(0,b7.default)(new Error("Invalid key"),"ERR_INVALID_KEY");let i=new xr(sn.GET_VALUE,n,t.clusterLevel);if(Ase(n)){E1("is public key");let a=Rse(n),c;try{let l=await this.components.getPeerStore().keyBook.get(a);if(l==null)throw(0,b7.default)(new Error("No public key found in key book"),"ERR_NOT_FOUND");c=l}catch(l){if(l.code!=="ERR_NOT_FOUND")throw l}if(c!=null)return E1("returning found public key"),i.record=new Rr(n,c,new Date),i}let[s,o]=await Promise.all([this._checkLocalDatastore(n),this.peerRouting.getCloserPeersOffline(t.key,e)]);return s!=null&&(E1("had record for %b in local datastore",n),i.record=s),o.length>0&&(E1("had %s closer peers in routing table",o.length),i.closerPeers=o),i}async _checkLocalDatastore(e){E1("checkLocalDatastore looking for %b",e);let t=vl(e),n;try{n=await this.components.getDatastore().get(t)}catch(s){if(s.code==="ERR_NOT_FOUND")return;throw s}let i=Rr.deserialize(n);if(i==null)throw(0,b7.default)(new Error("Invalid record"),"ERR_INVALID_RECORD");if(i.timeReceived==null||Date.now()-i.timeReceived.getTime()>1296e5){await this.components.getDatastore().delete(t);return}return i}};u();var KSe=C("libp2p:kad-dht:rpc:handlers:ping"),_7=class{async handle(e,t){return KSe("ping from %p",e),t}init(){}};u();var goe=E(V(),1);var S7=class{constructor(e){this.components=new je;let{validators:t}=e;this.log=C("libp2p:kad-dht:rpc:handlers:put-value"),this.validators=t}init(e){this.components=e}async handle(e,t){let n=t.key;this.log("%p asked us to store value for key %b",e,n);let i=t.record;if(i==null){let s=`Empty record from: ${e.toString()}`;throw this.log.error(s),(0,goe.default)(new Error(s),"ERR_EMPTY_RECORD")}try{await g1(this.validators,i),i.timeReceived=new Date;let s=vl(i.key);await this.components.getDatastore().put(s,i.serialize().subarray()),this.log("put record for %b into datastore under key %k",n,s)}catch(s){this.log("did not put record for key %b into datastore %o",n,s)}return t}};var x7=class{constructor(e){let{providers:t,peerRouting:n,validators:i,lan:s}=e;this.log=C("libp2p:kad-dht:rpc"),this.routingTable=e.routingTable,this.handlers={[sn.GET_VALUE]:new v7({peerRouting:n}),[sn.PUT_VALUE]:new S7({validators:i}),[sn.FIND_NODE]:new w7({peerRouting:n,lan:s}),[sn.ADD_PROVIDER]:new g7({providers:t}),[sn.GET_PROVIDERS]:new E7({peerRouting:n,providers:t,lan:s}),[sn.PING]:new _7}}init(e){for(let t of Object.values(this.handlers))t.init(e)}async handleMessage(e,t){try{await this.routingTable.add(e)}catch(i){this.log.error("Failed to update the kbucket store",i)}let n=this.handlers[t.type];if(n==null){this.log.error(`no handler found for message type: ${t.type}`);return}return await n.handle(e,t)}onIncomingStream(e){Promise.resolve().then(async()=>{let{stream:t,connection:n}=e,i=n.remotePeer;try{await this.routingTable.add(i)}catch(o){this.log.error(o)}let s=this;await we(t,yr(),async function*(o){for await(let a of o){let c=xr.deserialize(a);s.log("incoming %s from %p",c.type,i);let l=await s.handleMessage(i,c);l!=null&&(yield l.serialize())}},mr(),t)}).catch(t=>{this.log.error(t)})}};u();var T7=class extends We{constructor(e){super(),this.components=new je;let{protocol:t,lan:n}=e;this.log=C(`libp2p:kad-dht:topology-listener:${n?"lan":"wan"}`),this.running=!1,this.protocol=t}init(e){this.components=e}isStarted(){return this.running}async start(){if(this.running)return;this.running=!0;let e=k0({onConnect:t=>{this.log("observed peer %p with protocol %s",t,this.protocol),this.dispatchEvent(new ne("peer",{detail:t}))}});this.registrarId=await this.components.getRegistrar().register(this.protocol,e)}stop(){this.running=!1,this.registrarId!=null&&(this.components.getRegistrar().unregister(this.registrarId),this.registrarId=void 0)}};u();var OP=E(bn(),1),woe=E(Kp(),1),Eoe=E(J2(),1);var boe=E(an(),1),voe=E(ai(),1);var I7=class{constructor(e){this.components=new je;let{peerRouting:t,lan:n,count:i,interval:s,queryTimeout:o}=e;this.log=C(`libp2p:kad-dht:${n?"lan":"wan"}:query-self`),this.running=!1,this.peerRouting=t,this.count=i??20,this.interval=s??vse,this.queryTimeout=o??_se}init(e){this.components=e}isStarted(){return this.running}async start(){this.running||(this.running=!0,this._querySelf())}async stop(){this.running=!1,this.timeoutId!=null&&clearTimeout(this.timeoutId),this.controller!=null&&this.controller.abort()}_querySelf(){Promise.resolve().then(async()=>{let e=new boe.TimeoutController(this.queryTimeout);try{this.controller=new AbortController;let t=(0,voe.anySignal)([this.controller.signal,e.signal]);try{OP.setMaxListeners!=null&&(0,OP.setMaxListeners)(1/0,t)}catch{}let n=await we(this.peerRouting.getClosestPeers(this.components.getPeerId().toBytes(),{signal:t}),i=>(0,woe.default)(i,this.count),async i=>await(0,Eoe.default)(i));this.log("query ran successfully - found %d peers",n)}catch(t){this.log("query error",t)}finally{this.timeoutId=setTimeout(this._querySelf.bind(this),this.interval),e.clear()}}).catch(e=>{this.log("query error",e)})}};var qSe=32,zSe=64,i3=class extends We{constructor(e){super(),this.components=new je;let{kBucketSize:t,clientMode:n,validators:i,selectors:s,querySelfInterval:o,lan:a,protocolPrefix:c,pingTimeout:l,pingConcurrency:f,maxInboundStreams:h,maxOutboundStreams:p}=e;this.running=!1,this.lan=Boolean(a),this.log=C(`libp2p:kad-dht:${a===!0?"lan":"wan"}`),this.protocol=`${c??wse}${a===!0?gse:""}${Ese}`,this.kBucketSize=t??20,this.clientMode=n??!0,this.maxInboundStreams=h??qSe,this.maxOutboundStreams=p??zSe,this.routingTable=new i7({kBucketSize:t,lan:this.lan,pingTimeout:l,pingConcurrency:f,protocol:this.protocol}),this.providers=new p7,this.validators={...Qse,...i},this.selectors={...Zse,...s},this.network=new a7({protocol:this.protocol,lan:this.lan}),this.queryManager=new y7({disjointPaths:Math.ceil(this.kBucketSize/2),lan:a}),this.peerRouting=new d7({routingTable:this.routingTable,network:this.network,validators:this.validators,queryManager:this.queryManager,lan:this.lan}),this.contentFetching=new u7({validators:this.validators,selectors:this.selectors,peerRouting:this.peerRouting,queryManager:this.queryManager,routingTable:this.routingTable,network:this.network,lan:this.lan}),this.contentRouting=new f7({network:this.network,peerRouting:this.peerRouting,queryManager:this.queryManager,routingTable:this.routingTable,providers:this.providers,lan:this.lan}),this.routingTableRefresh=new o7({peerRouting:this.peerRouting,routingTable:this.routingTable,lan:this.lan}),this.rpc=new x7({routingTable:this.routingTable,providers:this.providers,peerRouting:this.peerRouting,validators:this.validators,lan:this.lan}),this.topologyListener=new T7({protocol:this.protocol,lan:this.lan}),this.querySelf=new I7({peerRouting:this.peerRouting,interval:o,lan:this.lan}),this.network.addEventListener("peer",d=>{let m=d.detail;this.onPeerConnect(m).catch(y=>{this.log.error("could not add %p to routing table",m.id,y)}),this.dispatchEvent(new ne("peer",{detail:m}))}),this.topologyListener.addEventListener("peer",d=>{let m=d.detail;Promise.resolve().then(async()=>{let y=await this.components.getPeerStore().addressBook.get(m),g={id:m,multiaddrs:y.map(w=>w.multiaddr),protocols:[]};await this.onPeerConnect(g)}).catch(y=>{this.log.error("could not add %p to routing table",m,y)})})}get[Xa](){return!0}get[Symbol.toStringTag](){return"@libp2p/kad-dht"}init(e){this.components=e,this.routingTable.init(e),this.providers.init(e),this.network.init(e),this.queryManager.init(e),this.peerRouting.init(e),this.contentFetching.init(e),this.contentRouting.init(e),this.routingTableRefresh.init(e),this.rpc.init(e),this.topologyListener.init(e),this.querySelf.init(e)}async onPeerConnect(e){if(this.log("peer %p connected with protocols %s",e.id,e.protocols),this.lan?e=m1(e):e=p1(e),e.multiaddrs.length===0){this.log("ignoring %p as they do not have any %s addresses in %s",e.id,this.lan?"private":"public",e.multiaddrs.map(t=>t.toString()));return}try{await this.routingTable.add(e.id)}catch(t){this.log.error("could not add %p to routing table",e.id,t)}}isStarted(){return this.running}async getMode(){return this.clientMode?"client":"server"}async setMode(e){await this.components.getRegistrar().unhandle(this.protocol),e==="client"?(this.log("enabling client mode"),this.clientMode=!0):(this.log("enabling server mode"),this.clientMode=!1,await this.components.getRegistrar().handle(this.protocol,this.rpc.onIncomingStream.bind(this.rpc),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams}))}async start(){this.running=!0,await this.setMode(this.clientMode?"client":"server"),await Promise.all([this.providers.start(),this.queryManager.start(),this.network.start(),this.routingTable.start(),this.topologyListener.start(),this.querySelf.start()]),await this.routingTableRefresh.start()}async stop(){this.running=!1,await Promise.all([this.providers.stop(),this.queryManager.stop(),this.network.stop(),this.routingTable.stop(),this.routingTableRefresh.stop(),this.topologyListener.stop(),this.querySelf.stop()])}async*put(e,t,n={}){yield*this.contentFetching.put(e,t,n)}async*get(e,t={}){yield*this.contentFetching.get(e,t)}async*provide(e,t={}){yield*this.contentRouting.provide(e,this.components.getAddressManager().getAddresses(),t)}async*findProviders(e,t={}){yield*this.contentRouting.findProviders(e,t)}async*findPeer(e,t={}){yield*this.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t={}){yield*this.peerRouting.getClosestPeers(e,t)}async refreshRoutingTable(){await this.routingTableRefresh.refreshTable(!0)}};u();var b1=E(V(),1),Td=E(Bc(),1);var $Se=C("libp2p:kad-dht"),A7=class extends We{constructor(e,t){super(),this.components=new je,this.wan=e,this.lan=t,this.wan.addEventListener("peer",n=>{this.dispatchEvent(new ne("peer",{detail:n.detail}))}),this.lan.addEventListener("peer",n=>{this.dispatchEvent(new ne("peer",{detail:n.detail}))})}get[Xa](){return!0}get[Symbol.toStringTag](){return"@libp2p/dual-kad-dht"}init(e){this.components=e,this.wan.init(e),this.lan.init(e)}isStarted(){return this.wan.isStarted()&&this.lan.isStarted()}async getMode(){return await this.wan.getMode()}async setMode(e){await this.wan.setMode(e)}async start(){await Promise.all([this.lan.start(),this.wan.start()])}async stop(){await Promise.all([this.lan.stop(),this.wan.stop()])}async*put(e,t,n={}){for await(let i of(0,Td.default)(this.lan.put(e,t,n),this.wan.put(e,t,n)))yield i}async*get(e,t={}){let n=!1,i=!1;for await(let s of(0,Td.default)(this.lan.get(e,t),this.wan.get(e,t)))yield s,s.name==="DIALING_PEER"&&(n=!0),s.name==="VALUE"&&(n=!0,s.value!=null&&(i=!0)),s.name==="SENDING_QUERY"&&(n=!0);if(!n)throw(0,b1.default)(new Error("No peers found in routing table!"),"ERR_NO_PEERS_IN_ROUTING_TABLE");i||(yield yi({from:this.components.getPeerId(),error:(0,b1.default)(new Error("Not found"),"ERR_NOT_FOUND")}))}async*provide(e,t={}){let n=0,i=0,s=[],o=[this.lan];await this.wan.getMode()==="server"&&o.push(this.wan);for await(let a of(0,Td.default)(...o.map(c=>c.provide(e,t))))yield a,a.name==="SENDING_QUERY"&&n++,a.name==="QUERY_ERROR"&&s.push(a.error),a.name==="PEER_RESPONSE"&&a.messageName==="ADD_PROVIDER"&&($Se("sent provider record for %s to %p",e,a.from),i++);if(i===0)throw s.length>0?(0,b1.default)(new Error(`Failed to provide to ${s.length} of ${n} peers`),"ERR_PROVIDES_FAILED",{errors:s}):(0,b1.default)(new Error("Failed to provide - no peers found"),"ERR_PROVIDES_FAILED")}async*findProviders(e,t={}){yield*(0,Td.default)(this.lan.findProviders(e,t),this.wan.findProviders(e,t))}async*findPeer(e,t={}){let n=!1;for await(let i of(0,Td.default)(this.lan.findPeer(e,t),this.wan.findPeer(e,t)))yield i,(i.name==="SENDING_QUERY"||i.name==="FINAL_PEER")&&(n=!0);if(!n)throw(0,b1.default)(new Error("Peer lookup failed"),"ERR_LOOKUP_FAILED")}async*getClosestPeers(e,t={}){yield*(0,Td.default)(this.lan.getClosestPeers(e,t),this.wan.getClosestPeers(e,t))}async refreshRoutingTable(){await Promise.all([this.lan.refreshRoutingTable(),this.wan.refreshRoutingTable()])}};var R7=class extends A7{constructor(e){super(new i3({protocolPrefix:"/ipfs",...e,lan:!1}),new i3({protocolPrefix:"/ipfs",...e,clientMode:!1,lan:!0}))}};u();var kP=C("libp2p:bootstrap"),s3=class extends We{constructor(e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.interval=e.interval??1e4,this.list=[];for(let t of e.list){if(!_4.matches(t)){kP.error("Invalid multiaddr");continue}let n=se(t),i=n.getPeerId();if(i==null){kP.error("Invalid bootstrap multiaddr without peer id");continue}let s={id:pe(i),multiaddrs:[n],protocols:[]};this.list.push(s)}}get[Xa](){return!0}get[Symbol.toStringTag](){return"@libp2p/bootstrap"}isStarted(){return Boolean(this.timer)}start(){this.timer==null&&(this.timer=setInterval(()=>this._discoverBootstrapPeers(),this.interval),kP("Starting bootstrap node discovery"),this._discoverBootstrapPeers())}_discoverBootstrapPeers(){this.timer!=null&&this.list.forEach(e=>{this.dispatchEvent(new ne("peer",{detail:e}))})}stop(){this.timer!=null&&clearInterval(this.timer),this.timer=void 0}};s3.tag="bootstrap";u();u();u();var _oe=WebSocket;u();u();var Ioe=E(xoe(),1);function Toe(r){return r instanceof ArrayBuffer||r?.constructor?.name==="ArrayBuffer"&&typeof r?.byteLength=="number"}var Aoe=r=>{r.binaryType="arraybuffer";let e=async()=>await new Promise((s,o)=>{if(n)return s();if(i!=null)return o(i);let a=f=>{r.removeEventListener("open",c),r.removeEventListener("error",l),f()},c=()=>a(s),l=f=>{a(()=>o(f.error??new Error(`connect ECONNREFUSED ${r.url}`)))};r.addEventListener("open",c),r.addEventListener("error",l)}),t=async function*(){let s=new Ioe.EventIterator(({push:o,stop:a,fail:c})=>{let l=h=>{let p=null;typeof h.data=="string"&&(p=z(h.data)),Toe(h.data)&&(p=new Uint8Array(h.data)),h.data instanceof Uint8Array&&(p=h.data),p!=null&&o(p)},f=h=>c(h.error??new Error("Socket error"));return r.addEventListener("message",l),r.addEventListener("error",f),r.addEventListener("close",a),()=>{r.removeEventListener("message",l),r.removeEventListener("error",f),r.removeEventListener("close",a)}},{highWaterMark:1/0});await e();for await(let o of s)yield Toe(o)?new Uint8Array(o):o}(),n=r.readyState===1,i;return r.addEventListener("open",()=>{n=!0,i=null}),r.addEventListener("close",()=>{n=!1,i=null}),r.addEventListener("error",s=>{n||(i=s.error??new Error(`connect ECONNREFUSED ${r.url}`))}),Object.assign(t,{connected:e})};u();u();var Roe=r=>{if(r.readyState>=2)throw new Error("socket closed");if(r.readyState!==1)return new Promise((e,t)=>{function n(){r.removeEventListener("open",i),r.removeEventListener("error",s)}function i(){n(),e()}function s(o){n(),t(o.error??new Error(`connect ECONNREFUSED ${r.url}`))}r.addEventListener("open",i),r.addEventListener("error",s)})};var Coe=(r,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let i of n){try{await Roe(r)}catch(s){if(s.message==="socket closed")break;throw s}r.send(i)}if(e.closeOnEnd!=null&&r.readyState<=1)return await new Promise((i,s)=>{r.addEventListener("close",o=>{if(o.wasClean||o.code===1006)i();else{let a=Object.assign(new Error("ws error"),{event:o});s(a)}}),setTimeout(()=>r.close())})});var Poe=(r,e)=>{e=e??{};let t=Aoe(r),n=e.remoteAddress,i=e.remotePort;if(r.url!=null)try{let o=new URL(r.url);n=o.hostname,i=parseInt(o.port,10)}catch{}if(n==null||i==null)throw new Error("Remote connection did not have address and/or port");return{sink:Coe(r,e),source:t,connected:async()=>await t.connected(),close:async()=>{(r.readyState===r.CONNECTING||r.readyState===r.OPEN)&&await new Promise(o=>{r.addEventListener("close",()=>{o()}),r.close()})},destroy:()=>{r.terminate!=null?r.terminate():r.close()},remoteAddress:n,remotePort:i,socket:r}};u();var Doe=E(x4(),1),GSe={http:"ws",https:"wss"},jSe="ws",Ooe=(r,e)=>(0,Doe.relative)(r,e,GSe,jSe);function koe(r,e){let t=typeof window>"u"?"":window.location;e=e??{};let n=Ooe(r,t.toString()),i=new _oe(n,e.websocket);return Poe(i,e)}u();function Noe(){throw new Error("WebSocket Servers can not be created in the browser!")}u();u();var Loe=C("libp2p:websockets:socket");function Boe(r,e,t){t=t??{};let n={async sink(i){t?.signal!=null&&(i=Kr(i,t.signal));try{await r.sink(i)}catch(s){s.type!=="aborted"&&Loe.error(s)}},source:t.signal!=null?Kr(r.source,t.signal):r.source,remoteAddr:e,timeline:{open:Date.now()},async close(){let i=Date.now();try{await H2(r.close(),{milliseconds:2e3})}catch{let{host:o,port:a}=n.remoteAddr.toOptions();Loe("timeout closing stream to %s:%s after %dms, destroying it manually",o,a,Date.now()-i),r.destroy()}finally{n.timeline.close=Date.now()}}};return r.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}u();function Foe(r){return r.filter(e=>{if(e.protoCodes().includes(290))return!1;let t=e.decapsulateCode(421);return Lf.matches(t)||Vl.matches(t)})}function Voe(r){return r.filter(e=>{if(e.protoCodes().includes(290))return!1;let t=e.decapsulateCode(421);return Vl.matches(t)&&Kl.matches(t.decapsulateCode(6).decapsulateCode(478))})}var Ef=C("libp2p:websockets"),D7=class{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[J0](){return!0}async dial(e,t){Ef("dialing %s",e),t=t??{};let n=await this._connect(e,t),i=Boe(n,e);Ef("new outbound connection %s",i.remoteAddr);let s=await t.upgrader.upgradeOutbound(i);return Ef("outbound connection %s upgraded",i.remoteAddr),s}async _connect(e,t){if(t?.signal?.aborted===!0)throw new ec;let n=e.toOptions();Ef("dialing %s:%s",n.host,n.port);let i=lr(),s=l=>{Ef.error("connection error:",l),i.reject(l)},o=koe(o0(e),this.init);if(o.socket.on!=null?o.socket.on("error",s):o.socket.onerror=s,t.signal==null)return await Promise.race([o.connected(),i.promise]),Ef("connected %s",e),o;let a,c=new Promise((l,f)=>{if(a=()=>{f(new ec),o.close().catch(h=>{Ef.error("error closing raw socket",h)})},t?.signal?.aborted===!0)return a();t?.signal?.addEventListener("abort",a)});try{await Promise.race([c,i.promise,o.connected()])}finally{a!=null&&t?.signal?.removeEventListener("abort",a)}return Ef("connected %s",e),o}createListener(e){return Noe({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):bd||_b?Voe(e):Foe(e)}};u();u();u();var v1=E(fa(),1);u();function BP(r){return new Uint8Array(r)}u();var ot;(function(r){r[r.NEW_STREAM=0]="NEW_STREAM",r[r.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",r[r.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",r[r.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",r[r.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",r[r.RESET_RECEIVER=5]="RESET_RECEIVER",r[r.RESET_INITIATOR=6]="RESET_INITIATOR"})(ot||(ot={}));var a3=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),MP=Object.freeze({NEW_STREAM:ot.NEW_STREAM,MESSAGE:ot.MESSAGE_INITIATOR,CLOSE:ot.CLOSE_INITIATOR,RESET:ot.RESET_INITIATOR}),Koe=Object.freeze({MESSAGE:ot.MESSAGE_RECEIVER,CLOSE:ot.CLOSE_RECEIVER,RESET:ot.RESET_RECEIVER});var UP=10*1024,FP=class{constructor(){this._pool=BP(UP),this._poolOffset=0}write(e){let t=this._pool,n=this._poolOffset;v1.default.encode(e.id<<3|e.type,t,n),n+=v1.default.encode.bytes,(e.type===ot.NEW_STREAM||e.type===ot.MESSAGE_INITIATOR||e.type===ot.MESSAGE_RECEIVER)&&e.data!=null?v1.default.encode(e.data.length,t,n):v1.default.encode(0,t,n),n+=v1.default.encode.bytes;let i=t.subarray(this._poolOffset,n);return UP-n<100?(this._pool=BP(UP),this._poolOffset=0):this._poolOffset=n,(e.type===ot.NEW_STREAM||e.type===ot.MESSAGE_INITIATOR||e.type===ot.MESSAGE_RECEIVER)&&e.data!=null?[i,...e.data instanceof Uint8Array?[e.data]:e.data]:[i]}},qoe=new FP;async function*zoe(r){for await(let e of r)if(Array.isArray(e))for(let t of e)yield*qoe.write(t);else yield*qoe.write(e)}u();var VP=class{constructor(){this._buffer=new Mt,this._headerInfo=null}write(e){if(e==null||e.length===0)return[];this._buffer.append(e);let t=[];for(;this._buffer.length!==0;){if(this._headerInfo==null)try{this._headerInfo=this._decodeHeader(this._buffer)}catch{break}let{id:n,type:i,length:s,offset:o}=this._headerInfo;if(this._buffer.length-o<s)break;let c={id:n,type:i};(i===ot.NEW_STREAM||i===ot.MESSAGE_INITIATOR||i===ot.MESSAGE_RECEIVER)&&(c.data=this._buffer.sublist(o,o+s)),t.push(c),this._buffer.consume(o+s),this._headerInfo=null}return t}_decodeHeader(e){let{value:t,offset:n}=Hoe(e),{value:i,offset:s}=Hoe(e,n),o=t&7;if(a3[o]==null)throw new Error(`Invalid type received: ${o}`);return{id:t>>3,type:o,offset:n+s,length:i}}},ZSe=128,$oe=127;function Hoe(r,e=0){let t=0,n=0,i=e,s,o=r.length;do{if(i>=o||n>49)throw e=0,new RangeError("Could not decode varint");s=r.get(i++),t+=n<28?(s&$oe)<<n:(s&$oe)*Math.pow(2,n),n+=7}while(s>=ZSe);return e=i-e,{value:t,offset:e}}async function*Goe(r){let e=new VP;for await(let t of r){let n=e.write(t);n.length>0&&(yield n)}}u();var KP=1<<20;function joe(r){let e=r??KP,t=n=>{if(!(n.type!==ot.NEW_STREAM&&n.type!==ot.MESSAGE_INITIATOR&&n.type!==ot.MESSAGE_RECEIVER)&&n.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return n=>async function*(){for await(let s of n)Array.isArray(s)?(s.forEach(t),yield*s):(t(s),yield s)}()}u();var O7=E(V(),1);var Woe=E(ai(),1);var Yo=C("libp2p:mplex:stream"),qP="ERR_STREAM_RESET",JSe="ERR_STREAM_ABORT",exe="ERR_SINK_ENDED",txe="ERR_DOUBLE_SINK";function Yoe(r){let{id:e,name:t,send:n,onEnd:i,type:s="initiator",maxMsgSize:o=KP}=r,a=new AbortController,c=new AbortController,l=new AbortController,f=s==="initiator"?MP:Koe,h=s==="initiator"?`i${e}`:`r${e}`,p=`${t??e}`,d=!1,m=!1,y=!1,g,w={open:Date.now()},b=T=>{d||(d=!0,Yo.trace("%s stream %s source end - err: %o",s,p,T),T!=null&&g==null&&(g=T),m&&(I.stat.timeline.close=Date.now(),i?.(g)))},S=T=>{m||(m=!0,Yo.trace("%s stream %s sink end - err: %o",s,p,T),T!=null&&g==null&&(g=T),d&&(w.close=Date.now(),i?.(g)))},_=ar({onEnd:b}),I={close:()=>{Yo.trace("%s stream %s close",s,p),I.closeRead(),I.closeWrite()},closeRead:()=>{Yo.trace("%s stream %s closeRead",s,p),!d&&_.end()},closeWrite:()=>{if(Yo.trace("%s stream %s closeWrite",s,p),!m){l.abort();try{n({id:e,type:f.CLOSE})}catch(T){Yo.trace("%s stream %s error sending close",s,t,T)}S()}},abort:T=>{Yo.trace("%s stream %s abort",s,p,T),_.end(T),a.abort(),S(T)},reset:()=>{let T=(0,O7.default)(new Error("stream reset"),qP);c.abort(),_.end(T),S(T)},sink:async T=>{if(y)throw(0,O7.default)(new Error("sink already called on stream"),txe);if(y=!0,m)throw(0,O7.default)(new Error("stream closed for writing"),exe);T=Kr(T,(0,Woe.anySignal)([a.signal,c.signal,l.signal]));try{s==="initiator"&&n({id:e,type:MP.NEW_STREAM,data:new Mt(z(p))});let x=new Mt;for await(let P of T)if(P.length<=o)n({id:e,type:f.MESSAGE,data:P instanceof Mt?P:new Mt(P)});else for(x.append(P);x.length!==0;){if(x.length<=o){n({id:e,type:f.MESSAGE,data:x.sublist()}),x.consume(x.length);break}n({id:e,type:f.MESSAGE,data:x.sublist(0,o)}),x.consume(o)}}catch(x){if(x.type==="aborted"&&x.message==="The operation was aborted"){if(l.signal.aborted)return;c.signal.aborted&&(x.message="stream reset",x.code=qP),a.signal.aborted&&(x.message="stream aborted",x.code=JSe)}if(x.code===qP)Yo.trace("%s stream %s reset",s,t);else{Yo.trace("%s stream %s error",s,t,x);try{n({id:e,type:f.RESET})}catch(P){Yo.trace("%s stream %s error sending reset",s,t,P)}}_.end(x),S(x);return}try{n({id:e,type:f.CLOSE})}catch(x){Yo.trace("%s stream %s error sending close",s,t,x)}S()},source:_,sourcePush:T=>{_.push(T)},sourceReadableLength(){return _.readableLength},stat:{direction:s==="initiator"?"outbound":"inbound",timeline:w},metadata:{},id:h};return I}var rD=E(V(),1),Gae=E($ae(),1),jae=E(ai(),1),Qo=C("libp2p:mplex"),Mxe=1024,Uxe=1024,Fxe=1024*1024*4,Vxe=5;function Hae(r){let e={...r,type:`${a3[r.type]} (${r.type})`};return r.type===ot.NEW_STREAM&&(e.data=K(r.data instanceof Uint8Array?r.data:r.data.subarray())),(r.type===ot.MESSAGE_INITIATOR||r.type===ot.MESSAGE_RECEIVER)&&(e.data=K(r.data instanceof Uint8Array?r.data:r.data.subarray(),"base16")),e}var N7=class{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:ii({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:ii({metrics:e.getMetrics(),component:"mplex",metric:"receiverStreams"})},this._init=t,this.sink=this._createSink();let n=this._createSource();this._source=n,this.source=n,this.closeController=new AbortController,this.rateLimiter=new Gae.RateLimiterMemory({points:t.disconnectThreshold??Vxe,duration:1})}init(e){}get streams(){let e=[];for(let t of this._streams.initiators.values())e.push(t);for(let t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");let t=this._streamId++;e=e==null?t.toString():e.toString();let n=this._streams.initiators;return this._newStream({id:t,name:e,type:"initiator",registry:n})}close(e){this.closeController.signal.aborted||(e!=null?this.streams.forEach(t=>t.abort(e)):this.streams.forEach(t=>t.close()),this.closeController.abort())}_newReceiverStream(e){let{id:t,name:n}=e,i=this._streams.receivers;return this._newStream({id:t,name:n,type:"receiver",registry:i})}_newStream(e){let{id:t,name:n,type:i,registry:s}=e;if(Qo("new %s stream %s %s",i,t),i==="initiator"&&this._streams.initiators.size===(this._init.maxOutboundStreams??Uxe))throw(0,rD.default)(new Error("Too many outbound streams open"),"ERR_TOO_MANY_OUTBOUND_STREAMS");if(s.has(t))throw new Error(`${i} stream ${t} already exists!`);let c=Yoe({id:t,name:n,send:l=>{Qo.enabled&&Qo.trace("%s stream %s send",i,t,Hae(l)),this._source.push(l)},type:i,onEnd:()=>{Qo("%s stream with id %s and protocol %s ended",i,t,c.stat.protocol),s.delete(t),this._init.onStreamEnd!=null&&this._init.onStreamEnd(c)},maxMsgSize:this._init.maxMsgSize});return s.set(t,c),c}_createSink(){return async t=>{let n=[this.closeController.signal];this._init.signal!=null&&n.push(this._init.signal),t=Kr(t,(0,jae.default)(n));try{await we(t,Goe,joe(this._init.maxMsgSize),async i=>{for await(let s of i)await this._handleIncoming(s)}),this._source.end()}catch(i){Qo("error in sink",i),this._source.end(i)}}}_createSource(){let t=fK({objectMode:!0,onEnd:n=>{this.close(n)}});return Object.assign(zoe(t),{push:t.push,end:t.end,return:t.return})}async _handleIncoming(e){let{id:t,type:n}=e;if(Qo.enabled&&Qo.trace("incoming message",Hae(e)),e.type===ot.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??Mxe)){Qo("too many inbound streams open"),this._source.push({id:t,type:ot.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{Qo("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),this._source.end(new Error("Too many open streams"));return}return}let a=this._newReceiverStream({id:t,name:K(e.data instanceof Uint8Array?e.data:e.data.subarray())});this._init.onIncomingStream!=null&&this._init.onIncomingStream(a);return}let s=((n&1)===1?this._streams.initiators:this._streams.receivers).get(t);if(s==null){Qo("missing stream %s for message type %s",t,a3[n]);return}let o=this._init.maxStreamBufferSize??Fxe;switch(n){case ot.MESSAGE_INITIATOR:case ot.MESSAGE_RECEIVER:if(s.sourceReadableLength()>o){this._source.push({id:e.id,type:n===ot.MESSAGE_INITIATOR?ot.RESET_RECEIVER:ot.RESET_INITIATOR});let a=(0,rD.default)(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");s.abort(a);return}s.sourcePush(e.data);break;case ot.CLOSE_INITIATOR:case ot.CLOSE_RECEIVER:s.closeRead();break;case ot.RESET_INITIATOR:case ot.RESET_RECEIVER:s.reset();break;default:Qo("unknown message type %s",n)}}};var L7=class{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new je,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new N7(this.components,{...e,...this._init})}};u();u();u();var Rce=E(ece(),1),A1=E(wce(),1),Y7=E(bce(),1),wD=E(Ace(),1),Cce={hashSHA256(r){return(0,Y7.hash)(r)},getHKDF(r,e){let i=new Rce.HKDF(Y7.SHA256,e,r).expand(96),s=i.subarray(0,32),o=i.subarray(32,64),a=i.subarray(64,96);return[s,o,a]},generateX25519KeyPair(){let r=A1.generateKeyPair();return{publicKey:r.publicKey,privateKey:r.secretKey}},generateX25519KeyPairFromSeed(r){let e=A1.generateKeyPairFromSeed(r);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey(r,e){return A1.sharedKey(r,e)},chaCha20Poly1305Encrypt(r,e,t,n){return new wD.ChaCha20Poly1305(n).seal(e,r,t)},chaCha20Poly1305Decrypt(r,e,t,n){return new wD.ChaCha20Poly1305(n).open(e,r,t)}};u();u();function ED(r,e={}){let t=ff(r),n=yr.fromReader(t.reader,e),i={read:async s=>{let{value:o}=await t.reader.next(s);if(o==null)throw new Error("Value is null");return o},readLP:async()=>{let{value:s}=await n.next();if(s==null)throw new Error("Value is null");return s},readPB:async s=>{let o=await i.readLP();if(o==null)throw new Error("Value is null");let a=o instanceof Uint8Array?o:o.slice();return s.decode(a)},write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(mr.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>({read:async()=>await i.readPB(s),write:o=>i.writePB(o,s)}),unwrap:()=>(t.rest(),t.stream)};return i}u();u();function bD(){let r=lr(),e=!1;return{sink:async t=>{if(e)throw new Error("already piped");e=!0,r.resolve(t)},source:async function*(){yield*await r.promise}()}}function Pce(){let r=bD(),e=bD();return[{source:r.source,sink:e.sink},{source:e.source,sink:r.sink}]}u();var Dce=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);u();function kce(r){return async function*(e){for await(let t of e)for(let n=0;n<t.length;n+=65519){let i=n+65519;i>t.length&&(i=t.length),yield r.encrypt(t.subarray(n,i),r.session)}}}function Nce(r){return async function*(e){for await(let t of e)for(let n=0;n<t.length;n+=65535){let i=n+65535;i>t.length&&(i=t.length);let{plaintext:s,valid:o}=await r.decrypt(t.subarray(n,i),r.session);if(!o)throw new Error("Failed to validate decrypted chunk");yield s}}}u();Mr();var YTe=r=>globalThis.Buffer?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r),y3=r=>{let e=YTe(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(0,r,!1),e};y3.bytes=2;var g3=r=>{if(r.length<2)throw RangeError("Could not decode int16BE");return r instanceof Uint8Array?new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,!1):r.getUint16(0)};g3.bytes=2;function Lce(r){return Le([r.ne,r.ciphertext],r.ne.length+r.ciphertext.length)}function Bce(r){return Le([r.ne,r.ns,r.ciphertext],r.ne.length+r.ns.length+r.ciphertext.length)}function Mce(r){return Le([r.ns,r.ciphertext],r.ns.length+r.ciphertext.length)}function Uce(r){if(r.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:r.subarray(0,32),ciphertext:r.subarray(32,r.length),ns:new Uint8Array(0)}}function Fce(r){if(r.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:r.subarray(0,32),ns:r.subarray(32,80),ciphertext:r.subarray(80,r.length)}}function Vce(r){if(r.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:r.subarray(0,48),ciphertext:r.subarray(48,r.length)}}u();u();var Id=class extends Error{constructor(e="Unexpected Peer"){super(e),this.code=Id.code}static get code(){return"ERR_UNEXPECTED_PEER"}},Rl=class extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Rl.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}};u();u();Mr();u();var Q7;(function(r){let e;(function(t){let n;t.codec=()=>(n==null&&(n=Et((i,s,o={})=>{if(o.lengthDelimited!==!1&&s.fork(),i.identityKey!=null)s.uint32(10),s.bytes(i.identityKey);else throw new Error('Protocol error: required field "identityKey" was not found in object');if(i.identitySig!=null)s.uint32(18),s.bytes(i.identitySig);else throw new Error('Protocol error: required field "identitySig" was not found in object');if(i.data!=null)s.uint32(26),s.bytes(i.data);else throw new Error('Protocol error: required field "data" was not found in object');o.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0),data:new Uint8Array(0)},a=s==null?i.len:i.pos+s;for(;i.pos<a;){let c=i.uint32();switch(c>>>3){case 1:o.identityKey=i.bytes();break;case 2:o.identitySig=i.bytes();break;case 3:o.data=i.bytes();break;default:i.skipType(c&7);break}}if(o.identityKey==null)throw new Error('Protocol error: value for required field "identityKey" was not found in protobuf');if(o.identitySig==null)throw new Error('Protocol error: value for required field "identitySig" was not found in protobuf');if(o.data==null)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),n),t.encode=i=>wt(i,t.codec()),t.decode=i=>gt(i,t.codec())})(e=r.NoiseHandshakePayload||(r.NoiseHandshakePayload={}))})(Q7||(Q7={}));var Kce=Q7.NoiseHandshakePayload;async function qce(r,e,t){let n=await XTe(r,zce(e)),i=t??new Uint8Array(0);if(r.publicKey==null)throw new Error("PublicKey was missing from local PeerId");return QTe(r.publicKey,n,i)}function QTe(r,e,t){return Kce.encode({identityKey:r,identitySig:e,data:t??new Uint8Array(0)}).subarray()}async function XTe(r,e){if(r.privateKey==null)throw new Error("PrivateKey was missing from PeerId");return await(await kn(r.privateKey)).sign(e)}async function vD(r){return await ln(r.identityKey)}function _D(r){return Kce.decode(r)}function zce(r){let e=z("noise-libp2p-static-key:");return Le([e,r],e.length+r.length)}async function SD(r,e,t){let n=await ln(e.identityKey);if(!n.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");let i=zce(r);if(n.publicKey==null)throw new Error("PublicKey was missing from PeerId");if(e.identitySig==null)throw new Error("Signature was missing from message");if(!await Ti(n.publicKey).verify(i,e.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return n}function w3(r){return!(!(r instanceof Uint8Array)||r.length!==32)}u();Mr();u();var Mn=C("libp2p:noise");var ro;Dce?ro=Mn:ro=Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});function $ce(r){ro(`LOCAL_STATIC_PUBLIC_KEY ${K(r.publicKey,"hex")}`),ro(`LOCAL_STATIC_PRIVATE_KEY ${K(r.privateKey,"hex")}`)}function xD(r){r?(ro(`LOCAL_PUBLIC_EPHEMERAL_KEY ${K(r.publicKey,"hex")}`),ro(`LOCAL_PRIVATE_EPHEMERAL_KEY ${K(r.privateKey,"hex")}`)):ro("Missing local ephemeral keys.")}function Hce(r){ro(`REMOTE_STATIC_PUBLIC_KEY ${K(r,"hex")}`)}function TD(r){ro(`REMOTE_EPHEMERAL_PUBLIC_KEY ${K(r,"hex")}`)}function Gce(r){r.cs1&&r.cs2?(ro(`CIPHER_STATE_1 ${r.cs1.n.getUint64()} ${K(r.cs1.k,"hex")}`),ro(`CIPHER_STATE_2 ${r.cs2.n.getUint64()} ${K(r.cs2.k,"hex")}`)):ro("Missing cipher state.")}u();var ZTe="Cipherstate has reached maximum n, a new handshake must be performed",X7=class{constructor(e=0){this.n=e,this.bytes=new Uint8Array(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(ZTe)}};var Z7=class{constructor(e){this.crypto=e}encryptWithAd(e,t,n){let i=this.encrypt(e.k,e.n,t,n);return e.n.increment(),i}decryptWithAd(e,t,n){let{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,n);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){let t=this.createEmptyKey();return ze(t,e)}encrypt(e,t,n,i){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(i,t.getBytes(),n,e)}encryptAndHash(e,t){let n;return this.hasKey(e.cs)?n=this.encryptWithAd(e.cs,e.h,t):n=t,this.mixHash(e,n),n}decrypt(e,t,n,i){t.assertValue();let s=this.crypto.chaCha20Poly1305Decrypt(i,t.getBytes(),n,e);return s?{plaintext:s,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(e,t){let n,i=!0;return this.hasKey(e.cs)?{plaintext:n,valid:i}=this.decryptWithAd(e.cs,e.h,t):n=t,this.mixHash(e,t),{plaintext:n,valid:i}}dh(e,t){try{let n=this.crypto.generateX25519SharedKey(e,t);return n.length===32?n:n.subarray(0,32)}catch(n){return Mn(n.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(Le([e,t],e.length+t.length))}mixKey(e,t){let[n,i]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(i),e.ck=n}initializeKey(e){return{k:e,n:new X7}}initializeSymmetric(e){let t=z(e,"utf-8"),n=this.hashProtocolName(t),i=n,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:i,h:n}}hashProtocolName(e){if(e.length<=32){let t=new Uint8Array(32);return t.set(e),t}else return this.getHash(e,new Uint8Array(0))}split(e){let[t,n]=this.crypto.getHKDF(e.ck,new Uint8Array(0)),i=this.initializeKey(t),s=this.initializeKey(n);return{cs1:i,cs2:s}}writeMessageRegular(e,t){let n=this.encryptWithAd(e,new Uint8Array(0),t),i=this.createEmptyKey(),s=new Uint8Array(0);return{ne:i,ns:s,ciphertext:n}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}};var J7=class extends Z7{initializeInitiator(e,t,n,i){let s="Noise_XX_25519_ChaChaPoly_SHA256",o=this.initializeSymmetric(s);this.mixHash(o,e);let a=new Uint8Array(32);return{ss:o,s:t,rs:n,psk:i,re:a}}initializeResponder(e,t,n,i){let s="Noise_XX_25519_ChaChaPoly_SHA256",o=this.initializeSymmetric(s);this.mixHash(o,e);let a=new Uint8Array(32);return{ss:o,s:t,rs:n,psk:i,re:a}}writeMessageA(e,t,n){let i=new Uint8Array(0);n!==void 0?e.e=n:e.e=this.crypto.generateX25519KeyPair();let s=e.e.publicKey;this.mixHash(e.ss,s);let o=this.encryptAndHash(e.ss,t);return{ne:s,ns:i,ciphertext:o}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();let n=e.e.publicKey;this.mixHash(e.ss,n),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));let i=e.s.publicKey,s=this.encryptAndHash(e.ss,i);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));let o=this.encryptAndHash(e.ss,t);return{ne:n,ns:s,ciphertext:o}}writeMessageC(e,t){let n=e.s.publicKey,i=this.encryptAndHash(e.ss,n);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));let s=this.encryptAndHash(e.ss,t),a={ne:this.createEmptyKey(),ns:i,ciphertext:s},{cs1:c,cs2:l}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:c,cs2:l}}readMessageA(e,t){return w3(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(w3(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));let{plaintext:n,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&w3(n)&&(e.rs=n),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));let{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageC(e,t){let{plaintext:n,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&w3(n)&&(e.rs=n),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));let{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:c}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:c}}initSession(e,t,n){let i=this.createEmptyKey(),s=new Uint8Array(32),o;return e?o=this.initializeInitiator(t,n,s,i):o=this.initializeResponder(t,n,s,i),{hs:o,i:e,mc:0}}sendMessage(e,t,n){let i;if(e.mc===0)i=this.writeMessageA(e.hs,t,n);else if(e.mc===1)i=this.writeMessageB(e.hs,t);else if(e.mc===2){let{h:s,messageBuffer:o,cs1:a,cs2:c}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=c}else if(e.mc>2)if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}else throw new Error("Session invalid.");return e.mc++,i}recvMessage(e,t){let n=new Uint8Array(0),i=!1;if(e.mc===0)({plaintext:n,valid:i}=this.readMessageA(e.hs,t));else if(e.mc===1)({plaintext:n,valid:i}=this.readMessageB(e.hs,t));else if(e.mc===2){let{h:s,plaintext:o,valid:a,cs1:c,cs2:l}=this.readMessageC(e.hs,t);n=o,i=a,e.h=s,e.cs1=c,e.cs2=l}return e.mc++,{plaintext:n,valid:i}}};var ev=class{constructor(e,t,n,i,s,o,a,c){this.isInitiator=e,this.payload=t,this.prologue=n,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=c??new J7(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}async propose(){if($ce(this.session.hs.s),this.isInitiator){Mn("Stage 0 - Initiator starting to send first message.");let e=this.xx.sendMessage(this.session,new Uint8Array(0));this.connection.writeLP(Lce(e)),Mn("Stage 0 - Initiator finished sending first message."),xD(this.session.hs.e)}else{Mn("Stage 0 - Responder waiting to receive first message...");let e=Uce((await this.connection.readLP()).subarray()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new Rl("xx handshake stage 0 validation fail");Mn("Stage 0 - Responder received first message."),TD(this.session.hs.re)}}async exchange(){if(this.isInitiator){Mn("Stage 1 - Initiator waiting to receive first message from responder...");let e=Fce((await this.connection.readLP()).subarray()),{plaintext:t,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new Rl("xx handshake stage 1 validation fail");Mn("Stage 1 - Initiator received the message."),TD(this.session.hs.re),Hce(this.session.hs.rs),Mn("Initiator going to check remote's signature...");try{let i=_D(t);this.remotePeer=this.remotePeer||await vD(i),await SD(this.session.hs.rs,i,this.remotePeer),this.setRemoteEarlyData(i.data)}catch(i){let s=i;throw new Id(`Error occurred while verifying signed payload: ${s.message}`)}Mn("All good with the signature!")}else{Mn("Stage 1 - Responder sending out first message with signed payload and static key.");let e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(Bce(e)),Mn("Stage 1 - Responder sent the second handshake message with signed payload."),xD(this.session.hs.e)}}async finish(){if(this.isInitiator){Mn("Stage 2 - Initiator sending third handshake message.");let e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(Mce(e)),Mn("Stage 2 - Initiator sent message with signed payload.")}else{Mn("Stage 2 - Responder waiting for third handshake message...");let e=Vce((await this.connection.readLP()).subarray()),{plaintext:t,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new Rl("xx handshake stage 2 validation fail");Mn("Stage 2 - Responder received the message, finished handshake.");try{let i=_D(t);this.remotePeer=this.remotePeer||await vD(i),await SD(this.session.hs.rs,i,this.remotePeer),this.setRemoteEarlyData(i.data)}catch(i){let s=i;throw new Id(`Error occurred while verifying signed payload: ${s.message}`)}}Gce(this.session)}encrypt(e,t){let n=this.getCS(t);return this.xx.encryptWithAd(n,new Uint8Array(0),e)}decrypt(e,t){let n=this.getCS(t,!1);return this.xx.decryptWithAd(n,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Rl("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}};var tv=class{constructor(e,t,n=Cce,i){this.protocol="/noise",this.earlyData=t??new Uint8Array(0),this.crypto=n,e?this.staticKeys=this.crypto.generateX25519KeyPairFromSeed(e):this.staticKeys=this.crypto.generateX25519KeyPair(),this.prologue=i??new Uint8Array(0)}async secureOutbound(e,t,n){let i=ED(t,{lengthEncoder:y3,lengthDecoder:g3,maxDataLength:65535}),s=await this.performHandshake({connection:i,isInitiator:!0,localPeer:e,remotePeer:n});return{conn:await this.createSecureConnection(i,s),remoteEarlyData:s.remoteEarlyData,remotePeer:s.remotePeer}}async secureInbound(e,t,n){let i=ED(t,{lengthEncoder:y3,lengthDecoder:g3,maxDataLength:65535}),s=await this.performHandshake({connection:i,isInitiator:!1,localPeer:e,remotePeer:n});return{conn:await this.createSecureConnection(i,s),remoteEarlyData:s.remoteEarlyData,remotePeer:s.remotePeer}}async performHandshake(e){let t=await qce(e.localPeer,this.staticKeys.publicKey,this.earlyData);return await this.performXXHandshake(e,t)}async performXXHandshake(e,t){let{isInitiator:n,remotePeer:i,connection:s}=e,o=new ev(n,t,this.prologue,this.crypto,this.staticKeys,s,i);try{await o.propose(),await o.exchange(),await o.finish()}catch(a){if(a instanceof Error)throw a.message=`Error occurred during XX handshake: ${a.message}`,a}return o}async createSecureConnection(e,t){let[n,i]=Pce(),s=e.unwrap();return await we(n,kce(t),mr({lengthEncoder:y3}),s,yr({lengthDecoder:g3}),Nce(t),n),i}};var JTe=Qe.bind({ignoreUndefined:!0,concatArrays:!0});function E3({options:r={},peerId:e,multiaddrs:t=[],repo:n,keychainConfig:i={},config:s={}}){let{datastore:o}=n,a=eIe({options:r,config:s,datastore:o,keychainConfig:i,peerId:e,multiaddrs:t});return typeof r.libp2p=="function"?r.libp2p({libp2pOptions:a,options:r,config:s,datastore:o,peerId:e}):lse(a)}function eIe({options:r,config:e,datastore:t,keychainConfig:n,peerId:i,multiaddrs:s}){let o=()=>{let d=(0,Ht.default)(e,"Pubsub.Router")||"gossipsub",m=GX();if(!m[d])throw(0,jce.default)(new Error(`Router unavailable. Configure libp2p.modules.pubsub to use the ${d} router.`),"ERR_NOT_SUPPORTED");return m[d]},a={datastore:t,peerId:i},c={addresses:{listen:s.map(d=>d.toString()),announce:(0,Ht.default)(r,"addresses.announce",(0,Ht.default)(e,"Addresses.Announce",[])),noAnnounce:(0,Ht.default)(r,"addresses.noAnnounce",(0,Ht.default)(e,"Addresses.NoAnnounce",[]))},connectionManager:(0,Ht.default)(r,"connectionManager",{maxConnections:(0,Ht.default)(r,"config.Swarm.ConnMgr.HighWater",(0,Ht.default)(e,"Swarm.ConnMgr.HighWater")),minConnections:(0,Ht.default)(r,"config.Swarm.ConnMgr.LowWater",(0,Ht.default)(e,"Swarm.ConnMgr.LowWater"))}),keychain:n,identify:{host:{agentVersion:`js-ipfs/${yh}`}},contentRouters:[],peerRouters:[],peerDiscovery:[],transports:[],streamMuxers:[new L7({maxInboundStreams:256,maxOutboundStreams:1024})],connectionEncryption:[new tv],relay:{enabled:(0,Ht.default)(r,"relay.enabled",(0,Ht.default)(e,"relay.enabled",!0)),hop:{enabled:(0,Ht.default)(r,"relay.hop.enabled",(0,Ht.default)(e,"relay.hop.enabled",!1)),active:(0,Ht.default)(r,"relay.hop.active",(0,Ht.default)(e,"relay.hop.active",!1))}},nat:{enabled:!(0,Ht.default)(e,"Swarm.DisableNatPortMap",!1)}};(0,Ht.default)(r,"config.Pubsub.Enabled",(0,Ht.default)(e,"Pubsub.Enabled",!0))&&(c.pubsub=o()),(0,Ht.default)(e,"Routing.Type","dhtclient")!=="none"&&(c.dht=new R7({clientMode:(0,Ht.default)(e,"Routing.Type","dht")!=="dhtserver",kBucketSize:(0,Ht.default)(r,"dht.kBucketSize",20),validators:{ipns:Fp},selectors:{ipns:Jw}}));let l=(0,Ht.default)(r,"config.Bootstrap",(0,Ht.default)(e,"Bootstrap",[]));l.length>0&&c.peerDiscovery?.push(new s3({list:l}));let f=(0,Ht.default)(r,"libp2p",void 0);typeof f=="function"&&(f=void 0);let h=JTe(a,ore(),c,f),p=(0,Ht.default)(r,"config.Addresses.Delegates",(0,Ht.default)(e,"Addresses.Delegates",[]));if(p.length>0){let d=p[Math.floor(Math.random()*p.length)],m=se(d).toOptions(),y={host:m.host,protocol:parseInt(m.port)===443?"https":"http",port:m.port},g=pte(y);h.contentRouters?.push(new aE(g)),h.peerRouters?.push(new Z8(g))}return(0,Ht.default)(r,"config.Discovery.MDNS.Enabled",(0,Ht.default)(e,"Discovery.MDNS.Enabled",!0))||(h.peerDiscovery=h.peerDiscovery?.filter(d=>d!=null&&d[Symbol.toStringTag]!=="@libp2p/mdns")),h.transports==null&&(h.transports=[]),h.transports.find(d=>d[Symbol.toStringTag]==="@libp2p/websockets")==null&&h.transports.push(new D7),h}var ID=E(V(),1);var Yce=Qe.bind({ignoreUndefined:!0}),b3=C("ipfs:components:peer:storage"),R1=class{constructor(e,t,n,i,s){this.print=i,this.peerId=e,this.keychain=t,this.repo=n,this.print=i,this.isNew=s}static async start(e,t,n){let{repoAutoMigrate:i,repo:s,onMigrationProgress:o}=n,a=typeof s=="string"||s==null?RQ(e,t,{path:s,autoMigrate:i,onMigrationProgress:o}):s,{peerId:c,keychain:l,isNew:f}=await tIe(e,a,n);return new R1(c,l,a,e,f)}},tIe=async(r,e,t)=>{if(!e.closed)return{...await Wce(e,t),isNew:!1};try{return await e.open(),{...await Wce(e,t),isNew:!1}}catch(n){if(n.code!==Oh)throw n;if(t.init&&t.init.allowNew===!1)throw new fo("Initialization of new repos disabled by config, pass `config.init.isNew: true` to enable it");return{...await rIe(r,e,t),isNew:!0}}},rIe=async(r,e,t)=>{let n=t.init||{},i=await e.exists();if(b3("repo exists?",i),i===!0)throw new Error("repo already exists");let s=n.privateKey?await nIe(n.privateKey):await iIe(r,n),o=sIe(s);b3("peer identity: %s",o.PeerID);let a={...Yce(Qce(Mc(),n.profiles),t.config),Identity:o};await e.init(a),await e.open(),b3("repo opened");let c={pass:t.pass};try{c.dek=await e.config.get("Keychain.DEK")}catch(f){if(f.code!=="ERR_NOT_FOUND")throw f}let l=await E3({options:void 0,multiaddrs:void 0,peerId:s,repo:e,config:a,keychainConfig:c});return await e.datastore.has(new fe("/info/self"))||await l.keychain.importPeer("self",s),await e.config.set("Keychain",{DEK:l.keychain.init.dek}),{peerId:s,keychain:l.keychain}},nIe=async r=>{if(b3("using user-supplied private-key"),Rs(r))return r;let e=z(r,"base64pad"),t=await kn(e);return await ln(t.public.bytes,t.bytes)},iIe=(r,{algorithm:e="Ed25519",bits:t=2048})=>{if(r("generating %s keypair...",e),e==="Ed25519")return $b();if(e==="RSA")return zie({bits:t});throw(0,ID.default)(new Error("Unknown PeerId algorithm"),"ERR_UNKNOWN_PEER_ID_ALGORITHM")},sIe=r=>{if(r.privateKey==null)throw(0,ID.default)(new Error("Private key missing"),"ERR_MISSING_PRIVATE_KEY");return{PeerID:r.toString(),PrivKey:K(r.privateKey,"base64pad")}},Wce=async(r,e)=>{let t=e.config,n=e.init&&e.init.profiles||[],i=e.pass,s=await r.config.getAll(),o=oIe(Qce(s,n),t);if(s!==o&&await r.config.replace(o),!o.Identity||!o.Identity.PrivKey)throw new yc("No private key was found in the config, please intialize the repo");let a=z(o.Identity.PrivKey,"base64pad"),c=await kn(a),l=await ln(c.public.bytes,c.bytes),f=await E3({options:void 0,multiaddrs:void 0,peerId:l,repo:r,config:o,keychainConfig:{pass:i,...o.Keychain}});return{peerId:l,keychain:f.keychain}},oIe=(r,e)=>e?Yce(r,e):r,Qce=(r,e)=>(e||[]).reduce((t,n)=>{let i=n0[n];if(!i)throw new Error(`Could not find profile with name '${n}'`);return b3("applying profile %s",n),i.transform(t)},r);u();u();u();u();u();var dle=E(ule(),1);u();var v3=E(fa(),1);function bIe(r){let e=new Uint8Array(r.reduce((n,i)=>n+v3.default.encodingLength(i),0)),t=0;for(let n of r)e=v3.encode(n,e,t),t+=v3.default.encodingLength(n);return e}var fle=bIe;u();var RD=E(Li(),1);u();u();u();var _3=class{constructor(e,t,n){this._refCounter=1,this.cid=e,this.priority=t||1,this.wantType=n}inc(){this._refCounter+=1}dec(){this._refCounter=Math.max(0,this._refCounter-1)}hasRefs(){return this._refCounter>0}get[Symbol.toStringTag](){return`WantlistEntry <key: ${this.cid.toString(Ue)}, priority: ${this.priority}, refs: ${this._refCounter}>`}equals(e){return this._refCounter===e._refCounter&&this.cid.equals(e.cid)&&this.priority===e.priority&&this.wantType===e.wantType}};u();var Xo=E(ca(),1),oc=Xo.default.Reader,S3=Xo.default.Writer,Vt=Xo.default.util,Dt=Xo.default.roots["ipfs-bitswap"]||(Xo.default.roots["ipfs-bitswap"]={}),bs=Dt.Message=(()=>{function r(e){if(this.blocks=[],this.payload=[],this.blockPresences=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)e[t[n]]!=null&&(this[t[n]]=e[t[n]])}return r.prototype.wantlist=null,r.prototype.blocks=Vt.emptyArray,r.prototype.payload=Vt.emptyArray,r.prototype.blockPresences=Vt.emptyArray,r.prototype.pendingBytes=0,r.encode=function(t,n){if(n||(n=S3.create()),t.wantlist!=null&&Object.hasOwnProperty.call(t,"wantlist")&&Dt.Message.Wantlist.encode(t.wantlist,n.uint32(10).fork()).ldelim(),t.blocks!=null&&t.blocks.length)for(var i=0;i<t.blocks.length;++i)n.uint32(18).bytes(t.blocks[i]);if(t.payload!=null&&t.payload.length)for(var i=0;i<t.payload.length;++i)Dt.Message.Block.encode(t.payload[i],n.uint32(26).fork()).ldelim();if(t.blockPresences!=null&&t.blockPresences.length)for(var i=0;i<t.blockPresences.length;++i)Dt.Message.BlockPresence.encode(t.blockPresences[i],n.uint32(34).fork()).ldelim();return t.pendingBytes!=null&&Object.hasOwnProperty.call(t,"pendingBytes")&&n.uint32(40).int32(t.pendingBytes),n},r.decode=function(t,n){t instanceof oc||(t=oc.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Dt.Message;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:{s.wantlist=Dt.Message.Wantlist.decode(t,t.uint32());break}case 2:{s.blocks&&s.blocks.length||(s.blocks=[]),s.blocks.push(t.bytes());break}case 3:{s.payload&&s.payload.length||(s.payload=[]),s.payload.push(Dt.Message.Block.decode(t,t.uint32()));break}case 4:{s.blockPresences&&s.blockPresences.length||(s.blockPresences=[]),s.blockPresences.push(Dt.Message.BlockPresence.decode(t,t.uint32()));break}case 5:{s.pendingBytes=t.int32();break}default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof Dt.Message)return t;var n=new Dt.Message;if(t.wantlist!=null){if(typeof t.wantlist!="object")throw TypeError(".Message.wantlist: object expected");n.wantlist=Dt.Message.Wantlist.fromObject(t.wantlist)}if(t.blocks){if(!Array.isArray(t.blocks))throw TypeError(".Message.blocks: array expected");n.blocks=[];for(var i=0;i<t.blocks.length;++i)typeof t.blocks[i]=="string"?Vt.base64.decode(t.blocks[i],n.blocks[i]=Vt.newBuffer(Vt.base64.length(t.blocks[i])),0):t.blocks[i].length>=0&&(n.blocks[i]=t.blocks[i])}if(t.payload){if(!Array.isArray(t.payload))throw TypeError(".Message.payload: array expected");n.payload=[];for(var i=0;i<t.payload.length;++i){if(typeof t.payload[i]!="object")throw TypeError(".Message.payload: object expected");n.payload[i]=Dt.Message.Block.fromObject(t.payload[i])}}if(t.blockPresences){if(!Array.isArray(t.blockPresences))throw TypeError(".Message.blockPresences: array expected");n.blockPresences=[];for(var i=0;i<t.blockPresences.length;++i){if(typeof t.blockPresences[i]!="object")throw TypeError(".Message.blockPresences: object expected");n.blockPresences[i]=Dt.Message.BlockPresence.fromObject(t.blockPresences[i])}}return t.pendingBytes!=null&&(n.pendingBytes=t.pendingBytes|0),n},r.toObject=function(t,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.blocks=[],i.payload=[],i.blockPresences=[]),n.defaults&&(i.wantlist=null,i.pendingBytes=0),t.wantlist!=null&&t.hasOwnProperty("wantlist")&&(i.wantlist=Dt.Message.Wantlist.toObject(t.wantlist,n)),t.blocks&&t.blocks.length){i.blocks=[];for(var s=0;s<t.blocks.length;++s)i.blocks[s]=n.bytes===String?Vt.base64.encode(t.blocks[s],0,t.blocks[s].length):n.bytes===Array?Array.prototype.slice.call(t.blocks[s]):t.blocks[s]}if(t.payload&&t.payload.length){i.payload=[];for(var s=0;s<t.payload.length;++s)i.payload[s]=Dt.Message.Block.toObject(t.payload[s],n)}if(t.blockPresences&&t.blockPresences.length){i.blockPresences=[];for(var s=0;s<t.blockPresences.length;++s)i.blockPresences[s]=Dt.Message.BlockPresence.toObject(t.blockPresences[s],n)}return t.pendingBytes!=null&&t.hasOwnProperty("pendingBytes")&&(i.pendingBytes=t.pendingBytes),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Xo.default.util.toJSONOptions)},r.getTypeUrl=function(t){return t===void 0&&(t="type.googleapis.com"),t+"/Message"},r.Wantlist=function(){function e(t){if(this.entries=[],t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}return e.prototype.entries=Vt.emptyArray,e.prototype.full=!1,e.encode=function(n,i){if(i||(i=S3.create()),n.entries!=null&&n.entries.length)for(var s=0;s<n.entries.length;++s)Dt.Message.Wantlist.Entry.encode(n.entries[s],i.uint32(10).fork()).ldelim();return n.full!=null&&Object.hasOwnProperty.call(n,"full")&&i.uint32(16).bool(n.full),i},e.decode=function(n,i){n instanceof oc||(n=oc.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Dt.Message.Wantlist;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:{o.entries&&o.entries.length||(o.entries=[]),o.entries.push(Dt.Message.Wantlist.Entry.decode(n,n.uint32()));break}case 2:{o.full=n.bool();break}default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof Dt.Message.Wantlist)return n;var i=new Dt.Message.Wantlist;if(n.entries){if(!Array.isArray(n.entries))throw TypeError(".Message.Wantlist.entries: array expected");i.entries=[];for(var s=0;s<n.entries.length;++s){if(typeof n.entries[s]!="object")throw TypeError(".Message.Wantlist.entries: object expected");i.entries[s]=Dt.Message.Wantlist.Entry.fromObject(n.entries[s])}}return n.full!=null&&(i.full=Boolean(n.full)),i},e.toObject=function(n,i){i||(i={});var s={};if((i.arrays||i.defaults)&&(s.entries=[]),i.defaults&&(s.full=!1),n.entries&&n.entries.length){s.entries=[];for(var o=0;o<n.entries.length;++o)s.entries[o]=Dt.Message.Wantlist.Entry.toObject(n.entries[o],i)}return n.full!=null&&n.hasOwnProperty("full")&&(s.full=n.full),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Xo.default.util.toJSONOptions)},e.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/Message.Wantlist"},e.WantType=function(){let t={},n=Object.create(t);return n[t[0]="Block"]=0,n[t[1]="Have"]=1,n}(),e.Entry=function(){function t(n){if(n)for(var i=Object.keys(n),s=0;s<i.length;++s)n[i[s]]!=null&&(this[i[s]]=n[i[s]])}return t.prototype.block=Vt.newBuffer([]),t.prototype.priority=0,t.prototype.cancel=!1,t.prototype.wantType=0,t.prototype.sendDontHave=!1,t.encode=function(i,s){return s||(s=S3.create()),i.block!=null&&Object.hasOwnProperty.call(i,"block")&&s.uint32(10).bytes(i.block),i.priority!=null&&Object.hasOwnProperty.call(i,"priority")&&s.uint32(16).int32(i.priority),i.cancel!=null&&Object.hasOwnProperty.call(i,"cancel")&&s.uint32(24).bool(i.cancel),i.wantType!=null&&Object.hasOwnProperty.call(i,"wantType")&&s.uint32(32).int32(i.wantType),i.sendDontHave!=null&&Object.hasOwnProperty.call(i,"sendDontHave")&&s.uint32(40).bool(i.sendDontHave),s},t.decode=function(i,s){i instanceof oc||(i=oc.create(i));for(var o=s===void 0?i.len:i.pos+s,a=new Dt.Message.Wantlist.Entry;i.pos<o;){var c=i.uint32();switch(c>>>3){case 1:{a.block=i.bytes();break}case 2:{a.priority=i.int32();break}case 3:{a.cancel=i.bool();break}case 4:{a.wantType=i.int32();break}case 5:{a.sendDontHave=i.bool();break}default:i.skipType(c&7);break}}return a},t.fromObject=function(i){if(i instanceof Dt.Message.Wantlist.Entry)return i;var s=new Dt.Message.Wantlist.Entry;switch(i.block!=null&&(typeof i.block=="string"?Vt.base64.decode(i.block,s.block=Vt.newBuffer(Vt.base64.length(i.block)),0):i.block.length>=0&&(s.block=i.block)),i.priority!=null&&(s.priority=i.priority|0),i.cancel!=null&&(s.cancel=Boolean(i.cancel)),i.wantType){case"Block":case 0:s.wantType=0;break;case"Have":case 1:s.wantType=1;break}return i.sendDontHave!=null&&(s.sendDontHave=Boolean(i.sendDontHave)),s},t.toObject=function(i,s){s||(s={});var o={};return s.defaults&&(s.bytes===String?o.block="":(o.block=[],s.bytes!==Array&&(o.block=Vt.newBuffer(o.block))),o.priority=0,o.cancel=!1,o.wantType=s.enums===String?"Block":0,o.sendDontHave=!1),i.block!=null&&i.hasOwnProperty("block")&&(o.block=s.bytes===String?Vt.base64.encode(i.block,0,i.block.length):s.bytes===Array?Array.prototype.slice.call(i.block):i.block),i.priority!=null&&i.hasOwnProperty("priority")&&(o.priority=i.priority),i.cancel!=null&&i.hasOwnProperty("cancel")&&(o.cancel=i.cancel),i.wantType!=null&&i.hasOwnProperty("wantType")&&(o.wantType=s.enums===String?Dt.Message.Wantlist.WantType[i.wantType]:i.wantType),i.sendDontHave!=null&&i.hasOwnProperty("sendDontHave")&&(o.sendDontHave=i.sendDontHave),o},t.prototype.toJSON=function(){return this.constructor.toObject(this,Xo.default.util.toJSONOptions)},t.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/Message.Wantlist.Entry"},t}(),e}(),r.Block=function(){function e(t){if(t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}return e.prototype.prefix=Vt.newBuffer([]),e.prototype.data=Vt.newBuffer([]),e.encode=function(n,i){return i||(i=S3.create()),n.prefix!=null&&Object.hasOwnProperty.call(n,"prefix")&&i.uint32(10).bytes(n.prefix),n.data!=null&&Object.hasOwnProperty.call(n,"data")&&i.uint32(18).bytes(n.data),i},e.decode=function(n,i){n instanceof oc||(n=oc.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Dt.Message.Block;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:{o.prefix=n.bytes();break}case 2:{o.data=n.bytes();break}default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof Dt.Message.Block)return n;var i=new Dt.Message.Block;return n.prefix!=null&&(typeof n.prefix=="string"?Vt.base64.decode(n.prefix,i.prefix=Vt.newBuffer(Vt.base64.length(n.prefix)),0):n.prefix.length>=0&&(i.prefix=n.prefix)),n.data!=null&&(typeof n.data=="string"?Vt.base64.decode(n.data,i.data=Vt.newBuffer(Vt.base64.length(n.data)),0):n.data.length>=0&&(i.data=n.data)),i},e.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.prefix="":(s.prefix=[],i.bytes!==Array&&(s.prefix=Vt.newBuffer(s.prefix))),i.bytes===String?s.data="":(s.data=[],i.bytes!==Array&&(s.data=Vt.newBuffer(s.data)))),n.prefix!=null&&n.hasOwnProperty("prefix")&&(s.prefix=i.bytes===String?Vt.base64.encode(n.prefix,0,n.prefix.length):i.bytes===Array?Array.prototype.slice.call(n.prefix):n.prefix),n.data!=null&&n.hasOwnProperty("data")&&(s.data=i.bytes===String?Vt.base64.encode(n.data,0,n.data.length):i.bytes===Array?Array.prototype.slice.call(n.data):n.data),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Xo.default.util.toJSONOptions)},e.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/Message.Block"},e}(),r.BlockPresenceType=function(){let e={},t=Object.create(e);return t[e[0]="Have"]=0,t[e[1]="DontHave"]=1,t}(),r.BlockPresence=function(){function e(t){if(t)for(var n=Object.keys(t),i=0;i<n.length;++i)t[n[i]]!=null&&(this[n[i]]=t[n[i]])}return e.prototype.cid=Vt.newBuffer([]),e.prototype.type=0,e.encode=function(n,i){return i||(i=S3.create()),n.cid!=null&&Object.hasOwnProperty.call(n,"cid")&&i.uint32(10).bytes(n.cid),n.type!=null&&Object.hasOwnProperty.call(n,"type")&&i.uint32(16).int32(n.type),i},e.decode=function(n,i){n instanceof oc||(n=oc.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Dt.Message.BlockPresence;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:{o.cid=n.bytes();break}case 2:{o.type=n.int32();break}default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof Dt.Message.BlockPresence)return n;var i=new Dt.Message.BlockPresence;switch(n.cid!=null&&(typeof n.cid=="string"?Vt.base64.decode(n.cid,i.cid=Vt.newBuffer(Vt.base64.length(n.cid)),0):n.cid.length>=0&&(i.cid=n.cid)),n.type){case"Have":case 0:i.type=0;break;case"DontHave":case 1:i.type=1;break}return i},e.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.cid="":(s.cid=[],i.bytes!==Array&&(s.cid=Vt.newBuffer(s.cid))),s.type=i.enums===String?"Have":0),n.cid!=null&&n.hasOwnProperty("cid")&&(s.cid=i.bytes===String?Vt.base64.encode(n.cid,0,n.cid.length):i.bytes===Array?Array.prototype.slice.call(n.cid):n.cid),n.type!=null&&n.hasOwnProperty("type")&&(s.type=i.enums===String?Dt.Message.BlockPresenceType[n.type]:n.type),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Xo.default.util.toJSONOptions)},e.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/Message.BlockPresence"},e}(),r})();var hle={Block:bs.Wantlist.WantType.Block,Have:bs.Wantlist.WantType.Have},vIe=(r,e)=>Array.prototype.slice.call(e,0).sort((t,n)=>{let i=r(t),s=r(n);return i<s?-1:i>s?1:0}),Zo=class{constructor(e,t){this.set=t?ii({system:"ipfs",component:"bitswap",metric:"wantlist",metrics:t.metrics}):new Map,this._stats=e}get length(){return this.set.size}add(e,t,n){let i=e.toString(Ue),s=this.set.get(i);s?(s.inc(),s.priority=t,s.wantType===hle.Have&&n===hle.Block&&(s.wantType=n)):(this.set.set(i,new _3(e,t,n)),this._stats&&this._stats.push(null,"wantListSize",1))}remove(e){let t=e.toString(Ue),n=this.set.get(t);!n||(n.dec(),!n.hasRefs()&&(this.set.delete(t),this._stats&&this._stats.push(null,"wantListSize",-1)))}removeForce(e){this.set.has(e)&&this.set.delete(e)}forEach(e){return this.set.forEach(e)}entries(){return this.set.entries()}sortedEntries(){return new Map(vIe(e=>e[1].key,Array.from(this.set.entries())))}contains(e){let t=e.toString(Ue);return this.set.has(t)}get(e){let t=e.toString(Ue);return this.set.get(t)}};Zo.Entry=_3;var _Ie=Zo.Entry,vf=class{constructor(e,t,n,i,s){this.entry=new _Ie(e,t,n),this.cancel=Boolean(i),this.sendDontHave=Boolean(s)}get cid(){return this.entry.cid}set cid(e){this.entry.cid=e}get priority(){return this.entry.priority}set priority(e){this.entry.priority=e}get wantType(){return this.entry.wantType}set wantType(e){this.entry.wantType=e}get[Symbol.toStringTag](){return`BitswapMessageEntry ${this.cid.toString(Ue)} <cancel: ${this.cancel}, priority: ${this.priority}>`}equals(e){return this.cancel===e.cancel&&this.sendDontHave===e.sendDontHave&&this.wantType===e.wantType&&this.entry.equals(e.entry)}};var no=(r,e)=>{let t=["bitswap"];return e&&t.push(e),r&&t.push(`${r.toString().slice(0,8)}`),Object.assign((0,RD.default)(t.join(":")),{error:(0,RD.default)(t.concat(["error"]).join(":"))})};var rv=(r,e)=>{if(r.size!==e.size)return!1;for(let[t,n]of r){let i=e.get(t);if(i===void 0||n instanceof Uint8Array&&i instanceof Uint8Array&&!ze(n,i)||n instanceof vf&&i instanceof vf&&!n.equals(i))return!1}return!0};var ple=E(V(),1),Gt=class{constructor(e){this.full=e,this.wantlist=new Map,this.blocks=new Map,this.blockPresences=new Map,this.pendingBytes=0}get empty(){return this.blocks.size===0&&this.wantlist.size===0&&this.blockPresences.size===0}addEntry(e,t,n,i,s){n==null&&(n=Gt.WantType.Block);let o=e.toString(Ue),a=this.wantlist.get(o);a?(a.wantType===n&&(a.priority=t),i&&(a.cancel=Boolean(i)),s&&(a.sendDontHave=Boolean(s)),n===Gt.WantType.Block&&a.wantType===Gt.WantType.Have&&(a.wantType=n)):this.wantlist.set(o,new vf(e,t,n,i,s))}addBlock(e,t){let n=e.toString(Ue);this.blocks.set(n,t)}addHave(e){let t=e.toString(Ue);this.blockPresences.has(t)||this.blockPresences.set(t,Gt.BlockPresenceType.Have)}addDontHave(e){let t=e.toString(Ue);this.blockPresences.has(t)||this.blockPresences.set(t,Gt.BlockPresenceType.DontHave)}cancel(e){let t=e.toString(Ue);this.wantlist.delete(t),this.addEntry(e,0,Gt.WantType.Block,!0,!1)}setPendingBytes(e){this.pendingBytes=e}serializeToBitswap100(){let e={wantlist:{entries:Array.from(this.wantlist.values()).map(t=>({block:t.cid.bytes,priority:Number(t.priority),cancel:Boolean(t.cancel)})),full:this.full?!0:void 0},blocks:Array.from(this.blocks.values())};return bs.encode(e).finish()}serializeToBitswap110(){let e={wantlist:{entries:Array.from(this.wantlist.values()).map(t=>({block:t.cid.bytes,priority:Number(t.priority),wantType:t.wantType,cancel:Boolean(t.cancel),sendDontHave:Boolean(t.sendDontHave)})),full:this.full?!0:void 0},blockPresences:[],payload:[],pendingBytes:this.pendingBytes};for(let[t,n]of this.blocks.entries()){let i=A.parse(t),s=i.version,o=i.code,a=i.multihash.code,c=i.multihash.digest.length,l=fle([s,o,a,c]);e.payload.push(new bs.Block({prefix:l,data:n}))}for(let[t,n]of this.blockPresences)e.blockPresences.push(new bs.BlockPresence({cid:A.parse(t).bytes,type:n}));return this.pendingBytes>0&&(e.pendingBytes=this.pendingBytes),bs.encode(e).finish()}equals(e){return!(this.full!==e.full||this.pendingBytes!==e.pendingBytes||!rv(this.wantlist,e.wantlist)||!rv(this.blocks,e.blocks)||!rv(this.blockPresences,e.blockPresences))}get[Symbol.toStringTag](){let e=Array.from(this.wantlist.keys()),t=Array.from(this.blocks.keys());return`BitswapMessage <full: ${this.full}, list: ${e}, blocks: ${t}>`}};Gt.deserialize=async(r,e)=>{let t=bs.decode(r),n=t.wantlist&&t.wantlist.full||!1,i=new Gt(n);return t.wantlist&&t.wantlist.entries&&t.wantlist.entries.forEach(s=>{if(!s.block)return;let o=A.decode(s.block);i.addEntry(o,s.priority||0,s.wantType,Boolean(s.cancel),Boolean(s.sendDontHave))}),t.blockPresences&&t.blockPresences.forEach(s=>{if(!s.cid)return;let o=A.decode(s.cid);s.type===Gt.BlockPresenceType.Have?i.addHave(o):i.addDontHave(o)}),t.blocks.length>0?(await Promise.all(t.blocks.map(async s=>{let o=await $e.digest(s),a=A.createV0(o);i.addBlock(a,s)})),i):(t.payload.length>0&&(await Promise.all(t.payload.map(async s=>{if(!s.prefix||!s.data)return;let o=(0,dle.default)(s.prefix),a=o[0],c=o[1],l=o[2],f=l===$e.code?$e:e&&await e.getHasher(l);if(!f)throw(0,ple.default)(new Error("Unknown hash algorithm"),"ERR_UNKNOWN_HASH_ALG");let h=await f.digest(s.data),p=A.create(a,c,h);i.addBlock(p,s.data)})),i.setPendingBytes(t.pendingBytes)),i)};Gt.blockPresenceSize=r=>r.bytes.length+1;Gt.Entry=vf;Gt.WantType={Block:bs.Wantlist.WantType.Block,Have:bs.Wantlist.WantType.Have};Gt.BlockPresenceType={Have:bs.BlockPresenceType.Have,DontHave:bs.BlockPresenceType.DontHave};u();var mle=Math.pow(2,31)-1,yle=1e3,gle=1;u();u();var wle=SIe;function SIe(r,e,t){var n=null,i=null,s=function(){n&&(clearTimeout(n),i=null,n=null)},o=function(){var c=i;s(),c&&c()},a=function(){if(!e)return r.apply(this,arguments);var c=this,l=arguments,f=t&&!n;if(s(),i=function(){r.apply(c,l)},n=setTimeout(function(){if(n=null,!f){var h=i;return i=null,h()}},e),f)return i()};return a.cancel=s,a.flush=o,a}var nv=class{constructor(e,t,n){this.peerId=t,this.network=n,this.refcnt=1,this._entries=[],this._log=no(e,"msgqueue"),this.sendEntries=wle(this._sendEntries.bind(this),gle)}addMessage(e){e.empty||this.send(e)}addEntries(e){this._entries=this._entries.concat(e),this.sendEntries()}_sendEntries(){if(!this._entries.length)return;let e=new Gt(!1);this._entries.forEach(t=>{t.cancel?e.cancel(t.cid):e.addEntry(t.cid,t.priority)}),this._entries=[],this.addMessage(e)}async send(e){try{await this.network.connectTo(this.peerId)}catch(t){this._log.error("cant connect to peer %s: %s",this.peerId.toString(),t.message);return}this._log("sending message to peer %s",this.peerId.toString()),this.network.sendMessage(this.peerId,e).catch(t=>{this._log.error("send error: %s",t.message)})}};var iv=class{constructor(e,t,n,i){this.peers=ii({system:"ipfs",component:"bitswap",metric:"want-manager-peers",metrics:i.metrics}),this.wantlist=new Zo(n,i),this.network=t,this._stats=n,this._peerId=e,this._log=no(e,"want")}_addEntries(e,t,n){let i=e.map((s,o)=>new Gt.Entry(s,mle-o,Gt.WantType.Block,t));i.forEach(s=>{s.cancel?n?this.wantlist.removeForce(s.cid.toString(Ue)):this.wantlist.remove(s.cid):(this._log("adding to wl"),this.wantlist.add(s.cid,s.priority))});for(let s of this.peers.values())s.addEntries(i)}_startPeerHandler(e){let t=this.peers.get(e.toString());if(t){t.refcnt++;return}t=new nv(this._peerId,e,this.network);let n=new Gt(!0);for(let i of this.wantlist.entries())n.addEntry(i[1].cid,i[1].priority);return t.addMessage(n),this.peers.set(e.toString(),t),t}_stopPeerHandler(e){let t=this.peers.get(e.toString());!t||(t.refcnt--,!(t.refcnt>0)&&this.peers.delete(e.toString()))}wantBlocks(e,t={}){this._addEntries(e,!1),t&&t.signal&&t.signal.addEventListener("abort",()=>{this.cancelWants(e)})}unwantBlocks(e){this._log("unwant blocks: %s",e.length),this._addEntries(e,!0,!0)}cancelWants(e){this._log("cancel wants: %s",e.length),this._addEntries(e,!0)}connectedPeers(){return Array.from(this.peers.keys())}connected(e){this._startPeerHandler(e)}disconnected(e){this._stopPeerHandler(e)}start(){}stop(){this.peers.forEach(e=>this.disconnected(e.peerId))}};u();var Ele=E(an(),1);var PD="/ipfs/bitswap/1.0.0",DD="/ipfs/bitswap/1.1.0",OD="/ipfs/bitswap/1.2.0",TIe=32,IIe=128,AIe=3e4,sv=class{constructor(e,t,n,i={}){this._log=no(e.peerId,"network"),this._libp2p=e,this._bitswap=t,this._protocols=[PD],i.b100Only||(this._protocols.unshift(DD),this._protocols.unshift(OD)),this._stats=n,this._running=!1,this._onPeerConnect=this._onPeerConnect.bind(this),this._onPeerDisconnect=this._onPeerDisconnect.bind(this),this._onConnection=this._onConnection.bind(this),this._hashLoader=i.hashLoader,this._maxInboundStreams=i.maxInboundStreams??TIe,this._maxOutboundStreams=i.maxOutboundStreams??IIe,this._incomingStreamTimeout=i.incomingStreamTimeout??AIe}async start(){this._running=!0,await this._libp2p.handle(this._protocols,this._onConnection,{maxInboundStreams:this._maxInboundStreams,maxOutboundStreams:this._maxOutboundStreams});let e=k0({onConnect:this._onPeerConnect,onDisconnect:this._onPeerDisconnect});this._registrarIds=[];for(let t of this._protocols)this._registrarIds.push(await this._libp2p.registrar.register(t,e));this._libp2p.getConnections().forEach(t=>{this._onPeerConnect(t.remotePeer)})}async stop(){if(this._running=!1,await this._libp2p.unhandle(this._protocols),this._registrarIds!=null){for(let e of this._registrarIds)this._libp2p.registrar.unregister(e);this._registrarIds=[]}}_onConnection({stream:e,connection:t}){if(!this._running)return;let n=new Ele.TimeoutController(this._incomingStreamTimeout);Promise.resolve().then(async()=>{this._log("incoming new bitswap %s connection from %p",e.stat.protocol,t.remotePeer),await we(Kr(e.source,n.signal),yr(),async i=>{for await(let s of i){try{let o=await Gt.deserialize(s.subarray(),this._hashLoader);await this._bitswap._receiveMessage(t.remotePeer,o)}catch(o){this._bitswap._receiveError(o);break}n.reset()}})}).catch(i=>{this._log(i),e.abort(i)}).finally(()=>{n.clear(),e.close()})}_onPeerConnect(e){this._bitswap._onPeerConnected(e)}_onPeerDisconnect(e){this._bitswap._onPeerDisconnected(e)}findProviders(e,t={}){return this._libp2p.contentRouting.findProviders(e,t)}async findAndConnect(e,t){let n=[],i=0;for await(let s of this.findProviders(e,t))if(this._log(`connecting to provider ${s.id}`),n.push(this.connectTo(s.id,t).catch(o=>{this._log.error(o)})),i++,i===3)break;await Promise.all(n)}async provide(e,t){await this._libp2p.contentRouting.provide(e,t)}async sendMessage(e,t){if(!this._running)throw new Error("network isn't running");let n=e.toString();this._log("sendMessage to %s",n,t);let s=await(await this._libp2p.dial(e)).newStream([OD,DD,PD]);await RIe(s,t,this._log),this._updateSentStats(e,t.blocks)}async connectTo(e,t){if(!this._running)throw new Error("network isn't running");return this._libp2p.dial(e,t)}_updateSentStats(e,t){let n=e.toString();if(this._stats){for(let i of t.values())this._stats.push(n,"dataSent",i.length);this._stats.push(n,"blocksSent",t.size)}}};async function RIe(r,e,t){try{let n;switch(r.stat.protocol){case PD:n=e.serializeToBitswap100();break;case DD:case OD:n=e.serializeToBitswap110();break;default:throw new Error("Unknown protocol: "+r.stat.protocol)}await we([n],mr(),r)}catch(n){t(n)}finally{r.close()}}u();u();var ov=class{constructor(e){this.partner=e,this.wantlist=new Zo,this.exchangeCount=0,this.sentToPeer=new Map,this.accounting={bytesSent:0,bytesRecv:0}}sentBytes(e){this.exchangeCount++,this.lastExchange=new Date().getTime(),this.accounting.bytesSent+=e}receivedBytes(e){this.exchangeCount++,this.lastExchange=new Date().getTime(),this.accounting.bytesRecv+=e}wants(e,t,n){this.wantlist.add(e,t,n)}cancelWant(e){this.wantlist.remove(e)}wantlistContains(e){return this.wantlist.get(e)}debtRatio(){return this.accounting.bytesSent/(this.accounting.bytesRecv+1)}};u();u();var x3=class extends Map{constructor(e,t){super(),this._cmp=t||this._defaultSort,this._keys=[];for(let[n,i]of e||[])this.set(n,i)}update(e){if(e<0||e>=this._keys.length)return;let t=this._keys[e];this._keys.splice(e,1);let n=this._find(t);this._keys.splice(n,0,t)}set(e,t){if(this.has(e)){let i=this.indexOf(e);this._keys.splice(i,1)}super.set(e,t);let n=this._find(e);return this._keys.splice(n,0,e),this}clear(){super.clear(),this._keys=[]}delete(e){if(!this.has(e))return!1;let t=this.indexOf(e);return this._keys.splice(t,1),super.delete(e)}indexOf(e){if(!this.has(e))return-1;let t=this._find(e);if(this._keys[t]===e)return t;for(let n=1;n<this._keys.length;n++){if(this._keys[t+n]===e)return t+n;if(this._keys[t-n]===e)return t-n}return-1}_find(e){let t=0,n=this._keys.length;for(;t<n;){let i=t+n>>>1,s=this._kCmp(this._keys[i],e);if(s<0)t=i+1;else if(s>0)n=i;else return i}return t}*keys(){for(let e of this._keys)yield e}*values(){for(let e of this._keys)yield this.get(e)}*entries(){for(let e of this._keys)yield[e,this.get(e)]}*[Symbol.iterator](){yield*this.entries()}forEach(e,t){if(!!e)for(let n of this._keys)e.apply(t,[[n,this.get(n)]])}_defaultSort(e,t){return e[0]<t[0]?-1:t[0]<e[0]?1:0}_kCmp(e,t){return this._cmp([e,this.get(e)],[t,this.get(t)])}};var CIe={hasNewInfo(){return!1},merge(){}},av=class{constructor(e=CIe){this._taskMerger=e,this._byPeer=new x3([],cv.compare)}pushTasks(e,t){let n=this._byPeer.get(e.toString());n||(n=new cv(e,this._taskMerger)),n.pushTasks(t),this._byPeer.set(e.toString(),n)}popTasks(e){let t=this._head();if(t===void 0)return{tasks:[],pendingSize:0};let{tasks:n,pendingSize:i}=t.popTasks(e);if(n.length===0)return{tasks:n,pendingSize:i};let s=t.peerId;return t.isIdle()?this._byPeer.delete(s.toString()):this._byPeer.update(0),{peerId:s,tasks:n,pendingSize:i}}_head(){if(this._byPeer.size!==0)for(let[,e]of this._byPeer)return e}remove(e,t){let n=this._byPeer.get(t.toString());n&&n.remove(e)}tasksDone(e,t){let n=this._byPeer.get(e.toString());if(!n)return;let i=this._byPeer.indexOf(e.toString());for(let s of t)n.taskDone(s);this._byPeer.update(i)}},cv=class{constructor(e,t){this.peerId=e,this._taskMerger=t,this._activeTotalSize=0,this._pending=new kD,this._active=new Set}pushTasks(e){for(let t of e)this._pushTask(t)}_pushTask(e){if(!this._taskHasMoreInfoThanActiveTasks(e))return;let t=this._pending.get(e.topic);if(t){e.priority>t.priority&&this._pending.updatePriority(e.topic,e.priority),this._taskMerger.merge(e,t);return}this._pending.add(e)}_taskHasMoreInfoThanActiveTasks(e){let t=[];for(let n of this._active)n.topic===e.topic&&t.push(n);return t.length===0?!0:this._taskMerger.hasNewInfo(e,t)}popTasks(e){let t=0,n=[],i=this._pending.tasks();for(let s=0;s<i.length&&t<e;s++){let o=i[s];n.push(o),t+=o.size,this._pending.delete(o.topic),this._activeTotalSize+=o.size,this._active.add(o)}return{tasks:n,pendingSize:this._pending.totalSize}}taskDone(e){this._active.has(e)&&(this._activeTotalSize-=e.size,this._active.delete(e))}remove(e){this._pending.delete(e)}isIdle(){return this._pending.length===0&&this._active.size===0}static compare(e,t){return e[1]._pending.length===0?1:t[1]._pending.length===0?-1:e[1]._activeTotalSize===t[1]._activeTotalSize?t[1]._pending.length-e[1]._pending.length:e[1]._activeTotalSize-t[1]._activeTotalSize}},kD=class{constructor(){this._tasks=new x3([],this._compare)}get length(){return this._tasks.size}get totalSize(){return[...this._tasks.values()].reduce((e,t)=>e+t.task.size,0)}get(e){return(this._tasks.get(e)||{}).task}add(e){this._tasks.set(e.topic,{created:Date.now(),task:e})}delete(e){this._tasks.delete(e)}tasks(){return[...this._tasks.values()].map(e=>e.task)}updatePriority(e,t){let n=this._tasks.get(e);if(!n)return;let i=this._tasks.indexOf(e);n.task.priority=t,this._tasks.update(i)}_compare(e,t){return e[1].task.priority===t[1].task.priority?e[1].created-t[1].created:t[1].task.priority-e[1].task.priority}};u();var ble={hasNewInfo(r,e){let t=!1,n=!1;for(let i of e)i.data.haveBlock&&(t=!0),i.data.isWantBlock&&(n=!0);return!!(!n&&r.data.isWantBlock||!t&&r.data.haveBlock)},merge(r,e){let t=r.data,n=e.data;!n.haveBlock&&t.haveBlock&&(n.haveBlock=t.haveBlock,n.blockSize=t.blockSize),!n.isWantBlock&&t.isWantBlock&&(n.isWantBlock=!0,(!n.haveBlock||t.haveBlock)&&(n.haveBlock=t.haveBlock,e.size=r.size)),n.isWantBlock&&n.haveBlock&&(e.size=n.blockSize)}};var vle=Gt.WantType,PIe=16*1024,DIe=1024,lv=class{constructor(e,t,n,i,s,o={}){this._log=no(e,"engine"),this.blockstore=t,this.network=n,this._stats=i,this._opts=this._processOpts(o),this.ledgerMap=ii({system:"ipfs",component:"bitswap",metric:"ledger-map",metrics:s.metrics}),this._running=!1,this._requestQueue=new av(ble)}_processOpts(e){return{maxSizeReplaceHasWithBlock:DIe,targetMessageSize:PIe,...e}}_scheduleProcessTasks(){setTimeout(()=>{this._processTasks()})}async _processTasks(){if(!this._running)return;let{peerId:e,tasks:t,pendingSize:n}=this._requestQueue.popTasks(this._opts.targetMessageSize);if(t.length===0)return;let i=new Gt(!1);i.setPendingBytes(n);let s=[],o=new Map;for(let c of t){let l=A.parse(c.topic);c.data.haveBlock?c.data.isWantBlock?(s.push(l),o.set(c.topic,c.data)):i.addHave(l):i.addDontHave(l)}let a=await this._getBlocks(s);for(let[c,l]of o){let f=A.parse(c),h=a.get(c);h?i.addBlock(f,h):l.sendDontHave&&i.addDontHave(f)}if(i.empty){e&&this._requestQueue.tasksDone(e,t),this._scheduleProcessTasks();return}try{e&&await this.network.sendMessage(e,i);for(let[c,l]of a.entries())e&&this.messageSent(e,A.parse(c),l)}catch(c){this._log.error(c)}e&&this._requestQueue.tasksDone(e,t),this._scheduleProcessTasks()}wantlistForPeer(e){let t=e.toString(),n=this.ledgerMap.get(t);return n?n.wantlist.sortedEntries():new Map}ledgerForPeer(e){let t=e.toString(),n=this.ledgerMap.get(t);return n?{peer:n.partner,value:n.debtRatio(),sent:n.accounting.bytesSent,recv:n.accounting.bytesRecv,exchanged:n.exchangeCount}:null}peers(){return Array.from(this.ledgerMap.values()).map(e=>e.partner)}receivedBlocks(e){if(!!e.length){for(let t of this.ledgerMap.values())for(let n of e){let i=t.wantlistContains(n.cid);if(!i)continue;let s=n.data.length,o=this._sendAsBlock(i.wantType,s),a=s;o||(a=Gt.blockPresenceSize(i.cid)),this._requestQueue.pushTasks(t.partner,[{topic:i.cid.toString(Ue),priority:i.priority,size:a,data:{blockSize:s,isWantBlock:o,haveBlock:!0,sendDontHave:!1}}])}this._scheduleProcessTasks()}}async messageReceived(e,t){let n=this._findOrCreate(e);if(t.empty)return;if(t.full&&(n.wantlist=new Zo),this._updateBlockAccounting(t.blocks,n),t.wantlist.size===0){this._scheduleProcessTasks();return}let i=[],s=[];t.wantlist.forEach(o=>{o.cancel?(n.cancelWant(o.cid),i.push(o.cid)):(n.wants(o.cid,o.priority,o.wantType),s.push(o))}),this._cancelWants(e,i),await this._addWants(e,s),this._scheduleProcessTasks()}_cancelWants(e,t){for(let n of t)this._requestQueue.remove(n.toString(Ue),e)}async _addWants(e,t){let n=await this._getBlockSizes(t.map(s=>s.cid)),i=[];for(let s of t){let o=s.cid.toString(Ue),a=n.get(o);if(a==null)s.sendDontHave&&i.push({topic:o,priority:s.priority,size:Gt.blockPresenceSize(s.cid),data:{isWantBlock:s.wantType===vle.Block,blockSize:0,haveBlock:!1,sendDontHave:s.sendDontHave}});else{let c=this._sendAsBlock(s.wantType,a),l=a;c||(l=Gt.blockPresenceSize(s.cid)),i.push({topic:o,priority:s.priority,size:l,data:{isWantBlock:c,blockSize:a,haveBlock:!0,sendDontHave:s.sendDontHave}})}this._requestQueue.pushTasks(e,i)}}_sendAsBlock(e,t){return e===vle.Block||t<=this._opts.maxSizeReplaceHasWithBlock}async _getBlockSizes(e){let t=await this._getBlocks(e);return new Map([...t].map(([n,i])=>[n,i.length]))}async _getBlocks(e){let t=new Map;return await Promise.all(e.map(async n=>{try{let i=await this.blockstore.get(n);t.set(n.toString(Ue),i)}catch(i){i.code!=="ERR_NOT_FOUND"&&this._log.error("failed to query blockstore for %s: %s",n,i)}})),t}_updateBlockAccounting(e,t){for(let n of e.values())this._log("got block (%s bytes)",n.length),t.receivedBytes(n.length)}messageSent(e,t,n){let i=this._findOrCreate(e);i.sentBytes(n.length),i.wantlist.remove(t)}numBytesSentTo(e){return this._findOrCreate(e).accounting.bytesSent}numBytesReceivedFrom(e){return this._findOrCreate(e).accounting.bytesRecv}peerDisconnected(e){this.ledgerMap.delete(e.toString())}_findOrCreate(e){let t=e.toString(),n=this.ledgerMap.get(t);if(n)return n;let i=new ov(e);return this.ledgerMap.set(t,i),this._stats&&this._stats.push(t,"peerCount",1),i}start(){this._running=!0}stop(){this._running=!1}};u();var xle=E(bn(),1);var _le=r=>`unwant:${K(r.multihash.bytes,"base64")}`,Sle=r=>`block:${K(r.multihash.bytes,"base64")}`,uv=class extends xle.EventEmitter{constructor(e){super(),this.setMaxListeners(yle),this._log=no(e,"notif")}hasBlock(e,t){let n=Sle(e);this._log(n),this.emit(n,t)}wantBlock(e,t={}){if(!e)throw new Error("Not a valid cid");let n=Sle(e),i=_le(e);return this._log(`wantBlock:${e}`),new Promise((s,o)=>{let a=()=>{this.removeListener(n,c),o(new Error(`Block for ${e} unwanted`))},c=l=>{this.removeListener(i,a),s(l)};this.once(i,a),this.once(n,c),t&&t.signal&&t.signal.addEventListener("abort",()=>{this.removeListener(n,c),this.removeListener(i,a),o(new Error(`Want for ${e} aborted`))})})}unwantBlock(e){let t=_le(e);this._log(t),this.emit(t)}};u();var Ple=E(bn(),1);u();var Rle=E(bn(),1),ND=E(Ale(),1),T3=class extends Rle.EventEmitter{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this),e.forEach(n=>{this._stats[n]=BigInt(0),this._movingAverages[n]={},this._options.movingAverageIntervals.forEach(i=>{(this._movingAverages[n][i]=(0,ND.default)(i)).push(this._frequencyLastTime,0)})}),this._enabled=this._options.enabled}enable(){this._enabled=!0}disable(){this._disabled=!0}stop(){this._timeout&&clearTimeout(this._timeout)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}push(e,t){this._enabled&&(this._queue.push([e,t,Date.now()]),this._resetComputeTimeout())}_resetComputeTimeout(){this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(this._update,this._nextTimeout())}_nextTimeout(){let e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(;this._queue.length;){let t=e=this._queue.shift();t&&this._applyOp(t)}e&&this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){let t=e-this._frequencyLastTime;t&&Object.keys(this._stats).forEach(n=>{this._updateFrequencyFor(n,t,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,t,n){let i=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;let s=i/t*1e3,o=this._movingAverages[e];o||(o=this._movingAverages[e]={}),this._options.movingAverageIntervals.forEach(a=>{let c=o[a];c||(c=o[a]=(0,ND.default)(a)),c.push(n,s)})}_applyOp(e){let t=e[0],n=e[1];if(typeof n!="number")throw new Error(`invalid increment number: ${n}`);Object.prototype.hasOwnProperty.call(this._stats,t)||(this._stats[t]=BigInt(0)),this._stats[t]=BigInt(this._stats[t])+BigInt(n),this._frequencyAccumulators[t]||(this._frequencyAccumulators[t]=0),this._frequencyAccumulators[t]+=n}};var Cle={enabled:!1,computeThrottleTimeout:1e3,computeThrottleMaxQueueSize:1e3,movingAverageIntervals:[60*1e3,5*60*1e3,15*60*1e3]},fv=class extends Ple.EventEmitter{constructor(e,t=[],n=Cle){super();let i=Object.assign({},Cle,n);if(typeof i.computeThrottleTimeout!="number")throw new Error("need computeThrottleTimeout");if(typeof i.computeThrottleMaxQueueSize!="number")throw new Error("need computeThrottleMaxQueueSize");this._initialCounters=t,this._options=i,this._enabled=this._options.enabled,this._global=new T3(t,i),this._global.on("update",s=>this.emit("update",s)),this._peers=ii({system:"ipfs",component:"bitswap",metric:"stats-peers",metrics:e.metrics})}enable(){this._enabled=!0,this._options.enabled=!0,this._global.enable()}disable(){this._enabled=!1,this._options.enabled=!1,this._global.disable()}stop(){this._enabled=!1,this._global.stop();for(let e of this._peers)e[1].stop()}get snapshot(){return this._global.snapshot}get movingAverages(){return this._global.movingAverages}forPeer(e){let t=typeof e!="string"&&e.toString?e.toString():`${e}`;return this._peers.get(t)}push(e,t,n){if(this._enabled&&(this._global.push(t,n),e)){let i=this._peers.get(e);i||(i=new T3(this._initialCounters,this._options),this._peers.set(e,i)),i.push(t,n)}}disconnected(e){let t=e.toString(),n=this._peers.get(t);n&&(n.stop(),this._peers.delete(t))}};var Dle=E(ai(),1);var kIe={statsEnabled:!1,statsComputeThrottleTimeout:1e3,statsComputeThrottleMaxQueueSize:1e3},NIe=["blocksReceived","dataReceived","dupBlksReceived","dupDataReceived","blocksSent","dataSent","providesBufferLength","wantListLength","peerCount"],hv=class extends za{constructor(e,t,n={}){super(),this._libp2p=e,this._log=no(this.peerId),this._options=Object.assign({},kIe,n),this._stats=new fv(e,NIe,{enabled:this._options.statsEnabled,computeThrottleTimeout:this._options.statsComputeThrottleTimeout,computeThrottleMaxQueueSize:this._options.statsComputeThrottleMaxQueueSize}),this.network=new sv(e,this,this._stats,{hashLoader:n.hashLoader,maxInboundStreams:n.maxInboundStreams,maxOutboundStreams:n.maxOutboundStreams,incomingStreamTimeout:n.incomingStreamTimeout}),this.blockstore=t,this.engine=new lv(this.peerId,t,this.network,this._stats,e),this.wm=new iv(this.peerId,this.network,this._stats,e),this.notifications=new uv(this.peerId),this.started=!1}isStarted(){return this.started}get peerId(){return this._libp2p.peerId}async _receiveMessage(e,t){try{await this.engine.messageReceived(e,t)}catch{this._log("failed to receive message",t)}if(t.blocks.size===0)return;let n=[];for(let[i,s]of t.blocks.entries()){let o=A.parse(i);n.push({wasWanted:this.wm.wantlist.contains(o),cid:o,data:s})}this.wm.cancelWants(n.filter(({wasWanted:i})=>i).map(({cid:i})=>i)),await Promise.all(n.map(({cid:i,wasWanted:s,data:o})=>this._handleReceivedBlock(e,i,o,s)))}async _handleReceivedBlock(e,t,n,i){this._log("received block");let s=await this.blockstore.has(t);this._updateReceiveCounters(e.toString(),t,n,s),i&&await this.put(t,n)}_updateReceiveCounters(e,t,n,i){this._stats.push(e,"blocksReceived",1),this._stats.push(e,"dataReceived",n.length),i&&(this._stats.push(e,"dupBlksReceived",1),this._stats.push(e,"dupDataReceived",n.length))}_receiveError(e){this._log.error("ReceiveError: %s",e.message)}_onPeerConnected(e){this.wm.connected(e)}_onPeerDisconnected(e){this.wm.disconnected(e),this.engine.peerDisconnected(e),this._stats.disconnected(e)}enableStats(){this._stats.enable()}disableStats(){this._stats.disable()}wantlistForPeer(e,t){return this.engine.wantlistForPeer(e)}ledgerForPeer(e){return this.engine.ledgerForPeer(e)}async get(e,t={}){let n=(c,l)=>(this.wm.wantBlocks([c],l),this.notifications.wantBlock(c,l)),i=!1,s=async(c,l)=>{try{return await this.blockstore.get(c,l)}catch(f){if(f.code!=="ERR_NOT_FOUND")throw f;return i||(i=!0,this.network.findAndConnect(c,l).catch(h=>this._log.error(h))),n(c,l)}},o=new AbortController,a=t.signal?(0,Dle.anySignal)([t.signal,o.signal]):o.signal;try{return await Promise.race([this.notifications.wantBlock(e,{signal:a}),s(e,{signal:a})])}finally{o.abort()}}async*getMany(e,t={}){for await(let n of e)yield this.get(n,t)}unwant(e){let t=Array.isArray(e)?e:[e];this.wm.unwantBlocks(t),t.forEach(n=>this.notifications.unwantBlock(n))}cancelWants(e){this.wm.cancelWants(Array.isArray(e)?e:[e])}async put(e,t,n){await this.blockstore.put(e,t),this._sendHaveBlockNotifications(e,t)}async*putMany(e,t){for await(let{key:n,value:i}of this.blockstore.putMany(e,t))this._sendHaveBlockNotifications(n,i),yield{key:n,value:i}}_sendHaveBlockNotifications(e,t){this.notifications.hasBlock(e,t),this.engine.receivedBlocks([{cid:e,data:t}]),this.network.provide(e).catch(n=>{this._log.error("Failed to provide: %s",n.message)})}getWantlist(){return this.wm.wantlist.entries()}peers(){return this.engine.peers()}stat(){return this._stats}async start(){this.wm.start(),await this.network.start(),this.engine.start(),this.started=!0}async stop(){this._stats.stop(),this.wm.stop(),await this.network.stop(),this.engine.stop(),this.started=!1}unwrap(){return this.blockstore}};var Ole=(r,e,t={})=>new hv(r,e,t);var Ble=E(V(),1);u();u();var dv={};Kt(dv,{abortedError:()=>LIe,notFoundError:()=>kle});u();var LD=E(V(),1);function kle(r){return r=r||new Error("Not Found"),(0,LD.default)(r,"ERR_NOT_FOUND")}function LIe(r){return r=r||new Error("Aborted"),(0,LD.default)(r,"ERR_ABORTED")}u();var gIt={...dv};var Nle=E(Bc(),1);var Lle=E(Ai(),1),pv=class extends za{constructor(e,t){super(),this.child=e,this.bitswap=t}open(){return this.child.open()}close(){return this.child.close()}unwrap(){return this.child}async put(e,t,n={}){await this.has(e)||(this.bitswap.isStarted()?await this.bitswap.put(e,t,n):await this.child.put(e,t,n))}async*putMany(e,t={}){let n=(0,Lle.default)(e,async({key:i})=>!await this.has(i));this.bitswap.isStarted()?yield*this.bitswap.putMany(n,t):yield*this.child.putMany(n,t)}async get(e,t={}){return!await this.has(e)&&this.bitswap.isStarted()?this.bitswap.get(e,t):this.child.get(e,t)}async*getMany(e,t={}){let n=ar({objectMode:!0}),i=ar({objectMode:!0});Promise.resolve().then(async()=>{for await(let s of e)!await this.has(s)&&this.bitswap.isStarted()?n.push(s):i.push(s);n.end(),i.end()}),yield*(0,Nle.default)(this.bitswap.getMany(n,t),this.child.getMany(i,t))}async delete(e,t){await this.child.delete(e,t)}async*deleteMany(e,t){yield*this.child.deleteMany(e,t)}async has(e,t={}){return this.child.has(e,t)}async*query(e,t={}){yield*this.child.query(e,t)}async*queryKeys(e,t={}){yield*this.child.queryKeys(e,t)}};var C1=class{constructor(e,t,n,i,s){this.peerId=e,this.libp2p=t,this.bitswap=n,this.repo=i,this.blockstore=s}static async start({peerId:e,repo:t,print:n,hashers:i,options:s}){t.closed&&await t.open();let o=await t.config.getAll(),a=await E3({options:s,repo:t,peerId:e,multiaddrs:BIe(e,o),config:o,keychainConfig:void 0});await a.start();for(let f of a.getMultiaddrs())n(`Swarm listening on ${f.toString()}`);let c=Ole(a,t.blocks,{statsEnabled:!0,hashLoader:i,maxInboundStreams:1024,maxOutboundStreams:1024});await c.start();let l=new pv(t.blocks,c);return t.blocks=l,t.pins.blockstore=l,new C1(e,a,c,t,l)}static async stop(e){e.repo.blocks=e.blockstore.unwrap(),e.repo.pins.blockstore=e.blockstore.unwrap(),await e.bitswap.stop(),await e.libp2p.stop()}},BIe=(r,e)=>{let t=r.toString(),n=[],i=e.Addresses&&e.Addresses.Swarm||[];for(let s of i){let o=se(s);if(o.protoCodes().includes(MIe))throw(0,Ble.default)(new Error("websocket-star swarm addresses are not supported. See https://github.com/ipfs/js-ipfs/issues/2779"),"ERR_WEBSOCKET_STAR_SWARM_ADDR_NOT_SUPPORTED");let a=o.getPeerId();a&&a!==t&&(o=o.encapsulate(`/p2p/${t}`)),n.push(o)}return n},MIe=479;u();u();function Mle({network:r}){async function e(t={}){let n=[],{libp2p:i}=await r.use(t);return await i.peerStore.forEach(s=>{n.push({id:s.id,addrs:s.addresses.map(o=>o.multiaddr)})}),n}return M(e)}u();function Ule({network:r}){async function e(t,n={}){let{libp2p:i}=await r.use(n);await i.dial(t,n)}return M(e)}u();function Fle({network:r}){async function e(t,n={}){let{libp2p:i}=await r.use(n);await i.hangUp(t)}return M(e)}u();function Vle({network:r}){async function e(t={}){let{libp2p:n}=await r.use(t);return n.getMultiaddrs()}return M(e)}u();function Kle({network:r}){async function e(t={}){let{libp2p:n}=await r.use(t);if(t.verbose){let s=[];for(let o of n.getConnections()){let a={addr:o.remoteAddr,peer:o.remotePeer};(t.verbose||t.direction)&&(a.direction=o.stat.direction),t.verbose&&(a.muxer=o.stat.multiplexer,a.latency="n/a",a.streams=[]),s.push(a)}return s}let i=new Map;for(let s of n.getConnections()){let o={addr:s.remoteAddr,peer:s.remotePeer};i.set(s.remotePeer.toString(),o)}return Array.from(i.values())}return M(e)}var mv=class{constructor({network:e}){this.addrs=Mle({network:e}),this.connect=Ule({network:e}),this.disconnect=Fle({network:e}),this.localAddrs=Vle({network:e}),this.peers=Kle({network:e})}};u();var I3={success:!0,time:0,text:""};function qle({network:r}){async function*e(t,n={}){let{libp2p:i}=await r.use();n.count=n.count||10;let s=await i.peerStore.get(t),o=s&&s.id;if(!o){yield{...I3,text:`Looking up peer ${t}`};let l=await i.peerRouting.findPeer(t);o=l&&l.id}if(!o)throw new Error("Peer was not found");yield{...I3,text:`PING ${o.toString()}`};let a=0,c=0;for(let l=0;l<n.count;l++)try{let f=await i.ping(o);c+=f,a++,yield{...I3,time:f}}catch(f){yield{...I3,success:!1,text:f.toString()}}if(a){let l=c/a;yield{...I3,text:`Average latency: ${l}ms`}}}return M(e)}u();var Cl=E(V(),1);Mr();var BD="/ipns/";function zle(r){r.startsWith(BD)&&(r=r.substring(BD.length));let e;if((r[0]==="1"||r[0]==="Q")&&(r=`z${r}`),r[0]==="z"&&(e=Ue.decode(r)),r[0]==="k"&&(e=rp.decode(r)),!e)throw new Error("Could not parse string");if(e[0]!==1&&e[1]!==114&&(e=Le([[1,114],e])),e.length!==40)throw new Error("Incorrect length "+e.length);return Le([z(BD),e.subarray(2)])}function $le({network:r,repo:e,peerId:t}){let{get:n,put:i,findProvs:s,findPeer:o,provide:a,query:c}={async*get(l,f={}){let{libp2p:h}=await P1(r,t,f),p=l instanceof Uint8Array?l:zle(l);if(h.dht==null)throw(0,Cl.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*h.dht.get(p,f)},async*put(l,f,h){let{libp2p:p}=await P1(r,t,h),d=l instanceof Uint8Array?l:zle(l);if(p.dht==null)throw(0,Cl.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*p.dht.put(d,f,h)},async*findProvs(l,f={}){let{libp2p:h}=await P1(r,t,f);if(h.dht==null)throw(0,Cl.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*h.dht.findProviders(l,{signal:f.signal})},async*findPeer(l,f={}){let{libp2p:h}=await P1(r,t,f);if(h.dht==null)throw(0,Cl.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*h.dht.findPeer(l,{signal:f.signal})},async*provide(l,f={recursive:!1}){let{libp2p:h}=await P1(r,t,f);if(!await e.blocks.has(l))throw(0,Cl.default)(new Error("block(s) not found locally, cannot provide"),"ERR_BLOCK_NOT_FOUND");if(f.recursive)throw(0,Cl.default)(new Error("not implemented yet"),"ERR_NOT_IMPLEMENTED_YET");if(h.dht==null)throw(0,Cl.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*h.dht.provide(l)},async*query(l,f={}){let{libp2p:h}=await P1(r,t,f),p,d=A.asCID(l);if(d!=null?p=d.multihash.bytes:p=pe(l.toString()).toBytes(),h.dht==null)throw(0,Cl.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*h.dht.getClosestPeers(p,f)}};return{get:M(n),put:M(i),findProvs:M(s),findPeer:M(o),provide:M(a),query:M(c)}}var P1=async(r,e,t)=>{let n=await r.use(t);if(n.libp2p.dht!=null)return n;{let i=async function*(){yield{from:e,name:"QUERY_ERROR",type:3,error:new fo("dht not enabled")}};return{libp2p:{dht:{get:i,put:i,findProviders:i,findPeer:i,provide:i,getClosestPeers:i}}}}};u();var Hle=E(V(),1);var Gle=E(Zw(),1);function jle({network:r,config:e}){let t=(0,Gle.default)(e||{},"Pubsub.Enabled",!0),n={},i;return{subscribe:t?M(s):A3,unsubscribe:t?M(o):A3,publish:t?M(a):A3,ls:t?M(c):A3,peers:t?M(l):A3};async function s(f,h,p={}){let{libp2p:d}=await r.use(p);d.pubsub.subscribe(f),i==null&&(i=m=>{let y=m.detail;n[y.topic]&&n[y.topic].forEach(g=>{if(typeof g=="function"){g(y);return}g!=null&&g.handleEvent!=null&&g.handleEvent(y)})},d.pubsub.addEventListener("message",i)),h!=null&&(n[f]==null&&(n[f]=[]),n[f].push(h))}async function o(f,h,p={}){let{libp2p:d}=await r.use(p);h!=null&&n[f]!=null&&(n[f]=n[f].filter(m=>m!==h),n[f].length===0&&delete n[f]),typeof h!="function"&&delete n[f],n[f]==null&&d.pubsub.unsubscribe(f),Object.keys(n).length===0&&(d.pubsub.removeEventListener("message",i),i=void 0)}async function a(f,h,p={}){let{libp2p:d}=await r.use(p);if(!h)throw(0,Hle.default)(new Error('argument "data" is required'),"ERR_ARG_REQUIRED");await d.pubsub.publish(f,h)}async function c(f={}){let{libp2p:h}=await r.use(f);return h.pubsub.getTopics()}async function l(f,h={}){let{libp2p:p}=await r.use(h);return p.pubsub.getSubscribers(f)}}var A3=async()=>{throw new fo("pubsub not enabled")};var UIe=Qe.bind({ignoreUndefined:!0}),_f=C("ipfs"),FIe=3e4,MD=class{constructor({print:e,storage:t,codecs:n,options:i}){let{peerId:s,repo:o,keychain:a}=t,c=Yn.create(C1),l=CG(i.preload),f=jB(),h=WB({network:c}),p=new i6(i),d=Object.values(u4);(i.ipld&&i.ipld.hashers?i.ipld.hashers:[]).forEach(Ce=>d.push(Ce)),this.hashers=new H0({hashers:d,loadHasher:i.ipld&&i.ipld.loadHasher});let m=Object.values(As);(i.ipld&&i.ipld.bases?i.ipld.bases:[]).forEach(Ce=>m.push(Ce)),this.bases=new z0({bases:m,loadBase:i.ipld&&i.ipld.loadBase});let y=new z4({repo:o,codecs:n}),g=new y6({codecs:n,hashers:this.hashers,preload:l,repo:o}),w=new a6({dns:f,ipns:p,repo:o,codecs:n,peerId:s,isOnline:h,keychain:a,options:i}),b=ZB({repo:o,codecs:n,bases:this.bases,name:w}),S=new m5({repo:o,codecs:n,hashers:this.hashers,preload:l}),_=Object.assign(HK({repo:o,codecs:n,resolve:b,preload:l}),{local:GK({repo:t.repo})}),{add:I,addAll:T,cat:x,get:P,ls:B}=new o5({preload:l,repo:o,options:i.EXPERIMENTAL,hashers:this.hashers}),q=Aj({repo:o,preload:l,hashers:this.hashers,options:i}),Y=PG({files:q,preload:l,options:i.preload});this.preload=l,this.name=w,this.ipns=p,this.pin=y,this.resolve=b,this.block=g,this.refs=_,this.start=gB({network:c,peerId:s,repo:o,preload:l,ipns:p,mfsPreload:Y,print:e,keychain:a,hashers:this.hashers,options:i}),this.stop=wB({network:c,preload:l,mfsPreload:Y,ipns:p,repo:o}),this.dht=$le({network:c,repo:o,peerId:s}),this.pubsub=jle({network:c,config:i.config}),this.dns=f,this.isOnline=h,this.id=ZH({network:c,peerId:s}),this.version=XH({repo:o}),this.bitswap=new l6({network:c}),this.bootstrap=new f6({repo:o}),this.config=eG({repo:o}),this.ping=qle({network:c}),this.add=I,this.addAll=T,this.cat=x,this.get=P,this.ls=B,this.dag=S,this.files=q,this.key=new D5({keychain:a}),this.object=new k5({preload:l,codecs:n,repo:o}),this.repo=new L5({repo:o,hashers:this.hashers}),this.stats=new B5({repo:o,network:c}),this.swarm=new mv({network:c}),Object.defineProperty(this,"libp2p",{get(){let Ce=c.try();return Ce?Ce.libp2p:void 0}});let re=()=>Promise.reject((0,yv.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")),ie=async function*(){throw(0,yv.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")};this.commands=re,this.diag={cmds:re,net:re,sys:re},this.log={level:re,ls:re,tail:ie},this.mount=re,this.codecs=n}async init(){throw new uo}},VIe=async r=>{let e=Xe({Data:new Je({type:"directory"}).marshal(),Links:[]}),t=await r.block.put(e,{mhtype:"sha2-256",format:"dag-pb"});return await r.pin.add(t),t},KIe=()=>({start:!0,EXPERIMENTAL:{},preload:{enabled:!Wle.isTest,addresses:["/dns4/node0.preload.ipfs.io/https","/dns4/node1.preload.ipfs.io/https","/dns4/node2.preload.ipfs.io/https","/dns4/node3.preload.ipfs.io/https"]}});async function Qle(r={}){r=UIe(KIe(),r);let e=r.init||{},t={name:on.name,code:on.code,encode:l=>l,decode:l=>l},n=Object.values(f4);[_t,mc,tp,Y1,t].concat(r.ipld&&r.ipld.codecs||[]).forEach(l=>n.push(l));let i=new $0({codecs:n,loadCodec:r.ipld&&r.ipld.loadCodec}),s=r.silent?_f:console.log;_f("creating repo");let o=await R1.start(s,i,r);_f("getting repo config");let a=await o.repo.config.getAll(),c=new MD({storage:o,print:s,codecs:i,options:{...r,config:a}});if(_f("starting preload"),await c.preload.start(),_f("starting storage"),c.ipns.startOffline(o),o.isNew&&!e.emptyRepo){let l=await VIe(c);if(_f("adding default assets"),await(c.addAll,void 0),_f("initializing IPNS keyspace"),o.peerId.publicKey==null)throw(0,yv.default)(new Error("Public key missing"),"ERR_MISSING_PUBLIC_KEY");let f=new Yle.TimeoutController(FIe);try{await c.ipns.initializeKeyspace(o.peerId,z(`/ipfs/${l}`),{signal:f.signal})}finally{f.clear()}}return r.start!==!1&&(_f("starting node"),await c.start()),c}var Xle=E(NR(),1),Zle=E(LR(),1),Jle=Qle,eue=Xle.default,tue=Zle.default;u();function rue(){throw new Error("Not supported in browsers")}var qIe=Jle,zIe=eue,$Ie=tue,HIe=rue;return KD(GIe);})();
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
/*!
* bytes
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015 Jed Watson
* MIT Licensed
*/
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/**
* Timestamp for 64-bit time_t, nanosecond precision and strftime
*
* @author Yusuke Kawasaki
* @license MIT
* @see https://github.com/kawanet/timestamp-nano
*/
return Ipfs}));