Astroport.ONE/www/ipfs.js

121 lines
1.5 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsCore = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var IpfsCore=(()=>{var tue=Object.create;var S3=Object.defineProperty;var rue=Object.getOwnPropertyDescriptor;var nue=Object.getOwnPropertyNames;var iue=Object.getPrototypeOf,sue=Object.prototype.hasOwnProperty;var ld=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var oue=(r,e)=>()=>(r&&(e=r(r=0)),e);var R=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Re=(r,e)=>{for(var t in e)S3(r,t,{get:e[t],enumerable:!0})},OP=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nue(e))!sue.call(r,i)&&i!==t&&S3(r,i,{get:()=>e[i],enumerable:!(n=rue(e,i))||n.enumerable});return r};var _=(r,e,t)=>(t=r!=null?tue(iue(r)):{},OP(e||!r||!r.__esModule?S3(t,"default",{value:r,enumerable:!0}):t,r)),aue=r=>OP(S3({},"__esModule",{value:!0}),r);var MP=R(x3=>{"use strict";u();x3.byteLength=uue;x3.toByteArray=fue;x3.fromByteArray=pue;var zo=[],ms=[],cue=typeof Uint8Array<"u"?Uint8Array:Array,Y7="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(sf=0,LP=Y7.length;sf<LP;++sf)zo[sf]=Y7[sf],ms[Y7.charCodeAt(sf)]=sf;var sf,LP;ms["-".charCodeAt(0)]=62;ms["_".charCodeAt(0)]=63;function BP(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 uue(r){var e=BP(r),t=e[0],n=e[1];return(t+n)*3/4-n}function lue(r,e,t){return(e+t)*3/4-t}function fue(r){var e,t=BP(r),n=t[0],i=t[1],s=new cue(lue(r,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=ms[r.charCodeAt(c)]<<18|ms[r.charCodeAt(c+1)]<<12|ms[r.charCodeAt(c+2)]<<6|ms[r.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=ms[r.charCodeAt(c)]<<2|ms[r.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=ms[r.charCodeAt(c)]<<10|ms[r.charCodeAt(c+1)]<<4|ms[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function hue(r){return zo[r>>18&63]+zo[r>>12&63]+zo[r>>6&63]+zo[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(zo[e>>2]+zo[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(zo[e>>10]+zo[e>>4&63]+zo[e<<2&63]+"=")),i.join("")}});var UP=R(Q7=>{u();Q7.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)};Q7.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 md=R(pd=>{"use strict";u();var X7=MP(),hd=UP(),FP=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;pd.Buffer=H;pd.SlowBuffer=bue;pd.INSPECT_MAX_BYTES=50;var T3=2147483647;pd.kMaxLength=T3;H.TYPED_ARRAY_SUPPORT=mue();!H.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(H.prototype,"parent",{enumerable:!0,get:function(){if(!!H.isBuffer(this))return this.buffer}});Object.defineProperty(H.prototype,"offset",{enumerable:!0,get:function(){if(!!H.isBuffer(this))return this.byteOffset}});function Ga(r){if(r>T3)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,H.prototype),e}function H(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 t_(r)}return qP(r,e,t)}H.poolSize=8192;function qP(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(qo(r,ArrayBuffer)||r&&qo(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(qo(r,SharedArrayBuffer)||r&&qo(r.buffer,SharedArrayBuffer)))return J7(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 H.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 H.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)}H.from=function(r,e,t){return qP(r,e,t)};Object.setPrototypeOf(H.prototype,Uint8Array.prototype);Object.setPrototypeOf(H,Uint8Array);function $P(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 $P(r),r<=0?Ga(r):e!==void 0?typeof t=="string"?Ga(r).fill(e,t):Ga(r).fill(e):Ga(r)}H.alloc=function(r,e,t){return yue(r,e,t)};function t_(r){return $P(r),Ga(r<0?0:r_(r)|0)}H.allocUnsafe=function(r){return t_(r)};H.allocUnsafeSlow=function(r){return t_(r)};function gue(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!H.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=HP(r,e)|0,n=Ga(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function Z7(r){let e=r.length<0?0:r_(r.length)|0,t=Ga(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function wue(r){if(qo(r,Uint8Array)){let e=new Uint8Array(r);return J7(e.buffer,e.byteOffset,e.byteLength)}return Z7(r)}function J7(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,H.prototype),n}function Eue(r){if(H.isBuffer(r)){let e=r_(r.length)|0,t=Ga(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||i_(r.length)?Ga(0):Z7(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Z7(r.data)}function r_(r){if(r>=T3)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+T3.toString(16)+" bytes");return r|0}function bue(r){return+r!=r&&(r=0),H.alloc(+r)}H.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==H.prototype};H.compare=function(e,t){if(qo(e,Uint8Array)&&(e=H.from(e,e.offset,e.byteLength)),qo(t,Uint8Array)&&(t=H.from(t,t.offset,t.byteLength)),!H.isBuffer(e)||!H.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};H.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}};H.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return H.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=H.allocUnsafe(t),s=0;for(n=0;n<e.length;++n){let o=e[n];if(qo(o,Uint8Array))s+o.length>i.length?(H.isBuffer(o)||(o=H.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(H.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function HP(r,e){if(H.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||qo(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 e_(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ek(r).length;default:if(i)return n?-1:e_(r).length;e=(""+e).toLowerCase(),i=!0}}H.byteLength=HP;function _ue(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 Pue(this,e,t);case"utf8":case"utf-8":return WP(this,e,t);case"ascii":return Cue(this,e,t);case"latin1":case"binary":return Due(this,e,t);case"base64":return Aue(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return kue(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}H.prototype._isBuffer=!0;function of(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}H.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)of(this,t,t+1);return this};H.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)of(this,t,t+3),of(this,t+1,t+2);return this};H.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)of(this,t,t+7),of(this,t+1,t+6),of(this,t+2,t+5),of(this,t+3,t+4);return this};H.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?WP(this,0,e):_ue.apply(this,arguments)};H.prototype.toLocaleString=H.prototype.toString;H.prototype.equals=function(e){if(!H.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:H.compare(this,e)===0};H.prototype.inspect=function(){let e="",t=pd.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};FP&&(H.prototype[FP]=H.prototype.inspect);H.prototype.compare=function(e,t,n,i,s){if(qo(e,Uint8Array)&&(e=H.from(e,e.offset,e.byteLength)),!H.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 GP(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,i_(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=H.from(e,n)),H.isBuffer(e))return e.length===0?-1:VP(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):VP(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function VP(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}H.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};H.prototype.indexOf=function(e,t,n){return GP(this,e,t,n,!0)};H.prototype.lastIndexOf=function(e,t,n){return GP(this,e,t,n,!1)};function vue(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(i_(a))return o;r[t+o]=a}return o}function Sue(r,e,t,n){return I3(e_(e,r.length-t),r,t,n)}function xue(r,e,t,n){return I3(Bue(e),r,t,n)}function Tue(r,e,t,n){return I3(ek(e),r,t,n)}function Iue(r,e,t,n){return I3(Mue(e,r.length-t),r,t,n)}H.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 vue(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}};H.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?X7.fromByteArray(r):X7.fromByteArray(r.slice(e,t))}function WP(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 KP=4096;function Rue(r){let e=r.length;if(e<=KP)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=KP));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 Due(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 Pue(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 kue(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}H.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,H.prototype),i};function bn(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")}H.prototype.readUintLE=H.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bn(e,t,this.length);let i=this[e],s=1,o=0;for(;++o<t&&(s*=256);)i+=this[e+o]*s;return i};H.prototype.readUintBE=H.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bn(e,t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i};H.prototype.readUint8=H.prototype.readUInt8=function(e,t){return e=e>>>0,t||bn(e,1,this.length),this[e]};H.prototype.readUint16LE=H.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||bn(e,2,this.length),this[e]|this[e+1]<<8};H.prototype.readUint16BE=H.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||bn(e,2,this.length),this[e]<<8|this[e+1]};H.prototype.readUint32LE=H.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||bn(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};H.prototype.readUint32BE=H.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||bn(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};H.prototype.readBigUInt64LE=du(function(e){e=e>>>0,dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&S1(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))});H.prototype.readBigUInt64BE=du(function(e){e=e>>>0,dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&S1(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)});H.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||bn(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};H.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||bn(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};H.prototype.readInt8=function(e,t){return e=e>>>0,t||bn(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};H.prototype.readInt16LE=function(e,t){e=e>>>0,t||bn(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};H.prototype.readInt16BE=function(e,t){e=e>>>0,t||bn(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};H.prototype.readInt32LE=function(e,t){return e=e>>>0,t||bn(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};H.prototype.readInt32BE=function(e,t){return e=e>>>0,t||bn(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};H.prototype.readBigInt64LE=du(function(e){e=e>>>0,dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&S1(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)});H.prototype.readBigInt64BE=du(function(e){e=e>>>0,dd(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&S1(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)});H.prototype.readFloatLE=function(e,t){return e=e>>>0,t||bn(e,4,this.length),hd.read(this,e,!0,23,4)};H.prototype.readFloatBE=function(e,t){return e=e>>>0,t||bn(e,4,this.length),hd.read(this,e,!1,23,4)};H.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||bn(e,8,this.length),hd.read(this,e,!0,52,8)};H.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||bn(e,8,this.length),hd.read(this,e,!1,52,8)};function di(r,e,t,n,i,s){if(!H.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")}H.prototype.writeUintLE=H.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;di(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};H.prototype.writeUintBE=H.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;di(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};H.prototype.writeUint8=H.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||di(this,e,t,1,255,0),this[t]=e&255,t+1};H.prototype.writeUint16LE=H.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||di(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};H.prototype.writeUint16BE=H.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||di(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};H.prototype.writeUint32LE=H.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||di(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};H.prototype.writeUint32BE=H.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||di(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 jP(r,e,t,n,i){JP(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 YP(r,e,t,n,i){JP(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}H.prototype.writeBigUInt64LE=du(function(e,t=0){return jP(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeBigUInt64BE=du(function(e,t=0){return YP(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});H.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);di(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};H.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let c=Math.pow(2,8*n-1);di(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};H.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||di(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};H.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||di(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};H.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||di(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};H.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||di(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};H.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||di(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};H.prototype.writeBigInt64LE=du(function(e,t=0){return jP(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});H.prototype.writeBigInt64BE=du(function(e,t=0){return YP(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function QP(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 XP(r,e,t,n,i){return e=+e,t=t>>>0,i||QP(r,e,t,4,34028234663852886e22,-34028234663852886e22),hd.write(r,e,t,n,23,4),t+4}H.prototype.writeFloatLE=function(e,t,n){return XP(this,e,t,!0,n)};H.prototype.writeFloatBE=function(e,t,n){return XP(this,e,t,!1,n)};function ZP(r,e,t,n,i){return e=+e,t=t>>>0,i||QP(r,e,t,8,17976931348623157e292,-17976931348623157e292),hd.write(r,e,t,n,52,8),t+8}H.prototype.writeDoubleLE=function(e,t,n){return ZP(this,e,t,!0,n)};H.prototype.writeDoubleBE=function(e,t,n){return ZP(this,e,t,!1,n)};H.prototype.copy=function(e,t,n,i){if(!H.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};H.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"&&!H.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=H.isBuffer(e)?e:H.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 fd={};function n_(r,e,t){fd[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}`}}}n_("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);n_("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);n_("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=zP(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=zP(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function zP(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 Nue(r,e,t){dd(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&S1(e,r.length-(t+1))}function JP(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 fd.ERR_OUT_OF_RANGE("value",a,r)}Nue(n,i,s)}function dd(r,e){if(typeof r!="number")throw new fd.ERR_INVALID_ARG_TYPE(e,"number",r)}function S1(r,e,t){throw Math.floor(r)!==r?(dd(r,t),new fd.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new fd.ERR_BUFFER_OUT_OF_BOUNDS:new fd.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var Oue=/[^+/0-9A-Za-z-_]/g;function Lue(r){if(r=r.split("=")[0],r=r.trim().replace(Oue,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function e_(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 ek(r){return X7.toByteArray(Lue(r))}function I3(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 qo(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function i_(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 du(r){return typeof BigInt>"u"?Fue:r}function Fue(){throw new Error("BigInt not supported")}});var sk=R((BAe,ik)=>{u();var zr=ik.exports={},$o,Ho;function s_(){throw new Error("setTimeout has not been defined")}function o_(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?$o=setTimeout:$o=s_}catch{$o=s_}try{typeof clearTimeout=="function"?Ho=clearTimeout:Ho=o_}catch{Ho=o_}})();function tk(r){if($o===setTimeout)return setTimeout(r,0);if(($o===s_||!$o)&&setTimeout)return $o=setTimeout,setTimeout(r,0);try{return $o(r,0)}catch{try{return $o.call(null,r,0)}catch{return $o.call(this,r,0)}}}function Vue(r){if(Ho===clearTimeout)return clearTimeout(r);if((Ho===o_||!Ho)&&clearTimeout)return Ho=clearTimeout,clearTimeout(r);try{return Ho(r)}catch{try{return Ho.call(null,r)}catch{return Ho.call(this,r)}}}var Wa=[],yd=!1,af,A3=-1;function Kue(){!yd||!af||(yd=!1,af.length?Wa=af.concat(Wa):A3=-1,Wa.length&&rk())}function rk(){if(!yd){var r=tk(Kue);yd=!0;for(var e=Wa.length;e;){for(af=Wa,Wa=[];++A3<e;)af&&af[A3].run();A3=-1,e=Wa.length}af=null,yd=!1,Vue(r)}}zr.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];Wa.push(new nk(r,e)),Wa.length===1&&!yd&&tk(rk)};function nk(r,e){this.fun=r,this.array=e}nk.prototype.run=function(){this.fun.apply(null,this.array)};zr.title="browser";zr.browser=!0;zr.env={};zr.argv=[];zr.version="";zr.versions={};function ja(){}zr.on=ja;zr.addListener=ja;zr.once=ja;zr.off=ja;zr.removeListener=ja;zr.removeAllListeners=ja;zr.emit=ja;zr.prependListener=ja;zr.prependOnceListener=ja;zr.listeners=function(r){return[]};zr.binding=function(r){throw new Error("process.binding is not supported")};zr.cwd=function(){return"/"};zr.chdir=function(r){throw new Error("process.chdir is not supported")};zr.umask=function(){return 0}});var Buffer,process,u=oue(()=>{({Buffer}=md()),process=sk()});var ak=R((FAe,ok)=>{"use strict";u();ok.exports=r=>{if(Object.prototype.toString.call(r)!=="[object Object]")return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}});var c_=R((fk,hk)=>{"use strict";u();var R3=ak(),{hasOwnProperty:uk}=Object.prototype,{propertyIsEnumerable:zue}=Object,gd=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),que=fk,ck={concatArrays:!1,ignoreUndefined:!1},C3=r=>{let e=[];for(let t in r)uk.call(r,t)&&e.push(t);if(Object.getOwnPropertySymbols){let t=Object.getOwnPropertySymbols(r);for(let n of t)zue.call(r,n)&&e.push(n)}return e};function wd(r){return Array.isArray(r)?$ue(r):R3(r)?Hue(r):r}function $ue(r){let e=r.slice(0,0);return C3(r).forEach(t=>{gd(e,t,wd(r[t]))}),e}function Hue(r){let e=Object.getPrototypeOf(r)===null?Object.create(null):{};return C3(r).forEach(t=>{gd(e,t,wd(r[t]))}),e}var lk=(r,e,t,n)=>(t.forEach(i=>{typeof e[i]>"u"&&n.ignoreUndefined||(i in r&&r[i]!==Object.getPrototypeOf(r)?gd(r,i,a_(r[i],e[i],n)):gd(r,i,wd(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++)!uk.call(s,a)||(o.push(String(a)),s===r?gd(n,i++,s[a]):gd(n,i++,wd(s[a])));n=lk(n,s,C3(s).filter(a=>!o.includes(a)),t)}),n};function a_(r,e,t){return t.concatArrays&&Array.isArray(r)&&Array.isArray(e)?Gue(r,e,t):!R3(e)||!R3(r)?wd(e):lk(r,e,C3(e),t)}hk.exports=function(...r){let e=a_(wd(ck),this!==que&&this||{},ck),t={_:{}};for(let n of r)if(n!==void 0){if(!R3(n))throw new TypeError("`"+n+"` is not an Option Object");t=a_(t,{_:n},e)}return t._}});var u_=R(($Ae,pk)=>{u();function Wue(){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}pk.exports=Wue});var l_=R((GAe,mk)=>{"use strict";u();var jue=u_(),D3=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,x1=jue(),Yue=D3&&!x1,Que=x1&&!D3,Xue=x1&&D3,Zue=typeof ld=="function"&&typeof process<"u"&&typeof process.release<"u"&&process.release.name==="node"&&!x1,Jue=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,ele=typeof process<"u"&&typeof process.env<"u"&&!1,tle=typeof navigator<"u"&&navigator.product==="ReactNative";mk.exports={isTest:ele,isElectron:x1,isElectronMain:Que,isElectronRenderer:Xue,isNode:Zue,isBrowser:Yue,isWebWorker:Jue,isEnvWithDom:D3,isReactNative:tle}});var f_=R((YAe,yk)=>{u();var Ed=1e3,bd=Ed*60,_d=bd*60,cf=_d*24,rle=cf*7,nle=cf*365.25;yk.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return ile(r);if(t==="number"&&isFinite(r))return e.long?ole(r):sle(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function ile(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*nle;case"weeks":case"week":case"w":return t*rle;case"days":case"day":case"d":return t*cf;case"hours":case"hour":case"hrs":case"hr":case"h":return t*_d;case"minutes":case"minute":case"mins":case"min":case"m":return t*bd;case"seconds":case"second":case"secs":case"sec":case"s":return t*Ed;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function sle(r){var e=Math.abs(r);return e>=cf?Math.round(r/cf)+"d":e>=_d?Math.round(r/_d)+"h":e>=bd?Math.round(r/bd)+"m":e>=Ed?Math.round(r/Ed)+"s":r+"ms"}function ole(r){var e=Math.abs(r);return e>=cf?P3(r,e,cf,"day"):e>=_d?P3(r,e,_d,"hour"):e>=bd?P3(r,e,bd,"minute"):e>=Ed?P3(r,e,Ed,"second"):r+" ms"}function P3(r,e,t,n){var i=e>=t*1.5;return Math.round(r/t)+" "+n+(i?"s":"")}});var wk=R((XAe,gk)=>{u();function ale(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=i,t.enabled=o,t.humanize=f_(),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,E=Number(new Date),v=E-(h||E);w.diff=v,w.prev=h,w.curr=E,h=E,g[0]=t.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let x=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(T,S)=>{if(T==="%%")return"%";x++;let C=t.formatters[S];if(typeof C=="function"){let B=g[x];T=C.call(w,B),g.splice(x,1),x--}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}gk.exports=ale});var Ci=R((Ri,k3)=>{u();Ri.formatArgs=ule;Ri.save=lle;Ri.load=fle;Ri.useColors=cle;Ri.storage=hle();Ri.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`."))}})();Ri.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 cle(){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 ule(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+k3.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)}Ri.log=console.debug||console.log||(()=>{});function lle(r){try{r?Ri.storage.setItem("debug",r):Ri.storage.removeItem("debug")}catch{}}function fle(){let r;try{r=Ri.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function hle(){try{return localStorage}catch{}}k3.exports=wk()(Ri);var{formatters:dle}=k3.exports;dle.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var V=R((bRe,Sk)=>{"use strict";u();function vk(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Ple(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 vk(r,t)}catch{t.message=r.message,t.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),vk(new i,t)}}Sk.exports=Ple});var x_=R((vRe,xk)=>{"use strict";u();xk.exports=kle;function kle(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 T_=R(Ak=>{"use strict";u();var N3=Ak;N3.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 xd=new Array(64),Ik=new Array(123);for(Xs=0;Xs<64;)Ik[xd[Xs]=Xs<26?Xs+65:Xs<52?Xs+71:Xs<62?Xs-4:Xs-59|43]=Xs++;var Xs;N3.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++]=xd[l>>2],c=(l&3)<<4,a=1;break;case 1:s[o++]=xd[c|l>>4],c=(l&15)<<2,a=2;break;case 2:s[o++]=xd[c|l>>6],s[o++]=xd[l&63],a=0;break}o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),o=0)}return a&&(s[o++]=xd[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 Tk="invalid encoding";N3.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=Ik[c])===void 0)throw Error(Tk);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(Tk);return n-i};N3.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}});var I_=R((IRe,Rk)=>{"use strict";u();Rk.exports=O3;function O3(){this._listeners={}}O3.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this};O3.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};O3.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 A_=R((RRe,Ok)=>{"use strict";u();Ok.exports=Ck(Ck);function Ck(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,Dk),r.writeFloatBE=e.bind(null,Pk);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,kk),r.readFloatBE=t.bind(null,Nk)}(),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,Dk,0,4),r.writeDoubleBE=e.bind(null,Pk,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,kk,0,4),r.readDoubleBE=t.bind(null,Nk,4,0)}(),r}function Dk(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 Pk(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 kk(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0}function Nk(r,e){return(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}});var R_=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 D_=R(Lk=>{"use strict";u();var C_=Lk;C_.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};C_.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))};C_.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 P_=R((NRe,Bk)=>{"use strict";u();Bk.exports=Nle;function Nle(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 Uk=R((LRe,Mk)=>{"use strict";u();Mk.exports=_n;var T1=Ya();function _n(r,e){this.lo=r>>>0,this.hi=e>>>0}var uf=_n.zero=new _n(0,0);uf.toNumber=function(){return 0};uf.zzEncode=uf.zzDecode=function(){return this};uf.length=function(){return 1};var Ole=_n.zeroHash="\0\0\0\0\0\0\0\0";_n.fromNumber=function(e){if(e===0)return uf;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 _n(n,i)};_n.from=function(e){if(typeof e=="number")return _n.fromNumber(e);if(T1.isString(e))if(T1.Long)e=T1.Long.fromString(e);else return _n.fromNumber(parseInt(e,10));return e.low||e.high?new _n(e.low>>>0,e.high>>>0):uf};_n.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};_n.prototype.toLong=function(e){return T1.Long?new T1.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var yu=String.prototype.charCodeAt;_n.fromHash=function(e){return e===Ole?uf:new _n((yu.call(e,0)|yu.call(e,1)<<8|yu.call(e,2)<<16|yu.call(e,3)<<24)>>>0,(yu.call(e,4)|yu.call(e,5)<<8|yu.call(e,6)<<16|yu.call(e,7)<<24)>>>0)};_n.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)};_n.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};_n.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};_n.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 Ya=R(k_=>{"use strict";u();var Te=k_;Te.asPromise=x_();Te.base64=T_();Te.EventEmitter=I_();Te.float=A_();Te.inquire=R_();Te.utf8=D_();Te.pool=P_();Te.LongBits=Uk();Te.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);Te.global=Te.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||k_;Te.emptyArray=Object.freeze?Object.freeze([]):[];Te.emptyObject=Object.freeze?Object.freeze({}):{};Te.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};Te.isString=function(e){return typeof e=="string"||e instanceof String};Te.isObject=function(e){return e&&typeof e=="object"};Te.isset=Te.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};Te.Buffer=function(){try{var r=Te.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();Te._Buffer_from=null;Te._Buffer_allocUnsafe=null;Te.newBuffer=function(e){return typeof e=="number"?Te.Buffer?Te._Buffer_allocUnsafe(e):new Te.Array(e):Te.Buffer?Te._Buffer_from(e):typeof Uint8Array>"u"?e:new Uint8Array(e)};Te.Array=typeof Uint8Array<"u"?Uint8Array:Array;Te.Long=Te.global.dcodeIO&&Te.global.dcodeIO.Long||Te.global.Long||Te.inquire("long");Te.key2Re=/^true|false|0|1$/;Te.key32Re=/^-?(?:0|[1-9][0-9]*)$/;Te.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;Te.longToHash=function(e){return e?Te.LongBits.from(e).toHash():Te.LongBits.zeroHash};Te.longFromHash=function(e,t){var n=Te.LongBits.fromHash(e);return Te.Long?Te.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))};function Fk(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}Te.merge=Fk;Te.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function Vk(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&&Fk(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}Te.newError=Vk;Te.ProtocolError=Vk("ProtocolError");Te.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]}};Te.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}};Te.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};Te._configure=function(){var r=Te.Buffer;if(!r){Te._Buffer_from=Te._Buffer_allocUnsafe=null;return}Te._Buffer_from=r.from!==Uint8Array.from&&r.from||function(t,n){return new r(t,n)},Te._Buffer_allocUnsafe=r.allocUnsafe||function(t){return new r(t)}}});var B3=R((FRe,$k)=>{"use strict";u();$k.exports=It;var gs=Ya(),N_,L3=gs.LongBits,Kk=gs.base64,zk=gs.utf8;function I1(r,e,t){this.fn=r,this.len=e,this.next=void 0,this.val=t}function L_(){}function Lle(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function It(){this.len=0,this.head=new I1(L_,0,0),this.tail=this.head,this.states=null}var qk=function(){return gs.Buffer?function(){return(It.create=function(){return new N_})()}:function(){return new It}};It.create=qk();It.alloc=function(e){return new gs.Array(e)};gs.Array!==Array&&(It.alloc=gs.pool(It.alloc,gs.Array.prototype.subarray));It.prototype._push=function(e,t,n){return this.tail=this.tail.next=new I1(e,t,n),this.len+=t,this};function B_(r,e,t){e[t]=r&255}function Ble(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}function M_(r,e){this.len=r,this.next=void 0,this.val=e}M_.prototype=Object.create(I1.prototype);M_.prototype.fn=Ble;It.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new M_((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};It.prototype.int32=function(e){return e<0?this._push(U_,10,L3.fromNumber(e)):this.uint32(e)};It.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function U_(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}It.prototype.uint64=function(e){var t=L3.from(e);return this._push(U_,t.length(),t)};It.prototype.int64=It.prototype.uint64;It.prototype.sint64=function(e){var t=L3.from(e).zzEncode();return this._push(U_,t.length(),t)};It.prototype.bool=function(e){return this._push(B_,1,e?1:0)};function O_(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}It.prototype.fixed32=function(e){return this._push(O_,4,e>>>0)};It.prototype.sfixed32=It.prototype.fixed32;It.prototype.fixed64=function(e){var t=L3.from(e);return this._push(O_,4,t.lo)._push(O_,4,t.hi)};It.prototype.sfixed64=It.prototype.fixed64;It.prototype.float=function(e){return this._push(gs.float.writeFloatLE,4,e)};It.prototype.double=function(e){return this._push(gs.float.writeDoubleLE,8,e)};var Mle=gs.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]};It.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(B_,1,0);if(gs.isString(e)){var n=It.alloc(t=Kk.length(e));Kk.decode(e,n,0),e=n}return this.uint32(t)._push(Mle,t,e)};It.prototype.string=function(e){var t=zk.length(e);return t?this.uint32(t)._push(zk.write,t,e):this._push(B_,1,0)};It.prototype.fork=function(){return this.states=new Lle(this),this.head=this.tail=new I1(L_,0,0),this.len=0,this};It.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 I1(L_,0,0),this.len=0),this};It.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};It.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};It._configure=function(r){N_=r,It.create=qk(),N_._configure()}});var F_=R((KRe,Gk)=>{"use strict";u();Gk.exports=jo;var Hk=B3();(jo.prototype=Object.create(Hk.prototype)).constructor=jo;var gu=Ya();function jo(){Hk.call(this)}jo._configure=function(){jo.alloc=gu._Buffer_allocUnsafe,jo.writeBytesBuffer=gu.Buffer&&gu.Buffer.prototype instanceof Uint8Array&&gu.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++]}};jo.prototype.bytes=function(e){gu.isString(e)&&(e=gu._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(jo.writeBytesBuffer,t,e),this};function Ule(r,e,t){r.length<40?gu.utf8.write(r,e,t):e.utf8Write?e.utf8Write(r,t):e.write(r,t)}jo.prototype.string=function(e){var t=gu.Buffer.byteLength(e);return this.uint32(t),t&&this._push(Ule,t,e),this};jo._configure()});var U3=R((qRe,Xk)=>{"use strict";u();Xk.exports=qr;var Yo=Ya(),K_,Yk=Yo.LongBits,Fle=Yo.utf8;function Zs(r,e){return RangeError("index out of range: "+r.pos+" + "+(e||1)+" > "+r.len)}function qr(r){this.buf=r,this.pos=0,this.len=r.length}var Wk=typeof Uint8Array<"u"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new qr(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new qr(e);throw Error("illegal buffer")},Qk=function(){return Yo.Buffer?function(t){return(qr.create=function(i){return Yo.Buffer.isBuffer(i)?new K_(i):Wk(i)})(t)}:Wk};qr.create=Qk();qr.prototype._slice=Yo.Array.prototype.subarray||Yo.Array.prototype.slice;qr.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,Zs(this,10);return e}}();qr.prototype.int32=function(){return this.uint32()|0};qr.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function V_(){var r=new Yk(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 Zs(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 Zs(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")}qr.prototype.bool=function(){return this.uint32()!==0};function M3(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}qr.prototype.fixed32=function(){if(this.pos+4>this.len)throw Zs(this,4);return M3(this.buf,this.pos+=4)};qr.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Zs(this,4);return M3(this.buf,this.pos+=4)|0};function jk(){if(this.pos+8>this.len)throw Zs(this,8);return new Yk(M3(this.buf,this.pos+=4),M3(this.buf,this.pos+=4))}qr.prototype.float=function(){if(this.pos+4>this.len)throw Zs(this,4);var e=Yo.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};qr.prototype.double=function(){if(this.pos+8>this.len)throw Zs(this,4);var e=Yo.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};qr.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Zs(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)};qr.prototype.string=function(){var e=this.bytes();return Fle.read(e,0,e.length)};qr.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Zs(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Zs(this);while(this.buf[this.pos++]&128);return this};qr.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};qr._configure=function(r){K_=r,qr.create=Qk(),K_._configure();var e=Yo.Long?"toLong":"toNumber";Yo.merge(qr.prototype,{int64:function(){return V_.call(this)[e](!1)},uint64:function(){return V_.call(this)[e](!0)},sint64:function(){return V_.call(this).zzDecode()[e](!1)},fixed64:function(){return jk.call(this)[e](!0)},sfixed64:function(){return jk.call(this)[e](!1)}})}});var z_=R((HRe,eN)=>{"use strict";u();eN.exports=lf;var Jk=U3();(lf.prototype=Object.create(Jk.prototype)).constructor=lf;var Zk=Ya();function lf(r){Jk.call(this,r)}lf._configure=function(){Zk.Buffer&&(lf.prototype._slice=Zk.Buffer.prototype.slice)};lf.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))};lf._configure()});var rN=R((WRe,tN)=>{"use strict";u();tN.exports=A1;var q_=Ya();(A1.prototype=Object.create(q_.EventEmitter.prototype)).constructor=A1;function A1(r,e,t){if(typeof r!="function")throw TypeError("rpcImpl must be a function");q_.EventEmitter.call(this),this.rpcImpl=r,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(t)}A1.prototype.rpcCall=function r(e,t,n,i,s){if(!i)throw TypeError("request must be specified");var o=this;if(!s)return q_.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}};A1.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var iN=R(nN=>{"use strict";u();var Vle=nN;Vle.Service=rN()});var oN=R((XRe,sN)=>{"use strict";u();sN.exports={}});var uN=R(cN=>{"use strict";u();var pi=cN;pi.build="minimal";pi.Writer=B3();pi.BufferWriter=F_();pi.Reader=U3();pi.BufferReader=z_();pi.util=Ya();pi.rpc=iN();pi.roots=oN();pi.configure=aN;function aN(){pi.util._configure(),pi.Writer._configure(pi.BufferWriter),pi.Reader._configure(pi.BufferReader)}aN()});var Qo=R((tCe,lN)=>{"use strict";u();lN.exports=uN()});var eL=R((wke,JO)=>{"use strict";u();JO.exports=function(){return Date.now()}});var z1=R((bke,tL)=>{"use strict";u();var i4=eL(),Sv=class{constructor(e,t,n){let i=this;this._started=i4(),this._rescheduled=0,this._scheduled=t,this._args=n,this._triggered=!1,this._timerWrapper=()=>{i._rescheduled>0?(i._scheduled=i._rescheduled-(i4()-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=i4();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=i4(),this._rescheduled=0,this._scheduled=e,this._timer=setTimeout(this._timerWrapper,e)}clear(){clearTimeout(this._timer)}};function Yhe(){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 Sv(arguments[0],arguments[1],r)}tL.exports=Yhe});var pn=R((vke,nL)=>{"use strict";u();var{AbortController:Qhe}=globalThis,rL=z1(),q1=class extends Qhe{constructor(e){super(),this._ms=e,this._timer=rL(()=>this.abort(),e),Object.setPrototypeOf(this,q1.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=rL(()=>this.abort(),this._ms)}};nL.exports={TimeoutController:q1}});var pL=R((eNe,dL)=>{u();dL.exports=Pv;var hL=128,ode=127,ade=~ode,cde=Math.pow(2,31);function Pv(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Pv.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=cde;)e[t++]=r&255|hL,r/=128;for(;r&ade;)e[t++]=r&255|hL,r>>>=7;return e[t]=r|0,Pv.bytes=t-n+1,e}});var gL=R((rNe,yL)=>{u();yL.exports=kv;var ude=128,mL=127;function kv(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a||i>49)throw kv.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&mL)<<i:(o&mL)*Math.pow(2,i),i+=7}while(o>=ude);return kv.bytes=s-n,t}});var EL=R((iNe,wL)=>{u();var lde=Math.pow(2,7),fde=Math.pow(2,14),hde=Math.pow(2,21),dde=Math.pow(2,28),pde=Math.pow(2,35),mde=Math.pow(2,42),yde=Math.pow(2,49),gde=Math.pow(2,56),wde=Math.pow(2,63);wL.exports=function(r){return r<lde?1:r<fde?2:r<hde?3:r<dde?4:r<pde?5:r<mde?6:r<yde?7:r<gde?8:r<wde?9:10}});var Jo=R((oNe,bL)=>{u();bL.exports={encode:pL(),decode:gL(),encodingLength:EL()}});var Gv=R((VNe,KL)=>{"use strict";u();var zde=typeof navigator<"u"&&navigator.product==="ReactNative";function qde(){return zde?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var Q1=self.URL,VL=qde(),Hv=class{constructor(e="",t=VL){this.super=new Q1(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 Q1.createObjectURL(e)}static revokeObjectURL(e){Q1.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function $de(r){if(typeof r=="string")return new Q1(r).toString();if(!(r instanceof Q1)){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}`}}KL.exports={URLWithLegacySupport:Hv,URLSearchParams:self.URLSearchParams,defaultBase:VL,format:$de}});var $L=R((zNe,qL)=>{"use strict";u();var{URLWithLegacySupport:zL,format:Hde}=Gv();qL.exports=(r,e={},t={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(t[i]||n||i)+":";let s;try{s=new zL(r)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new zL(r,Hde(o)).toString()}});var y4=R(($Ne,HL)=>{"use strict";u();var{URLWithLegacySupport:Gde,format:Wde,URLSearchParams:jde,defaultBase:Yde}=Gv(),Qde=$L();HL.exports={URL:Gde,URLSearchParams:jde,format:Wde,relative:Qde,defaultBase:Yde}});var ri=R((sOe,Wv)=>{u();function rB(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}Wv.exports=rB;Wv.exports.anySignal=rB});var qd=R((OOe,fB)=>{u();fB.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 Ru=R((UOe,Qv)=>{"use strict";u();var npe=Object.prototype.hasOwnProperty,ni="~";function J1(){}Object.create&&(J1.prototype=Object.create(null),new J1().__proto__||(ni=!1));function ipe(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function dB(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new ipe(t,n||r,i),o=ni?ni+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 A4(r,e){--r._eventsCount===0?r._events=new J1:delete r._events[e]}function Wn(){this._events=new J1,this._eventsCount=0}Wn.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)npe.call(t,n)&&e.push(ni?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Wn.prototype.listeners=function(e){var t=ni?ni+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};Wn.prototype.listenerCount=function(e){var t=ni?ni+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Wn.prototype.emit=function(e,t,n,i,s,o){var a=ni?ni+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};Wn.prototype.on=function(e,t,n){return dB(this,e,t,n,!1)};Wn.prototype.once=function(e,t,n){return dB(this,e,t,n,!0)};Wn.prototype.removeListener=function(e,t,n,i){var s=ni?ni+e:e;if(!this._events[s])return this;if(!t)return A4(this,s),this;var o=this._events[s];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&A4(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:A4(this,s)}return this};Wn.prototype.removeAllListeners=function(e){var t;return e?(t=ni?ni+e:e,this._events[t]&&A4(this,t)):(this._events=new J1,this._eventsCount=0),this};Wn.prototype.off=Wn.prototype.removeListener;Wn.prototype.addListener=Wn.prototype.on;Wn.prefixed=ni;Wn.EventEmitter=Wn;typeof Qv<"u"&&(Qv.exports=Wn)});var o9=R(L4=>{"use strict";u();var n9=class extends Error{constructor(e="Request timed out"){super(e),this.name="TimeoutError"}};L4.TimeoutError=n9;var i9=class extends Error{constructor(e="The operation was aborted."){super(e),this.name="AbortError"}};L4.AbortError=i9;var s9=class extends Error{constructor(e){super(e.statusText),this.name="HTTPError",this.response=e}};L4.HTTPError=s9});var am=R(($d,SB)=>{"use strict";u();var ope=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof fc<"u")return fc;throw new Error("unable to locate global object")},fc=ope();SB.exports=$d=fc.fetch;fc.fetch&&($d.default=fc.fetch.bind(fc));$d.Headers=fc.Headers;$d.Request=fc.Request;$d.Response=fc.Response});var xB=R((eLe,a9)=>{"use strict";u();globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?a9.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:a9.exports={default:am().default,Headers:am().Headers,Request:am().Request,Response:am().Response}});var IB=R((rLe,TB)=>{"use strict";u();TB.exports=xB()});var CB=R((iLe,RB)=>{"use strict";u();var{TimeoutError:ape,AbortError:cpe}=o9(),{Response:AB,Request:upe,Headers:u9,default:lpe}=IB(),fpe=(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 u9(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(AB.error());break}case"load":{s(new c9(t.responseURL,t.response,{status:t.status,statusText:t.statusText,headers:ppe(t.getAllResponseHeaders())}));break}case"timeout":{o(new ape);break}case"abort":{o(new cpe);break}default:break}};t.onerror=a,t.onload=a,t.ontimeout=a,t.onabort=a,t.send(e.body)})},hpe=lpe,dpe=(r,e={})=>e.onUploadProgress!=null?fpe(r,e):hpe(r,e),ppe=r=>{let e=new u9;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 AB{constructor(e,t,n){super(t,n),Object.defineProperty(this,"url",{value:e})}};RB.exports={fetch:dpe,Request:upe,Headers:u9}});var Hd=R((oLe,LB)=>{"use strict";u();var{fetch:mpe,Request:ype,Headers:gpe}=CB(),{TimeoutError:l9,HTTPError:NB}=o9(),DB=c_().bind({ignoreUndefined:!0}),{URL:PB,URLSearchParams:kB}=y4(),wpe=ri(),Epe=(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 l9),t.abort())},e),c=l=>h=>{if(clearTimeout(a),i()){o(new l9);return}l(h)};r.then(c(s),c(o))})},bpe={throwHttpErrors:!0,credentials:"same-origin"},jn=class{constructor(e={}){this.opts=DB(bpe,e)}async fetch(e,t={}){let n=DB(this.opts,t),i=new gpe(n.headers);if(typeof e!="string"&&!(e instanceof PB||e instanceof ype))throw new TypeError("`resource` must be a string, URL, or Request");let s=new PB(e.toString(),n.base),{searchParams:o,transformSearchParams:a,json:c}=n;o&&(typeof a=="function"?s.search=a(new kB(n.searchParams)):s.search=new kB(n.searchParams)),c&&(n.body=JSON.stringify(n.json),i.set("content-type","application/json"));let l=new AbortController,f=wpe([l.signal,n.signal]),h=await Epe(mpe(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 NB(h);return h.iterator=async function*(){yield*OB(h.body)},h.ndjson=async function*(){for await(let p of _pe(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"})}},_pe=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))},OB=r=>{if(xpe(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(Spe(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(vpe(r))return r;throw new TypeError("Body can't be converted to AsyncIterable")},vpe=r=>typeof r=="object"&&r!==null&&typeof r[Symbol.asyncIterator]=="function",Spe=r=>r&&typeof r.getReader=="function",xpe=r=>Object.prototype.hasOwnProperty.call(r,"readable")&&Object.prototype.hasOwnProperty.call(r,"writable");jn.HTTPError=NB;jn.TimeoutError=l9;jn.streamToAsyncIterator=OB;jn.post=(r,e)=>new jn(e).post(r,e);jn.get=(r,e)=>new jn(e).get(r,e);jn.put=(r,e)=>new jn(e).put(r,e);jn.delete=(r,e)=>new jn(e).delete(r,e);jn.options=(r,e)=>new jn(e).options(r,e);LB.exports=jn});var QB=R((vBe,y9)=>{u();var _Be=function(){typeof y9<"u"&&(y9.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||Ue,p=w.prototype;w.fromDate=B,w.fromInt64BE=Ae(0,1,2,3,0,4),w.fromInt64LE=Ae(3,2,1,0,4,0),w.fromString=C,w.fromTimeT=q,p.year=0,p.time=0,p.nano=0,p.addNano=T,p.getNano=S,p.getTimeT=oe,p.getYear=E,p.toDate=x,p.toJSON=te,p.toString=Ve,p.writeInt64BE=me(0,1,2,3,0,4),p.writeInt64LE=me(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(Z,le,ae){var xe=this;if(!(xe instanceof w))return new w(Z,le,ae);xe.time=+Z||0,xe.nano=+le||0,xe.year=+ae||0,v(xe)}function E(){var Z=this.toDate().getUTCFullYear();return Z+this.year}function v(Z){var le=Z.year,ae=Z.time,xe=Z.nano,Oe,Ne;if(xe<0||c<=xe){var Nt=Math.floor(xe/c);xe-=Nt*c,ae+=Nt,Oe=1}var qt=le%e;if(ae<-s||s<ae||qt){Ne=h(ae/i),Ne&&(le+=Ne*e,ae-=Ne*i);var He=I(ae);He.setUTCFullYear(qt+He.getUTCFullYear()),le-=qt,ae=+He,Ne=h(le/e);var Xe=ae+Ne*i;Ne&&-s<=Xe&&Xe<=s&&(le-=Ne*e,ae=Xe),Oe=1}return Oe&&(Z.year=le,Z.time=ae,Z.nano=xe),Z}function x(){var Z=v(this);return I(Z.time)}function I(Z){var le=new Date(0);return le.setTime(Z),le}function T(Z){return this.nano+=+Z||0,this}function S(){var Z=v(this);return(Z.time%1e3*c+ +Z.nano+l)%l}function C(Z){var le,ae=new w;Z+="";var xe=Z.replace(/^\s*[+\-]?\d+/,function(Oe){var Ne=+Oe,Nt=1970+(Ne-1970)%400;return ae.year=Ne-Nt,Nt}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(Oe,Ne,Nt){return Ne<0&&(Nt*=-1),le=(+Ne*60+ +Nt)*6e4,""}).replace(/\.\d+$/,function(Oe){return ae.nano=+(Oe+f).substr(1,9),""}).split(/\D+/);if(xe.length>1?xe[1]--:xe[1]=0,ae.time=le=Date.UTC.apply(Date,xe)-(le||0),isNaN(le))throw new TypeError("Invalid Date");return v(ae)}function B(Z){return new w(+Z)}function q(Z){return W(Z,0)}function W(Z,le){le|=0,le*=a,Z=+Z||0;var ae=h(le/n)+h(Z/n),xe=le%n+Z%n,Oe=h(xe/n);return Oe&&(ae+=Oe,xe-=Oe*n),new w(xe*1e3,0,ae*e)}function oe(){var Z=v(this),le=Math.floor(Z.time/1e3),ae=Z.year;return ae&&(le+=ae*t*r/e),le}function te(){return this.toString().replace(/0{1,6}Z$/,"Z")}function Ve(Z){var le=this,ae=le.toDate(),xe={H:Xe,L:Vr,M:$t,N:Kr,S:Er,Y:Ne,a:_1,b:v1,d:qt,e:He,m:Nt};return Oe(Z||d);function Oe(Qs){return Qs.replace(/%./g,function(DP){var PP=DP[1],kP=g[PP],NP=xe[PP];return kP?Oe(kP):NP?NP():DP})}function Ne(){var Qs=le.getYear();return Qs>999999?"+"+Qs:Qs>9999?"+"+Ye(Qs,6):Qs>=0?Ye(Qs,4):Qs>=-999999?"-"+Ye(-Qs,6):Qs}function Nt(){return je(ae.getUTCMonth()+1)}function qt(){return je(ae.getUTCDate())}function He(){return zt(ae.getUTCDate())}function Xe(){return je(ae.getUTCHours())}function $t(){return je(ae.getUTCMinutes())}function Er(){return je(ae.getUTCSeconds())}function Vr(){return Ye(ae.getUTCMilliseconds(),3)}function Kr(){return Ye(le.getNano(),9)}function _1(){return y[ae.getUTCDay()]}function v1(){return m[ae.getUTCMonth()]}}function me(Z,le,ae,xe,Oe,Ne){return Nt;function Nt(He,Xe){var $t=v(this);He||(He=new Array(8)),$(He,Xe|=0);var Er=Math.floor($t.time/1e3),Vr=$t.year*(t*r/e),Kr=h(Vr/a)+h(Er/a),_1=Vr%a+Er%a,v1=Math.floor(_1/a);return v1&&(Kr+=v1,_1-=v1*a),qt(He,Xe+Oe,Kr),qt(He,Xe+Ne,_1),He}function qt(He,Xe,$t){He[Xe+Z]=$t>>24&255,He[Xe+le]=$t>>16&255,He[Xe+ae]=$t>>8&255,He[Xe+xe]=$t&255}}function Ae(Z,le,ae,xe,Oe,Ne){return Nt;function Nt(He,Xe){$(He,Xe|=0);var $t=qt(He,Xe+Oe),Er=qt(He,Xe+Ne);return W(Er,$t)}function qt(He,Xe){return He[Xe+Z]*o+(He[Xe+le]<<16|He[Xe+ae]<<8|He[Xe+xe])}}function $(Z,le){var ae=Z&&Z.length;if(ae==null)throw new TypeError("Invalid Buffer");if(ae<le+8)throw new RangeError("Out of range")}function Ue(Z){var le=Z-Z%1;return le===0&&(Z<0||Z===0&&1/Z!==1/0)?-0:le}function zt(Z){return(Z>9?"":" ")+(Z|0)}function je(Z){return(Z>9?"":"0")+(Z|0)}function Ye(Z,le){return(f+(Z|0)).substr(-le)}}()});var ut=R((YBe,tM)=>{u();tM.exports={options:{usePureJavaScript:!1}}});var iM=R((XBe,nM)=>{u();var v9={};nM.exports=v9;var rM={};v9.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=Lpe(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};v9.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=rM[e];if(!t){t=rM[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 Lpe(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 er=R((JBe,cM)=>{u();var sM=ut(),oM=iM(),O=cM.exports=sM.util=sM.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){O.nextTick=process.nextTick,typeof setImmediate=="function"?O.setImmediate=setImmediate:O.setImmediate=O.nextTick;return}if(typeof setImmediate=="function"){O.setImmediate=function(){return setImmediate.apply(void 0,arguments)},O.nextTick=function(a){return setImmediate(a)};return}if(O.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=[];O.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=O.setImmediate;O.setImmediate=function(c){Date.now()-t>15?(t=Date.now(),s(c)):(e.push(c),e.length===1&&i.setAttribute("a",n=!n))}}O.nextTick=O.setImmediate})();O.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;O.globalScope=function(){return O.isNodejs?globalThis:typeof self>"u"?window:self}();O.isArray=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"};O.isArrayBuffer=function(r){return typeof ArrayBuffer<"u"&&r instanceof ArrayBuffer};O.isArrayBufferView=function(r){return r&&O.isArrayBuffer(r.buffer)&&r.byteLength!==void 0};function lm(r){if(!(r===8||r===16||r===24||r===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+r)}O.ByteBuffer=S9;function S9(r){if(this.data="",this.read=0,typeof r=="string")this.data=r;else if(O.isArrayBuffer(r)||O.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 S9||typeof r=="object"&&typeof r.data=="string"&&typeof r.read=="number")&&(this.data=r.data,this.read=r.read);this._constructedStringLength=0}O.ByteStringBuffer=S9;var Bpe=4096;O.ByteStringBuffer.prototype._optimizeConstructedString=function(r){this._constructedStringLength+=r,this._constructedStringLength>Bpe&&(this.data.substr(0,1),this._constructedStringLength=0)};O.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};O.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};O.ByteStringBuffer.prototype.putByte=function(r){return this.putBytes(String.fromCharCode(r))};O.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};O.ByteStringBuffer.prototype.putBytes=function(r){return this.data+=r,this._optimizeConstructedString(r.length),this};O.ByteStringBuffer.prototype.putString=function(r){return this.putBytes(O.encodeUtf8(r))};O.ByteStringBuffer.prototype.putInt16=function(r){return this.putBytes(String.fromCharCode(r>>8&255)+String.fromCharCode(r&255))};O.ByteStringBuffer.prototype.putInt24=function(r){return this.putBytes(String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r&255))};O.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))};O.ByteStringBuffer.prototype.putInt16Le=function(r){return this.putBytes(String.fromCharCode(r&255)+String.fromCharCode(r>>8&255))};O.ByteStringBuffer.prototype.putInt24Le=function(r){return this.putBytes(String.fromCharCode(r&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r>>16&255))};O.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))};O.ByteStringBuffer.prototype.putInt=function(r,e){lm(e);var t="";do e-=8,t+=String.fromCharCode(r>>e&255);while(e>0);return this.putBytes(t)};O.ByteStringBuffer.prototype.putSignedInt=function(r,e){return r<0&&(r+=2<<e-1),this.putInt(r,e)};O.ByteStringBuffer.prototype.putBuffer=function(r){return this.putBytes(r.getBytes())};O.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};O.ByteStringBuffer.prototype.getInt16=function(){var r=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,r};O.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};O.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};O.ByteStringBuffer.prototype.getInt16Le=function(){var r=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,r};O.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};O.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};O.ByteStringBuffer.prototype.getInt=function(r){lm(r);var e=0;do e=(e<<8)+this.data.charCodeAt(this.read++),r-=8;while(r>0);return e};O.ByteStringBuffer.prototype.getSignedInt=function(r){var e=this.getInt(r),t=2<<r-2;return e>=t&&(e-=t<<1),e};O.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};O.ByteStringBuffer.prototype.bytes=function(r){return typeof r>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+r)};O.ByteStringBuffer.prototype.at=function(r){return this.data.charCodeAt(this.read+r)};O.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};O.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};O.ByteStringBuffer.prototype.copy=function(){var r=O.createBuffer(this.data);return r.read=this.read,r};O.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};O.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};O.ByteStringBuffer.prototype.truncate=function(r){var e=Math.max(0,this.length()-r);return this.data=this.data.substr(this.read,e),this.read=0,this};O.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};O.ByteStringBuffer.prototype.toString=function(){return O.decodeUtf8(this.bytes())};function Mpe(r,e){e=e||{},this.read=e.readOffset||0,this.growSize=e.growSize||1024;var t=O.isArrayBuffer(r),n=O.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)}O.DataBuffer=Mpe;O.DataBuffer.prototype.length=function(){return this.write-this.read};O.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};O.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};O.DataBuffer.prototype.putByte=function(r){return this.accommodate(1),this.data.setUint8(this.write++,r),this};O.DataBuffer.prototype.fillWithByte=function(r,e){this.accommodate(e);for(var t=0;t<e;++t)this.data.setUint8(r);return this};O.DataBuffer.prototype.putBytes=function(r,e){if(O.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(O.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 O.DataBuffer||typeof r=="object"&&typeof r.read=="number"&&typeof r.write=="number"&&O.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 O.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+=O.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+=O.binary.base64.decode(r,s,this.write),this;if(e==="utf8"&&(r=O.encodeUtf8(r),e="binary"),e==="binary"||e==="raw")return this.accommodate(r.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=O.binary.raw.decode(s),this;if(e==="utf16")return this.accommodate(r.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=O.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+e)}throw Error("Invalid parameter: "+r)};O.DataBuffer.prototype.putBuffer=function(r){return this.putBytes(r),r.clear(),this};O.DataBuffer.prototype.putString=function(r){return this.putBytes(r,"utf16")};O.DataBuffer.prototype.putInt16=function(r){return this.accommodate(2),this.data.setInt16(this.write,r),this.write+=2,this};O.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};O.DataBuffer.prototype.putInt32=function(r){return this.accommodate(4),this.data.setInt32(this.write,r),this.write+=4,this};O.DataBuffer.prototype.putInt16Le=function(r){return this.accommodate(2),this.data.setInt16(this.write,r,!0),this.write+=2,this};O.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};O.DataBuffer.prototype.putInt32Le=function(r){return this.accommodate(4),this.data.setInt32(this.write,r,!0),this.write+=4,this};O.DataBuffer.prototype.putInt=function(r,e){lm(e),this.accommodate(e/8);do e-=8,this.data.setInt8(this.write++,r>>e&255);while(e>0);return this};O.DataBuffer.prototype.putSignedInt=function(r,e){return lm(e),this.accommodate(e/8),r<0&&(r+=2<<e-1),this.putInt(r,e)};O.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};O.DataBuffer.prototype.getInt16=function(){var r=this.data.getInt16(this.read);return this.read+=2,r};O.DataBuffer.prototype.getInt24=function(){var r=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,r};O.DataBuffer.prototype.getInt32=function(){var r=this.data.getInt32(this.read);return this.read+=4,r};O.DataBuffer.prototype.getInt16Le=function(){var r=this.data.getInt16(this.read,!0);return this.read+=2,r};O.DataBuffer.prototype.getInt24Le=function(){var r=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,r};O.DataBuffer.prototype.getInt32Le=function(){var r=this.data.getInt32(this.read,!0);return this.read+=4,r};O.DataBuffer.prototype.getInt=function(r){lm(r);var e=0;do e=(e<<8)+this.data.getInt8(this.read++),r-=8;while(r>0);return e};O.DataBuffer.prototype.getSignedInt=function(r){var e=this.getInt(r),t=2<<r-2;return e>=t&&(e-=t<<1),e};O.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};O.DataBuffer.prototype.bytes=function(r){return typeof r>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+r)};O.DataBuffer.prototype.at=function(r){return this.data.getUint8(this.read+r)};O.DataBuffer.prototype.setAt=function(r,e){return this.data.setUint8(r,e),this};O.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};O.DataBuffer.prototype.copy=function(){return new O.DataBuffer(this)};O.DataBuffer.prototype.compact=function(){if(this.read>0){var 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};O.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};O.DataBuffer.prototype.truncate=function(r){return this.write=Math.max(0,this.length()-r),this.read=Math.min(this.read,this.write),this};O.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};O.DataBuffer.prototype.toString=function(r){var e=new Uint8Array(this.data,this.read,this.length());if(r=r||"utf8",r==="binary"||r==="raw")return O.binary.raw.encode(e);if(r==="hex")return O.binary.hex.encode(e);if(r==="base64")return O.binary.base64.encode(e);if(r==="utf8")return O.text.utf8.decode(e);if(r==="utf16")return O.text.utf16.decode(e);throw new Error("Invalid encoding: "+r)};O.createBuffer=function(r,e){return e=e||"raw",r!==void 0&&e==="utf8"&&(r=O.encodeUtf8(r)),new O.ByteBuffer(r)};O.fillString=function(r,e){for(var t="";e>0;)e&1&&(t+=r),e>>>=1,e>0&&(r+=r);return t};O.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};O.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};O.bytesToHex=function(r){return O.createBuffer(r).toHex()};O.int32ToBytes=function(r){return String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(r&255)};var Pu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ku=[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],aM="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";O.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+=Pu.charAt(i>>2),t+=Pu.charAt((i&3)<<4|s>>4),isNaN(s)?t+="==":(t+=Pu.charAt((s&15)<<2|o>>6),t+=isNaN(o)?"=":Pu.charAt(o&63)),e&&t.length>e&&(n+=t.substr(0,e)+`\r
`,t=t.substr(e));return n+=t,n};O.decode64=function(r){r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e="",t,n,i,s,o=0;o<r.length;)t=ku[r.charCodeAt(o++)-43],n=ku[r.charCodeAt(o++)-43],i=ku[r.charCodeAt(o++)-43],s=ku[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};O.encodeUtf8=function(r){return unescape(encodeURIComponent(r))};O.decodeUtf8=function(r){return decodeURIComponent(escape(r))};O.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:oM.encode,decode:oM.decode}};O.binary.raw.encode=function(r){return String.fromCharCode.apply(null,r)};O.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};O.binary.hex.encode=O.bytesToHex;O.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};O.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+=Pu.charAt(i>>2),t+=Pu.charAt((i&3)<<4|s>>4),isNaN(s)?t+="==":(t+=Pu.charAt((s&15)<<2|o>>6),t+=isNaN(o)?"=":Pu.charAt(o&63)),e&&t.length>e&&(n+=t.substr(0,e)+`\r
`,t=t.substr(e));return n+=t,n};O.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=ku[r.charCodeAt(c++)-43],s=ku[r.charCodeAt(c++)-43],o=ku[r.charCodeAt(c++)-43],a=ku[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)};O.binary.base58.encode=function(r,e){return O.binary.baseN.encode(r,aM,e)};O.binary.base58.decode=function(r,e){return O.binary.baseN.decode(r,aM,e)};O.text={utf8:{},utf16:{}};O.text.utf8.encode=function(r,e,t){r=O.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};O.text.utf8.decode=function(r){return O.decodeUtf8(String.fromCharCode.apply(null,r))};O.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};O.text.utf16.decode=function(r){return String.fromCharCode.apply(null,new Uint16Array(r.buffer))};O.deflate=function(r,e,t){if(e=O.decode64(r.deflate(O.encode64(e)).rval),t){var n=2,i=e.charCodeAt(1);i&32&&(n=6),e=e.substring(n,e.length-4)}return e};O.inflate=function(r,e,t){var n=r.inflate(O.encode64(e)).rval;return n===null?null:O.decode64(n)};var x9=function(r,e,t){if(!r)throw new Error("WebStorage not available.");var n;if(t===null?n=r.removeItem(e):(t=O.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}},T9=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(O.decode64(t))),t},Upe=function(r,e,t,n){var i=T9(r,e);i===null&&(i={}),i[t]=n,x9(r,e,i)},Fpe=function(r,e,t){var n=T9(r,e);return n!==null&&(n=t in n?n[t]:null),n},Vpe=function(r,e,t){var n=T9(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),x9(r,e,n)}},Kpe=function(r,e){x9(r,e,null)},K4=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};O.setItem=function(r,e,t,n,i){K4(Upe,arguments,i)};O.getItem=function(r,e,t,n){return K4(Fpe,arguments,n)};O.removeItem=function(r,e,t,n){K4(Vpe,arguments,n)};O.clearItems=function(r,e,t){K4(Kpe,arguments,t)};O.isEmpty=function(r){for(var e in r)if(r.hasOwnProperty(e))return!1;return!0};O.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("")};O.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):"")};O.formatSize=function(r){return r>=1073741824?r=O.formatNumber(r/1073741824,2,".","")+" GiB":r>=1048576?r=O.formatNumber(r/1048576,2,".","")+" MiB":r>=1024?r=O.formatNumber(r/1024,0)+" KiB":r=O.formatNumber(r,0)+" bytes",r};O.bytesFromIP=function(r){return r.indexOf(".")!==-1?O.bytesFromIPv4(r):r.indexOf(":")!==-1?O.bytesFromIPv6(r):null};O.bytesFromIPv4=function(r){if(r=r.split("."),r.length!==4)return null;for(var e=O.createBuffer(),t=0;t<r.length;++t){var n=parseInt(r[t],10);if(isNaN(n))return null;e.putByte(n)}return e.getBytes()};O.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=O.createBuffer(),i=0;i<8;++i){if(!r[i]||r[i].length===0){n.fillWithByte(0,t),t=0;continue}var s=O.hexToBytes(r[i]);s.length<2&&n.putByte(0),n.putBytes(s)}return n.getBytes()};O.bytesToIP=function(r){return r.length===4?O.bytesToIPv4(r):r.length===16?O.bytesToIPv6(r):null};O.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(".")};O.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=O.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(":")};O.estimateCores=function(r,e){if(typeof r=="function"&&(e=r,r={}),r=r||{},"cores"in O&&!r.update)return e(null,O.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return O.cores=navigator.hardwareConcurrency,e(null,O.cores);if(typeof Worker>"u")return O.cores=1,e(null,O.cores);if(typeof Blob>"u")return O.cores=2,e(null,O.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 O.cores=Math.max(1,l),URL.revokeObjectURL(t),e(null,O.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 Qd=R((tMe,uM)=>{u();var fm=ut();fm.pki=fm.pki||{};var I9=uM.exports=fm.pki.oids=fm.oids=fm.oids||{};function X(r,e){I9[r]=e,I9[e]=r}function Bt(r,e){I9[r]=e}X("1.2.840.113549.1.1.1","rsaEncryption");X("1.2.840.113549.1.1.4","md5WithRSAEncryption");X("1.2.840.113549.1.1.5","sha1WithRSAEncryption");X("1.2.840.113549.1.1.7","RSAES-OAEP");X("1.2.840.113549.1.1.8","mgf1");X("1.2.840.113549.1.1.9","pSpecified");X("1.2.840.113549.1.1.10","RSASSA-PSS");X("1.2.840.113549.1.1.11","sha256WithRSAEncryption");X("1.2.840.113549.1.1.12","sha384WithRSAEncryption");X("1.2.840.113549.1.1.13","sha512WithRSAEncryption");X("1.3.101.112","EdDSA25519");X("1.2.840.10040.4.3","dsa-with-sha1");X("1.3.14.3.2.7","desCBC");X("1.3.14.3.2.26","sha1");X("1.3.14.3.2.29","sha1WithRSASignature");X("2.16.840.1.101.3.4.2.1","sha256");X("2.16.840.1.101.3.4.2.2","sha384");X("2.16.840.1.101.3.4.2.3","sha512");X("2.16.840.1.101.3.4.2.4","sha224");X("2.16.840.1.101.3.4.2.5","sha512-224");X("2.16.840.1.101.3.4.2.6","sha512-256");X("1.2.840.113549.2.2","md2");X("1.2.840.113549.2.5","md5");X("1.2.840.113549.1.7.1","data");X("1.2.840.113549.1.7.2","signedData");X("1.2.840.113549.1.7.3","envelopedData");X("1.2.840.113549.1.7.4","signedAndEnvelopedData");X("1.2.840.113549.1.7.5","digestedData");X("1.2.840.113549.1.7.6","encryptedData");X("1.2.840.113549.1.9.1","emailAddress");X("1.2.840.113549.1.9.2","unstructuredName");X("1.2.840.113549.1.9.3","contentType");X("1.2.840.113549.1.9.4","messageDigest");X("1.2.840.113549.1.9.5","signingTime");X("1.2.840.113549.1.9.6","counterSignature");X("1.2.840.113549.1.9.7","challengePassword");X("1.2.840.113549.1.9.8","unstructuredAddress");X("1.2.840.113549.1.9.14","extensionRequest");X("1.2.840.113549.1.9.20","friendlyName");X("1.2.840.113549.1.9.21","localKeyId");X("1.2.840.113549.1.9.22.1","x509Certificate");X("1.2.840.113549.1.12.10.1.1","keyBag");X("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");X("1.2.840.113549.1.12.10.1.3","certBag");X("1.2.840.113549.1.12.10.1.4","crlBag");X("1.2.840.113549.1.12.10.1.5","secretBag");X("1.2.840.113549.1.12.10.1.6","safeContentsBag");X("1.2.840.113549.1.5.13","pkcs5PBES2");X("1.2.840.113549.1.5.12","pkcs5PBKDF2");X("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");X("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");X("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");X("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");X("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");X("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");X("1.2.840.113549.2.7","hmacWithSHA1");X("1.2.840.113549.2.8","hmacWithSHA224");X("1.2.840.113549.2.9","hmacWithSHA256");X("1.2.840.113549.2.10","hmacWithSHA384");X("1.2.840.113549.2.11","hmacWithSHA512");X("1.2.840.113549.3.7","des-EDE3-CBC");X("2.16.840.1.101.3.4.1.2","aes128-CBC");X("2.16.840.1.101.3.4.1.22","aes192-CBC");X("2.16.840.1.101.3.4.1.42","aes256-CBC");X("2.5.4.3","commonName");X("2.5.4.4","surname");X("2.5.4.5","serialNumber");X("2.5.4.6","countryName");X("2.5.4.7","localityName");X("2.5.4.8","stateOrProvinceName");X("2.5.4.9","streetAddress");X("2.5.4.10","organizationName");X("2.5.4.11","organizationalUnitName");X("2.5.4.12","title");X("2.5.4.13","description");X("2.5.4.15","businessCategory");X("2.5.4.17","postalCode");X("2.5.4.42","givenName");X("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");X("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");X("2.16.840.1.113730.1.1","nsCertType");X("2.16.840.1.113730.1.13","nsComment");Bt("2.5.29.1","authorityKeyIdentifier");Bt("2.5.29.2","keyAttributes");Bt("2.5.29.3","certificatePolicies");Bt("2.5.29.4","keyUsageRestriction");Bt("2.5.29.5","policyMapping");Bt("2.5.29.6","subtreesConstraint");Bt("2.5.29.7","subjectAltName");Bt("2.5.29.8","issuerAltName");Bt("2.5.29.9","subjectDirectoryAttributes");Bt("2.5.29.10","basicConstraints");Bt("2.5.29.11","nameConstraints");Bt("2.5.29.12","policyConstraints");Bt("2.5.29.13","basicConstraints");X("2.5.29.14","subjectKeyIdentifier");X("2.5.29.15","keyUsage");Bt("2.5.29.16","privateKeyUsagePeriod");X("2.5.29.17","subjectAltName");X("2.5.29.18","issuerAltName");X("2.5.29.19","basicConstraints");Bt("2.5.29.20","cRLNumber");Bt("2.5.29.21","cRLReason");Bt("2.5.29.22","expirationDate");Bt("2.5.29.23","instructionCode");Bt("2.5.29.24","invalidityDate");Bt("2.5.29.25","cRLDistributionPoints");Bt("2.5.29.26","issuingDistributionPoint");Bt("2.5.29.27","deltaCRLIndicator");Bt("2.5.29.28","issuingDistributionPoint");Bt("2.5.29.29","certificateIssuer");Bt("2.5.29.30","nameConstraints");X("2.5.29.31","cRLDistributionPoints");X("2.5.29.32","certificatePolicies");Bt("2.5.29.33","policyMappings");Bt("2.5.29.34","policyConstraints");X("2.5.29.35","authorityKeyIdentifier");Bt("2.5.29.36","policyConstraints");X("2.5.29.37","extKeyUsage");Bt("2.5.29.46","freshestCRL");Bt("2.5.29.54","inhibitAnyPolicy");X("1.3.6.1.4.1.11129.2.4.2","timestampList");X("1.3.6.1.5.5.7.1.1","authorityInfoAccess");X("1.3.6.1.5.5.7.3.1","serverAuth");X("1.3.6.1.5.5.7.3.2","clientAuth");X("1.3.6.1.5.5.7.3.3","codeSigning");X("1.3.6.1.5.5.7.3.4","emailProtection");X("1.3.6.1.5.5.7.3.8","timeStamping")});var Nu=R((nMe,fM)=>{u();var sr=ut();er();Qd();var ue=fM.exports=sr.asn1=sr.asn1||{};ue.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};ue.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};ue.create=function(r,e,t,n,i){if(sr.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||sr.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(a.bitStringContents=i.bitStringContents,a.original=ue.copy(a)),a};ue.copy=function(r,e){var t;if(sr.util.isArray(r)){t=[];for(var n=0;n<r.length;++n)t.push(ue.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:ue.copy(r.value,e)},e&&!e.excludeBitStringContents&&(t.bitStringContents=r.bitStringContents),t)};ue.equals=function(r,e,t){if(sr.util.isArray(r)){if(!sr.util.isArray(e)||r.length!==e.length)return!1;for(var n=0;n<r.length;++n)if(!ue.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&&ue.equals(r.value,e.value);return t&&t.includeBitStringContents&&(i=i&&r.bitStringContents===e.bitStringContents),i};ue.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 hm(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 zpe=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;hm(r,e,s),n=r.getInt(s<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};ue.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=sr.util.createBuffer(r));var t=r.length(),n=z4(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 z4(r,e,t,n){var i;hm(r,e,2);var s=r.getByte();e--;var o=s&192,a=s&31;i=r.length();var c=zpe(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(hm(r,e,2),r.bytes(2)===String.fromCharCode(0,0)){r.getBytes(2),e-=2;break}i=r.length(),f.push(z4(r,e,t+1,n)),e-=i-r.length()}else for(;c>0;)i=r.length(),f.push(z4(r,c,t+1,n)),e-=i-r.length(),c-=i-r.length();if(f===void 0&&o===ue.Class.UNIVERSAL&&a===ue.Type.BITSTRING&&(h=r.bytes(c)),f===void 0&&n.decodeBitStrings&&o===ue.Class.UNIVERSAL&&a===ue.Type.BITSTRING&&c>1){var d=r.read,m=e,y=0;if(a===ue.Type.BITSTRING&&(hm(r,e,1),y=r.getByte(),e--),y===0)try{i=r.length();var g={strict:!0,decodeBitStrings:!0},w=z4(r,e,t+1,g),E=i-r.length();e-=E,a==ue.Type.BITSTRING&&E++;var v=w.tagClass;E===c&&(v===ue.Class.UNIVERSAL||v===ue.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===ue.Type.BMPSTRING)for(f="";c>0;c-=2)hm(r,e,2),f+=String.fromCharCode(r.getInt16()),e-=2;else f=r.getBytes(c),e-=c}var x=h===void 0?null:{bitStringContents:h};return ue.create(o,a,p,f,x)}ue.toDer=function(r){var e=sr.util.createBuffer(),t=r.tagClass|r.type,n=sr.util.createBuffer(),i=!1;if("bitStringContents"in r&&(i=!0,r.original&&(i=ue.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(ue.toDer(r.value[s]))}else if(r.type===ue.Type.BMPSTRING)for(var s=0;s<r.value.length;++s)n.putInt16(r.value.charCodeAt(s));else r.type===ue.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};ue.oidToDer=function(r){var e=r.split("."),t=sr.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};ue.derToOid=function(r){var e;typeof r=="string"&&(r=sr.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};ue.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};ue.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};ue.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};ue.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};ue.integerToDer=function(r){var e=sr.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};ue.derToInteger=function(r){typeof r=="string"&&(r=sr.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)};ue.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&&sr.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=ue.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 lM=/[^\\u0000-\\u00ff]/;ue.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 ue.Class.UNIVERSAL:n+="Universal:";break;case ue.Class.APPLICATION:n+="Application:";break;case ue.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case ue.Class.PRIVATE:n+="Private:";break}if(r.tagClass===ue.Class.UNIVERSAL)switch(n+=r.type,r.type){case ue.Type.NONE:n+=" (None)";break;case ue.Type.BOOLEAN:n+=" (Boolean)";break;case ue.Type.INTEGER:n+=" (Integer)";break;case ue.Type.BITSTRING:n+=" (Bit string)";break;case ue.Type.OCTETSTRING:n+=" (Octet string)";break;case ue.Type.NULL:n+=" (Null)";break;case ue.Type.OID:n+=" (Object Identifier)";break;case ue.Type.ODESC:n+=" (Object Descriptor)";break;case ue.Type.EXTERNAL:n+=" (External or Instance of)";break;case ue.Type.REAL:n+=" (Real)";break;case ue.Type.ENUMERATED:n+=" (Enumerated)";break;case ue.Type.EMBEDDED:n+=" (Embedded PDV)";break;case ue.Type.UTF8:n+=" (UTF8)";break;case ue.Type.ROID:n+=" (Relative Object Identifier)";break;case ue.Type.SEQUENCE:n+=" (Sequence)";break;case ue.Type.SET:n+=" (Set)";break;case ue.Type.PRINTABLESTRING:n+=" (Printable String)";break;case ue.Type.IA5String:n+=" (IA5String (ASCII))";break;case ue.Type.UTCTIME:n+=" (UTC time)";break;case ue.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case ue.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+=ue.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===ue.Type.OID){var c=ue.derToOid(r.value);n+=c,sr.pki&&sr.pki.oids&&c in sr.pki.oids&&(n+=" ("+sr.pki.oids[c]+") ")}if(r.type===ue.Type.INTEGER)try{n+=ue.derToInteger(r.value)}catch{n+="0x"+sr.util.bytesToHex(r.value)}else if(r.type===ue.Type.BITSTRING){if(r.value.length>1?n+="0x"+sr.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===ue.Type.OCTETSTRING)lM.test(r.value)||(n+="("+r.value+") "),n+="0x"+sr.util.bytesToHex(r.value);else if(r.type===ue.Type.UTF8)try{n+=sr.util.decodeUtf8(r.value)}catch(f){if(f.message==="URI malformed")n+="0x"+sr.util.bytesToHex(r.value)+" (malformed UTF8)";else throw f}else r.type===ue.Type.PRINTABLESTRING||r.type===ue.Type.IA5String?n+=r.value:lM.test(r.value)?n+="0x"+sr.util.bytesToHex(r.value):r.value.length===0?n+="[null]":n+=r.value}return n}});var R9=R((sMe,hM)=>{u();var Tn=ut();er();hM.exports=Tn.cipher=Tn.cipher||{};Tn.cipher.algorithms=Tn.cipher.algorithms||{};Tn.cipher.createCipher=function(r,e){var t=r;if(typeof t=="string"&&(t=Tn.cipher.getAlgorithm(t),t&&(t=t())),!t)throw new Error("Unsupported algorithm: "+r);return new Tn.cipher.BlockCipher({algorithm:t,key:e,decrypt:!1})};Tn.cipher.createDecipher=function(r,e){var t=r;if(typeof t=="string"&&(t=Tn.cipher.getAlgorithm(t),t&&(t=t())),!t)throw new Error("Unsupported algorithm: "+r);return new Tn.cipher.BlockCipher({algorithm:t,key:e,decrypt:!0})};Tn.cipher.registerAlgorithm=function(r,e){r=r.toUpperCase(),Tn.cipher.algorithms[r]=e};Tn.cipher.getAlgorithm=function(r){return r=r.toUpperCase(),r in Tn.cipher.algorithms?Tn.cipher.algorithms[r]:null};var A9=Tn.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)};A9.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=Tn.util.createBuffer(),this.output=r.output||Tn.util.createBuffer(),this.mode.start(e)};A9.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()};A9.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 D9=R((aMe,dM)=>{u();var In=ut();er();In.cipher=In.cipher||{};var lt=dM.exports=In.cipher.modes=In.cipher.modes||{};lt.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)};lt.ecb.prototype.start=function(r){};lt.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])};lt.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])};lt.ecb.prototype.pad=function(r,e){var t=r.length()===this.blockSize?this.blockSize:this.blockSize-r.length();return r.fillWithByte(t,t),!0};lt.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)};lt.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)};lt.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=q4(r.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};lt.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};lt.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)};lt.cbc.prototype.pad=function(r,e){var t=r.length()===this.blockSize?this.blockSize:this.blockSize-r.length();return r.fillWithByte(t,t),!0};lt.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)};lt.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=In.util.createBuffer(),this._partialBytes=0};lt.cfb.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");this._iv=q4(r.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};lt.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};lt.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};lt.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=In.util.createBuffer(),this._partialBytes=0};lt.ofb.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");this._iv=q4(r.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};lt.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};lt.ofb.prototype.decrypt=lt.ofb.prototype.encrypt;lt.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=In.util.createBuffer(),this._partialBytes=0};lt.ctr.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");this._iv=q4(r.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};lt.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}$4(this._inBlock)};lt.ctr.prototype.decrypt=lt.ctr.prototype.encrypt;lt.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=In.util.createBuffer(),this._partialBytes=0,this._R=3774873600};lt.gcm.prototype.start=function(r){if(!("iv"in r))throw new Error("Invalid IV parameter.");var e=In.util.createBuffer(r.iv);this._cipherLength=0;var t;if("additionalData"in r?t=In.util.createBuffer(r.additionalData):t=In.util.createBuffer(),"tagLength"in r?this._tagLength=r.tagLength:this._tagLength=128,this._tag=null,r.decrypt&&(this._tag=In.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(C9(n*8)))}this._inBlock=this._j0.slice(0),$4(this._inBlock),this._partialBytes=0,t=In.util.createBuffer(t),this._aDataLength=C9(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()])};lt.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),$4(this._inBlock)};lt.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),$4(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};lt.gcm.prototype.afterFinish=function(r,e){var t=!0;e.decrypt&&e.overflow&&r.truncate(this.blockSize-e.overflow),this.tag=In.util.createBuffer();var n=this._aDataLength.concat(C9(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};lt.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};lt.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)};lt.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};lt.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)};lt.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};lt.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 q4(r,e){if(typeof r=="string"&&(r=In.util.createBuffer(r)),In.util.isArray(r)&&r.length>4){var t=r;r=In.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(!In.util.isArray(r)){for(var i=[],s=e/4,n=0;n<s;++n)i.push(r.getInt32());r=i}return r}function $4(r){r[r.length-1]=r[r.length-1]+1&4294967295}function C9(r){return[r/4294967296|0,r&4294967295]}});var Jd=R((uMe,gM)=>{u();var tr=ut();R9();D9();er();gM.exports=tr.aes=tr.aes||{};tr.aes.startEncrypting=function(r,e,t,n){var i=H4({key:r,output:t,decrypt:!1,mode:n});return i.start(e),i};tr.aes.createEncryptionCipher=function(r,e){return H4({key:r,output:null,decrypt:!1,mode:e})};tr.aes.startDecrypting=function(r,e,t,n){var i=H4({key:r,output:t,decrypt:!0,mode:n});return i.start(e),i};tr.aes.createDecryptionCipher=function(r,e){return H4({key:r,output:null,decrypt:!0,mode:e})};tr.aes.Algorithm=function(r,e){N9||mM();var t=this;t.name=r,t.mode=new e({blockSize:16,cipher:{encrypt:function(n,i){return k9(t._w,n,i,!1)},decrypt:function(n,i){return k9(t._w,n,i,!0)}}}),t._init=!1};tr.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=tr.util.createBuffer(e);else if(tr.util.isArray(e)&&(e.length===16||e.length===24||e.length===32)){t=e,e=tr.util.createBuffer();for(var n=0;n<t.length;++n)e.putByte(t[n])}if(!tr.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(!tr.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=yM(e,r.decrypt&&!o),this._init=!0}};tr.aes._expandKey=function(r,e){return N9||mM(),yM(r,e)};tr.aes._updateBlock=k9;Zd("AES-ECB",tr.cipher.modes.ecb);Zd("AES-CBC",tr.cipher.modes.cbc);Zd("AES-CFB",tr.cipher.modes.cfb);Zd("AES-OFB",tr.cipher.modes.ofb);Zd("AES-CTR",tr.cipher.modes.ctr);Zd("AES-GCM",tr.cipher.modes.gcm);function Zd(r,e){var t=function(){return new tr.aes.Algorithm(r,e)};tr.cipher.registerAlgorithm(r,t)}var N9=!1,Xd=4,ii,P9,pM,_f,ho;function mM(){N9=!0,pM=[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;ii=new Array(256),P9=new Array(256),_f=new Array(4),ho=new Array(4);for(var e=0;e<4;++e)_f[e]=new Array(256),ho[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,ii[t]=a,P9[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)_f[h][t]=l,ho[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 yM(r,e){for(var t=r.slice(0),n,i=1,s=t.length,o=s+6+1,a=Xd*o,c=s;c<a;++c)n=t[c-1],c%s===0?(n=ii[n>>>16&255]<<24^ii[n>>>8&255]<<16^ii[n&255]<<8^ii[n>>>24]^pM[i]<<24,i++):s>6&&c%s===4&&(n=ii[n>>>24]<<24^ii[n>>>16&255]<<16^ii[n>>>8&255]<<8^ii[n&255]),t[c]=t[c-s]^n;if(e){var l,f=ho[0],h=ho[1],p=ho[2],d=ho[3],m=t.slice(0);a=t.length;for(var c=0,y=a-Xd;c<a;c+=Xd,y-=Xd)if(c===0||c===a-Xd)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<Xd;++g)l=t[y+g],m[c+(3&-g)]=f[ii[l>>>24]]^h[ii[l>>>16&255]]^p[ii[l>>>8&255]]^d[ii[l&255]];t=m}return t}function k9(r,e,t,n){var i=r.length/4-1,s,o,a,c,l;n?(s=ho[0],o=ho[1],a=ho[2],c=ho[3],l=P9):(s=_f[0],o=_f[1],a=_f[2],c=_f[3],l=ii);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,E=1;E<i;++E)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 H4(r){r=r||{};var e=(r.mode||"CBC").toUpperCase(),t="AES-"+e,n;r.decrypt?n=tr.cipher.createDecipher(t,r.key):n=tr.cipher.createCipher(t,r.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof tr.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var W4=R((fMe,EM)=>{u();var lr=ut();R9();D9();er();EM.exports=lr.des=lr.des||{};lr.des.startEncrypting=function(r,e,t,n){var i=G4({key:r,output:t,decrypt:!1,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};lr.des.createEncryptionCipher=function(r,e){return G4({key:r,output:null,decrypt:!1,mode:e})};lr.des.startDecrypting=function(r,e,t,n){var i=G4({key:r,output:t,decrypt:!0,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};lr.des.createDecryptionCipher=function(r,e){return G4({key:r,output:null,decrypt:!0,mode:e})};lr.des.Algorithm=function(r,e){var t=this;t.name=r,t.mode=new e({blockSize:8,cipher:{encrypt:function(n,i){return wM(t._keys,n,i,!1)},decrypt:function(n,i){return wM(t._keys,n,i,!0)}}}),t._init=!1};lr.des.Algorithm.prototype.initialize=function(r){if(!this._init){var e=lr.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=Xpe(e),this._init=!0}};na("DES-ECB",lr.cipher.modes.ecb);na("DES-CBC",lr.cipher.modes.cbc);na("DES-CFB",lr.cipher.modes.cfb);na("DES-OFB",lr.cipher.modes.ofb);na("DES-CTR",lr.cipher.modes.ctr);na("3DES-ECB",lr.cipher.modes.ecb);na("3DES-CBC",lr.cipher.modes.cbc);na("3DES-CFB",lr.cipher.modes.cfb);na("3DES-OFB",lr.cipher.modes.ofb);na("3DES-CTR",lr.cipher.modes.ctr);function na(r,e){var t=function(){return new lr.des.Algorithm(r,e)};lr.cipher.registerAlgorithm(r,t)}var qpe=[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],$pe=[-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],Hpe=[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],Gpe=[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],Wpe=[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],jpe=[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],Ype=[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],Qpe=[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 Xpe(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],E=0,v,x=0;x<y;x++){var I=r.getInt32(),T=r.getInt32();v=(I>>>4^T)&252645135,T^=v,I^=v<<4,v=(T>>>-16^I)&65535,I^=v,T^=v<<-16,v=(I>>>2^T)&858993459,T^=v,I^=v<<2,v=(T>>>-16^I)&65535,I^=v,T^=v<<-16,v=(I>>>1^T)&1431655765,T^=v,I^=v<<1,v=(T>>>8^I)&16711935,I^=v,T^=v<<8,v=(I>>>1^T)&1431655765,T^=v,I^=v<<1,v=I<<8|T>>>20&240,I=T<<24|T<<8&16711680|T>>>8&65280|T>>>24&240,T=v;for(var S=0;S<w.length;++S){w[S]?(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 C=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];v=(B>>>16^C)&65535,g[E++]=C^v,g[E++]=B^v<<16}}return g}function wM(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^($pe[d>>>24&63]|Gpe[d>>>16&63]|jpe[d>>>8&63]|Qpe[d&63]|qpe[m>>>24&63]|Hpe[m>>>16&63]|Wpe[m>>>8&63]|Ype[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 G4(r){r=r||{};var e=(r.mode||"CBC").toUpperCase(),t="DES-"+e,n;r.decrypt?n=lr.cipher.createDecipher(t,r.key):n=lr.cipher.createCipher(t,r.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof lr.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var Ou=R((dMe,bM)=>{u();var j4=ut();bM.exports=j4.md=j4.md||{};j4.md.algorithms=j4.md.algorithms||{}});var vM=R((mMe,_M)=>{u();var hc=ut();Ou();er();var Zpe=_M.exports=hc.hmac=hc.hmac||{};Zpe.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 hc.md.algorithms)e=hc.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=hc.util.createBuffer(o);else if(hc.util.isArray(o)){var a=o;o=hc.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=hc.util.createBuffer(),n=hc.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 Lu=R(()=>{u()});var O9=R((bMe,SM)=>{u();var si=ut();vM();Ou();er();var Jpe=si.pkcs5=si.pkcs5||{},dc;si.util.isNodejs&&!si.options.usePureJavaScript&&(dc=Lu());SM.exports=si.pbkdf2=Jpe.pbkdf2=function(r,e,t,n,i,s){if(typeof i=="function"&&(s=i,i=null),si.util.isNodejs&&!si.options.usePureJavaScript&&dc.pbkdf2&&(i===null||typeof i!="object")&&(dc.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),r=Buffer.from(r,"binary"),e=Buffer.from(e,"binary"),s?dc.pbkdf2Sync.length===4?dc.pbkdf2(r,e,t,n,function(v,x){if(v)return s(v);s(null,x.toString("binary"))}):dc.pbkdf2(r,e,t,n,i,function(v,x){if(v)return s(v);s(null,x.toString("binary"))}):dc.pbkdf2Sync.length===4?dc.pbkdf2Sync(r,e,t,n).toString("binary"):dc.pbkdf2Sync(r,e,t,n,i).toString("binary");if((typeof i>"u"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in si.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=si.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=si.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(si.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=si.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(si.util.int32ToBytes(y)),p=m=f.digest().getBytes(),g=2,E()}function E(){if(g<=t)return f.start(null,null),f.update(m),d=f.digest().getBytes(),p=si.util.xorBytes(p,d,o),m=d,++g,si.util.setImmediate(E);h+=y<c?p:p.substr(0,l),++y,w()}w()}});var X4=R((vMe,TM)=>{u();var Q4=ut();er();var xM=TM.exports=Q4.pem=Q4.pem||{};xM.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+=Y4(n)),r.contentDomain&&(n={name:"Content-Domain",values:[r.contentDomain]},t+=Y4(n)),r.dekInfo&&(n={name:"DEK-Info",values:[r.dekInfo.algorithm]},r.dekInfo.parameters&&n.values.push(r.dekInfo.parameters),t+=Y4(n)),r.headers)for(var i=0;i<r.headers.length;++i)t+=Y4(r.headers[i]);return r.procType&&(t+=`\r
`),t+=Q4.util.encode64(r.body,e.maxline||64)+`\r
`,t+="-----END "+r.type+`-----\r
`,t};xM.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:Q4.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(e0e(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 Y4(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 e0e(r){return r.replace(/^\s+/,"")}});var PM=R((xMe,DM)=>{u();var ia=ut();Ou();er();var AM=DM.exports=ia.sha256=ia.sha256||{};ia.md.sha256=ia.md.algorithms.sha256=AM;AM.create=function(){RM||t0e();var r=null,e=ia.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=ia.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=ia.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),IM(r,t,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=ia.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(L9.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};IM(h,t,i);var p=ia.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 L9=null,RM=!1,CM=null;function t0e(){L9=String.fromCharCode(128),L9+=ia.util.fillString(String.fromCharCode(0),64),CM=[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],RM=!0}function IM(r,e,t){for(var n,i,s,o,a,c,l,f,h,p,d,m,y,g,w,E=t.length();E>=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+CM[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,E-=64}}});var NM=R((IMe,kM)=>{u();var sa=ut();er();var Z4=null;sa.util.isNodejs&&!sa.options.usePureJavaScript&&!process.versions["node-webkit"]&&(Z4=Lu());var r0e=kM.exports=sa.prng=sa.prng||{};r0e.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=sa.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 sa.util.nextTick(function(){s(g)});var E=h(e.key,e.seed);e.generated+=E.length,y.putBytes(E),e.key=d(h(e.key,p(e.seed))),e.seed=m(h(e.key,e.seed)),sa.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=sa.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=sa.util.globalScope,p=h.crypto||h.msCrypto;p&&p.getRandomValues&&(f=function(I){return p.getRandomValues(I)});var d=sa.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,E,v,x=Math.floor(Math.random()*65536);d.length()<l;){E=16807*(x&65535),w=16807*(x>>16),E+=(w&32767)<<16,E+=w>>15,E=(E&2147483647)+(E>>31),x=E&4294967295;for(var g=0;g<3;++g)v=x>>>(g<<3),v^=Math.floor(Math.random()*256),d.putByte(v&255)}return d.getBytes(l)}return Z4?(e.seedFile=function(l,f){Z4.randomBytes(l,function(h,p){if(h)return f(h);f(null,p.toString())})},e.seedFileSync=function(l){return Z4.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 vf=R((RMe,B9)=>{u();var An=ut();Jd();PM();NM();er();(function(){if(An.random&&An.random.getBytes){B9.exports=An.random;return}(function(r){var e={},t=new Array(4),n=An.util.createBuffer();e.formatKey=function(h){var p=An.util.createBuffer(h);return h=new Array(4),h[0]=p.getInt32(),h[1]=p.getInt32(),h[2]=p.getInt32(),h[3]=p.getInt32(),An.aes._expandKey(h,!1)},e.formatSeed=function(h){var p=An.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 An.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=An.md.sha256;function i(){var h=An.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=An.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(o=function(h){return c.getRandomValues(h)}),An.options.usePureJavaScript||!An.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(!An.random)An.random=s;else for(var f in s)An.random[f]=s[f];An.random.createInstance=i,B9.exports=An.random})(typeof jQuery<"u"?jQuery:null)})()});var MM=R((DMe,BM)=>{u();var yi=ut();er();var M9=[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],OM=[1,2,3,5],n0e=function(r,e){return r<<e&65535|(r&65535)>>16-e},i0e=function(r,e){return(r&65535)>>e|r<<16-e&65535};BM.exports=yi.rc2=yi.rc2||{};yi.rc2.expandKey=function(r,e){typeof r=="string"&&(r=yi.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(M9[t.at(a-1)+t.at(a-n)&255]);for(t.setAt(128-s,M9[t.at(128-s)&o]),a=127-s;a>=0;a--)t.setAt(a,M9[t.at(a+1)^t.at(a+s)]);return t};var LM=function(r,e,t){var n=!1,i=null,s=null,o=null,a,c,l,f,h=[];for(r=yi.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]=n0e(m[l],OM[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]=i0e(m[l],OM[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 E=0;E<m[w][0];E++)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=yi.util.createBuffer(m)),n=!1,i=yi.util.createBuffer(),s=y||new yi.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(),E=s.at(w-1);E>w?y=!1:s.truncate(E)}return y}},d};yi.rc2.startEncrypting=function(r,e,t){var n=yi.rc2.createEncryptionCipher(r,128);return n.start(e,t),n};yi.rc2.createEncryptionCipher=function(r,e){return LM(r,e,!0)};yi.rc2.startDecrypting=function(r,e,t){var n=yi.rc2.createDecryptionCipher(r,128);return n.start(e,t),n};yi.rc2.createDecryptionCipher=function(r,e){return LM(r,e,!1)}});var t6=R((kMe,HM)=>{u();var U9=ut();HM.exports=U9.jsbn=U9.jsbn||{};var pc,s0e=0xdeadbeefcafe,UM=(s0e&16777215)==15715070;function j(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))}U9.jsbn.BigInteger=j;function At(){return new j(null)}function o0e(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 a0e(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 FM(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"?(j.prototype.am=FM,pc=28):UM&&navigator.appName=="Microsoft Internet Explorer"?(j.prototype.am=a0e,pc=30):UM&&navigator.appName!="Netscape"?(j.prototype.am=o0e,pc=26):(j.prototype.am=FM,pc=28);j.prototype.DB=pc;j.prototype.DM=(1<<pc)-1;j.prototype.DV=1<<pc;var F9=52;j.prototype.FV=Math.pow(2,F9);j.prototype.F1=F9-pc;j.prototype.F2=2*pc-F9;var c0e="0123456789abcdefghijklmnopqrstuvwxyz",J4=new Array,ep,Ss;ep="0".charCodeAt(0);for(Ss=0;Ss<=9;++Ss)J4[ep++]=Ss;ep="a".charCodeAt(0);for(Ss=10;Ss<36;++Ss)J4[ep++]=Ss;ep="A".charCodeAt(0);for(Ss=10;Ss<36;++Ss)J4[ep++]=Ss;function VM(r){return c0e.charAt(r)}function KM(r,e){var t=J4[r.charCodeAt(e)];return t??-1}function u0e(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 l0e(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 Bu(r){var e=At();return e.fromInt(r),e}function f0e(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:KM(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&&j.ZERO.subTo(this,this)}function h0e(){for(var r=this.s&this.DM;this.t>0&&this.data[this.t-1]==r;)--this.t}function d0e(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=VM(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+=VM(n));return i?s:"0"}function p0e(){var r=At();return j.ZERO.subTo(this,r),r}function m0e(){return this.s<0?this.negate():this}function y0e(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 e6(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 g0e(){return this.t<=0?0:this.DB*(this.t-1)+e6(this.data[this.t-1]^this.s&this.DM)}function w0e(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 E0e(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 b0e(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 _0e(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 v0e(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 S0e(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&&j.ZERO.subTo(e,e)}function x0e(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 T0e(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=At());var s=At(),o=this.s,a=r.s,c=this.DB-e6(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??At();for(s.dlShiftTo(g,w),t.compareTo(w)>=0&&(t.data[t.t++]=1,t.subTo(w,t)),j.ONE.dlShiftTo(l,w),w.subTo(s,s);s.t<l;)s.data[s.t++]=0;for(;--g>=0;){var E=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,E,t,g,0,l))<E)for(s.dlShiftTo(g,w),t.subTo(w,t);t.data[y]<--E;)t.subTo(w,t)}e!=null&&(t.drShiftTo(l,e),o!=a&&j.ZERO.subTo(e,e)),t.t=l,t.clamp(),c>0&&t.rShiftTo(c,t),o<0&&j.ZERO.subTo(t,t)}}}function I0e(r){var e=At();return this.abs().divRemTo(r,null,e),this.s<0&&e.compareTo(j.ZERO)>0&&r.subTo(e,e),e}function Sf(r){this.m=r}function A0e(r){return r.s<0||r.compareTo(this.m)>=0?r.mod(this.m):r}function R0e(r){return r}function C0e(r){r.divRemTo(this.m,null,r)}function D0e(r,e,t){r.multiplyTo(e,t),this.reduce(t)}function P0e(r,e){r.squareTo(e),this.reduce(e)}Sf.prototype.convert=A0e;Sf.prototype.revert=R0e;Sf.prototype.reduce=C0e;Sf.prototype.mulTo=D0e;Sf.prototype.sqrTo=P0e;function k0e(){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 xf(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 N0e(r){var e=At();return r.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),r.s<0&&e.compareTo(j.ZERO)>0&&this.m.subTo(e,e),e}function O0e(r){var e=At();return r.copyTo(e),this.reduce(e),e}function L0e(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 B0e(r,e){r.squareTo(e),this.reduce(e)}function M0e(r,e,t){r.multiplyTo(e,t),this.reduce(t)}xf.prototype.convert=N0e;xf.prototype.revert=O0e;xf.prototype.reduce=L0e;xf.prototype.mulTo=M0e;xf.prototype.sqrTo=B0e;function U0e(){return(this.t>0?this.data[0]&1:this.s)==0}function F0e(r,e){if(r>4294967295||r<1)return j.ONE;var t=At(),n=At(),i=e.convert(this),s=e6(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 V0e(r,e){var t;return r<256||e.isEven()?t=new Sf(e):t=new xf(e),this.exp(r,t)}j.prototype.copyTo=u0e;j.prototype.fromInt=l0e;j.prototype.fromString=f0e;j.prototype.clamp=h0e;j.prototype.dlShiftTo=w0e;j.prototype.drShiftTo=E0e;j.prototype.lShiftTo=b0e;j.prototype.rShiftTo=_0e;j.prototype.subTo=v0e;j.prototype.multiplyTo=S0e;j.prototype.squareTo=x0e;j.prototype.divRemTo=T0e;j.prototype.invDigit=k0e;j.prototype.isEven=U0e;j.prototype.exp=F0e;j.prototype.toString=d0e;j.prototype.negate=p0e;j.prototype.abs=m0e;j.prototype.compareTo=y0e;j.prototype.bitLength=g0e;j.prototype.mod=I0e;j.prototype.modPowInt=V0e;j.ZERO=Bu(0);j.ONE=Bu(1);function K0e(){var r=At();return this.copyTo(r),r}function z0e(){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 q0e(){return this.t==0?this.s:this.data[0]<<24>>24}function $0e(){return this.t==0?this.s:this.data[0]<<16>>16}function H0e(r){return Math.floor(Math.LN2*this.DB/Math.log(r))}function G0e(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function W0e(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=Bu(t),i=At(),s=At(),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 j0e(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=KM(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&&j.ZERO.subTo(this,this)}function Y0e(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(j.ONE.shiftLeft(r-1),V9,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>r&&this.subTo(j.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 Q0e(){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 X0e(r){return this.compareTo(r)==0}function Z0e(r){return this.compareTo(r)<0?this:r}function J0e(r){return this.compareTo(r)>0?this:r}function e1e(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 t1e(r,e){return r&e}function r1e(r){var e=At();return this.bitwiseTo(r,t1e,e),e}function V9(r,e){return r|e}function n1e(r){var e=At();return this.bitwiseTo(r,V9,e),e}function zM(r,e){return r^e}function i1e(r){var e=At();return this.bitwiseTo(r,zM,e),e}function qM(r,e){return r&~e}function s1e(r){var e=At();return this.bitwiseTo(r,qM,e),e}function o1e(){for(var r=At(),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 a1e(r){var e=At();return r<0?this.rShiftTo(-r,e):this.lShiftTo(r,e),e}function c1e(r){var e=At();return r<0?this.lShiftTo(-r,e):this.rShiftTo(r,e),e}function u1e(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 l1e(){for(var r=0;r<this.t;++r)if(this.data[r]!=0)return r*this.DB+u1e(this.data[r]);return this.s<0?this.t*this.DB:-1}function f1e(r){for(var e=0;r!=0;)r&=r-1,++e;return e}function h1e(){for(var r=0,e=this.s&this.DM,t=0;t<this.t;++t)r+=f1e(this.data[t]^e);return r}function d1e(r){var e=Math.floor(r/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<r%this.DB)!=0}function p1e(r,e){var t=j.ONE.shiftLeft(r);return this.bitwiseTo(t,e,t),t}function m1e(r){return this.changeBit(r,V9)}function y1e(r){return this.changeBit(r,qM)}function g1e(r){return this.changeBit(r,zM)}function w1e(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 E1e(r){var e=At();return this.addTo(r,e),e}function b1e(r){var e=At();return this.subTo(r,e),e}function _1e(r){var e=At();return this.multiplyTo(r,e),e}function v1e(r){var e=At();return this.divRemTo(r,e,null),e}function S1e(r){var e=At();return this.divRemTo(r,null,e),e}function x1e(r){var e=At(),t=At();return this.divRemTo(r,e,t),new Array(e,t)}function T1e(r){this.data[this.t]=this.am(0,r-1,this,0,0,this.t),++this.t,this.clamp()}function I1e(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 dm(){}function $M(r){return r}function A1e(r,e,t){r.multiplyTo(e,t)}function R1e(r,e){r.squareTo(e)}dm.prototype.convert=$M;dm.prototype.revert=$M;dm.prototype.mulTo=A1e;dm.prototype.sqrTo=R1e;function C1e(r){return this.exp(r,new dm)}function D1e(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 P1e(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 tp(r){this.r2=At(),this.q3=At(),j.ONE.dlShiftTo(2*r.t,this.r2),this.mu=this.r2.divide(r),this.m=r}function k1e(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=At();return r.copyTo(e),this.reduce(e),e}function N1e(r){return r}function O1e(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 L1e(r,e){r.squareTo(e),this.reduce(e)}function B1e(r,e,t){r.multiplyTo(e,t),this.reduce(t)}tp.prototype.convert=k1e;tp.prototype.revert=N1e;tp.prototype.reduce=O1e;tp.prototype.mulTo=B1e;tp.prototype.sqrTo=L1e;function M1e(r,e){var t=r.bitLength(),n,i=Bu(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 Sf(e):e.isEven()?s=new tp(e):s=new xf(e);var o=new Array,a=3,c=n-1,l=(1<<n)-1;if(o[1]=s.convert(this),n>1){var f=At();for(s.sqrTo(o[1],f);a<=l;)o[a]=At(),s.mulTo(f,o[a-2],o[a]),a+=2}var h=r.t-1,p,d=!0,m=At(),y;for(t=e6(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 U1e(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 F1e(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 V1e(r){var e=r.isEven();if(this.isEven()&&e||r.signum()==0)return j.ZERO;for(var t=r.clone(),n=this.clone(),i=Bu(1),s=Bu(0),o=Bu(0),a=Bu(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(j.ONE)!=0)return j.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 po=[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],K1e=(1<<26)/po[po.length-1];function z1e(r){var e,t=this.abs();if(t.t==1&&t.data[0]<=po[po.length-1]){for(e=0;e<po.length;++e)if(t.data[0]==po[e])return!0;return!1}if(t.isEven())return!1;for(e=1;e<po.length;){for(var n=po[e],i=e+1;i<po.length&&n<K1e;)n*=po[i++];for(n=t.modInt(n);e<i;)if(n%po[e++]==0)return!1}return t.millerRabin(r)}function q1e(r){var e=this.subtract(j.ONE),t=e.getLowestSetBit();if(t<=0)return!1;for(var n=e.shiftRight(t),i=$1e(),s,o=0;o<r;++o){do s=new j(this.bitLength(),i);while(s.compareTo(j.ONE)<=0||s.compareTo(e)>=0);var a=s.modPow(n,this);if(a.compareTo(j.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<t&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(j.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function $1e(){return{nextBytes:function(r){for(var e=0;e<r.length;++e)r[e]=Math.floor(Math.random()*256)}}}j.prototype.chunkSize=H0e;j.prototype.toRadix=W0e;j.prototype.fromRadix=j0e;j.prototype.fromNumber=Y0e;j.prototype.bitwiseTo=e1e;j.prototype.changeBit=p1e;j.prototype.addTo=w1e;j.prototype.dMultiply=T1e;j.prototype.dAddOffset=I1e;j.prototype.multiplyLowerTo=D1e;j.prototype.multiplyUpperTo=P1e;j.prototype.modInt=F1e;j.prototype.millerRabin=q1e;j.prototype.clone=K0e;j.prototype.intValue=z0e;j.prototype.byteValue=q0e;j.prototype.shortValue=$0e;j.prototype.signum=G0e;j.prototype.toByteArray=Q0e;j.prototype.equals=X0e;j.prototype.min=Z0e;j.prototype.max=J0e;j.prototype.and=r1e;j.prototype.or=n1e;j.prototype.xor=i1e;j.prototype.andNot=s1e;j.prototype.not=o1e;j.prototype.shiftLeft=a1e;j.prototype.shiftRight=c1e;j.prototype.getLowestSetBit=l1e;j.prototype.bitCount=h1e;j.prototype.testBit=d1e;j.prototype.setBit=m1e;j.prototype.clearBit=y1e;j.prototype.flipBit=g1e;j.prototype.add=E1e;j.prototype.subtract=b1e;j.prototype.multiply=_1e;j.prototype.divide=v1e;j.prototype.remainder=S1e;j.prototype.divideAndRemainder=x1e;j.prototype.modPow=M1e;j.prototype.modInverse=V1e;j.prototype.pow=C1e;j.prototype.gcd=U1e;j.prototype.isProbablePrime=z1e});var QM=R((OMe,YM)=>{u();var oa=ut();Ou();er();var WM=YM.exports=oa.sha1=oa.sha1||{};oa.md.sha1=oa.md.algorithms.sha1=WM;WM.create=function(){jM||H1e();var r=null,e=oa.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=oa.util.createBuffer(),r={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=oa.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),GM(r,t,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=oa.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(K9.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};GM(h,t,i);var p=oa.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 K9=null,jM=!1;function H1e(){K9=String.fromCharCode(128),K9+=oa.util.fillString(String.fromCharCode(0),64),jM=!0}function GM(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 JM=R((BMe,ZM)=>{u();var aa=ut();er();vf();QM();var XM=ZM.exports=aa.pkcs1=aa.pkcs1||{};XM.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=aa.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=aa.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=r6(i,a-s.digestLength-1,o),g=aa.util.xorBytes(m,y,m.length),w=r6(g,s.digestLength,o),E=aa.util.xorBytes(i,w,i.length);return"\0"+E+g};XM.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=aa.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=r6(f,i.digestLength,s),p=aa.util.xorBytes(l,h,l.length),d=r6(p,o-i.digestLength-1,s),m=aa.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 E=1,v=i.digestLength,x=i.digestLength;x<m.length;x++){var I=m.charCodeAt(x),T=I&1^1,S=E?65534:0;g|=I&S,E=E&T,v+=E}if(g||m.charCodeAt(v)!==1)throw new Error("Invalid RSAES-OAEP padding.");return m.substring(v+1)};function r6(r,e,t){t||(t=aa.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 eU=R((UMe,z9)=>{u();var Mu=ut();er();t6();vf();(function(){if(Mu.prime){z9.exports=Mu.prime;return}var r=z9.exports=Mu.prime=Mu.prime||{},e=Mu.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||Mu.random,g={nextBytes:function(w){for(var E=y.getBytesSync(w.length),v=0;v<w.length;++v)w[v]=E.charCodeAt(v)}};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 E=10;"maxBlockTime"in d&&(E=d.maxBlockTime),a(y,h,p,g,w,E,m)}function a(h,p,d,m,y,g,w){var E=+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-E<g);Mu.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,E=w*30/8,v=d.workerScript||"forge/prime.worker.js";if(g===-1)return Mu.util.estimateCores(function(I,T){I&&(T=2),g=T-1,x()});x();function x(){g=Math.max(1,g);for(var I=[],T=0;T<g;++T)I[T]=new Worker(v);for(var S=g,T=0;T<g;++T)I[T].addEventListener("message",B);var C=!1;function B(q){if(!C){--S;var W=q.data;if(W.found){for(var oe=0;oe<I.length;++oe)I[oe].terminate();return C=!0,m(null,new e(W.prime,16))}y.bitLength()>h&&(y=l(h,p));var te=y.toString(16);q.target.postMessage({hex:te,workLoad:w}),y.dAddOffset(E,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 pm=R((VMe,aU)=>{u();var Pe=ut();Nu();t6();Qd();JM();eU();vf();er();typeof bt>"u"&&(bt=Pe.jsbn.BigInteger);var bt,q9=Pe.util.isNodejs?Lu():null,F=Pe.asn1,xs=Pe.util;Pe.pki=Pe.pki||{};aU.exports=Pe.pki.rsa=Pe.rsa=Pe.rsa||{};var Ge=Pe.pki,G1e=[6,4,2,4,2,4,6,2],W1e={name:"PrivateKeyInfo",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:F.Class.UNIVERSAL,type:F.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:F.Class.UNIVERSAL,type:F.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},j1e={name:"RSAPrivateKey",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},Y1e={name:"RSAPublicKey",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:F.Class.UNIVERSAL,type:F.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},Q1e=Pe.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:F.Class.UNIVERSAL,type:F.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:F.Class.UNIVERSAL,type:F.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},X1e={name:"DigestInfo",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:F.Class.UNIVERSAL,type:F.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:F.Class.UNIVERSAL,type:F.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:F.Class.UNIVERSAL,type:F.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:F.Class.UNIVERSAL,type:F.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},Z1e=function(r){var e;if(r.algorithm in Ge.oids)e=Ge.oids[r.algorithm];else{var t=new Error("Unknown message digest algorithm.");throw t.algorithm=r.algorithm,t}var n=F.oidToDer(e).getBytes(),i=F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[]),s=F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[]);s.value.push(F.create(F.Class.UNIVERSAL,F.Type.OID,!1,n)),s.value.push(F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,""));var o=F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,r.digest().getBytes());return i.value.push(s),i.value.push(o),F.toDer(i).getBytes()},sU=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(bt.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(bt.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new bt(Pe.util.bytesToHex(Pe.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(bt.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};Ge.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=oU(r,e,t)):(i=Pe.util.createBuffer(),i.putBytes(r));for(var o=new bt(i.toHex(),16),a=sU(o,e,n),c=a.toString(16),l=Pe.util.createBuffer(),f=s-Math.ceil(c.length/2);f>0;)l.putByte(0),--f;return l.putBytes(Pe.util.hexToBytes(c)),l.getBytes()};Ge.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 bt(Pe.util.createBuffer(r).toHex(),16);if(o.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=sU(o,e,t),c=a.toString(16),l=Pe.util.createBuffer(),f=i-Math.ceil(c.length/2);f>0;)l.putByte(0),--f;return l.putBytes(Pe.util.hexToBytes(c)),n!==!1?n6(l.getBytes(),e,t):l.getBytes()};Ge.rsa.createKeyPairGenerationState=function(r,e,t){typeof r=="string"&&(r=parseInt(r,10)),r=r||2048,t=t||{};var n=t.prng||Pe.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 bt(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};Ge.rsa.stepKeyPairGenerationState=function(r,e){"algorithm"in r||(r.algorithm="PRIMEINC");var t=new bt(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 bt(c,r.rng),r.num.testBit(l)||r.num.bitwiseTo(bt.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(eme(r.num.bitLength()))?++r.pqState:r.num.dAddOffset(G1e[n++%8],0):r.pqState===2?r.pqState=r.num.subtract(bt.ONE).gcd(r.e).compareTo(bt.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(bt.ONE),r.q1=r.q.subtract(bt.ONE),r.phi=r.p1.multiply(r.q1),++r.state;else if(r.state===3)r.phi.gcd(r.e).compareTo(bt.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:Ge.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:Ge.rsa.setPublicKey(r.n,r.e)}}o=+new Date,a+=o-s,s=o}return r.keys!==null};Ge.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),!Pe.options.usePureJavaScript&&!t.prng&&r>=256&&r<=16384&&(e===65537||e===3)){if(n){if(tU("generateKeyPair"))return q9.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:Ge.privateKeyFromPem(l),publicKey:Ge.publicKeyFromPem(c)})});if(rU("generateKey")&&rU("exportKey"))return xs.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:iU(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return xs.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=Ge.privateKeyFromAsn1(F.fromDer(Pe.util.createBuffer(a)));n(null,{privateKey:c,publicKey:Ge.setRsaPublicKey(c.n,c.e)})}});if(nU("generateKey")&&nU("exportKey")){var i=xs.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:iU(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,l=xs.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);l.oncomplete=function(f){var h=f.target.result,p=Ge.privateKeyFromAsn1(F.fromDer(Pe.util.createBuffer(h)));n(null,{privateKey:p,publicKey:Ge.setRsaPublicKey(p.n,p.e)})},l.onerror=function(f){n(f)}},i.onerror=function(a){n(a)};return}}else if(tU("generateKeyPairSync")){var s=q9.generateKeyPairSync("rsa",{modulusLength:r,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:Ge.privateKeyFromPem(s.privateKey),publicKey:Ge.publicKeyFromPem(s.publicKey)}}}var o=Ge.rsa.createKeyPairGenerationState(r,e,t);if(!n)return Ge.rsa.stepKeyPairGenerationState(o,0),o.keys;J1e(o,t,n)};Ge.setRsaPublicKey=Ge.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 oU(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return Pe.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 Ge.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=n6(l,t,!0);var f=F.fromDer(l,{parseAllBytes:o._parseAllDigestBytes}),h={},p=[];if(!F.validate(f,X1e,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=F.derToOid(h.algorithmIdentifier);if(!(m===Pe.oids.md2||m===Pe.oids.md5||m===Pe.oids.sha1||m===Pe.oids.sha224||m===Pe.oids.sha256||m===Pe.oids.sha384||m===Pe.oids.sha512||m===Pe.oids["sha512-224"]||m===Pe.oids["sha512-256"])){var d=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw d.oid=m,d}if((m===Pe.oids.md2||m===Pe.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=n6(l,t,!0),c===l}});var a=Ge.rsa.decrypt(i,t,!0,!1);return s.verify(n,a,t.n.bitLength())},t};Ge.setRsaPrivateKey=Ge.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=Ge.rsa.decrypt(l,c,!1,!1);if(f==="RSAES-PKCS1-V1_5")f={decode:n6};else if(f==="RSA-OAEP"||f==="RSAES-OAEP")f={decode:function(d,m){return Pe.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:Z1e},h=1):(f==="NONE"||f==="NULL"||f===null)&&(f={encode:function(){return l}},h=1);var p=f.encode(l,c.n.bitLength());return Ge.rsa.encrypt(p,c,h)},c};Ge.wrapRsaPrivateKey=function(r){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(0).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(Ge.oids.rsaEncryption).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]),F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,F.toDer(r).getBytes())])};Ge.privateKeyFromAsn1=function(r){var e={},t=[];if(F.validate(r,W1e,e,t)&&(r=F.fromDer(Pe.util.createBuffer(e.privateKey))),e={},t=[],!F.validate(r,j1e,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=Pe.util.createBuffer(e.privateKeyModulus).toHex(),s=Pe.util.createBuffer(e.privateKeyPublicExponent).toHex(),o=Pe.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=Pe.util.createBuffer(e.privateKeyPrime1).toHex(),c=Pe.util.createBuffer(e.privateKeyPrime2).toHex(),l=Pe.util.createBuffer(e.privateKeyExponent1).toHex(),f=Pe.util.createBuffer(e.privateKeyExponent2).toHex(),h=Pe.util.createBuffer(e.privateKeyCoefficient).toHex(),Ge.setRsaPrivateKey(new bt(i,16),new bt(s,16),new bt(o,16),new bt(a,16),new bt(c,16),new bt(l,16),new bt(f,16),new bt(h,16))};Ge.privateKeyToAsn1=Ge.privateKeyToRSAPrivateKey=function(r){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(0).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.n)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.e)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.d)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.p)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.q)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.dP)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.dQ)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.qInv))])};Ge.publicKeyFromAsn1=function(r){var e={},t=[];if(F.validate(r,Q1e,e,t)){var n=F.derToOid(e.publicKeyOid);if(n!==Ge.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}r=e.rsaPublicKey}if(t=[],!F.validate(r,Y1e,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=Pe.util.createBuffer(e.publicKeyModulus).toHex(),o=Pe.util.createBuffer(e.publicKeyExponent).toHex();return Ge.setRsaPublicKey(new bt(s,16),new bt(o,16))};Ge.publicKeyToAsn1=Ge.publicKeyToSubjectPublicKeyInfo=function(r){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(Ge.oids.rsaEncryption).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]),F.create(F.Class.UNIVERSAL,F.Type.BITSTRING,!1,[Ge.publicKeyToRSAPublicKey(r)])])};Ge.publicKeyToRSAPublicKey=function(r){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.n)),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ca(r.e))])};function oU(r,e,t){var n=Pe.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=Pe.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 n6(r,e,t,n){var i=Math.ceil(e.n.bitLength()/8),s=Pe.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 J1e(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){Pe.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(bt.ONE).gcd(r.e).compareTo(bt.ONE)!==0){r.p=null,i();return}if(r.q.subtract(bt.ONE).gcd(r.e).compareTo(bt.ONE)!==0){r.q=null,s(r.qBits,o);return}if(r.p1=r.p.subtract(bt.ONE),r.q1=r.q.subtract(bt.ONE),r.phi=r.p1.multiply(r.q1),r.phi.gcd(r.e).compareTo(bt.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:Ge.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:Ge.rsa.setPublicKey(r.n,r.e)},t(null,r.keys)}}function ca(r){var e=r.toString(16);e[0]>="8"&&(e="00"+e);var t=Pe.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 eme(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 tU(r){return Pe.util.isNodejs&&typeof q9[r]=="function"}function rU(r){return typeof xs.globalScope<"u"&&typeof xs.globalScope.crypto=="object"&&typeof xs.globalScope.crypto.subtle=="object"&&typeof xs.globalScope.crypto.subtle[r]=="function"}function nU(r){return typeof xs.globalScope<"u"&&typeof xs.globalScope.msCrypto=="object"&&typeof xs.globalScope.msCrypto.subtle=="object"&&typeof xs.globalScope.msCrypto.subtle[r]=="function"}function iU(r){for(var e=Pe.util.hexToBytes(r.toString(16)),t=new Uint8Array(e.length),n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}});var $9=R((zMe,hU)=>{u();var he=ut();Jd();Nu();W4();Ou();Qd();O9();X4();vf();MM();pm();er();typeof cU>"u"&&(cU=he.jsbn.BigInteger);var cU,G=he.asn1,Qe=he.pki=he.pki||{};hU.exports=Qe.pbe=he.pbe=he.pbe||{};var Tf=Qe.oids,tme={name:"EncryptedPrivateKeyInfo",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:G.Class.UNIVERSAL,type:G.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:G.Class.UNIVERSAL,type:G.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},rme={name:"PBES2Algorithms",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:G.Class.UNIVERSAL,type:G.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:G.Class.UNIVERSAL,type:G.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:G.Class.UNIVERSAL,type:G.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:G.Class.UNIVERSAL,type:G.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:G.Class.UNIVERSAL,type:G.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:G.Class.UNIVERSAL,type:G.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:G.Class.UNIVERSAL,type:G.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},nme={name:"pkcs-12PbeParams",tagClass:G.Class.UNIVERSAL,type:G.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:G.Class.UNIVERSAL,type:G.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:G.Class.UNIVERSAL,type:G.Type.INTEGER,constructed:!1,capture:"iterations"}]};Qe.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=he.random.getBytesSync(t.saltSize),i=t.count,s=G.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=Tf["aes128-CBC"],h=he.aes.createEncryptionCipher;break;case"aes192":o=24,l=16,f=Tf["aes192-CBC"],h=he.aes.createEncryptionCipher;break;case"aes256":o=32,l=16,f=Tf["aes256-CBC"],h=he.aes.createEncryptionCipher;break;case"des":o=8,l=8,f=Tf.desCBC,h=he.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=fU(d),y=he.pkcs5.pbkdf2(e,n,i,o,m),g=he.random.getBytesSync(l),w=h(y);w.start(g),w.update(G.toDer(r)),w.finish(),c=w.output.getBytes();var E=ime(n,s,o,d);a=G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OID,!1,G.oidToDer(Tf.pkcs5PBES2).getBytes()),G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OID,!1,G.oidToDer(Tf.pkcs5PBKDF2).getBytes()),E]),G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OID,!1,G.oidToDer(f).getBytes()),G.create(G.Class.UNIVERSAL,G.Type.OCTETSTRING,!1,g)])])])}else if(t.algorithm==="3des"){o=24;var v=new he.util.ByteBuffer(n),y=Qe.pbe.generatePkcs12Key(e,v,1,i,o),g=Qe.pbe.generatePkcs12Key(e,v,2,i,o),w=he.des.createEncryptionCipher(y);w.start(g),w.update(G.toDer(r)),w.finish(),c=w.output.getBytes(),a=G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OID,!1,G.oidToDer(Tf["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OCTETSTRING,!1,n),G.create(G.Class.UNIVERSAL,G.Type.INTEGER,!1,s.getBytes())])])}else{var p=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw p.algorithm=t.algorithm,p}var x=G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[a,G.create(G.Class.UNIVERSAL,G.Type.OCTETSTRING,!1,c)]);return x};Qe.decryptPrivateKeyInfo=function(r,e){var t=null,n={},i=[];if(!G.validate(r,tme,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=G.derToOid(n.encryptionOid),a=Qe.pbe.getCipher(o,n.encryptionParams,e),c=he.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(t=G.fromDer(a.output)),t};Qe.encryptedPrivateKeyToPem=function(r,e){var t={type:"ENCRYPTED PRIVATE KEY",body:G.toDer(r).getBytes()};return he.pem.encode(t,{maxline:e})};Qe.encryptedPrivateKeyFromPem=function(r){var e=he.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 G.fromDer(e.body)};Qe.encryptRsaPrivateKey=function(r,e,t){if(t=t||{},!t.legacy){var n=Qe.wrapRsaPrivateKey(Qe.privateKeyToAsn1(r));return n=Qe.encryptPrivateKeyInfo(n,e,t),Qe.encryptedPrivateKeyToPem(n)}var i,s,o,a;switch(t.algorithm){case"aes128":i="AES-128-CBC",o=16,s=he.random.getBytesSync(16),a=he.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,s=he.random.getBytesSync(16),a=he.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,s=he.random.getBytesSync(16),a=he.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,s=he.random.getBytesSync(8),a=he.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,s=he.random.getBytesSync(8),a=he.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=he.pbe.opensslDeriveBytes(e,s.substr(0,8),o),f=a(l);f.start(s),f.update(G.toDer(Qe.privateKeyToAsn1(r))),f.finish();var h={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:he.util.bytesToHex(s).toUpperCase()},body:f.output.getBytes()};return he.pem.encode(h)};Qe.decryptRsaPrivateKey=function(r,e){var t=null,n=he.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=he.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,o=he.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,o=he.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,o=he.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,o=he.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,o=function(h){return he.rc2.createDecryptionCipher(h,40)};break;case"RC2-64-CBC":s=8,o=function(h){return he.rc2.createDecryptionCipher(h,64)};break;case"RC2-128-CBC":s=16,o=function(h){return he.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=he.util.hexToBytes(n.dekInfo.parameters),c=he.pbe.opensslDeriveBytes(e,a.substr(0,8),s),l=o(c);if(l.start(a),l.update(he.util.createBuffer(n.body)),l.finish())t=l.output.getBytes();else return t}else t=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?t=Qe.decryptPrivateKeyInfo(G.fromDer(t),e):t=G.fromDer(t),t!==null&&(t=Qe.privateKeyFromAsn1(t)),t};Qe.pbe.generatePkcs12Key=function(r,e,t,n,i,s){var o,a;if(typeof s>"u"||s===null){if(!("sha1"in he.md))throw new Error('"sha1" hash algorithm unavailable.');s=he.md.sha1.create()}var c=s.digestLength,l=s.blockLength,f=new he.util.ByteBuffer,h=new he.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 he.util.ByteBuffer;m.fillWithByte(t,l);var y=l*Math.ceil(d/l),g=new he.util.ByteBuffer;for(a=0;a<y;a++)g.putByte(e.at(a%d));var w=l*Math.ceil(p/l),E=new he.util.ByteBuffer;for(a=0;a<w;a++)E.putByte(h.at(a%p));var v=g;v.putBuffer(E);for(var x=Math.ceil(i/c),I=1;I<=x;I++){var T=new he.util.ByteBuffer;T.putBytes(m.bytes()),T.putBytes(v.bytes());for(var S=0;S<n;S++)s.start(),s.update(T.getBytes()),T=s.digest();var C=new he.util.ByteBuffer;for(a=0;a<l;a++)C.putByte(T.at(a%c));var B=Math.ceil(d/l)+Math.ceil(p/l),q=new he.util.ByteBuffer;for(o=0;o<B;o++){var W=new he.util.ByteBuffer(v.getBytes(l)),oe=511;for(a=C.length()-1;a>=0;a--)oe=oe>>8,oe+=C.at(a)+W.at(a),W.setAt(a,oe&255);q.putBuffer(W)}v=q,f.putBuffer(T)}return f.truncate(f.length()-i),f};Qe.pbe.getCipher=function(r,e,t){switch(r){case Qe.oids.pkcs5PBES2:return Qe.pbe.getCipherForPBES2(r,e,t);case Qe.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case Qe.oids["pbewithSHAAnd40BitRC2-CBC"]:return Qe.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}};Qe.pbe.getCipherForPBES2=function(r,e,t){var n={},i=[];if(!G.validate(e,rme,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=G.derToOid(n.kdfOid),r!==Qe.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=G.derToOid(n.encOid),r!==Qe.oids["aes128-CBC"]&&r!==Qe.oids["aes192-CBC"]&&r!==Qe.oids["aes256-CBC"]&&r!==Qe.oids["des-EDE3-CBC"]&&r!==Qe.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=he.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,l;switch(Qe.oids[r]){case"aes128-CBC":c=16,l=he.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,l=he.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,l=he.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,l=he.des.createDecryptionCipher;break;case"desCBC":c=8,l=he.des.createDecryptionCipher;break}var f=lU(n.prfOid),h=he.pkcs5.pbkdf2(t,o,a,c,f),p=n.encIv,d=l(h);return d.start(p),d};Qe.pbe.getCipherForPKCS12PBE=function(r,e,t){var n={},i=[];if(!G.validate(e,nme,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=he.util.createBuffer(n.salt),a=he.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,l,f;switch(r){case Qe.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,l=8,f=he.des.startDecrypting;break;case Qe.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,l=8,f=function(y,g){var w=he.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=lU(n.prfOid),p=Qe.pbe.generatePkcs12Key(t,o,1,a,c,h);h.start();var d=Qe.pbe.generatePkcs12Key(t,o,2,a,l,h);return f(p,d)};Qe.pbe.opensslDeriveBytes=function(r,e,t,n){if(typeof n>"u"||n===null){if(!("md5"in he.md))throw new Error('"md5" hash algorithm unavailable.');n=he.md.md5.create()}e===null&&(e="");for(var i=[uU(n,r+e)],s=16,o=1;s<t;++o,s+=16)i.push(uU(n,i[o-1]+r+e));return i.join("").substr(0,t)};function uU(r,e){return r.start().update(e).digest().getBytes()}function lU(r){var e;if(!r)e="hmacWithSHA1";else if(e=Qe.oids[G.derToOid(r)],!e){var t=new Error("Unsupported PRF OID.");throw t.oid=r,t.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],t}return fU(e)}function fU(r){var e=he.md;switch(r){case"hmacWithSHA224":e=he.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 ime(r,e,t,n){var i=G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OCTETSTRING,!1,r),G.create(G.Class.UNIVERSAL,G.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(G.create(G.Class.UNIVERSAL,G.Type.INTEGER,!1,he.util.hexToBytes(t.toString(16))),G.create(G.Class.UNIVERSAL,G.Type.SEQUENCE,!0,[G.create(G.Class.UNIVERSAL,G.Type.OID,!1,G.oidToDer(Qe.oids[n]).getBytes()),G.create(G.Class.UNIVERSAL,G.Type.NULL,!1,"")])),i}});var DU=R((TUe,CU)=>{u();var or=ut();Ou();er();var mm=CU.exports=or.sha512=or.sha512||{};or.md.sha512=or.md.algorithms.sha512=mm;var AU=or.sha384=or.sha512.sha384=or.sha512.sha384||{};AU.create=function(){return mm.create("SHA-384")};or.md.sha384=or.md.algorithms.sha384=AU;or.sha512.sha256=or.sha512.sha256||{create:function(){return mm.create("SHA-512/256")}};or.md["sha512/256"]=or.md.algorithms["sha512/256"]=or.sha512.sha256;or.sha512.sha224=or.sha512.sha224||{create:function(){return mm.create("SHA-512/224")}};or.md["sha512/224"]=or.md.algorithms["sha512/224"]=or.sha512.sha224;mm.create=function(r){if(RU||lme(),typeof r>"u"&&(r="SHA-512"),!(r in If))throw new Error("Invalid SHA-512 algorithm: "+r);for(var e=If[r],t=null,n=or.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=or.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=or.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),IU(t,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=or.util.createBuffer();c.putBytes(n.bytes());var l=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,f=l&a.blockLength-1;c.putBytes(W9.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);IU(y,i,c);var g=or.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 W9=null,RU=!1,j9=null,If=null;function lme(){W9=String.fromCharCode(128),W9+=or.util.fillString(String.fromCharCode(0),128),j9=[[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]],If={},If["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],If["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],If["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],If["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],RU=!0}function IU(r,e,t){for(var n,i,s,o,a,c,l,f,h,p,d,m,y,g,w,E,v,x,I,T,S,C,B,q,W,oe,te,Ve,me,Ae,$,Ue,zt,je,Ye,Z=t.length();Z>=128;){for(me=0;me<16;++me)e[me][0]=t.getInt32()>>>0,e[me][1]=t.getInt32()>>>0;for(;me<80;++me)Ue=e[me-2],Ae=Ue[0],$=Ue[1],n=((Ae>>>19|$<<13)^($>>>29|Ae<<3)^Ae>>>6)>>>0,i=((Ae<<13|$>>>19)^($<<3|Ae>>>29)^(Ae<<26|$>>>6))>>>0,je=e[me-15],Ae=je[0],$=je[1],s=((Ae>>>1|$<<31)^(Ae>>>8|$<<24)^Ae>>>7)>>>0,o=((Ae<<31|$>>>1)^(Ae<<24|$>>>8)^(Ae<<25|$>>>7))>>>0,zt=e[me-7],Ye=e[me-16],$=i+zt[1]+o+Ye[1],e[me][0]=n+zt[0]+s+Ye[0]+($/4294967296>>>0)>>>0,e[me][1]=$>>>0;for(y=r[0][0],g=r[0][1],w=r[1][0],E=r[1][1],v=r[2][0],x=r[2][1],I=r[3][0],T=r[3][1],S=r[4][0],C=r[4][1],B=r[5][0],q=r[5][1],W=r[6][0],oe=r[6][1],te=r[7][0],Ve=r[7][1],me=0;me<80;++me)l=((S>>>14|C<<18)^(S>>>18|C<<14)^(C>>>9|S<<23))>>>0,f=((S<<18|C>>>14)^(S<<14|C>>>18)^(C<<23|S>>>9))>>>0,h=(W^S&(B^W))>>>0,p=(oe^C&(q^oe))>>>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|v&(y^w))>>>0,m=(g&E|x&(g^E))>>>0,$=Ve+f+p+j9[me][1]+e[me][1],n=te+l+h+j9[me][0]+e[me][0]+($/4294967296>>>0)>>>0,i=$>>>0,$=c+m,s=a+d+($/4294967296>>>0)>>>0,o=$>>>0,te=W,Ve=oe,W=B,oe=q,B=S,q=C,$=T+i,S=I+n+($/4294967296>>>0)>>>0,C=$>>>0,I=v,T=x,v=w,x=E,w=y,E=g,$=i+o,y=n+s+($/4294967296>>>0)>>>0,g=$>>>0;$=r[0][1]+g,r[0][0]=r[0][0]+y+($/4294967296>>>0)>>>0,r[0][1]=$>>>0,$=r[1][1]+E,r[1][0]=r[1][0]+w+($/4294967296>>>0)>>>0,r[1][1]=$>>>0,$=r[2][1]+x,r[2][0]=r[2][0]+v+($/4294967296>>>0)>>>0,r[2][1]=$>>>0,$=r[3][1]+T,r[3][0]=r[3][0]+I+($/4294967296>>>0)>>>0,r[3][1]=$>>>0,$=r[4][1]+C,r[4][0]=r[4][0]+S+($/4294967296>>>0)>>>0,r[4][1]=$>>>0,$=r[5][1]+q,r[5][0]=r[5][0]+B+($/4294967296>>>0)>>>0,r[5][1]=$>>>0,$=r[6][1]+oe,r[6][0]=r[6][0]+W+($/4294967296>>>0)>>>0,r[6][1]=$>>>0,$=r[7][1]+Ve,r[7][0]=r[7][0]+te+($/4294967296>>>0)>>>0,r[7][1]=$>>>0,Z-=128}}});var GF=R((LVe,HF)=>{"use strict";u();var y2e=async r=>{let e=[];for await(let t of r)e.push(t);return e};HF.exports=y2e});var RS=R((FVe,jF)=>{"use strict";u();var g2e=async r=>{for await(let e of r);};jF.exports=g2e});var CS=R((KVe,YF)=>{"use strict";u();var w2e=async function*(r,e){for await(let t of r)await e(t)&&(yield t)};YF.exports=w2e});var Ep=R((qVe,QF)=>{"use strict";u();var E2e=async function*(r,e){let t=0;if(!(e<1)){for await(let n of r)if(yield n,t++,t===e)return}};QF.exports=E2e});var A6=R((NS,OS)=>{u();(function(r,e){typeof NS=="object"&&typeof OS<"u"?OS.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}})(NS)});var rV=R((xKe,tV)=>{"use strict";u();var S2e=async function*(r,e){for await(let t of r)yield e(t)};tV.exports=S2e});var iV=R((AKe,nV)=>{u();nV.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 _p=R((DKe,oV)=>{u();var sV=iV();oV.exports=class{constructor(e){this.hwm=e||16,this.head=new sV(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){let t=this.head;this.head=t.next=new sV(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 cV=R((kKe,aV)=>{u();var LS=_p();aV.exports=r=>{r=r||{};let e;typeof r=="function"?(e=r,r={}):e=r.onEnd;let t=new LS,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 LS,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 LS,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 lV=R((OKe,uV)=>{"use strict";u();var x2e=cV(),T2e=async function*(...r){let e=x2e();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};uV.exports=T2e});var mV=R((ZKe,pV)=>{u();var MS=_p();pV.exports=r=>{r=r||{};let e;typeof r=="function"?(e=r,r={}):e=r.onEnd;let t=new MS,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 MS,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 MS,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 gV=R((eze,yV)=>{"use strict";u();var C2e=mV(),D2e=async function*(...r){let e=C2e();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};yV.exports=D2e});var IV=R((Fqe,TV)=>{"use strict";u();var M2e=/^(?:[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;TV.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 M2e.test(e)}});var JV=R(($m,Y6)=>{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,E=0,v=3432918353,x=461845907,I=0;I<g;I=I+4)E=d[I]|d[I+1]<<8|d[I+2]<<16|d[I+3]<<24,E=i(E,v),E=s(E,15),E=i(E,x),w^=E,w=s(w,13),w=i(w,5)+3864292196;switch(E=0,y){case 3:E^=d[I+2]<<16;case 2:E^=d[I+1]<<8;case 1:E^=d[I],E=i(E,v),E=s(E,15),E=i(E,x),w^=E}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,E=m,v=m,x=m,I=0,T=0,S=0,C=0,B=597399067,q=2869860233,W=951274213,oe=2716044179,te=0;te<g;te=te+16)I=d[te]|d[te+1]<<8|d[te+2]<<16|d[te+3]<<24,T=d[te+4]|d[te+5]<<8|d[te+6]<<16|d[te+7]<<24,S=d[te+8]|d[te+9]<<8|d[te+10]<<16|d[te+11]<<24,C=d[te+12]|d[te+13]<<8|d[te+14]<<16|d[te+15]<<24,I=i(I,B),I=s(I,15),I=i(I,q),w^=I,w=s(w,19),w+=E,w=i(w,5)+1444728091,T=i(T,q),T=s(T,16),T=i(T,W),E^=T,E=s(E,17),E+=v,E=i(E,5)+197830471,S=i(S,W),S=s(S,17),S=i(S,oe),v^=S,v=s(v,15),v+=x,v=i(v,5)+2530024501,C=i(C,oe),C=s(C,18),C=i(C,B),x^=C,x=s(x,13),x+=w,x=i(x,5)+850148119;switch(I=0,T=0,S=0,C=0,y){case 15:C^=d[te+14]<<16;case 14:C^=d[te+13]<<8;case 13:C^=d[te+12],C=i(C,oe),C=s(C,18),C=i(C,B),x^=C;case 12:S^=d[te+11]<<24;case 11:S^=d[te+10]<<16;case 10:S^=d[te+9]<<8;case 9:S^=d[te+8],S=i(S,W),S=s(S,17),S=i(S,oe),v^=S;case 8:T^=d[te+7]<<24;case 7:T^=d[te+6]<<16;case 6:T^=d[te+5]<<8;case 5:T^=d[te+4],T=i(T,q),T=s(T,16),T=i(T,W),E^=T;case 4:I^=d[te+3]<<24;case 3:I^=d[te+2]<<16;case 2:I^=d[te+1]<<8;case 1:I^=d[te],I=i(I,B),I=s(I,15),I=i(I,q),w^=I}return w^=d.length,E^=d.length,v^=d.length,x^=d.length,w+=E,w+=v,w+=x,E+=w,v+=w,x+=w,w=o(w),E=o(E),v=o(v),x=o(x),w+=E,w+=v,w+=x,E+=w,v+=w,x+=w,("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)+("00000000"+(v>>>0).toString(16)).slice(-8)+("00000000"+(x>>>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],E=[0,m],v=[0,0],x=[0,0],I=[2277735313,289559509],T=[1291169091,658871167],S=0;S<g;S=S+16)v=[d[S+4]|d[S+5]<<8|d[S+6]<<16|d[S+7]<<24,d[S]|d[S+1]<<8|d[S+2]<<16|d[S+3]<<24],x=[d[S+12]|d[S+13]<<8|d[S+14]<<16|d[S+15]<<24,d[S+8]|d[S+9]<<8|d[S+10]<<16|d[S+11]<<24],v=c(v,I),v=l(v,31),v=c(v,T),w=h(w,v),w=l(w,27),w=a(w,E),w=a(c(w,[0,5]),[0,1390208809]),x=c(x,T),x=l(x,33),x=c(x,I),E=h(E,x),E=l(E,31),E=a(E,w),E=a(c(E,[0,5]),[0,944331445]);switch(v=[0,0],x=[0,0],y){case 15:x=h(x,f([0,d[S+14]],48));case 14:x=h(x,f([0,d[S+13]],40));case 13:x=h(x,f([0,d[S+12]],32));case 12:x=h(x,f([0,d[S+11]],24));case 11:x=h(x,f([0,d[S+10]],16));case 10:x=h(x,f([0,d[S+9]],8));case 9:x=h(x,[0,d[S+8]]),x=c(x,T),x=l(x,33),x=c(x,I),E=h(E,x);case 8:v=h(v,f([0,d[S+7]],56));case 7:v=h(v,f([0,d[S+6]],48));case 6:v=h(v,f([0,d[S+5]],40));case 5:v=h(v,f([0,d[S+4]],32));case 4:v=h(v,f([0,d[S+3]],24));case 3:v=h(v,f([0,d[S+2]],16));case 2:v=h(v,f([0,d[S+1]],8));case 1:v=h(v,[0,d[S]]),v=c(v,I),v=l(v,31),v=c(v,T),w=h(w,v)}return w=h(w,[0,d.length]),E=h(E,[0,d.length]),w=a(w,E),E=a(E,w),w=p(w),E=p(E),w=a(w,E),E=a(E,w),("00000000"+(w[0]>>>0).toString(16)).slice(-8)+("00000000"+(w[1]>>>0).toString(16)).slice(-8)+("00000000"+(E[0]>>>0).toString(16)).slice(-8)+("00000000"+(E[1]>>>0).toString(16)).slice(-8)},typeof $m<"u"?(typeof Y6<"u"&&Y6.exports&&($m=Y6.exports=t),$m.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)})($m)});var tK=R((QGe,eK)=>{u();eK.exports=JV()});var pK=R((HWe,dK)=>{u();var QS=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}};dK.exports=QS});var bK=R(Wm=>{"use strict";u();var oye=typeof BigUint64Array<"u",Hm=Symbol(),Gm=1024;function mK(r,e){let t=new Uint32Array(r),n=new Uint16Array(r);var i=t[e+-4>>>2]>>>1,s=e>>>1;if(i<=Gm)return String.fromCharCode.apply(String,n.subarray(s,s+i));let o=[];do{let a=n[s+Gm-1],c=a>=55296&&a<56320?Gm-1:Gm;o.push(String.fromCharCode.apply(String,n.subarray(s,s+=c))),i-=c}while(i>Gm);return o.join("")+String.fromCharCode.apply(String,n.subarray(s,s+i))}function XS(r){let e={};function t(i,s){return i?mK(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 ZS(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 S=new Uint32Array(n.buffer),C=S[a>>>2];if((T>>>=0)>=C)throw Error("invalid id: "+T);return S[(a+4>>>2)+T*2]}function l(T){let S=new Uint32Array(n.buffer),C=S[a>>>2];if((T>>>=0)>=C)throw Error("invalid id: "+T);return S[(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 S=T.length,C=s(S<<1,1),B=new Uint16Array(n.buffer);for(var q=0,W=C>>>1;q<S;++q)B[W+q]=T.charCodeAt(q);return C}r.__allocString=p;function d(T){let S=n.buffer;if(new Uint32Array(S)[T+-8>>>2]!==1)throw Error("not a string: "+T);return mK(S,T)}r.__getString=d;function m(T,S,C){let B=n.buffer;if(C)switch(T){case 2:return new Float32Array(B);case 3:return new Float64Array(B)}else switch(T){case 0:return new(S?Int8Array:Uint8Array)(B);case 1:return new(S?Int16Array:Uint16Array)(B);case 2:return new(S?Int32Array:Uint32Array)(B);case 3:return new(S?BigInt64Array:BigUint64Array)(B)}throw Error("unsupported align: "+T)}function y(T,S){let C=c(T);if(!(C&3))throw Error("not an array: "+T+" @ "+C);let B=f(C),q=S.length,W=s(q<<B,0),oe=s(C&2?16:12,T),te=new Uint32Array(n.buffer);te[oe+0>>>2]=o(W),te[oe+4>>>2]=W,te[oe+8>>>2]=q<<B,C&2&&(te[oe+12>>>2]=q);let Ve=m(B,C&1024,C&2048);if(C&8192)for(let me=0;me<q;++me)Ve[(W>>>B)+me]=o(S[me]);else Ve.set(S,W>>>B);return oe}r.__allocArray=y;function g(T){let S=new Uint32Array(n.buffer),C=S[T+-8>>>2],B=c(C);if(!(B&1))throw Error("not an array: "+C);let q=f(B);var W=S[T+4>>>2];let oe=B&2?S[T+12>>>2]:S[W+-4>>>2]>>>q;return m(q,B&1024,B&2048).subarray(W>>>=q,W+oe)}r.__getArrayView=g;function w(T){let S=g(T),C=S.length,B=new Array(C);for(let q=0;q<C;q++)B[q]=S[q];return B}r.__getArray=w;function E(T){let S=n.buffer,C=new Uint32Array(S)[T+-4>>>2];return S.slice(T,T+C)}r.__getArrayBuffer=E;function v(T,S,C){return new T(x(T,S,C))}function x(T,S,C){let B=n.buffer,q=new Uint32Array(B),W=q[C+4>>>2];return new T(B,W,q[W+-4>>>2]>>>S)}r.__getInt8Array=v.bind(null,Int8Array,0),r.__getInt8ArrayView=x.bind(null,Int8Array,0),r.__getUint8Array=v.bind(null,Uint8Array,0),r.__getUint8ArrayView=x.bind(null,Uint8Array,0),r.__getUint8ClampedArray=v.bind(null,Uint8ClampedArray,0),r.__getUint8ClampedArrayView=x.bind(null,Uint8ClampedArray,0),r.__getInt16Array=v.bind(null,Int16Array,1),r.__getInt16ArrayView=x.bind(null,Int16Array,1),r.__getUint16Array=v.bind(null,Uint16Array,1),r.__getUint16ArrayView=x.bind(null,Uint16Array,1),r.__getInt32Array=v.bind(null,Int32Array,2),r.__getInt32ArrayView=x.bind(null,Int32Array,2),r.__getUint32Array=v.bind(null,Uint32Array,2),r.__getUint32ArrayView=x.bind(null,Uint32Array,2),oye&&(r.__getInt64Array=v.bind(null,BigInt64Array,3),r.__getInt64ArrayView=x.bind(null,BigInt64Array,3),r.__getUint64Array=v.bind(null,BigUint64Array,3),r.__getUint64ArrayView=x.bind(null,BigUint64Array,3)),r.__getFloat32Array=v.bind(null,Float32Array,2),r.__getFloat32ArrayView=x.bind(null,Float32Array,2),r.__getFloat64Array=v.bind(null,Float64Array,3),r.__getFloat64ArrayView=x.bind(null,Float64Array,3);function I(T,S){let C=new Uint32Array(n.buffer);var B=C[T+-8>>>2];if(B<=C[a>>>2])do if(B==S)return!0;while(B=l(B));return!1}return r.__instanceof=I,r.memory=r.memory||n,r.table=r.table||i,EK(t,r)}function yK(r){return typeof Response<"u"&&r instanceof Response}async function gK(r,e){return yK(r=await r)?wK(r,e):ZS(XS(e||(e={})),await WebAssembly.instantiate(r instanceof WebAssembly.Module?r:await WebAssembly.compile(r),e))}Wm.instantiate=gK;function aye(r,e){return ZS(XS(e||(e={})),new WebAssembly.Instance(r instanceof WebAssembly.Module?r:new WebAssembly.Module(r),e))}Wm.instantiateSync=aye;async function wK(r,e){return WebAssembly.instantiateStreaming?ZS(XS(e||(e={})),(await WebAssembly.instantiateStreaming(r,e)).instance):gK(yK(r=await r)?r.arrayBuffer():r,e)}Wm.instantiateStreaming=wK;function EK(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[Hm]}},p.wrap=function(d){return Object.create(p.prototype,{[Hm]:{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[Hm])},set:function(m){d(this[Hm],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[Hm],...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}Wm.demangle=EK});var vK=R((YWe,_K)=>{u();var{instantiate:cye}=bK();JS.supported=typeof WebAssembly<"u";function JS(r={}){if(!JS.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 cye(new Response(new Blob([e],{type:"application/wasm"})),r)}_K.exports=JS});var TK=R((XWe,xK)=>{u();var SK=pK(),uye=vK(),lye=async(r,e,t,n,i)=>{let s=await uye();return new SK(s,r,e,t,n,i)};xK.exports={Rabin:SK,create:lye}});var NK=R((xje,kK)=>{"use strict";u();kK.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(Eye,0),c=~(4294967295<<s+1),l=PK(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(bye),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),f=s&l;i|=f<<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(_ye)}};function Eye(r,e){return r+PK(e)}function PK(r){let e=r;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function bye(r,e){return r[0]-e[0]}function _ye(r){return r[1]}});var _z=R((_Xe,bz)=>{"use strict";u();bz.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 qH=R((ST,zH)=>{"use strict";u();Object.defineProperty(ST,"__esModule",{value:!0});u8.BASE=2166136261;function u8(r,e=u8.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}ST.default=u8;zH.exports=u8});var mG=R((Sct,g8)=>{"use strict";u();g8.exports=x8e;g8.exports.format=dG;g8.exports.parse=pG;var _8e=/\B(?=(\d{3})+(?!\d))/g,v8e=/(?:\.0*|(\.[^0]+)0+)$/,yl={b:1,kb:1<<10,mb:1<<20,gb:1<<30,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},S8e=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function x8e(r,e){return typeof r=="string"?pG(r):typeof r=="number"?dG(r,e):null}function dG(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||!yl[a.toLowerCase()])&&(t>=yl.pb?a="PB":t>=yl.tb?a="TB":t>=yl.gb?a="GB":t>=yl.mb?a="MB":t>=yl.kb?a="KB":a="B");var c=r/yl[a.toLowerCase()],l=c.toFixed(s);return o||(l=l.replace(v8e,"$1")),n&&(l=l.split(".").map(function(f,h){return h===0?f.replace(_8e,n):f}).join(".")),l+i+a}function pG(r){if(typeof r=="number"&&!isNaN(r))return r;if(typeof r!="string")return null;var e=S8e.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(yl[n]*t)}});var JG=R((Plt,ZG)=>{"use strict";u();var q8e=async function*(r,e){for await(let t of r)await e(t)&&(yield t)};ZG.exports=q8e});var tW=R((Nlt,eW)=>{"use strict";u();var $8e=async function*(r,e){for await(let t of r)yield e(t)};eW.exports=$8e});var nW=R((Llt,rW)=>{"use strict";u();var H8e=async r=>{let e=[];for await(let t of r)e.push(t);return e};rW.exports=H8e});var sW=R((Mlt,iW)=>{"use strict";u();var G8e=nW(),W8e=async function*(r,e){yield*(await G8e(r)).sort(e)};iW.exports=W8e});var aW=R(oW=>{"use strict";u();oW.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 Io=R((zlt,cW)=>{"use strict";u();cW.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 JT=R(($lt,uW)=>{"use strict";u();var ZT=null;uW.exports=function(){return ZT===null&&(ZT={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),ZT}});var rI=R(lW=>{"use strict";u();var eI=Io(),j8e=new Set(["buffer","view","utf8"]),tI=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"||!j8e.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 eI(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new eI(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new eI(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};lW.Encoding=tI});var oI=R(D8=>{"use strict";u();var{Buffer:iI}=md()||{},{Encoding:sI}=rI(),Y8e=JT(),ry=class extends sI{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new ny({encode:this.encode,decode:e=>this.decode(iI.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},ny=class extends sI{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new ry({encode:e=>{let t=this.encode(e);return iI.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},nI=class extends sI{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new ry({encode:e=>iI.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=Y8e();return new ny({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(t.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};D8.BufferFormat=ry;D8.ViewFormat=ny;D8.UTF8Format=nI});var pW=R(yh=>{"use strict";u();var{Buffer:Yn}=md()||{Buffer:{isBuffer:()=>!1}},{textEncoder:hW,textDecoder:fW}=JT()(),{BufferFormat:iy,ViewFormat:aI,UTF8Format:dW}=oI(),P8=r=>r;yh.utf8=new dW({encode:function(r){return Yn.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?fW.decode(r):String(r)},decode:P8,name:"utf8",createViewTranscoder(){return new aI({encode:function(r){return ArrayBuffer.isView(r)?r:hW.encode(r)},decode:function(r){return fW.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new iy({encode:function(r){return Yn.isBuffer(r)?r:ArrayBuffer.isView(r)?Yn.from(r.buffer,r.byteOffset,r.byteLength):Yn.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});yh.json=new dW({encode:JSON.stringify,decode:JSON.parse,name:"json"});yh.buffer=new iy({encode:function(r){return Yn.isBuffer(r)?r:ArrayBuffer.isView(r)?Yn.from(r.buffer,r.byteOffset,r.byteLength):Yn.from(String(r),"utf8")},decode:P8,name:"buffer",createViewTranscoder(){return new aI({encode:function(r){return ArrayBuffer.isView(r)?r:Yn.from(String(r),"utf8")},decode:function(r){return Yn.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});yh.view=new aI({encode:function(r){return ArrayBuffer.isView(r)?r:hW.encode(r)},decode:P8,name:"view",createBufferTranscoder(){return new iy({encode:function(r){return Yn.isBuffer(r)?r:ArrayBuffer.isView(r)?Yn.from(r.buffer,r.byteOffset,r.byteLength):Yn.from(String(r),"utf8")},decode:P8,name:`${this.name}+buffer`})}});yh.hex=new iy({encode:function(r){return Yn.isBuffer(r)?r:Yn.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});yh.base64=new iy({encode:function(r){return Yn.isBuffer(r)?r:Yn.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var gW=R(yW=>{"use strict";u();var mW=Io(),N8=pW(),{Encoding:Q8e}=rI(),{BufferFormat:X8e,ViewFormat:Z8e,UTF8Format:J8e}=oI(),sy=Symbol("formats"),k8=Symbol("encodings"),e5e=new Set(["buffer","view","utf8"]),cI=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>e5e.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[k8]=new Map,this[sy]=new Set(e);for(let t in N8)try{this.encoding(t)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[k8].values()))}encoding(e){let t=this[k8].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=i5e[e],!t)throw new mW(`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=t5e(e)}let{name:n,format:i}=t;if(!this[sy].has(i))if(this[sy].has("view"))t=t.createViewTranscoder();else if(this[sy].has("buffer"))t=t.createBufferTranscoder();else if(this[sy].has("utf8"))t=t.createUTF8Transcoder();else throw new mW(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let s of[e,n,t.name,t.commonName])this[k8].set(s,t)}return t}};yW.Transcoder=cI;function t5e(r){if(r instanceof Q8e)return r;let e="type"in r&&typeof r.type=="string"?r.type:void 0,t=r.name||e||`anonymous-${s5e++}`;switch(r5e(r)){case"view":return new Z8e({...r,name:t});case"utf8":return new J8e({...r,name:t});case"buffer":return new X8e({...r,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function r5e(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 n5e={binary:N8.buffer,"utf-8":N8.utf8},i5e={...N8,...n5e},s5e=0});var qn=R((eft,uI)=>{"use strict";u();var Jp=typeof Reflect=="object"?Reflect:null,wW=Jp&&typeof Jp.apply=="function"?Jp.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},O8;Jp&&typeof Jp.ownKeys=="function"?O8=Jp.ownKeys:Object.getOwnPropertySymbols?O8=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:O8=function(e){return Object.getOwnPropertyNames(e)};function o5e(r){console&&console.warn&&console.warn(r)}var bW=Number.isNaN||function(e){return e!==e};function Gt(){Gt.init.call(this)}uI.exports=Gt;uI.exports.once=l5e;Gt.EventEmitter=Gt;Gt.prototype._events=void 0;Gt.prototype._eventsCount=0;Gt.prototype._maxListeners=void 0;var EW=10;function L8(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Gt,"defaultMaxListeners",{enumerable:!0,get:function(){return EW},set:function(r){if(typeof r!="number"||r<0||bW(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");EW=r}});Gt.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};Gt.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||bW(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 _W(r){return r._maxListeners===void 0?Gt.defaultMaxListeners:r._maxListeners}Gt.prototype.getMaxListeners=function(){return _W(this)};Gt.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")wW(c,this,t);else for(var l=c.length,f=IW(c,l),n=0;n<l;++n)wW(f[n],this,t);return!0};function vW(r,e,t,n){var i,s,o;if(L8(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=_W(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,o5e(a)}return r}Gt.prototype.addListener=function(e,t){return vW(this,e,t,!1)};Gt.prototype.on=Gt.prototype.addListener;Gt.prototype.prependListener=function(e,t){return vW(this,e,t,!0)};function a5e(){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 SW(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},i=a5e.bind(n);return i.listener=t,n.wrapFn=i,i}Gt.prototype.once=function(e,t){return L8(t),this.on(e,SW(this,e,t)),this};Gt.prototype.prependOnceListener=function(e,t){return L8(t),this.prependListener(e,SW(this,e,t)),this};Gt.prototype.removeListener=function(e,t){var n,i,s,o,a;if(L8(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():c5e(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};Gt.prototype.off=Gt.prototype.removeListener;Gt.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 xW(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?u5e(i):IW(i,i.length)}Gt.prototype.listeners=function(e){return xW(this,e,!0)};Gt.prototype.rawListeners=function(e){return xW(this,e,!1)};Gt.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):TW.call(r,e)};Gt.prototype.listenerCount=TW;function TW(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}Gt.prototype.eventNames=function(){return this._eventsCount>0?O8(this._events):[]};function IW(r,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=r[n];return t}function c5e(r,e){for(;e+1<r.length;e++)r[e]=r[e+1];r.pop()}function u5e(r){for(var e=new Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}function l5e(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))}AW(r,e,s,{once:!0}),e!=="error"&&f5e(r,i,{once:!0})})}function f5e(r,e,t){typeof r.on=="function"&&AW(r,"error",e,t)}function AW(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 CW=R((rft,RW)=>{u();RW.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var oy=R(lI=>{"use strict";u();var DW=CW();lI.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};lI.fromPromise=function(r,e){if(e===void 0)return r;r.then(function(t){DW(()=>e(null,t))}).catch(function(t){DW(()=>e(t))})}});var B8=R(fI=>{"use strict";u();fI.getCallback=function(r,e){return typeof r=="function"?r:e};fI.getOptions=function(r,e){return typeof r=="object"&&r!==null?r:e!==void 0?e:{}}});var Tl=R(V8=>{"use strict";u();var{fromCallback:hI}=oy(),Qi=Io(),{getOptions:dI,getCallback:PW}=B8(),gh=Symbol("promise"),e0=Symbol("callback"),va=Symbol("working"),wh=Symbol("handleOne"),kc=Symbol("handleMany"),pI=Symbol("autoClose"),Sl=Symbol("finishWork"),Sa=Symbol("returnMany"),bl=Symbol("closing"),ay=Symbol("handleClose"),M8=Symbol("closed"),cy=Symbol("closeCallbacks"),vl=Symbol("keyEncoding"),Eh=Symbol("valueEncoding"),mI=Symbol("abortOnClose"),U8=Symbol("legacy"),yI=Symbol("keys"),gI=Symbol("values"),_l=Symbol("limit"),Ls=Symbol("count"),F8=Object.freeze({}),h5e=()=>{},kW=!1,uy=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[M8]=!1,this[cy]=[],this[va]=!1,this[bl]=!1,this[pI]=!1,this[e0]=null,this[wh]=this[wh].bind(this),this[kc]=this[kc].bind(this),this[ay]=this[ay].bind(this),this[vl]=t[vl],this[Eh]=t[Eh],this[U8]=n,this[_l]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[Ls]=0,this[mI]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[Ls]}get limit(){return this[_l]}next(e){let t;if(e===void 0)t=new Promise((n,i)=>{e=(s,o,a)=>{s?i(s):this[U8]?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[bl]?this.nextTick(e,new Qi("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[va]?this.nextTick(e,new Qi("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[va]=!0,this[e0]=e,this[Ls]>=this[_l]?this.nextTick(this[wh],null):this._next(this[wh])),t}_next(e){this.nextTick(e)}nextv(e,t,n){return n=PW(t,n),n=hI(n,gh),t=dI(t,F8),Number.isInteger(e)?(this[bl]?this.nextTick(n,new Qi("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[va]?this.nextTick(n,new Qi("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[_l]<1/0&&(e=Math.min(e,this[_l]-this[Ls])),this[va]=!0,this[e0]=n,e<=0?this.nextTick(this[kc],null,[]):this._nextv(e,t,this[kc])),n[gh]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[gh])}_nextv(e,t,n){let i=[],s=(o,a,c)=>{if(o)return n(o);if(this[U8]?a===void 0&&c===void 0:a===void 0)return n(null,i);i.push(this[U8]?[a,c]:a),i.length===e?n(null,i):this._next(s)};this._next(s)}all(e,t){return t=PW(e,t),t=hI(t,gh),e=dI(e,F8),this[bl]?this.nextTick(t,new Qi("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[va]?this.nextTick(t,new Qi("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[va]=!0,this[e0]=t,this[pI]=!0,this[Ls]>=this[_l]?this.nextTick(this[kc],null,[]):this._all(e,this[kc])),t[gh]}_all(e,t){let n=this[Ls],i=[],s=()=>{let a=this[_l]<1/0?Math.min(1e3,this[_l]-n):1e3;a<=0?this.nextTick(t,null,i):this._nextv(a,F8,o)},o=(a,c)=>{a?t(a):c.length===0?t(null,i):(i.push.apply(i,c),n+=c.length,s())};s()}[Sl](){let e=this[e0];return this[mI]&&e===null?h5e:(this[va]=!1,this[e0]=null,this[bl]&&this._close(this[ay]),e)}[Sa](e,t,n){this[pI]?this.close(e.bind(null,t,n)):e(t,n)}seek(e,t){if(t=dI(t,F8),!this[bl]){if(this[va])throw new Qi("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(t.keyEncoding||this[vl]),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 Qi("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=hI(e,gh),this[M8]?this.nextTick(e):this[bl]?this[cy].push(e):(this[bl]=!0,this[cy].push(e),this[va]?this[mI]&&this[Sl]()(new Qi("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[ay])),e[gh]}_close(e){this.nextTick(e)}[ay](){this[M8]=!0,this.db.detachResource(this);let e=this[cy];this[cy]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[M8]||await this.close()}}},t0=class extends uy{constructor(e,t){super(e,t,!0),this[yI]=t.keys!==!1,this[gI]=t.values!==!1}[wh](e,t,n){let i=this[Sl]();if(e)return i(e);try{t=this[yI]&&t!==void 0?this[vl].decode(t):void 0,n=this[gI]&&n!==void 0?this[Eh].decode(n):void 0}catch(s){return i(new xl("entry",s))}t===void 0&&n===void 0||this[Ls]++,i(null,t,n)}[kc](e,t){let n=this[Sl]();if(e)return this[Sa](n,e);try{for(let i of t){let s=i[0],o=i[1];i[0]=this[yI]&&s!==void 0?this[vl].decode(s):void 0,i[1]=this[gI]&&o!==void 0?this[Eh].decode(o):void 0}}catch(i){return this[Sa](n,new xl("entries",i))}this[Ls]+=t.length,this[Sa](n,null,t)}end(e){return!kW&&typeof console<"u"&&(kW=!0,console.warn(new Qi("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)}},wI=class extends uy{constructor(e,t){super(e,t,!1)}[wh](e,t){let n=this[Sl]();if(e)return n(e);try{t=t!==void 0?this[vl].decode(t):void 0}catch(i){return n(new xl("key",i))}t!==void 0&&this[Ls]++,n(null,t)}[kc](e,t){let n=this[Sl]();if(e)return this[Sa](n,e);try{for(let i=0;i<t.length;i++){let s=t[i];t[i]=s!==void 0?this[vl].decode(s):void 0}}catch(i){return this[Sa](n,new xl("keys",i))}this[Ls]+=t.length,this[Sa](n,null,t)}},EI=class extends uy{constructor(e,t){super(e,t,!1)}[wh](e,t){let n=this[Sl]();if(e)return n(e);try{t=t!==void 0?this[Eh].decode(t):void 0}catch(i){return n(new xl("value",i))}t!==void 0&&this[Ls]++,n(null,t)}[kc](e,t){let n=this[Sl]();if(e)return this[Sa](n,e);try{for(let i=0;i<t.length;i++){let s=t[i];t[i]=s!==void 0?this[Eh].decode(s):void 0}}catch(i){return this[Sa](n,new xl("values",i))}this[Ls]+=t.length,this[Sa](n,null,t)}},xl=class extends Qi{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(t0.prototype,r.split(" ")[0],{get(){throw new Qi(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Qi(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});t0.keyEncoding=vl;t0.valueEncoding=Eh;V8.AbstractIterator=t0;V8.AbstractKeyIterator=wI;V8.AbstractValueIterator=EI});var NW=R(bI=>{"use strict";u();var{AbstractKeyIterator:d5e,AbstractValueIterator:p5e}=Tl(),bh=Symbol("iterator"),ly=Symbol("callback"),r0=Symbol("handleOne"),_h=Symbol("handleMany"),fy=class extends d5e{constructor(e,t){super(e,t),this[bh]=e.iterator({...t,keys:!0,values:!1}),this[r0]=this[r0].bind(this),this[_h]=this[_h].bind(this)}},K8=class extends p5e{constructor(e,t){super(e,t),this[bh]=e.iterator({...t,keys:!1,values:!0}),this[r0]=this[r0].bind(this),this[_h]=this[_h].bind(this)}};for(let r of[fy,K8]){let e=r===fy,t=e?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[ly]=n,this[bh].next(this[r0])},r.prototype[r0]=function(n,i,s){let o=this[ly];n?o(n):o(null,e?i:s)},r.prototype._nextv=function(n,i,s){this[ly]=s,this[bh].nextv(n,i,this[_h])},r.prototype._all=function(n,i){this[ly]=i,this[bh].all(n,this[_h])},r.prototype[_h]=function(n,i){let s=this[ly];n?s(n):s(null,i.map(t))},r.prototype._seek=function(n,i){this[bh].seek(n,i)},r.prototype._close=function(n){this[bh].close(n)}}bI.DefaultKeyIterator=fy;bI.DefaultValueIterator=K8});var OW=R(W8=>{"use strict";u();var{AbstractIterator:m5e,AbstractKeyIterator:y5e,AbstractValueIterator:g5e}=Tl(),_I=Io(),Ti=Symbol("nut"),H8=Symbol("undefer"),G8=Symbol("factory"),z8=class extends m5e{constructor(e,t){super(e,t),this[Ti]=null,this[G8]=()=>e.iterator(t),this.db.defer(()=>this[H8]())}},q8=class extends y5e{constructor(e,t){super(e,t),this[Ti]=null,this[G8]=()=>e.keys(t),this.db.defer(()=>this[H8]())}},$8=class extends g5e{constructor(e,t){super(e,t),this[Ti]=null,this[G8]=()=>e.values(t),this.db.defer(()=>this[H8]())}};for(let r of[z8,q8,$8])r.prototype[H8]=function(){this.db.status==="open"&&(this[Ti]=this[G8]())},r.prototype._next=function(e){this[Ti]!==null?this[Ti].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new _I("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(e,t,n){this[Ti]!==null?this[Ti].nextv(e,t,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,t,n)):this.nextTick(n,new _I("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(e,t){this[Ti]!==null?this[Ti].all(t):this.db.status==="opening"?this.db.defer(()=>this._all(e,t)):this.nextTick(t,new _I("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(e,t){this[Ti]!==null?this[Ti]._seek(e,t):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,t))},r.prototype._close=function(e){this[Ti]!==null?this[Ti].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};W8.DeferredIterator=z8;W8.DeferredKeyIterator=q8;W8.DeferredValueIterator=$8});var SI=R(BW=>{"use strict";u();var{fromCallback:LW}=oy(),j8=Io(),{getCallback:w5e,getOptions:E5e}=B8(),Y8=Symbol("promise"),Bs=Symbol("status"),n0=Symbol("operations"),hy=Symbol("finishClose"),i0=Symbol("closeCallbacks"),vI=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[n0]=[],this[i0]=[],this[Bs]="open",this[hy]=this[hy].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[n0].length}put(e,t,n){if(this[Bs]!=="open")throw new j8("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[n0].push({...o,type:"put",key:e,value:t}),this}_put(e,t,n){}del(e,t){if(this[Bs]!=="open")throw new j8("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[n0].push({...s,type:"del",key:e}),this}_del(e,t){}clear(){if(this[Bs]!=="open")throw new j8("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[n0]=[],this}_clear(){}write(e,t){return t=w5e(e,t),t=LW(t,Y8),e=E5e(e),this[Bs]!=="open"?this.nextTick(t,new j8("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(t):(this[Bs]="writing",this._write(e,n=>{this[Bs]="closing",this[i0].push(()=>t(n)),n||this.db.emit("batch",this[n0]),this._close(this[hy])})),t[Y8]}_write(e,t){}close(e){return e=LW(e,Y8),this[Bs]==="closing"?this[i0].push(e):this[Bs]==="closed"?this.nextTick(e):(this[i0].push(e),this[Bs]!=="writing"&&(this[Bs]="closing",this._close(this[hy]))),e[Y8]}_close(e){this.nextTick(e)}[hy](){this[Bs]="closed",this.db.detachResource(this);let e=this[i0];this[i0]=[];for(let t of e)t()}};BW.AbstractChainedBatch=vI});var UW=R(MW=>{"use strict";u();var{AbstractChainedBatch:b5e}=SI(),_5e=Io(),s0=Symbol("encoded"),xI=class extends b5e{constructor(e){super(e),this[s0]=[]}_put(e,t,n){this[s0].push({...n,type:"put",key:e,value:t})}_del(e,t){this[s0].push({...t,type:"del",key:e})}_clear(){this[s0]=[]}_write(e,t){this.db.status==="opening"?this.db.defer(()=>this._write(e,t)):this.db.status==="open"?this[s0].length===0?this.nextTick(t):this.db._batch(this[s0],e,t):this.nextTick(t,new _5e("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};MW.DefaultChainedBatch=xI});var KW=R((wft,VW)=>{"use strict";u();var FW=Io(),v5e=Object.prototype.hasOwnProperty,S5e=new Set(["lt","lte","gt","gte"]);VW.exports=function(r,e){let t={};for(let n in r)if(!!v5e.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new FW(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new FW("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});S5e.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 TI=R((bft,qW)=>{u();var zW;qW.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(zW||(zW=Promise.resolve())).then(r).catch(e=>setTimeout(()=>{throw e},0))});var GW=R((vft,HW)=>{"use strict";u();var $W=TI();HW.exports=function(r,...e){e.length===0?$W(r):$W(()=>r(...e))}});var WW=R(Q8=>{"use strict";u();var{AbstractIterator:x5e,AbstractKeyIterator:T5e,AbstractValueIterator:I5e}=Tl(),o0=Symbol("unfix"),Ao=Symbol("iterator"),vh=Symbol("handleOne"),Il=Symbol("handleMany"),Nc=Symbol("callback"),dy=class extends x5e{constructor(e,t,n,i){super(e,t),this[Ao]=n,this[o0]=i,this[vh]=this[vh].bind(this),this[Il]=this[Il].bind(this),this[Nc]=null}[vh](e,t,n){let i=this[Nc];if(e)return i(e);t!==void 0&&(t=this[o0](t)),i(e,t,n)}[Il](e,t){let n=this[Nc];if(e)return n(e);for(let i of t){let s=i[0];s!==void 0&&(i[0]=this[o0](s))}n(e,t)}},py=class extends T5e{constructor(e,t,n,i){super(e,t),this[Ao]=n,this[o0]=i,this[vh]=this[vh].bind(this),this[Il]=this[Il].bind(this),this[Nc]=null}[vh](e,t){let n=this[Nc];if(e)return n(e);t!==void 0&&(t=this[o0](t)),n(e,t)}[Il](e,t){let n=this[Nc];if(e)return n(e);for(let i=0;i<t.length;i++){let s=t[i];s!==void 0&&(t[i]=this[o0](s))}n(e,t)}},my=class extends I5e{constructor(e,t,n){super(e,t),this[Ao]=n}};for(let r of[dy,py])r.prototype._next=function(e){this[Nc]=e,this[Ao].next(this[vh])},r.prototype._nextv=function(e,t,n){this[Nc]=n,this[Ao].nextv(e,t,this[Il])},r.prototype._all=function(e,t){this[Nc]=t,this[Ao].all(e,this[Il])};for(let r of[my])r.prototype._next=function(e){this[Ao].next(e)},r.prototype._nextv=function(e,t,n){this[Ao].nextv(e,t,n)},r.prototype._all=function(e,t){this[Ao].all(e,t)};for(let r of[dy,py,my])r.prototype._seek=function(e,t){this[Ao].seek(e,t)},r.prototype._close=function(e){this[Ao].close(e)};Q8.AbstractSublevelIterator=dy;Q8.AbstractSublevelKeyIterator=py;Q8.AbstractSublevelValueIterator=my});var XW=R((Ift,QW)=>{"use strict";u();var II=Io(),{Buffer:CI}=md()||{},{AbstractSublevelIterator:A5e,AbstractSublevelKeyIterator:R5e,AbstractSublevelValueIterator:C5e}=WW(),Oc=Symbol("prefix"),jW=Symbol("upperBound"),yy=Symbol("prefixRange"),Xi=Symbol("parent"),AI=Symbol("unfix"),YW=new TextEncoder,D5e={separator:"!"};QW.exports=function({AbstractLevel:r}){class e extends r{static defaults(n){if(typeof n=="string")throw new II("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new II("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?D5e:n.separator?n:{...n,separator:"!"}}constructor(n,i,s){let{separator:o,manifest:a,...c}=e.defaults(s);i=k5e(i,o);let l=o.charCodeAt(0)+1,f=n[Xi]||n;if(!YW.encode(i).every(d=>d>l&&d<127))throw new II(`Prefix must use bytes > ${l} < ${127}`,{code:"LEVEL_INVALID_PREFIX"});super(P5e(f,a),c);let h=(n.prefix||"")+o+i+o,p=h.slice(0,-1)+String.fromCharCode(l);this[Xi]=f,this[Oc]=new X8(h),this[jW]=new X8(p),this[AI]=new DI,this.nextTick=f.nextTick}prefixKey(n,i){if(i==="utf8")return this[Oc].utf8+n;if(n.byteLength===0)return this[Oc][i];if(i==="view"){let s=this[Oc].view,o=new Uint8Array(s.byteLength+n.byteLength);return o.set(s,0),o.set(n,s.byteLength),o}else{let s=this[Oc].buffer;return CI.concat([s,n],s.byteLength+n.byteLength)}}[yy](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[Oc][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[jW][i]}get prefix(){return this[Oc].utf8}get db(){return this[Xi]}_open(n,i){this[Xi].open({passive:!0},i)}_put(n,i,s,o){this[Xi].put(n,i,s,o)}_get(n,i,s){this[Xi].get(n,i,s)}_getMany(n,i,s){this[Xi].getMany(n,i,s)}_del(n,i,s){this[Xi].del(n,i,s)}_batch(n,i,s){this[Xi].batch(n,i,s)}_clear(n,i){this[yy](n,n.keyEncoding),this[Xi].clear(n,i)}_iterator(n){this[yy](n,n.keyEncoding);let i=this[Xi].iterator(n),s=this[AI].get(this[Oc].utf8.length,n.keyEncoding);return new A5e(this,n,i,s)}_keys(n){this[yy](n,n.keyEncoding);let i=this[Xi].keys(n),s=this[AI].get(this[Oc].utf8.length,n.keyEncoding);return new R5e(this,n,i,s)}_values(n){this[yy](n,n.keyEncoding);let i=this[Xi].values(n);return new C5e(this,n,i)}}return{AbstractSublevel:e}};var P5e=function(r,e){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:RI(r,"utf8"),buffer:RI(r,"buffer"),view:RI(r,"view")}}},RI=function(r,e){return r.supports.encodings[e]?r.keyEncoding(e).name===e:!1},X8=class{constructor(e){this.utf8=e,this.view=YW.encode(e),this.buffer=CI?CI.from(this.view.buffer,0,this.view.byteLength):{}}},DI=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}},k5e=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 LI=R(OI=>{"use strict";u();var{supports:N5e}=aW(),{Transcoder:O5e}=gW(),{EventEmitter:L5e}=qn(),{fromCallback:Al}=oy(),Ro=Io(),{AbstractIterator:Sh}=Tl(),{DefaultKeyIterator:B5e,DefaultValueIterator:M5e}=NW(),{DeferredIterator:U5e,DeferredKeyIterator:F5e,DeferredValueIterator:V5e}=OW(),{DefaultChainedBatch:ZW}=UW(),{getCallback:xh,getOptions:Rl}=B8(),Z8=KW(),Ze=Symbol("promise"),Lc=Symbol("landed"),Th=Symbol("resources"),PI=Symbol("closeResources"),gy=Symbol("operations"),wy=Symbol("undefer"),J8=Symbol("deferOpen"),JW=Symbol("options"),ft=Symbol("status"),Ih=Symbol("defaultOptions"),a0=Symbol("transcoder"),e5=Symbol("keyEncoding"),kI=Symbol("valueEncoding"),K5e=()=>{},Ey=class extends L5e{constructor(e,t){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");t=Rl(t);let{keyEncoding:n,valueEncoding:i,passive:s,...o}=t;this[Th]=new Set,this[gy]=[],this[J8]=!0,this[JW]=o,this[ft]="opening",this.supports=N5e(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[a0]=new O5e(z5e(this)),this[e5]=this[a0].encoding(n||"utf8"),this[kI]=this[a0].encoding(i||"utf8");for(let a of this[a0].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Ih]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[e5].commonName,valueEncoding:this[kI].commonName}),key:Object.freeze({keyEncoding:this[e5].commonName})},this.nextTick(()=>{this[J8]&&this.open({passive:!1},K5e)})}get status(){return this[ft]}keyEncoding(e){return this[a0].encoding(e??this[e5])}valueEncoding(e){return this[a0].encoding(e??this[kI])}open(e,t){t=xh(e,t),t=Al(t,Ze),e={...this[JW],...Rl(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[ft]==="closing"||this[ft]==="opening"?this.once(Lc,i?()=>n(i):n):this[ft]!=="open"?t(new Ro("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):t()};return e.passive?this[ft]==="opening"?this.once(Lc,n):this.nextTick(n):this[ft]==="closed"||this[J8]?(this[J8]=!1,this[ft]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[ft]="closed",this[PI](()=>{this.emit(Lc),n(i)}),this[wy]();return}this[ft]="open",this[wy](),this.emit(Lc),this[ft]==="open"&&this.emit("open"),this[ft]==="open"&&this.emit("ready"),n()})):this[ft]==="open"?this.nextTick(n):this.once(Lc,()=>this.open(e,t)),t[Ze]}_open(e,t){this.nextTick(t)}close(e){e=Al(e,Ze);let t=n=>{this[ft]==="opening"||this[ft]==="closing"?this.once(Lc,n?t(n):t):this[ft]!=="closed"?e(new Ro("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[ft]==="open"){this[ft]="closing",this.emit("closing");let n=i=>{this[ft]="open",this[wy](),this.emit(Lc),t(i)};this[PI](()=>{this._close(i=>{if(i)return n(i);this[ft]="closed",this[wy](),this.emit(Lc),this[ft]==="closed"&&this.emit("closed"),t()})})}else this[ft]==="closed"?this.nextTick(t):this.once(Lc,()=>this.close(e));return e[Ze]}[PI](e){if(this[Th].size===0)return this.nextTick(e);let t=this[Th].size,n=!0,i=()=>{--t===0&&(n?this.nextTick(e):e())};for(let s of this[Th])s.close(i);n=!1,this[Th].clear()}_close(e){this.nextTick(e)}get(e,t,n){if(n=xh(t,n),n=Al(n,Ze),t=Rl(t,this[Ih].entry),this[ft]==="opening")return this.defer(()=>this.get(e,t,n)),n[Ze];if(c0(this,n))return n[Ze];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[Ze];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 Ro("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,f)}),n[Ze]}_get(e,t,n){this.nextTick(n,new Error("NotFound"))}getMany(e,t,n){if(n=xh(t,n),n=Al(n,Ze),t=Rl(t,this[Ih].entry),this[ft]==="opening")return this.defer(()=>this.getMany(e,t,n)),n[Ze];if(c0(this,n))return n[Ze];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[Ze];if(e.length===0)return this.nextTick(n,null,[]),n[Ze];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[Ze];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 Ro(`Could not decode one or more of ${f.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:h}))}n(null,f)}),n[Ze]}_getMany(e,t,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,t,n,i){if(i=xh(n,i),i=Al(i,Ze),n=Rl(n,this[Ih].entry),this[ft]==="opening")return this.defer(()=>this.put(e,t,n,i)),i[Ze];if(c0(this,i))return i[Ze];let s=this._checkKey(e)||this._checkValue(t);if(s)return this.nextTick(i,s),i[Ze];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[Ze]}_put(e,t,n,i){this.nextTick(i)}del(e,t,n){if(n=xh(t,n),n=Al(n,Ze),t=Rl(t,this[Ih].key),this[ft]==="opening")return this.defer(()=>this.del(e,t,n)),n[Ze];if(c0(this,n))return n[Ze];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[Ze];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[Ze]}_del(e,t,n){this.nextTick(n)}batch(e,t,n){if(!arguments.length){if(this[ft]==="opening")return new ZW(this);if(this[ft]!=="open")throw new Ro("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=xh(t,n),n=Al(n,Ze),t=Rl(t,this[Ih].empty),this[ft]==="opening")return this.defer(()=>this.batch(e,t,n)),n[Ze];if(c0(this,n))return n[Ze];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[Ze];if(e.length===0)return this.nextTick(n),n[Ze];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[Ze];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[Ze];let f=this._checkKey(l.key);if(f)return this.nextTick(n,f),n[Ze];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[Ze];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[Ze]}_batch(e,t,n){this.nextTick(n)}sublevel(e,t){return this._sublevel(e,NI.defaults(t))}_sublevel(e,t){return new NI(this,e,t)}prefixKey(e,t){return e}clear(e,t){if(t=xh(e,t),t=Al(t,Ze),e=Rl(e,this[Ih].empty),this[ft]==="opening")return this.defer(()=>this.clear(e,t)),t[Ze];if(c0(this,t))return t[Ze];let n=e,i=this.keyEncoding(e.keyEncoding);return e=Z8(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[Ze]}_clear(e,t){this.nextTick(t)}iterator(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=Z8(e,t),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Sh.keyEncoding]=t,e[Sh.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[ft]==="opening")return new U5e(this,e);if(this[ft]!=="open")throw new Ro("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Sh(this,e)}keys(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=Z8(e,t),e[Sh.keyEncoding]=t,e[Sh.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[ft]==="opening")return new F5e(this,e);if(this[ft]!=="open")throw new Ro("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new B5e(this,e)}values(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=Z8(e,t),e[Sh.keyEncoding]=t,e[Sh.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[ft]==="opening")return new V5e(this,e);if(this[ft]!=="open")throw new Ro("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new M5e(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[gy].push(e)}[wy](){if(this[gy].length===0)return;let e=this[gy];this[gy]=[];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[Th].add(e)}detachResource(e){this[Th].delete(e)}_chainedBatch(){return new ZW(this)}_checkKey(e){if(e==null)return new Ro("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new Ro("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Ey.prototype.nextTick=GW();var{AbstractSublevel:NI}=XW()({AbstractLevel:Ey});OI.AbstractLevel=Ey;OI.AbstractSublevel=NI;var c0=function(r,e){return r[ft]!=="open"?(r.nextTick(e,new Ro("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},z5e=function(r){return Object.keys(r.supports.encodings).filter(e=>!!r.supports.encodings[e])}});var BI=R(Ah=>{"use strict";u();Ah.AbstractLevel=LI().AbstractLevel;Ah.AbstractSublevel=LI().AbstractSublevel;Ah.AbstractIterator=Tl().AbstractIterator;Ah.AbstractKeyIterator=Tl().AbstractKeyIterator;Ah.AbstractValueIterator=Tl().AbstractValueIterator;Ah.AbstractChainedBatch=SI().AbstractChainedBatch});var tj=R((kft,ej)=>{u();ej.exports=$5e;var q5e=TI();function $5e(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?q5e(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 MI=R((Oft,rj)=>{"use strict";u();rj.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 UI=R((Bft,nj)=>{"use strict";u();var H5e=new TextEncoder;nj.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):H5e.encode(r)}});var cj=R(aj=>{"use strict";u();var{AbstractIterator:G5e}=BI(),ij=MI(),t5=UI(),xa=Symbol("cache"),Bc=Symbol("finished"),Zi=Symbol("options"),Mc=Symbol("currentOptions"),Rh=Symbol("position"),FI=Symbol("location"),u0=Symbol("first"),sj={},VI=class extends G5e{constructor(e,t,n){super(e,n),this[xa]=[],this[Bc]=this.limit===0,this[Zi]=n,this[Mc]={...n},this[Rh]=void 0,this[FI]=t,this[u0]=!0}_nextv(e,t,n){if(this[u0]=!1,this[Bc])return this.nextTick(n,null,[]);if(this[xa].length>0)return e=Math.min(e,this[xa].length),this.nextTick(n,null,this[xa].splice(0,e));this[Rh]!==void 0&&(this[Zi].reverse?(this[Mc].lt=this[Rh],this[Mc].lte=void 0):(this[Mc].gt=this[Rh],this[Mc].gte=void 0));let i;try{i=ij(this[Mc])}catch{return this[Bc]=!0,this.nextTick(n,null,[])}let s=this.db.db.transaction([this[FI]],"readonly"),o=s.objectStore(this[FI]),a=[];if(this[Zi].reverse){let c=!this[Zi].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[Rh]=h,a.push([this[Zi].keys&&h!==void 0?t5(h):void 0,this[Zi].values&&p!==void 0?t5(p):void 0]),a.length<e?f.continue():oj(s)}else this[Bc]=!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[Bc]=!0:this[Rh]=c[h-1],a.length=h;for(let p=0;p<h;p++){let d=c[p],m=l[p];a[p]=[this[Zi].keys&&d!==void 0?t5(d):void 0,this[Zi].values&&m!==void 0?t5(m):void 0]}oj(s)};this[Zi].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[Zi].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[xa].length>0){let[t,n]=this[xa].shift();this.nextTick(e,null,t,n)}else if(this[Bc])this.nextTick(e);else{let t=Math.min(100,this.limit-this.count);this[u0]&&(this[u0]=!1,t=1),this._nextv(t,sj,(n,i)=>{if(n)return e(n);this[xa]=i,this._next(e)})}}_all(e,t){this[u0]=!1;let n=this[xa].splice(0,this[xa].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(t,null,n);this._nextv(i,sj,(s,o)=>{if(s)return t(s);n.length>0&&(o=n.concat(o)),t(null,o)})}_seek(e,t){this[u0]=!0,this[xa]=[],this[Bc]=!1,this[Rh]=void 0,this[Mc]={...this[Zi]};let n;try{n=ij(this[Zi])}catch{this[Bc]=!0;return}n!==null&&!n.includes(e)?this[Bc]=!0:this[Zi].reverse?this[Mc].lte=e:this[Mc].gte=e}};aj.Iterator=VI;function oj(r){typeof r.commit=="function"&&r.commit()}});var lj=R((Vft,uj)=>{"use strict";u();uj.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 yj=R(mj=>{"use strict";u();var{AbstractLevel:W5e}=BI(),fj=Io(),j5e=tj(),{fromCallback:Y5e}=oy(),{Iterator:Q5e}=cj(),hj=UI(),X5e=lj(),Z5e=MI(),pj="level-js-",by=Symbol("idb"),KI=Symbol("namePrefix"),Uc=Symbol("location"),zI=Symbol("version"),Ch=Symbol("store"),_y=Symbol("onComplete"),dj=Symbol("promise"),r5=class extends W5e{constructor(e,t,n){if(typeof t=="function"||typeof n=="function")throw new fj("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[Uc]=e,this[KI]=i??pj,this[zI]=parseInt(s||1,10),this[by]=null}get location(){return this[Uc]}get namePrefix(){return this[KI]}get version(){return this[zI]}get db(){return this[by]}get type(){return"browser-level"}_open(e,t){let n=indexedDB.open(this[KI]+this[Uc],this[zI]);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[Uc])||s.createObjectStore(this[Uc])}}[Ch](e){return this[by].transaction([this[Uc]],e).objectStore(this[Uc])}[_y](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[Ch]("readonly"),s;try{s=i.get(e)}catch(o){return this.nextTick(n,o)}this[_y](s,function(o,a){if(o)return n(o);if(a===void 0)return n(new fj("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,hj(a))})}_getMany(e,t,n){let i=this[Ch]("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:hj(l))},c.onerror=l=>{l.stopPropagation(),a(c.error)}});j5e(s,16,n)}_del(e,t,n){let i=this[Ch]("readwrite"),s;try{s=i.delete(e)}catch(o){return this.nextTick(n,o)}this[_y](s,n)}_put(e,t,n,i){let s=this[Ch]("readwrite"),o;try{o=s.put(t,e)}catch(a){return this.nextTick(i,a)}this[_y](o,i)}_iterator(e){return new Q5e(this,this[Uc],e)}_batch(e,t,n){let i=this[Ch]("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=Z5e(e)}catch{return this.nextTick(t)}if(e.limit>=0)return X5e(this,this[Uc],n,e,t);try{let s=this[Ch]("readwrite");i=n?s.delete(n):s.clear()}catch(s){return this.nextTick(t,s)}this[_y](i,t)}_close(e){this[by].close(),this.nextTick(e)}};r5.destroy=function(r,e,t){typeof e=="function"&&(t=e,e=pj),t=Y5e(t,dj);let n=indexedDB.deleteDatabase(e+r);return n.onsuccess=function(){t()},n.onerror=function(i){t(i)},t[dj]};mj.BrowserLevel=r5});var wj=R(gj=>{u();gj.Level=yj().BrowserLevel});var vj=R((Qft,_j)=>{"use strict";u();var tEe=async r=>{for await(let e of r);};_j.exports=tEe});var xj=R((Zft,Sj)=>{"use strict";u();var rEe=async function*(r,e){for await(let t of r)await e(t)&&(yield t)};Sj.exports=rEe});var Ij=R((eht,Tj)=>{"use strict";u();var nEe=async r=>{let e=[];for await(let t of r)e.push(t);return e};Tj.exports=nEe});var Kj=R((ydt,Vj)=>{"use strict";u();Vj.exports=On;var Ty=kl();function On(r,e){this.lo=r>>>0,this.hi=e>>>0}var kh=On.zero=new On(0,0);kh.toNumber=function(){return 0};kh.zzEncode=kh.zzDecode=function(){return this};kh.length=function(){return 1};var yEe=On.zeroHash="\0\0\0\0\0\0\0\0";On.fromNumber=function(e){if(e===0)return kh;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 On(n,i)};On.from=function(e){if(typeof e=="number")return On.fromNumber(e);if(Ty.isString(e))if(Ty.Long)e=Ty.Long.fromString(e);else return On.fromNumber(parseInt(e,10));return e.low||e.high?new On(e.low>>>0,e.high>>>0):kh};On.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};On.prototype.toLong=function(e){return Ty.Long?new Ty.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var Pl=String.prototype.charCodeAt;On.fromHash=function(e){return e===yEe?kh:new On((Pl.call(e,0)|Pl.call(e,1)<<8|Pl.call(e,2)<<16|Pl.call(e,3)<<24)>>>0,(Pl.call(e,4)|Pl.call(e,5)<<8|Pl.call(e,6)<<16|Pl.call(e,7)<<24)>>>0)};On.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)};On.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};On.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};On.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 kl=R(QI=>{"use strict";u();var Ie=QI;Ie.asPromise=x_();Ie.base64=T_();Ie.EventEmitter=I_();Ie.float=A_();Ie.inquire=R_();Ie.utf8=D_();Ie.pool=P_();Ie.LongBits=Kj();Ie.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);Ie.global=Ie.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||QI;Ie.emptyArray=Object.freeze?Object.freeze([]):[];Ie.emptyObject=Object.freeze?Object.freeze({}):{};Ie.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};Ie.isString=function(e){return typeof e=="string"||e instanceof String};Ie.isObject=function(e){return e&&typeof e=="object"};Ie.isset=Ie.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};Ie.Buffer=function(){try{var r=Ie.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();Ie._Buffer_from=null;Ie._Buffer_allocUnsafe=null;Ie.newBuffer=function(e){return typeof e=="number"?Ie.Buffer?Ie._Buffer_allocUnsafe(e):new Ie.Array(e):Ie.Buffer?Ie._Buffer_from(e):typeof Uint8Array>"u"?e:new Uint8Array(e)};Ie.Array=typeof Uint8Array<"u"?Uint8Array:Array;Ie.Long=Ie.global.dcodeIO&&Ie.global.dcodeIO.Long||Ie.global.Long||Ie.inquire("long");Ie.key2Re=/^true|false|0|1$/;Ie.key32Re=/^-?(?:0|[1-9][0-9]*)$/;Ie.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;Ie.longToHash=function(e){return e?Ie.LongBits.from(e).toHash():Ie.LongBits.zeroHash};Ie.longFromHash=function(e,t){var n=Ie.LongBits.fromHash(e);return Ie.Long?Ie.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))};function zj(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}Ie.merge=zj;Ie.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function qj(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&&zj(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}Ie.newError=qj;Ie.ProtocolError=qj("ProtocolError");Ie.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]}};Ie.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}};Ie.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};Ie._configure=function(){var r=Ie.Buffer;if(!r){Ie._Buffer_from=Ie._Buffer_allocUnsafe=null;return}Ie._Buffer_from=r.from!==Uint8Array.from&&r.from||function(t,n){return new r(t,n)},Ie._Buffer_allocUnsafe=r.allocUnsafe||function(t){return new r(t)}}});var nA=R((bdt,Wj)=>{"use strict";u();Wj.exports=Rt;var Ms=kl(),XI,a5=Ms.LongBits,$j=Ms.base64,Hj=Ms.utf8;function Iy(r,e,t){this.fn=r,this.len=e,this.next=void 0,this.val=t}function JI(){}function gEe(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function Rt(){this.len=0,this.head=new Iy(JI,0,0),this.tail=this.head,this.states=null}var Gj=function(){return Ms.Buffer?function(){return(Rt.create=function(){return new XI})()}:function(){return new Rt}};Rt.create=Gj();Rt.alloc=function(e){return new Ms.Array(e)};Ms.Array!==Array&&(Rt.alloc=Ms.pool(Rt.alloc,Ms.Array.prototype.subarray));Rt.prototype._push=function(e,t,n){return this.tail=this.tail.next=new Iy(e,t,n),this.len+=t,this};function eA(r,e,t){e[t]=r&255}function wEe(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}function tA(r,e){this.len=r,this.next=void 0,this.val=e}tA.prototype=Object.create(Iy.prototype);tA.prototype.fn=wEe;Rt.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new tA((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};Rt.prototype.int32=function(e){return e<0?this._push(rA,10,a5.fromNumber(e)):this.uint32(e)};Rt.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function rA(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}Rt.prototype.uint64=function(e){var t=a5.from(e);return this._push(rA,t.length(),t)};Rt.prototype.int64=Rt.prototype.uint64;Rt.prototype.sint64=function(e){var t=a5.from(e).zzEncode();return this._push(rA,t.length(),t)};Rt.prototype.bool=function(e){return this._push(eA,1,e?1:0)};function ZI(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}Rt.prototype.fixed32=function(e){return this._push(ZI,4,e>>>0)};Rt.prototype.sfixed32=Rt.prototype.fixed32;Rt.prototype.fixed64=function(e){var t=a5.from(e);return this._push(ZI,4,t.lo)._push(ZI,4,t.hi)};Rt.prototype.sfixed64=Rt.prototype.fixed64;Rt.prototype.float=function(e){return this._push(Ms.float.writeFloatLE,4,e)};Rt.prototype.double=function(e){return this._push(Ms.float.writeDoubleLE,8,e)};var EEe=Ms.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]};Rt.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(eA,1,0);if(Ms.isString(e)){var n=Rt.alloc(t=$j.length(e));$j.decode(e,n,0),e=n}return this.uint32(t)._push(EEe,t,e)};Rt.prototype.string=function(e){var t=Hj.length(e);return t?this.uint32(t)._push(Hj.write,t,e):this._push(eA,1,0)};Rt.prototype.fork=function(){return this.states=new gEe(this),this.head=this.tail=new Iy(JI,0,0),this.len=0,this};Rt.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 Iy(JI,0,0),this.len=0),this};Rt.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};Rt.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};Rt._configure=function(r){XI=r,Rt.create=Gj(),XI._configure()}});var Qj=R((vdt,Yj)=>{"use strict";u();Yj.exports=Ia;var jj=nA();(Ia.prototype=Object.create(jj.prototype)).constructor=Ia;var Nl=kl();function Ia(){jj.call(this)}Ia._configure=function(){Ia.alloc=Nl._Buffer_allocUnsafe,Ia.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++]}};Ia.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(Ia.writeBytesBuffer,t,e),this};function bEe(r,e,t){r.length<40?Nl.utf8.write(r,e,t):e.utf8Write?e.utf8Write(r,t):e.write(r,t)}Ia.prototype.string=function(e){var t=Nl.Buffer.byteLength(e);return this.uint32(t),t&&this._push(bEe,t,e),this};Ia._configure()});var oA=R((xdt,tY)=>{"use strict";u();tY.exports=Xr;var Aa=kl(),sA,Jj=Aa.LongBits,_Ee=Aa.utf8;function Do(r,e){return RangeError("index out of range: "+r.pos+" + "+(e||1)+" > "+r.len)}function Xr(r){this.buf=r,this.pos=0,this.len=r.length}var Xj=typeof Uint8Array<"u"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new Xr(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new Xr(e);throw Error("illegal buffer")},eY=function(){return Aa.Buffer?function(t){return(Xr.create=function(i){return Aa.Buffer.isBuffer(i)?new sA(i):Xj(i)})(t)}:Xj};Xr.create=eY();Xr.prototype._slice=Aa.Array.prototype.subarray||Aa.Array.prototype.slice;Xr.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,Do(this,10);return e}}();Xr.prototype.int32=function(){return this.uint32()|0};Xr.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function iA(){var r=new Jj(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 Do(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 Do(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")}Xr.prototype.bool=function(){return this.uint32()!==0};function c5(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}Xr.prototype.fixed32=function(){if(this.pos+4>this.len)throw Do(this,4);return c5(this.buf,this.pos+=4)};Xr.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Do(this,4);return c5(this.buf,this.pos+=4)|0};function Zj(){if(this.pos+8>this.len)throw Do(this,8);return new Jj(c5(this.buf,this.pos+=4),c5(this.buf,this.pos+=4))}Xr.prototype.float=function(){if(this.pos+4>this.len)throw Do(this,4);var e=Aa.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};Xr.prototype.double=function(){if(this.pos+8>this.len)throw Do(this,4);var e=Aa.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};Xr.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Do(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)};Xr.prototype.string=function(){var e=this.bytes();return _Ee.read(e,0,e.length)};Xr.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Do(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Do(this);while(this.buf[this.pos++]&128);return this};Xr.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};Xr._configure=function(r){sA=r,Xr.create=eY(),sA._configure();var e=Aa.Long?"toLong":"toNumber";Aa.merge(Xr.prototype,{int64:function(){return iA.call(this)[e](!1)},uint64:function(){return iA.call(this)[e](!0)},sint64:function(){return iA.call(this).zzDecode()[e](!1)},fixed64:function(){return Zj.call(this)[e](!0)},sfixed64:function(){return Zj.call(this)[e](!1)}})}});var sY=R((Idt,iY)=>{"use strict";u();iY.exports=Nh;var nY=oA();(Nh.prototype=Object.create(nY.prototype)).constructor=Nh;var rY=kl();function Nh(r){nY.call(this,r)}Nh._configure=function(){rY.Buffer&&(Nh.prototype._slice=rY.Buffer.prototype.slice)};Nh.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))};Nh._configure()});var aY=R((Rdt,oY)=>{"use strict";u();oY.exports=Ay;var aA=kl();(Ay.prototype=Object.create(aA.EventEmitter.prototype)).constructor=Ay;function Ay(r,e,t){if(typeof r!="function")throw TypeError("rpcImpl must be a function");aA.EventEmitter.call(this),this.rpcImpl=r,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(t)}Ay.prototype.rpcCall=function r(e,t,n,i,s){if(!i)throw TypeError("request must be specified");var o=this;if(!s)return aA.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}};Ay.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var uY=R(cY=>{"use strict";u();var vEe=cY;vEe.Service=aY()});var fY=R((kdt,lY)=>{"use strict";u();lY.exports={}});var pY=R(dY=>{"use strict";u();var Ii=dY;Ii.build="minimal";Ii.Writer=nA();Ii.BufferWriter=Qj();Ii.Reader=oA();Ii.BufferReader=sY();Ii.util=kl();Ii.rpc=uY();Ii.roots=fY();Ii.configure=hY;function hY(){Ii.util._configure(),Ii.Writer._configure(Ii.BufferWriter),Ii.Reader._configure(Ii.BufferReader)}hY()});var yY=R((Bdt,mY)=>{"use strict";u();mY.exports=pY()});var wY=R((gY,Ry)=>{"use strict";u();(function(r,e){typeof define=="function"&&define.amd?define(["protobufjs/minimal"],e):typeof ld=="function"&&typeof Ry=="object"&&Ry&&Ry.exports&&(Ry.exports=e(yY()))})(gY,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 YY=R((M0t,jY)=>{"use strict";u();function Lr(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)}Lr.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]}};Lr.prototype.get=function(e){return this.peekAt(e)};Lr.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]};Lr.prototype.peekFront=function(){return this.peek()};Lr.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(Lr.prototype,"length",{get:function(){return this.size()}});Lr.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)};Lr.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)};Lr.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}};Lr.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)};Lr.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}};Lr.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}}};Lr.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}}};Lr.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)}};Lr.prototype.clear=function(){this._head=0,this._tail=0};Lr.prototype.isEmpty=function(){return this._head===this._tail};Lr.prototype.toArray=function(){return this._copyArray(!1)};Lr.prototype._fromArray=function(e){for(var t=0;t<e.length;t++)this.push(e[t])};Lr.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};Lr.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};Lr.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1};jY.exports=Lr});var tX=R((ogt,eX)=>{"use strict";u();var N_e=async r=>{for await(let e of r);};eX.exports=N_e});var wZ=R((p5t,gZ)=>{u();gZ.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 xR=R(()=>{u()});var TR=R((Zxt,oee)=>{"use strict";u();var mve=Hd(),yve=(r,e)=>({path:decodeURIComponent(new URL(r).pathname.split("/").pop()||""),content:gve(r,e)});async function*gve(r,e){yield*(await new mve().get(r,e)).iterator()}oee.exports=yve});var uE=R((ZAt,kee)=>{"use strict";u();function $ve(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}kee.exports=$ve});var UR=R((nRt,MR)=>{"use strict";u();var Gve=(r,e)=>Math.floor(Math.random()*(e-r+1)+r),Lee=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Bee=({clearTimeout:r,setTimeout:e,willResolve:t})=>(n,{value:i,signal:s}={})=>{if(s&&s.aborted)return Promise.reject(Lee());let o,a,c,l=r||clearTimeout,f=()=>{l(o),c(Lee())},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},Mee=r=>{let e=Bee({...r,willResolve:!0});return e.reject=Bee({...r,willResolve:!1}),e.range=(t,n,i)=>e(Gve(t,n),i),e},BR=Mee();BR.createWithTimers=Mee;MR.exports=BR;MR.exports.default=BR});var jR=R((jCt,tte)=>{"use strict";u();var $0=new Map,n9e=()=>`${Date.now()}:${Math.floor(Math.random()*1e6)}`;async function i9e(r,e,t){for(;$0.get(t);){try{await r()}catch(n){setTimeout(()=>{throw n},1);break}if(!$0.get(t))break;await new Promise(n=>{let i=setTimeout(n,e);$0.set(t,i)})}}function s9e(r,e,t){t=t||e;let n=n9e(),i=setTimeout(()=>{i9e(r,e,n)},t);return $0.set(n,i),n}function o9e(r){let e=$0.get(r);e&&(clearTimeout(e),$0.delete(r))}tte.exports={setDelayedInterval:s9e,clearDelayedInterval:o9e}});var bg=R((rPt,ate)=>{u();ate.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 ute=R((sPt,cte)=>{u();cte.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 fte=R((aPt,lte)=>{u();var f9e=ute();lte.exports=f9e});var as=R((lPt,hte)=>{u();hte.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 G0=R((dPt,pte)=>{u();var XR=bg(),h9e=fte(),dte=as();pte.exports=class extends XR{constructor(e={}){super(e),this.inMemoryBlockOnConsumed=e.inMemoryBlockOnConsumed||e.inmemoryBlockOnConsumed,this.inMemoryBlockDuration=e.inMemoryBlockDuration||e.inmemoryBlockDuration,this.insuranceLimiter=e.insuranceLimiter,this._inMemoryBlockedKeys=new h9e}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 XR?this.insuranceLimiter[t](s,o,a).then(c=>{n(c)}).catch(c=>{i(c)}):i(e)}get _inmemoryBlockedKeys(){return this._inMemoryBlockedKeys}getInmemoryBlockMsBeforeExpire(e){return this.getInMemoryBlockMsBeforeExpire(e)}get inmemoryBlockOnConsumed(){return this.inMemoryBlockOnConsumed}set inmemoryBlockOnConsumed(e){this.inMemoryBlockOnConsumed=e}get inmemoryBlockDuration(){return this.inMemoryBlockDuration}set inmemoryBlockDuration(e){this.inMemoryBlockDuration=e}get msInmemoryBlockDuration(){return this.inMemoryBlockDuration*1e3}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 XR))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 dte(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 dte(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(e,t,n,i=!1,s={}){throw new Error("You have to implement the method '_upsert'!")}}});var gte=R((mPt,yte)=>{u();var d9e=G0(),p9e=as(),mte="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} ",ZR=class extends d9e{constructor(e){super(e),e.redis?this.client=e.redis:this.client=e.storeClient,this._rejectIfRedisNotReady=!!e.rejectIfRedisNotReady,typeof this.client.defineCommand=="function"&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:mte})}_isRedisReady(){return this._rejectIfRedisNotReady?!(this.client.status&&this.client.status!=="ready"||typeof this.client.isReady=="function"&&!this.client.isReady()):!0}_getRateLimiterRes(e,t,n){let[i,s]=n;Array.isArray(i)&&([,i]=i,[,s]=s);let o=new p9e;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)=>{if(!this._isRedisReady())return o(new Error("Redis connection is not ready"));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(mte,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)=>{if(!this._isRedisReady())return n(new Error("Redis connection is not ready"));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)})})}};yte.exports=ZR});var bte=R((gPt,Ete)=>{u();var m9e=G0(),y9e=as();function wte(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 _g=class extends m9e{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=wte(this.client)}):(this._initCollection(),this._driverVersion=wte(this.client))}get dbName(){return this._dbName}set dbName(e){this._dbName=typeof e>"u"?_g.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 y9e,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)}};Ete.exports=_g});var vte=R((EPt,_te)=>{u();var g9e=G0(),w9e=as(),JR=class extends g9e{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 w9e,[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"))}};_te.exports=JR});var xte=R((_Pt,Ste)=>{u();var E9e=G0(),b9e=as(),eC=class extends E9e{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 b9e,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"))}};Ste.exports=eC});var Tte=R(()=>{u()});var Ate=R((APt,Ite)=>{u();Ite.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 Cte=R((DPt,Rte)=>{u();var _9e=Ate(),tC=as();Rte.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 tC(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 _9e(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 tC(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 tC(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 nC=R((kPt,Pte)=>{u();var v9e=bg(),S9e=Cte(),Dte=as(),rC=class extends v9e{constructor(e={}){super(e),this._memoryStorage=new S9e}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 Dte(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 Dte(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)))}};Pte.exports=rC});var Ute=R((OPt,Mte)=>{u();var kte=Tte(),x9e=Lu(),T9e=bg(),Ote=nC(),I9e=as(),zs="rate_limiter_flexible",Y0=null,Nte=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:zs,keyPrefix:e.keyPrefix,promiseId:e.promiseId,type:t,data:i})},Lte=function(r){setTimeout(()=>{this._initiated?process.send(r):typeof this._promises[r.promiseId]<"u"&&Lte.call(this,r)},30)},W0=function(r,e,t,n,i){let s={channel:zs,keyPrefix:this.keyPrefix,func:r,promiseId:e,data:{key:t,arg:n,opts:i}};this._initiated?process.send(s):Lte.call(this,s)},Bte=function(r,e){if(!e||e.channel!==zs||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=>{Nte(r,e,"resolve",n)}).catch(n=>{Nte(r,e,"reject",n)})},A9e=function(r){if(!r||r.channel!==zs||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 I9e(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]}},R9e=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},j0=function(r,e){let t=process.hrtime(),n=t[0].toString()+t[1].toString();return typeof this._promises[n]<"u"&&(n+=x9e.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},iC=class{constructor(){if(Y0)return Y0;this._rateLimiters={},kte.setMaxListeners(0),kte.on("message",(e,t)=>{t&&t.channel===zs&&t.type==="init"?(typeof this._rateLimiters[t.opts.keyPrefix]>"u"&&(this._rateLimiters[t.opts.keyPrefix]=new Ote(t.opts)),e.send({channel:zs,type:"init",keyPrefix:t.opts.keyPrefix})):Bte.call(this,e,t)}),Y0=this}},sC=class{constructor(e){if(Y0)return Y0;this._rateLimiters={},e.launchBus((t,n)=>{n.on("process:msg",i=>{let s=i.raw;if(s&&s.channel===zs&&s.type==="init")typeof this._rateLimiters[s.opts.keyPrefix]>"u"&&(this._rateLimiters[s.opts.keyPrefix]=new Ote(s.opts)),e.sendDataToProcessId(i.process.pm_id,{data:{},topic:zs,channel:zs,type:"init",keyPrefix:s.opts.keyPrefix},(o,a)=>{o&&console.log(o,a)});else{let o={send:a=>{let c=a;c.topic=zs,typeof c.data>"u"&&(c.data={}),e.sendDataToProcessId(i.process.pm_id,c,(l,f)=>{l&&console.log(l,f)})}};Bte.call(this,o,s)}})}),Y0=this}},oC=class extends T9e{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===zs&&t.type==="init"&&t.keyPrefix===this.keyPrefix?this._initiated=!0:A9e.call(this,t)}),process.send({channel:zs,type:"init",opts:R9e.call(this)}),this._promises={}}consume(e,t=1,n={}){return new Promise((i,s)=>{let o=j0.call(this,i,s);W0.call(this,"consume",o,e,t,n)})}penalty(e,t=1,n={}){return new Promise((i,s)=>{let o=j0.call(this,i,s);W0.call(this,"penalty",o,e,t,n)})}reward(e,t=1,n={}){return new Promise((i,s)=>{let o=j0.call(this,i,s);W0.call(this,"reward",o,e,t,n)})}block(e,t,n={}){return new Promise((i,s)=>{let o=j0.call(this,i,s);W0.call(this,"block",o,e,t,n)})}get(e,t={}){return new Promise((n,i)=>{let s=j0.call(this,n,i);W0.call(this,"get",s,e,t)})}delete(e,t={}){return new Promise((n,i)=>{let s=j0.call(this,n,i);W0.call(this,"delete",s,e,t)})}};Mte.exports={RateLimiterClusterMaster:iC,RateLimiterClusterMasterPM2:sC,RateLimiterCluster:oC}});var Vte=R((BPt,Fte)=>{u();var C9e=G0(),D9e=as(),aC=class extends C9e{constructor(e){super(e),this.client=e.storeClient}_getRateLimiterRes(e,t,n){let i=new D9e;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)})})})}};Fte.exports=aC});var qte=R((FPt,zte)=>{u();var Kte=as();zte.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 Kte(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new Kte(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 Hte=R((zPt,$te)=>{u();var P9e=bg();$te.exports=class{constructor(...e){if(e.length<1)throw new Error("RateLimiterUnion: at least one limiter have to be passed");e.forEach(t=>{if(!(t instanceof P9e))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 Wte=R((HPt,Gte)=>{u();Gte.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 Xte=R((jPt,Qte)=>{u();var jte=Wte(),Yte=4294967295,cC="limiter";Qte.exports=class{constructor(e,t={maxQueueSize:Yte}){this._queueLimiters={KEY_DEFAULT:new TE(e,t)},this._limiterFlexible=e,this._maxQueueSize=t.maxQueueSize}getTokensRemaining(e=cC){return this._queueLimiters[e]?this._queueLimiters[e].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(e,t=cC){return this._queueLimiters[t]||(this._queueLimiters[t]=new TE(this._limiterFlexible,{key:t,maxQueueSize:this._maxQueueSize})),this._queueLimiters[t].removeTokens(e)}};var TE=class{constructor(e,t={maxQueueSize:Yte,key:cC}){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 jte(`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 jte(`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 Jte=R((XPt,Zte)=>{u();var uC=as();Zte.exports=class{constructor(e,t){this._rateLimiter=e,this._burstLimiter=t}_combineRes(e,t){return new uC(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 uC?this._burstLimiter.consume(e,t,n).then(s=>Promise.resolve(this._combineRes(i,s))).catch(s=>s instanceof uC?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 lC=R((JPt,ere)=>{u();var k9e=gte(),N9e=bte(),O9e=vte(),L9e=xte(),{RateLimiterClusterMaster:B9e,RateLimiterClusterMasterPM2:M9e,RateLimiterCluster:U9e}=Ute(),F9e=nC(),V9e=Vte(),K9e=qte(),z9e=Hte(),q9e=Xte(),$9e=Jte(),H9e=as();ere.exports={RateLimiterRedis:k9e,RateLimiterMongo:N9e,RateLimiterMySQL:O9e,RateLimiterPostgres:L9e,RateLimiterMemory:F9e,RateLimiterMemcache:V9e,RateLimiterClusterMaster:B9e,RateLimiterClusterMasterPM2:M9e,RateLimiterCluster:U9e,RLWrapperBlackAndWhite:K9e,RateLimiterUnion:z9e,RateLimiterQueue:q9e,BurstyRateLimiter:$9e,RateLimiterRes:H9e}});var dre=R(xg=>{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}(),xg.ip2long=o,xg.long2ip=a,xg.Netmask=r}).call(xg)});var vC=R((MNt,mre)=>{"use strict";u();var pre="[a-fA-F\\d:]",Wl=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${pre})|(?<=${pre})(?=\\s|$))`:"",Oo="(?: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}",fn="[a-fA-F\\d]{1,4}",NE=`
(?:
(?:${fn}:){7}(?:${fn}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:${fn}:){6}(?:${Oo}|:${fn}|:)| // 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
(?:${fn}:){5}(?::${Oo}|(?::${fn}){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
(?:${fn}:){4}(?:(?::${fn}){0,1}:${Oo}|(?::${fn}){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
(?:${fn}:){3}(?:(?::${fn}){0,2}:${Oo}|(?::${fn}){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
(?:${fn}:){2}(?:(?::${fn}){0,3}:${Oo}|(?::${fn}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:${fn}:){1}(?:(?::${fn}){0,4}:${Oo}|(?::${fn}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::${fn}){0,5}:${Oo}|(?::${fn}){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(),X9e=new RegExp(`(?:^${Oo}$)|(?:^${NE}$)`),Z9e=new RegExp(`^${Oo}$`),J9e=new RegExp(`^${NE}$`),_C=r=>r&&r.exact?X9e:new RegExp(`(?:${Wl(r)}${Oo}${Wl(r)})|(?:${Wl(r)}${NE}${Wl(r)})`,"g");_C.v4=r=>r&&r.exact?Z9e:new RegExp(`${Wl(r)}${Oo}${Wl(r)}`,"g");_C.v6=r=>r&&r.exact?J9e:new RegExp(`${Wl(r)}${NE}${Wl(r)}`,"g");mre.exports=_C});var gre=R((FNt,yre)=>{"use strict";u();var SC=vC(),Q0=r=>SC({exact:!0}).test(r);Q0.v4=r=>SC.v4({exact:!0}).test(r);Q0.v6=r=>SC.v6({exact:!0}).test(r);Q0.version=r=>Q0(r)?Q0.v4(r)?4:6:void 0;yre.exports=Q0});var Ere=R((wre,OE)=>{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],E,v;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(v=m-y,E=":";v--;)E+="0:";return d=d.replace("::",E),d[0]===":"&&(d=d.slice(1)),d[d.length-1]===":"&&(d=d.slice(0,-1)),m=function(){let x=d.split(":"),I=[];for(let T=0;T<x.length;T++)I.push(parseInt(x[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,E;for(;g>0;){if(E=y-g,E<0&&(E=0),d[w]>>E!==m[w]>>E)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,E,v;for(w=3;w>=0;w-=1)if(E=this.octets[w],E in g){if(v=g[E],y&&v!==0)return null;v!==8&&(y=!0),m+=v}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=[],E=0;for(;E<4;)w.push(parseInt(y[E],10)|parseInt(g[E],10)^255),E++;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,E;try{for(m=this.parseCIDR(d),g=m[0].toByteArray(),E=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),w=[],y=0;y<4;)w.push(parseInt(g[y],10)&parseInt(E[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),E=[];for(let v=0;v<w.length;v++)y=w[v],E.push(f(y));return E}();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=[],E;for(E=0;E<=24;E+=8)w.push(g>>E&255);return w}().reverse()}else return(m=d.match(t.twoOctet))?function(){let w=m.slice(1,4),E=[];if(g=f(w[1]),g>16777215||g<0)throw new Error("ipaddr: address outside defined range");return E.push(f(w[0])),E.push(g>>16&255),E.push(g>>8&255),E.push(g&255),E}():(m=d.match(t.threeOctet))?function(){let w=m.slice(1,5),E=[];if(g=f(w[2]),g>65535||g<0)throw new Error("ipaddr: address outside defined range");return E.push(f(w[0])),E.push(f(w[1])),E.push(g>>8&255),E.push(g&255),E}():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,E;for(let v=7;v>=0;v-=1)if(w=this.parts[v],w in g){if(E=g[w],y&&E!==0)return null;E!==16&&(y=!0),m+=E}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,E;for(;E=m.exec(y);)E[0].length>w&&(g=E.index,w=E[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=[],E=0;for(;E<16;)w.push(parseInt(y[E],10)|parseInt(g[E],10)^255),E++;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,E;try{for(m=this.parseCIDR(d),g=m[0].toByteArray(),E=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),w=[],y=0;y<16;)w.push(parseInt(g[y],10)&parseInt(E[y],10)),y++;return new this(w)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},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,E,v;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))&&(v=g[6]||"",m=c(g[1].slice(0,-1)+v,6),m.parts)){for(E=[parseInt(g[2]),parseInt(g[3]),parseInt(g[4]),parseInt(g[5])],y=0;y<E.length;y++)if(w=E[y],!(0<=w&&w<=255))return null;return m.parts.push(E[0]<<8|E[1]),m.parts.push(E[2]<<8|E[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,E,v;y==null&&(y="unicast");for(w in m)if(Object.prototype.hasOwnProperty.call(m,w)){for(E=m[w],E[0]&&!(E[0]instanceof Array)&&(E=[E]),g=0;g<E.length;g++)if(v=E[g],d.kind()===v[0].kind()&&d.match.apply(d,v))return w}return y},typeof OE<"u"&&OE.exports?OE.exports=p:r.ipaddr=p})(wre)});var Sre=R(Tg=>{"use strict";u();var vre=Tg&&Tg.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Tg,"__esModule",{value:!0});var eSe=dre(),tSe=vre(vC()),rSe=vre(gre()),bre=Ere(),nSe=["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"],iSe=nSe.map(r=>new eSe.Netmask(r));function sSe(r){for(let e of iSe)if(e.contains(r))return!0;return!1}function _re(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)}Tg.default=r=>{if((0,bre.isValid)(r)){let e=(0,bre.parse)(r);if(e.kind()==="ipv4")return sSe(e.toNormalizedString());if(e.kind()==="ipv6")return _re(r)}else if((0,rSe.default)(r)&&tSe.default.v6().test(r))return _re(r)}});var LE=R(($Nt,xre)=>{"use strict";u();xre.exports=Sre().default});var Rre=R((gOt,Are)=>{"use strict";u();function cSe(r){return r>=55296&&r<=56319}function uSe(r){return r>=56320&&r<=57343}Are.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],cSe(o)&&uSe(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 Dre=R((EOt,Cre)=>{"use strict";u();function lSe(r){return r>=55296&&r<=56319}function fSe(r){return r>=56320&&r<=57343}Cre.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),fSe(i)?s!=null&&lSe(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 kre=R((_Ot,Pre)=>{"use strict";u();var hSe=Rre(),dSe=Dre();Pre.exports=hSe.bind(null,dSe)});var Lre=R((SOt,Ore)=>{"use strict";u();var pSe=kre(),mSe=/[\/\?<>\\:\*\|"]/g,ySe=/[\x00-\x1f\x80-\x9f]/g,gSe=/^\.+$/,wSe=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,ESe=/[\. ]+$/;function Nre(r,e){if(typeof r!="string")throw new Error("Input must be string");var t=r.replace(mSe,e).replace(ySe,e).replace(gSe,e).replace(wSe,e).replace(ESe,e);return pSe(t,255)}Ore.exports=function(r,e){var t=e&&e.replacement||"",n=Nre(r,t);return t===""?n:Nre(n,"")}});var Fre=R((TOt,Ure)=>{u();var Z0=ut();Nu();er();var fe=Z0.asn1,J0=Ure.exports=Z0.pkcs7asn1=Z0.pkcs7asn1||{};Z0.pkcs7=Z0.pkcs7||{};Z0.pkcs7.asn1=J0;var Bre={name:"ContentInfo",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:fe.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};J0.contentInfoValidator=Bre;var Mre={name:"EncryptedContentInfo",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:fe.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:fe.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};J0.envelopedDataValidator={name:"EnvelopedData",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(Mre)};J0.encryptedDataValidator={name:"EncryptedData",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1,capture:"version"}].concat(Mre)};var bSe={name:"SignerInfo",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:fe.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:fe.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:fe.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};J0.signedDataValidator={name:"SignedData",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},Bre,{name:"SignedData.Certificates",tagClass:fe.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:fe.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SET,capture:"signerInfos",optional:!0,value:[bSe]}]};J0.recipientInfoValidator={name:"RecipientInfo",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:fe.Class.UNIVERSAL,type:fe.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:fe.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:fe.Class.UNIVERSAL,type:fe.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var Kre=R((AOt,Vre)=>{u();var Yh=ut();er();Yh.mgf=Yh.mgf||{};var _Se=Vre.exports=Yh.mgf.mgf1=Yh.mgf1=Yh.mgf1||{};_Se.create=function(r){var e={generate:function(t,n){for(var i=new Yh.util.ByteBuffer,s=Math.ceil(n/r.digestLength),o=0;o<s;o++){var a=new Yh.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 qre=R((COt,zre)=>{u();var FE=ut();Kre();zre.exports=FE.mgf=FE.mgf||{};FE.mgf.mgf1=FE.mgf1});var Hre=R((POt,$re)=>{u();var Qh=ut();vf();er();var vSe=$re.exports=Qh.pss=Qh.pss||{};vSe.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=Qh.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||Qh.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 Qh.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 Qh.util.ByteBuffer;w.fillWithByte(0,p-s-n-2),w.putByte(1),w.putBytes(m);var E=w.getBytes(),v=p-n-1,x=t.generate(g,v),I="";for(f=0;f<v;f++)I+=String.fromCharCode(E.charCodeAt(f)^x.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 E=t.generate(g,m),v="";for(h=0;h<m;h++)v+=String.fromCharCode(y.charCodeAt(h)^E.charCodeAt(h));v=String.fromCharCode(v.charCodeAt(0)&~w)+v.substr(1);var x=d-n-s-2;for(h=0;h<x;h++)if(v.charCodeAt(h)!==0)throw new Error("Leftmost octets not zero as expected");if(v.charCodeAt(x)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var I=v.substr(-s),T=new Qh.util.ByteBuffer;T.fillWithByte(0,8),T.putBytes(c),T.putBytes(I),e.start(),e.update(T.getBytes());var S=e.digest().getBytes();return g===S},a}});var IC=R((NOt,Qre)=>{u();var ke=ut();Jd();Nu();W4();Ou();qre();Qd();X4();Hre();pm();er();var b=ke.asn1,re=Qre.exports=ke.pki=ke.pki||{},xt=re.oids,Ur={};Ur.CN=xt.commonName;Ur.commonName="CN";Ur.C=xt.countryName;Ur.countryName="C";Ur.L=xt.localityName;Ur.localityName="L";Ur.ST=xt.stateOrProvinceName;Ur.stateOrProvinceName="ST";Ur.O=xt.organizationName;Ur.organizationName="O";Ur.OU=xt.organizationalUnitName;Ur.organizationalUnitName="OU";Ur.E=xt.emailAddress;Ur.emailAddress="E";var Wre=ke.pki.rsa.publicKeyValidator,SSe={name:"Certificate",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:b.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:b.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:b.Class.UNIVERSAL,type:b.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:b.Class.UNIVERSAL,type:b.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:b.Class.UNIVERSAL,type:b.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:b.Class.UNIVERSAL,type:b.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},Wre,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:b.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:b.Class.UNIVERSAL,type:b.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:b.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:b.Class.UNIVERSAL,type:b.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:b.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:b.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:b.Class.UNIVERSAL,type:b.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},xSe={name:"rsapss",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:b.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:b.Class.UNIVERSAL,type:b.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:b.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:b.Class.UNIVERSAL,type:b.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:b.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:b.Class.UNIVERSAL,type:b.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:b.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:b.Class.UNIVERSAL,type:b.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},TSe={name:"CertificationRequestInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},Wre,{name:"CertificationRequestInfo.attributes",tagClass:b.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:b.Class.UNIVERSAL,type:b.Type.SET,constructed:!0}]}]}]},ISe={name:"CertificationRequest",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[TSe,{name:"CertificationRequest.signatureAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:b.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:b.Class.UNIVERSAL,type:b.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};re.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=b.derToOid(i.value[0].value),s.value=i.value[1].value,s.valueTagClass=i.value[1].type,s.type in xt&&(s.name=xt[s.type],s.name in Ur&&(s.shortName=Ur[s.name])),e&&(e.update(s.type),e.update(s.value)),t.push(s)}return t};re.CRIAttributesAsArray=function(r){for(var e=[],t=0;t<r.length;++t)for(var n=r[t],i=b.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 xt&&(a.name=xt[a.type],a.name in Ur&&(a.shortName=Ur[a.name])),a.type===xt.extensionRequest){a.extensions=[];for(var c=0;c<a.value.length;++c)a.extensions.push(re.certificateExtensionFromAsn1(a.value[c]))}e.push(a)}return e};function jl(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 VE=function(r,e,t){var n={};if(r!==xt["RSASSA-PSS"])return n;t&&(n={hash:{algorithmOid:xt.sha1},mgf:{algorithmOid:xt.mgf1,hash:{algorithmOid:xt.sha1}},saltLength:20});var i={},s=[];if(!b.validate(e,xSe,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=b.derToOid(i.hashOid)),i.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=b.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=b.derToOid(i.maskGenHashOid)),i.saltLength!==void 0&&(n.saltLength=i.saltLength.charCodeAt(0)),n},KE=function(r){switch(xt[r.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return ke.md.sha1.create();case"md5WithRSAEncryption":return ke.md.md5.create();case"sha256WithRSAEncryption":return ke.md.sha256.create();case"sha384WithRSAEncryption":return ke.md.sha384.create();case"sha512WithRSAEncryption":return ke.md.sha512.create();case"RSASSA-PSS":return ke.md.sha256.create();default:var e=new Error("Could not compute "+r.type+" digest. Unknown signature OID.");throw e.signatureOid=r.signatureOid,e}},jre=function(r){var e=r.certificate,t;switch(e.signatureOid){case xt.sha1WithRSAEncryption:case xt.sha1WithRSASignature:break;case xt["RSASSA-PSS"]:var n,i;if(n=xt[e.signatureParameters.mgf.hash.algorithmOid],n===void 0||ke.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=xt[e.signatureParameters.mgf.algorithmOid],i===void 0||ke.mgf[i]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=e.signatureParameters.mgf.algorithmOid,s.name=i,s}if(i=ke.mgf[i].create(ke.md[n].create()),n=xt[e.signatureParameters.hash.algorithmOid],n===void 0||ke.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=ke.pss.create(ke.md[n].create(),i,e.signatureParameters.saltLength);break}return e.publicKey.verify(r.md.digest().getBytes(),r.signature,t)};re.certificateFromPem=function(r,e,t){var n=ke.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=b.fromDer(n.body,t);return re.certificateFromAsn1(s,e)};re.certificateToPem=function(r,e){var t={type:"CERTIFICATE",body:b.toDer(re.certificateToAsn1(r)).getBytes()};return ke.pem.encode(t,{maxline:e})};re.publicKeyFromPem=function(r){var e=ke.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=b.fromDer(e.body);return re.publicKeyFromAsn1(n)};re.publicKeyToPem=function(r,e){var t={type:"PUBLIC KEY",body:b.toDer(re.publicKeyToAsn1(r)).getBytes()};return ke.pem.encode(t,{maxline:e})};re.publicKeyToRSAPublicKeyPem=function(r,e){var t={type:"RSA PUBLIC KEY",body:b.toDer(re.publicKeyToRSAPublicKey(r)).getBytes()};return ke.pem.encode(t,{maxline:e})};re.getPublicKeyFingerprint=function(r,e){e=e||{};var t=e.md||ke.md.sha1.create(),n=e.type||"RSAPublicKey",i;switch(n){case"RSAPublicKey":i=b.toDer(re.publicKeyToRSAPublicKey(r)).getBytes();break;case"SubjectPublicKeyInfo":i=b.toDer(re.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};re.certificationRequestFromPem=function(r,e,t){var n=ke.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=b.fromDer(n.body,t);return re.certificationRequestFromAsn1(s,e)};re.certificationRequestToPem=function(r,e){var t={type:"CERTIFICATE REQUEST",body:b.toDer(re.certificationRequestToAsn1(r)).getBytes()};return ke.pem.encode(t,{maxline:e})};re.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 jl(r.issuer,e)},r.issuer.addField=function(e){Hs([e]),r.issuer.attributes.push(e)},r.issuer.attributes=[],r.issuer.hash=null,r.subject={},r.subject.getField=function(e){return jl(r.subject,e)},r.subject.addField=function(e){Hs([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){Hs(e),r.subject.attributes=e,delete r.subject.uniqueId,t&&(r.subject.uniqueId=t),r.subject.hash=null},r.setIssuer=function(e,t){Hs(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)Yre(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||ke.md.sha1.create();var n=xt[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=re.getTBSCertificate(r);var s=b.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=KE({signatureOid:e.signatureOid,type:"certificate"});var a=e.tbsCertificate||re.getTBSCertificate(e),c=b.toDer(a);o.update(c.getBytes())}return o!==null&&(t=jre({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 re.getPublicKeyFingerprint(r.publicKey,{type:"RSAPublicKey"})},r.verifySubjectKeyIdentifier=function(){for(var e=xt.subjectKeyIdentifier,t=0;t<r.extensions.length;++t){var n=r.extensions[t];if(n.id===e){var i=r.generateSubjectKeyIdentifier().getBytes();return ke.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},r};re.certificateFromAsn1=function(r,e){var t={},n=[];if(!b.validate(r,SSe,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=b.derToOid(t.publicKeyOid);if(s!==re.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=re.createCertificate();o.version=t.certVersion?t.certVersion.charCodeAt(0):0;var a=ke.util.createBuffer(t.certSerialNumber);o.serialNumber=a.toHex(),o.signatureOid=ke.asn1.derToOid(t.certSignatureOid),o.signatureParameters=VE(o.signatureOid,t.certSignatureParams,!0),o.siginfo.algorithmOid=ke.asn1.derToOid(t.certinfoSignatureOid),o.siginfo.parameters=VE(o.siginfo.algorithmOid,t.certinfoSignatureParams,!1),o.signature=t.certSignature;var c=[];if(t.certValidity1UTCTime!==void 0&&c.push(b.utcTimeToDate(t.certValidity1UTCTime)),t.certValidity2GeneralizedTime!==void 0&&c.push(b.generalizedTimeToDate(t.certValidity2GeneralizedTime)),t.certValidity3UTCTime!==void 0&&c.push(b.utcTimeToDate(t.certValidity3UTCTime)),t.certValidity4GeneralizedTime!==void 0&&c.push(b.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=KE({signatureOid:o.signatureOid,type:"certificate"});var l=b.toDer(o.tbsCertificate);o.md.update(l.getBytes())}var f=ke.md.sha1.create(),h=b.toDer(t.certIssuer);f.update(h.getBytes()),o.issuer.getField=function(m){return jl(o.issuer,m)},o.issuer.addField=function(m){Hs([m]),o.issuer.attributes.push(m)},o.issuer.attributes=re.RDNAttributesAsArray(t.certIssuer),t.certIssuerUniqueId&&(o.issuer.uniqueId=t.certIssuerUniqueId),o.issuer.hash=f.digest().toHex();var p=ke.md.sha1.create(),d=b.toDer(t.certSubject);return p.update(d.getBytes()),o.subject.getField=function(m){return jl(o.subject,m)},o.subject.addField=function(m){Hs([m]),o.subject.attributes.push(m)},o.subject.attributes=re.RDNAttributesAsArray(t.certSubject),t.certSubjectUniqueId&&(o.subject.uniqueId=t.certSubjectUniqueId),o.subject.hash=p.digest().toHex(),t.certExtensions?o.extensions=re.certificateExtensionsFromAsn1(t.certExtensions):o.extensions=[],o.publicKey=re.publicKeyFromAsn1(t.subjectPublicKeyInfo),o};re.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(re.certificateExtensionFromAsn1(n.value[i]));return e};re.certificateExtensionFromAsn1=function(r){var e={};if(e.id=b.derToOid(r.value[0].value),e.critical=!1,r.value[1].type===b.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 xt){if(e.name=xt[e.id],e.name==="keyUsage"){var t=b.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=b.fromDer(e.value);t.value.length>0&&t.value[0].type===b.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===b.Type.INTEGER?s=t.value[0].value:t.value.length>1&&(s=t.value[1].value),s!==null&&(e.pathLenConstraint=b.derToInteger(s))}else if(e.name==="extKeyUsage")for(var t=b.fromDer(e.value),o=0;o<t.value.length;++o){var a=b.derToOid(t.value[o].value);a in xt?e[xt[a]]=!0:e[a]=!0}else if(e.name==="nsCertType"){var t=b.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=b.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=ke.util.bytesToIP(c.value);break;case 8:f.oid=b.derToOid(c.value);break;default:}}}else if(e.name==="subjectKeyIdentifier"){var t=b.fromDer(e.value);e.subjectKeyIdentifier=ke.util.bytesToHex(t.value)}}return e};re.certificationRequestFromAsn1=function(r,e){var t={},n=[];if(!b.validate(r,ISe,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=b.derToOid(t.publicKeyOid);if(s!==re.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=re.createCertificationRequest();if(o.version=t.csrVersion?t.csrVersion.charCodeAt(0):0,o.signatureOid=ke.asn1.derToOid(t.csrSignatureOid),o.signatureParameters=VE(o.signatureOid,t.csrSignatureParams,!0),o.siginfo.algorithmOid=ke.asn1.derToOid(t.csrSignatureOid),o.siginfo.parameters=VE(o.siginfo.algorithmOid,t.csrSignatureParams,!1),o.signature=t.csrSignature,o.certificationRequestInfo=t.certificationRequestInfo,e){o.md=KE({signatureOid:o.signatureOid,type:"certification request"});var a=b.toDer(o.certificationRequestInfo);o.md.update(a.getBytes())}var c=ke.md.sha1.create();return o.subject.getField=function(l){return jl(o.subject,l)},o.subject.addField=function(l){Hs([l]),o.subject.attributes.push(l)},o.subject.attributes=re.RDNAttributesAsArray(t.certificationRequestInfoSubject,c),o.subject.hash=c.digest().toHex(),o.publicKey=re.publicKeyFromAsn1(t.subjectPublicKeyInfo),o.getAttribute=function(l){return jl(o,l)},o.addAttribute=function(l){Hs([l]),o.attributes.push(l)},o.attributes=re.CRIAttributesAsArray(t.certificationRequestInfoAttributes||[]),o};re.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 jl(r.subject,e)},r.subject.addField=function(e){Hs([e]),r.subject.attributes.push(e)},r.subject.attributes=[],r.subject.hash=null,r.publicKey=null,r.attributes=[],r.getAttribute=function(e){return jl(r,e)},r.addAttribute=function(e){Hs([e]),r.attributes.push(e)},r.md=null,r.setSubject=function(e){Hs(e),r.subject.attributes=e,r.subject.hash=null},r.setAttributes=function(e){Hs(e),r.attributes=e},r.sign=function(e,t){r.md=t||ke.md.sha1.create();var n=xt[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=re.getCertificationRequestInfo(r);var s=b.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=KE({signatureOid:r.signatureOid,type:"certification request"});var n=r.certificationRequestInfo||re.getCertificationRequestInfo(r),i=b.toDer(n);t.update(i.getBytes())}return t!==null&&(e=jre({certificate:r,md:t,signature:r.signature})),e},r};function e1(r){for(var e=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]),t,n,i=r.attributes,s=0;s<i.length;++s){t=i[s];var o=t.value,a=b.Type.PRINTABLESTRING;"valueTagClass"in t&&(a=t.valueTagClass,a===b.Type.UTF8&&(o=ke.util.encodeUtf8(o))),n=b.create(b.Class.UNIVERSAL,b.Type.SET,!0,[b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(t.type).getBytes()),b.create(b.Class.UNIVERSAL,a,!1,o)])]),e.value.push(n)}return e}function Hs(r){for(var e,t=0;t<r.length;++t){if(e=r[t],typeof e.name>"u"&&(e.type&&e.type in re.oids?e.name=re.oids[e.type]:e.shortName&&e.shortName in Ur&&(e.name=re.oids[Ur[e.shortName]])),typeof e.type>"u")if(e.name&&e.name in re.oids)e.type=re.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 Ur&&(e.shortName=Ur[e.name]),e.type===xt.extensionRequest&&(e.valueConstructed=!0,e.valueTagClass=b.Type.SEQUENCE,!e.value&&e.extensions)){e.value=[];for(var i=0;i<e.extensions.length;++i)e.value.push(re.certificateExtensionToAsn1(Yre(e.extensions[i])))}if(typeof e.value>"u"){var n=new Error("Attribute value not specified.");throw n.attribute=e,n}}}function Yre(r,e){if(e=e||{},typeof r.name>"u"&&r.id&&r.id in re.oids&&(r.name=re.oids[r.id]),typeof r.id>"u")if(r.name&&r.name in re.oids)r.id=re.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=b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,o)}else if(r.name==="basicConstraints")r.value=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]),r.cA&&r.value.value.push(b.create(b.Class.UNIVERSAL,b.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in r&&r.value.value.push(b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,b.integerToDer(r.pathLenConstraint).getBytes()));else if(r.name==="extKeyUsage"){r.value=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]);var a=r.value.value;for(var c in r)r[c]===!0&&(c in xt?a.push(b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(xt[c]).getBytes())):c.indexOf(".")!==-1&&a.push(b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.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=b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,o)}else if(r.name==="subjectAltName"||r.name==="issuerAltName"){r.value=b.create(b.Class.UNIVERSAL,b.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=ke.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=b.oidToDer(b.oidToDer(l.oid)):o=b.oidToDer(o));r.value.value.push(b.create(b.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=b.create(b.Class.UNIVERSAL,b.Type.IA5STRING,!1,r.comment)}else if(r.name==="subjectKeyIdentifier"&&e.cert){var h=e.cert.generateSubjectKeyIdentifier();r.subjectKeyIdentifier=h.toHex(),r.value=b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,h.getBytes())}else if(r.name==="authorityKeyIdentifier"&&e.cert){r.value=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]);var a=r.value.value;if(r.keyIdentifier){var p=r.keyIdentifier===!0?e.cert.generateSubjectKeyIdentifier().getBytes():r.keyIdentifier;a.push(b.create(b.Class.CONTEXT_SPECIFIC,0,!1,p))}if(r.authorityCertIssuer){var d=[b.create(b.Class.CONTEXT_SPECIFIC,4,!0,[e1(r.authorityCertIssuer===!0?e.cert.issuer:r.authorityCertIssuer)])];a.push(b.create(b.Class.CONTEXT_SPECIFIC,1,!0,d))}if(r.serialNumber){var m=ke.util.hexToBytes(r.serialNumber===!0?e.cert.serialNumber:r.serialNumber);a.push(b.create(b.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if(r.name==="cRLDistributionPoints"){r.value=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]);for(var a=r.value.value,y=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]),g=b.create(b.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=ke.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=b.oidToDer(b.oidToDer(l.oid)):o=b.oidToDer(o));g.value.push(b.create(b.Class.CONTEXT_SPECIFIC,l.type,!1,o))}y.value.push(b.create(b.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 TC(r,e){switch(r){case xt["RSASSA-PSS"]:var t=[];return e.hash.algorithmOid!==void 0&&t.push(b.create(b.Class.CONTEXT_SPECIFIC,0,!0,[b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(e.hash.algorithmOid).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,"")])])),e.mgf.algorithmOid!==void 0&&t.push(b.create(b.Class.CONTEXT_SPECIFIC,1,!0,[b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(e.mgf.algorithmOid).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(e.mgf.hash.algorithmOid).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,"")])])])),e.saltLength!==void 0&&t.push(b.create(b.Class.CONTEXT_SPECIFIC,2,!0,[b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,b.integerToDer(e.saltLength).getBytes())])),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,t);default:return b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,"")}}function ASe(r){var e=b.create(b.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=b.Type.UTF8;"valueTagClass"in i&&(o=i.valueTagClass),o===b.Type.UTF8&&(s=ke.util.encodeUtf8(s));var a=!1;"valueConstructed"in i&&(a=i.valueConstructed);var c=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(i.type).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.SET,!0,[b.create(b.Class.UNIVERSAL,o,a,s)])]);e.value.push(c)}return e}var RSe=new Date("1950-01-01T00:00:00Z"),CSe=new Date("2050-01-01T00:00:00Z");function Gre(r){return r>=RSe&&r<CSe?b.create(b.Class.UNIVERSAL,b.Type.UTCTIME,!1,b.dateToUtcTime(r)):b.create(b.Class.UNIVERSAL,b.Type.GENERALIZEDTIME,!1,b.dateToGeneralizedTime(r))}re.getTBSCertificate=function(r){var e=Gre(r.validity.notBefore),t=Gre(r.validity.notAfter),n=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.CONTEXT_SPECIFIC,0,!0,[b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,b.integerToDer(r.version).getBytes())]),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,ke.util.hexToBytes(r.serialNumber)),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(r.siginfo.algorithmOid).getBytes()),TC(r.siginfo.algorithmOid,r.siginfo.parameters)]),e1(r.issuer),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[e,t]),e1(r.subject),re.publicKeyToAsn1(r.publicKey)]);return r.issuer.uniqueId&&n.value.push(b.create(b.Class.CONTEXT_SPECIFIC,1,!0,[b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,String.fromCharCode(0)+r.issuer.uniqueId)])),r.subject.uniqueId&&n.value.push(b.create(b.Class.CONTEXT_SPECIFIC,2,!0,[b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,String.fromCharCode(0)+r.subject.uniqueId)])),r.extensions.length>0&&n.value.push(re.certificateExtensionsToAsn1(r.extensions)),n};re.getCertificationRequestInfo=function(r){var e=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,b.integerToDer(r.version).getBytes()),e1(r.subject),re.publicKeyToAsn1(r.publicKey),ASe(r)]);return e};re.distinguishedNameToAsn1=function(r){return e1(r)};re.certificateToAsn1=function(r){var e=r.tbsCertificate||re.getTBSCertificate(r);return b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[e,b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(r.signatureOid).getBytes()),TC(r.signatureOid,r.signatureParameters)]),b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,String.fromCharCode(0)+r.signature)])};re.certificateExtensionsToAsn1=function(r){var e=b.create(b.Class.CONTEXT_SPECIFIC,3,!0,[]),t=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]);e.value.push(t);for(var n=0;n<r.length;++n)t.value.push(re.certificateExtensionToAsn1(r[n]));return e};re.certificateExtensionToAsn1=function(r){var e=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]);e.value.push(b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(r.id).getBytes())),r.critical&&e.value.push(b.create(b.Class.UNIVERSAL,b.Type.BOOLEAN,!1,String.fromCharCode(255)));var t=r.value;return typeof r.value!="string"&&(t=b.toDer(t).getBytes()),e.value.push(b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,t)),e};re.certificationRequestToAsn1=function(r){var e=r.certificationRequestInfo||re.getCertificationRequestInfo(r);return b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[e,b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(r.signatureOid).getBytes()),TC(r.signatureOid,r.signatureParameters)]),b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,String.fromCharCode(0)+r.signature)])};re.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=ke.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))if(o.subject.hash in e.certs){var a=e.certs[o.subject.hash];ke.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=ke.pki.certificateFromPem(o));var a=t(o.subject);if(!a)return!1;ke.util.isArray(a)||(a=[a]);for(var c=b.toDer(re.certificateToAsn1(o)).getBytes(),l=0;l<a.length;++l){var f=b.toDer(re.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(!ke.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=ke.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))return null;var c=t(o.subject);if(!ke.util.isArray(c))return a=e.certs[o.subject.hash],delete e.certs[o.subject.hash],a;for(var l=b.toDer(re.certificateToAsn1(o)).getBytes(),f=0;f<c.length;++f){var h=b.toDer(re.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=ke.md.sha1.create();o.attributes=re.RDNAttributesAsArray(e1(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};re.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"};re.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:re.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;ke.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:re.certificateError.bad_certificate})}o===null&&(!l||f)&&!r.hasCertificate(c)&&(o={message:"Certificate is not trusted.",error:re.certificateError.unknown_ca})}if(o===null&&l&&!c.isIssuer(l)&&(o={message:"Certificate issuer is invalid.",error:re.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:re.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:re.certificateError.bad_certificate}),o===null&&g!==null&&!g.cA&&(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:re.certificateError.bad_certificate}),o===null&&w!==null&&"pathLenConstraint"in g){var E=a-1;E>g.pathLenConstraint&&(o={message:"Certificate basicConstraints pathLenConstraint violated.",error:re.certificateError.bad_certificate})}}var v=o===null?!0:o.error,x=t.verify?t.verify(v,a,n):v;if(x===!0)o=null;else throw v===!0&&(o={message:"The application rejected the certificate.",error:re.certificateError.bad_certificate}),(x||x===0)&&(typeof x=="object"&&!ke.util.isArray(x)?(x.message&&(o.message=x.message),x.error&&(o.error=x.error)):typeof x=="string"&&(o.error=x)),o;s=!1,++a}while(e.length>0);return!0}});var Jre=R((LOt,Zre)=>{u();var se=ut();Jd();Nu();W4();Qd();X4();Fre();vf();er();IC();var k=se.asn1,fi=Zre.exports=se.pkcs7=se.pkcs7||{};fi.messageFromPem=function(r){var e=se.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=k.fromDer(e.body);return fi.messageFromAsn1(n)};fi.messageToPem=function(r,e){var t={type:"PKCS7",body:k.toDer(r.toAsn1()).getBytes()};return se.pem.encode(t,{maxline:e})};fi.messageFromAsn1=function(r){var e={},t=[];if(!k.validate(r,fi.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=k.derToOid(e.contentType),s;switch(i){case se.pki.oids.envelopedData:s=fi.createEnvelopedData();break;case se.pki.oids.encryptedData:s=fi.createEncryptedData();break;case se.pki.oids.signedData:s=fi.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};fi.createSignedData=function(){var r=null;return r={type:se.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(RC(r,n,fi.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(se.pki.certificateFromAsn1(i[s]))},toAsn1:function(){r.contentInfo||r.sign();for(var n=[],i=0;i<r.certificates.length;++i)n.push(se.pki.certificateToAsn1(r.certificates[i]));var s=[],o=k.create(k.Class.CONTEXT_SPECIFIC,0,!0,[k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.INTEGER,!1,k.integerToDer(r.version).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.SET,!0,r.digestAlgorithmIdentifiers),r.contentInfo])]);return n.length>0&&o.value[0].value.push(k.create(k.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&o.value[0].value.push(k.create(k.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(k.create(k.Class.UNIVERSAL,k.Type.SET,!0,r.signerInfos)),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.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=se.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=se.pki.privateKeyFromPem(a));var c=n.digestAlgorithm||se.pki.oids.sha1;switch(c){case se.pki.oids.sha1:case se.pki.oids.sha256:case se.pki.oids.sha384:case se.pki.oids.sha512:case se.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===se.pki.oids.contentType){if(f=!0,h)break;continue}if(!h&&d.type===se.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:se.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:l,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof r.content!="object"||r.contentInfo===null)&&(r.contentInfo=k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(se.pki.oids.data).getBytes())]),"content"in r)){var i;r.content instanceof se.util.ByteBuffer?i=r.content.bytes():typeof r.content=="string"&&(i=se.util.encodeUtf8(r.content)),n.detached?r.detachedContent=k.create(k.Class.UNIVERSAL,k.Type.OCTETSTRING,!1,i):r.contentInfo.value.push(k.create(k.Class.CONTEXT_SPECIFIC,0,!0,[k.create(k.Class.UNIVERSAL,k.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=se.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]=se.md[se.pki.oids[o]].create()),s.authenticatedAttributes.length===0?s.md=n[o]:s.md=se.md[se.pki.oids[o]].create()}r.digestAlgorithmIdentifiers=[];for(var o in n)r.digestAlgorithmIdentifiers.push(k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(o).getBytes()),k.create(k.Class.UNIVERSAL,k.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=k.derToOid(r.contentInfo.value[0].value),o=k.toDer(i);o.getByte(),k.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!==se.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=k.create(k.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var h=k.create(k.Class.UNIVERSAL,k.Type.SET,!0,[]),p=0;p<f.authenticatedAttributes.length;++p){var d=f.authenticatedAttributes[p];d.type===se.pki.oids.messageDigest?d.value=n[f.digestAlgorithm].digest():d.type===se.pki.oids.signingTime&&(d.value||(d.value=c)),h.value.push(AC(d)),f.authenticatedAttributesAsn1.value.push(AC(d))}o=k.toDer(h).getBytes(),f.md.start().update(o)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}r.signerInfos=LSe(r.signers)}};fi.createEncryptedData=function(){var r=null;return r={type:se.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:se.pki.oids["aes256-CBC"]},fromAsn1:function(e){RC(r,e,fi.asn1.encryptedDataValidator)},decrypt:function(e){e!==void 0&&(r.encryptedContent.key=e),Xre(r)}},r};fi.createEnvelopedData=function(){var r=null;return r={type:se.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:se.pki.oids["aes256-CBC"]},fromAsn1:function(e){var t=RC(r,e,fi.asn1.envelopedDataValidator);r.recipients=kSe(t.recipientInfos.value)},toAsn1:function(){return k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.type).getBytes()),k.create(k.Class.CONTEXT_SPECIFIC,0,!0,[k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.INTEGER,!1,k.integerToDer(r.version).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.SET,!0,NSe(r.recipients)),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,BSe(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 se.pki.oids.rsaEncryption:case se.pki.oids.desCBC:var n=t.decrypt(e.encryptedContent.content);r.encryptedContent.key=se.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+e.encryptedContent.algorithm)}Xre(r)},addRecipient:function(e){r.recipients.push({version:0,issuer:e.issuer.attributes,serialNumber:e.serialNumber,encryptedContent:{algorithm:se.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 se.pki.oids["aes128-CBC"]:n=16,i=16,s=se.aes.createEncryptionCipher;break;case se.pki.oids["aes192-CBC"]:n=24,i=16,s=se.aes.createEncryptionCipher;break;case se.pki.oids["aes256-CBC"]:n=32,i=16,s=se.aes.createEncryptionCipher;break;case se.pki.oids["des-EDE3-CBC"]:n=24,i=8,s=se.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+t)}if(e===void 0)e=se.util.createBuffer(se.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=se.util.createBuffer(se.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 se.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 DSe(r){var e={},t=[];if(!k.validate(r,fi.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:se.pki.RDNAttributesAsArray(e.issuer),serialNumber:se.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:k.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}}function PSe(r){return k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.INTEGER,!1,k.integerToDer(r.version).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[se.pki.distinguishedNameToAsn1({attributes:r.issuer}),k.create(k.Class.UNIVERSAL,k.Type.INTEGER,!1,se.util.hexToBytes(r.serialNumber))]),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.encryptedContent.algorithm).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.NULL,!1,"")]),k.create(k.Class.UNIVERSAL,k.Type.OCTETSTRING,!1,r.encryptedContent.content)])}function kSe(r){for(var e=[],t=0;t<r.length;++t)e.push(DSe(r[t]));return e}function NSe(r){for(var e=[],t=0;t<r.length;++t)e.push(PSe(r[t]));return e}function OSe(r){var e=k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.INTEGER,!1,k.integerToDer(r.version).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[se.pki.distinguishedNameToAsn1({attributes:r.issuer}),k.create(k.Class.UNIVERSAL,k.Type.INTEGER,!1,se.util.hexToBytes(r.serialNumber))]),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.digestAlgorithm).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.NULL,!1,"")])]);if(r.authenticatedAttributesAsn1&&e.value.push(r.authenticatedAttributesAsn1),e.value.push(k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.signatureAlgorithm).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.NULL,!1,"")])),e.value.push(k.create(k.Class.UNIVERSAL,k.Type.OCTETSTRING,!1,r.signature)),r.unauthenticatedAttributes.length>0){for(var t=k.create(k.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<r.unauthenticatedAttributes.length;++n){var i=r.unauthenticatedAttributes[n];t.values.push(AC(i))}e.value.push(t)}return e}function LSe(r){for(var e=[],t=0;t<r.length;++t)e.push(OSe(r[t]));return e}function AC(r){var e;if(r.type===se.pki.oids.contentType)e=k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.value).getBytes());else if(r.type===se.pki.oids.messageDigest)e=k.create(k.Class.UNIVERSAL,k.Type.OCTETSTRING,!1,r.value.bytes());else if(r.type===se.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=k.utcTimeToDate(i):i=k.generalizedTimeToDate(i):i=new Date(s)}i>=t&&i<n?e=k.create(k.Class.UNIVERSAL,k.Type.UTCTIME,!1,k.dateToUtcTime(i)):e=k.create(k.Class.UNIVERSAL,k.Type.GENERALIZEDTIME,!1,k.dateToGeneralizedTime(i))}return k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.type).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.SET,!0,[e])])}function BSe(r){return[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(se.pki.oids.data).getBytes()),k.create(k.Class.UNIVERSAL,k.Type.SEQUENCE,!0,[k.create(k.Class.UNIVERSAL,k.Type.OID,!1,k.oidToDer(r.algorithm).getBytes()),r.parameter?k.create(k.Class.UNIVERSAL,k.Type.OCTETSTRING,!1,r.parameter.getBytes()):void 0]),k.create(k.Class.CONTEXT_SPECIFIC,0,!0,[k.create(k.Class.UNIVERSAL,k.Type.OCTETSTRING,!1,r.content.getBytes())])]}function RC(r,e,t){var n={},i=[];if(!k.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=k.derToOid(n.contentType);if(o!==se.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(se.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==k.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:k.derToOid(n.encAlgorithm),parameter:se.util.createBuffer(n.encParameter.value),content:se.util.createBuffer(a)}}if(n.content){var a="";if(se.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==k.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=se.util.createBuffer(a)}return r.version=n.version.charCodeAt(0),r.rawCapture=n,n}function Xre(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 se.pki.oids["aes128-CBC"]:case se.pki.oids["aes192-CBC"]:case se.pki.oids["aes256-CBC"]:e=se.aes.createDecryptionCipher(r.encryptedContent.key);break;case se.pki.oids.desCBC:case se.pki.oids["des-EDE3-CBC"]:e=se.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 lne=R((qLt,une)=>{"use strict";u();var qSe=async r=>{for await(let e of r)return e};une.exports=qSe});var yne=R((XLt,mne)=>{u();var UC=_p();mne.exports=r=>{r=r||{};let e;typeof r=="function"?(e=r,r={}):e=r.onEnd;let t=new UC,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 UC,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 UC,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 wne=R((JLt,gne)=>{"use strict";u();var HSe=yne(),GSe=async function*(...r){let e=HSe();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};gne.exports=GSe});var _ne=R((vBt,bne)=>{"use strict";u();function YSe(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)}bne.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(YSe(h.slice(1))))}}});return{setTarget:i,setHandler:s,getTarget:function(){return n},getHandler:function(){return t},proxy:new Proxy(n,o)}}});var rie=R((mUt,tie)=>{"use strict";u();var nxe=async r=>{let e=[];for await(let t of r)e.push(t);return e};tie.exports=nxe});var iie=R((gUt,nie)=>{"use strict";u();var ixe=async function*(r,e){for await(let t of r)await e(t)&&(yield t)};nie.exports=ixe});var oie=R((EUt,sie)=>{"use strict";u();var sxe=async function*(r,e){for await(let t of r)yield e(t)};sie.exports=sxe});var cie=R((_Ut,aie)=>{"use strict";u();var oxe=async function*(r,e){for await(let t of r)await e(t),yield t};aie.exports=oxe});var bie=R((PFt,Eie)=>{"use strict";u();Eie.exports=wie;var cxe=f_(),Ql=wie.prototype,uxe=new Date%1e9;function lxe(){return(Math.random()*1e9>>>0)+uxe++}function wie(r){r=r||{},this.id=r.id||lxe(),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)}Ql.has=function(r){return r in this._lookup};Ql.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};Ql.meta=function(r){if(!this.has(r))return null;var e=this._lookup[r];return"meta"in e?e.meta:null};Ql.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};Ql.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};Ql.expire=function(r,e){var t=e||0,n=this._lookup[r];if(!n)return this;if(typeof t=="string"&&(t=cxe(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};Ql.clear=function(){for(var r=this.items.length;r--;)this.delete(this.items[r].key);return this};Ql.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 Pie=R((SVt,Die)=>{"use strict";u();var gxe=()=>{let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r};Die.exports=gxe});var Lie=R((IVt,Oie)=>{u();var kie=_p(),Nie=Pie();Oie.exports=class{constructor(){this._buffer=new kie,this._waitingConsumers=new kie}push(e){let{promise:t,resolve:n}=Nie();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}=Nie();return this._waitingConsumers.push({resolve:t}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}});var Wie=R((lD,Gie)=>{u();var Ab=md(),Va=Ab.Buffer;function Hie(r,e){for(var t in r)e[t]=r[t]}Va.from&&Va.alloc&&Va.allocUnsafe&&Va.allocUnsafeSlow?Gie.exports=Ab:(Hie(Ab,lD),lD.Buffer=sd);function sd(r,e,t){return Va(r,e,t)}sd.prototype=Object.create(Va.prototype);Hie(Va,sd);sd.from=function(r,e,t){if(typeof r=="number")throw new TypeError("Argument must not be a number");return Va(r,e,t)};sd.alloc=function(r,e,t){if(typeof r!="number")throw new TypeError("Argument must be a number");var n=Va(r);return e!==void 0?typeof t=="string"?n.fill(e,t):n.fill(e):n.fill(0),n};sd.allocUnsafe=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return Va(r)};sd.allocUnsafeSlow=function(r){if(typeof r!="number")throw new TypeError("Argument must be a number");return Ab.SlowBuffer(r)}});var jie=R((BKt,hD)=>{"use strict";u();var fD=65536,_xe=4294967295;function vxe(){throw new Error(`Secure random number generation is not supported by this browser.
Use Chrome, Firefox or Internet Explorer 11`)}var Sxe=Wie().Buffer,Rb=globalThis.crypto||globalThis.msCrypto;Rb&&Rb.getRandomValues?hD.exports=xxe:hD.exports=vxe;function xxe(r,e){if(r>_xe)throw new RangeError("requested too many random bytes");var t=Sxe.allocUnsafe(r);if(r>0)if(r>fD)for(var n=0;n<r;n+=fD)Rb.getRandomValues(t.slice(n,n+fD));else Rb.getRandomValues(t);return typeof e=="function"?process.nextTick(function(){e(null,t)}):t}});var Xie=R((UKt,Qie)=>{"use strict";u();var Txe=jie(),{EventEmitter:Ixe}=qn();function Yie(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 dD(){return{contacts:[],dontSplit:!1,left:null,right:null}}function Kg(r,e){if(!(e instanceof Uint8Array))throw new TypeError(r+" is not a Uint8Array")}var a1=class extends Ixe{constructor(e={}){super(),this.localNodeId=e.localNodeId||Txe(20),this.numberOfNodesPerKBucket=e.numberOfNodesPerKBucket||20,this.numberOfNodesToPing=e.numberOfNodesToPing||3,this.distance=e.distance||a1.distance,this.arbiter=e.arbiter||a1.arbiter,this.metadata=Object.assign({},e.metadata),Kg("option.localNodeId as parameter 1",this.localNodeId),this.root=dD()}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){Kg("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(Kg("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){Kg("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(Yie(e.contacts[n].id,t))return n;return-1}remove(e){Kg("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=dD(),e.right=dD();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(!Yie(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))}};Qie.exports=a1});var TD=R((mzt,xse)=>{"use strict";u();var Lxe=async r=>{let e=0;for await(let t of r)e++;return e};xse.exports=Lxe});var Rse=R((Izt,Ase)=>{"use strict";u();var Bxe=async r=>{for await(let e of r);};Ase.exports=Bxe});var Dse=R((Rzt,Cse)=>{"use strict";u();var Mxe=async r=>{for await(let e of r)return e};Cse.exports=Mxe});var zse=R((iqt,Kse)=>{"use strict";u();var Kxe=()=>{let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r};Kse.exports=Kxe});var CD=R((oqt,qse)=>{"use strict";u();var Kb=zse(),zb=globalThis.CustomEvent||Event;async function*zxe(r,e={}){let t=e.concurrency||1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,s=[],o=Kb(),a=Kb(),c=!1,l,f=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(s.length===t&&(o=Kb(),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.dispatchEvent(new zb("task-complete"))},g=>{y.done=!0,y.err=g,i.dispatchEvent(new zb("task-complete"))})}c=!0,i.dispatchEvent(new zb("task-complete"))}catch(m){l=m,i.dispatchEvent(new zb("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=Kb(),await a.promise),l)throw l;if(n?yield*p():yield*d(),c&&s.length===0)break}}qse.exports=zxe});var DD=R((cqt,$se)=>{"use strict";u();var qxe=async function*(r,e){for await(let t of r)yield e(t)};$se.exports=qxe});var noe=R((a$t,roe)=>{u();var kD=_p();roe.exports=r=>{r=r||{};let e;typeof r=="function"?(e=r,r={}):e=r.onEnd;let t=new kD,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 kD,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 kD,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 ND=R((u$t,ioe)=>{"use strict";u();var Xxe=noe(),Zxe=async function*(...r){let e=Xxe();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};ioe.exports=Zxe});var boe=R(f7=>{"use strict";u();Object.defineProperty(f7,"__esModule",{value:!0});var MD=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}))}}},l7=class{constructor(e,{highWaterMark:t=100,lowWaterMark:n=1}={}){let i=new MD;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)}};f7.EventIterator=l7;f7.default=l7});var _oe=R(r3=>{"use strict";u();Object.defineProperty(r3,"__esModule",{value:!0});var UD=boe();r3.EventIterator=UD.EventIterator;function cTe(r,e,t){return new UD.EventIterator(({push:n})=>(this.addEventListener(r,n,e),()=>this.removeEventListener(r,n,e)),t)}r3.subscribe=cTe;r3.default=UD.EventIterator});var eae=R(XD=>{"use strict";u();Object.defineProperty(XD,"__esModule",{value:!0});function STe(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}XD.isSerializableHash=STe});var p7=R(y1=>{"use strict";u();Object.defineProperty(y1,"__esModule",{value:!0});function xTe(r,e,t){return~(r-1)&e|r-1&t}y1.select=xTe;function TTe(r,e){return(r|0)-(e|0)-1>>>31&1}y1.lessOrEqual=TTe;function tae(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}y1.compare=tae;function ITe(r,e){return r.length===0||e.length===0?!1:tae(r,e)!==0}y1.equal=ITe});var za=R(ZD=>{"use strict";u();Object.defineProperty(ZD,"__esModule",{value:!0});function ATe(r){for(var e=0;e<r.length;e++)r[e]=0;return r}ZD.wipe=ATe});var nae=R(i3=>{"use strict";u();Object.defineProperty(i3,"__esModule",{value:!0});var qa=eae(),RTe=p7(),CTe=za(),rae=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),qa.isSerializableHash(this._inner)&&qa.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),CTe.wipe(n)}return r.prototype.reset=function(){if(!qa.isSerializableHash(this._inner)||!qa.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(){qa.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),qa.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(!qa.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(!qa.isSerializableHash(this._inner)||!qa.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(!qa.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},r}();i3.HMAC=rae;function DTe(r,e,t){var n=new rae(r,e);n.update(t);var i=n.digest();return n.clean(),i}i3.hmac=DTe;i3.equal=RTe.equal});var oae=R(JD=>{"use strict";u();Object.defineProperty(JD,"__esModule",{value:!0});var iae=nae(),sae=za(),PTe=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=iae.hmac(this._hash,n,t);this._hmac=new iae.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(),sae.wipe(this._buffer),sae.wipe(this._counter),this._bufpos=0},r}();JD.HKDF=PTe});var cae=R(m7=>{"use strict";u();Object.defineProperty(m7,"__esModule",{value:!0});m7.BrowserRandomSource=void 0;var aae=65536,eP=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+=aae)this._crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,aae)));return t}};m7.BrowserRandomSource=eP});var uae=R(y7=>{"use strict";u();Object.defineProperty(y7,"__esModule",{value:!0});y7.NodeRandomSource=void 0;var kTe=za(),tP=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof ld<"u"){let e=Lu();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,kTe.wipe)(t),n}};y7.NodeRandomSource=tP});var lae=R(g7=>{"use strict";u();Object.defineProperty(g7,"__esModule",{value:!0});g7.SystemRandomSource=void 0;var NTe=cae(),OTe=uae(),rP=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new NTe.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new OTe.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)}};g7.SystemRandomSource=rP});var fae=R(ds=>{"use strict";u();Object.defineProperty(ds,"__esModule",{value:!0});function LTe(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}ds.mul=Math.imul||LTe;function BTe(r,e){return r+e|0}ds.add=BTe;function MTe(r,e){return r-e|0}ds.sub=MTe;function UTe(r,e){return r<<e|r>>>32-e}ds.rotl=UTe;function FTe(r,e){return r<<32-e|r>>>e}ds.rotr=FTe;function VTe(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}ds.isInteger=Number.isInteger||VTe;ds.MAX_SAFE_INTEGER=9007199254740991;ds.isSafeInteger=function(r){return ds.isInteger(r)&&r>=-ds.MAX_SAFE_INTEGER&&r<=ds.MAX_SAFE_INTEGER}});var s3=R(st=>{"use strict";u();Object.defineProperty(st,"__esModule",{value:!0});var hae=fae();function KTe(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}st.readInt16BE=KTe;function zTe(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}st.readUint16BE=zTe;function qTe(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}st.readInt16LE=qTe;function $Te(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}st.readUint16LE=$Te;function dae(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}st.writeUint16BE=dae;st.writeInt16BE=dae;function pae(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}st.writeUint16LE=pae;st.writeInt16LE=pae;function nP(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}st.readInt32BE=nP;function iP(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}st.readUint32BE=iP;function sP(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}st.readInt32LE=sP;function oP(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}st.readUint32LE=oP;function w7(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}st.writeUint32BE=w7;st.writeInt32BE=w7;function E7(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}st.writeUint32LE=E7;st.writeInt32LE=E7;function HTe(r,e){e===void 0&&(e=0);var t=nP(r,e),n=nP(r,e+4);return t*4294967296+n-(n>>31)*4294967296}st.readInt64BE=HTe;function GTe(r,e){e===void 0&&(e=0);var t=iP(r,e),n=iP(r,e+4);return t*4294967296+n}st.readUint64BE=GTe;function WTe(r,e){e===void 0&&(e=0);var t=sP(r,e),n=sP(r,e+4);return n*4294967296+t-(t>>31)*4294967296}st.readInt64LE=WTe;function jTe(r,e){e===void 0&&(e=0);var t=oP(r,e),n=oP(r,e+4);return n*4294967296+t}st.readUint64LE=jTe;function mae(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),w7(r/4294967296>>>0,e,t),w7(r>>>0,e,t+4),e}st.writeUint64BE=mae;st.writeInt64BE=mae;function yae(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),E7(r>>>0,e,t),E7(r/4294967296>>>0,e,t+4),e}st.writeUint64LE=yae;st.writeInt64LE=yae;function YTe(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}st.readUintBE=YTe;function QTe(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}st.readUintLE=QTe;function XTe(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(!hae.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}st.writeUintBE=XTe;function ZTe(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(!hae.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}st.writeUintLE=ZTe;function JTe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e)}st.readFloat32BE=JTe;function eIe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat32(e,!0)}st.readFloat32LE=eIe;function tIe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e)}st.readFloat64BE=tIe;function rIe(r,e){e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.getFloat64(e,!0)}st.readFloat64LE=rIe;function nIe(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}st.writeFloat32BE=nIe;function iIe(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}st.writeFloat32LE=iIe;function sIe(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}st.writeFloat64BE=sIe;function oIe(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}st.writeFloat64LE=oIe});var bae=R(ei=>{"use strict";u();Object.defineProperty(ei,"__esModule",{value:!0});ei.randomStringForEntropy=ei.randomString=ei.randomUint32=ei.randomBytes=ei.defaultRandomSource=void 0;var aIe=lae(),cIe=s3(),gae=za();ei.defaultRandomSource=new aIe.SystemRandomSource;function aP(r,e=ei.defaultRandomSource){return e.randomBytes(r)}ei.randomBytes=aP;function uIe(r=ei.defaultRandomSource){let e=aP(4,r),t=(0,cIe.readUint32LE)(e);return(0,gae.wipe)(e),t}ei.randomUint32=uIe;var wae="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Eae(r,e=wae,t=ei.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=aP(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,gae.wipe)(o)}return n}ei.randomString=Eae;function lIe(r,e=wae,t=ei.defaultRandomSource){let n=Math.ceil(r/(Math.log(e.length)/Math.LN2));return Eae(n,e,t)}ei.randomStringForEntropy=lIe});var xae=R(Fr=>{"use strict";u();Object.defineProperty(Fr,"__esModule",{value:!0});Fr.sharedKey=Fr.generateKeyPair=Fr.generateKeyPairFromSeed=Fr.scalarMultBase=Fr.scalarMult=Fr.SHARED_KEY_LENGTH=Fr.SECRET_KEY_LENGTH=Fr.PUBLIC_KEY_LENGTH=void 0;var fIe=bae(),hIe=za();Fr.PUBLIC_KEY_LENGTH=32;Fr.SECRET_KEY_LENGTH=32;Fr.SHARED_KEY_LENGTH=32;function $a(r){let e=new Float64Array(16);if(r)for(let t=0;t<r.length;t++)e[t]=r[t];return e}var _ae=new Uint8Array(32);_ae[0]=9;var dIe=$a([56129,1]);function cP(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 o3(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 pIe(r,e){let t=$a(),n=$a();for(let i=0;i<16;i++)n[i]=e[i];cP(n),cP(n),cP(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,o3(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 mIe(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function b7(r,e,t){for(let n=0;n<16;n++)r[n]=e[n]+t[n]}function _7(r,e,t){for(let n=0;n<16;n++)r[n]=e[n]-t[n]}function cu(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,E=0,v=0,x=0,I=0,T=0,S=0,C=0,B=0,q=0,W=0,oe=0,te=0,Ve=0,me=0,Ae=0,$=0,Ue=0,zt=0,je=t[0],Ye=t[1],Z=t[2],le=t[3],ae=t[4],xe=t[5],Oe=t[6],Ne=t[7],Nt=t[8],qt=t[9],He=t[10],Xe=t[11],$t=t[12],Er=t[13],Vr=t[14],Kr=t[15];n=e[0],s+=n*je,o+=n*Ye,a+=n*Z,c+=n*le,l+=n*ae,f+=n*xe,h+=n*Oe,p+=n*Ne,d+=n*Nt,m+=n*qt,y+=n*He,g+=n*Xe,w+=n*$t,E+=n*Er,v+=n*Vr,x+=n*Kr,n=e[1],o+=n*je,a+=n*Ye,c+=n*Z,l+=n*le,f+=n*ae,h+=n*xe,p+=n*Oe,d+=n*Ne,m+=n*Nt,y+=n*qt,g+=n*He,w+=n*Xe,E+=n*$t,v+=n*Er,x+=n*Vr,I+=n*Kr,n=e[2],a+=n*je,c+=n*Ye,l+=n*Z,f+=n*le,h+=n*ae,p+=n*xe,d+=n*Oe,m+=n*Ne,y+=n*Nt,g+=n*qt,w+=n*He,E+=n*Xe,v+=n*$t,x+=n*Er,I+=n*Vr,T+=n*Kr,n=e[3],c+=n*je,l+=n*Ye,f+=n*Z,h+=n*le,p+=n*ae,d+=n*xe,m+=n*Oe,y+=n*Ne,g+=n*Nt,w+=n*qt,E+=n*He,v+=n*Xe,x+=n*$t,I+=n*Er,T+=n*Vr,S+=n*Kr,n=e[4],l+=n*je,f+=n*Ye,h+=n*Z,p+=n*le,d+=n*ae,m+=n*xe,y+=n*Oe,g+=n*Ne,w+=n*Nt,E+=n*qt,v+=n*He,x+=n*Xe,I+=n*$t,T+=n*Er,S+=n*Vr,C+=n*Kr,n=e[5],f+=n*je,h+=n*Ye,p+=n*Z,d+=n*le,m+=n*ae,y+=n*xe,g+=n*Oe,w+=n*Ne,E+=n*Nt,v+=n*qt,x+=n*He,I+=n*Xe,T+=n*$t,S+=n*Er,C+=n*Vr,B+=n*Kr,n=e[6],h+=n*je,p+=n*Ye,d+=n*Z,m+=n*le,y+=n*ae,g+=n*xe,w+=n*Oe,E+=n*Ne,v+=n*Nt,x+=n*qt,I+=n*He,T+=n*Xe,S+=n*$t,C+=n*Er,B+=n*Vr,q+=n*Kr,n=e[7],p+=n*je,d+=n*Ye,m+=n*Z,y+=n*le,g+=n*ae,w+=n*xe,E+=n*Oe,v+=n*Ne,x+=n*Nt,I+=n*qt,T+=n*He,S+=n*Xe,C+=n*$t,B+=n*Er,q+=n*Vr,W+=n*Kr,n=e[8],d+=n*je,m+=n*Ye,y+=n*Z,g+=n*le,w+=n*ae,E+=n*xe,v+=n*Oe,x+=n*Ne,I+=n*Nt,T+=n*qt,S+=n*He,C+=n*Xe,B+=n*$t,q+=n*Er,W+=n*Vr,oe+=n*Kr,n=e[9],m+=n*je,y+=n*Ye,g+=n*Z,w+=n*le,E+=n*ae,v+=n*xe,x+=n*Oe,I+=n*Ne,T+=n*Nt,S+=n*qt,C+=n*He,B+=n*Xe,q+=n*$t,W+=n*Er,oe+=n*Vr,te+=n*Kr,n=e[10],y+=n*je,g+=n*Ye,w+=n*Z,E+=n*le,v+=n*ae,x+=n*xe,I+=n*Oe,T+=n*Ne,S+=n*Nt,C+=n*qt,B+=n*He,q+=n*Xe,W+=n*$t,oe+=n*Er,te+=n*Vr,Ve+=n*Kr,n=e[11],g+=n*je,w+=n*Ye,E+=n*Z,v+=n*le,x+=n*ae,I+=n*xe,T+=n*Oe,S+=n*Ne,C+=n*Nt,B+=n*qt,q+=n*He,W+=n*Xe,oe+=n*$t,te+=n*Er,Ve+=n*Vr,me+=n*Kr,n=e[12],w+=n*je,E+=n*Ye,v+=n*Z,x+=n*le,I+=n*ae,T+=n*xe,S+=n*Oe,C+=n*Ne,B+=n*Nt,q+=n*qt,W+=n*He,oe+=n*Xe,te+=n*$t,Ve+=n*Er,me+=n*Vr,Ae+=n*Kr,n=e[13],E+=n*je,v+=n*Ye,x+=n*Z,I+=n*le,T+=n*ae,S+=n*xe,C+=n*Oe,B+=n*Ne,q+=n*Nt,W+=n*qt,oe+=n*He,te+=n*Xe,Ve+=n*$t,me+=n*Er,Ae+=n*Vr,$+=n*Kr,n=e[14],v+=n*je,x+=n*Ye,I+=n*Z,T+=n*le,S+=n*ae,C+=n*xe,B+=n*Oe,q+=n*Ne,W+=n*Nt,oe+=n*qt,te+=n*He,Ve+=n*Xe,me+=n*$t,Ae+=n*Er,$+=n*Vr,Ue+=n*Kr,n=e[15],x+=n*je,I+=n*Ye,T+=n*Z,S+=n*le,C+=n*ae,B+=n*xe,q+=n*Oe,W+=n*Ne,oe+=n*Nt,te+=n*qt,Ve+=n*He,me+=n*Xe,Ae+=n*$t,$+=n*Er,Ue+=n*Vr,zt+=n*Kr,s+=38*I,o+=38*T,a+=38*S,c+=38*C,l+=38*B,f+=38*q,h+=38*W,p+=38*oe,d+=38*te,m+=38*Ve,y+=38*me,g+=38*Ae,w+=38*$,E+=38*Ue,v+=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=E+i+65535,i=Math.floor(n/65536),E=n-i*65536,n=v+i+65535,i=Math.floor(n/65536),v=n-i*65536,n=x+i+65535,i=Math.floor(n/65536),x=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=E+i+65535,i=Math.floor(n/65536),E=n-i*65536,n=v+i+65535,i=Math.floor(n/65536),v=n-i*65536,n=x+i+65535,i=Math.floor(n/65536),x=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]=E,r[14]=v,r[15]=x}function a3(r,e){cu(r,e,e)}function yIe(r,e){let t=$a();for(let n=0;n<16;n++)t[n]=e[n];for(let n=253;n>=0;n--)a3(t,t),n!==2&&n!==4&&cu(t,t,e);for(let n=0;n<16;n++)r[n]=t[n]}function uP(r,e){let t=new Uint8Array(32),n=new Float64Array(80),i=$a(),s=$a(),o=$a(),a=$a(),c=$a(),l=$a();for(let d=0;d<31;d++)t[d]=r[d];t[31]=r[31]&127|64,t[0]&=248,mIe(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;o3(i,s,m),o3(o,a,m),b7(c,i,o),_7(i,i,o),b7(o,s,a),_7(s,s,a),a3(a,c),a3(l,i),cu(i,o,i),cu(o,s,c),b7(c,i,o),_7(i,i,o),a3(s,i),_7(o,a,l),cu(i,o,dIe),b7(i,i,a),cu(o,o,i),cu(i,a,l),cu(a,s,n),a3(s,c),o3(i,s,m),o3(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);yIe(f,f),cu(h,h,f);let p=new Uint8Array(32);return pIe(p,h),p}Fr.scalarMult=uP;function vae(r){return uP(r,_ae)}Fr.scalarMultBase=vae;function Sae(r){if(r.length!==Fr.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Fr.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:vae(e),secretKey:e}}Fr.generateKeyPairFromSeed=Sae;function gIe(r){let e=(0,fIe.randomBytes)(32,r),t=Sae(e);return(0,hIe.wipe)(e),t}Fr.generateKeyPair=gIe;function wIe(r,e,t=!1){if(r.length!==Fr.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Fr.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let n=uP(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}Fr.sharedKey=wIe});var Iae=R(tf=>{"use strict";u();Object.defineProperty(tf,"__esModule",{value:!0});var S7=s3(),v7=za();tf.DIGEST_LENGTH=32;tf.BLOCK_SIZE=64;var Tae=function(){function r(){this.digestLength=tf.DIGEST_LENGTH,this.blockSize=tf.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(){v7.wipe(this._buffer),v7.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&&(lP(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=lP(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;S7.writeUint32BE(i,this._buffer,o-8),S7.writeUint32BE(s,this._buffer,o-4),lP(this._temp,this._state,this._buffer,0,o),this._finished=!0}for(var a=0;a<this.digestLength/4;a++)S7.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){v7.wipe(e.state),e.buffer&&v7.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();tf.SHA256=Tae;var EIe=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 lP(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]=S7.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+(EIe[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 bIe(r){var e=new Tae;e.update(r);var t=e.digest();return e.clean(),t}tf.hash=bIe});var Rae=R(x7=>{"use strict";u();Object.defineProperty(x7,"__esModule",{value:!0});var ti=s3(),fP=za(),_Ie=20;function vIe(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],E=e[15]<<24|e[14]<<16|e[13]<<8|e[12],v=n,x=i,I=s,T=o,S=a,C=c,B=l,q=f,W=h,oe=p,te=d,Ve=m,me=y,Ae=g,$=w,Ue=E,zt=0;zt<_Ie;zt+=2)v=v+S|0,me^=v,me=me>>>32-16|me<<16,W=W+me|0,S^=W,S=S>>>32-12|S<<12,x=x+C|0,Ae^=x,Ae=Ae>>>32-16|Ae<<16,oe=oe+Ae|0,C^=oe,C=C>>>32-12|C<<12,I=I+B|0,$^=I,$=$>>>32-16|$<<16,te=te+$|0,B^=te,B=B>>>32-12|B<<12,T=T+q|0,Ue^=T,Ue=Ue>>>32-16|Ue<<16,Ve=Ve+Ue|0,q^=Ve,q=q>>>32-12|q<<12,I=I+B|0,$^=I,$=$>>>32-8|$<<8,te=te+$|0,B^=te,B=B>>>32-7|B<<7,T=T+q|0,Ue^=T,Ue=Ue>>>32-8|Ue<<8,Ve=Ve+Ue|0,q^=Ve,q=q>>>32-7|q<<7,x=x+C|0,Ae^=x,Ae=Ae>>>32-8|Ae<<8,oe=oe+Ae|0,C^=oe,C=C>>>32-7|C<<7,v=v+S|0,me^=v,me=me>>>32-8|me<<8,W=W+me|0,S^=W,S=S>>>32-7|S<<7,v=v+C|0,Ue^=v,Ue=Ue>>>32-16|Ue<<16,te=te+Ue|0,C^=te,C=C>>>32-12|C<<12,x=x+B|0,me^=x,me=me>>>32-16|me<<16,Ve=Ve+me|0,B^=Ve,B=B>>>32-12|B<<12,I=I+q|0,Ae^=I,Ae=Ae>>>32-16|Ae<<16,W=W+Ae|0,q^=W,q=q>>>32-12|q<<12,T=T+S|0,$^=T,$=$>>>32-16|$<<16,oe=oe+$|0,S^=oe,S=S>>>32-12|S<<12,I=I+q|0,Ae^=I,Ae=Ae>>>32-8|Ae<<8,W=W+Ae|0,q^=W,q=q>>>32-7|q<<7,T=T+S|0,$^=T,$=$>>>32-8|$<<8,oe=oe+$|0,S^=oe,S=S>>>32-7|S<<7,x=x+B|0,me^=x,me=me>>>32-8|me<<8,Ve=Ve+me|0,B^=Ve,B=B>>>32-7|B<<7,v=v+C|0,Ue^=v,Ue=Ue>>>32-8|Ue<<8,te=te+Ue|0,C^=te,C=C>>>32-7|C<<7;ti.writeUint32LE(v+n|0,r,0),ti.writeUint32LE(x+i|0,r,4),ti.writeUint32LE(I+s|0,r,8),ti.writeUint32LE(T+o|0,r,12),ti.writeUint32LE(S+a|0,r,16),ti.writeUint32LE(C+c|0,r,20),ti.writeUint32LE(B+l|0,r,24),ti.writeUint32LE(q+f|0,r,28),ti.writeUint32LE(W+h|0,r,32),ti.writeUint32LE(oe+p|0,r,36),ti.writeUint32LE(te+d|0,r,40),ti.writeUint32LE(Ve+m|0,r,44),ti.writeUint32LE(me+y|0,r,48),ti.writeUint32LE(Ae+g|0,r,52),ti.writeUint32LE($+w|0,r,56),ti.writeUint32LE(Ue+E|0,r,60)}function Aae(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){vIe(a,s,r);for(var l=c;l<c+64&&l<t.length;l++)n[l]=t[l]^a[l-c];xIe(s,0,o)}return fP.wipe(a),i===0&&fP.wipe(s),n}x7.streamXOR=Aae;function SIe(r,e,t,n){return n===void 0&&(n=0),fP.wipe(t),Aae(r,e,t,t,n)}x7.stream=SIe;function xIe(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 Dae=R(uu=>{"use strict";u();Object.defineProperty(uu,"__esModule",{value:!0});var TIe=p7(),T7=za();uu.DIGEST_LENGTH=16;var Cae=function(){function r(e){this.digestLength=uu.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],E=this._r[3],v=this._r[4],x=this._r[5],I=this._r[6],T=this._r[7],S=this._r[8],C=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 W=e[t+4]|e[t+5]<<8;a+=(q>>>10|W<<6)&8191;var oe=e[t+6]|e[t+7]<<8;c+=(W>>>7|oe<<9)&8191;var te=e[t+8]|e[t+9]<<8;l+=(oe>>>4|te<<12)&8191,f+=te>>>1&8191;var Ve=e[t+10]|e[t+11]<<8;h+=(te>>>14|Ve<<2)&8191;var me=e[t+12]|e[t+13]<<8;p+=(Ve>>>11|me<<5)&8191;var Ae=e[t+14]|e[t+15]<<8;d+=(me>>>8|Ae<<8)&8191,m+=Ae>>>5|i;var $=0,Ue=$;Ue+=s*y,Ue+=o*(5*C),Ue+=a*(5*S),Ue+=c*(5*T),Ue+=l*(5*I),$=Ue>>>13,Ue&=8191,Ue+=f*(5*x),Ue+=h*(5*v),Ue+=p*(5*E),Ue+=d*(5*w),Ue+=m*(5*g),$+=Ue>>>13,Ue&=8191;var zt=$;zt+=s*g,zt+=o*y,zt+=a*(5*C),zt+=c*(5*S),zt+=l*(5*T),$=zt>>>13,zt&=8191,zt+=f*(5*I),zt+=h*(5*x),zt+=p*(5*v),zt+=d*(5*E),zt+=m*(5*w),$+=zt>>>13,zt&=8191;var je=$;je+=s*w,je+=o*g,je+=a*y,je+=c*(5*C),je+=l*(5*S),$=je>>>13,je&=8191,je+=f*(5*T),je+=h*(5*I),je+=p*(5*x),je+=d*(5*v),je+=m*(5*E),$+=je>>>13,je&=8191;var Ye=$;Ye+=s*E,Ye+=o*w,Ye+=a*g,Ye+=c*y,Ye+=l*(5*C),$=Ye>>>13,Ye&=8191,Ye+=f*(5*S),Ye+=h*(5*T),Ye+=p*(5*I),Ye+=d*(5*x),Ye+=m*(5*v),$+=Ye>>>13,Ye&=8191;var Z=$;Z+=s*v,Z+=o*E,Z+=a*w,Z+=c*g,Z+=l*y,$=Z>>>13,Z&=8191,Z+=f*(5*C),Z+=h*(5*S),Z+=p*(5*T),Z+=d*(5*I),Z+=m*(5*x),$+=Z>>>13,Z&=8191;var le=$;le+=s*x,le+=o*v,le+=a*E,le+=c*w,le+=l*g,$=le>>>13,le&=8191,le+=f*y,le+=h*(5*C),le+=p*(5*S),le+=d*(5*T),le+=m*(5*I),$+=le>>>13,le&=8191;var ae=$;ae+=s*I,ae+=o*x,ae+=a*v,ae+=c*E,ae+=l*w,$=ae>>>13,ae&=8191,ae+=f*g,ae+=h*y,ae+=p*(5*C),ae+=d*(5*S),ae+=m*(5*T),$+=ae>>>13,ae&=8191;var xe=$;xe+=s*T,xe+=o*I,xe+=a*x,xe+=c*v,xe+=l*E,$=xe>>>13,xe&=8191,xe+=f*w,xe+=h*g,xe+=p*y,xe+=d*(5*C),xe+=m*(5*S),$+=xe>>>13,xe&=8191;var Oe=$;Oe+=s*S,Oe+=o*T,Oe+=a*I,Oe+=c*x,Oe+=l*v,$=Oe>>>13,Oe&=8191,Oe+=f*E,Oe+=h*w,Oe+=p*g,Oe+=d*y,Oe+=m*(5*C),$+=Oe>>>13,Oe&=8191;var Ne=$;Ne+=s*C,Ne+=o*S,Ne+=a*T,Ne+=c*I,Ne+=l*x,$=Ne>>>13,Ne&=8191,Ne+=f*v,Ne+=h*E,Ne+=p*w,Ne+=d*g,Ne+=m*y,$+=Ne>>>13,Ne&=8191,$=($<<2)+$|0,$=$+Ue|0,Ue=$&8191,$=$>>>13,zt+=$,s=Ue,o=zt,a=je,c=Ye,l=Z,f=le,h=ae,p=xe,d=Oe,m=Ne,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 T7.wipe(this._buffer),T7.wipe(this._r),T7.wipe(this._h),T7.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},r}();uu.Poly1305=Cae;function IIe(r,e){var t=new Cae(r);t.update(e);var n=t.digest();return t.clean(),n}uu.oneTimeAuth=IIe;function AIe(r,e){return r.length!==uu.DIGEST_LENGTH||e.length!==uu.DIGEST_LENGTH?!1:TIe.equal(r,e)}uu.equal=AIe});var Nae=R(lu=>{"use strict";u();Object.defineProperty(lu,"__esModule",{value:!0});var I7=Rae(),RIe=Dae(),c3=za(),Pae=s3(),CIe=p7();lu.KEY_LENGTH=32;lu.NONCE_LENGTH=12;lu.TAG_LENGTH=16;var kae=new Uint8Array(16),DIe=function(){function r(e){if(this.nonceLength=lu.NONCE_LENGTH,this.tagLength=lu.TAG_LENGTH,e.length!==lu.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);I7.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 I7.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),c3.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);I7.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),!CIe.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 I7.streamXOR(this._key,s,t.subarray(0,t.length-this.tagLength),l,4),c3.wipe(s),l},r.prototype.clean=function(){return c3.wipe(this._key),this},r.prototype._authenticate=function(e,t,n,i){var s=new RIe.Poly1305(t);i&&(s.update(i),i.length%16>0&&s.update(kae.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(kae.subarray(n.length%16));var o=new Uint8Array(8);i&&Pae.writeUint64LE(i.length,o),s.update(o),Pae.writeUint64LE(n.length,o),s.update(o);for(var a=s.digest(),c=0;c<a.length;c++)e[c]=a[c];s.clean(),c3.wipe(a),c3.wipe(o)},r}();lu.ChaCha20Poly1305=DIe});var ice=R((yQt,nce)=>{u();nce.exports=rce;var tce=128,qIe=127,$Ie=~qIe,HIe=Math.pow(2,31);function rce(r,e,t){e=e||[],t=t||0;for(var n=t;r>=HIe;)e[t++]=r&255|tce,r/=128;for(;r&$Ie;)e[t++]=r&255|tce,r>>>=7;return e[t]=r|0,rce.bytes=t-n+1,e}});var ace=R((wQt,oce)=>{u();oce.exports=EP;var GIe=128,sce=127;function EP(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw EP.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&sce)<<i:(o&sce)*Math.pow(2,i),i+=7}while(o>=GIe);return EP.bytes=s-n,t}});var uce=R((bQt,cce)=>{u();var WIe=Math.pow(2,7),jIe=Math.pow(2,14),YIe=Math.pow(2,21),QIe=Math.pow(2,28),XIe=Math.pow(2,35),ZIe=Math.pow(2,42),JIe=Math.pow(2,49),eAe=Math.pow(2,56),tAe=Math.pow(2,63);cce.exports=function(r){return r<WIe?1:r<jIe?2:r<YIe?3:r<QIe?4:r<XIe?5:r<ZIe?6:r<JIe?7:r<eAe?8:r<tAe?9:10}});var fce=R((vQt,lce)=>{u();lce.exports={encode:ice(),decode:ace(),encodingLength:uce()}});var pce=R((xQt,dce)=>{"use strict";u();var hce=fce();dce.exports=r=>{if(!(r instanceof Uint8Array))throw new Error("arg needs to be a Uint8Array");let e=[];for(;r.length>0;){let t=hce.decode(r);e.push(t),r=r.slice(hce.decode.bytes)}return e}});var Pce=R((Cce,Dce)=>{"use strict";u();var pAe=Math.exp;Cce=Dce.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-pAe(-(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 AAe={};Re(AAe,{create:()=>xAe,globSource:()=>TAe,urlSource:()=>IAe});u();u();u();var dk=_(c_(),1),ze=dk.default;var Qce=_(l_(),1);u();var Wo=_(Ci(),1);var E_={};Re(E_,{base58btc:()=>Ce,base58flickr:()=>vle});u();u();u();function ple(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,E=m.length;w!==E&&m[w]===0;)w++,y++;for(var v=(E-w)*f+1>>>0,x=new Uint8Array(v);w!==E;){for(var I=m[w],T=0,S=v-1;(I!==0||T<g)&&S!==-1;S--,T++)I+=256*x[S]>>>0,x[S]=I%a>>>0,I=I/a>>>0;if(I!==0)throw new Error("Non-zero carry");g=T,w++}for(var C=v-g;C!==v&&x[C]===0;)C++;for(var B=c.repeat(y);C<v;++C)B+=r.charAt(x[C]);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 E=(m.length-y)*l+1>>>0,v=new Uint8Array(E);m[y];){var x=t[m.charCodeAt(y)];if(x===255)return;for(var I=0,T=E-1;(x!==0||I<w)&&T!==-1;T--,I++)x+=a*v[T]>>>0,v[T]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");w=I,y++}if(m[y]!==" "){for(var S=E-w;S!==E&&v[S]===0;)S++;for(var C=new Uint8Array(g+(E-S)),B=g;S!==E;)C[B++]=v[S++];return C}}}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 mle=ple,yle=mle,Ek=yle;var vd={};Re(vd,{coerce:()=>ys,empty:()=>bk,equals:()=>h_,fromHex:()=>wle,fromString:()=>d_,isBinary:()=>Ele,toHex:()=>gle,toString:()=>p_});u();var bk=new Uint8Array(0),gle=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),wle=r=>{let e=r.match(/../g);return e?new Uint8Array(e.map(t=>parseInt(t,16))):bk},h_=(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},ys=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")},Ele=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),d_=r=>new TextEncoder().encode(r),p_=r=>new TextDecoder().decode(r);u();var m_=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")}},y_=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 _k(this,e)}},g_=class{constructor(e){this.decoders=e}or(e){return _k(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`)}},_k=(r,e)=>new g_({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),w_=class{constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new m_(e,t,n),this.decoder=new y_(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Sd=({name:r,prefix:e,encode:t,decode:n})=>new w_(r,e,t,n),pu=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:i}=Ek(t,e);return Sd({prefix:r,name:e,encode:n,decode:s=>ys(i(s))})},ble=(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},_le=(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},Pr=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Sd({prefix:e,name:r,encode(i){return _le(i,n,t)},decode(i){return ble(i,n,t,r)}});var Ce=pu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vle=pu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var v_={};Re(v_,{base32:()=>dt,base32hex:()=>xle,base32hexpad:()=>Ile,base32hexpadupper:()=>Ale,base32hexupper:()=>Tle,base32pad:()=>__,base32padupper:()=>Sle,base32upper:()=>b_,base32z:()=>Rle});u();var dt=Pr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),b_=Pr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),__=Pr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Sle=Pr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xle=Pr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Tle=Pr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ile=Pr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ale=Pr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rle=Pr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var S_={};Re(S_,{base64:()=>Go,base64pad:()=>Cle,base64url:()=>mu,base64urlpad:()=>Dle});u();var Go=Pr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cle=Pr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mu=Pr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Dle=Pr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});Wo.default.formatters.b=r=>r==null?"undefined":Ce.baseEncode(r);Wo.default.formatters.t=r=>r==null?"undefined":dt.baseEncode(r);Wo.default.formatters.m=r=>r==null?"undefined":Go.baseEncode(r);Wo.default.formatters.p=r=>r==null?"undefined":r.toString();Wo.default.formatters.c=r=>r==null?"undefined":r.toString();Wo.default.formatters.k=r=>r==null?"undefined":r.toString();function D(r){return Object.assign((0,Wo.default)(r),{error:(0,Wo.default)(`${r}:error`),trace:(0,Wo.default)(`${r}:trace`)})}var j7=_(V(),1);u();var F3=_(V(),1);u();var Qa=_(Qo(),1),Td=Qa.default.Reader,$_=Qa.default.Writer,Le=Qa.default.util,Mn=Qa.default.roots["ipfs-unixfs"]||(Qa.default.roots["ipfs-unixfs"]={}),fN=Mn.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=Le.newBuffer([]),r.prototype.filesize=Le.Long?Le.Long.fromBits(0,0,!0):0,r.prototype.blocksizes=Le.emptyArray,r.prototype.hashType=Le.Long?Le.Long.fromBits(0,0,!0):0,r.prototype.fanout=Le.Long?Le.Long.fromBits(0,0,!0):0,r.prototype.mode=0,r.prototype.mtime=null,r.encode=function(t,n){if(n||(n=$_.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")&&Mn.UnixTime.encode(t.mtime,n.uint32(66).fork()).ldelim(),n},r.decode=function(t,n){t instanceof Td||(t=Td.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Mn.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=Mn.UnixTime.decode(t,t.uint32());break;default:t.skipType(o&7);break}}if(!s.hasOwnProperty("Type"))throw Le.ProtocolError("missing required 'Type'",{instance:s});return s},r.fromObject=function(t){if(t instanceof Mn.Data)return t;var n=new Mn.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"?Le.base64.decode(t.Data,n.Data=Le.newBuffer(Le.base64.length(t.Data)),0):t.Data.length&&(n.Data=t.Data)),t.filesize!=null&&(Le.Long?(n.filesize=Le.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 Le.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)Le.Long?(n.blocksizes[i]=Le.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 Le.LongBits(t.blocksizes[i].low>>>0,t.blocksizes[i].high>>>0).toNumber(!0))}if(t.hashType!=null&&(Le.Long?(n.hashType=Le.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 Le.LongBits(t.hashType.low>>>0,t.hashType.high>>>0).toNumber(!0))),t.fanout!=null&&(Le.Long?(n.fanout=Le.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 Le.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=Mn.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=Le.newBuffer(i.Data))),Le.Long){var s=new Le.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(Le.Long){var s=new Le.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(Le.Long){var s=new Le.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?Mn.Data.DataType[t.Type]:t.Type),t.Data!=null&&t.hasOwnProperty("Data")&&(i.Data=n.bytes===String?Le.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?Le.Long.prototype.toString.call(t.filesize):n.longs===Number?new Le.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?Le.Long.prototype.toString.call(t.blocksizes[o]):n.longs===Number?new Le.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?Le.Long.prototype.toString.call(t.hashType):n.longs===Number?new Le.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?Le.Long.prototype.toString.call(t.fanout):n.longs===Number?new Le.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=Mn.UnixTime.toObject(t.mtime,n)),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Qa.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})(),nCe=Mn.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=Le.Long?Le.Long.fromBits(0,0,!1):0,r.prototype.FractionalNanoseconds=0,r.encode=function(t,n){return n||(n=$_.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 Td||(t=Td.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Mn.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 Le.ProtocolError("missing required 'Seconds'",{instance:s});return s},r.fromObject=function(t){if(t instanceof Mn.UnixTime)return t;var n=new Mn.UnixTime;return t.Seconds!=null&&(Le.Long?(n.Seconds=Le.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 Le.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(Le.Long){var s=new Le.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?Le.Long.prototype.toString.call(t.Seconds):n.longs===Number?new Le.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,Qa.default.util.toJSONOptions)},r})(),iCe=Mn.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=$_.create()),t.MimeType!=null&&Object.hasOwnProperty.call(t,"MimeType")&&n.uint32(10).string(t.MimeType),n},r.decode=function(t,n){t instanceof Td||(t=Td.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Mn.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 Mn.Metadata)return t;var n=new Mn.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,Qa.default.util.toJSONOptions)},r})();var Xa=fN,hN=["raw","directory","file","metadata","symlink","hamt-sharded-directory"],zle=["directory","hamt-sharded-directory"],dN=parseInt("0644",8),pN=parseInt("0755",8);function Za(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 wu(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,F3.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}var $e=class{static unmarshal(e){let t=Xa.decode(e),n=Xa.toObject(t,{defaults:!1,arrays:!0,longs:Number,objects:!1}),i=new $e({type:hN[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&&!hN.includes(t))throw(0,F3.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=Za(c),a&&(this.mtime=wu(a),this.mtime&&!this.mtime.nsecs&&(this.mtime.nsecs=0))}set mode(e){this._mode=this.isDirectory()?pN:dN;let t=Za(e);t!==void 0&&(this._mode=t)}get mode(){return this._mode}isDirectory(){return Boolean(this.type&&zle.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=Xa.DataType.Raw;break;case"directory":e=Xa.DataType.Directory;break;case"file":e=Xa.DataType.File;break;case"metadata":e=Xa.DataType.Metadata;break;case"symlink":e=Xa.DataType.Symlink;break;case"hamt-sharded-directory":e=Xa.DataType.HAMTShard;break;default:throw(0,F3.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|(Za(this.mode)||0),n===dN&&!this.isDirectory()&&(n=void 0),n===pN&&this.isDirectory()&&(n=void 0));let i;if(this.mtime!=null){let o=wu(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 Xa.encode(s).finish()}};var gt={};Re(gt,{code:()=>rt,createLink:()=>DN,createNode:()=>CN,decode:()=>yt,encode:()=>qe,name:()=>Sfe,prepare:()=>vn,validate:()=>Y_});u();u();u();u();var qle=gN,mN=128,$le=127,Hle=~$le,Gle=Math.pow(2,31);function gN(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Gle;)e[t++]=r&255|mN,r/=128;for(;r&Hle;)e[t++]=r&255|mN,r>>>=7;return e[t]=r|0,gN.bytes=t-n+1,e}var Wle=H_,jle=128,yN=127;function H_(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw H_.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&yN)<<i:(o&yN)*Math.pow(2,i),i+=7}while(o>=jle);return H_.bytes=s-n,t}var Yle=Math.pow(2,7),Qle=Math.pow(2,14),Xle=Math.pow(2,21),Zle=Math.pow(2,28),Jle=Math.pow(2,35),efe=Math.pow(2,42),tfe=Math.pow(2,49),rfe=Math.pow(2,56),nfe=Math.pow(2,63),ife=function(r){return r<Yle?1:r<Qle?2:r<Xle?3:r<Zle?4:r<Jle?5:r<efe?6:r<tfe?7:r<rfe?8:r<nfe?9:10},sfe={encode:qle,decode:Wle,encodingLength:ife},ofe=sfe,R1=ofe;var C1=(r,e=0)=>[R1.decode(r,e),R1.decode.bytes],Id=(r,e,t=0)=>(R1.encode(r,e,t),e),Ad=r=>R1.encodingLength(r);u();var Xo=(r,e)=>{let t=e.byteLength,n=Ad(r),i=n+Ad(t),s=new Uint8Array(i+t);return Id(r,s,0),Id(t,s,n),s.set(e,i),new Rd(r,t,e,s)},Jt=r=>{let e=ys(r),[t,n]=C1(e),[i,s]=C1(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new Rd(t,i,o,e)},wN=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&h_(r.bytes,t.bytes)}},Rd=class{constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};u();var afe=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return ufe(t,G_(r),e||Ce.encoder);default:return lfe(t,G_(r),e||dt.encoder)}},EN=new WeakMap,G_=r=>{let e=EN.get(r);if(e==null){let t=new Map;return EN.set(r,t),t}return e},A=class{constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==D1)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ffe)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return A.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Xo(e,t);return A.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return A.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&wN(e.multihash,n.multihash)}toString(e){return afe(this,e)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof A)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:s,bytes:o}=t;return new A(n,i,s,o||bN(n,i,s.bytes))}else if(t[hfe]===!0){let{version:n,multihash:i,code:s}=t,o=Jt(i);return A.create(n,s,o)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==D1)throw new Error(`Version 0 CID must use dag-pb (code: ${D1}) block encoding`);return new A(e,t,n,n.bytes)}case 1:{let i=bN(e,t,n.bytes);return new A(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return A.create(0,D1,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=ys(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 Rd(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]=C1(e.subarray(t));return t+=p,h},i=n(),s=D1;if(i===18?(i=0,t=0):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]=cfe(e,t),s=A.decode(i);return G_(s).set(n,e),s}},cfe=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ce;return[Ce.prefix,t.decode(`${Ce.prefix}${r}`)]}case Ce.prefix:{let t=e||Ce;return[Ce.prefix,t.decode(r)]}case dt.prefix:{let t=e||dt;return[dt.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)]}}},ufe=(r,e,t)=>{let{prefix:n}=t;if(n!==Ce.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},lfe=(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},D1=112,ffe=18,bN=(r,e,t)=>{let n=Ad(r),i=n+Ad(e),s=new Uint8Array(i+t.byteLength);return Id(r,s,0),Id(e,s,n),s.set(t,i),s},hfe=Symbol.for("@ipld/js-cid/CID");u();var dfe=new TextDecoder;function W_(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 K3(r,e){let t;[t,e]=W_(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 _N(r,e){let t;return[t,e]=W_(r,e),[t&7,t>>3,e]}function pfe(r){let e={},t=r.length,n=0;for(;n<t;){let i,s;if([i,s,n]=_N(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]=K3(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]=K3(r,n),e.Name=dfe.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]=W_(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 vN(r){let e=r.length,t=0,n,i=!1,s;for(;t<e;){let a,c;if([a,c,t]=_N(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]=K3(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]=K3(r,t),n.push(pfe(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 xN=new TextEncoder,SN=2**32,mfe=2**31;function yfe(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=P1(e,t,r.Tsize)-1,e[t]=24}if(typeof r.Name=="string"){let n=xN.encode(r.Name);t-=n.length,e.set(n,t),t=P1(e,t,n.length)-1,e[t]=18}return r.Hash&&(t-=r.Hash.length,e.set(r.Hash,t),t=P1(e,t,r.Hash.length)-1,e[t]=10),e.length-t}function TN(r){let e=wfe(r),t=new Uint8Array(e),n=e;if(r.Data&&(n-=r.Data.length,t.set(r.Data,n),n=P1(t,n,r.Data.length)-1,t[n]=10),r.Links)for(let i=r.Links.length-1;i>=0;i--){let s=yfe(r.Links[i],t.subarray(0,n));n-=s,n=P1(t,n,s)-1,t[n]=18}return t}function gfe(r){let e=0;if(r.Hash){let t=r.Hash.length;e+=1+t+Cd(t)}if(typeof r.Name=="string"){let t=xN.encode(r.Name).length;e+=1+t+Cd(t)}return typeof r.Tsize=="number"&&(e+=1+Cd(r.Tsize)),e}function wfe(r){let e=0;if(r.Data){let t=r.Data.length;e+=1+t+Cd(t)}if(r.Links)for(let t of r.Links){let n=gfe(t);e+=1+n+Cd(n)}return e}function P1(r,e,t){e-=Cd(t);let n=e;for(;t>=mfe;)r[e++]=t&127|128,t/=128;for(;t>=128;)r[e++]=t&127|128,t>>>=7;return r[e]=t,n}function Cd(r){return r%2===0&&r++,Math.floor((Efe(r)+6)/7)}function Efe(r){let e=0;return r>=SN&&(r=Math.floor(r/SN),e=32),r>=1<<16&&(r>>>=16,e+=16),r>=1<<8&&(r>>>=8,e+=8),e+bfe[r]}var bfe=[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 _fe=["Data","Links"],vfe=["Hash","Name","Tsize"],j_=new TextEncoder;function AN(r,e){if(r===e)return 0;let t=r.Name?j_.encode(r.Name):[],n=e.Name?j_.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 IN(r,e){return!Object.keys(r).some(t=>!e.includes(t))}function RN(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 vn(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=j_.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(RN),e.Links.sort(AN);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function Y_(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");if(!IN(r,_fe))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(!IN(t,vfe))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&&AN(t,r.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function CN(r,e=[]){return vn({Data:r,Links:e})}function DN(r,e,t){return RN({Hash:t,Name:r,Tsize:e})}var Sfe="dag-pb",rt=112;function qe(r){Y_(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),TN(e)}function yt(r){let e=vN(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 tc={};Re(tc,{code:()=>F1,decode:()=>hf,encode:()=>V1,name:()=>rhe});u();u();u();u();var xfe=["string","number","bigint","symbol"],Tfe=["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 PN(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(xfe.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Ife(r))return"Buffer";let t=Afe(r);return t||"Object"}function Ife(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Afe(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Tfe.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 Q=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 Dd=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Rfe=new TextDecoder,Cfe=new TextEncoder;function z3(r){return Dd&&globalThis.Buffer.isBuffer(r)}function k1(r){return r instanceof Uint8Array?z3(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var LN=Dd?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):NN(r,e,t):(r,e,t)=>t-e>64?Rfe.decode(r.subarray(e,t)):NN(r,e,t),q3=Dd?r=>r.length>64?globalThis.Buffer.from(r):kN(r):r=>r.length>64?Cfe.encode(r):kN(r),Zo=r=>Uint8Array.from(r),Pd=Dd?(r,e,t)=>z3(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),BN=Dd?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),k1(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},MN=Dd?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function UN(r,e){if(z3(r)&&z3(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 kN(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 NN(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 Q_(n)}var ON=4096;function Q_(r){let e=r.length;if(e<=ON)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=ON));return t}var Dfe=256,N1=class{constructor(e=Dfe){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=MN(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=Pd(n,0,this.cursor)}else t=BN(this.chunks,this.cursor);return e&&this.reset(),t}};u();var ye="CBOR decode error:",Ja="CBOR encode error:",O1=[];O1[23]=1;O1[24]=2;O1[25]=3;O1[26]=5;O1[27]=9;function ec(r,e,t){if(r.length-e<t)throw new Error(`${ye} not enough data for type`)}u();u();var Sn=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Di(r,e,t){ec(r,e,1);let n=r[e];if(t.strict===!0&&n<Sn[0])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);return n}function Pi(r,e,t){ec(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<Sn[1])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);return n}function ki(r,e,t){ec(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<Sn[2])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);return n}function Ni(r,e,t){ec(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<Sn[3])throw new Error(`${ye} 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(`${ye} integers outside of the safe integer range are not supported`)}function FN(r,e,t,n){return new Q(L.uint,Di(r,e+1,n),2)}function VN(r,e,t,n){return new Q(L.uint,Pi(r,e+1,n),3)}function KN(r,e,t,n){return new Q(L.uint,ki(r,e+1,n),5)}function zN(r,e,t,n){return new Q(L.uint,Ni(r,e+1,n),9)}function ws(r,e){return Fn(r,0,e.value)}function Fn(r,e,t){if(t<Sn[0]){let n=Number(t);r.push([e|n])}else if(t<Sn[1]){let n=Number(t);r.push([e|24,n])}else if(t<Sn[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<Sn[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<Sn[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(`${ye} encountered BigInt larger than allowable range`)}}ws.encodedSize=function(e){return Fn.encodedSize(e.value)};Fn.encodedSize=function(e){return e<Sn[0]?1:e<Sn[1]?2:e<Sn[2]?3:e<Sn[3]?5:9};ws.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};u();function qN(r,e,t,n){return new Q(L.negint,-1-Di(r,e+1,n),2)}function $N(r,e,t,n){return new Q(L.negint,-1-Pi(r,e+1,n),3)}function HN(r,e,t,n){return new Q(L.negint,-1-ki(r,e+1,n),5)}var X_=BigInt(-1),GN=BigInt(1);function WN(r,e,t,n){let i=Ni(r,e+1,n);if(typeof i!="bigint"){let s=-1-i;if(s>=Number.MIN_SAFE_INTEGER)return new Q(L.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${ye} integers outside of the safe integer range are not supported`);return new Q(L.negint,X_-BigInt(i),9)}function $3(r,e){let t=e.value,n=typeof t=="bigint"?t*X_-GN:t*-1-1;Fn(r,e.type.majorEncoded,n)}$3.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*X_-GN:t*-1-1;return n<Sn[0]?1:n<Sn[1]?2:n<Sn[2]?3:n<Sn[3]?5:9};$3.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};u();function L1(r,e,t,n){ec(r,e,t+n);let i=Pd(r,e+t,e+t+n);return new Q(L.bytes,i,t+n)}function jN(r,e,t,n){return L1(r,e,1,t)}function YN(r,e,t,n){return L1(r,e,2,Di(r,e+1,n))}function QN(r,e,t,n){return L1(r,e,3,Pi(r,e+1,n))}function XN(r,e,t,n){return L1(r,e,5,ki(r,e+1,n))}function ZN(r,e,t,n){let i=Ni(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer bytes lengths not supported`);return L1(r,e,9,i)}function H3(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===L.string?q3(r.value):r.value),r.encodedBytes}function kd(r,e){let t=H3(e);Fn(r,e.type.majorEncoded,t.length),r.push(t)}kd.encodedSize=function(e){let t=H3(e);return Fn.encodedSize(t.length)+t.length};kd.compareTokens=function(e,t){return kfe(H3(e),H3(t))};function kfe(r,e){return r.length<e.length?-1:r.length>e.length?1:UN(r,e)}u();function B1(r,e,t,n,i){let s=t+n;ec(r,e,s);let o=new Q(L.string,LN(r,e+t,e+s),s);return i.retainStringBytes===!0&&(o.byteValue=Pd(r,e+t,e+s)),o}function JN(r,e,t,n){return B1(r,e,1,t,n)}function eO(r,e,t,n){return B1(r,e,2,Di(r,e+1,n),n)}function tO(r,e,t,n){return B1(r,e,3,Pi(r,e+1,n),n)}function rO(r,e,t,n){return B1(r,e,5,ki(r,e+1,n),n)}function nO(r,e,t,n){let i=Ni(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer string lengths not supported`);return B1(r,e,9,i,n)}var iO=kd;u();function Nd(r,e,t,n){return new Q(L.array,n,t)}function sO(r,e,t,n){return Nd(r,e,1,t)}function oO(r,e,t,n){return Nd(r,e,2,Di(r,e+1,n))}function aO(r,e,t,n){return Nd(r,e,3,Pi(r,e+1,n))}function cO(r,e,t,n){return Nd(r,e,5,ki(r,e+1,n))}function uO(r,e,t,n){let i=Ni(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer array lengths not supported`);return Nd(r,e,9,i)}function lO(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ye} indefinite length items not allowed`);return Nd(r,e,1,1/0)}function G3(r,e){Fn(r,L.array.majorEncoded,e.value)}G3.compareTokens=ws.compareTokens;G3.encodedSize=function(e){return Fn.encodedSize(e.value)};u();function Od(r,e,t,n){return new Q(L.map,n,t)}function fO(r,e,t,n){return Od(r,e,1,t)}function hO(r,e,t,n){return Od(r,e,2,Di(r,e+1,n))}function dO(r,e,t,n){return Od(r,e,3,Pi(r,e+1,n))}function pO(r,e,t,n){return Od(r,e,5,ki(r,e+1,n))}function mO(r,e,t,n){let i=Ni(r,e+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer map lengths not supported`);return Od(r,e,9,i)}function yO(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ye} indefinite length items not allowed`);return Od(r,e,1,1/0)}function W3(r,e){Fn(r,L.map.majorEncoded,e.value)}W3.compareTokens=ws.compareTokens;W3.encodedSize=function(e){return Fn.encodedSize(e.value)};u();function gO(r,e,t,n){return new Q(L.tag,t,1)}function wO(r,e,t,n){return new Q(L.tag,Di(r,e+1,n),2)}function EO(r,e,t,n){return new Q(L.tag,Pi(r,e+1,n),3)}function bO(r,e,t,n){return new Q(L.tag,ki(r,e+1,n),5)}function _O(r,e,t,n){return new Q(L.tag,Ni(r,e+1,n),9)}function j3(r,e){Fn(r,L.tag.majorEncoded,e.value)}j3.compareTokens=ws.compareTokens;j3.encodedSize=function(e){return Fn.encodedSize(e.value)};u();var Ufe=20,Ffe=21,Vfe=22,Kfe=23;function vO(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${ye} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Q(L.null,null,1):new Q(L.undefined,void 0,1)}function SO(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${ye} indefinite length items not allowed`);return new Q(L.break,void 0,1)}function Z_(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${ye} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${ye} Infinity values are not supported`)}return new Q(L.float,r,e)}function xO(r,e,t,n){return Z_(J_(r,e+1),3,n)}function TO(r,e,t,n){return Z_(ev(r,e+1),5,n)}function IO(r,e,t,n){return Z_(DO(r,e+1),9,n)}function Y3(r,e,t){let n=e.value;if(n===!1)r.push([L.float.majorEncoded|Ufe]);else if(n===!0)r.push([L.float.majorEncoded|Ffe]);else if(n===null)r.push([L.float.majorEncoded|Vfe]);else if(n===void 0)r.push([L.float.majorEncoded|Kfe]);else{let i,s=!1;(!t||t.float64!==!0)&&(RO(n),i=J_(Js,1),n===i||Number.isNaN(n)?(Js[0]=249,r.push(Js.slice(0,3)),s=!0):(CO(n),i=ev(Js,1),n===i&&(Js[0]=250,r.push(Js.slice(0,5)),s=!0))),s||(zfe(n),i=DO(Js,1),Js[0]=251,r.push(Js.slice(0,9)))}}Y3.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){RO(n);let i=J_(Js,1);if(n===i||Number.isNaN(n))return 3;if(CO(n),i=ev(Js,1),n===i)return 5}return 9};var AO=new ArrayBuffer(9),Es=new DataView(AO,1),Js=new Uint8Array(AO,0);function RO(r){if(r===1/0)Es.setUint16(0,31744,!1);else if(r===-1/0)Es.setUint16(0,64512,!1);else if(Number.isNaN(r))Es.setUint16(0,32256,!1);else{Es.setFloat32(0,r);let e=Es.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Es.setUint16(0,31744,!1);else if(t===0)Es.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let i=t-127;i<-24?Es.setUint16(0,0):i<-14?Es.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Es.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function J_(r,e){if(r.length-e<2)throw new Error(`${ye} 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 CO(r){Es.setFloat32(0,r,!1)}function ev(r,e){if(r.length-e<4)throw new Error(`${ye} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function zfe(r){Es.setFloat64(0,r,!1)}function DO(r,e){if(r.length-e<8)throw new Error(`${ye} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Y3.compareTokens=ws.compareTokens;function Ct(r,e,t){throw new Error(`${ye} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Q3(r){return()=>{throw new Error(`${ye} ${r}`)}}var ne=[];for(let r=0;r<=23;r++)ne[r]=Ct;ne[24]=FN;ne[25]=VN;ne[26]=KN;ne[27]=zN;ne[28]=Ct;ne[29]=Ct;ne[30]=Ct;ne[31]=Ct;for(let r=32;r<=55;r++)ne[r]=Ct;ne[56]=qN;ne[57]=$N;ne[58]=HN;ne[59]=WN;ne[60]=Ct;ne[61]=Ct;ne[62]=Ct;ne[63]=Ct;for(let r=64;r<=87;r++)ne[r]=jN;ne[88]=YN;ne[89]=QN;ne[90]=XN;ne[91]=ZN;ne[92]=Ct;ne[93]=Ct;ne[94]=Ct;ne[95]=Q3("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)ne[r]=JN;ne[120]=eO;ne[121]=tO;ne[122]=rO;ne[123]=nO;ne[124]=Ct;ne[125]=Ct;ne[126]=Ct;ne[127]=Q3("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)ne[r]=sO;ne[152]=oO;ne[153]=aO;ne[154]=cO;ne[155]=uO;ne[156]=Ct;ne[157]=Ct;ne[158]=Ct;ne[159]=lO;for(let r=160;r<=183;r++)ne[r]=fO;ne[184]=hO;ne[185]=dO;ne[186]=pO;ne[187]=mO;ne[188]=Ct;ne[189]=Ct;ne[190]=Ct;ne[191]=yO;for(let r=192;r<=215;r++)ne[r]=gO;ne[216]=wO;ne[217]=EO;ne[218]=bO;ne[219]=_O;ne[220]=Ct;ne[221]=Ct;ne[222]=Ct;ne[223]=Ct;for(let r=224;r<=243;r++)ne[r]=Q3("simple values are not supported");ne[244]=Ct;ne[245]=Ct;ne[246]=Ct;ne[247]=vO;ne[248]=Q3("simple values are not supported");ne[249]=xO;ne[250]=TO;ne[251]=IO;ne[252]=Ct;ne[253]=Ct;ne[254]=Ct;ne[255]=SO;var eo=[];for(let r=0;r<24;r++)eo[r]=new Q(L.uint,r,1);for(let r=-1;r>=-24;r--)eo[31-r]=new Q(L.negint,r,1);eo[64]=new Q(L.bytes,new Uint8Array(0),1);eo[96]=new Q(L.string,"",1);eo[128]=new Q(L.array,0,1);eo[160]=new Q(L.map,0,1);eo[244]=new Q(L.false,!1,1);eo[245]=new Q(L.true,!0,1);eo[246]=new Q(L.null,null,1);function PO(r){switch(r.type){case L.false:return Zo([244]);case L.true:return Zo([245]);case L.null:return Zo([246]);case L.bytes:return r.value.length?void 0:Zo([64]);case L.string:return r.value===""?Zo([96]):void 0;case L.array:return r.value===0?Zo([128]):void 0;case L.map:return r.value===0?Zo([160]):void 0;case L.uint:return r.value<24?Zo([Number(r.value)]):void 0;case L.negint:if(r.value>=-24)return Zo([31-Number(r.value)])}}var $fe={float64:!1,mapSorter:Wfe,quickEncodeToken:PO};function Hfe(){let r=[];return r[L.uint.major]=ws,r[L.negint.major]=$3,r[L.bytes.major]=kd,r[L.string.major]=iO,r[L.array.major]=G3,r[L.map.major]=W3,r[L.tag.major]=j3,r[L.float.major]=Y3,r}var kO=Hfe(),tv=new N1,Ld=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(`${Ja} object contains circular references`);return new Ld(t,e)}},Eu={null:new Q(L.null,null),undefined:new Q(L.undefined,void 0),true:new Q(L.true,!0),false:new Q(L.false,!1),emptyArray:new Q(L.array,0),emptyMap:new Q(L.map,0)},bu={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new Q(L.float,r):r>=0?new Q(L.uint,r):new Q(L.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new Q(L.uint,r):new Q(L.negint,r)},Uint8Array(r,e,t,n){return new Q(L.bytes,r)},string(r,e,t,n){return new Q(L.string,r)},boolean(r,e,t,n){return r?Eu.true:Eu.false},null(r,e,t,n){return Eu.null},undefined(r,e,t,n){return Eu.undefined},ArrayBuffer(r,e,t,n){return new Q(L.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new Q(L.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Eu.emptyArray,new Q(L.break)]:Eu.emptyArray;n=Ld.createCheck(n,r);let i=[],s=0;for(let o of r)i[s++]=X3(o,t,n);return t.addBreakTokens?[new Q(L.array,r.length),i,new Q(L.break)]:[new Q(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?[Eu.emptyMap,new Q(L.break)]:Eu.emptyMap;n=Ld.createCheck(n,r);let a=[],c=0;for(let l of s)a[c++]=[X3(l,t,n),X3(i?r.get(l):r[l],t,n)];return Gfe(a,t),t.addBreakTokens?[new Q(L.map,o),a,new Q(L.break)]:[new Q(L.map,o),a]}};bu.Map=bu.Object;bu.Buffer=bu.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))bu[`${r}Array`]=bu.DataView;function X3(r,e={},t){let n=PN(r),i=e&&e.typeEncoders&&e.typeEncoders[n]||bu[n];if(typeof i=="function"){let o=i(r,n,e,t);if(o!=null)return o}let s=bu[n];if(!s)throw new Error(`${Ja} unsupported type: ${n}`);return s(r,n,e,t)}function Gfe(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Wfe(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=kO[i].compareTokens(t,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function NO(r,e,t,n){if(Array.isArray(e))for(let i of e)NO(r,i,t,n);else t[e.type.major](r,e,n)}function rv(r,e,t){let n=X3(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 N1(o);if(s(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return k1(a.chunks[0])}}return tv.reset(),NO(tv,n,e,t),tv.toBytes(!0)}function to(r,e){return e=Object.assign({},$fe,e),rv(r,kO,e)}u();var jfe={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},nv=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=eo[e];if(t===void 0){let n=ne[e];if(!n)throw new Error(`${ye} 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}},M1=Symbol.for("DONE"),Z3=Symbol.for("BREAK");function Yfe(r,e,t){let n=[];for(let i=0;i<r.value;i++){let s=U1(e,t);if(s===Z3){if(r.value===1/0)break;throw new Error(`${ye} got unexpected break to lengthed array`)}if(s===M1)throw new Error(`${ye} found array but not enough entries (got ${i}, expected ${r.value})`);n[i]=s}return n}function Qfe(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=U1(e,t);if(a===Z3){if(r.value===1/0)break;throw new Error(`${ye} got unexpected break to lengthed map`)}if(a===M1)throw new Error(`${ye} found map but not enough entries (got ${o} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ye} non-string keys not supported (got ${typeof a})`);let c=U1(e,t);if(c===M1)throw new Error(`${ye} 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 U1(r,e){if(r.done())return M1;let t=r.next();if(t.type===L.break)return Z3;if(t.type.terminal)return t.value;if(t.type===L.array)return Yfe(t,r,e);if(t.type===L.map)return Qfe(t,r,e);if(t.type===L.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=U1(r,e);return e.tags[t.value](n)}throw new Error(`${ye} tag not supported (${t.value})`)}throw new Error("unsupported")}function $n(r,e){if(!(r instanceof Uint8Array))throw new Error(`${ye} data to decode must be a Uint8Array`);e=Object.assign({},jfe,e);let t=e.tokenizer||new nv(r,e),n=U1(t,e);if(n===M1)throw new Error(`${ye} did not find any content to decode`);if(n===Z3)throw new Error(`${ye} got unexpected break`);if(!t.done())throw new Error(`${ye} too many terminals, data makes no sense`);return n}var OO=42;function Xfe(r){if(r.asCID!==r&&r["/"]!==r.bytes)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 Q(L.tag,OO),new Q(L.bytes,t)]}function Zfe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Jfe(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 ehe={float64:!0,typeEncoders:{Object:Xfe,undefined:Zfe,number:Jfe}};function the(r){if(r[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return A.decode(r.subarray(1))}var LO={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};LO.tags[OO]=the;var rhe="dag-cbor",F1=113,V1=r=>to(r,ehe),hf=r=>$n(r,LO);var Ud={};Re(Ud,{code:()=>lv,decode:()=>hhe,encode:()=>fhe,name:()=>lhe});u();u();u();var Bd=({name:r,code:e,encode:t})=>new iv(r,e,t),iv=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?Xo(this.code,t):t.then(n=>Xo(this.code,n))}else throw Error("Unknown type, must be binary type")}};u();u();u();var sv=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(`${Ja} unsupported type: Uint8Array`)}[L.string.major](e,t){this.prefix(e);let n=q3(JSON.stringify(t.value));e.push(n.length>32?k1(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(`${Ja} 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 nhe(r,e){if(Array.isArray(r[0])||Array.isArray(e[0]))throw new Error(`${Ja} 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(`${Ja} non-string map keys are not supported`);if(t<n)return-1;if(t>n)return 1;throw new Error(`${Ja} unexpected duplicate map keys, this is not supported`)}var ihe={addBreakTokens:!0,mapSorter:nhe};function ov(r,e){return e=Object.assign({},ihe,e),rv(r,new sv,e)}u();var Md=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(`${ye} 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(`${ye} 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 Q(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(`${ye} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${ye} 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 Q(L.float,o,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(o)?new Q(o>=0?L.uint:L.negint,o,this.pos-e):new Q(o>=0?L.uint:L.negint,BigInt(s),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${ye} 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 Q(L.string,c,o)}}let e=this.pos,t=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${ye} 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(`${ye} 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(`${ye} 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(`${ye} 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(`${ye} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new Q(L.string,Q_(t),this.pos-e);default:if(s<32)throw new Error(`${ye} invalid control character at position ${this.pos}`);s<128?(t.push(s),this.pos++):i()}}throw new Error(`${ye} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new Q(L.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new Q(L.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new Q(L.null,null,4);case 102:return this.expect([102,97,108,115,101]),new Q(L.false,!1,5);case 116:return this.expect([116,114,117,101]),new Q(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(`${ye} 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 Q(L.break,void 0,1);if(this.ch()!==44)throw new Error(`${ye} 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 Q(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 Q(L.break,void 0,1);if(this.ch()!==44)throw new Error(`${ye} 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 Q(L.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${ye} 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(`${ye} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function av(r,e){return e=Object.assign({tokenizer:new Md(r,e)},e),$n(r,e)}function ohe(r){if(r.asCID!==r&&r["/"]!==r.bytes)return null;let e=A.asCID(r);if(!e)return null;let t=e.toString();return[new Q(L.map,1/0,1),new Q(L.string,"/",1),new Q(L.string,t,t.length),new Q(L.break,void 0,1)]}function MO(r){let e=Go.encode(r).slice(1);return[new Q(L.map,1/0,1),new Q(L.string,"/",1),new Q(L.map,1/0,1),new Q(L.string,"bytes",5),new Q(L.string,e,e.length),new Q(L.break,void 0,1),new Q(L.break,void 0,1)]}function ahe(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function che(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 uhe={typeEncoders:{Object:ohe,Uint8Array:MO,Buffer:MO,undefined:ahe,number:che}},cv=class extends Md{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 Q(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=Go.decode(`m${s.value}`);return new Q(L.bytes,o,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(i)}this.tokenBuffer.push(n)}this.tokenBuffer.push(t)}return e}},uv={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};uv.tags[42]=A.parse;var lhe="dag-json",lv=297,fhe=r=>ov(r,uhe),hhe=r=>{let e=Object.assign(uv,{tokenizer:new cv(r,uv)});return av(r,e)};var K1={};Re(K1,{code:()=>bhe,decode:()=>xhe,encode:()=>She,name:()=>Ehe,toGeneral:()=>GO});u();u();u();function ro(r){return mu.encode(r).slice(1)}function bs(r){return mu.decode(`u${r}`)}function UO(r){let[e,t,n]=r;return{payload:t,signatures:[{protected:e,signature:n}],link:A.decode(bs(t))}}function dhe(r){let e={signature:bs(r.signature)};return r.header&&(e.header=r.header),r.protected&&(e.protected=bs(r.protected)),e}function FO(r){let e=bs(r.payload);try{A.decode(e)}catch{throw new Error("Not a valid DagJWS")}return{payload:e,signatures:r.signatures.map(dhe)}}function phe(r){let e={signature:ro(r.signature)};return r.header&&(e.header=r.header),r.protected&&(e.protected=ro(r.protected)),e}function VO(r){let e={payload:ro(r.payload),signatures:r.signatures.map(phe)};return e.link=A.decode(new Uint8Array(r.payload)),e}u();function KO(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 yhe(r){let e={};return r.encrypted_key&&(e.encrypted_key=bs(r.encrypted_key)),r.header&&(e.header=r.header),e}function zO(r){let e={ciphertext:bs(r.ciphertext),protected:bs(r.protected),iv:bs(r.iv),tag:bs(r.tag)};return r.aad&&(e.aad=bs(r.aad)),r.recipients&&(e.recipients=r.recipients.map(yhe)),r.unprotected&&(e.unprotected=r.unprotected),e}function ghe(r){let e={};return r.encrypted_key&&(e.encrypted_key=ro(r.encrypted_key)),r.header&&(e.header=r.header),e}function qO(r){let e={ciphertext:ro(r.ciphertext),protected:ro(r.protected),iv:ro(r.iv),tag:ro(r.tag)};return r.aad&&(e.aad=ro(r.aad)),r.recipients&&(e.recipients=r.recipients.map(ghe)),r.unprotected&&(e.unprotected=r.unprotected),e}var Ehe="dag-jose",bhe=133;function $O(r){return"payload"in r&&typeof r.payload=="string"&&"signatures"in r&&Array.isArray(r.signatures)}function _he(r){return"payload"in r&&r.payload instanceof Uint8Array&&"signatures"in r&&Array.isArray(r.signatures)}function vhe(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 HO(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 GO(r){if(typeof r=="string"){let e=r.split(".");if(e.length===3)return UO(e);if(e.length===5)return KO(e);throw new Error("Not a valid JOSE string")}if($O(r)||HO(r))return r;throw new Error("Not a valid unencoded JOSE object")}function She(r){typeof r=="string"&&(r=GO(r));let e;if($O(r))e=FO(r);else if(HO(r))e=zO(r);else throw new Error("Not a valid JOSE object");return new Uint8Array(V1(e))}function xhe(r){let e;try{e=hf(r)}catch{throw new Error("Not a valid DAG-JOSE object")}if(_he(e))return VO(e);if(vhe(e))return qO(e);throw new Error("Not a valid DAG-JOSE object")}var fv={};Re(fv,{identity:()=>rn});u();var WO=0,The="identity",jO=ys,Ihe=r=>Xo(WO,jO(r)),rn={code:WO,name:The,encode:jO,digest:Ihe};u();var hv={};Re(hv,{identity:()=>Ahe});u();var Ahe=Sd({prefix:"\0",name:"identity",encode:r=>p_(r),decode:r=>d_(r)});var dv={};Re(dv,{base2:()=>Rhe});u();var Rhe=Pr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pv={};Re(pv,{base8:()=>Che});u();var Che=Pr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mv={};Re(mv,{base10:()=>Dhe});u();var Dhe=pu({prefix:"9",name:"base10",alphabet:"0123456789"});var yv={};Re(yv,{base16:()=>Phe,base16upper:()=>khe});u();var Phe=Pr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),khe=Pr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gv={};Re(gv,{base36:()=>Fd,base36upper:()=>Nhe});u();var Fd=pu({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Nhe=pu({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var wv={};Re(wv,{base256emoji:()=>Uhe});u();var YO=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}"),Ohe=YO.reduce((r,e,t)=>(r[t]=e,r),[]),Lhe=YO.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Bhe(r){return r.reduce((e,t)=>(e+=Ohe[t],e),"")}function Mhe(r){let e=[];for(let t of r){let n=Lhe[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Uhe=Sd({prefix:"\u{1F680}",name:"base256emoji",encode:Bhe,decode:Mhe});var Ev={};Re(Ev,{sha256:()=>Ke,sha512:()=>Fhe});u();var QO=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Ke=Bd({name:"sha2-256",code:18,encode:QO("SHA-256")}),Fhe=Bd({name:"sha2-512",code:19,encode:QO("SHA-512")});var mi={};Re(mi,{code:()=>xn,decode:()=>zhe,encode:()=>Khe,name:()=>Vhe});u();var Vhe="raw",xn=85,Khe=r=>ys(r),zhe=r=>ys(r);var e4={};Re(e4,{code:()=>bv,decode:()=>Whe,encode:()=>Ghe,name:()=>Hhe});u();var qhe=new TextEncoder,$he=new TextDecoder,Hhe="json",bv=512,Ghe=r=>qhe.encode(JSON.stringify(r)),Whe=r=>JSON.parse($he.decode(r));var _s={...hv,...dv,...pv,...mv,...yv,...v_,...gv,...E_,...S_,...wv},t4={...Ev,...fv},r4={raw:mi,json:e4};u();u();var rc=class extends Error{constructor(e="not initialized"){super(e),this.name="NotInitializedError",this.code=rc.code}};rc.code="ERR_NOT_INITIALIZED";var _v=class extends Error{constructor(e="cannot initialize an initializing node"){super(e),this.name="AlreadyInitializingError",this.code=no.code}};_v.code="ERR_ALREADY_INITIALIZING";var no=class extends Error{constructor(e="cannot re-initialize an initialized node"){super(e),this.name="AlreadyInitializedError",this.code=no.code}};no.code="ERR_ALREADY_INITIALIZED";var nc=class extends Error{constructor(e="not started"){super(e),this.name="NotStartedError",this.code=nc.code}};nc.code="ERR_NOT_STARTED";var df=class extends Error{constructor(e="cannot start, already startin"){super(e),this.name="AlreadyStartingError",this.code=df.code}};df.code="ERR_ALREADY_STARTING";var pf=class extends Error{constructor(e="cannot start, already started"){super(e),this.name="AlreadyStartedError",this.code=pf.code}};pf.code="ERR_ALREADY_STARTED";var io=class extends Error{constructor(e="not enabled"){super(e),this.name="NotEnabledError",this.code=io.code}};io.code="ERR_NOT_ENABLED";u();u();u();u();function ic(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function sc(r=0){return globalThis.Buffer?.alloc!=null?ic(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function so(r=0){return globalThis.Buffer?.allocUnsafe!=null?ic(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function ZO(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var XO=ZO("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),vv=ZO("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=so(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),jhe={utf8:XO,"utf-8":XO,hex:_s.base16,latin1:vv,ascii:vv,binary:vv,..._s},n4=jhe;function z(r,e="utf8"){let t=n4[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ic(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Xce=_(pn(),1);u();u();u();u();u();u();u();u();u();u();var iL="[a-fA-F\\d:]",_u=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${iL})|(?<=${iL})(?=\\s|$))`:"",oo="(?: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}",nn="[a-fA-F\\d]{1,4}",s4=`
(?:
(?:${nn}:){7}(?:${nn}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:${nn}:){6}(?:${oo}|:${nn}|:)| // 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
(?:${nn}:){5}(?::${oo}|(?::${nn}){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
(?:${nn}:){4}(?:(?::${nn}){0,1}:${oo}|(?::${nn}){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
(?:${nn}:){3}(?:(?::${nn}){0,2}:${oo}|(?::${nn}){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
(?:${nn}:){2}(?:(?::${nn}){0,3}:${oo}|(?::${nn}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:${nn}:){1}(?:(?::${nn}){0,4}:${oo}|(?::${nn}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::${nn}){0,5}:${oo}|(?::${nn}){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(),Xhe=new RegExp(`(?:^${oo}$)|(?:^${s4}$)`),Zhe=new RegExp(`^${oo}$`),Jhe=new RegExp(`^${s4}$`),xv=r=>r&&r.exact?Xhe:new RegExp(`(?:${_u(r)}${oo}${_u(r)})|(?:${_u(r)}${s4}${_u(r)})`,"g");xv.v4=r=>r&&r.exact?Zhe:new RegExp(`${_u(r)}${oo}${_u(r)}`,"g");xv.v6=r=>r&&r.exact?Jhe:new RegExp(`${_u(r)}${s4}${_u(r)}`,"g");var o4=xv;u();u();function Tv(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function sL(){return!1}u();u();u();var{toString:ede}=Object.prototype;function Iv(r){return ede.call(r)==="[object RegExp]"}var oL={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Av(r,e={}){if(!Iv(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(oL).map(i=>(typeof e[i]=="boolean"?e[i]:r[i])?oL[i]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function a4(r,e,{timeout:t}={}){try{return Tv(()=>Av(r).test(e),{timeout:t})()}catch(n){if(sL(n))return!1;throw n}}var tde=15,aL=45,Rv={timeout:400};function c4(r){return a4(o4({exact:!0}),r.slice(0,aL),Rv)}function cL(r){return a4(o4.v6({exact:!0}),r.slice(0,aL),Rv)}function uL(r){return a4(o4.v4({exact:!0}),r.slice(0,tde),Rv)}u();function K(r,e="utf8"){let t=n4[e];if(t==null)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 lL=uL,rde=cL,Cv=function(r){let e=0;if(r=r.toString().trim(),lL(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(rde(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=lL(t[n]),o;s&&(o=Cv(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")},fL=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 $1={},Dv={},ide=[[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"]];ide.forEach(r=>{let e=sde(...r);Dv[e.code]=e,$1[e.name]=e});function sde(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:Boolean(n),path:Boolean(i)}}function Ht(r){if(typeof r=="number"){if(Dv[r]!=null)return Dv[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if($1[r]!=null)return $1[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ea=_(Jo(),1);u();function De(r,e){e==null&&(e=r.reduce((i,s)=>i+s.length,0));let t=so(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return ic(t)}function SL(r,e){switch(Ht(r).code){case 4:case 41:return bde(e);case 6:case 273:case 33:case 132:return TL(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return vde(e);case 421:return Ide(e);case 444:return vL(e);case 445:return vL(e);case 466:return Tde(e);default:return K(e,"base16")}}function xL(r,e){switch(Ht(r).code){case 4:return _L(e);case 41:return _L(e);case 6:case 273:case 33:case 132:return Ov(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return _de(e);case 421:return Sde(e);case 444:return Ade(e);case 445:return Rde(e);case 466:return xde(e);default:return z(e,"base16")}}var Nv=Object.values(_s).map(r=>r.decoder),Ede=function(){let r=Nv[0].or(Nv[1]);return Nv.slice(2).forEach(e=>r=r.or(e)),r}();function _L(r){if(!c4(r))throw new Error("invalid ip address");return Cv(r)}function bde(r){let e=fL(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!c4(e))throw new Error("invalid ip address");return e}function Ov(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function TL(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function _de(r){let e=z(r),t=Uint8Array.from(ea.default.encode(e.length));return De([t,e],t.length+e.length)}function vde(r){let e=ea.default.decode(r);if(r=r.slice(ea.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return K(r)}function Sde(r){let e;r[0]==="Q"||r[0]==="1"?e=Jt(Ce.decode(`z${r}`)).bytes:e=A.parse(r).multihash.bytes;let t=Uint8Array.from(ea.default.encode(e.length));return De([t,e],t.length+e.length)}function xde(r){let e=Ede.decode(r),t=Uint8Array.from(ea.default.encode(e.length));return De([t,e],t.length+e.length)}function Tde(r){let e=ea.default.decode(r),t=r.slice(ea.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+K(t,"base64url")}function Ide(r){let e=ea.default.decode(r),t=r.slice(ea.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return K(t,"base58btc")}function Ade(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=dt.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=Ov(n);return De([t,i],t.length+i.length)}function Rde(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=dt.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=Ov(n);return De([t,i],t.length+i.length)}function vL(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=K(e,"base32"),i=TL(t);return`${n}:${i}`}var Vd=_(Jo(),1);function Cde(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=Ht(i);if(s.size===0){e.push([i]);continue}if(n++,n>=t.length)throw AL("invalid address: "+r);if(s.path===!0){e.push([i,Fv(t.slice(n).join("/"))]);break}e.push([i,t[n]])}return e}function Dde(r){let e=[];return r.map(t=>{let n=f4(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Fv(e.join("/"))}function Pde(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=f4(e);return e.length>1?[t.code,xL(t.code,e[1])]:[t.code]})}function Lv(r){return r.map(e=>{let t=f4(e);return e[1]!=null?[t.code,SL(t.code,e[1])]:[t.code]})}function Bv(r){return l4(De(r.map(e=>{let t=f4(e),n=Uint8Array.from(Vd.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=De([n,e[1]])),n})))}function Mv(r,e){return r.size>0?r.size/8:r.size===0?0:Vd.default.decode(e)+Vd.default.decode.bytes}function u4(r){let e=[],t=0;for(;t<r.length;){let n=Vd.default.decode(r,t),i=Vd.default.decode.bytes,s=Ht(n),o=Mv(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 AL("Invalid address Uint8Array: "+K(r,"base16"));e.push([n,a])}return e}function Uv(r){let e=u4(r),t=Lv(e);return Dde(t)}function kde(r){r=Fv(r);let e=Cde(r),t=Pde(e);return Bv(t)}function IL(r){return kde(r)}function l4(r){let e=Nde(r);if(e!=null)throw e;return Uint8Array.from(r)}function Nde(r){try{u4(r)}catch(e){return e}}function Fv(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function AL(r){return new Error("Error parsing address: "+r)}function f4(r){return Ht(r[0])}var Kv=_(Jo(),1);var DL=_(V(),1);u();function Be(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 Kd=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)},Vv=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},H1,G1,W1,RL,Lde=Symbol.for("nodejs.util.inspect.custom"),CL=[Ht("dns").code,Ht("dns4").code,Ht("dns6").code,Ht("dnsaddr").code],Bde=[Ht("p2p").code,Ht("ipfs").code],zv=new Map,PL=Symbol.for("@multiformats/js-multiaddr/multiaddr");function kL(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 ta("/"+[t,r.address,e,r.port].join("/"))}function NL(r){return oc(r)?r.protos().some(e=>e.resolvable):!1}function oc(r){return Boolean(r?.[PL])}var ta=class{constructor(e){if(H1.set(this,void 0),G1.set(this,void 0),W1.set(this,void 0),this[RL]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=l4(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=IL(e)}else if(oc(e))this.bytes=l4(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Kd(this,H1,"f")==null&&Vv(this,H1,Uv(this.bytes),"f"),Kd(this,H1,"f")}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),t=this.toString().split("/").slice(1),n,i;if(t.length>2)CL.includes(e[0])&&Bde.includes(e[1])?(n=Ht("tcp").name,i=443):(n=Ht(t[2]).name,i=parseInt(t[3]));else if(CL.includes(e[0]))n=Ht("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({},Ht(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let i=Kv.default.decode(t,n),s=Kv.default.decode.bytes,o=Ht(i),a=Mv(o,t.slice(n+s));n+=a+s,e.push(i)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Kd(this,G1,"f")==null&&Vv(this,G1,u4(this.bytes),"f"),Kd(this,G1,"f")}stringTuples(){return Kd(this,W1,"f")==null&&Vv(this,W1,Lv(this.tuples()),"f"),Kd(this,W1,"f")}encapsulate(e){return e=new ta(e),new ta(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 ta(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 ta(Bv(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===$1.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?K(Ce.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=>Ht(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return Be(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=zv.get(t.name);if(n==null)throw(0,DL.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new ta(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)}[(H1=new WeakMap,G1=new WeakMap,W1=new WeakMap,RL=PL,Lde)](){return this.inspect()}inspect(){return"<Multiaddr "+K(this.bytes,"base16")+" - "+Uv(this.bytes)+">"}};function ee(r){return new ta(r)}u();var Mde=Me("dns4"),Ude=Me("dns6"),Fde=Me("dnsaddr"),xu=Hn(Me("dns"),Fde,Mde,Ude),h4=Hn(Me("ip4"),Me("ip6")),Y1=Hn(Je(h4,Me("tcp")),Je(xu,Me("tcp"))),LL=Je(h4,Me("udp")),Vde=Je(LL,Me("utp")),Kde=Je(LL,Me("quic")),yf=Hn(Je(Y1,Me("ws")),Je(xu,Me("ws"))),Su=Hn(Je(Y1,Me("wss")),Je(xu,Me("wss"))),qv=Hn(Je(Y1,Me("http")),Je(h4,Me("http")),Je(xu,Me("http"))),$v=Hn(Je(Y1,Me("https")),Je(h4,Me("https")),Je(xu,Me("https"))),d4=Hn(Je(yf,Me("p2p-webrtc-star"),Me("p2p")),Je(Su,Me("p2p-webrtc-star"),Me("p2p")),Je(yf,Me("p2p-webrtc-star")),Je(Su,Me("p2p-webrtc-star"))),MNe=Hn(Je(yf,Me("p2p-websocket-star"),Me("p2p")),Je(Su,Me("p2p-websocket-star"),Me("p2p")),Je(yf,Me("p2p-websocket-star")),Je(Su,Me("p2p-websocket-star"))),BL=Hn(Je(qv,Me("p2p-webrtc-direct"),Me("p2p")),Je($v,Me("p2p-webrtc-direct"),Me("p2p")),Je(qv,Me("p2p-webrtc-direct")),Je($v,Me("p2p-webrtc-direct"))),j1=Hn(yf,Su,qv,$v,d4,BL,Y1,Vde,Kde,xu),UNe=Hn(Je(j1,Me("p2p-stardust"),Me("p2p")),Je(j1,Me("p2p-stardust"))),vu=Hn(Je(j1,Me("p2p")),d4,BL,Me("p2p")),OL=Hn(Je(vu,Me("p2p-circuit"),vu),Je(vu,Me("p2p-circuit")),Je(Me("p2p-circuit"),vu),Je(j1,Me("p2p-circuit")),Je(Me("p2p-circuit"),j1),Me("p2p-circuit")),ML=()=>Hn(Je(OL,ML),OL),mf=ML(),p4=Hn(Je(mf,vu,mf),Je(vu,mf),Je(mf,vu),mf,vu),UL=p4;function FL(r){function e(t){let n;try{n=ee(t)}catch{return!1}let i=r(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return e}function Je(...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:FL(e),partialMatch:e}}function Hn(...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:FL(e),partialMatch:e}}function Me(r){let e=r;function t(i){let s;try{s=ee(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 GL=_(y4(),1);var g4=/^\/(ip[fn]s)\/([^/?#]+)/,WL=1,jL=2,YL=/^https?:\/\/([^/]+)\.(ip[fn]s)\.[^/?]+/;var Xde=/^(([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 w4(r){try{return ZL(r)?Boolean(A.parse(r)):r instanceof Uint8Array?Boolean(A.decode(r)):Boolean(A.asCID(r))}catch{return!1}}function QL(r,e,t=WL,n=jL){let i=JL(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===YL&&(o=o.toLowerCase()),w4(o)}function XL(r,e,t=WL,n=jL){let i=JL(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===YL){if(o=o.toLowerCase(),w4(o))return!0;try{!o.includes(".")&&o.includes("-")&&(o=o.replace(/--/g,"@").replace(/-/g,".").replace(/@/g,"-"));let{hostname:a}=new GL.URL(`http://${o}`);return Xde.test(a)}catch{return!1}}return!0}function ZL(r){return typeof r=="string"}function JL(r){return r instanceof Uint8Array?K(r,"base58btc"):ZL(r)?r:!1}var E4=r=>QL(r,g4)||XL(r,g4);var eB=r=>QL(r,g4),b4=r=>XL(r,g4);u();u();var v4=(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 ac="/",tB=new TextEncoder().encode(ac),S4=tB[0],ie=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]!==S4)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 ie(e.join(ac))}static random(){return new ie(v4().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new ie(e):typeof e.uint8Array=="function"?new ie(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=tB),this._buf[0]!==S4){let e=new Uint8Array(this._buf.byteLength+1);e.fill(S4,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===S4;)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 ie.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(ac).slice(1)}type(){return Zde(this.baseNamespace())}name(){return Jde(this.baseNamespace())}instance(e){return new ie(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(ac)||(e+=ac),e+=this.type(),new ie(e)}parent(){let e=this.list();return e.length===1?new ie(ac):new ie(e.slice(0,-1).join(ac))}child(e){return this.toString()===ac?e:e.toString()===ac?this:new ie(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 ie.withNamespaces([...this.namespaces(),...epe(e.map(t=>t.namespaces()))])}};function Zde(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function Jde(r){let e=r.split(":");return e[e.length-1]}function epe(r){return[].concat(...r)}var x4=_(V(),1);u();var iB=_(pn(),1),sB=_(ri(),1);u();var tpe=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/uig;nt.nanosecond=nt.ns=1/1e6;nt.\u00B5s=nt.\u03BCs=nt.us=nt.microsecond=1/1e3;nt.millisecond=nt.ms=nt[""]=1;nt.second=nt.sec=nt.s=nt.ms*1e3;nt.minute=nt.min=nt.m=nt.s*60;nt.hour=nt.hr=nt.h=nt.m*60;nt.day=nt.d=nt.h*24;nt.week=nt.wk=nt.w=nt.d*7;nt.month=nt.b=nt.d*(365.25/12);nt.year=nt.yr=nt.y=nt.d*365.25;function nt(r="",e="ms"){var t=null;return r=(r+"").replace(/(\d)[,_](\d)/g,"$1$2"),r.replace(tpe,function(n,i,s){s=nB(s),s&&(t=(t||0)+parseFloat(i,10)*s)}),t&&t/(nB(e)||1)}function nB(r){return nt[r]||nt[r.toLowerCase().replace(/s$/,"")]}var Tu=nt;u();var cc=class extends Error{constructor(e="request timed out"){super(e),this.name="TimeoutError",this.code=cc.code}};cc.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"?Tu(n.timeout):n.timeout,s=new iB.TimeoutController(i);n.signal=(0,sB.anySignal)([n.signal,s.signal]);let o=r(...t),a=new Promise((f,h)=>{s.signal.addEventListener("abort",()=>{h(new cc)})}),c=Date.now(),l=()=>{if(s.signal.aborted)throw new cc;if(Date.now()-c>i)throw s.abort(),new cc};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 jv=_(V(),1),oB="/ipfs/";function uc(r){if(r instanceof Uint8Array)try{r=A.decode(r)}catch(i){throw(0,jv.default)(i,"ERR_INVALID_CID")}let e=A.asCID(r);if(e)return{cid:e,path:void 0};r=r.toString(),r.startsWith(oB)&&(r=r.substring(oB.length));let t=r.split("/"),n;try{e=A.parse(t.shift()||"")}catch(i){throw(0,jv.default)(i,"ERR_INVALID_CID")}return t.length&&(n=`/${t.join("/")}`),{cid:e,path:n}}var rpe="ERR_BAD_PATH",T4="This command must be run in online mode. Try running 'ipfs daemon' first.",X1=new ie("/local/filesroot"),Z1=262144;var aB=r=>{if(A.asCID(r))return`/ipfs/${r}`;let t=r.toString();try{return`/ipfs/${A.parse(t)}`}catch{}if(E4(t))return t;throw(0,x4.default)(new Error(`invalid path: ${r}`),rpe)},zd=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),Iu=async function(r,e,t,n={}){let{cid:i,path:s}=uc(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 Au(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||""}},Yv=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},cB=M(async(r,e)=>await r),Au=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,x4.default)(new Error(`Could not resolve path "${e}"`),"ERR_INVALID_PATH");if(r.code===rt&&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,x4.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 Gn=class{static create({start:e,stop:t}){return new Gn(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 df;case"started":throw new pf;case"stopping":return await n.ready,await Gn.start(e,t);default:return Gn.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 Gn.stop(e)}case"stopping":return await t.ready;case"started":{n&&await n(t.value),e.state={status:"stopped"};break}default:Gn.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 cB(e.ready,t);default:throw new nc}}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 Gn.use(this,e)}try(){return Gn.try(this)}};function uB({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 Gn.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 lB({network:r,preload:e,ipns:t,repo:n,mfsPreload:i}){return async()=>{await Promise.all([e.stop(),t.stop(),i.stop()]),await Gn.stop(r),await n.close()}}u();u();u();var hB=_(qd(),1),I4=class{constructor(e){this.lru=(0,hB.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 vB=_(Ru(),1);u();var em=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Xv=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},pB=r=>globalThis.DOMException===void 0?new Xv(r):new DOMException(r),mB=r=>{let e=r.reason===void 0?pB("This operation was aborted."):r.reason;return e instanceof Error?e:pB(e)};function Zv(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(mB(c)),c.addEventListener("abort",()=>{a(mB(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 em(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 Jv(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 gf=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)},lc,tm=class{constructor(){lc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&gf(this,lc,"f")[this.size-1].priority>=t.priority){gf(this,lc,"f").push(n);return}let i=Jv(gf(this,lc,"f"),n,(s,o)=>o.priority-s.priority);gf(this,lc,"f").splice(i,0,n)}dequeue(){let e=gf(this,lc,"f").shift();return e?.run}filter(e){return gf(this,lc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return gf(this,lc,"f").length}};lc=new WeakMap;var br=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},ge=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)},$r,nm,im,Du,N4,sm,R4,ao,rm,Oi,C4,Li,om,Cu,D4,yB,gB,_B,wB,EB,bB,P4,e9,t9,O4,k4,spe=new em,r9=class extends Error{},co=class extends vB.default{constructor(e){var t,n,i,s;if(super(),$r.add(this),nm.set(this,void 0),im.set(this,void 0),Du.set(this,0),N4.set(this,void 0),sm.set(this,void 0),R4.set(this,0),ao.set(this,void 0),rm.set(this,void 0),Oi.set(this,void 0),C4.set(this,void 0),Li.set(this,0),om.set(this,void 0),Cu.set(this,void 0),D4.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:tm,...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})`);br(this,nm,e.carryoverConcurrencyCount,"f"),br(this,im,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),br(this,N4,e.intervalCap,"f"),br(this,sm,e.interval,"f"),br(this,Oi,new e.queueClass,"f"),br(this,C4,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,br(this,D4,e.throwOnTimeout===!0,"f"),br(this,Cu,e.autoStart===!1,"f")}get concurrency(){return ge(this,om,"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})`);br(this,om,e,"f"),ge(this,$r,"m",O4).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;br(this,Li,(a=ge(this,Li,"f"),a++,a),"f"),br(this,Du,(c=ge(this,Du,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new r9("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):Zv(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?ge(this,D4,"f"):t.throwOnTimeout)&&i(spe)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}ge(this,$r,"m",_B).call(this)};ge(this,Oi,"f").enqueue(s,t),ge(this,$r,"m",P4).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return ge(this,Cu,"f")?(br(this,Cu,!1,"f"),ge(this,$r,"m",O4).call(this),this):this}pause(){br(this,Cu,!0,"f")}clear(){br(this,Oi,new(ge(this,C4,"f")),"f")}async onEmpty(){ge(this,Oi,"f").size!==0&&await ge(this,$r,"m",k4).call(this,"empty")}async onSizeLessThan(e){ge(this,Oi,"f").size<e||await ge(this,$r,"m",k4).call(this,"next",()=>ge(this,Oi,"f").size<e)}async onIdle(){ge(this,Li,"f")===0&&ge(this,Oi,"f").size===0||await ge(this,$r,"m",k4).call(this,"idle")}get size(){return ge(this,Oi,"f").size}sizeBy(e){return ge(this,Oi,"f").filter(e).length}get pending(){return ge(this,Li,"f")}get isPaused(){return ge(this,Cu,"f")}};nm=new WeakMap,im=new WeakMap,Du=new WeakMap,N4=new WeakMap,sm=new WeakMap,R4=new WeakMap,ao=new WeakMap,rm=new WeakMap,Oi=new WeakMap,C4=new WeakMap,Li=new WeakMap,om=new WeakMap,Cu=new WeakMap,D4=new WeakMap,$r=new WeakSet,yB=function(){return ge(this,im,"f")||ge(this,Du,"f")<ge(this,N4,"f")},gB=function(){return ge(this,Li,"f")<ge(this,om,"f")},_B=function(){var e;br(this,Li,(e=ge(this,Li,"f"),e--,e),"f"),ge(this,$r,"m",P4).call(this),this.emit("next")},wB=function(){this.emit("empty"),ge(this,Li,"f")===0&&this.emit("idle")},EB=function(){ge(this,$r,"m",t9).call(this),ge(this,$r,"m",e9).call(this),br(this,rm,void 0,"f")},bB=function(){let e=Date.now();if(ge(this,ao,"f")===void 0){let t=ge(this,R4,"f")-e;if(t<0)br(this,Du,ge(this,nm,"f")?ge(this,Li,"f"):0,"f");else return ge(this,rm,"f")===void 0&&br(this,rm,setTimeout(()=>{ge(this,$r,"m",EB).call(this)},t),"f"),!0}return!1},P4=function(){if(ge(this,Oi,"f").size===0)return ge(this,ao,"f")&&clearInterval(ge(this,ao,"f")),br(this,ao,void 0,"f"),ge(this,$r,"m",wB).call(this),!1;if(!ge(this,Cu,"f")){let e=!ge(this,$r,"a",bB);if(ge(this,$r,"a",yB)&&ge(this,$r,"a",gB)){let t=ge(this,Oi,"f").dequeue();return t?(this.emit("active"),t(),e&&ge(this,$r,"m",e9).call(this),!0):!1}}return!1},e9=function(){ge(this,im,"f")||ge(this,ao,"f")!==void 0||(br(this,ao,setInterval(()=>{ge(this,$r,"m",t9).call(this)},ge(this,sm,"f")),"f"),br(this,R4,Date.now()+ge(this,sm,"f"),"f"))},t9=function(){ge(this,Du,"f")===0&&ge(this,Li,"f")===0&&ge(this,ao,"f")&&(clearInterval(ge(this,ao,"f")),br(this,ao,void 0,"f")),br(this,Du,ge(this,nm,"f")?ge(this,Li,"f"):0,"f"),ge(this,$r,"m",O4).call(this)},O4=function(){for(;ge(this,$r,"m",P4).call(this););},k4=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var MB=_(Hd(),1),f9=new I4(1e3),Tpe=60*1e3,Ipe=co.default?co.default:co,Ape=new Ipe({concurrency:4}),BB=r=>{if(r.Path)return r.Path;throw new Error(r.Message)};async function UB(r,e){return(async(n,i={})=>{let s=new URLSearchParams(i);s.set("arg",n);let o=s.toString();if(!i.nocache&&f9.has(o)){let c=f9.get(o);return BB(c)}let a=await Ape.add(async()=>{let c=await MB.default.get("https://ipfs.io/api/v0/dns",{searchParams:s}),l=new URL(c.url).search.slice(1),f=await c.json();return f9.set(l,f,Tpe),f});return BB(a)})(r,e)}function Rpe(r){return r.endsWith(".eth")&&(r=r.replace(/.eth$/,".eth.link")),r}function FB(){return M(async(e,t={recursive:!0})=>{if(typeof e!="string")throw new Error("Invalid arguments, domain must be a string");return e=Rpe(e),UB(e,t)})}u();function VB({network:r}){return()=>{let e=r.try();return e!=null&&Boolean(e.libp2p.isStarted())}}u();u();var zB=_(V(),1);u();var h9=Symbol.for("@libp2p/peer-id");function vs(r){return r!=null&&Boolean(r[h9])}var KB=Object.values(_s).map(r=>r.decoder).reduce((r,e)=>r.or(e),_s.identity.decoder),qB=114,d9=36,p9=37,cm=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[h9](){return!0}toString(){return this.string==null&&(this.string=Ce.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return A.createV1(qB,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Be(this.multihash.bytes,e);if(typeof e=="string")return ce(e).equals(this);if(e?.multihash?.bytes!=null)return Be(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}},wf=class extends cm{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},Ef=class extends cm{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},bf=class extends cm{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function Hr(r){if(r.type==="RSA")return new wf(r);if(r.type==="Ed25519")return new Ef(r);if(r.type==="secp256k1")return new bf(r);throw(0,zB.default)(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function ce(r,e){if(e=e??KB,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Jt(Ce.decode(`z${r}`));return r.startsWith("12D")?new Ef({multihash:t}):r.startsWith("16U")?new bf({multihash:t}):new wf({multihash:t})}return _r(KB.decode(r))}function _r(r){try{let e=Jt(r);if(e.code===rn.code){if(e.digest.length===d9)return new Ef({multihash:e});if(e.digest.length===p9)return new bf({multihash:e})}if(e.code===Ke.code)return new wf({multihash:e})}catch{return Cpe(A.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Cpe(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==qB)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ke.code)return new wf({multihash:r.multihash});if(e.code===rn.code){if(e.digest.length===d9)return new Ef({multihash:r.multihash});if(e.digest.length===p9)return new bf({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function sn(r,e){return r.length===d9?new Ef({multihash:Xo(rn.code,r),privateKey:e}):r.length===p9?new bf({multihash:Xo(rn.code,r),privateKey:e}):new wf({multihash:await Ke.digest(r),publicKey:r,privateKey:e})}function $B({repo:r,codecs:e,bases:t,name:n}){async function i(s,o={}){if(!E4(s))throw new Error("invalid argument "+s);if(b4(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=Dpe(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=Au(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 Dpe(r){try{return ce(r).toBytes()}catch{return A.parse(r).bytes}}u();u();u();async function Xt(r){let e;for await(let t of r)e=t;return e}function HB({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),Xt(n)}}u();u();var Gd=_(V(),1);async function*ra(r){if(r==null)throw(0,Gd.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT");let e=A.asCID(r);if(e){yield uo({cid:e});return}if(r instanceof String||typeof r=="string"){yield uo({path:r});return}if(r.cid!=null||r.path!=null)return yield uo(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 uo({cid:n.value});for(let i of t)yield uo({cid:i});return}if(n.value.cid!=null||n.value.path!=null){yield uo(n.value);for(let i of t)yield uo(i);return}throw(0,Gd.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 uo({cid:n.value});for await(let i of t)yield uo({cid:i});return}if(n.value.cid!=null||n.value.path!=null){yield uo(n.value);for await(let i of t)yield uo(i);return}throw(0,Gd.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}throw(0,Gd.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}function uo(r){let e=r.cid||`${r.path}`;if(!e)throw(0,Gd.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 pt={direct:"direct",recursive:"recursive",indirect:"indirect",all:"all"};function GB({repo:r,codecs:e}){async function*t(n,i={}){let s=async function*(){for await(let{path:c,recursive:l,metadata:f}of ra(n)){let{cid:h}=await Iu(r,e,c),{reason:p}=await r.pins.isPinnedWithType(h,[pt.recursive,pt.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 m9=_(V(),1);function um(r,e,t){let n={type:r,cid:e};return t&&(n.metadata=t),n}function WB({repo:r,codecs:e}){async function*t(n={}){let i=pt.all;if(n.type&&(i=n.type,!Object.keys(pt).includes(i)))throw(0,m9.default)(new Error("Invalid pin type"),"ERR_INVALID_PIN_TYPE");if(n.paths){let s=!1;for await(let{path:o}of ra(n.paths)){let{cid:a}=await Iu(r,e,o),{reason:c,pinned:l,parent:f,metadata:h}=await r.pins.isPinnedWithType(a,i);if(!l)throw(0,m9.default)(new Error(`path '${o}' is not pinned`),"ERR_NOT_PINNED");switch(c){case pt.direct:case pt.recursive:s=!0,yield um(c,a,h);break;default:s=!0,yield um(`${pt.indirect} through ${f}`,a,h)}}if(!s)throw new Error("No match found");return}if(i===pt.recursive||i===pt.all)for await(let{cid:s,metadata:o}of r.pins.recursiveKeys())yield um(pt.recursive,s,o);if(i===pt.indirect||i===pt.all)for await(let s of r.pins.indirectKeys(n))yield um(pt.indirect,s);if(i===pt.direct||i===pt.all)for await(let{cid:s,metadata:o}of r.pins.directKeys())yield um(pt.direct,s,o)}return M(t)}u();function jB({rmAll:r}){async function e(t,n={}){let i=await Xt(r([{path:t,...n}],n));if(!i)throw new Error("CID expected");return i}return e}u();function YB({repo:r,codecs:e}){async function*t(n,i={}){let s=await r.gcLock.readLock();try{for await(let{path:o,recursive:a}of ra(n)){let{cid:c}=await Iu(r,e,o),{pinned:l,reason:f}=await r.pins.isPinnedWithType(c,pt.all);if(!l)throw new Error(`${c} is not pinned`);switch(f){case pt.recursive:if(!a)throw new Error(`${c} is pinned recursively`);await r.pins.unpin(c),yield c;break;case pt.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 B4=class{constructor({codecs:e,repo:t}){let n=GB({codecs:e,repo:t});this.addAll=n,this.add=HB({addAll:n});let i=YB({codecs:e,repo:t});this.rmAll=i,this.rm=jB({rmAll:i}),this.ls=WB({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 $F=_(V(),1);u();var Bi={};Re(Bi,{abortedError:()=>Ppe,dbDeleteFailedError:()=>U4,dbOpenFailedError:()=>M4,dbWriteFailedError:()=>F4,notFoundError:()=>mn});u();var Wd=_(V(),1);function M4(r){return r=r||new Error("Cannot open database"),(0,Wd.default)(r,"ERR_DB_OPEN_FAILED")}function U4(r){return r=r||new Error("Delete failed"),(0,Wd.default)(r,"ERR_DB_DELETE_FAILED")}function F4(r){return r=r||new Error("Write failed"),(0,Wd.default)(r,"ERR_DB_WRITE_FAILED")}function mn(r){return r=r||new Error("Not Found"),(0,Wd.default)(r,"ERR_NOT_FOUND")}function Ppe(r){return r=r||new Error("Aborted"),(0,Wd.default)(r,"ERR_ABORTED")}var As=_(V(),1);u();var NF=_(QB(),1);var w6={};Re(w6,{generateEphemeralKeyPair:()=>SU,generateKeyPair:()=>mp,generateKeyPairFromSeed:()=>o2e,importKey:()=>wc,keyStretcher:()=>gU,keysPBM:()=>Yd,marshalPrivateKey:()=>bS,marshalPublicKey:()=>Cm,supportedKeys:()=>fa,unmarshalPrivateKey:()=>Cn,unmarshalPublicKey:()=>Ei});u();var Yd={};Re(Yd,{KeyType:()=>ir,PrivateKey:()=>fo,PublicKey:()=>lo});u();u();u();u();var g9=_(U3(),1),XB=_(z_(),1),w9=_(B3(),1),ZB=_(F_(),1),JB=_(Ya(),1);function kpe(){JB.default._configure(),g9.default._configure(XB.default),w9.default._configure(ZB.default)}kpe();var eM=["uint64","int64","sint64","fixed64","sfixed64"];function Npe(r){for(let e of eM){if(r[e]==null)continue;let t=r[e];r[e]=function(){return BigInt(t.call(this).toString())}}return r}function E9(r){return Npe(new g9.default(r))}function Ope(r){for(let e of eM){if(r[e]==null)continue;let t=r[e];r[e]=function(n){return t.call(this,n.toString())}}return r}function b9(){return Ope(w9.default.create())}function ot(r,e){let t=E9(r instanceof Uint8Array?r:r.subarray());return e.decode(t)}u();function at(r,e){let t=b9();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}u();u();var jd;(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"})(jd||(jd={}));function V4(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Mi(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.int32();return e(o)};return V4("enum",jd.VARINT,t,n)}u();function ct(r,e){return V4("message",jd.LENGTH_DELIMITED,r,e)}var ir;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ir||(ir={}));var _9;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(_9||(_9={}));(function(r){r.codec=()=>Mi(_9)})(ir||(ir={}));var lo;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ir.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),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.Type=ir.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(lo||(lo={}));var fo;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ir.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),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.Type=ir.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(fo||(fo={}));var wFe=_(Nu(),1),EFe=_($9(),1),y6=_(ut(),1),g6=_(V(),1);u();var H9=_(V(),1);u();u();var Gr={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 dU={SHA1:20,SHA256:32,SHA512:64};var sme={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},ome=async(r,e)=>{let t=await Gr.get().subtle.sign({name:"HMAC"},r,e);return new Uint8Array(t,0,t.byteLength)};async function pU(r,e){let t=sme[r],n=await Gr.get().subtle.importKey("raw",e,{name:"HMAC",hash:{name:t}},!1,["sign"]);return{async digest(i){return await ome(n,i)},length:dU[r]}}var yU={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,keySize:32}};async function gU(r,e,t){let n=yU[r];if(n==null){let E=Object.keys(yU).join(" / ");throw(0,H9.default)(new Error(`unknown cipher type '${r}'. Must be ${E}`),"ERR_INVALID_CIPHER_TYPE")}if(e==null)throw(0,H9.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 pU(e,t),f=await l.digest(a),h=[],p=0;for(;p<c;){let E=await l.digest(De([f,a])),v=E.length;p+v>c&&(v=c-p),h.push(E),p+=v,f=await l.digest(f)}let d=c/2,m=De(h),y=m.slice(0,d),g=m.slice(d,c),w=E=>({iv:E.slice(0,s),cipherKey:E.slice(s,s+i),macKey:E.slice(s+i)});return{k1:w(y),k2:w(g)}}u();u();var rp=_(V(),1);u();var tUe=_(er(),1),rUe=_(t6(),1),wU=_(ut(),1);function mo(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=De([new Uint8Array(e-t.length),t])}return K(t,"base64url")}function Ui(r){let e=i6(r);return new wU.default.jsbn.BigInteger(K(e,"base16"),16)}function i6(r,e){let t=z(r,"base64urlpad");if(e!=null){if(t.length>e)throw new Error("byte array longer than desired length");t=De([new Uint8Array(e-t.length),t])}return t}var EU={"P-256":256,"P-384":384,"P-521":521},ame=Object.keys(EU),G9=ame.join(" / ");async function bU(r){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw(0,rp.default)(new Error(`Unknown curve: ${r}. Must be ${G9}`),"ERR_INVALID_CURVE");let e=await Gr.get().subtle.generateKey({name:"ECDH",namedCurve:r},!0,["deriveBits"]),t=async(s,o)=>{let a;o!=null?a=await Gr.get().subtle.importKey("jwk",ume(r,o),{name:"ECDH",namedCurve:r},!1,["deriveBits"]):a=e.privateKey;let c=await Gr.get().subtle.importKey("jwk",vU(r,s),{name:"ECDH",namedCurve:r},!1,[]),l=await Gr.get().subtle.deriveBits({name:"ECDH",namedCurve:r,public:c},a,EU[r]);return new Uint8Array(l,0,l.byteLength)},n=await Gr.get().subtle.exportKey("jwk",e.publicKey);return{key:cme(n),genSharedKey:t}}var _U={"P-256":32,"P-384":48,"P-521":66};function cme(r){if(r.crv==null||r.x==null||r.y==null)throw(0,rp.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,rp.default)(new Error(`Unknown curve: ${r.crv}. Must be ${G9}`),"ERR_INVALID_CURVE");let e=_U[r.crv];return De([Uint8Array.from([4]),i6(r.x,e),i6(r.y,e)],1+e*2)}function vU(r,e){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw(0,rp.default)(new Error(`Unknown curve: ${r}. Must be ${G9}`),"ERR_INVALID_CURVE");let t=_U[r];if(!Be(e.slice(0,1),Uint8Array.from([4])))throw(0,rp.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 ume=(r,e)=>({...vU(r,e.public),d:K(e.private,"base64url")});var SU=bU;u();u();function s6(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=Gr.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"]),E=await a.subtle.deriveKey(g,w,{name:e,length:t},!0,["encrypt"]),v=await a.subtle.encrypt(y,E,h);return De([d,y.iv,new Uint8Array(v)])}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}},E=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),v=await a.subtle.deriveKey(w,E,{name:e,length:t},!0,["decrypt"]),x=await a.subtle.decrypt(g,v,y);return new Uint8Array(x)}return{encrypt:c,decrypt:l}}async function TU(r,e){let t=Go.decode(r);return await s6().decrypt(t,e)}var iS={};Re(iS,{RsaPrivateKey:()=>lp,RsaPublicKey:()=>_m,fromJwk:()=>Ome,generateKeyPair:()=>Lme,unmarshalRsaPrivateKey:()=>kme,unmarshalRsaPublicKey:()=>Nme});u();var nS=_(V(),1);var JUe=_(DU(),1),bm=_(ut(),1);u();u();u();var fme=_(Lu(),1);var _t=BigInt(0),ar=BigInt(1),Uu=BigInt(2),gm=BigInt(3),hme=BigInt(8),fr=Object.freeze({a:_t,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:ar,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function PU(r){let{a:e,b:t}=fr,n=pe(r*r),i=pe(n*r);return pe(i+e*r+t)}var o6=fr.a===_t,c6=class extends Error{constructor(e){super(e)}},Ot=class{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Ft))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Ot(e.x,e.y,ar)}static toAffineBatch(e){let t=gme(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(t[i]))}static normalizeZ(e){return Ot.toAffineBatch(e).map(Ot.fromAffine)}equals(e){if(!(e instanceof Ot))throw new TypeError("JacobianPoint expected");let{x:t,y:n,z:i}=this,{x:s,y:o,z:a}=e,c=pe(i*i),l=pe(a*a),f=pe(t*l),h=pe(s*c),p=pe(pe(n*a)*l),d=pe(pe(o*i)*c);return f===h&&p===d}negate(){return new Ot(this.x,pe(-this.y),this.z)}double(){let{x:e,y:t,z:n}=this,i=pe(e*e),s=pe(t*t),o=pe(s*s),a=e+s,c=pe(Uu*(pe(a*a)-i-o)),l=pe(gm*i),f=pe(l*l),h=pe(f-Uu*c),p=pe(l*(c-h)-hme*o),d=pe(Uu*t*n);return new Ot(h,p,d)}add(e){if(!(e instanceof Ot))throw new TypeError("JacobianPoint expected");let{x:t,y:n,z:i}=this,{x:s,y:o,z:a}=e;if(s===_t||o===_t)return this;if(t===_t||n===_t)return e;let c=pe(i*i),l=pe(a*a),f=pe(t*l),h=pe(s*c),p=pe(pe(n*a)*l),d=pe(pe(o*i)*c),m=pe(h-f),y=pe(d-p);if(m===_t)return y===_t?this.double():Ot.ZERO;let g=pe(m*m),w=pe(m*g),E=pe(f*g),v=pe(y*y-w-Uu*E),x=pe(y*(E-v)-p*w),I=pe(i*a*m);return new Ot(v,x,I)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let t=Ot.ZERO;if(typeof e=="bigint"&&e===_t)return t;let n=OU(e);if(n===ar)return this;if(!o6){let h=t,p=this;for(;n>_t;)n&ar&&(h=h.add(p)),p=p.double(),n>>=ar;return h}let{k1neg:i,k1:s,k2neg:o,k2:a}=BU(n),c=t,l=t,f=this;for(;s>_t||a>_t;)s&ar&&(c=c.add(f)),a&ar&&(l=l.add(f)),f=f.double(),s>>=ar,a>>=ar;return i&&(c=c.negate()),o&&(l=l.negate()),l=new Ot(pe(l.x*fr.beta),l.y,l.z),c.add(l)}precomputeWindow(e){let t=o6?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(Ot.BASE)&&(t=Ft.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&&Q9.get(t);i||(i=this.precomputeWindow(n),t&&n!==1&&(i=Ot.normalizeZ(i),Q9.set(t,i)));let s=Ot.ZERO,o=Ot.ZERO,a=1+(o6?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+=ar),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=OU(e),i,s;if(o6){let{k1neg:o,k1:a,k2neg:c,k2:l}=BU(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 Ot(pe(p.x*fr.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 Ot.normalizeZ([i,s])[0]}toAffine(e=cp(this.z)){let{x:t,y:n,z:i}=this,s=e,o=pe(s*s),a=pe(o*s),c=pe(t*o),l=pe(n*a);if(pe(i*s)!==ar)throw new Error("invZ was invalid");return new Ft(c,l)}};Ot.BASE=new Ot(fr.Gx,fr.Gy,ar);Ot.ZERO=new Ot(_t,ar,_t);var Q9=new WeakMap,Ft=class{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Q9.delete(this)}hasEvenY(){return this.y%Uu===_t}static fromCompressedHex(e){let t=e.length===32,n=mc(t?e:e.subarray(1));if(!Y9(n))throw new Error("Point is not on curve");let i=PU(n),s=yme(i),o=(s&ar)===ar;t?o&&(s=pe(-s)):(e[0]&1)===1!==o&&(s=pe(-s));let a=new Ft(n,s);return a.assertValidity(),a}static fromUncompressedHex(e){let t=mc(e.subarray(1,33)),n=mc(e.subarray(33,65)),i=new Ft(t,n);return i.assertValidity(),i}static fromHex(e){let t=ap(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 Ft.BASE.multiply(l6(e))}static fromSignature(e,t,n){e=ap(e);let i=MU(e),{r:s,s:o}=UU(t);if(n!==0&&n!==1)throw new Error("Cannot recover signature: invalid recovery bit");let a=n&1?"03":"02",c=Ft.fromHex(a+ip(s)),{n:l}=fr,f=cp(s,l),h=pe(-i*f,l),p=pe(o*f,l),d=Ft.BASE.multiplyAndAddUnsafe(c,h,p);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(e=!1){return Af(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(!Y9(t)||!Y9(n))throw new Error(e);let i=pe(n*n),s=PU(t);if(pe(i-s)!==_t)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Ft(this.x,pe(-this.y))}double(){return Ot.fromAffine(this).double().toAffine()}add(e){return Ot.fromAffine(this).add(Ot.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ot.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){let i=Ot.fromAffine(this),s=t===_t||t===ar||this!==Ft.BASE?i.multiplyUnsafe(t):i.multiply(t),o=Ot.fromAffine(e).multiplyUnsafe(n),a=s.add(o);return a.equals(Ot.ZERO)?void 0:a.toAffine()}};Ft.BASE=new Ft(fr.Gx,fr.Gy);Ft.ZERO=new Ft(_t,_t);function kU(r){return Number.parseInt(r[0],16)>=8?"00"+r:r}function NU(r){if(r.length<2||r[0]!==2)throw new Error(`Invalid signature integer tag: ${op(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:mc(t),left:r.subarray(e+2)}}function dme(r){if(r.length<2||r[0]!=48)throw new Error(`Invalid signature tag: ${op(r)}`);if(r[1]!==r.length-2)throw new Error("Invalid signature: incorrect length");let{data:e,left:t}=NU(r.subarray(2)),{data:n,left:i}=NU(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${op(i)}`);return{r:e,s:n}}var ua=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?op(e):e;if(i.length!==128)throw new Error(`${n}: Expected 64-byte hex`);return new ua(u6(i.slice(0,64)),u6(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}=dme(t?e:Af(e));return new ua(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){let{r:e,s:t}=this;if(!Em(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Em(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){let e=fr.n>>ar;return this.s>e}normalizeS(){return this.hasHighS()?new ua(this.r,fr.n-this.s):this}toDERRawBytes(e=!1){return Af(this.toDERHex(e))}toDERHex(e=!1){let t=kU(ym(this.s));if(e)return t;let n=kU(ym(this.r)),i=ym(n.length/2),s=ym(t.length/2);return`30${ym(n.length/2+t.length/2+4)}02${i}${n}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Af(this.toCompactHex())}toCompactHex(){return ip(this.r)+ip(this.s)}};function np(...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 pme=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function op(r){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t<r.length;t++)e+=pme[r[t]];return e}var mme=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function ip(r){if(typeof r!="bigint")throw new Error("Expected bigint");if(!(_t<=r&&r<mme))throw new Error("Expected number < 2^256");return r.toString(16).padStart(64,"0")}function X9(r){let e=Af(ip(r));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function ym(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function u6(r){if(typeof r!="string")throw new TypeError("hexToNumber: expected string, got "+typeof r);return BigInt(`0x${r}`)}function Af(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 mc(r){return u6(op(r))}function ap(r){return r instanceof Uint8Array?Uint8Array.from(r):Af(r)}function OU(r){if(typeof r=="number"&&Number.isSafeInteger(r)&&r>0)return BigInt(r);if(typeof r=="bigint"&&Em(r))return r;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function pe(r,e=fr.P){let t=r%e;return t>=_t?t:e+t}function Ts(r,e){let{P:t}=fr,n=r;for(;e-- >_t;)n*=n,n%=t;return n}function yme(r){let{P:e}=fr,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=Ts(l,gm)*l%e,h=Ts(f,gm)*l%e,p=Ts(h,Uu)*c%e,d=Ts(p,n)*p%e,m=Ts(d,i)*d%e,y=Ts(m,o)*m%e,g=Ts(y,a)*y%e,w=Ts(g,o)*m%e,E=Ts(w,gm)*l%e,v=Ts(E,s)*d%e,x=Ts(v,t)*c%e;return Ts(x,Uu)}function cp(r,e=fr.P){if(r===_t||e<=_t)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=pe(r,e),n=e,i=_t,s=ar,o=ar,a=_t;for(;t!==_t;){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!==ar)throw new Error("invert: does not exist");return pe(i,e)}function gme(r,e=fr.P){let t=new Array(r.length),n=r.reduce((s,o,a)=>o===_t?s:(t[a]=s,pe(s*o,e)),ar),i=cp(n,e);return r.reduceRight((s,o,a)=>o===_t?s:(t[a]=pe(s*t[a],e),pe(s*o,e)),i),t}var LU=(r,e)=>(r+e/Uu)/e,wme={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-ar*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function BU(r){let{n:e}=fr,{a1:t,b1:n,a2:i,b2:s,POW_2_128:o}=wme,a=LU(s*r,e),c=LU(-n*r,e),l=pe(r-a*t-c*i,e),f=pe(-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 MU(r){let{n:e}=fr,n=r.length*8-256,i=mc(r);return n>0&&(i=i>>BigInt(n)),i>=e&&(i-=e),i}var sp,wm,Z9=class{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return yo.hmacSha256(this.k,...e)}hmacSync(...e){return wm(this.k,...e)}checkSync(){if(typeof wm!="function")throw new c6("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 Em(r){return _t<r&&r<fr.n}function Y9(r){return _t<r&&r<fr.P}function Eme(r,e,t){let n=mc(r);if(!Em(n))return;let{n:i}=fr,s=Ft.BASE.multiply(n),o=pe(s.x,i);if(o===_t)return;let a=pe(cp(n,i)*pe(e+t*o,i),i);if(a===_t)return;let c=new ua(o,a),l=(s.x===c.r?0:2)|Number(s.y&ar);return{sig:c,recovery:l}}function l6(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=u6(r)}else if(r instanceof Uint8Array){if(r.length!==32)throw new Error("Expected 32 bytes of private key");e=mc(r)}else throw new TypeError("Expected valid private key");if(!Em(e))throw new Error("Expected private key: 0 < key < n");return e}function bme(r){return r instanceof Ft?(r.assertValidity(),r):Ft.fromHex(r)}function UU(r){if(r instanceof ua)return r.assertValidity(),r;try{return ua.fromDER(r)}catch{return ua.fromCompact(r)}}function J9(r,e=!1){return Ft.fromPrivateKey(r).toRawBytes(e)}function FU(r){let e=r.length>32?r.slice(0,32):r;return mc(e)}function _me(r){let e=FU(r),t=pe(e,fr.n);return VU(t<_t?e:t)}function VU(r){return X9(r)}function vme(r,e,t){if(r==null)throw new Error(`sign: expected valid message hash, not "${r}"`);let n=ap(r),i=l6(e),s=[VU(i),_me(n)];if(t!=null){t===!0&&(t=yo.randomBytes(32));let c=ap(t);if(c.length!==32)throw new Error("sign: Expected 32 bytes of extra data");s.push(c)}let o=np(...s),a=FU(n);return{seed:o,m:a,d:i}}function Sme(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 KU(r,e,t={}){let{seed:n,m:i,d:s}=vme(r,e,t.extraEntropy),o,a=new Z9;for(await a.reseed(n);!(o=Eme(await a.generate(),i,s));)await a.reseed();return Sme(o,t)}var xme={strict:!0};function zU(r,e,t,n=xme){let i;try{i=UU(r),e=ap(e)}catch{return!1}let{r:s,s:o}=i;if(n.strict&&i.hasHighS())return!1;let a=MU(e),c;try{c=bme(t)}catch{return!1}let{n:l}=fr,f=cp(o,l),h=pe(a*f,l),p=pe(s*f,l),d=Ft.BASE.multiplyAndAddUnsafe(c,h,p);return d?pe(d.x,l)===s:!1}Ft.BASE._setWindowSize(8);var Fi={node:fme,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};var a6={},yo={bytesToHex:op,hexToBytes:Af,concatBytes:np,mod:pe,invert:cp,isValidPrivateKey(r){try{return l6(r),!0}catch{return!1}},_bigintTo32Bytes:X9,_normalizePrivateKey:l6,hashToPrivateKey:r=>{if(r=ap(r),r.length<40||r.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");let e=pe(mc(r),fr.n-ar)+ar;return X9(e)},randomBytes:(r=32)=>{if(Fi.web)return Fi.web.getRandomValues(new Uint8Array(r));if(Fi.node){let{randomBytes:e}=Fi.node;return Uint8Array.from(e(r))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>yo.hashToPrivateKey(yo.randomBytes(40)),sha256:async(...r)=>{if(Fi.web){let e=await Fi.web.subtle.digest("SHA-256",np(...r));return new Uint8Array(e)}else if(Fi.node){let{createHash:e}=Fi.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(Fi.web){let t=await Fi.web.subtle.importKey("raw",r,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=np(...e),i=await Fi.web.subtle.sign("HMAC",t,n);return new Uint8Array(i)}else if(Fi.node){let{createHmac:t}=Fi.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=a6[r];if(t===void 0){let n=await yo.sha256(Uint8Array.from(r,i=>i.charCodeAt(0)));t=np(n,n),a6[r]=t}return yo.sha256(t,...e)},taggedHashSync:(r,...e)=>{if(typeof sp!="function")throw new c6("sha256Sync is undefined, you need to set it");let t=a6[r];if(t===void 0){let n=sp(Uint8Array.from(r,i=>i.charCodeAt(0)));t=np(n,n),a6[r]=t}return sp(t,...e)},precompute(r=8,e=Ft.BASE){let t=e===Ft.BASE?e:new Ft(e.x,e.y);return t._setWindowSize(r),t.multiply(gm),t}};Object.defineProperties(yo,{sha256Sync:{configurable:!1,get(){return sp},set(r){sp||(sp=r)}},hmacSha256Sync:{configurable:!1,get(){return wm},set(r){wm||(wm=r)}}});var qU=_(V(),1);function gi(r){if(isNaN(r)||r<=0)throw(0,qU.default)(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return yo.randomBytes(r)}var Rf={};Re(Rf,{jwkToPkcs1:()=>Ame,jwkToPkix:()=>Cme,pkcs1ToJwk:()=>Ime,pkixToJwk:()=>Rme});u();var PUe=_(Nu(),1),kUe=_(pm(),1),yc=_(ut(),1);var eS=_(V(),1);function Ime(r){let e=yc.default.asn1.fromDer(K(r,"ascii")),t=yc.default.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:mo(t.n),e:mo(t.e),d:mo(t.d),p:mo(t.p),q:mo(t.q),dp:mo(t.dP),dq:mo(t.dQ),qi:mo(t.qInv),alg:"RS256"}}function Ame(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,eS.default)(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");let e=yc.default.pki.privateKeyToAsn1({n:Ui(r.n),e:Ui(r.e),d:Ui(r.d),p:Ui(r.p),q:Ui(r.q),dP:Ui(r.dp),dQ:Ui(r.dq),qInv:Ui(r.qi)});return z(yc.default.asn1.toDer(e).getBytes(),"ascii")}function Rme(r){let e=yc.default.asn1.fromDer(K(r,"ascii")),t=yc.default.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:mo(t.n),e:mo(t.e)}}function Cme(r){if(r.n==null||r.e==null)throw(0,eS.default)(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");let e=yc.default.pki.publicKeyToAsn1({n:Ui(r.n),e:Ui(r.e)});return z(yc.default.asn1.toDer(e).getBytes(),"ascii")}u();var MUe=_(pm(),1),tS=_(ut(),1);function $U(r,e){return e.map(t=>Ui(r[t]))}function HU(r){return tS.default.pki.setRsaPrivateKey(...$U(r,["n","e","d","p","q","dp","dq","qi"]))}function GU(r){return tS.default.pki.setRsaPublicKey(...$U(r,["n","e"]))}var WU=_(V(),1);async function jU(r){let e=await Gr.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 XU(e);return{privateKey:t[0],publicKey:t[1]}}async function rS(r){let t=[await Gr.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Dme(r)],n=await XU({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function YU(r,e){let t=await Gr.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Gr.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(n,0,n.byteLength)}async function QU(r,e,t){let n=await Gr.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return await Gr.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t)}async function XU(r){if(r.privateKey==null||r.publicKey==null)throw(0,WU.default)(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return await Promise.all([Gr.get().subtle.exportKey("jwk",r.privateKey),Gr.get().subtle.exportKey("jwk",r.publicKey)])}async function Dme(r){return await Gr.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 ZU(r,e,t,n){let i=e?GU(r):HU(r),s=K(Uint8Array.from(t),"ascii"),o=n(s,i);return z(o,"ascii")}function JU(r,e){return ZU(r,!0,e,(t,n)=>n.encrypt(t))}function eF(r,e){return ZU(r,!1,e,(t,n)=>n.decrypt(t))}u();async function up(r,e){let n=await s6().encrypt(r,e);return Go.encode(n)}var _m=class{constructor(e){this._key=e}async verify(e,t){return await QU(this._key,t,e)}marshal(){return Rf.jwkToPkix(this._key)}get bytes(){return lo.encode({Type:ir.RSA,Data:this.marshal()}).subarray()}encrypt(e){return JU(this._key,e)}equals(e){return Be(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Ke.digest(this.bytes);return e}},lp=class{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return gi(16)}async sign(e){return await YU(this._key,e)}get public(){if(this._publicKey==null)throw(0,nS.default)(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new _m(this._publicKey)}decrypt(e){return eF(this._key,e)}marshal(){return Rf.jwkToPkcs1(this._key)}get bytes(){return fo.encode({Type:ir.RSA,Data:this.marshal()}).subarray()}equals(e){return Be(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Ke.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 bm.default.util.ByteBuffer(this.marshal()),i=bm.default.asn1.fromDer(n),s=bm.default.pki.privateKeyFromAsn1(i),o={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return bm.default.pki.encryptRsaPrivateKey(s,e,o)}else{if(t==="libp2p-key")return await up(this.bytes,e);throw(0,nS.default)(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}};async function kme(r){let e=Rf.pkcs1ToJwk(r),t=await rS(e);return new lp(t.privateKey,t.publicKey)}function Nme(r){let e=Rf.pkixToJwk(r);return new _m(e)}async function Ome(r){let e=await rS(r);return new lp(e.privateKey,e.publicKey)}async function Lme(r){let e=await jU(r);return new lp(e.privateKey,e.publicKey)}var mS={};Re(mS,{Ed25519PrivateKey:()=>Df,Ed25519PublicKey:()=>Im,generateKeyPair:()=>t2e,generateKeyPairFromSeed:()=>pS,unmarshalEd25519PrivateKey:()=>Jme,unmarshalEd25519PublicKey:()=>e2e});u();var dS=_(V(),1);u();u();var Bme=_(Lu(),1);var Rn=BigInt(0),St=BigInt(1),fp=BigInt(2),tF=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),hr=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:tF,n:tF,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")});var sF=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),vm=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),rFe=BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),Mme=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Ume=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Fme=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Vme=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),vt=class{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.t=i}static fromAffine(e){if(!(e instanceof vr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(vr.ZERO)?vt.ZERO:new vt(e.x,e.y,St,Y(e.x*e.y))}static toAffineBatch(e){let t=qme(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){rF(e);let{x:t,y:n,z:i}=this,{x:s,y:o,z:a}=e,c=Y(t*a),l=Y(s*i),f=Y(n*a),h=Y(o*i);return c===l&&f===h}negate(){return new vt(Y(-this.x),this.y,this.z,Y(-this.t))}double(){let{x:e,y:t,z:n}=this,{a:i}=hr,s=Y(e*e),o=Y(t*t),a=Y(fp*Y(n*n)),c=Y(i*s),l=e+t,f=Y(Y(l*l)-s-o),h=c+o,p=h-a,d=c-o,m=Y(f*p),y=Y(h*d),g=Y(f*d),w=Y(p*h);return new vt(m,y,w,g)}add(e){rF(e);let{x:t,y:n,z:i,t:s}=this,{x:o,y:a,z:c,t:l}=e,f=Y((n-t)*(a+o)),h=Y((n+t)*(a-o)),p=Y(h-f);if(p===Rn)return this.double();let d=Y(i*fp*l),m=Y(s*fp*c),y=m+d,g=h+f,w=m-d,E=Y(y*p),v=Y(g*w),x=Y(y*w),I=Y(p*g);return new vt(E,v,I,x)}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(vt.BASE)&&(t=vr.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&&uS.get(t);i||(i=this.precomputeWindow(n),t&&n!==1&&(i=vt.normalizeZ(i),uS.set(t,i)));let s=vt.ZERO,o=vt.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+=St),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 vt.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(h6(e,hr.l),t)}multiplyUnsafe(e){let t=h6(e,hr.l,!1),n=vt.BASE,i=vt.ZERO;if(t===Rn)return i;if(this.equals(i)||t===St)return this;if(this.equals(n))return this.wNAF(t);let s=i,o=this;for(;t>Rn;)t&St&&(s=s.add(o)),o=o.double(),t>>=St;return s}isSmallOrder(){return this.multiplyUnsafe(hr.h).equals(vt.ZERO)}isTorsionFree(){return this.multiplyUnsafe(hr.l).equals(vt.ZERO)}toAffine(e=d6(this.z)){let{x:t,y:n,z:i}=this,s=Y(t*e),o=Y(n*e);if(Y(i*e)!==St)throw new Error("invZ was invalid");return new vr(s,o)}fromRistrettoBytes(){oS()}toRistrettoBytes(){oS()}fromRistrettoHash(){oS()}};vt.BASE=new vt(hr.Gx,hr.Gy,St,Y(hr.Gx*hr.Gy));vt.ZERO=new vt(Rn,St,St,Rn);function rF(r){if(!(r instanceof vt))throw new TypeError("ExtendedPoint expected")}function sS(r){if(!(r instanceof wi))throw new TypeError("RistrettoPoint expected")}function oS(){throw new Error("Legacy method: switch to RistrettoPoint")}var wi=class{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){let{d:t}=hr,n=Y(vm*e*e),i=Y((n+St)*Fme),s=BigInt(-1),o=Y((s-t*n)*Y(n+t)),{isValid:a,value:c}=fS(i,o),l=Y(c*e);Vu(l)||(l=Y(-l)),a||(c=l),a||(s=n);let f=Y(s*(n-St)*Vme-o),h=c*c,p=Y((c+c)*o),d=Y(f*Mme),m=Y(St-h),y=Y(St+h);return new vt(Y(p*y),Y(m*d),Y(d*y),Y(p*m))}static hashToCurve(e){e=Ku(e,64);let t=aS(e.slice(0,32)),n=this.calcElligatorRistrettoMap(t),i=aS(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new wi(n.add(s))}static fromHex(e){e=Ku(e,32);let{a:t,d:n}=hr,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=aS(e);if(!Hme(Sm(s),e)||Vu(s))throw new Error(i);let o=Y(s*s),a=Y(St+t*o),c=Y(St-t*o),l=Y(a*a),f=Y(c*c),h=Y(t*n*l-f),{isValid:p,value:d}=iF(Y(h*f)),m=Y(d*c),y=Y(d*m*h),g=Y((s+s)*m);Vu(g)&&(g=Y(-g));let w=Y(a*y),E=Y(g*w);if(!p||Vu(E)||w===Rn)throw new Error(i);return new wi(new vt(g,w,St,E))}toRawBytes(){let{x:e,y:t,z:n,t:i}=this.ep,s=Y(Y(n+t)*Y(n-t)),o=Y(e*t),a=Y(o*o),{value:c}=iF(Y(s*a)),l=Y(c*s),f=Y(c*o),h=Y(l*f*i),p;if(Vu(i*h)){let m=Y(t*vm),y=Y(e*vm);e=m,t=y,p=Y(l*Ume)}else p=f;Vu(e*h)&&(t=Y(-t));let d=Y((n-t)*p);return Vu(d)&&(d=Y(-d)),Sm(d)}toHex(){return xm(this.toRawBytes())}toString(){return this.toHex()}equals(e){sS(e);let t=this.ep,n=e.ep,i=Y(t.x*n.y)===Y(t.y*n.x),s=Y(t.y*n.y)===Y(t.x*n.x);return i||s}add(e){return sS(e),new wi(this.ep.add(e.ep))}subtract(e){return sS(e),new wi(this.ep.subtract(e.ep))}multiply(e){return new wi(this.ep.multiply(e))}multiplyUnsafe(e){return new wi(this.ep.multiplyUnsafe(e))}};wi.BASE=new wi(vt.BASE);wi.ZERO=new wi(vt.ZERO);var uS=new WeakMap,vr=class{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,uS.delete(this)}static fromHex(e,t=!0){let{d:n,P:i}=hr;e=Ku(e,32);let s=e.slice();s[31]=e[31]&-129;let o=Tm(s);if(t&&o>=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=sF)throw new Error("Expected 0 < hex < 2**256");let a=Y(o*o),c=Y(a-St),l=Y(n*a+St),{isValid:f,value:h}=fS(c,l);if(!f)throw new Error("Point.fromHex: invalid y coordinate");let p=(h&St)===St;return(e[31]&128)!==0!==p&&(h=Y(-h)),new vr(h,o)}static async fromPrivateKey(e){return(await p6(e)).point}toRawBytes(){let e=Sm(this.y);return e[31]|=this.x&St?128:0,e}toHex(){return xm(this.toRawBytes())}toX25519(){let{y:e}=this,t=Y((St+e)*d6(St-e));return Sm(t)}isTorsionFree(){return vt.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new vr(Y(-this.x),this.y)}add(e){return vt.fromAffine(this).add(vt.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return vt.fromAffine(this).multiply(e,this).toAffine()}};vr.BASE=new vr(hr.Gx,hr.Gy);vr.ZERO=new vr(Rn,St);var Cf=class{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){let t=Ku(e,64),n=vr.fromHex(t.slice(0,32),!1),i=Tm(t.slice(32,64));return new Cf(n,i)}assertValidity(){let{r:e,s:t}=this;if(!(e instanceof vr))throw new Error("Expected Point instance");return h6(t,hr.l,!1),this}toRawBytes(){let e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Sm(this.s),32),e}toHex(){return xm(this.toRawBytes())}};function nF(...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 Kme=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function xm(r){if(!(r instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Kme[r[t]];return e}function lS(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 oF(r){let t=r.toString(16).padStart(64,"0");return lS(t)}function Sm(r){return oF(r).reverse()}function Vu(r){return(Y(r)&St)===St}function Tm(r){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+xm(Uint8Array.from(r).reverse()))}var zme=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function aS(r){return Y(Tm(r)&zme)}function Y(r,e=hr.P){let t=r%e;return t>=Rn?t:e+t}function d6(r,e=hr.P){if(r===Rn||e<=Rn)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Y(r,e),n=e,i=Rn,s=St,o=St,a=Rn;for(;t!==Rn;){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!==St)throw new Error("invert: does not exist");return Y(i,e)}function qme(r,e=hr.P){let t=new Array(r.length),n=r.reduce((s,o,a)=>o===Rn?s:(t[a]=s,Y(s*o,e)),St),i=d6(n,e);return r.reduceRight((s,o,a)=>o===Rn?s:(t[a]=Y(s*t[a],e),Y(s*o,e)),i),t}function la(r,e){let{P:t}=hr,n=r;for(;e-- >Rn;)n*=n,n%=t;return n}function $me(r){let{P:e}=hr,t=BigInt(5),n=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),c=r*r%e*r%e,l=la(c,fp)*c%e,f=la(l,St)*r%e,h=la(f,t)*f%e,p=la(h,n)*h%e,d=la(p,i)*p%e,m=la(d,s)*d%e,y=la(m,o)*m%e,g=la(y,o)*m%e,w=la(g,n)*h%e;return{pow_p_5_8:la(w,fp)*r%e,b2:c}}function fS(r,e){let t=Y(e*e*e),n=Y(t*t*e),i=$me(r*n).pow_p_5_8,s=Y(r*t*i),o=Y(e*s*s),a=s,c=Y(s*vm),l=o===r,f=o===Y(-r),h=o===Y(-r*vm);return l&&(s=a),(f||h)&&(s=c),Vu(s)&&(s=Y(-s)),{isValid:l||f,value:s}}function iF(r){return fS(St,r)}function f6(r){return Y(Tm(r),hr.l)}function Hme(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 Ku(r,e){let t=r instanceof Uint8Array?Uint8Array.from(r):lS(r);if(typeof e=="number"&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function h6(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(Rn<r)return r}else if(Rn<=r)return r}throw new TypeError("Expected valid scalar: 0 < scalar < max")}function Gme(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Wme(r){if(r=typeof r=="bigint"||typeof r=="number"?oF(h6(r,sF)):Ku(r),r.length!==32)throw new Error("Expected 32 bytes");return r}function jme(r){let e=Gme(r.slice(0,32)),t=r.slice(32,64),n=f6(e),i=vr.BASE.multiply(n),s=i.toRawBytes();return{head:e,prefix:t,scalar:n,point:i,pointBytes:s}}var cS;async function p6(r){return jme(await zu.sha512(Wme(r)))}async function hS(r){return(await p6(r)).pointBytes}async function aF(r,e){r=Ku(r);let{prefix:t,scalar:n,pointBytes:i}=await p6(e),s=f6(await zu.sha512(t,r)),o=vr.BASE.multiply(s),a=f6(await zu.sha512(o.toRawBytes(),i,r)),c=Y(s+a*n,hr.l);return new Cf(o,c).toRawBytes()}function Yme(r,e,t){e=Ku(e),t instanceof vr||(t=vr.fromHex(t,!1));let{r:n,s:i}=r instanceof Cf?r.assertValidity():Cf.fromHex(r),s=vt.BASE.multiplyUnsafe(i);return{r:n,s:i,SB:s,pub:t,msg:e}}function Qme(r,e,t,n){let i=f6(n),s=vt.fromAffine(r).multiplyUnsafe(i);return vt.fromAffine(e).add(s).subtract(t).multiplyUnsafe(hr.h).equals(vt.ZERO)}async function cF(r,e,t){let{r:n,SB:i,msg:s,pub:o}=Yme(r,e,t),a=await zu.sha512(n.toRawBytes(),o.toRawBytes(),s);return Qme(o,n,i,a)}vr.BASE._setWindowSize(8);var Fu={node:Bme,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},zu={bytesToHex:xm,hexToBytes:lS,concatBytes:nF,getExtendedPublicKey:p6,mod:Y,invert:d6,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:r=>{if(r=Ku(r),r.length<40||r.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Y(Tm(r),hr.l-St)+St},randomBytes:(r=32)=>{if(Fu.web)return Fu.web.getRandomValues(new Uint8Array(r));if(Fu.node){let{randomBytes:e}=Fu.node;return new Uint8Array(e(r).buffer)}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>zu.randomBytes(32),sha512:async(...r)=>{let e=nF(...r);if(Fu.web){let t=await Fu.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}else{if(Fu.node)return Uint8Array.from(Fu.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")}},precompute(r=8,e=vr.BASE){let t=e.equals(vr.BASE)?e:new vr(e.x,e.y);return t._setWindowSize(r),t.multiply(fp),t},sha512Sync:void 0};Object.defineProperties(zu,{sha512Sync:{configurable:!1,get(){return cS},set(r){cS||(cS=r)}}});var hp=32,gc=64,m6=32;async function uF(){let r=zu.randomPrivateKey(),e=await hS(r);return{privateKey:dF(r,e),publicKey:e}}async function lF(r){if(r.length!==m6)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 hS(e);return{privateKey:dF(e,t),publicKey:t}}async function fF(r,e){let t=r.slice(0,m6);return await aF(e,t)}async function hF(r,e,t){return await cF(e,t,r)}function dF(r,e){let t=new Uint8Array(gc);for(let n=0;n<m6;n++)t[n]=r[n],t[m6+n]=e[n];return t}var Im=class{constructor(e){this._key=dp(e,hp)}async verify(e,t){return await hF(this._key,t,e)}marshal(){return this._key}get bytes(){return lo.encode({Type:ir.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Be(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Ke.digest(this.bytes);return e}},Df=class{constructor(e,t){this._key=dp(e,gc),this._publicKey=dp(t,hp)}async sign(e){return await fF(this._key,e)}get public(){return new Im(this._publicKey)}marshal(){return this._key}get bytes(){return fo.encode({Type:ir.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Be(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Ke.digest(this.bytes);return e}async id(){let e=await rn.digest(this.public.bytes);return Ce.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return await up(this.bytes,e);throw(0,dS.default)(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}};function Jme(r){if(r.length>gc){r=dp(r,gc+hp);let n=r.slice(0,gc),i=r.slice(gc,r.length);return new Df(n,i)}r=dp(r,gc);let e=r.slice(0,gc),t=r.slice(hp);return new Df(e,t)}function e2e(r){return r=dp(r,hp),new Im(r)}async function t2e(){let{privateKey:r,publicKey:e}=await uF();return new Df(r,e)}async function pS(r){let{privateKey:e,publicKey:t}=await lF(r);return new Df(e,t)}function dp(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw(0,dS.default)(new Error(`Key must be a Uint8Array of length ${e}, got ${r.length}`),"ERR_INVALID_KEY_TYPE");return r}var gS={};Re(gS,{Secp256k1PrivateKey:()=>Rm,Secp256k1PublicKey:()=>Am,generateKeyPair:()=>s2e,unmarshalSecp256k1PrivateKey:()=>n2e,unmarshalSecp256k1PublicKey:()=>i2e});u();var bF=_(V(),1);u();var pp=_(V(),1);function pF(){return yo.randomPrivateKey()}async function mF(r,e){let{digest:t}=await Ke.digest(e);try{return await KU(t,r)}catch(n){throw(0,pp.default)(n,"ERR_INVALID_INPUT")}}async function yF(r,e,t){try{let{digest:n}=await Ke.digest(t);return zU(e,n,r)}catch(n){throw(0,pp.default)(n,"ERR_INVALID_INPUT")}}function gF(r){return Ft.fromHex(r).toRawBytes(!0)}function wF(r){try{J9(r,!0)}catch(e){throw(0,pp.default)(e,"ERR_INVALID_PRIVATE_KEY")}}function yS(r){try{Ft.fromHex(r)}catch(e){throw(0,pp.default)(e,"ERR_INVALID_PUBLIC_KEY")}}function EF(r){try{return J9(r,!0)}catch(e){throw(0,pp.default)(e,"ERR_INVALID_PRIVATE_KEY")}}var Am=class{constructor(e){yS(e),this._key=e}async verify(e,t){return await yF(this._key,t,e)}marshal(){return gF(this._key)}get bytes(){return lo.encode({Type:ir.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Be(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Ke.digest(this.bytes);return e}},Rm=class{constructor(e,t){this._key=e,this._publicKey=t??EF(e),wF(this._key),yS(this._publicKey)}async sign(e){return await mF(this._key,e)}get public(){return new Am(this._publicKey)}marshal(){return this._key}get bytes(){return fo.encode({Type:ir.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Be(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Ke.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 up(this.bytes,e);throw(0,bF.default)(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}};function n2e(r){return new Rm(r)}function i2e(r){return new Am(r)}async function s2e(){let r=await pF();return new Rm(r)}var fa={rsa:iS,ed25519:mS,secp256k1:gS};function wS(r){let e=Object.keys(fa).join(" / ");return(0,g6.default)(new Error(`invalid or unsupported key type ${r}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function ES(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return fa[r];throw wS(r)}async function mp(r,e){return await ES(r).generateKeyPair(e??2048)}async function o2e(r,e,t){if(r.toLowerCase()!=="ed25519")throw(0,g6.default)(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return await pS(e)}function Ei(r){let e=lo.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ir.RSA:return fa.rsa.unmarshalRsaPublicKey(t);case ir.Ed25519:return fa.ed25519.unmarshalEd25519PublicKey(t);case ir.Secp256k1:return fa.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw wS(e.Type??"RSA")}}function Cm(r,e){return e=(e??"rsa").toLowerCase(),ES(e),r.bytes}async function Cn(r){let e=fo.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ir.RSA:return await fa.rsa.unmarshalRsaPrivateKey(t);case ir.Ed25519:return fa.ed25519.unmarshalEd25519PrivateKey(t);case ir.Secp256k1:return fa.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw wS(e.Type??"RSA")}}function bS(r,e){return e=(e??"rsa").toLowerCase(),ES(e),r.bytes}async function wc(r,e){try{let i=await TU(r,e);return await Cn(i)}catch{}let t=y6.default.pki.decryptRsaPrivateKey(r,e);if(t===null)throw(0,g6.default)(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let n=y6.default.asn1.toDer(y6.default.pki.privateKeyToAsn1(t));return n=z(n.getBytes(),"ascii"),await fa.rsa.unmarshalRsaPrivateKey(n)}var TS=_(V(),1);u();var yp=_(V(),1);u();var _F="ERR_IPNS_EXPIRED_RECORD",Dm="ERR_UNRECOGNIZED_VALIDITY",vF="ERR_SIGNATURE_CREATION",qu="ERR_SIGNATURE_VERIFICATION",SF="ERR_UNRECOGNIZED_FORMAT";var _S="ERR_UNDEFINED_PARAMETER",xF="ERR_INVALID_RECORD_DATA",TF="ERR_INVALID_EMBEDDED_KEY",IF="ERR_MISSING_PRIVATE_KEY";u();var bi;(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=()=>Mi(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=ct((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=>at(i,r.codec()),r.decode=i=>ot(i,r.codec())})(bi||(bi={}));var AF=D("ipns:utils"),RF=z("/ipns/");function Pm(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 CF=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw AF.error(n),(0,yp.default)(n,_S)}let t;if(e.pubKey!=null){try{t=Ei(e.pubKey)}catch(i){throw AF.error(i),i}if(!(await sn(e.pubKey)).equals(r))throw(0,yp.default)(new Error("Embedded public key did not match PeerID"),TF)}else r.publicKey!=null&&(t=Ei(r.publicKey));if(t!=null)return t;throw(0,yp.default)(new Error("no public key is available"),_S)},DF=(r,e,t)=>{let n=z(e);return De([r,t,n])},E6=r=>{let e=z("ipns-signature:");return De([e,r])},SS=r=>bi.encode(r),Ec=r=>{let e=bi.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??bi.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}},$u=r=>De([RF,r.toBytes()]),xS=r=>_r(r.slice(RF.length)),PF=(r,e,t,n,i)=>{let s;if(t===bi.ValidityType.EOL)s=0;else throw(0,yp.default)(new Error("Unknown validity type"),Dm);return to({Value:r,Validity:e,ValidityType:s,Sequence:n,TTL:i})},kF=r=>{let e=$n(r);if(e.ValidityType===0)e.ValidityType=bi.ValidityType.EOL;else throw(0,yp.default)(new Error("Unknown validity type"),Dm);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e};var OF=D("ipns"),a2e=rn.code,km="/ipns/",b6=km.length,LF=async(r,e,t,n)=>{let i=new NF.default(Date.now()+Number(n)),s=bi.ValidityType.EOL,[o,a]=n.toString().split("."),c=BigInt(o)*BigInt(1e5)+BigInt(a??"0");return await c2e(r,e,t,s,i,c)};var c2e=async(r,e,t,n,i,s)=>{t=BigInt(t);let o=z(i.toString());if(r.privateKey==null)throw(0,TS.default)(new Error("Missing private key"),IF);let a=await Cn(r.privateKey),c=await l2e(a,e,n,o),l=PF(e,o,n,t,s),f=E6(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=Jt(r.toBytes());(d.code!==a2e||!Be(r.publicKey,d.digest))&&(p.pubKey=r.publicKey)}return OF("ipns entry for %b created",e),p},u2e=r=>b_.encode(r).slice(1),Nm=r=>new ie(`/ipns/${u2e(r)}`),l2e=async(r,e,t,n)=>{try{let i=DF(e,t,n);return await r.sign(i)}catch(i){throw OF.error("record signature creation failed",i),(0,TS.default)(new Error("record signature creation failed"),vF)}};var Is=D("ipfs:ipns:publisher"),BF=mn().code,MF=60*60*1e3,Pf=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,MF,n)}async _putRecordToRouting(e,t,n){if(!vs(t)){let s="peerId received is not valid";throw Is.error(s),(0,As.default)(new Error(s),"ERR_INVALID_PEER_ID")}if(t.publicKey==null)throw(0,As.default)(new Error("Public key was missing"),"ERR_MISSING_PUBLIC_KEY");let i=$u(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 Is(`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 Is.error(s),Is.error(i),(0,As.default)(new Error(s),"ERR_PUTTING_TO_ROUTING")}}async _getPublished(e,t={}){if(!vs(e)){let i="peerId received is not valid";throw Is.error(i),(0,As.default)(new Error(i),"ERR_INVALID_PEER_ID")}let n=t.checkRouting!==!1;try{let i=await this._datastore.get(Nm(e.toBytes()));return this._unmarshalData(i)}catch(i){if(i.code!==BF){let s=`unexpected error getting the ipns record ${e.toString()} from datastore`;throw Is.error(s),(0,As.default)(new Error(s),"ERR_UNEXPECTED_DATASTORE_RESPONSE")}if(!n)throw(0,As.default)(i,"ERR_NOT_FOUND_AND_CHECK_ROUTING_NOT_ENABLED");try{let s=$u(e),o=await this._routing.get(s);return this._unmarshalData(o)}catch(s){throw Is.error(s),s}}}_unmarshalData(e){try{return Ec(e)}catch(t){throw(0,As.default)(t,"ERR_INVALID_RECORD_DATA")}}async _updateOrCreateRecord(e,t,n,i){if(!vs(e)){let l="peerId received is not valid";throw Is.error(l),(0,As.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!==BF){let f=`unexpected error when determining the last published IPNS record for ${e.toString()} ${l.stack}`;throw Is.error(f),(0,As.default)(new Error(f),"ERR_DETERMINING_PUBLISHED_RECORD")}}let a=0n;o&&o.sequence!==void 0&&(a=Be(o.value,t)?o.sequence:o.sequence+BigInt(1));let c;try{c=await LF(e,t,a,n)}catch(l){let f=`ipns record for ${t} could not be created`;throw Is.error(l),(0,As.default)(new Error(f),"ERR_CREATING_IPNS_RECORD")}try{let l=SS(c);return await this._datastore.put(Nm(e.toBytes()),l,i),Is(`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 Is.error(f),(0,As.default)(new Error(f),"ERR_STORING_IN_DATASTORE")}}};Pf.defaultRecordLifetime=MF;u();var kf=_(V(),1);var UF=_(pn(),1),_6=D("ipfs:ipns:republisher"),FF=60*1e3,VF=60*FF,f2e=4*VF,h2e=24*VF,v6=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,kf.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){_6.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 UF.TimeoutController(3e4);try{await this._republishEntries(this._peerId,t,{signal:i.signal})}finally{i.clear()}},e.runPeriodically(()=>n?(n=!1,this._options.initialBroadcastInterval||FF):this._options.broadcastInterval||f2e),this._republishHandle=e}async stop(){let e=this._republishHandle;if(!e)throw(0,kf.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";_6.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 wc(o,t),c=await sn(a.public.bytes,a.bytes);await this._republishEntry(c,n)}}catch(i){_6.error(i)}}async _republishEntry(e,t){try{let n=await this._getPreviousValue(e);await this._publisher.publishWithEOL(e,n,h2e,t)}catch(n){if(n.code==="ERR_NO_ENTRY_FOUND")return;throw n}}async _getPreviousValue(e){if(!vs(e))throw(0,kf.default)(new Error("invalid peer ID"),"ERR_INVALID_PEER_ID");try{let t=await this._datastore.get(Nm(e.toBytes()));if(!(t instanceof Uint8Array))throw(0,kf.default)(new Error("found ipns record that we couldn't process"),"ERR_INVALID_IPNS_RECORD");try{return Ec(t).value}catch(n){throw _6.error(n),(0,kf.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,kf.default)(new Error(`no previous entry for record with id: ${e.toString()}`),"ERR_NO_ENTRY_FOUND"):t}}};u();var wp=_(V(),1);u();var Rs=_(V(),1);var Om=D("ipns:validator"),d2e=async(r,e)=>{let{value:t,validityType:n,validity:i}=e,s,o;if(e.signatureV2!=null&&e.data!=null)o=e.signatureV2,s=E6(e.data),p2e(e);else throw(0,Rs.default)(new Error("missing data or signatureV2"),qu);let a;try{a=await r.verify(s,o)}catch{a=!1}if(!a)throw Om.error("record signature verification failed"),(0,Rs.default)(new Error("record signature verification failed"),qu);if(i!=null&&n===bi.ValidityType.EOL){let c;try{c=Pm(K(i))}catch{throw Om.error("unrecognized validity format (not an rfc3339 format)"),(0,Rs.default)(new Error("unrecognized validity format (not an rfc3339 format)"),SF)}if(c.getTime()<Date.now())throw Om.error("record has expired"),(0,Rs.default)(new Error("record has expired"),_F)}else if(n!=null)throw Om.error("unrecognized validity type"),(0,Rs.default)(new Error("unrecognized validity type"),Dm);Om("ipns entry for %b is valid",t)},p2e=r=>{if(r.data==null)throw(0,Rs.default)(new Error("Record data is missing"),xF);let e=kF(r.data);if(!Be(e.Value,r.value))throw(0,Rs.default)(new Error('Field "value" did not match between protobuf and CBOR'),qu);if(!Be(e.Validity,r.validity))throw(0,Rs.default)(new Error('Field "validity" did not match between protobuf and CBOR'),qu);if(e.ValidityType!==r.validityType)throw(0,Rs.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),qu);if(e.Sequence!==r.sequence)throw(0,Rs.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),qu);if(e.TTL!==r.ttl)throw(0,Rs.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),qu)},gp=async(r,e)=>{let t=xS(r),n=Ec(e),i=await CF(t,n);await d2e(i,n)};var AS=D("ipfs:ipns:resolver"),m2e=mn().code,KF=32,S6=class{constructor(e){this._routing=e}async resolve(e,t={}){if(typeof e!="string")throw(0,wp.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,wp.default)(new Error("invalid name"),"ERR_INVALID_NAME");let s=i[2],o=1/0;n&&(o=KF);let a=await this.resolver(s,o,t);return AS(`${e} was locally resolved correctly`),a}async resolver(e,t,n){if(t===0){let o=`could not resolve name (recursion limit of ${KF} exceeded)`;throw AS.error(o),(0,wp.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=ce(e),i=$u(n),s;try{s=await this._routing.get(i,t)}catch(o){throw AS.error("could not get record from routing",o),o.code===m2e?(0,wp.default)(new Error(`record requested for ${e} was not found in the network`),"ERR_NO_RECORD_FOUND"):(0,wp.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 gp(De([z("/ipns/"),e.toBytes()]),t);let n=Ec(t);return K(n.value)}};u();var zF=_(qd(),1),x6=class{constructor(e){this.lru=(0,zF.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 Lm=D("ipfs:ipns"),qF=60*1e3,Bm=class{constructor(e,t,n,i,s){this.publisher=new Pf(e,t),this.republisher=new v6(this.publisher,t,n,i,s),this.resolver=new S6(e),this.cache=new x6(1e3),this.routing=e}async publish(e,t,n=Pf.defaultRecordLifetime,i){try{await this.publisher.publishWithEOL(e,t,n,i),Lm(`IPNS value ${K(t,"base32")} was published correctly`);let s=e.toString(),o=parseFloat(n),a=o<qF?o:qF;return this.cache.set(s,t,a),Lm(`IPNS value ${K(t,"base32")} was cached correctly`),{name:s,value:t}}catch(s){throw Lm.error(s),s}}async resolve(e,t={}){if(typeof e!="string")throw(0,$F.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 Lm(`IPNS record from ${e} was resolved correctly`),n}catch(n){throw Lm.error(n),n}}async initializeKeyspace(e,t,n){return this.publish(e,t,Pf.defaultRecordLifetime,n)}};u();u();u();u();var WF=_(GF(),1),T6=(r,e)=>async function*(){yield*(await(0,WF.default)(r)).sort(e)}();var DS=_(RS(),1),Nf=_(CS(),1),PS=_(Ep(),1),_i=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,DS.default)(this.putMany(e,n)),e=[],await(0,DS.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,Nf.default)(n,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Nf.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>T6(i,s),n)),e.offset!=null){let i=0;n=(0,Nf.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,PS.default)(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(e.prefix!=null&&(n=(0,Nf.default)(n,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Nf.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>T6(i,s),n)),e.offset!=null){let i=0;n=(0,Nf.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,PS.default)(n,e.limit)),n}};u();u();var I6=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}},bp=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new I6(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 I6(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 Vt(r={}){return ZF(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 XF(r={}){return ZF(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 ZF(r,e){e=e??{};let t=e.onEnd,n=new bp,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(E){g(E)}return i}}):r(n),c=y=>s!=null?s(y):(n.push(y),i),l=y=>(n=new bp,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 bp,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 kS=_(RS(),1),b2e=D("datastore:core:tiered"),Mm=class extends _i{constructor(e){super(),this.stores=e.slice()}async open(){try{await Promise.all(this.stores.map(e=>e.open()))}catch{throw M4()}}async put(e,t,n){try{await Promise.all(this.stores.map(i=>i.put(e,t,n)))}catch{throw F4()}}async get(e,t){for(let n of this.stores)try{let i=await n.get(e,t);if(i)return i}catch(i){b2e.error(i)}throw mn()}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 U4()}}async*putMany(e,t={}){let n,i=this.stores.map(s=>{let o=Vt({objectMode:!0});return(0,kS.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=Vt({objectMode:!0});return(0,kS.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 Km=_(A6(),1);u();u();var R6=(r,e)=>{let t=e.map((n,i)=>({entry:bi.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=Pm(K(a)),f=Pm(K(c));return l.getTime()>f.getTime()?-1:l.getTime()<f.getTime()?1:0}),t[0].index};u();u();u();u();u();var JF="SHARDING",eV="_README";u();var Um=class extends _i{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 mn();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 ie(e),value:t}))}async*_allKeys(){yield*Object.entries(this.data).map(([e])=>new ie(e))}};u();var R2e=_(rV(),1);u();var fV=_(lV(),1),I2e=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},hV=r=>r!=null&&(typeof r[Symbol.asyncIterator]=="function"||typeof r[Symbol.iterator]=="function"||typeof r.next=="function"),BS=r=>r!=null&&typeof r.sink=="function"&&hV(r.source),A2e=r=>e=>{let t=r.sink(e);if(t.then!=null){let n=Vt({objectMode:!0});return t.then(()=>{n.end()},s=>{n.end(s)}),(0,fV.default)(n,async function*(){yield*r.source,n.end()}())}return r.source};function de(r,...e){if(BS(r)){let n=r;r=()=>n.source}else if(hV(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&BS(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++)BS(t[n])&&(t[n]=A2e(t[n]));return I2e(...t)}u();var jKe=new ie(JF),YKe=new ie(eV);u();var P2e=_(CS(),1),k2e=_(Ep(),1),N2e=_(gV(),1);u();u();var wV=_(V(),1);var C6="/record/";function US(r){return K(r,"base32")}function Fm(r){(typeof r=="string"||r instanceof String)&&(r=z(r.toString()));let e=K(r,"base64url");return`${C6}${e}`}function EV(r){if(r.substring(0,C6.length)!==C6)throw(0,wV.default)(new Error("topic received is not from a record"),"ERR_TOPIC_IS_NOT_FROM_RECORD_NAMESPACE");let e=r.substring(C6.length);return z(e,"base64url")}var Vi=_(V(),1);var Vn=D("datastore-pubsub:publisher"),D6=class extends _i{constructor(e,t,n,i,s,o){if(super(),!i)throw(0,Vi.default)(new TypeError("missing validator"),"ERR_INVALID_PARAMETERS");if(typeof i!="function")throw(0,Vi.default)(new TypeError("missing validate function"),"ERR_INVALID_PARAMETERS");if(typeof s!="function")throw(0,Vi.default)(new TypeError("missing select function"),"ERR_INVALID_PARAMETERS");if(o&&typeof o!="function")throw(0,Vi.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 Vn.error(s),(0,Vi.default)(new Error(s),"ERR_INVALID_DATASTORE_KEY")}if(!(t instanceof Uint8Array)){let s="received value is not a Uint8Array";throw Vn.error(s),(0,Vi.default)(new Error(s),"ERR_INVALID_VALUE_RECEIVED")}let i=Fm(e);Vn(`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 Vn.error(s),(0,Vi.default)(new Error(s),"ERR_INVALID_DATASTORE_KEY")}let n=Fm(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 Vn.error(o),(0,Vi.default)(new Error(o),"ERR_SUBSCRIBING_TOPIC")}return Vn(`subscribed values for key ${n}`),this._getLocal(e)}unsubscribe(e){let t=Fm(e);return this._pubsub.unsubscribe(t)}async _getLocal(e,t){let n=new ie("/"+US(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 Vn.error(a),(0,Vi.default)(new Error(a),"ERR_UNEXPECTED_ERROR_GETTING_RECORD")}let o=`local record requested was not found for ${n.toString()}`;throw Vn.error(o),(0,Vi.default)(new Error(o),"ERR_NOT_FOUND")}if(!(i instanceof Uint8Array)){let s="found record that we couldn't convert to a value";throw Vn.error(s),(0,Vi.default)(new Error(s),"ERR_INVALID_RECORD_RECEIVED")}return i}async _onMessage(e){let t=e.detail;if(t.type!=="signed"){Vn.error("unsigned message received, this module can only work with signed messages");return}let{data:n,from:i,topic:s}=t,o;try{o=EV(s)}catch(a){Vn.error(a);return}if(Vn(`message received for topic ${s}`),this._peerId.equals(i)){Vn("message discarded as it is from the same peer");return}if(this._handleSubscriptionKeyFn){let a;try{a=await this._handleSubscriptionKeyFn(o)}catch{Vn.error("message discarded by the subscriptionKeyFn");return}o=a}try{await this._storeIfSubscriptionIsBetter(o,n)}catch(a){Vn.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 Vn.error(o),(0,Vi.default)(new Error(o),"ERR_NOT_VALID_RECORD")}let n=new ie(e),i;try{i=await this._getLocal(n.uint8Array())}catch{return!0}return Be(i,t)?!1:this._selectRecord(e,[i,t])}async _storeRecord(e,t,n){let i=new ie("/"+US(e),!1);await this._datastore.put(i,t,n),Vn(`record for ${Fm(e)} was stored in the datastore`)}};var FS=_(V(),1);var P6=D("ipfs:ipns:pubsub"),Of=class{constructor(e,t,n){this._subscriptions={},this._handleSubscriptionKey=this._handleSubscriptionKey.bind(this),this._pubsubDs=new D6(e,t,n,gp,R6,this._handleSubscriptionKey)}async put(e,t,n){try{await this._pubsubDs.put(e,t,n)}catch(i){throw P6.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,b6);if(K(s)===km){let o=Ce.encode(e).substring(1),a=Ce.encode(e.slice(b6)).substring(1);this._subscriptions[o]=a,P6(`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,FS.default)(new Error(`key ${e} does not correspond to a subscription`),"ERR_INVALID_KEY");try{return $u(ce(t))}catch(n){throw P6.error(n),n}}getSubscriptions(){return Object.values(this._subscriptions).filter(Boolean).map(t=>`${km}${t}`)}async cancel(e){if(typeof e!="string")throw(0,FS.default)(new Error("invalid subscription name"),"ERR_INVALID_SUBSCRIPTION_NAME");e.startsWith(km)&&(e=e.substring(b6));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],P6(`unsubscribed pubsub ${t}: ${e}`),{canceled:!0}}};u();u();u();var Vm;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.key!=null&&t.key.byteLength>0)&&(n.uint32(10),n.bytes(t.key)),(i.writeDefaults===!0||t.value!=null&&t.value.byteLength>0)&&(n.uint32(18),n.bytes(t.value)),(i.writeDefaults===!0||t.timeReceived!=="")&&(n.uint32(42),n.string(t.timeReceived)),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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(Vm||(Vm={}));u();function bV(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 _V(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 Sr=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 Vm.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:bV(this.timeReceived)}}static deserialize(e){let t=Vm.decode(e);return new Sr(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=_V(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 Sr(e.key,e.value,t)}};var vp=_(V(),1);var VS=D("ipfs:ipns:offline-datastore"),Sp=class{constructor(e){this._datastore=e,this.stores=[]}async put(e,t,n){if(!(e instanceof Uint8Array))throw(0,vp.default)(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");if(!(t instanceof Uint8Array))throw(0,vp.default)(new Error("Offline datastore value must be a Uint8Array"),"ERR_INVALID_VALUE");let i;try{i=this._routingKey(e)}catch(o){throw VS.error(o),(0,vp.default)(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}let s=new Sr(e,t,new Date);await this._datastore.put(i,s.serialize(),n)}async get(e,t){if(!(e instanceof Uint8Array))throw(0,vp.default)(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");let n;try{n=this._routingKey(e)}catch(o){throw VS.error(o),(0,vp.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=Sr.deserialize(i)}catch(o){throw VS.error(o),o}return s.value}_routingKey(e){return new ie("/dht/record/"+K(e,"base32"),!1)}};u();u();async function yn(r){for await(let e of r);}var L2e=D("ipfs:ipns:dht-datastore"),k6=class{constructor(e){this._dht=e}async put(e,t,n){try{await yn(this._dht.put(e,t,n))}catch(i){throw L2e.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 mn()}};function vV({libp2p:r,repo:e,peerId:t,options:n}){let i=[],s;if((0,Km.default)(n,"EXPERIMENTAL.ipnsPubsub",!1)&&(s=new Of(r.pubsub,e.datastore,t),i.push(s)),(0,Km.default)(n,"offline",!1)!==!0&&["dht","dhtclient","dhtserver"].includes((0,Km.default)(n,"config.Routing.Type","none"))&&i.push(new k6(r.dht)),(0,Km.default)(n,"offline",!1)||i.length===0){let o=new Sp(e.datastore);i.push(o)}return new Mm(i)}var B2e=D("ipfs:components:ipns"),N6=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 rc}get routing(){return this.getIPNS().routing}startOffline({repo:e,peerId:t,keychain:n}){if(this.offline!=null)throw new no;B2e("initializing IPNS keyspace (offline)");let i=new Sp(e.datastore),s=new Bm(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 no;let s=vV({libp2p:e,repo:t,peerId:n,options:this.options}),o=new Bm(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 zS=_(V(),1);u();async function SV({ipns:r,repo:e,codecs:t},n,i){if(b4(n))return r.resolve(n);let{cid:s,path:o}=uc(n);await yn(Au(s,o||"",t,e,i))}var KS=D("ipfs:name:publish");function xV({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 Cn(n.privateKey);else try{let f=await s.exportKey(c,"temp");l=await wc(f,"temp")}catch(f){throw KS.error(f),(0,zS.default)(f,"ERR_CANNOT_GET_KEY")}return sn(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,zS.default)(new Error(T4),"OFFLINE_ERROR");try{c=aB(c)}catch(w){throw KS.error(w),w}let d=0;try{d=Tu(h)||0,d=parseFloat(d.toFixed(6))}catch(w){throw KS.error(w),w}let m=await Promise.all([o(p),f?SV({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 O6=_(V(),1);var RV=_(IV(),1);var U2e=ze.bind({ignoreUndefined:!0}),F2e=D("ipfs:name:resolve"),AV=(r,e)=>e.length>0?r+"/"+e.join("/"):r;function CV({dns:r,ipns:e,isOnline:t,options:{offline:n}}){async function*i(s,o={}){if(o=U2e({nocache:!1,recursive:!0},o),n&&o&&o.nocache)throw(0,O6.default)(new Error("cannot specify both offline and nocache"),"ERR_NOCACHE_AND_OFFLINE");if(!t()&&!n)throw(0,O6.default)(new Error(T4),"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=ce(l),d=Jt(p.toBytes());l=A.createV1(114,d).toString(Fd)}else{let p=A.parse(l);p.version===1&&(l=p.toString(Fd))}}catch(p){if((0,RV.default)(l)){yield AV(await r(l,o),f);return}throw F2e.error(p),(0,O6.default)(new Error("Invalid IPNS name"),"ERR_IPNS_INVALID_NAME")}let h=await e.resolve(`/${c}/${l}`,o);yield AV(h instanceof Uint8Array?K(h):h,f)}return M(i)}u();u();u();var qS=_(V(),1);function xp(r,e){if(!r||!(e&&e.ipnsPubsub))throw(0,qS.default)(new Error("IPNS pubsub subsystem is not enabled"),"ERR_IPNS_PUBSUB_NOT_ENABLED");if(r.routing instanceof Of)return r.routing;let t=(r.routing.stores||[]).find(n=>n instanceof Of);if(!t)throw(0,qS.default)(new Error("IPNS pubsub datastore not found"),"ERR_PUBSUB_DATASTORE_NOT_FOUND");return t}function DV({ipns:r,options:e}){let t=e.EXPERIMENTAL;async function n(i,s={}){return xp(r,t).cancel(i,s)}return M(n)}u();function PV({ipns:r,options:e}){let t=e.EXPERIMENTAL;async function n(i={}){try{return{enabled:Boolean(xp(r,t))}}catch{return{enabled:!1}}}return M(n)}u();function kV({ipns:r,options:e}){let t=e.EXPERIMENTAL;async function n(i={}){return xp(r,t).getSubscriptions(i)}return M(n)}var L6=class{constructor({ipns:e,options:t}){this.cancel=DV({ipns:e,options:t}),this.state=PV({ipns:e,options:t}),this.subs=kV({ipns:e,options:t})}};var B6=class{constructor({dns:e,ipns:t,repo:n,codecs:i,peerId:s,isOnline:o,keychain:a,options:c}){this.publish=xV({ipns:t,repo:n,codecs:i,peerId:s,isOnline:o,keychain:a}),this.resolve=CV({dns:e,ipns:t,isOnline:o,options:c}),this.pubsub=new L6({ipns:t,options:c})}};u();var NV=_(pn(),1),OV=_(ri(),1),V2e=mn().code,$S={default:"<dst>",edges:"<src> -> <dst>"};function LV({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!==$S.default)throw new Error("Cannot set edges to true and also specify format");if(o.format=o.edges?$S.edges:o.format,typeof o.maxDepth!="number"&&(o.maxDepth=o.recursive?1/0:1),o.timeout){let f=[new NV.TimeoutController(o.timeout).signal];o.signal&&f.push(o.signal),o.signal=(0,OV.anySignal)(f)}let c=(Array.isArray(s)?s:[s]).map(l=>K2e(n,l,o));for(let l of c)try{yield*z2e(t,r,e,l,o)}catch(f){yield{ref:"",err:f.message}}}return i}function K2e(r,e,t){let{cid:n,path:i}=uc(e);return t.preload!==!1&&r(n),`/ipfs/${n}${i||""}`}async function*z2e(r,e,t,n,i){let s=await r(n,i),{cid:o}=uc(s),a=i.maxDepth!=null?i.maxDepth:1/0,c=i.unique||!1;for await(let l of $2e(e,t,o,a,c,i))!l.parent||l.isDuplicate||(yield{ref:q2e(l.parent.cid,l.node.cid,l.node.name,i.format)})}function q2e(r,e,t="",n=$S.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*$2e(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 H2e(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===V2e&&(h.message=`Could not find object with CID: ${c.cid}`),h}}yield*a({cid:t},0)}async function*H2e(r,e,t,n){let i=await r.blocks.get(t,n),o=(await e.getCodec(t.code)).decode(i),a=t.code===rt,c=[];for(let[l,f]of HS(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 HS=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*HS(o,a))}else{let s=A.asCID(n);s?yield[i.join("/"),s]:yield*HS(n,i)}}return[]}};u();function BV({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 MV({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 UV({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 FV({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 M6({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 U6=class{constructor({network:e}){this.wantlist=MV({network:e}),this.wantlistForPeer=UV({network:e}),this.unwant=FV({network:e}),this.stat=M6({network:e})}};u();u();u();function F6(r){try{return UL.matches(r)}catch{return!1}}function VV({repo:r}){async function e(t,n={}){if(!F6(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 KV({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=>ee(s))}}return M(e)}u();function zV({repo:r}){async function e(t={}){return{Peers:(await r.config.get("Bootstrap",t)||[]).map(i=>ee(i))}}return M(e)}u();u();var bc=()=>({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 qV({repo:r}){async function e(t={}){let n=await r.config.getAll(t);return n.Bootstrap=bc().Bootstrap,await r.config.replace(n),{Peers:bc().Bootstrap.map(i=>ee(i))}}return M(e)}u();function $V({repo:r}){async function e(t,n={}){if(!F6(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 V6=class{constructor({repo:e}){this.add=VV({repo:e}),this.list=zV({repo:e}),this.rm=$V({repo:e}),this.clear=KV({repo:e}),this.reset=qV({repo:e})}};u();u();function HV({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 GV({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 WV=_(V(),1);u();u();function Lt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var K6=globalThis.CustomEvent??Event;async function*zm(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,s=[],o=Lt(),a=Lt(),c=!1,l,f=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(s.length===t&&(o=Lt(),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.dispatchEvent(new K6("task-complete"))},g=>{y.done=!0,y.err=g,i.dispatchEvent(new K6("task-complete"))})}c=!0,i.dispatchEvent(new K6("task-complete"))}catch(m){l=m,i.dispatchEvent(new K6("task-complete"))}});function h(){return n?s[0]?.done:Boolean(s.find(m=>m.done))}function*p(){for(;s.length>0&&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=Lt(),await a.promise),l!=null)throw l;if(n?yield*p():yield*d(),c&&s.length===0)break}}u();async function*dr(r,e){for await(let t of r)yield e(t)}u();async function*Dn(r,e){for await(let t of r)await e(t)&&(yield t)}u();function z6(r){return r instanceof Uint8Array?A.decode(r):A.parse(r.toString())}var G2e=8;function jV({repo:r}){async function*e(t,n={}){Array.isArray(t)||(t=[t]);let i=await r.gcLock.writeLock();try{yield*de(t,s=>dr(s,o=>async()=>{o=z6(o);let a={cid:o};try{if(!await r.blocks.has(o))throw(0,WV.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=>zm(s,{concurrency:G2e}),s=>Dn(s,()=>!n.quiet))}finally{i()}}return M(e)}u();function YV({repo:r,preload:e}){async function t(n,i={}){n=z6(n),i.preload!==!1&&e(n);let s=await r.blocks.get(n);return{cid:n,size:s.length}}return M(t)}var q6=class{constructor({codecs:e,hashers:t,preload:n,repo:i}){this.get=HV({preload:n,repo:i}),this.put=GV({codecs:e,hashers:t,preload:n,repo:i}),this.rm=jV({repo:i}),this.stat=YV({preload:n,repo:i})}};u();u();u();u();var QV=_(V(),1);u();async function*Cs(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}u();function GS(r){return typeof r.stream=="function"?Cs(r.stream()):Cs(new Response(r).body)}u();function go(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}u();async function oi(r){let e=[];for await(let t of r)e.push(t);return e}u();function Ds(r){return ArrayBuffer.isView(r)||r instanceof ArrayBuffer}function _c(r){return r.constructor&&(r.constructor.name==="Blob"||r.constructor.name==="File")&&typeof r.stream=="function"}function qm(r){return typeof r=="object"&&(r.path||r.content)}var vc=r=>r&&typeof r.getReader=="function";async function*$6(r){yield r}async function H6(r){if(Ds(r))return $6(WS(r));if(typeof r=="string"||r instanceof String)return $6(WS(r.toString()));if(_c(r))return GS(r);if(vc(r)&&(r=Cs(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let e=go(r),{value:t,done:n}=await e.peek();if(n)return $6(new Uint8Array(0));if(e.push(t),Number.isInteger(t))return $6(Uint8Array.from(await oi(e)));if(Ds(t)||typeof t=="string"||t instanceof String)return dr(e,WS)}throw(0,QV.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT")}function WS(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 W6=_(V(),1);async function*XV(r,e){if(r==null)throw(0,W6.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT");if(typeof r=="string"||r instanceof String){yield G6(r.toString(),e);return}if(Ds(r)||_c(r)){yield G6(r,e);return}if(vc(r)&&(r=Cs(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let t=go(r),{value:n,done:i}=await t.peek();if(i){yield{content:[]};return}if(t.push(n),Number.isInteger(n)||Ds(n)||typeof n=="string"||n instanceof String){yield G6(t,e);return}throw(0,W6.default)(new Error("Unexpected input: multiple items passed - if you are using ipfs.add, please use ipfs.addAll instead"),"ERR_UNEXPECTED_INPUT")}if(qm(r)){yield G6(r,e);return}throw(0,W6.default)(new Error('Unexpected input: cannot convert "'+typeof r+'" into ImportCandidate'),"ERR_UNEXPECTED_INPUT")}async function G6(r,e){let{path:t,mode:n,mtime:i,content:s}=r,o={path:t||"",mode:Za(n),mtime:wu(i)};return s?o.content=await e(s):t||(o.content=await e(r)),o}function j6(r){return XV(r,H6)}function ZV({addAll:r}){async function e(t,n={}){let i=await Xt(r(j6(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();u();u();async function*Lf(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>0;)yield t.slice(0,e),t=t.slice(e)}async function*Bf(r,e=1){for await(let t of Lf(r,e)){let n=t.map(async i=>await 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}}}u();u();var jS=_(tK(),1);function W2e(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 eWe=Bd({name:"murmur3-32",code:35,encode:r=>W2e(jS.default.x86.hash32(r))}),Mf=Bd({name:"murmur3-128",code:34,encode:r=>vd.fromHex(jS.default.x64.hash128(r))});async function j2e(r){return(await Mf.encode(r)).slice(0,8).reverse()}var Y2e={chunker:"fixed",strategy:"balanced",rawLeaves:!1,onlyHash:!1,reduceSingleLeafToSelf:!0,hasher:Ke,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:j2e,hamtHashCode:34,hamtBucketBits:8},rK=(r={})=>ze.bind({ignoreUndefined:!0})(Y2e,r);u();u();u();var Q2e=async(r,e,t)=>{t.codec||(t.codec=gt),t.hasher||(t.hasher=Ke),t.cidVersion===void 0&&(t.cidVersion=1),t.codec===gt&&t.hasher!==Ke&&(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},wo=Q2e;var X2e=async(r,e,t)=>{let n=new $e({type:"directory",mtime:r.mtime,mode:r.mode}),i=qe(vn({Data:n.marshal()})),s=await wo(i,e,t),o=r.path;return{cid:s,path:o,unixfs:n,size:i.length}},nK=X2e;u();var uK=_(V(),1);u();async function Z2e(r,e){return e(await oi(r))}var iK=Z2e;u();function J2e(r,e,t){return sK(r,e,t)}async function sK(r,e,t){let n=[];for await(let i of Lf(r,t.maxChildrenPerNode))n.push(await e(i));return n.length>1?sK(n,e,t):n[0]}var oK=J2e;u();async function eye(r,e,t){let n=new YS(t.layerRepeat),i=0,s=1,o=n;for await(let a of Lf(r,t.maxChildrenPerNode))o.isFull()&&(o!==n&&n.addChild(await o.reduce(e)),i&&i%t.layerRepeat===0&&s++,o=new Q6(s,t.layerRepeat,i),i++),o.append(a);return o&&o!==n&&n.addChild(await o.reduce(e)),n.reduce(e)}var aK=eye,Q6=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}},YS=class extends Q6{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*tye(r,e,t){for await(let n of r.content)yield async()=>{t.progress(n.length,r.path);let i,s={codec:gt,cidVersion:t.cidVersion,hasher:t.hasher,onlyHash:t.onlyHash};return t.rawLeaves?(s.codec=mi,s.cidVersion=1):(i=new $e({type:t.leafType,data:n}),n=qe({Data:i.marshal(),Links:[]})),{cid:await wo(n,e,s),unixfs:i,size:n.length}}}var cK=tye;var rye={flat:iK,balanced:oK,trickle:aK};async function*nye(r,e,t){let n=-1,i,s;typeof t.bufferImporter=="function"?s=t.bufferImporter:s=cK;for await(let o of Bf(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 iye=(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 $e({type:"file",mtime:r.mtime,mode:r.mode,data:h}),h=qe(vn({Data:f.unixfs.marshal()})),f.cid=await wo(h,e,{...t,codec:gt,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 $e({type:"file",mtime:r.mtime,mode:r.mode}),o=i.filter(f=>f.cid.code===xn&&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===xn?(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=qe(vn(a));return{cid:await wo(c,e,t),path:r.path,unixfs:s,size:c.length+a.Links.reduce((f,h)=>f+h.Tsize,0)}}return n};function sye(r,e,t){let n=rye[t.strategy];if(!n)throw(0,uK.default)(new Error(`Unknown importer build strategy name: ${t.strategy}`),"ERR_BAD_STRATEGY");return n(nye(r,e,t),iye(r,e,t),t)}var lK=sye;var rx=_(V(),1);u();u();var hK=Symbol.for("@achingbrain/uint8arraylist");function fK(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 Sc(r){return Boolean(r?.[hK])}var et=class{constructor(...e){Object.defineProperty(this,hK,{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(Sc(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(Sc(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=fK(this.bufs,e);return t.buf[t.index]}set(e,t){let n=fK(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(Sc(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 De(n,i)}subarray(e,t){let{bufs:n,length:i}=this._subList(e,t);return n.length===1?n[0]:De(n,i)}sublist(e,t){let{bufs:n,length:i}=this._subList(e,t),s=new et;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=so(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=sc(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=sc(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=sc(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=so(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=sc(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=sc(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=sc(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=sc(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=sc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof et)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Be(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new et;return n.bufs=e,t==null&&(t=e.reduce((i,s)=>i+s.byteLength,0)),n.length=t,n}};var IK=_(TK(),1),ex=_(V(),1);async function*fye(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,ex.default)(new Error("please specify an average chunk size"),"ERR_INVALID_AVG_CHUNK_SIZE");if(t<16)throw(0,ex.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 hye(r,{min:t,max:n,bits:s,window:e.window,polynomial:e.polynomial}))yield o}var AK=fye;async function*hye(r,e){let t=await(0,IK.create)(e.bits,e.min,e.max,e.window),n=new et;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.subarray(0))}u();async function*dye(r,e){let t=new et,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 et,n=0;else{let a=new et;a.append(t.sublist(s)),t=a,n-=s}(!i||n)&&(yield t.subarray(0,n))}var RK=dye;u();var tx=_(V(),1);async function*pye(r){for await(let e of r){if(e.length===void 0)throw(0,tx.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,tx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}}var CK=pye;function mye(r){return Symbol.iterator in r}function yye(r){return Symbol.asyncIterator in r}function gye(r){try{if(r instanceof Uint8Array)return async function*(){yield r}();if(mye(r))return async function*(){yield*r}();if(yye(r))return r}catch{throw(0,rx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,rx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}async function*wye(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=AK:i=RK;let s;typeof t.chunkValidator=="function"?s=t.chunkValidator:s=CK;let o={path:n.path,mtime:n.mtime,mode:n.mode,content:i(s(gye(n.content),t),t)};yield()=>lK(o,e,t)}else if(n.path){let i={path:n.path,mtime:n.mtime,mode:n.mode};yield()=>nK(i,e,t)}else throw new Error("Import candidate must have content or path or both")}var DK=wye;u();u();u();var nx=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){}},Hu=nx;var ix=class extends Hu{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 Hu)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 $e({type:"directory",mtime:this.mtime,mode:this.mode}),s={Data:i.marshal(),Links:n},o=qe(vn(s)),a=await wo(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}}},jm=ix;u();u();u();u();var OK=_(NK(),1);var xr=class{constructor(e,t,n=0){this._options=e,this._popCount=0,this._parent=t,this._posAtParent=n,this._children=new OK.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 xr?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 xr?yield*t.eachLeafSeries():yield t}serialize(e,t){let n=[];return t(this._children.reduce((i,s,o)=>(s!=null&&(s instanceof xr?i.push(s.serialize(e,t)):i.push(e(s,o))),i),n))}async asyncTransform(e,t){return await LK(this,e,t)}toJSON(){return this.serialize(Sye,xye)}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 xr)&&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 xr?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 xr(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(vye);if(e!=null&&!(e instanceof xr)){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 vye(r){return Boolean(r)}function Sye(r,e){return r.key}function xye(r){return r}async function LK(r,e,t){let n=[];for(let i of r._children.compactArray())if(i instanceof xr)await LK(i,e,t);else{let s=await e(i);n.push({bitField:r._children.bitField(),children:s})}return await t(n)}u();u();var Tye=[255,254,252,248,240,224,192,128],Iye=[1,3,7,15,31,63,127,255],X6=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=Aye(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 Aye(r,e,t){let n=Rye(e,t);return(r&n)>>>e}function Rye(r,e){return Tye[r]&Iye[Math.min(e+r-1,7)]}function BK(r){function e(t){return t instanceof Z6?t:new Z6(t,r)}return e}var Z6=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?De([this._value,Uint8Array.from([this._depth])]):this._value,t=await this._hashFn(e),n=new X6(t);this._buffers.push(n),this._availableBits+=n.availableBits()}};function Gu(r){if(r==null||r.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:r.bits??8,hash:BK(r.hashFn)};return new xr(e)}var sx=class extends Hu{constructor(e,t){super(e,t),this._bucket=Gu({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 UK(this._bucket,e,this,this.options))yield{...t,path:this.path}}},MK=sx;async function*UK(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 xr){let g;for await(let w of await UK(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 v of g.flush(e))w=v,yield w;let E=y+m.key;s.push({Name:E,Tsize:w.size,Hash:w.cid}),o+=w.size}else{let g=m.value;if(!g.cid)continue;let w=y+m.key,E=g.size;s.push({Name:w,Tsize:E,Hash:g.cid}),o+=E}}let a=Uint8Array.from(i.bitField().reverse()),c=new $e({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=qe(vn(l)),h=await wo(f,e,n),p=f.length+o;yield{cid:h,unixfs:c,size:p}}async function FK(r,e,t,n){let i=e;e instanceof jm&&e.directChildrenCount()>=t&&(i=await Cye(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 FK(i,s,t,n)}return i}async function Cye(r,e){let t=new MK({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 VK=FK;u();var Dye=(r="")=>(r.trim().match(/([^\\/]|\\\/)+/g)||[]).filter(Boolean),KK=Dye;async function Pye(r,e,t){let n=KK(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 VK(null,s,t.shardSplitThreshold,t);else{let f=await s.get(c);(!f||!(f instanceof Hu))&&(f=new jm({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*zK(r,e){if(!(r instanceof Hu)){r&&r.unixfs&&r.unixfs.isDirectory()&&(yield r);return}yield*r.flush(e)}async function*kye(r,e,t){let n=new jm({root:!0,dir:!0,path:"",dirty:!0,flat:!0},t);for await(let i of r)!i||(n=await Pye(i,n,t),(!i.unixfs||!i.unixfs.isDirectory())&&(yield i));if(t.wrapWithDirectory)yield*zK(n,e);else for await(let i of n.eachChildSeries())!i||(yield*zK(i.child,e))}var qK=kye;async function*Tp(r,e,t={}){let n=rK(t),i;typeof t.dagBuilder=="function"?i=t.dagBuilder:i=DK;let s;typeof t.treeBuilder=="function"?s=t.treeBuilder:s=qK;let o;Symbol.asyncIterator in r||Symbol.iterator in r?o=r:o=[r];for await(let a of s(Bf(i(o,e,n),n.fileImportConcurrency),e,n))yield{cid:a.cid,path:a.path,unixfs:a.unixfs,size:a.size}}u();u();var Ym=_(V(),1);async function*J6(r,e){if(typeof r=="string"||r instanceof String||Ds(r)||_c(r)||r._readableState)throw(0,Ym.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(vc(r)&&(r=Cs(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let t=go(r),{value:n,done:i}=await t.peek();if(i){yield*[];return}if(t.push(n),Number.isInteger(n))throw(0,Ym.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*dr(t,s=>ox({content:s},e));return}if(Ds(n)){yield ox({content:t},e);return}if(qm(n)||n[Symbol.iterator]||n[Symbol.asyncIterator]||vc(n)||_c(n)){yield*dr(t,s=>ox(s,e));return}}throw qm(r)?(0,Ym.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT"):(0,Ym.default)(new Error("Unexpected input: "+typeof r),"ERR_UNEXPECTED_INPUT")}async function ox(r,e){let{path:t,mode:n,mtime:i,content:s}=r,o={path:t||"",mode:Za(n),mtime:wu(i)};return s?o.content=await e(s):t||(o.content=await e(r)),o}function $K(r){return J6(r,H6)}u();var HK=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",...Nye(r)};throw new Error(`Unrecognized chunker option: ${r}`)}else return{chunker:"fixed"}},Nye=r=>{let e={},t=r.split("-");switch(t.length){case 1:e.avgChunkSize=262144;break;case 2:e.avgChunkSize=ew(t[1],"avg");break;case 4:e.minChunkSize=ew(t[1],"min"),e.avgChunkSize=ew(t[2],"avg"),e.maxChunkSize=ew(t[3],"max");break;default:throw new Error('Incorrect chunker format (expected "rabin" "rabin-[avg]" or "rabin-[min]-[avg]-[max]"')}return e},ew=(r,e)=>{let t=parseInt(r);if(isNaN(t))throw new Error(`Chunker parameter ${e} must be an integer`);return t};var Oye=ze.bind({ignoreUndefined:!0});function GK({repo:r,preload:e,hashers:t,options:n}){let i=n&&n.sharding;async function*s(o,a={}){let c=Oye({shardSplitThreshold:i?1e3:1/0,strategy:"balanced"},a,{...HK(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=de($K(o),d=>Tp(d,r.blocks,{...c,hasher:f,pin:!1}),Lye(c),Bye(e,c),Mye(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 Lye(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 Bye(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 Mye(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 fw=_(V(),1);u();var yz=_(V(),1);u();var lw=_(V(),1);u();var Uye=async function(r){return(await Mf.encode(r)).slice(0,8).reverse()},Fye=(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 xr({hash:t._options.hash,bits:t._options.bits},e,i))}return t.put(n.Name.substring(2),!0)})),WK=r=>r.toString(16).toUpperCase().padStart(2,"0").substring(0,2),Vye=r=>{let e=r.bucket,t=[];for(;e._parent;)t.push(e),e=e._parent;return t.push(e),t.reverse()},jK=async(r,e,t,n,i)=>{if(!n){let f=Gu({hashFn:Uye});n={rootBucket:f,hamtDepth:1,lastBucket:f}}await Fye(r.Links,n.lastBucket,n.rootBucket);let s=await n.rootBucket._findNewBucketAndPos(e),o=WK(s.pos),a=Vye(s);a.length>n.hamtDepth&&(n.lastBucket=a[n.hamtDepth],o=WK(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=yt(l),jK(r,e,t,n,i)},YK=jK;u();u();function Kye(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 Uf=Kye;u();var tw=_(V(),1),zye=(r,e,t)=>{if(e||(e=0),e<0)throw(0,tw.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(e>r)throw(0,tw.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,tw.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}},Ip=zye;var uw=_(V(),1);u();var iz=_(Ru(),1);u();var Qm=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},ax=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},QK=r=>globalThis.DOMException===void 0?new ax(r):new DOMException(r),XK=r=>{let e=r.reason===void 0?QK("This operation was aborted."):r.reason;return e instanceof Error?e:QK(e)};function cx(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(XK(c)),c.addEventListener("abort",()=>{a(XK(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 Qm(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 ux(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 Ff=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)},xc,Xm=class{constructor(){xc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Ff(this,xc,"f")[this.size-1].priority>=t.priority){Ff(this,xc,"f").push(n);return}let i=ux(Ff(this,xc,"f"),n,(s,o)=>o.priority-s.priority);Ff(this,xc,"f").splice(i,0,n)}dequeue(){let e=Ff(this,xc,"f").shift();return e?.run}filter(e){return Ff(this,xc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ff(this,xc,"f").length}};xc=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},we=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)},Wr,Jm,e2,ju,aw,t2,rw,Eo,Zm,Ki,nw,zi,r2,Wu,iw,ZK,JK,nz,ez,tz,rz,sw,lx,fx,cw,ow,qye=new Qm,hx=class extends Error{},n2=class extends iz.default{constructor(e){var t,n,i,s;if(super(),Wr.add(this),Jm.set(this,void 0),e2.set(this,void 0),ju.set(this,0),aw.set(this,void 0),t2.set(this,void 0),rw.set(this,0),Eo.set(this,void 0),Zm.set(this,void 0),Ki.set(this,void 0),nw.set(this,void 0),zi.set(this,0),r2.set(this,void 0),Wu.set(this,void 0),iw.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:Xm,...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,Jm,e.carryoverConcurrencyCount,"f"),Tr(this,e2,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Tr(this,aw,e.intervalCap,"f"),Tr(this,t2,e.interval,"f"),Tr(this,Ki,new e.queueClass,"f"),Tr(this,nw,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Tr(this,iw,e.throwOnTimeout===!0,"f"),Tr(this,Wu,e.autoStart===!1,"f")}get concurrency(){return we(this,r2,"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,r2,e,"f"),we(this,Wr,"m",cw).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Tr(this,zi,(a=we(this,zi,"f"),a++,a),"f"),Tr(this,ju,(c=we(this,ju,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new hx("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):cx(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?we(this,iw,"f"):t.throwOnTimeout)&&i(qye)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}we(this,Wr,"m",nz).call(this)};we(this,Ki,"f").enqueue(s,t),we(this,Wr,"m",sw).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return we(this,Wu,"f")?(Tr(this,Wu,!1,"f"),we(this,Wr,"m",cw).call(this),this):this}pause(){Tr(this,Wu,!0,"f")}clear(){Tr(this,Ki,new(we(this,nw,"f")),"f")}async onEmpty(){we(this,Ki,"f").size!==0&&await we(this,Wr,"m",ow).call(this,"empty")}async onSizeLessThan(e){we(this,Ki,"f").size<e||await we(this,Wr,"m",ow).call(this,"next",()=>we(this,Ki,"f").size<e)}async onIdle(){we(this,zi,"f")===0&&we(this,Ki,"f").size===0||await we(this,Wr,"m",ow).call(this,"idle")}get size(){return we(this,Ki,"f").size}sizeBy(e){return we(this,Ki,"f").filter(e).length}get pending(){return we(this,zi,"f")}get isPaused(){return we(this,Wu,"f")}};Jm=new WeakMap,e2=new WeakMap,ju=new WeakMap,aw=new WeakMap,t2=new WeakMap,rw=new WeakMap,Eo=new WeakMap,Zm=new WeakMap,Ki=new WeakMap,nw=new WeakMap,zi=new WeakMap,r2=new WeakMap,Wu=new WeakMap,iw=new WeakMap,Wr=new WeakSet,ZK=function(){return we(this,e2,"f")||we(this,ju,"f")<we(this,aw,"f")},JK=function(){return we(this,zi,"f")<we(this,r2,"f")},nz=function(){var e;Tr(this,zi,(e=we(this,zi,"f"),e--,e),"f"),we(this,Wr,"m",sw).call(this),this.emit("next")},ez=function(){this.emit("empty"),we(this,zi,"f")===0&&this.emit("idle")},tz=function(){we(this,Wr,"m",fx).call(this),we(this,Wr,"m",lx).call(this),Tr(this,Zm,void 0,"f")},rz=function(){let e=Date.now();if(we(this,Eo,"f")===void 0){let t=we(this,rw,"f")-e;if(t<0)Tr(this,ju,we(this,Jm,"f")?we(this,zi,"f"):0,"f");else return we(this,Zm,"f")===void 0&&Tr(this,Zm,setTimeout(()=>{we(this,Wr,"m",tz).call(this)},t),"f"),!0}return!1},sw=function(){if(we(this,Ki,"f").size===0)return we(this,Eo,"f")&&clearInterval(we(this,Eo,"f")),Tr(this,Eo,void 0,"f"),we(this,Wr,"m",ez).call(this),!1;if(!we(this,Wu,"f")){let e=!we(this,Wr,"a",rz);if(we(this,Wr,"a",ZK)&&we(this,Wr,"a",JK)){let t=we(this,Ki,"f").dequeue();return t?(this.emit("active"),t(),e&&we(this,Wr,"m",lx).call(this),!0):!1}}return!1},lx=function(){we(this,e2,"f")||we(this,Eo,"f")!==void 0||(Tr(this,Eo,setInterval(()=>{we(this,Wr,"m",fx).call(this)},we(this,t2,"f")),"f"),Tr(this,rw,Date.now()+we(this,t2,"f"),"f"))},fx=function(){we(this,ju,"f")===0&&we(this,zi,"f")===0&&we(this,Eo,"f")&&(clearInterval(we(this,Eo,"f")),Tr(this,Eo,void 0,"f")),Tr(this,ju,we(this,Jm,"f")?we(this,zi,"f"):0,"f"),we(this,Wr,"m",cw).call(this)},cw=function(){for(;we(this,Wr,"m",sw).call(this););},ow=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};async function sz(r,e,t,n,i,s,o,a){if(e instanceof Uint8Array){t.push(Uf(e,n,i,s));return}if(e.Data==null)throw(0,uw.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let c;try{c=$e.unmarshal(e.Data)}catch(f){throw(0,uw.default)(f,"ERR_NOT_UNIXFS")}if(c.data!=null){let f=c.data,h=Uf(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 de(l,f=>dr(f,h=>async()=>{let p=await r.get(h.link.Hash,{signal:a.signal});return{...h,block:p}}),f=>zm(f,{ordered:!0}),async f=>{for await(let{link:h,block:p,blockStart:d}of f){let m;switch(h.Hash.code){case rt:m=yt(p);break;case xn:m=p;break;default:t.end((0,uw.default)(new Error(`Unsupported codec: ${h.Hash.code}`),"ERR_NOT_UNIXFS"));return}o.add(async()=>{await sz(r,m,t,d,i,s,o,a)})}})}var $ye=(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}=Ip(l,c.offset,c.length);if(h===0)return;let p=new n2({concurrency:1}),d=Vt();p.add(async()=>{await sz(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},dx=$ye;u();var Hye=(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},oz=Hye;u();var Gye=(r,e,t,n,i,s,o)=>{function a(c={}){return az(e,n,i,s,o,c)}return a};async function*az(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=yt(l);for await(let f of az(r,e,t,n,i,s))yield f}}}var cz=Gye;var Wye=(r,e)=>{let t=r.Links.find(n=>n.Name===e);return t&&t.Hash},jye={raw:dx,file:dx,directory:oz,"hamt-sharded-directory":cz,metadata:(r,e,t,n,i,s,o)=>()=>[],symlink:(r,e,t,n,i,s,o)=>()=>[]},Yye=async(r,e,t,n,i,s,o,a)=>{let c=await o.get(r,a),l=yt(c),f,h;if(e||(e=r.toString()),l.Data==null)throw(0,lw.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{f=$e.unmarshal(l.Data)}catch(p){throw(0,lw.default)(p,"ERR_NOT_UNIXFS")}if(t||(t=e),n.length){let p;if(f&&f.type==="hamt-sharded-directory"?p=await YK(l,n[0],o):p=Wye(l,n[0]),!p)throw(0,lw.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:jye[f.type](r,l,f,t,i,s,o),unixfs:f,depth:s,node:l,size:f.fileSize()},next:h}},uz=Yye;u();var lz=_(V(),1);var Qye=r=>{async function*e(t={}){let{offset:n,length:i}=Ip(r.length,t.offset,t.length);yield Uf(r,0,n,n+i)}return e},Xye=async(r,e,t,n,i,s,o,a)=>{if(n.length)throw(0,lz.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:Qye(c),depth:s,size:c.length,node:c}}},fz=Xye;u();var hz=_(V(),1);var Zye=async(r,e,t,n,i,s,o,a)=>{let c=await o.get(r),l=hf(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,hz.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}}}},dz=Zye;u();var pz=_(V(),1);var Jye=r=>{async function*e(t={}){let{offset:n,length:i}=Ip(r.length,t.offset,t.length);yield Uf(r,0,n,n+i)}return e},ege=async(r,e,t,n,i,s,o,a)=>{if(n.length)throw(0,pz.default)(new Error(`No link named ${t} found in raw node ${r}`),"ERR_NOT_FOUND");let c=await Jt(r.multihash.bytes);return{entry:{type:"identity",name:e,path:t,cid:r,content:Jye(c.digest),depth:s,size:c.digest.length,node:c.digest}}},mz=ege;var tge={[rt]:uz,[xn]:fz,[F1]:dz,[rn.code]:mz};function gz(r,e,t,n,i,s,o){let a=tge[r.code];if(!a)throw(0,yz.default)(new Error(`No resolver for code ${r.code}`),"ERR_NO_RESOLVER");return a(r,e,t,n,gz,i,s,o)}var wz=gz;var rge=(r="")=>(r.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean),nge=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=rge(r);return{cid:A.parse(t[0]),toResolve:t.slice(1)}}throw(0,fw.default)(new Error(`Unknown path type ${r}`),"ERR_BAD_PATH")};async function*px(r,e,t={}){let{cid:n,toResolve:i}=nge(r),s=n.toString(),o=s,a=i.length;for(;;){let c=await wz(n,s,o,i,a,e,t);if(!c.entry&&!c.next)throw(0,fw.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 Kn(r,e,t={}){let n=await Xt(px(r,e,t));if(!n)throw(0,fw.default)(new Error(`Could not resolve ${r}`),"ERR_NOT_FOUND");return n}async function*hw(r,e,t={}){let n=await Kn(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 Ez({repo:r,preload:e}){async function*t(n,i={}){if(n=zd(n),i.preload!==!1){let o=n.split("/");e(A.parse(o[0]))}let s=await Kn(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 Np=_(V(),1);u();u();u();u();function Vf(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 tXe="0".charCodeAt(0),rXe=z("ustar\0","binary"),nXe=z("ustar ","binary"),iXe=z(" \0","binary");u();u();function dw(r){let e=async function*(){let t=yield,n=new et;for await(let i of r){if(t==null){n.append(i),t=yield n,n=new et;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 et);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 Sz=_(_z(),1);u();async function Ap(r){let e=new Uint8Array(0);for await(let t of r)e=De([e,t],e.length+t.length);return e}u();var sge="0000000000000000000",oge="7777777777777777777",age="0".charCodeAt(0),cge=z("ustar\0","binary"),uge=z("00","binary"),lge=parseInt("7777",8),fge=257,hge=263,dge=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}},pge=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},Yu=function(r,e){let t=r.toString(8);return t.length>e?z(oge.slice(0,e)+" "):z(sge.slice(0,e-t.length)+t+" ")},mx=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 vz(r){let e="";r.name!=null&&(e+=mx(" path="+r.name+`
`)),r.linkname!=null&&(e+=mx(" linkpath="+r.linkname+`
`));let t=r.pax;if(t!=null)for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e+=mx(" "+n+"="+t[n]+`
`));return z(e)}function pw(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(Yu(r.mode&lge,6),100),e.set(Yu(r.uid,6),108),e.set(Yu(r.gid,6),116),e.set(Yu(r.size,11),124),e.set(Yu(r.mtime.getTime()/1e3|0,11),136),e[156]=age+dge(r.type),r.linkname!=null&&e.set(z(r.linkname),157),e.set(cge,fge),e.set(uge,hge),r.uname!=null&&e.set(z(r.uname),265),r.gname!=null&&e.set(z(r.gname),297),e.set(Yu(r.devmajor??0,6),329),e.set(Yu(r.devminor??0,6),337),n!=null&&e.set(z(n),345),e.set(Yu(pge(e),6),148),e)}var{S_IFMT:yge,S_IFBLK:gge,S_IFCHR:wge,S_IFDIR:Ege,S_IFIFO:bge,S_IFLNK:_ge}=Sz.default,vge=parseInt("755",8),Sge=parseInt("644",8),xz=new Uint8Array(1024);function xge(r=0){switch(r&yge){case gge:return"block-device";case wge:return"character-device";case Ege:return"directory";case bge:return"fifo";case _ge:return"symlink";default:return"file"}}function gx(r){return r&=511,r!==0?xz.subarray(0,512-r):new Uint8Array(0)}function yx(r){if(r.pax==null){let e=pw(r);if(e!=null)return e}return Tge(r)}function Tge(r){let e=vz(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 et(pw(t)??new Uint8Array(0),e,gx(e.length),pw({...t,size:r.size,type:r.type})??new Uint8Array(0)).subarray()}function mw(){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??xge(e.mode),mode:e.mode??(e.type==="directory"?vge:Sge),uid:e.uid??0,gid:e.gid??0,mtime:e.mtime??new Date};if(typeof t=="string"&&(t=z(t)),t instanceof Uint8Array||Sc(t)){n.size=t.length,yield yx(n),yield Sc(t)?t.subarray():t,yield gx(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 Ap(t)),yield yx(n);continue}if(yield yx(n),n.type!=="file"&&n.type!=="contiguous-file")continue;let i=0;for await(let s of t??[])i+=s.length,yield Sc(s)?s.subarray():s;if(i!==n.size)throw new Error(`size mismatch, wrote ${i} of ${n.size} bytes`);yield gx(n.size)}yield xz}}u();function Pp(r){let e=r.length;for(;--e>=0;)r[e]=0}var Ige=0,uq=1,Age=2,Rge=3,Cge=258,Bx=29,w2=256,l2=w2+1+Bx,Dp=30,Mx=19,lq=2*l2+1,Kf=15,wx=16,Dge=7,Ux=256,fq=16,hq=17,dq=18,kx=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]),_w=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]),Pge=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pq=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),kge=512,Ic=new Array((l2+2)*2);Pp(Ic);var a2=new Array(Dp*2);Pp(a2);var f2=new Array(kge);Pp(f2);var h2=new Array(Cge-Rge+1);Pp(h2);var Fx=new Array(Bx);Pp(Fx);var Tw=new Array(Dp);Pp(Tw);function Ex(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 mq,yq,gq;function bx(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}var wq=r=>r<256?f2[r]:f2[256+(r>>>7)],d2=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},vi=(r,e,t)=>{r.bi_valid>wx-t?(r.bi_buf|=e<<r.bi_valid&65535,d2(r,r.bi_buf),r.bi_buf=e>>wx-r.bi_valid,r.bi_valid+=t-wx):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},da=(r,e,t)=>{vi(r,t[e*2],t[e*2+1])},Eq=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},Nge=r=>{r.bi_valid===16?(d2(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)},Oge=(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<=Kf;p++)r.bl_count[p]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<lq;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--)}},bq=(r,e,t)=>{let n=new Array(Kf+1),i=0,s,o;for(s=1;s<=Kf;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]=Eq(n[a]++,a))}},Lge=()=>{let r,e,t,n,i,s=new Array(Kf+1);for(t=0,n=0;n<Bx-1;n++)for(Fx[n]=t,r=0;r<1<<kx[n];r++)h2[t++]=n;for(h2[t-1]=n,i=0,n=0;n<16;n++)for(Tw[n]=i,r=0;r<1<<_w[n];r++)f2[i++]=n;for(i>>=7;n<Dp;n++)for(Tw[n]=i<<7,r=0;r<1<<_w[n]-7;r++)f2[256+i++]=n;for(e=0;e<=Kf;e++)s[e]=0;for(r=0;r<=143;)Ic[r*2+1]=8,r++,s[8]++;for(;r<=255;)Ic[r*2+1]=9,r++,s[9]++;for(;r<=279;)Ic[r*2+1]=7,r++,s[7]++;for(;r<=287;)Ic[r*2+1]=8,r++,s[8]++;for(bq(Ic,l2+1,s),r=0;r<Dp;r++)a2[r*2+1]=5,a2[r*2]=Eq(r,5);mq=new Ex(Ic,kx,w2+1,l2,Kf),yq=new Ex(a2,_w,0,Dp,Kf),gq=new Ex(new Array(0),Pge,0,Mx,Dge)},_q=r=>{let e;for(e=0;e<l2;e++)r.dyn_ltree[e*2]=0;for(e=0;e<Dp;e++)r.dyn_dtree[e*2]=0;for(e=0;e<Mx;e++)r.bl_tree[e*2]=0;r.dyn_ltree[Ux*2]=1,r.opt_len=r.static_len=0,r.last_lit=r.matches=0},vq=r=>{r.bi_valid>8?d2(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},Bge=(r,e,t,n)=>{vq(r),n&&(d2(r,t),d2(r,~t)),r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},Tz=(r,e,t,n)=>{let i=e*2,s=t*2;return r[i]<r[s]||r[i]===r[s]&&n[e]<=n[t]},_x=(r,e,t)=>{let n=r.heap[t],i=t<<1;for(;i<=r.heap_len&&(i<r.heap_len&&Tz(e,r.heap[i+1],r.heap[i],r.depth)&&i++,!Tz(e,n,r.heap[i],r.depth));)r.heap[t]=r.heap[i],t=i,i<<=1;r.heap[t]=n},Iz=(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?da(r,i,e):(o=h2[i],da(r,o+w2+1,e),a=kx[o],a!==0&&(i-=Fx[o],vi(r,i,a)),n--,o=wq(n),da(r,o,t),a=_w[o],a!==0&&(n-=Tw[o],vi(r,n,a)));while(s<r.last_lit);da(r,Ux,e)},Nx=(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=lq,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--)_x(r,t,o);l=s;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],_x(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++,_x(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],Oge(r,e),bq(t,c,r.bl_count)},Az=(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[fq*2]++):a<=10?r.bl_tree[hq*2]++:r.bl_tree[dq*2]++,a=0,i=s,o===0?(c=138,l=3):s===o?(c=6,l=3):(c=7,l=4))},Rz=(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 da(r,s,r.bl_tree);while(--a!==0);else s!==0?(s!==i&&(da(r,s,r.bl_tree),a--),da(r,fq,r.bl_tree),vi(r,a-3,2)):a<=10?(da(r,hq,r.bl_tree),vi(r,a-3,3)):(da(r,dq,r.bl_tree),vi(r,a-11,7));a=0,i=s,o===0?(c=138,l=3):s===o?(c=6,l=3):(c=7,l=4)}},Mge=r=>{let e;for(Az(r,r.dyn_ltree,r.l_desc.max_code),Az(r,r.dyn_dtree,r.d_desc.max_code),Nx(r,r.bl_desc),e=Mx-1;e>=3&&r.bl_tree[pq[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},Uge=(r,e,t,n)=>{let i;for(vi(r,e-257,5),vi(r,t-1,5),vi(r,n-4,4),i=0;i<n;i++)vi(r,r.bl_tree[pq[i]*2+1],3);Rz(r,r.dyn_ltree,e-1),Rz(r,r.dyn_dtree,t-1)},Fge=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<w2;t++)if(r.dyn_ltree[t*2]!==0)return 1;return 0},Cz=!1,Vge=r=>{Cz||(Lge(),Cz=!0),r.l_desc=new bx(r.dyn_ltree,mq),r.d_desc=new bx(r.dyn_dtree,yq),r.bl_desc=new bx(r.bl_tree,gq),r.bi_buf=0,r.bi_valid=0,_q(r)},Sq=(r,e,t,n)=>{vi(r,(Ige<<1)+(n?1:0),3),Bge(r,e,t,!0)},Kge=r=>{vi(r,uq<<1,3),da(r,Ux,Ic),Nge(r)},zge=(r,e,t,n)=>{let i,s,o=0;r.level>0?(r.strm.data_type===2&&(r.strm.data_type=Fge(r)),Nx(r,r.l_desc),Nx(r,r.d_desc),o=Mge(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?Sq(r,e,t,n):r.strategy===4||s===i?(vi(r,(uq<<1)+(n?1:0),3),Iz(r,Ic,a2)):(vi(r,(Age<<1)+(n?1:0),3),Uge(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),Iz(r,r.dyn_ltree,r.dyn_dtree)),_q(r),n&&vq(r)},qge=(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[(h2[t]+w2+1)*2]++,r.dyn_dtree[wq(e)*2]++),r.last_lit===r.lit_bufsize-1),$ge=Vge,Hge=Sq,Gge=zge,Wge=qge,jge=Kge,Yge={_tr_init:$ge,_tr_stored_block:Hge,_tr_flush_block:Gge,_tr_tally:Wge,_tr_align:jge},Qge=(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},p2=Qge,Xge=()=>{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},Zge=new Uint32Array(Xge()),Jge=(r,e,t,n)=>{let i=Zge,s=n+t;r^=-1;for(let o=n;o<s;o++)r=r>>>8^i[(r^e[o])&255];return r^-1},Pn=Jge,qf={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"},Wf={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:e3e,_tr_stored_block:t3e,_tr_flush_block:r3e,_tr_tally:el,_tr_align:n3e}=Yge,{Z_NO_FLUSH:jf,Z_PARTIAL_FLUSH:i3e,Z_FULL_FLUSH:s3e,Z_FINISH:tl,Z_BLOCK:Dz,Z_OK:pa,Z_STREAM_END:Pz,Z_STREAM_ERROR:Ps,Z_DATA_ERROR:o3e,Z_BUF_ERROR:vx,Z_DEFAULT_COMPRESSION:a3e,Z_FILTERED:c3e,Z_HUFFMAN_ONLY:yw,Z_RLE:u3e,Z_FIXED:l3e,Z_DEFAULT_STRATEGY:f3e,Z_UNKNOWN:h3e,Z_DEFLATED:Rw}=Wf,d3e=9,p3e=15,m3e=8,y3e=29,g3e=256,Ox=g3e+1+y3e,w3e=30,E3e=19,b3e=2*Ox+1,_3e=15,wt=3,Zu=258,bo=Zu+wt+1,v3e=32,Cw=42,Lx=69,vw=73,Sw=91,xw=103,zf=113,s2=666,gn=1,E2=2,$f=3,kp=4,S3e=3,Ju=(r,e)=>(r.msg=qf[e],e),kz=r=>(r<<1)-(r>4?9:0),Xu=r=>{let e=r.length;for(;--e>=0;)r[e]=0},x3e=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask,rl=x3e,Qu=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))},zn=(r,e)=>{r3e(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,Qu(r.strm)},Dt=(r,e)=>{r.pending_buf[r.pending++]=e},i2=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},T3e=(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=p2(r.adler,e,i,t):r.state.wrap===2&&(r.adler=Pn(r.adler,e,i,t)),r.next_in+=i,r.total_in+=i,i)},xq=(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-bo?r.strstart-(r.w_size-bo):0,l=r.window,f=r.w_mask,h=r.prev,p=r.strstart+Zu,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=Zu-(p-n),n=p-Zu,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},Hf=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-bo)){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=T3e(r.strm,r.window,r.strstart+r.lookahead,s),r.lookahead+=n,r.lookahead+r.insert>=wt)for(o=r.strstart-r.insert,r.ins_h=r.window[o],r.ins_h=rl(r,r.ins_h,r.window[o+1]);r.insert&&(r.ins_h=rl(r,r.ins_h,r.window[o+wt-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<wt)););}while(r.lookahead<bo&&r.strm.avail_in!==0)},I3e=(r,e)=>{let t=65535;for(t>r.pending_buf_size-5&&(t=r.pending_buf_size-5);;){if(r.lookahead<=1){if(Hf(r),r.lookahead===0&&e===jf)return gn;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,zn(r,!1),r.strm.avail_out===0)||r.strstart-r.block_start>=r.w_size-bo&&(zn(r,!1),r.strm.avail_out===0))return gn}return r.insert=0,e===tl?(zn(r,!0),r.strm.avail_out===0?$f:kp):(r.strstart>r.block_start&&(zn(r,!1),r.strm.avail_out===0),gn)},Sx=(r,e)=>{let t,n;for(;;){if(r.lookahead<bo){if(Hf(r),r.lookahead<bo&&e===jf)return gn;if(r.lookahead===0)break}if(t=0,r.lookahead>=wt&&(r.ins_h=rl(r,r.ins_h,r.window[r.strstart+wt-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-bo&&(r.match_length=xq(r,t)),r.match_length>=wt)if(n=el(r,r.strstart-r.match_start,r.match_length-wt),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=wt){r.match_length--;do r.strstart++,r.ins_h=rl(r,r.ins_h,r.window[r.strstart+wt-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=rl(r,r.ins_h,r.window[r.strstart+1]);else n=el(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(n&&(zn(r,!1),r.strm.avail_out===0))return gn}return r.insert=r.strstart<wt-1?r.strstart:wt-1,e===tl?(zn(r,!0),r.strm.avail_out===0?$f:kp):r.last_lit&&(zn(r,!1),r.strm.avail_out===0)?gn:E2},Rp=(r,e)=>{let t,n,i;for(;;){if(r.lookahead<bo){if(Hf(r),r.lookahead<bo&&e===jf)return gn;if(r.lookahead===0)break}if(t=0,r.lookahead>=wt&&(r.ins_h=rl(r,r.ins_h,r.window[r.strstart+wt-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=wt-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-bo&&(r.match_length=xq(r,t),r.match_length<=5&&(r.strategy===c3e||r.match_length===wt&&r.strstart-r.match_start>4096)&&(r.match_length=wt-1)),r.prev_length>=wt&&r.match_length<=r.prev_length){i=r.strstart+r.lookahead-wt,n=el(r,r.strstart-1-r.prev_match,r.prev_length-wt),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=i&&(r.ins_h=rl(r,r.ins_h,r.window[r.strstart+wt-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=wt-1,r.strstart++,n&&(zn(r,!1),r.strm.avail_out===0))return gn}else if(r.match_available){if(n=el(r,0,r.window[r.strstart-1]),n&&zn(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return gn}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(n=el(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<wt-1?r.strstart:wt-1,e===tl?(zn(r,!0),r.strm.avail_out===0?$f:kp):r.last_lit&&(zn(r,!1),r.strm.avail_out===0)?gn:E2},A3e=(r,e)=>{let t,n,i,s,o=r.window;for(;;){if(r.lookahead<=Zu){if(Hf(r),r.lookahead<=Zu&&e===jf)return gn;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=wt&&r.strstart>0&&(i=r.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=r.strstart+Zu;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=Zu-(s-i),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=wt?(t=el(r,1,r.match_length-wt),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=el(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(zn(r,!1),r.strm.avail_out===0))return gn}return r.insert=0,e===tl?(zn(r,!0),r.strm.avail_out===0?$f:kp):r.last_lit&&(zn(r,!1),r.strm.avail_out===0)?gn:E2},R3e=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(Hf(r),r.lookahead===0)){if(e===jf)return gn;break}if(r.match_length=0,t=el(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(zn(r,!1),r.strm.avail_out===0))return gn}return r.insert=0,e===tl?(zn(r,!0),r.strm.avail_out===0?$f:kp):r.last_lit&&(zn(r,!1),r.strm.avail_out===0)?gn:E2};function ha(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 o2=[new ha(0,0,0,0,I3e),new ha(4,4,8,4,Sx),new ha(4,5,16,8,Sx),new ha(4,6,32,32,Sx),new ha(4,4,16,16,Rp),new ha(8,16,32,32,Rp),new ha(8,16,128,128,Rp),new ha(8,32,128,256,Rp),new ha(32,128,258,1024,Rp),new ha(32,258,258,4096,Rp)],C3e=r=>{r.window_size=2*r.w_size,Xu(r.head),r.max_lazy_match=o2[r.level].max_lazy,r.good_match=o2[r.level].good_length,r.nice_match=o2[r.level].nice_length,r.max_chain_length=o2[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=wt-1,r.match_available=0,r.ins_h=0};function D3e(){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=Rw,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(b3e*2),this.dyn_dtree=new Uint16Array((2*w3e+1)*2),this.bl_tree=new Uint16Array((2*E3e+1)*2),Xu(this.dyn_ltree),Xu(this.dyn_dtree),Xu(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(_3e+1),this.heap=new Uint16Array(2*Ox+1),Xu(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Ox+1),Xu(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 Tq=r=>{if(!r||!r.state)return Ju(r,Ps);r.total_in=r.total_out=0,r.data_type=h3e;let e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Cw:zf,r.adler=e.wrap===2?0:1,e.last_flush=jf,e3e(e),pa},Iq=r=>{let e=Tq(r);return e===pa&&C3e(r.state),e},P3e=(r,e)=>!r||!r.state||r.state.wrap!==2?Ps:(r.state.gzhead=e,pa),Aq=(r,e,t,n,i,s)=>{if(!r)return Ps;let o=1;if(e===a3e&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>d3e||t!==Rw||n<8||n>15||e<0||e>9||s<0||s>l3e)return Ju(r,Ps);n===8&&(n=9);let a=new D3e;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+wt-1)/wt),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,Iq(r)},k3e=(r,e)=>Aq(r,e,Rw,p3e,m3e,f3e),N3e=(r,e)=>{let t,n;if(!r||!r.state||e>Dz||e<0)return r?Ju(r,Ps):Ps;let i=r.state;if(!r.output||!r.input&&r.avail_in!==0||i.status===s2&&e!==tl)return Ju(r,r.avail_out===0?vx:Ps);i.strm=r;let s=i.last_flush;if(i.last_flush=e,i.status===Cw)if(i.wrap===2)r.adler=0,Dt(i,31),Dt(i,139),Dt(i,8),i.gzhead?(Dt(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)),Dt(i,i.gzhead.time&255),Dt(i,i.gzhead.time>>8&255),Dt(i,i.gzhead.time>>16&255),Dt(i,i.gzhead.time>>24&255),Dt(i,i.level===9?2:i.strategy>=yw||i.level<2?4:0),Dt(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(Dt(i,i.gzhead.extra.length&255),Dt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(r.adler=Pn(r.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Lx):(Dt(i,0),Dt(i,0),Dt(i,0),Dt(i,0),Dt(i,0),Dt(i,i.level===9?2:i.strategy>=yw||i.level<2?4:0),Dt(i,S3e),i.status=zf);else{let o=Rw+(i.w_bits-8<<4)<<8,a=-1;i.strategy>=yw||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,o|=a<<6,i.strstart!==0&&(o|=v3e),o+=31-o%31,i.status=zf,i2(i,o),i.strstart!==0&&(i2(i,r.adler>>>16),i2(i,r.adler&65535)),r.adler=1}if(i.status===Lx)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=Pn(r.adler,i.pending_buf,i.pending-t,t)),Qu(r),t=i.pending,i.pending===i.pending_buf_size));)Dt(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>t&&(r.adler=Pn(r.adler,i.pending_buf,i.pending-t,t)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=vw)}else i.status=vw;if(i.status===vw)if(i.gzhead.name){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(r.adler=Pn(r.adler,i.pending_buf,i.pending-t,t)),Qu(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,Dt(i,n)}while(n!==0);i.gzhead.hcrc&&i.pending>t&&(r.adler=Pn(r.adler,i.pending_buf,i.pending-t,t)),n===0&&(i.gzindex=0,i.status=Sw)}else i.status=Sw;if(i.status===Sw)if(i.gzhead.comment){t=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>t&&(r.adler=Pn(r.adler,i.pending_buf,i.pending-t,t)),Qu(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,Dt(i,n)}while(n!==0);i.gzhead.hcrc&&i.pending>t&&(r.adler=Pn(r.adler,i.pending_buf,i.pending-t,t)),n===0&&(i.status=xw)}else i.status=xw;if(i.status===xw&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Qu(r),i.pending+2<=i.pending_buf_size&&(Dt(i,r.adler&255),Dt(i,r.adler>>8&255),r.adler=0,i.status=zf)):i.status=zf),i.pending!==0){if(Qu(r),r.avail_out===0)return i.last_flush=-1,pa}else if(r.avail_in===0&&kz(e)<=kz(s)&&e!==tl)return Ju(r,vx);if(i.status===s2&&r.avail_in!==0)return Ju(r,vx);if(r.avail_in!==0||i.lookahead!==0||e!==jf&&i.status!==s2){let o=i.strategy===yw?R3e(i,e):i.strategy===u3e?A3e(i,e):o2[i.level].func(i,e);if((o===$f||o===kp)&&(i.status=s2),o===gn||o===$f)return r.avail_out===0&&(i.last_flush=-1),pa;if(o===E2&&(e===i3e?n3e(i):e!==Dz&&(t3e(i,0,0,!1),e===s3e&&(Xu(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Qu(r),r.avail_out===0))return i.last_flush=-1,pa}return e!==tl?pa:i.wrap<=0?Pz:(i.wrap===2?(Dt(i,r.adler&255),Dt(i,r.adler>>8&255),Dt(i,r.adler>>16&255),Dt(i,r.adler>>24&255),Dt(i,r.total_in&255),Dt(i,r.total_in>>8&255),Dt(i,r.total_in>>16&255),Dt(i,r.total_in>>24&255)):(i2(i,r.adler>>>16),i2(i,r.adler&65535)),Qu(r),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?pa:Pz)},O3e=r=>{if(!r||!r.state)return Ps;let e=r.state.status;return e!==Cw&&e!==Lx&&e!==vw&&e!==Sw&&e!==xw&&e!==zf&&e!==s2?Ju(r,Ps):(r.state=null,e===zf?Ju(r,o3e):pa)},L3e=(r,e)=>{let t=e.length;if(!r||!r.state)return Ps;let n=r.state,i=n.wrap;if(i===2||i===1&&n.status!==Cw||n.lookahead)return Ps;if(i===1&&(r.adler=p2(r.adler,e,t,0)),n.wrap=0,t>=n.w_size){i===0&&(Xu(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,Hf(n);n.lookahead>=wt;){let c=n.strstart,l=n.lookahead-(wt-1);do n.ins_h=rl(n,n.ins_h,n.window[c+wt-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=wt-1,Hf(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=wt-1,n.match_available=0,r.next_in=o,r.input=a,r.avail_in=s,n.wrap=i,pa},B3e=k3e,M3e=Aq,U3e=Iq,F3e=Tq,V3e=P3e,K3e=N3e,z3e=O3e,q3e=L3e,$3e="pako deflate (from Nodeca project)",c2={deflateInit:B3e,deflateInit2:M3e,deflateReset:U3e,deflateResetKeep:F3e,deflateSetHeader:V3e,deflate:K3e,deflateEnd:z3e,deflateSetDictionary:q3e,deflateInfo:$3e},H3e=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),G3e=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)H3e(t,n)&&(r[n]=t[n])}}return r},W3e=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},Dw={assign:G3e,flattenChunks:W3e},Rq=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Rq=!1}var m2=new Uint8Array(256);for(let r=0;r<256;r++)m2[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;m2[254]=m2[254]=1;var j3e=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},Y3e=(r,e)=>{if(e<65534&&r.subarray&&Rq)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},Q3e=(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=m2[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 Y3e(s,i)},X3e=(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+m2[r[t]]>e?t:e},y2={string2buf:j3e,buf2string:Q3e,utf8border:X3e};function Z3e(){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 Cq=Z3e,Dq=Object.prototype.toString,{Z_NO_FLUSH:J3e,Z_SYNC_FLUSH:e4e,Z_FULL_FLUSH:t4e,Z_FINISH:r4e,Z_OK:Iw,Z_STREAM_END:n4e,Z_DEFAULT_COMPRESSION:i4e,Z_DEFAULT_STRATEGY:s4e,Z_DEFLATED:o4e}=Wf;function b2(r){this.options=Dw.assign({level:i4e,method:o4e,chunkSize:16384,windowBits:15,memLevel:8,strategy:s4e},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 Cq,this.strm.avail_out=0;let t=c2.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==Iw)throw new Error(qf[t]);if(e.header&&c2.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=y2.string2buf(e.dictionary):Dq.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,t=c2.deflateSetDictionary(this.strm,n),t!==Iw)throw new Error(qf[t]);this._dict_set=!0}}b2.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?r4e:J3e,typeof r=="string"?t.input=y2.string2buf(r):Dq.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===e4e||s===t4e)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(i=c2.deflate(t,s),i===n4e)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),i=c2.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Iw;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};b2.prototype.onData=function(r){this.chunks.push(r)};b2.prototype.onEnd=function(r){r===Iw&&(this.result=Dw.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Vx(r,e){let t=new b2(e);if(t.push(r,!0),t.err)throw t.msg||qf[t.err];return t.result}function a4e(r,e){return e=e||{},e.raw=!0,Vx(r,e)}function c4e(r,e){return e=e||{},e.gzip=!0,Vx(r,e)}var u4e=b2,l4e=Vx,f4e=a4e,h4e=c4e,d4e=Wf,p4e={Deflate:u4e,deflate:l4e,deflateRaw:f4e,gzip:h4e,constants:d4e},gw=30,m4e=12,y4e=function(e,t){let n,i,s,o,a,c,l,f,h,p,d,m,y,g,w,E,v,x,I,T,S,C,B,q,W=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=W.dmax,l=W.wsize,f=W.whave,h=W.wnext,p=W.window,d=W.hold,m=W.bits,y=W.lencode,g=W.distcode,w=(1<<W.lenbits)-1,E=(1<<W.distbits)-1;e:do{m<15&&(d+=B[n++]<<m,m+=8,d+=B[n++]<<m,m+=8),v=y[d&w];t:for(;;){if(x=v>>>24,d>>>=x,m-=x,x=v>>>16&255,x===0)q[s++]=v&65535;else if(x&16){I=v&65535,x&=15,x&&(m<x&&(d+=B[n++]<<m,m+=8),I+=d&(1<<x)-1,d>>>=x,m-=x),m<15&&(d+=B[n++]<<m,m+=8,d+=B[n++]<<m,m+=8),v=g[d&E];r:for(;;){if(x=v>>>24,d>>>=x,m-=x,x=v>>>16&255,x&16){if(T=v&65535,x&=15,m<x&&(d+=B[n++]<<m,m+=8,m<x&&(d+=B[n++]<<m,m+=8)),T+=d&(1<<x)-1,T>c){e.msg="invalid distance too far back",W.mode=gw;break e}if(d>>>=x,m-=x,x=s-o,T>x){if(x=T-x,x>f&&W.sane){e.msg="invalid distance too far back",W.mode=gw;break e}if(S=0,C=p,h===0){if(S+=l-x,x<I){I-=x;do q[s++]=p[S++];while(--x);S=s-T,C=q}}else if(h<x){if(S+=l+h-x,x-=h,x<I){I-=x;do q[s++]=p[S++];while(--x);if(S=0,h<I){x=h,I-=x;do q[s++]=p[S++];while(--x);S=s-T,C=q}}}else if(S+=h-x,x<I){I-=x;do q[s++]=p[S++];while(--x);S=s-T,C=q}for(;I>2;)q[s++]=C[S++],q[s++]=C[S++],q[s++]=C[S++],I-=3;I&&(q[s++]=C[S++],I>1&&(q[s++]=C[S++]))}else{S=s-T;do q[s++]=q[S++],q[s++]=q[S++],q[s++]=q[S++],I-=3;while(I>2);I&&(q[s++]=q[S++],I>1&&(q[s++]=q[S++]))}}else if((x&64)===0){v=g[(v&65535)+(d&(1<<x)-1)];continue r}else{e.msg="invalid distance code",W.mode=gw;break e}break}}else if((x&64)===0){v=y[(v&65535)+(d&(1<<x)-1)];continue t}else if(x&32){W.mode=m4e;break e}else{e.msg="invalid literal/length code",W.mode=gw;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),W.hold=d,W.bits=m},Cp=15,Nz=852,Oz=592,Lz=0,xx=1,Bz=2,g4e=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]),w4e=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]),E4e=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]),b4e=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]),_4e=(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,E=0,v,x,I,T,S,C=null,B=0,q,W=new Uint16Array(Cp+1),oe=new Uint16Array(Cp+1),te=null,Ve=0,me,Ae,$;for(l=0;l<=Cp;l++)W[l]=0;for(f=0;f<n;f++)W[e[t+f]]++;for(d=c,p=Cp;p>=1&&W[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&&W[h]===0;h++);for(d<h&&(d=h),g=1,l=1;l<=Cp;l++)if(g<<=1,g-=W[l],g<0)return-1;if(g>0&&(r===Lz||p!==1))return-1;for(oe[1]=0,l=1;l<Cp;l++)oe[l+1]=oe[l]+W[l];for(f=0;f<n;f++)e[t+f]!==0&&(o[oe[e[t+f]]++]=f);if(r===Lz?(C=te=o,q=19):r===xx?(C=g4e,B-=257,te=w4e,Ve-=257,q=256):(C=E4e,te=b4e,q=-1),E=0,f=0,l=h,S=s,m=d,y=0,I=-1,w=1<<d,T=w-1,r===xx&&w>Nz||r===Bz&&w>Oz)return 1;for(;;){me=l-y,o[f]<q?(Ae=0,$=o[f]):o[f]>q?(Ae=te[Ve+o[f]],$=C[B+o[f]]):(Ae=32+64,$=0),v=1<<l-y,x=1<<m,h=x;do x-=v,i[S+(E>>y)+x]=me<<24|Ae<<16|$|0;while(x!==0);for(v=1<<l-1;E&v;)v>>=1;if(v!==0?(E&=v-1,E+=v):E=0,f++,--W[l]===0){if(l===p)break;l=e[t+o[f]]}if(l>d&&(E&T)!==I){for(y===0&&(y=d),S+=h,m=l-y,g=1<<m;m+y<p&&(g-=W[m+y],!(g<=0));)m++,g<<=1;if(w+=1<<m,r===xx&&w>Nz||r===Bz&&w>Oz)return 1;I=E&T,i[I]=d<<24|m<<16|S-s|0}}return E!==0&&(i[S+E]=l-y<<24|64<<16|0),a.bits=d,0},u2=_4e,v4e=0,Pq=1,kq=2,{Z_FINISH:Mz,Z_BLOCK:S4e,Z_TREES:ww,Z_OK:Gf,Z_STREAM_END:x4e,Z_NEED_DICT:T4e,Z_STREAM_ERROR:ks,Z_DATA_ERROR:Nq,Z_MEM_ERROR:Oq,Z_BUF_ERROR:I4e,Z_DEFLATED:Uz}=Wf,Lq=1,Fz=2,Vz=3,Kz=4,zz=5,qz=6,$z=7,Hz=8,Gz=9,Wz=10,Aw=11,Tc=12,Tx=13,jz=14,Ix=15,Yz=16,Qz=17,Xz=18,Zz=19,Ew=20,bw=21,Jz=22,eq=23,tq=24,rq=25,nq=26,Ax=27,iq=28,sq=29,pr=30,Bq=31,A4e=32,R4e=852,C4e=592,D4e=15,P4e=D4e,oq=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function k4e(){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 Mq=r=>{if(!r||!r.state)return ks;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=Lq,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(R4e),e.distcode=e.distdyn=new Int32Array(C4e),e.sane=1,e.back=-1,Gf},Uq=r=>{if(!r||!r.state)return ks;let e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,Mq(r)},Fq=(r,e)=>{let t;if(!r||!r.state)return ks;let n=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?ks:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=t,n.wbits=e,Uq(r))},Vq=(r,e)=>{if(!r)return ks;let t=new k4e;r.state=t,t.window=null;let n=Fq(r,e);return n!==Gf&&(r.state=null),n},N4e=r=>Vq(r,P4e),aq=!0,Rx,Cx,O4e=r=>{if(aq){Rx=new Int32Array(512),Cx=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(u2(Pq,r.lens,0,288,Rx,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;u2(kq,r.lens,0,32,Cx,0,r.work,{bits:5}),aq=!1}r.lencode=Rx,r.lenbits=9,r.distcode=Cx,r.distbits=5},Kq=(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},L4e=(r,e)=>{let t,n,i,s,o,a,c,l,f,h,p,d,m,y,g=0,w,E,v,x,I,T,S,C,B=new Uint8Array(4),q,W,oe=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 ks;t=r.state,t.mode===Tc&&(t.mode=Tx),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,C=Gf;e:for(;;)switch(t.mode){case Lq:if(t.wrap===0){t.mode=Tx;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=Pn(t.check,B,2,0),l=0,f=0,t.mode=Fz;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=pr;break}if((l&15)!==Uz){r.msg="unknown compression method",t.mode=pr;break}if(l>>>=4,f-=4,S=(l&15)+8,t.wbits===0)t.wbits=S;else if(S>t.wbits){r.msg="invalid window size",t.mode=pr;break}t.dmax=1<<t.wbits,r.adler=t.check=1,t.mode=l&512?Wz:Tc,l=0,f=0;break;case Fz:for(;f<16;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(t.flags=l,(t.flags&255)!==Uz){r.msg="unknown compression method",t.mode=pr;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=pr;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&(B[0]=l&255,B[1]=l>>>8&255,t.check=Pn(t.check,B,2,0)),l=0,f=0,t.mode=Vz;case Vz: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=Pn(t.check,B,4,0)),l=0,f=0,t.mode=Kz;case Kz: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=Pn(t.check,B,2,0)),l=0,f=0,t.mode=zz;case zz: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=Pn(t.check,B,2,0)),l=0,f=0}else t.head&&(t.head.extra=null);t.mode=qz;case qz:if(t.flags&1024&&(d=t.length,d>a&&(d=a),d&&(t.head&&(S=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),S)),t.flags&512&&(t.check=Pn(t.check,n,d,s)),a-=d,s+=d,t.length-=d),t.length))break e;t.length=0,t.mode=$z;case $z:if(t.flags&2048){if(a===0)break e;d=0;do S=n[s+d++],t.head&&S&&t.length<65536&&(t.head.name+=String.fromCharCode(S));while(S&&d<a);if(t.flags&512&&(t.check=Pn(t.check,n,d,s)),a-=d,s+=d,S)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=Hz;case Hz:if(t.flags&4096){if(a===0)break e;d=0;do S=n[s+d++],t.head&&S&&t.length<65536&&(t.head.comment+=String.fromCharCode(S));while(S&&d<a);if(t.flags&512&&(t.check=Pn(t.check,n,d,s)),a-=d,s+=d,S)break e}else t.head&&(t.head.comment=null);t.mode=Gz;case Gz: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=pr;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=Tc;break;case Wz:for(;f<32;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}r.adler=t.check=oq(l),l=0,f=0,t.mode=Aw;case Aw: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,T4e;r.adler=t.check=1,t.mode=Tc;case Tc:if(e===S4e||e===ww)break e;case Tx:if(t.last){l>>>=f&7,f-=f&7,t.mode=Ax;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=jz;break;case 1:if(O4e(t),t.mode=Ew,e===ww){l>>>=2,f-=2;break e}break;case 2:t.mode=Qz;break;case 3:r.msg="invalid block type",t.mode=pr}l>>>=2,f-=2;break;case jz: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=pr;break}if(t.length=l&65535,l=0,f=0,t.mode=Ix,e===ww)break e;case Ix:t.mode=Yz;case Yz: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=Tc;break;case Qz: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=pr;break}t.have=0,t.mode=Xz;case Xz:for(;t.have<t.ncode;){for(;f<3;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}t.lens[oe[t.have++]]=l&7,l>>>=3,f-=3}for(;t.have<19;)t.lens[oe[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,q={bits:t.lenbits},C=u2(v4e,t.lens,0,19,t.lencode,0,t.work,q),t.lenbits=q.bits,C){r.msg="invalid code lengths set",t.mode=pr;break}t.have=0,t.mode=Zz;case Zz:for(;t.have<t.nlen+t.ndist;){for(;g=t.lencode[l&(1<<t.lenbits)-1],w=g>>>24,E=g>>>16&255,v=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(v<16)l>>>=w,f-=w,t.lens[t.have++]=v;else{if(v===16){for(W=w+2;f<W;){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=pr;break}S=t.lens[t.have-1],d=3+(l&3),l>>>=2,f-=2}else if(v===17){for(W=w+3;f<W;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=w,f-=w,S=0,d=3+(l&7),l>>>=3,f-=3}else{for(W=w+7;f<W;){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=w,f-=w,S=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=pr;break}for(;d--;)t.lens[t.have++]=S}}if(t.mode===pr)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=pr;break}if(t.lenbits=9,q={bits:t.lenbits},C=u2(Pq,t.lens,0,t.nlen,t.lencode,0,t.work,q),t.lenbits=q.bits,C){r.msg="invalid literal/lengths set",t.mode=pr;break}if(t.distbits=6,t.distcode=t.distdyn,q={bits:t.distbits},C=u2(kq,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,q),t.distbits=q.bits,C){r.msg="invalid distances set",t.mode=pr;break}if(t.mode=Ew,e===ww)break e;case Ew:t.mode=bw;case bw: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,y4e(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===Tc&&(t.back=-1);break}for(t.back=0;g=t.lencode[l&(1<<t.lenbits)-1],w=g>>>24,E=g>>>16&255,v=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if(E&&(E&240)===0){for(x=w,I=E,T=v;g=t.lencode[T+((l&(1<<x+I)-1)>>x)],w=g>>>24,E=g>>>16&255,v=g&65535,!(x+w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=x,f-=x,t.back+=x}if(l>>>=w,f-=w,t.back+=w,t.length=v,E===0){t.mode=nq;break}if(E&32){t.back=-1,t.mode=Tc;break}if(E&64){r.msg="invalid literal/length code",t.mode=pr;break}t.extra=E&15,t.mode=Jz;case Jz:if(t.extra){for(W=t.extra;f<W;){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=eq;case eq:for(;g=t.distcode[l&(1<<t.distbits)-1],w=g>>>24,E=g>>>16&255,v=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}if((E&240)===0){for(x=w,I=E,T=v;g=t.distcode[T+((l&(1<<x+I)-1)>>x)],w=g>>>24,E=g>>>16&255,v=g&65535,!(x+w<=f);){if(a===0)break e;a--,l+=n[s++]<<f,f+=8}l>>>=x,f-=x,t.back+=x}if(l>>>=w,f-=w,t.back+=w,E&64){r.msg="invalid distance code",t.mode=pr;break}t.offset=v,t.extra=E&15,t.mode=tq;case tq:if(t.extra){for(W=t.extra;f<W;){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=pr;break}t.mode=rq;case rq: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=pr;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=bw);break;case nq:if(c===0)break e;i[o++]=t.length,c--,t.mode=bw;break;case Ax: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?Pn(t.check,i,p,o-p):p2(t.check,i,p,o-p)),p=c,(t.flags?l:oq(l))!==t.check){r.msg="incorrect data check",t.mode=pr;break}l=0,f=0}t.mode=iq;case iq: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=pr;break}l=0,f=0}t.mode=sq;case sq:C=x4e;break e;case pr:C=Nq;break e;case Bq:return Oq;case A4e:default:return ks}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<pr&&(t.mode<Ax||e!==Mz))&&Kq(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?Pn(t.check,i,p,r.next_out-p):p2(t.check,i,p,r.next_out-p)),r.data_type=t.bits+(t.last?64:0)+(t.mode===Tc?128:0)+(t.mode===Ew||t.mode===Ix?256:0),(h===0&&p===0||e===Mz)&&C===Gf&&(C=I4e),C},B4e=r=>{if(!r||!r.state)return ks;let e=r.state;return e.window&&(e.window=null),r.state=null,Gf},M4e=(r,e)=>{if(!r||!r.state)return ks;let t=r.state;return(t.wrap&2)===0?ks:(t.head=e,e.done=!1,Gf)},U4e=(r,e)=>{let t=e.length,n,i,s;return!r||!r.state||(n=r.state,n.wrap!==0&&n.mode!==Aw)?ks:n.mode===Aw&&(i=1,i=p2(i,e,t,0),i!==n.check)?Nq:(s=Kq(r,e,t,t),s?(n.mode=Bq,Oq):(n.havedict=1,Gf))},F4e=Uq,V4e=Fq,K4e=Mq,z4e=N4e,q4e=Vq,$4e=L4e,H4e=B4e,G4e=M4e,W4e=U4e,j4e="pako inflate (from Nodeca project)",Ac={inflateReset:F4e,inflateReset2:V4e,inflateResetKeep:K4e,inflateInit:z4e,inflateInit2:q4e,inflate:$4e,inflateEnd:H4e,inflateGetHeader:G4e,inflateSetDictionary:W4e,inflateInfo:j4e};function Y4e(){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 Q4e=Y4e,zq=Object.prototype.toString,{Z_NO_FLUSH:X4e,Z_FINISH:Z4e,Z_OK:g2,Z_STREAM_END:Dx,Z_NEED_DICT:Px,Z_STREAM_ERROR:J4e,Z_DATA_ERROR:cq,Z_MEM_ERROR:e6e}=Wf;function _2(r){this.options=Dw.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 Cq,this.strm.avail_out=0;let t=Ac.inflateInit2(this.strm,e.windowBits);if(t!==g2)throw new Error(qf[t]);if(this.header=new Q4e,Ac.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=y2.string2buf(e.dictionary):zq.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Ac.inflateSetDictionary(this.strm,e.dictionary),t!==g2)))throw new Error(qf[t])}_2.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?Z4e:X4e,zq.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=Ac.inflate(t,o),s===Px&&i&&(s=Ac.inflateSetDictionary(t,i),s===g2?s=Ac.inflate(t,o):s===cq&&(s=Px));t.avail_in>0&&s===Dx&&t.state.wrap>0&&r[t.next_in]!==0;)Ac.inflateReset(t),s=Ac.inflate(t,o);switch(s){case J4e:case cq:case Px:case e6e:return this.onEnd(s),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||s===Dx))if(this.options.to==="string"){let c=y2.utf8border(t.output,t.next_out),l=t.next_out-c,f=y2.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===g2&&a===0)){if(s===Dx)return s=Ac.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};_2.prototype.onData=function(r){this.chunks.push(r)};_2.prototype.onEnd=function(r){r===g2&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Dw.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Kx(r,e){let t=new _2(e);if(t.push(r),t.err)throw t.msg||qf[t.err];return t.result}function t6e(r,e){return e=e||{},e.raw=!0,Kx(r,e)}var r6e=_2,n6e=Kx,i6e=t6e,s6e=Kx,o6e=Wf,a6e={Inflate:r6e,inflate:n6e,inflateRaw:i6e,ungzip:s6e,constants:o6e},{Deflate:c6e,deflate:u6e,deflateRaw:l6e,gzip:f6e}=p4e,{Inflate:h6e,inflate:d6e,inflateRaw:p6e,ungzip:m6e}=a6e,y6e=c6e,g6e=u6e,w6e=l6e,E6e=f6e,b6e=h6e,_6e=d6e,v6e=p6e,S6e=m6e,x6e=Wf,zx={Deflate:y6e,deflate:g6e,deflateRaw:w6e,gzip:E6e,Inflate:b6e,inflate:_6e,inflateRaw:v6e,ungzip:S6e,constants:x6e};var qq=6;function $q({repo:r,preload:e}){async function*t(n,i={}){if(i.compressionLevel!=null&&(i.compressionLevel<-1||i.compressionLevel>9))throw(0,Np.default)(new Error("Compression level must be between -1 and 9"),"ERR_INVALID_PARAMS");if(i.preload!==!1){let a;try{a=zd(n).split("/")}catch(c){throw(0,Np.default)(c,"ERR_INVALID_PATH")}e(A.parse(a[0]))}let s=A.asCID(n)||n,o=await Kn(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()}],mw()):a.push(o.content),i.compress&&a.push(async function*(c){let l=await Ap(c);yield zx.gzip(l,{level:i.compressionLevel||qq})}),yield*de(...a);return}if(o.type==="directory"){let a=[hw(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,Np.default)(new Error("Not a UnixFS node"),"ERR_NOT_UNIXFS");yield f}},mw()];if(i.compress){if(!i.archive)throw(0,Np.default)(new Error("file is not regular"),"ERR_INVALID_PATH");i.compress&&a.push(async function*(c){let l=await Ap(c);yield zx.gzip(l,{level:i.compressionLevel||qq})})}yield*de(...a);return}throw(0,Np.default)(new Error("Not a UnixFS node"),"ERR_NOT_UNIXFS")}return M(t)}u();var Hq=_(V(),1);function Gq({repo:r,preload:e}){async function*t(n,i={}){let s=zd(n),o=s.split("/");i.preload!==!1&&e(A.parse(o[0]));let a=A.asCID(s)||s,c=await Kn(a,r.blocks,i);if(c.type==="file"){yield Yv(c);return}if(c.type==="directory"){for await(let l of c.content())yield Yv(l);return}throw(0,Hq.default)(new Error(`Unknown UnixFS type ${c.type}`),"ERR_UNKNOWN_UNIXFS_TYPE")}return M(t)}var Pw=class{constructor({preload:e,repo:t,hashers:n,options:i}){let s=GK({preload:e,repo:t,options:i,hashers:n});this.addAll=s,this.add=ZV({addAll:s}),this.cat=Ez({repo:t,preload:e}),this.get=$q({repo:t,preload:e}),this.ls=Gq({repo:t,preload:e})}};u();u();var Yf="",Wq="",jq="";function Yq({repo:r}){async function e(t={}){let n=await r.version.get();return{version:Yf,commit:Wq,repo:`${n}`,"ipfs-core":Yf,"interface-ipfs-core":jq}}return M(e)}u();var kw=_(V(),1);var T6e=D("ipfs:components:id");function Qq({peerId:r,network:e}){async function t(n={}){let i=e.try();if(!i){if(n.peerId)throw new nc;if(r.publicKey==null)throw(0,kw.default)(new Error("Public key missing"),"ERR_MISSING_PUBLIC_KEY");return{id:r,publicKey:K(r.publicKey,"base64pad"),addresses:[],agentVersion:`js-ipfs/${Yf}`,protocolVersion:"9000",protocols:[]}}let{libp2p:s}=i,o=n.peerId?n.peerId:r,a=await I6e(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=>ee(p)),agentVersion:c,protocolVersion:l,protocols:(a.protocols||[]).sort()}}return M(t)}async function I6e(r,e,t){let n=await e.peerStore.get(r);n||(n=await A6e(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){T6e.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 A6e(r,e,t){if(e.dht==null)throw(0,kw.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,kw.default)(new Error("Could not find peer"),"ERR_NOT_FOUND");return n}u();u();u();var mr=R6e;function R6e(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;Xq(i);for(var s;s=n.shift();)if(Xq(s),typeof r[s]>"u"&&(r[s]={}),r=r[s],!r||typeof r!="object")return!1;return r[i]=t,!0}function Xq(r){if(r=="__proto__"||r=="constructor"||r=="prototype")throw new Error("setting of prototype values not supported")}var Op={server:{description:"Recommended for nodes with public IPv4 address (servers, VPSes, etc.), disables host and content discovery and UPnP in local networks.",transform:r=>(mr(r,"Discovery.MDNS.Enabled",!1),mr(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=>(mr(r,"Discovery.MDNS.Enabled",!0),mr(r,"Discovery.webRTCStar.Enabled",!0),mr(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=bc();return mr(r,"Addresses.API",e.Addresses.API?"/ip4/127.0.0.1/tcp/0":""),mr(r,"Addresses.Gateway",e.Addresses.Gateway?"/ip4/127.0.0.1/tcp/0":""),mr(r,"Addresses.Swarm",e.Addresses.Swarm.length?["/ip4/127.0.0.1/tcp/0"]:[]),mr(r,"Addresses.Delegates",[]),mr(r,"Bootstrap",[]),mr(r,"Discovery.MDNS.Enabled",!1),mr(r,"Discovery.webRTCStar.Enabled",!1),mr(r,"Swarm",{...r.Swarm||{},DisableNatPortMap:!0}),r}},"default-networking":{description:"Restores default network settings. Inverse profile of the `test` profile.",transform:r=>{let e=bc();return mr(r,"Addresses.API",e.Addresses.API),mr(r,"Addresses.Gateway",e.Addresses.Gateway),mr(r,"Addresses.Swarm",e.Addresses.Swarm),mr(r,"Addresses.Delegates",e.Addresses.Delegates),mr(r,"Bootstrap",e.Bootstrap),mr(r,"Discovery.MDNS.Enabled",e.Discovery.MDNS.Enabled),mr(r,"Discovery.webRTCStar.Enabled",e.Discovery.webRTCStar.Enabled),mr(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=bc();return r.Swarm=e.Swarm,r}}};var C6e=D("ipfs:core:config");function Zq({repo:r}){return{getAll:M(e),get:M(t),set:M(n),replace:M(i),profiles:{apply:M(s),list:M(D6e)}};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=Op[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 C6e(f),new Error(`Could not apply profile '${o}' to config: ${f.message}`)}}}async function D6e(r){return Object.keys(Op).map(e=>({name:e,description:Op[e].description}))}u();u();u();function Nw({enumerable:r=!0,configurable:e=!1}={}){return{enumerable:r,configurable:e,writable:!1}}function*P6e(r,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[t,n]of e.entries()){let i=[...r,t],s=A.asCID(n);s?yield[i.join("/"),s]:typeof n=="object"&&(yield*qx(n,i))}else{let t=A.asCID(e);t?yield[r.join("/"),t]:yield*qx(e,r)}}function*qx(r,e){if(!(r==null||r instanceof Uint8Array))for(let[t,n]of Object.entries(r)){let i=[...e,t];yield*P6e(i,n)}}function*k6e(r,e){if(Array.isArray(e))for(let[t,n]of e.entries()){let i=[...r,t];yield i.join("/"),typeof n=="object"&&!A.asCID(n)&&(yield*$x(n,i))}else yield*$x(e,r)}function*$x(r,e){if(!(r==null||typeof r!="object"))for(let[t,n]of Object.entries(r)){let i=[...e,t];yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!A.asCID(n)&&(yield*k6e(i,n))}}function N6e(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}}var Hx=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:Nw(),bytes:Nw(),value:Nw(),asBlock:Nw()})}links(){return qx(this.value,[])}tree(){return $x(this.value,[])}get(e="/"){return N6e(this.value,e.split("/").filter(Boolean))}};function Lp({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 Hx({cid:e,bytes:r,value:i})}u();u();var Gx=_(Jo(),1);function Wx(r){let e=V1({version:1,roots:r}),t=Gx.default.encode(e.length),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function Jq(r){return{async setRoots(e){let t=Wx(e);await r.write(t)},async writeBlock(e){let{cid:t,bytes:n}=e;await r.write(new Uint8Array(Gx.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 Ow(){}function e$(){let r=[],e=null,t=Ow,n=!1,i=null,s=Ow,o=()=>(e||(e=new Promise(l=>{t=()=>{e=null,t=Ow,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=Ow,f(c.next()))})),i)}};return{writer:a,iterator:c}}u();var il=_(Jo(),1);u();var nl={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=>!nl.Null(r)&&typeof r=="object"&&r.asCID===r,List:r=>Array.isArray(r),Map:r=>!nl.Null(r)&&typeof r=="object"&&r.asCID!==r&&!nl.List(r)&&!nl.Bytes(r)},Bp={Int:nl.Int,"CarHeader > version":r=>Bp.Int(r),"CarHeader > roots (anon) > valueType (anon)":nl.Link,"CarHeader > roots (anon)":r=>nl.List(r)&&Array.prototype.every.call(r,Bp["CarHeader > roots (anon) > valueType (anon)"]),"CarHeader > roots":r=>Bp["CarHeader > roots (anon)"](r),CarHeader:r=>{let e=r&&Object.keys(r);return nl.Map(r)&&["version"].every(t=>e.includes(t))&&Object.entries(r).every(([t,n])=>Bp["CarHeader > "+t]&&Bp["CarHeader > "+t](n))}},t$=Bp.CarHeader;var jx={SHA2_256:18,LENGTH:32,DAG_PB:112},r$=16+8+8+8;async function Lw(r){let e=await r.upTo(8);if(!e.length)throw new Error("Unexpected end of data");let t=il.default.decode(e);return r.seek(il.default.decode.bytes),t}async function O6e(r){let e=await r.exactly(r$),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(r$),i}async function Bw(r,e){let t=await Lw(r);if(t===0)throw new Error("Invalid CAR header (zero length)");let n=await r.exactly(t);r.seek(t);let i=hf(n);if(!t$(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 O6e(r);r.seek(o.dataOffset-r.pos);let a=await Bw(r,1);return Object.assign(a,o)}async function L6e(r){let e=await r.upTo(8);il.default.decode(e);let t=il.default.decode.bytes,n=il.default.decode(e.subarray(il.default.decode.bytes)),i=il.default.decode.bytes,s=t+i+n,o=await r.exactly(s);return r.seek(s),o}async function B6e(r){let e=await r.exactly(2);if(e[0]===jx.SHA2_256&&e[1]===jx.LENGTH){let o=await r.exactly(34);r.seek(34);let a=Jt(o);return A.create(0,jx.DAG_PB,a)}let t=await Lw(r);if(t!==1)throw new Error(`Unexpected CID version (${t})`);let n=await Lw(r),i=await L6e(r),s=Jt(i);return A.create(t,n,s)}async function n$(r){let e=r.pos,t=await Lw(r);if(t===0)throw new Error("Invalid CAR section (zero length)");t+=r.pos-e;let n=await B6e(r),i=t-Number(r.pos-e);return{cid:n,length:t,blockLength:i}}async function M6e(r){let{cid:e,blockLength:t}=await n$(r),n=await r.exactly(t);return r.seek(t),{bytes:n,cid:e}}async function U6e(r){let e=r.pos,{cid:t,length:n,blockLength:i}=await n$(r),s={cid:t,length:n,blockLength:i,offset:e,blockOffset:r.pos};return r.seek(s.blockLength),s}function i$(r){let e=(async()=>{let t=await Bw(r);if(t.version===2){let n=r.pos-t.dataOffset;r=V6e(r,t.dataSize-n)}return t})();return{header:()=>e,async*blocks(){for(await e;(await r.upTo(8)).length>0;)yield await M6e(r)},async*blocksIndex(){for(await e;(await r.upTo(8)).length>0;)yield await U6e(r)}}}function Mw(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 F6e(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 s$(r){let e=r[Symbol.asyncIterator]();async function t(){let n=await e.next();return n.done?null:n.value}return F6e(t)}function V6e(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 Qf=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=K6e(e);let{encoder:t,iterator:n}=o$(),i=new Qf(e,t),s=new Uw(n);return{writer:i,out:s}}static createAppender(){let{encoder:e,iterator:t}=o$();e.setRoots=()=>Promise.resolve();let n=new Qf([],e),i=new Uw(t);return{writer:n,out:i}}static async updateRootsInBytes(e,t){let n=Mw(e);await Bw(n);let i=Wx(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}},Uw=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 o$(){let r=e$(),{writer:e,iterator:t}=r;return{encoder:Jq(e),iterator:t}}function K6e(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 Yx=async({cid:r,load:e,seen:t})=>{t=t||new Set;let n=r.toString(Ce);if(t.has(n))return;let i=await e(r);if(t.add(n),i!==null)for(let[,s]of i.links())await Yx({cid:s,load:e,seen:t})};var a$=D("ipfs:components:dag:import"),z6e=[xn,bv];function c$({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}`);a$(`Exporting ${o} as car`);let{writer:a,out:c}=await Qf.create([o]),l=null;(async()=>{try{let f=q6e(r,a,{signal:s.signal,timeout:s.timeout},t);await Yx({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 q6e(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 a$(`Adding block ${i} to car`),await e.put({cid:i,bytes:o}),z6e.includes(i.code)?null:Lp({bytes:o,cid:i,codec:s})}}u();u();async function kn(r){for await(let e of r)return e}var u$=_(V(),1);function l$({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 kn(Au(s,o.path,r,e,o)):await Xt(Au(s,o.path,r,e,o));if(!h)throw(0,u$.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 Fw=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}},Xf=class extends Fw{[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 f$(e);return new Xf(t,n,i)}static async fromIterable(e){let{version:t,roots:n,iterator:i}=await h$(e);return new Xf(t,n,i)}},v2=class extends Fw{[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 f$(e);return new v2(t,n,i)}static async fromIterable(e){let{version:t,roots:n,iterator:i}=await h$(e);return new v2(t,n,i)}};async function f$(r){if(!(r instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return d$(Mw(r))}async function h$(r){if(!r||typeof r[Symbol.asyncIterator]!="function")throw new TypeError("fromIterable() requires an async iterable");return d$(s$(r))}async function d$(r){let e=i$(r),{version:t,roots:n}=await e.header();return{version:t,roots:n,iterator:e.blocks()}}var p$=D("ipfs:components:dag:import");function m$({repo:r}){async function*e(t,n={}){let i=await r.gcLock.readLock();try{let s={signal:n.signal,timeout:n.timeout},o=go(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 $6e(r,s,f);if(n.pinRoots!==!1)for(let p of h){let d="";try{await r.blocks.has(p)?(p$(`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 $6e(r,e,t){let n=await Xf.fromIterable(t),i=await n.getRoots();return await yn(r.blocks.putMany(dr(n,({cid:s,bytes:o})=>(p$(`Import block ${s}`),{key:s,value:o})),{signal:e.signal})),i}u();function y$({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 g$({repo:r,codecs:e,preload:t}){async function n(i,s={}){let{cid:o}=uc(i);return s.preload!==!1&&t(o),Iu(r,e,i,s)}return M(n)}var Vw=class{constructor({repo:e,codecs:t,hashers:n,preload:i}){this.export=c$({repo:e,preload:i,codecs:t}),this.get=l$({codecs:t,repo:e,preload:i}),this.import=m$({repo:e}),this.resolve=g$({repo:e,codecs:t,preload:i}),this.put=y$({repo:e,codecs:t,hashers:n,preload:i})}};u();u();var Kw=(r,e)=>e,H6e=(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}`},G6e={ip4:Kw,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}`:H6e(r,e,n,i),udp:(r,e)=>`udp://${r}:${e}`,dnsaddr:Kw,dns4:Kw,dns6:Kw,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 Mp(r,e){let t=ee(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=G6e[s.protocol];if(c==null)throw new Error(`Unsupported protocol ${s.protocol}`);return c(i,s.content,o,a,e)},"")}u();function Qx(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 w$=_(Hd(),1);var W6e=D("ipfs:preload"),j6e=co.default?co.default:co,Y6e=new j6e({concurrency:4});function E$(r,e={}){return W6e(r),Y6e.add(async()=>{let n=(await w$.default.post(r,{signal:e.signal})).body.getReader();try{for(;;){let{done:i}=await n.read();if(i)return}}finally{n.releaseLock()}})}var b$=_(qd(),1),S2=D("ipfs:preload");function _$(r={}){if(r.enabled=Boolean(r.enabled),r.addresses=r.addresses||[],r.cache=r.cache||1e3,!r.enabled||!r.addresses.length)return S2("preload disabled"),Object.assign(()=>{},{start:()=>{},stop:()=>{}});let e=!0,t=[],n=r.addresses.map(o=>Mp(o)),i=(0,b$.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=Qx(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 E$(`${h}/api/v0/refs?r=true&arg=${encodeURIComponent(a)}`,{signal:p.signal}),l=!0}catch(d){d.type!=="aborted"&&S2.error(d)}finally{t=t.filter(d=>d!==p)}if(l)break}S2(`${l?"":"un"}successfully preloaded ${a} in ${Date.now()-f}ms`)}catch(a){S2.error(a)}};return s.start=()=>{e=!1},s.stop=()=>{e=!0,S2(`aborting ${t.length} pending preload request(s)`),t.forEach(o=>o.abort()),t=[]},s}u();var zw=D("ipfs:mfs-preload");function v$({preload:r,files:e,options:t={}}){if(t.interval=t.interval||30*1e3,!t.enabled){zw("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&&(zw(`preloading updated MFS root ${n} -> ${o.cid}`),await r(o.cid),n=a)}catch(o){zw.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(),zw(`monitoring MFS root ${o.cid}`),i=setTimeout(s,t.interval)},stop(){clearTimeout(i)}}}u();u();u();u();var P$=_(Ru(),1);u();var x2=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Xx=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},S$=r=>globalThis.DOMException===void 0?new Xx(r):new DOMException(r),x$=r=>{let e=r.reason===void 0?S$("This operation was aborted."):r.reason;return e instanceof Error?e:S$(e)};function Zx(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(x$(c)),c.addEventListener("abort",()=>{a(x$(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 x2(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 Jx(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 Zf=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)},Rc,T2=class{constructor(){Rc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Zf(this,Rc,"f")[this.size-1].priority>=t.priority){Zf(this,Rc,"f").push(n);return}let i=Jx(Zf(this,Rc,"f"),n,(s,o)=>o.priority-s.priority);Zf(this,Rc,"f").splice(i,0,n)}dequeue(){let e=Zf(this,Rc,"f").shift();return e?.run}filter(e){return Zf(this,Rc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Zf(this,Rc,"f").length}};Rc=new WeakMap;var Ir=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},Ee=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)},jr,A2,R2,ol,jw,C2,qw,_o,I2,qi,$w,$i,D2,sl,Hw,T$,I$,D$,A$,R$,C$,Gw,eT,tT,Yw,Ww,Q6e=new x2,rT=class extends Error{},Up=class extends P$.default{constructor(e){var t,n,i,s;if(super(),jr.add(this),A2.set(this,void 0),R2.set(this,void 0),ol.set(this,0),jw.set(this,void 0),C2.set(this,void 0),qw.set(this,0),_o.set(this,void 0),I2.set(this,void 0),qi.set(this,void 0),$w.set(this,void 0),$i.set(this,0),D2.set(this,void 0),sl.set(this,void 0),Hw.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:T2,...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})`);Ir(this,A2,e.carryoverConcurrencyCount,"f"),Ir(this,R2,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Ir(this,jw,e.intervalCap,"f"),Ir(this,C2,e.interval,"f"),Ir(this,qi,new e.queueClass,"f"),Ir(this,$w,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Ir(this,Hw,e.throwOnTimeout===!0,"f"),Ir(this,sl,e.autoStart===!1,"f")}get concurrency(){return Ee(this,D2,"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})`);Ir(this,D2,e,"f"),Ee(this,jr,"m",Yw).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Ir(this,$i,(a=Ee(this,$i,"f"),a++,a),"f"),Ir(this,ol,(c=Ee(this,ol,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new rT("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):Zx(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Ee(this,Hw,"f"):t.throwOnTimeout)&&i(Q6e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Ee(this,jr,"m",D$).call(this)};Ee(this,qi,"f").enqueue(s,t),Ee(this,jr,"m",Gw).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Ee(this,sl,"f")?(Ir(this,sl,!1,"f"),Ee(this,jr,"m",Yw).call(this),this):this}pause(){Ir(this,sl,!0,"f")}clear(){Ir(this,qi,new(Ee(this,$w,"f")),"f")}async onEmpty(){Ee(this,qi,"f").size!==0&&await Ee(this,jr,"m",Ww).call(this,"empty")}async onSizeLessThan(e){Ee(this,qi,"f").size<e||await Ee(this,jr,"m",Ww).call(this,"next",()=>Ee(this,qi,"f").size<e)}async onIdle(){Ee(this,$i,"f")===0&&Ee(this,qi,"f").size===0||await Ee(this,jr,"m",Ww).call(this,"idle")}get size(){return Ee(this,qi,"f").size}sizeBy(e){return Ee(this,qi,"f").filter(e).length}get pending(){return Ee(this,$i,"f")}get isPaused(){return Ee(this,sl,"f")}};A2=new WeakMap,R2=new WeakMap,ol=new WeakMap,jw=new WeakMap,C2=new WeakMap,qw=new WeakMap,_o=new WeakMap,I2=new WeakMap,qi=new WeakMap,$w=new WeakMap,$i=new WeakMap,D2=new WeakMap,sl=new WeakMap,Hw=new WeakMap,jr=new WeakSet,T$=function(){return Ee(this,R2,"f")||Ee(this,ol,"f")<Ee(this,jw,"f")},I$=function(){return Ee(this,$i,"f")<Ee(this,D2,"f")},D$=function(){var e;Ir(this,$i,(e=Ee(this,$i,"f"),e--,e),"f"),Ee(this,jr,"m",Gw).call(this),this.emit("next")},A$=function(){this.emit("empty"),Ee(this,$i,"f")===0&&this.emit("idle")},R$=function(){Ee(this,jr,"m",tT).call(this),Ee(this,jr,"m",eT).call(this),Ir(this,I2,void 0,"f")},C$=function(){let e=Date.now();if(Ee(this,_o,"f")===void 0){let t=Ee(this,qw,"f")-e;if(t<0)Ir(this,ol,Ee(this,A2,"f")?Ee(this,$i,"f"):0,"f");else return Ee(this,I2,"f")===void 0&&Ir(this,I2,setTimeout(()=>{Ee(this,jr,"m",R$).call(this)},t),"f"),!0}return!1},Gw=function(){if(Ee(this,qi,"f").size===0)return Ee(this,_o,"f")&&clearInterval(Ee(this,_o,"f")),Ir(this,_o,void 0,"f"),Ee(this,jr,"m",A$).call(this),!1;if(!Ee(this,sl,"f")){let e=!Ee(this,jr,"a",C$);if(Ee(this,jr,"a",T$)&&Ee(this,jr,"a",I$)){let t=Ee(this,qi,"f").dequeue();return t?(this.emit("active"),t(),e&&Ee(this,jr,"m",eT).call(this),!0):!1}}return!1},eT=function(){Ee(this,R2,"f")||Ee(this,_o,"f")!==void 0||(Ir(this,_o,setInterval(()=>{Ee(this,jr,"m",tT).call(this)},Ee(this,C2,"f")),"f"),Ir(this,qw,Date.now()+Ee(this,C2,"f"),"f"))},tT=function(){Ee(this,ol,"f")===0&&Ee(this,$i,"f")===0&&Ee(this,_o,"f")&&(clearInterval(Ee(this,_o,"f")),Ir(this,_o,void 0,"f")),Ir(this,ol,Ee(this,A2,"f")?Ee(this,$i,"f"):0,"f"),Ee(this,jr,"m",Yw).call(this)},Yw=function(){for(;Ee(this,jr,"m",Gw).call(this););},Ww=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};u();var nT=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},iT=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},k$=r=>globalThis.DOMException===void 0?new iT(r):new DOMException(r),N$=r=>{let e=r.reason===void 0?k$("This operation was aborted."):r.reason;return e instanceof Error?e:k$(e)};function P2(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(N$(f)),f.addEventListener("abort",()=>{l(N$(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 nT(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 sT="lock:worker:request-read",oT="lock:worker:release-read",aT="lock:master:grant-read",cT="lock:worker:request-write",uT="lock:worker:release-write",lT="lock:master:grant-write";u();var al={},Fp=r=>{r.addEventListener("message",e=>{Fp.dispatchEvent("message",r,e)}),r.port!=null&&r.port.addEventListener("message",e=>{Fp.dispatchEvent("message",r,e)})};Fp.addEventListener=(r,e)=>{al[r]==null&&(al[r]=[]),al[r].push(e)};Fp.removeEventListener=(r,e)=>{al[r]!=null&&(al[r]=al[r].filter(t=>t===e))};Fp.dispatchEvent=function(r,e,t){al[r]!=null&&al[r].forEach(n=>n(e,t))};var fT=Fp;var O$=(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)}))}}))},L$=(r,e,t,n)=>async()=>{let i=v4();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)})},X6e={singleProcess:!1},B$=r=>{if(r=Object.assign({},X6e,r),Boolean(globalThis.document)||r.singleProcess){let t=new EventTarget;return fT.addEventListener("message",O$(t,"requestReadLock",sT,oT,aT)),fT.addEventListener("message",O$(t,"requestWriteLock",cT,uT,lT)),t}return{isWorker:!0,readLock:t=>L$(t,sT,aT,oT),writeLock:t=>L$(t,cT,lT,uT)}};var Jf={},cl;async function hT(r,e){let t,n=new Promise(i=>{t=i});return r.add(async()=>await P2((async()=>await new Promise(i=>{t(()=>{i()})}))(),{milliseconds:e.timeout})),await n}var Z6e=(r,e)=>{if(cl.isWorker===!0)return{readLock:cl.readLock(r,e),writeLock:cl.writeLock(r,e)};let t=new Up({concurrency:1}),n;return{async readLock(){if(n!=null)return await hT(n,e);n=new Up({concurrency:e.concurrency,autoStart:!1});let i=n,s=hT(n,e);return t.add(async()=>(i.start(),await i.onIdle().then(()=>{n===i&&(n=null)}))),await s},async writeLock(){return n=null,await hT(t,e)}}},J6e={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function eh(r){let e=Object.assign({},J6e,r);return cl==null&&(cl=B$(e),cl.isWorker!==!0&&(cl.addEventListener("requestReadLock",t=>{Jf[t.data.name]!=null&&Jf[t.data.name].readLock().then(async n=>await t.data.handler().finally(()=>n()))}),cl.addEventListener("requestWriteLock",async t=>{Jf[t.data.name]!=null&&Jf[t.data.name].writeLock().then(async n=>await t.data.handler().finally(()=>n()))}))),Jf[e.name]==null&&(Jf[e.name]=Z6e(e.name,e)),Jf[e.name]}var Qw;function k2(r=!1){if(Qw)return Qw;let e=eh({singleProcess:r});return Qw={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()}}},Qw}u();u();u();var dT=_(V(),1);var M$=D("ipfs:mfs:utils:with-mfs-root");async function Vp(r,e){if(e&&e.signal&&e.signal.aborted)throw(0,dT.default)(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});await r.repo.datastore.open();let t;try{let n=await r.repo.datastore.get(X1);t=A.decode(n)}catch(n){if(n.code!=="ERR_NOT_FOUND")throw n;M$("Creating new MFS root");let i=qe({Data:new $e({type:"directory"}).marshal(),Links:[]}),s=await Ke.digest(i);if(t=A.createV0(s),await r.repo.blocks.put(t,i),e&&e.signal&&e.signal.aborted)throw(0,dT.default)(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});await r.repo.datastore.put(X1,t.bytes)}return M$(`Loaded MFS root /ipfs/${t}`),t}u();function Kp(r=""){return(r.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean)}var mT=_(V(),1);var pT="ipfs",kr=async(r,e,t)=>{let n=await Vp(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,mT.default)(new Error("paths must not be empty"),"ERR_NO_PATH");if(s.substring(0,1)!=="/")throw(0,mT.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=Kp(s);if(o[0]===pT){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=`/${pT}/${n}${o.length?"/"+o.join("/"):""}`,l=`/${pT}/${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 Kn(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 F$=_(V(),1);var ewe=ze.bind({ignoreUndefined:!0}),twe=D("ipfs:mfs:stat"),rwe={withLocal:!1};function ul(r){async function e(t,n={}){n=ewe(rwe,n),twe(`Fetching stats for ${t}`);let{type:i,cid:s,mfsPath:o}=await kr(r,t,n),a=i==="ipfs"&&s?s:o,c;try{c=await Kn(a,r.repo.blocks)}catch(l){throw l.code==="ERR_NOT_FOUND"?(0,F$.default)(new Error(`${t} does not exist`),"ERR_NOT_FOUND"):l}if(!U$[c.type])throw new Error(`Cannot stat codec ${c.cid.code}`);return U$[c.type](c)}return M(e)}var U$={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:qe(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:qe(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 Gp=_(V(),1);u();var nwe=D("ipfs:mfs:utils:to-trail");async function ma(r,e){nwe(`Creating trail for path ${e}`);let t=[];for await(let n of px(e,r.repo.blocks))t.push({name:n.name,cid:n.cid,size:n.size,type:n.type});return t}u();u();u();var Xw=async(r,e,t)=>{t.codec||(t.codec=gt),t.hasher||(t.hasher=Ke),t.cidVersion===void 0&&(t.cidVersion=1),t.codec===gt&&t.hasher!==Ke&&(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 Zw=Mf.code,Jw=8;async function e8(r){return(await Mf.encode(r)).subarray(0,8).reverse()}var yT=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){}},zp=class extends yT{constructor(e,t){super(e,t),this._bucket=Gu({hashFn:e8,bits:Jw})}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*V$(this._bucket,e,this,this.options)}};async function*V$(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 xr){let g;for await(let w of await V$(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 v of g.flush(e))w=v,yield w;let E=y+m.key;s.push({Name:E,Tsize:w.size,Hash:w.cid}),o+=w.size}else{let g=m.value;if(!g.cid)continue;let w=y+m.key,E=g.size;s.push({Name:w,Tsize:E,Hash:g.cid}),o+=E}}let a=Uint8Array.from(i.bitField().reverse()),l={Data:new $e({type:"hamt-sharded-directory",data:a,fanout:r.tableSize(),hashType:Zw,mtime:t&&t.mtime,mode:t&&t.mode}).marshal(),Links:s},f=qe(vn(l)),h=await Xw(f,e,n),p=f.length+o;yield{cid:h,node:l,size:p}}u();var N2=D("ipfs:mfs:core:utils:hamt-utils"),qp=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=$e.unmarshal(n.parent.Data),o=new $e({type:"hamt-sharded-directory",data:i,fanout:t.tableSize(),hashType:Zw,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=qe(c),f=await a.digest(l),h=A.create(n.cidVersion,rt,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)}},gT=async(r,e,t,n,i)=>{let s=new xr({hash:t._options.hash,bits:t._options.bits},n,i);return n._putObjectAt(i,s),await O2(r,e,s,t),s},wT=async r=>{let e=Gu({hashFn:e8,bits:Jw});return await Promise.all(r.map(async t=>{let n=t.Name||"";if(n.length===2){let i=parseInt(n,16),s=new xr({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},O2=async(r,e,t,n)=>{await Promise.all(e.map(async i=>{let s=i.Name||"";if(s.length===2){N2("Populating sub bucket",s);let o=parseInt(s,16),a=await r.repo.blocks.get(i.Hash),c=yt(a),l=new xr({hash:n._options.hash,bits:n._options.bits},t,o);return t._putObjectAt(o,l),await O2(r,c.Links,l,n),Promise.resolve()}return n.put(s.substring(2),{size:i.Tsize,cid:i.Hash})}))},th=r=>r.toString(16).toUpperCase().padStart(2,"0").substring(0,2),K$=async(r,e,t)=>{let n=await wT(t.Links),i=await n._findNewBucketAndPos(e),s=[{bucket:i.bucket,prefix:th(i.pos)}],o=i.bucket;for(;o!==n;)s.push({bucket:o,prefix:th(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){N2(`Link ${c.prefix}${e} will be added`);continue}if(l.Name===`${c.prefix}${e}`){N2(`Link ${c.prefix}${e} will be replaced`);continue}N2(`Found subshard ${c.prefix}`);let f=await r.repo.blocks.get(l.Hash),h=yt(f);if(!s[a+1]){N2(`Loaded new subshard ${c.prefix}`),await gT(r,h.Links,n,c.bucket,parseInt(c.prefix,16));let d=await n._findNewBucketAndPos(e);s.push({bucket:d.bucket,prefix:th(d.pos),node:h});continue}let p=s[a+1];await O2(r,h.Links,p.bucket,n),p.node=h}return await n.put(e,!0),s.reverse(),{rootBucket:n,path:s}},z$=async(r,e,t={})=>{let n=new zp({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 Xt(n.flush(r.repo.blocks));if(!i)throw new Error("Flushing shard yielded no result");return i};var ya=_(V(),1);var ga=D("ipfs:mfs:core:utils:add-link");async function Ns(r,e){let t=e.parent;if(e.parentCid){let i=A.asCID(e.parentCid);if(i===null)throw(0,ya.default)(new Error("Invalid CID passed to addLink"),"EINVALIDPARENTCID");if(i.code!==rt)throw(0,ya.default)(new Error("Unsupported codec. Only DAG-PB is supported"),"EINVALIDPARENTCID");ga(`Loading parent node ${i}`);let s=await r.repo.blocks.get(i);t=yt(s)}if(!t)throw(0,ya.default)(new Error("No parent node or CID passed to addLink"),"EINVALIDPARENT");if(!e.cid)throw(0,ya.default)(new Error("No child cid passed to addLink"),"EINVALIDCHILDCID");if(!e.name)throw(0,ya.default)(new Error("No child name passed to addLink"),"EINVALIDCHILDNAME");if(!e.size&&e.size!==0)throw(0,ya.default)(new Error("No child size passed to addLink"),"EINVALIDCHILDSIZE");if(!t.Data)throw(0,ya.default)(new Error("Parent node with no data passed to addLink"),"ERR_INVALID_PARENT");let n=$e.unmarshal(t.Data);return n.type==="hamt-sharded-directory"?(ga("Adding link to sharded directory"),owe(r,{...e,parent:t})):t.Links.length>=e.shardSplitThreshold?(ga("Converting directory to sharded directory"),iwe(r,{...e,parent:t,mtime:n.mtime,mode:n.mode})):(ga(`Adding ${e.name} (${e.cid}) to regular directory`),swe(r,{...e,parent:t}))}var iwe=async(r,e)=>{let t=await z$(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 ga(`Converted directory to sharded directory ${t.cid}`),t},swe=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,ya.default)(new Error("Parent node with no data passed to addToDirectory"),"ERR_INVALID_PARENT");let n=$e.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=vn({Data:i,Links:t});let s=await r.hashers.getHasher(e.hashAlg),o=qe(e.parent),a=await s.digest(o),c=A.create(e.cidVersion,rt,a);return e.flush&&await r.repo.blocks.put(c,o),{node:e.parent,cid:c,size:o.length}},owe=async(r,e)=>{let{shard:t,path:n}=await awe(r,e),i=await Xt(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=yt(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),qp(r,a,n[0].bucket,e)},awe=async(r,e)=>{let t={name:e.name,cid:e.cid,size:e.size};if(!e.parent.Data)throw(0,ya.default)(new Error("Parent node with no data passed to addFileToShardedDirectory"),"ERR_INVALID_PARENT");let n=await wT(e.parent.Links),i=$e.unmarshal(e.parent.Data),s=new zp({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=cwe(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){ga(`Link ${l.prefix}${t.name} will be added`),c=a.length;break}if(h.Name===`${l.prefix}${t.name}`){ga(`Link ${l.prefix}${t.name} will be replaced`),c=a.length;break}if((h.Name||"").length>2){ga(`Link ${h.Name} ${h.Hash} will be replaced with a subshard`),c=a.length;break}ga(`Found subshard ${l.prefix}`);let p=await r.repo.blocks.get(h.Hash),d=yt(p);if(!a[c]){ga(`Loaded new subshard ${l.prefix}`),await gT(r,d.Links,n,l.bucket,parseInt(l.prefix,16));let y=await n._findNewBucketAndPos(t.name);a.push({bucket:y.bucket,prefix:th(y.pos),node:d});break}let m=a[c];await O2(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}},cwe=r=>{let e=[{bucket:r.bucket,prefix:th(r.pos)}],t=r.bucket._parent,n=r.bucket._posAtParent;for(;t;)e.push({bucket:t,prefix:th(n)}),n=t._posAtParent,t=t._parent;return e.reverse(),e};u();var q$=D("ipfs:mfs:utils:update-tree"),uwe={shardSplitThreshold:1e3};async function Hi(r,e,t){t=Object.assign({},uwe,t),q$("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=yt(o),c=e[n].cid,l=e[n].name;if(n++,!i){i={cid:c,name:l,size:o.length};continue}let f=await Ns(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 q$(`Final CID ${s}`),s}u();var $$=_(V(),1),lwe=D("ipfs:mfs:utils:update-mfs-root");async function Gi(r,e,t){if(t&&t.signal&&t.signal.aborted)throw(0,$$.default)(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});return lwe(`New MFS root will be ${e}`),await r.repo.datastore.put(X1,e.bytes),e}u();u();var rh=_(V(),1);u();async function H$(r,e,t){let n=new $e({type:e,mode:t.mode,mtime:t.mtime}),i=await r.hashers.getHasher(t.hashAlg),s={Data:n.marshal(),Links:[]},o=qe(s),a=await i.digest(o),c=A.create(t.cidVersion,rt,a);return t.flush&&await r.repo.blocks.put(c,o),{cid:c,node:s}}var fwe=ze.bind({ignoreUndefined:!0}),G$=D("ipfs:mfs:mkdir"),hwe={parents:!1,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3,flush:!0};function nh(r){async function e(t,n={}){let i=fwe(hwe,n);if(!t)throw new Error("no path given to Mkdir");if(t=t.trim(),t==="/"){if(i.parents)return;throw(0,rh.default)(new Error("cannot create directory '/': Already exists"),"ERR_INVALID_PATH")}if(t.substring(0,1)!=="/")throw(0,rh.default)(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");G$(`Creating ${t}`);let s=Kp(t);if(s[0]==="ipfs")throw(0,rh.default)(new Error("path cannot have the prefix 'ipfs'"),"ERR_INVALID_PATH");let o=await Vp(r,i),a,c=[],l=await H$(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 Kn(d,r.repo.blocks),a.type!=="file"&&a.type!=="directory")throw(0,rh.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");if(h===s.length){if(i.parents)return;throw(0,rh.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,rh.default)(new Error(`Intermediate directory path ${d} does not exist, use the -p flag to create it`),"ERR_NOT_FOUND");await dwe(r,p[p.length-1],l,c[c.length-1],c,i)}else throw m}}let f=await Hi(r,c,i);await Gi(r,f,i)}return M(e)}var dwe=async(r,e,t,n,i,s)=>{G$(`Adding empty dir called ${e} to ${n.cid}`);let o=await Ns(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 ll=_(V(),1);var pwe=ze.bind({ignoreUndefined:!0}),t8=D("ipfs:mfs:cp"),mwe={parents:!1,flush:!0,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3};function $p(r){async function e(t,n,i={}){let s=pwe(mwe,i);Array.isArray(t)||(t=[t]);let o=await Promise.all(t.map(p=>kr(r,p,s))),a=await kr(r,n,s);if(!o.length||!a)throw(0,ll.default)(new Error("Please supply at least one source"),"ERR_INVALID_PARAMS");let c=o.find(p=>!p.exists);if(c)throw(0,ll.default)(new Error(`${c.path} does not exist`),"ERR_INVALID_PARAMS");let l=W$(a);if(a.exists){if(t8("Destination exists"),o.length===1&&!l)throw(0,ll.default)(new Error("directory already has entry by that name"),"ERR_ALREADY_EXISTS")}else if(t8("Destination does not exist"),o.length>1){if(!s.parents)throw(0,ll.default)(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await nh(r)(a.path,s),a=await kr(r,a.path,s)}else if(a.parts.length>1){let p=`/${a.parts.slice(0,-1).join("/")}`;try{await ul(r)(p,s)}catch(d){if(d.code!=="ERR_NOT_FOUND")throw d;if(!s.parents)throw(0,ll.default)(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await nh(r)(p,s),a=await kr(r,a.path,s)}}let f=W$(a)?a.mfsPath:a.mfsDirectory,h=await ma(r,f);if(o.length===1){let p=o.pop();if(!p)throw(0,ll.default)(new Error("could not find source"),"ERR_INVALID_PARAMS");let d=l?p.name:a.name;return t8(`Only one source, copying to destination ${l?"directory":"file"} ${d}`),ywe(r,p,d,h,s)}return t8("Multiple sources, wrapping in a directory"),gwe(r,o,a,h,s)}return M(e)}var W$=r=>r.unixfs&&r.unixfs.type&&r.unixfs.type.includes("directory"),ywe=async(r,e,t,n,i)=>{let s=n.pop();if(!s)throw(0,ll.default)(new Error("destination had no parent"),"ERR_INVALID_PARAMS");s=await j$(r,e,t,s,i),n.push(s);let o=await Hi(r,n,i);await Gi(r,o,i)},gwe=async(r,e,t,n,i)=>{for(let o=0;o<e.length;o++){let a=e[o];t=await j$(r,a,a.name,t,i)}n[n.length-1]=t;let s=await Hi(r,n,i);await Gi(r,s,i)},j$=async(r,e,t,n,i)=>{let s=await r.repo.blocks.get(e.cid),{node:o,cid:a,size:c}=await Ns(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 L2=_(V(),1);u();var fl=_(V(),1),hl=D("ipfs:mfs:core:utils:remove-link");async function Y$(r,e){let t=e.parent;if(e.parentCid){let i=A.asCID(e.parentCid);if(i===null)throw(0,fl.default)(new Error("Invalid CID passed to removeLink"),"EINVALIDPARENTCID");hl(`Loading parent node ${i}`);let s=await r.repo.blocks.get(i);t=yt(s)}if(!t)throw(0,fl.default)(new Error("No parent node or CID passed to removeLink"),"EINVALIDPARENT");if(!e.name)throw(0,fl.default)(new Error("No child name passed to removeLink"),"EINVALIDCHILDNAME");if(!t.Data)throw(0,fl.default)(new Error("Parent node had no data"),"ERR_INVALID_NODE");return $e.unmarshal(t.Data).type==="hamt-sharded-directory"?(hl(`Removing ${e.name} from sharded directory`),Ewe(r,{...e,parent:t})):(hl(`Removing link ${e.name} regular directory`),wwe(r,{...e,parent:t}))}var wwe=async(r,e)=>{e.parent.Links=e.parent.Links.filter(o=>o.Name!==e.name);let t=await qe(e.parent),i=await(await r.hashers.getHasher(e.hashAlg)).digest(t),s=A.create(e.cidVersion,rt,i);return await r.repo.blocks.put(s,t),hl(`Updated regular directory ${s}`),{node:e.parent,cid:s}},Ewe=async(r,e)=>{let{rootBucket:t,path:n}=await K$(r,e.name,e.parent);await t.del(e.name);let{node:i}=await Q$(r,n,e.name,e);return qp(r,i.Links,t,e)},Q$=async(r,e,t,n)=>{let i=e.pop();if(!i)throw(0,fl.default)(new Error("Could not find parent"),"EINVALIDPARENT");let{bucket:s,prefix:o,node:a}=i;if(!a)throw(0,fl.default)(new Error("Could not find parent"),"EINVALIDPARENT");let c=a.Links.find(d=>(d.Name||"").substring(0,2)===o);if(!c)throw(0,fl.default)(new Error(`No link found with prefix ${o} for file ${t}`),"ERR_NOT_FOUND");if(c.Name===`${o}${t}`){hl(`Removing existing link ${c.Name}`);let d=a.Links.filter(m=>m.Name!==c.Name);return await s.del(t),qp(r,d,s,n)}hl(`Descending into sub-shard ${c.Name} for ${o}${t}`);let l=await Q$(r,e,t,n),f=l.cid,h=l.size,p=o;if(l.node.Links.length===1){hl(`Removing subshard for ${o}`);let d=l.node.Links[0];p=`${o}${(d.Name||"").substring(2)}`,f=d.Hash,h=d.Tsize||0}return hl(`Updating shard ${o} with name ${p}`),bwe(r,s,a,o,p,h,f,n)},bwe=(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}),qp(r,c,e,a)};var _we=ze.bind({ignoreUndefined:!0}),vwe={recursive:!1,cidVersion:0,hashAlg:"sha2-256",flush:!0,shardSplitThreshold:1e3};function Hp(r){async function e(t,n={}){let i=_we(vwe,n);Array.isArray(t)||(t=[t]);let s=await Promise.all(t.map(o=>kr(r,o,i)));if(!s.length)throw(0,L2.default)(new Error("Please supply at least one path to remove"),"ERR_INVALID_PARAMS");s.forEach(o=>{if(o.path==="/")throw(0,L2.default)(new Error("Cannot delete root"),"ERR_INVALID_PARAMS")});for(let o of s)await Swe(r,o.path,i)}return M(e)}var Swe=async(r,e,t)=>{let n=await kr(r,e,t),i=await ma(r,n.mfsPath),s=i[i.length-1];i.pop();let o=i[i.length-1];if(!o)throw(0,L2.default)(new Error(`${e} does not exist`),"ERR_NOT_FOUND");if(s.type==="directory"&&!t.recursive)throw(0,L2.default)(new Error(`${e} is a directory, use -r to remove directories`),"ERR_WAS_DIR");let{cid:a}=await Y$(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 Hi(r,i,t);await Gi(r,c,t)};var xwe=ze.bind({ignoreUndefined:!0}),Twe=D("ipfs:mfs:touch"),X$={flush:!0,shardSplitThreshold:1e3,hashAlg:"sha2-256",cidVersion:0,recursive:!1};function Iwe(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 Awe(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 Rwe(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 Cwe(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=Iwe(o,e,t);return a=Awe(i,a),a=Rwe(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 Z$(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)=>Cwe(i,n,e.isDirectory()),e.mode||0)}return r}function J$(r){async function e(t,n,i={}){let s=xwe(X$,i);Twe(`Fetching stats for ${t}`);let{cid:o,mfsDirectory:a,name:c}=await kr(r,t,s);if(o.code!==rt)throw(0,Gp.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");if(s.recursive){let C=await de(async function*(){for await(let B of hw(o,r.repo.blocks)){if(B.type!=="file"&&B.type!=="directory")throw(0,Gp.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");B.unixfs.mode=Z$(n,B.unixfs);let q=vn({Data:B.unixfs.marshal(),Links:B.node.Links});yield{path:B.path,content:q}}},B=>Tp(B,r.repo.blocks,{...s,pin:!1,dagBuilder:async function*(q,W,oe){for await(let te of q)yield async function(){let Ve=te.content,me=qe(Ve),Ae=await Xw(me,W,oe);if(!Ve.Data)throw(0,Gp.default)(new Error(`${Ae} had no data`),"ERR_INVALID_NODE");let $=$e.unmarshal(Ve.Data);return{cid:Ae,size:me.length,path:te.path,unixfs:$}}}}),B=>Xt(B));if(!C)throw(0,Gp.default)(new Error(`Could not chmod ${t}`),"ERR_COULD_NOT_CHMOD");await Hp(r)(t,s),await $p(r)(`/ipfs/${C.cid}`,t,s);return}let l=await r.repo.blocks.get(o),f=yt(l);if(!f.Data)throw(0,Gp.default)(new Error(`${o} had no data`),"ERR_INVALID_NODE");let h=$e.unmarshal(f.Data);h.mode=Z$(n,h);let p=qe({Data:h.marshal(),Links:f.Links}),d=s.hashAlg||X$.hashAlg,y=await(await r.hashers.getHasher(d)).digest(p),g=A.create(s.cidVersion,rt,y);s.flush&&await r.repo.blocks.put(g,p);let w=await ma(r,a),E=w[w.length-1],v=A.decode(E.cid.bytes),x=await r.repo.blocks.get(v),I=yt(x),T=await Ns(r,{parent:I,name:c,cid:g,size:p.length,flush:s.flush,hashAlg:d,cidVersion:o.version,shardSplitThreshold:1/0});E.cid=T.cid;let S=await Hi(r,w,s);await Gi(r,S,s)}return M(e)}u();var Dwe=ze.bind({ignoreUndefined:!0}),Pwe={};function eH(r){async function e(t,n={}){n=Dwe(Pwe,n);let{cid:i}=await ul(r)(t,n);return i}return M(e)}u();var kwe=ze.bind({ignoreUndefined:!0}),Nwe={parents:!1,flush:!0,cidVersion:0,hashAlg:"sha2-256",shardSplitThreshold:1e3};function tH(r){async function e(t,n,i={}){let s=kwe(Nwe,i);await $p(r)(t,n,s),await Hp(r)(t,{...s,recursive:!0})}return M(e)}u();var ET=_(V(),1);var Owe=ze.bind({ignoreUndefined:!0}),Lwe=D("ipfs:mfs:touch"),rH={flush:!0,shardSplitThreshold:1e3,cidVersion:0,hashAlg:"sha2-256"};function nH(r){async function e(t,n={}){let i=Owe(rH,n);i.mtime=i.mtime||new Date,Lwe(`Touching ${t} mtime: ${i.mtime}`);let{cid:s,mfsDirectory:o,name:a,exists:c}=await kr(r,t,i),l=n.hashAlg||rH.hashAlg,f=await r.hashers.getHasher(l),h,p,d=i.cidVersion;if(c){if(s.code!==rt)throw(0,ET.default)(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");d=s.version;let I=await r.repo.blocks.get(s),T=yt(I);if(!T.Data)throw(0,ET.default)(new Error(`${t} had no data`),"ERR_INVALID_NODE");let S=$e.unmarshal(T.Data);S.mtime=i.mtime,h=qe({Data:S.marshal(),Links:T.Links});let C=await f.digest(h);p=A.create(i.cidVersion,rt,C),i.flush&&await r.repo.blocks.put(p,h)}else{let I=new $e({type:"file",mtime:i.mtime});h=qe({Data:I.marshal(),Links:[]});let T=await f.digest(h);p=A.create(i.cidVersion,rt,T),i.flush&&await r.repo.blocks.put(p,h)}let m=await ma(r,o),y=m[m.length-1],g=y.cid,w=await r.repo.blocks.get(g),E=yt(w),v=await Ns(r,{parent:E,name:a,cid:p,size:h.length,flush:i.flush,shardSplitThreshold:i.shardSplitThreshold,hashAlg:i.hashAlg,cidVersion:d});y.cid=v.cid;let x=await Hi(r,m,i);await Gi(r,x,i)}return M(e)}u();var bT=_(V(),1);var Bwe=ze.bind({ignoreUndefined:!0}),Mwe={offset:0,length:1/0};function iH(r){function e(t,n={}){return n=Bwe(Mwe,n),{[Symbol.asyncIterator]:async function*(){let s=await kr(r,t,n),o=await Kn(s.mfsPath,r.repo.blocks);if(o.type!=="file")throw(0,bT.default)(new Error(`${t} was not a file`),"ERR_NOT_FILE");if(!o.content)throw(0,bT.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 _T=_(V(),1);var B2=D("ipfs:mfs:utils:to-async-iterator");function sH(r){if(!r)throw(0,_T.default)(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");if((typeof r=="string"||r instanceof String)&&(B2("Content was a string"),r=z(r.toString())),r.length)return B2("Content was array-like"),{[Symbol.asyncIterator]:function*(){yield r}};if(r[Symbol.asyncIterator])return B2("Content was an async iterator"),r;if(r[Symbol.iterator])return B2("Content was an iterator"),r;if(globalThis.Blob&&r instanceof globalThis.Blob){B2("Content was an HTML5 Blob");let e=0,t={next:()=>e>r.size?{done:!0}:new Promise((n,i)=>{let s=r.slice(e,Z1);e+=Z1;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,_T.default)(new Error(`Don't know how to convert ${r} into an async iterator`),"ERR_INVALID_PARAMS")}var Ea=_(V(),1);var Uwe=ze.bind({ignoreUndefined:!0}),wa=D("ipfs:mfs:write"),Fwe={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 aH(r){async function e(t,n,i={}){let s=Uwe(Fwe,i),o,a,c;if(wa("Reading source, destination and parent"),await k2().readLock(async()=>{o=await sH(n),a=await kr(r,t,s),c=await kr(r,a.mfsDirectory,s)})(),wa("Read source, destination and parent"),!s.parents&&!c.exists)throw(0,Ea.default)(new Error("directory does not exist"),"ERR_NO_EXIST");if(o==null)throw(0,Ea.default)(new Error("could not create source"),"ERR_NO_SOURCE");if(a==null)throw(0,Ea.default)(new Error("could not create destination"),"ERR_NO_DESTINATION");if(!s.create&&!a.exists)throw(0,Ea.default)(new Error("file does not exist"),"ERR_NO_EXIST");if(a.entryType!=="file")throw(0,Ea.default)(new Error("not a file"),"ERR_NOT_A_FILE");return Vwe(r,t,o,a,s)}return M(e)}var Vwe=async(r,e,t,n,i)=>{let s=await Kwe(r,t,n,i);await k2().writeLock(async()=>{let o=Kp(e),a=o.pop();if(a==null)throw(0,Ea.default)(new Error("source does not exist"),"ERR_NO_EXIST");let c=!1;try{await ul(r)(`/${o.join("/")}`,i),c=!0}catch(g){if(g.code!=="ERR_NOT_FOUND")throw g}c||await nh(r)(`/${o.join("/")}`,i);let l=await kr(r,e,i),f=await ma(r,l.mfsDirectory),h=f[f.length-1];if(!h)throw(0,Ea.default)(new Error("directory does not exist"),"ERR_NO_EXIST");if(!h.type||!h.type.includes("directory"))throw(0,Ea.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=yt(p),m=await Ns(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 Hi(r,f,i);await Gi(r,y,i)})()},Kwe=async(r,e,t,n)=>{t.exists?wa(`Overwriting file ${t.cid} offset ${n.offset} length ${n.length}`):wa(`Writing file offset ${n.offset} length ${n.length}`);let i=[];if(n.offset>0)if(t.unixfs){if(wa(`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();wa(`Writing zeros for extra ${f} bytes`),i.push(oH(f))}}else wa(`Writing zeros for first ${n.offset} bytes`),i.push(oH(n.offset));i.push(cH(e,n.length));let s=qwe(zwe(i),f=>{if(t.unixfs&&!n.truncate){let h=t.unixfs.fileSize();if(h>f)return wa(`Writing last ${h-f} of ${h} bytes from original file starting at offset ${f}`),t.content({offset:f});wa("Not writing last bytes from original file")}return{[Symbol.asyncIterator]:async function*(){}}}),o;n.mode!==void 0&&n.mode!==null?o=Za(n.mode):t&&t.unixfs&&(o=t.unixfs.mode);let a;n.mtime!=null?a=wu(n.mtime):t&&t.unixfs&&(a=t.unixfs.mtime);let c=await r.hashers.getHasher(n.hashAlg),l=await Xt(Tp([{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,Ea.default)(new Error(`cannot write to ${parent.name}`),"ERR_COULD_NOT_WRITE");return wa(`Wrote ${l.cid}`),{cid:l.cid,size:l.size}},cH=(r,e)=>async function*(){let n=0;for await(let i of r){if(n+=i.length,n>e){yield i.subarray(0,e-n);return}yield i}},oH=(r,e=Z1)=>{let t=new Uint8Array(e);async function*n(){for(;;)yield t}return cH(n(),r)},zwe=async function*(r){for(let e=0;e<r.length;e++)yield*r[e]()},qwe=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 uH=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 lH(r){async function*e(t,n={}){let i=await kr(r,t,n),s=await Kn(i.mfsPath,r.repo.blocks);if(s.type==="directory"){yield*dr(s.content(n),uH);return}yield uH(s)}return M(e)}var $we={stat:ul},Hwe={chmod:J$,cp:$p,flush:eH,mkdir:nh,mv:tH,rm:Hp,touch:nH},fH={write:aH,read:iH,ls:lH},hH=({options:r,mfs:e,operations:t,lock:n})=>{Object.keys(t).forEach(i=>{e[i]=n(t[i](r))})},Gwe={repoOwner:!0,repo:null};function Wwe(r){let{repoOwner:e}=Object.assign({},Gwe||{},r),t=k2(e),n=o=>t.readLock(o),i=o=>t.writeLock(o),s={};return hH({options:r,mfs:s,operations:$we,lock:n}),hH({options:r,mfs:s,operations:Hwe,lock:i}),Object.keys(fH).forEach(o=>{s[o]=fH[o](r)}),s}function dH({repo:r,preload:e,hashers:t,options:n}){let i=Wwe({repo:r,repoOwner:n.repoOwner!==!1,hashers:t}),s=o=>(...c)=>{let l=c.filter(f=>eB(f)||w4(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 pH({keychain:r}){return M((t,n)=>r.exportKey(t,n))}u();var mH="Ed25519",yH=2048;function gH({keychain:r}){return M((t,n={type:mH,size:yH})=>r.createKey(t,n.type||mH,n.size||yH))}u();function wH({keychain:r}){return M((t,n,i)=>r.importKey(t,n,i))}u();function EH({keychain:r}){return M(t=>r.findKeyByName(t))}u();function bH({keychain:r}){return M(()=>r.listKeys())}u();function _H({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 vH({keychain:r}){return M(t=>r.removeKey(t))}var r8=class{constructor({keychain:e}){this.gen=gH({keychain:e}),this.list=bH({keychain:e}),this.rm=vH({keychain:e}),this.rename=_H({keychain:e}),this.export=pH({keychain:e}),this.import=wH({keychain:e}),this.info=EH({keychain:e})}};u();u();u();function Si({repo:r,preload:e}){async function t(n,i={}){i.preload!==!1&&e(n);let s=await r.blocks.get(n,i);return yt(s)}return M(t)}function SH({repo:r,preload:e}){let t=Si({repo:r,preload:e});async function n(i,s={}){return(await t(i,s)).Data||new Uint8Array(0)}return M(n)}u();function vT(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)&&vT(n,e),n&&typeof n=="object"&&vT(n,e)}return e}function xH({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 xn:return[];case rt:return a.Links;case F1:case lv:return vT(a);default:throw new Error(`Cannot resolve links from codec ${n.code}`)}}return M(t)}u();function TH({repo:r,preload:e}){async function t(n={}){let i;if(n.template)if(n.template==="unixfs-dir")i=new $e({type:"directory"}).marshal();else throw new Error("unknown template");let s=qe({Data:i,Links:[]}),o=await Ke.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 ba({repo:r,preload:e}){async function t(n,i={}){let s=await r.gcLock.readLock();try{let o=qe(n),a=await Ke.digest(o),c=A.createV1(rt,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 IH({repo:r,preload:e}){let t=Si({repo:r,preload:e});async function n(i,s={}){let o=await t(i,s),c=qe(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 AH({repo:r,preload:e}){let t=Si({repo:r,preload:e}),n=ba({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();function RH({repo:r,preload:e}){let t=Si({repo:r,preload:e}),n=ba({repo:r,preload:e});async function i(s,o,a={}){let c=await t(s,a),l=De([c.Data||[],o]);return n({...c,Data:l},a)}return M(i)}u();function CH({repo:r,preload:e}){let t=Si({repo:r,preload:e}),n=ba({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 DH({repo:r,preload:e}){let t=Si({repo:r,preload:e}),n=ba({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 n8=class{constructor({repo:e,preload:t}){this.addLink=AH({repo:e,preload:t}),this.appendData=RH({repo:e,preload:t}),this.rmLink=CH({repo:e,preload:t}),this.setData=DH({repo:e,preload:t})}};var i8=class{constructor({repo:e,codecs:t,preload:n}){this.data=SH({repo:e,preload:n}),this.get=Si({repo:e,preload:n}),this.links=xH({repo:e,codecs:t}),this.new=TH({repo:e,preload:n}),this.put=ba({repo:e,preload:n}),this.stat=IH({repo:e,preload:n}),this.patch=new n8({repo:e,preload:n})}};u();u();var jwe=D("ipfs:repo:gc");function PH({repo:r,hashers:e}){async function*t(n={}){let i=Date.now(),s;try{s=await Vp({repo:r,hashers:e},n),await r.pins.pinRecursively(s),yield*r.gc()}finally{s&&await r.pins.unpin(s)}jwe(`Complete (${Date.now()-i}ms)`)}return M(t)}u();function s8({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 kH({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 o8=class{constructor({repo:e,hashers:t}){this.gc=PH({repo:e,hashers:t}),this.stat=s8({repo:e}),this.version=kH({repo:e}),this.setApiAddr=n=>e.apiAddr.set(n)}};u();u();var OH=_(V(),1);function NH(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 LH({network:r}){return M(async function*(t={}){let{libp2p:n}=await r.use(t);if(!t.poll){yield NH(n,t);return}let i=t.interval||1e3,s=-1;try{if(s=typeof i=="string"?Tu(i)||-1:i,!s||s<0)throw new Error("invalid duration")}catch(a){throw(0,OH.default)(a,"ERR_INVALID_POLL_INTERVAL")}let o;try{for(;;)yield NH(n,t),await new Promise(a=>{o=setTimeout(a,s)})}finally{clearTimeout(o)}})}var a8=class{constructor({repo:e,network:t}){this.repo=s8({repo:e}),this.bw=LH({network:t}),this.bitswap=M6({network:t})}};u();u();u();u();var U2=Qwe;function Qwe(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 YG=_(Ci(),1),mh=_(V(),1);u();u();u();var MH=_(Ci(),1);u();async function ih(r){let e=0;for await(let t of r)e++;return e}var Xwe=(0,MH.default)("ipfs:repo:migrator:migration-8");function UH(r){return r.child?UH(r.child):r}function Zwe(r){try{let e=dt.decode(`b${r.toString().toLowerCase().slice(1)}`),t=A.decode(e).multihash.bytes,n=dt.encode(t).slice(1).toUpperCase();return new ie(`/${n}`,!1)}catch{return r}}function Jwe(r){try{let e=dt.decode(`b${r.toString().toLowerCase().slice(1)}`),t=Jt(e),n=dt.encode(A.createV1(xn,t).bytes).slice(1);return new ie(`/${n.toUpperCase()}`,!1)}catch{return r}}async function BH(r,e,t){let n=r.blocks;await n.open();let i=UH(n),s=await ih(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,Xwe(`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 FH={version:8,description:"Transforms key names into base32 encoding and converts Block store to use bare multihashes encoded as base32",migrate:(r,e=()=>{})=>BH(r,e,Zwe),revert:(r,e=()=>{})=>BH(r,e,Jwe)};u();u();u();var sh=_(Qo(),1),VH=sh.default.Reader,e8e=sh.default.Writer,Zot=sh.default.util,c8=sh.default.roots.default||(sh.default.roots.default={}),KH=c8.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=e8e.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 VH||(i=VH.create(i));for(var o=s===void 0?i.len:i.pos+s,a=new c8.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 c8.ipfs.pin.Set)return i;var s=new c8.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,sh.default.util.toJSONOptions)},t}(),e}(),r})();var HH=_(qH(),1),f8=_(Jo(),1);u();var F2=new ie("/local/pins"),l8=256,$H=8192,xT=A.parse("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n"),oh={direct:"direct",recursive:"recursive"};function TT(r){return new ie(`/${dt.encode(r.multihash.bytes).toUpperCase().substring(1)}`)}var IT=KH.pin.Set;function t8e(r){let e=r.Data;if(!e)throw new Error("No data present");let t=f8.default.decode(e),n=f8.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=IT.toObject(IT.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 r8e(r,e){let t=new Uint8Array(4);new DataView(t.buffer).setUint32(0,r,!0);let i=z(e.toString()),s=De([t,i],t.byteLength+i.byteLength);return(0,HH.default)(K(s))}async function*GH(r,e){let t=t8e(e),n=0;for(let i of e.Links){if(n<t.header.fanout){let s=i.Hash;if(!xT.equals(s)){let o=await r.get(s),a=yt(o);yield*GH(r,a)}}else yield i.Hash;n++}}async function*V2(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=yt(i);yield*GH(r,s)}function n8e(r,e){return t(e,0);async function t(n,i){let s=IT.encode({version:1,fanout:l8,seed:i}).finish(),o=f8.default.encode(s.length),a=De([o,s]),c=[];for(let f=0;f<l8;f++)c.push({Name:"",Tsize:1,Hash:xT});if(n.length<=$H){let f=n.map(d=>({link:{Name:"",Tsize:1,Hash:d.key},data:d.data||new Uint8Array})).sort((d,m)=>Vf(d.link.Hash.bytes,m.link.Hash.bytes)),h=c.concat(f.map(d=>d.link));return{Data:De([a,...f.map(d=>d.data)]),Links:h}}else{let f=n.reduce((p,d)=>{let m=r8e(i,d.key)%l8;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=qe(f),d=await Ke.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 AT(r,e,t){let n=await n8e(r,t.map(c=>({key:c}))),i=qe(n),s=await Ke.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}}async function s8e(r,e,t,n){if(!await e.has(F2))return;let i=await e.get(F2),s=A.decode(i),o=await r.get(s),a=yt(o),c=0,l=await ih(V2(r,a,oh.recursive))+await ih(V2(r,a,oh.direct));for await(let f of V2(r,a,oh.recursive)){c++;let h={depth:1/0};f.version!==0&&(h.version=f.version),f.code!==rt&&(h.codec=f.code),await t.put(TT(f),to(h)),n(c/l*100,`Migrated recursive pin ${f}`)}for await(let f of V2(r,a,oh.direct)){c++;let h={depth:0};f.version!==0&&(h.version=f.version),f.code!==rt&&(h.codec=f.code),await t.put(TT(f),to(h)),n(c/l*100,`Migrated direct pin ${f}`)}await r.delete(s),await e.delete(F2)}async function o8e(r,e,t,n){let i=[],s=[],o=0,a=await ih(t.queryKeys({}));for await(let{key:p,value:d}of t.query({})){o++;let m=$n(d),y=A.create(m.version||0,m.codec||rt,Jt(dt.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 AT(r,oh.direct,s),await AT(r,oh.recursive,i)]},l=qe(c),f=await Ke.digest(l),h=A.createV0(f);await r.put(h,l),await e.put(F2,h.bytes)}async function WH(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 jH={version:9,description:"Migrates pins to datastore",migrate:(r,e=()=>{})=>WH(r,e,s8e),revert:(r,e=()=>{})=>WH(r,e,o8e)};u();u();var YH=new ie("/config"),K2=new ie("/version");function z2(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 a8e(r,e,t){let n=await e(r);if(n)return n;let i=z2(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 c8e(r,e,t,n){if(await t(r))return e(r);let i=z2(n);if(!i)throw mn();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(mn())}})}function h8(r){let e=r.get.bind(r),t=r.has.bind(r);return r.get=n=>c8e(n,e,t,r),r.has=n=>a8e(n,t,r),r}function RT(r){return{...r,root:h8(r.root),datastore:h8(r.datastore),pins:h8(r.pins),keys:h8(r.keys)}}async function u8e(r,e,t=()=>{}){let n=z2(e);if(!n){t(`${r} did not need an upgrade`);return}t(`Upgrading ${r}`),await JH(n,(s,o)=>[{type:"del",key:s},{type:"put",key:z(s),value:o}])}async function l8e(r,e,t=()=>{}){let n=z2(e);if(!n){t(`${r} did not need a downgrade`);return}t(`Downgrading ${r}`),await JH(n,(s,o)=>[{type:"del",key:s},{type:"put",key:K(s),value:o}])}function XH(r){return r.child?XH(r.child):r}async function QH(r,e,t){let n=Object.entries(r).map(([o,a])=>({key:o,backend:XH(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 ZH={version:10,description:"Migrates datastore-level keys to binary",migrate:(r,e=()=>{})=>QH(r,e,u8e),revert:(r,e=()=>{})=>QH(r,e,l8e)};function JH(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 dl=new ie("/local/filesroot");async function f8e(r,e=()=>{}){if(e(100,"Migrating MFS root to repo datastore"),await r.root.open(),await r.datastore.open(),await r.root.has(dl)){let t=await r.root.get(dl);await r.datastore.put(dl,t),await r.root.delete(dl)}await r.datastore.close(),await r.root.close(),e(100,"Stored MFS root in repo datastore")}async function h8e(r,e=()=>{}){if(e(100,"Migrating MFS root to repo root datastore"),await r.root.open(),await r.datastore.open(),await r.datastore.has(dl)){let t=await r.datastore.get(dl);await r.root.put(dl,t),await r.datastore.delete(dl)}await r.datastore.close(),await r.root.close(),e(100,"Stored MFS root in repo root datastore")}var eG={version:11,description:"Store mfs root in the datastore",migrate:f8e,revert:h8e};u();var OT=_(Qo(),1);u();var ah=_(Qo(),1),tG=ah.default.Reader,d8e=ah.default.Writer,p8e=ah.default.util,d8=ah.default.roots.default||(ah.default.roots.default={}),CT=d8.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=p8e.emptyArray,r.encode=function(t,n){if(n||(n=d8e.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 tG||(t=tG.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new d8.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 d8.Protocols)return t;var n=new d8.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 Cc=_(Qo(),1),Wp=Cc.default.Reader,DT=Cc.default.Writer,yr=Cc.default.util,Nn=Cc.default.roots.default||(Cc.default.roots.default={}),PT=Nn.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=yr.emptyArray,r.prototype.certifiedRecord=null,r.encode=function(t,n){if(n||(n=DT.create()),t.addrs!=null&&t.addrs.length)for(var i=0;i<t.addrs.length;++i)Nn.Addresses.Address.encode(t.addrs[i],n.uint32(10).fork()).ldelim();return t.certifiedRecord!=null&&Object.hasOwnProperty.call(t,"certifiedRecord")&&Nn.Addresses.CertifiedRecord.encode(t.certifiedRecord,n.uint32(18).fork()).ldelim(),n},r.decode=function(t,n){t instanceof Wp||(t=Wp.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Nn.Addresses;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:s.addrs&&s.addrs.length||(s.addrs=[]),s.addrs.push(Nn.Addresses.Address.decode(t,t.uint32()));break;case 2:s.certifiedRecord=Nn.Addresses.CertifiedRecord.decode(t,t.uint32());break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof Nn.Addresses)return t;var n=new Nn.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]=Nn.Addresses.Address.fromObject(t.addrs[i])}}if(t.certifiedRecord!=null){if(typeof t.certifiedRecord!="object")throw TypeError(".Addresses.certifiedRecord: object expected");n.certifiedRecord=Nn.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]=Nn.Addresses.Address.toObject(t.addrs[s],n)}return t.certifiedRecord!=null&&t.hasOwnProperty("certifiedRecord")&&(i.certifiedRecord=Nn.Addresses.CertifiedRecord.toObject(t.certifiedRecord,n)),i},r.prototype.toJSON=function(){return this.constructor.toObject(this,Cc.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=yr.newBuffer([]),e.prototype.isCertified=null;let t;return Object.defineProperty(e.prototype,"_isCertified",{get:yr.oneOfGetter(t=["isCertified"]),set:yr.oneOfSetter(t)}),e.encode=function(i,s){return s||(s=DT.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 Wp||(i=Wp.create(i));for(var o=s===void 0?i.len:i.pos+s,a=new Nn.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 Nn.Addresses.Address)return i;var s=new Nn.Addresses.Address;return i.multiaddr!=null&&(typeof i.multiaddr=="string"?yr.base64.decode(i.multiaddr,s.multiaddr=yr.newBuffer(yr.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=yr.newBuffer(o.multiaddr)))),i.multiaddr!=null&&i.hasOwnProperty("multiaddr")&&(o.multiaddr=s.bytes===String?yr.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,Cc.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=yr.Long?yr.Long.fromBits(0,0,!0):0,e.prototype.raw=yr.newBuffer([]),e.encode=function(n,i){return i||(i=DT.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 Wp||(n=Wp.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Nn.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 Nn.Addresses.CertifiedRecord)return n;var i=new Nn.Addresses.CertifiedRecord;return n.seq!=null&&(yr.Long?(i.seq=yr.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 yr.LongBits(n.seq.low>>>0,n.seq.high>>>0).toNumber(!0))),n.raw!=null&&(typeof n.raw=="string"?yr.base64.decode(n.raw,i.raw=yr.newBuffer(yr.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(yr.Long){var o=new yr.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=yr.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?yr.Long.prototype.toString.call(n.seq):i.longs===Number?new yr.LongBits(n.seq.low>>>0,n.seq.high>>>0).toNumber(!0):n.seq),n.raw!=null&&n.hasOwnProperty("raw")&&(s.raw=i.bytes===String?yr.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,Cc.default.util.toJSONOptions)},e}(),r})();u();var Dc=_(Qo(),1),jp=Dc.default.Reader,kT=Dc.default.Writer,Kt=Dc.default.util,on=Dc.default.roots.default||(Dc.default.roots.default={}),NT=on.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=Kt.emptyArray,r.prototype.protocols=Kt.emptyArray,r.prototype.metadata=Kt.emptyArray,r.prototype.pubKey=null,r.prototype.peerRecordEnvelope=null;let e;return Object.defineProperty(r.prototype,"_pubKey",{get:Kt.oneOfGetter(e=["pubKey"]),set:Kt.oneOfSetter(e)}),Object.defineProperty(r.prototype,"_peerRecordEnvelope",{get:Kt.oneOfGetter(e=["peerRecordEnvelope"]),set:Kt.oneOfSetter(e)}),r.encode=function(n,i){if(i||(i=kT.create()),n.addresses!=null&&n.addresses.length)for(var s=0;s<n.addresses.length;++s)on.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)on.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 jp||(n=jp.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new on.Peer;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.addresses&&o.addresses.length||(o.addresses=[]),o.addresses.push(on.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(on.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 on.Peer)return n;var i=new on.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]=on.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]=on.Metadata.fromObject(n.metadata[s])}}return n.pubKey!=null&&(typeof n.pubKey=="string"?Kt.base64.decode(n.pubKey,i.pubKey=Kt.newBuffer(Kt.base64.length(n.pubKey)),0):n.pubKey.length&&(i.pubKey=n.pubKey)),n.peerRecordEnvelope!=null&&(typeof n.peerRecordEnvelope=="string"?Kt.base64.decode(n.peerRecordEnvelope,i.peerRecordEnvelope=Kt.newBuffer(Kt.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]=on.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]=on.Metadata.toObject(n.metadata[o],i)}return n.pubKey!=null&&n.hasOwnProperty("pubKey")&&(s.pubKey=i.bytes===String?Kt.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?Kt.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,Dc.default.util.toJSONOptions)},r})(),Fat=on.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=Kt.newBuffer([]),r.prototype.isCertified=null;let e;return Object.defineProperty(r.prototype,"_isCertified",{get:Kt.oneOfGetter(e=["isCertified"]),set:Kt.oneOfSetter(e)}),r.encode=function(n,i){return i||(i=kT.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 jp||(n=jp.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new on.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 on.Address)return n;var i=new on.Address;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?Kt.base64.decode(n.multiaddr,i.multiaddr=Kt.newBuffer(Kt.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=Kt.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?Kt.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,Dc.default.util.toJSONOptions)},r})(),Vat=on.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=Kt.newBuffer([]),r.encode=function(t,n){return n||(n=kT.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 jp||(t=jp.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new on.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 on.Metadata)return t;var n=new on.Metadata;return t.key!=null&&(n.key=String(t.key)),t.value!=null&&(typeof t.value=="string"?Kt.base64.decode(t.value,n.value=Kt.newBuffer(Kt.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=Kt.newBuffer(i.value)))),t.key!=null&&t.hasOwnProperty("key")&&(i.key=t.key),t.value!=null&&t.hasOwnProperty("value")&&(i.value=n.bytes===String?Kt.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,Dc.default.util.toJSONOptions)},r})();u();var ch=_(Qo(),1),rG=ch.default.Reader,m8e=ch.default.Writer,gr=ch.default.util,p8=ch.default.roots.default||(ch.default.roots.default={}),nG=p8.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=gr.newBuffer([]),r.prototype.payloadType=gr.newBuffer([]),r.prototype.payload=gr.newBuffer([]),r.prototype.signature=gr.newBuffer([]),r.encode=function(t,n){return n||(n=m8e.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 rG||(t=rG.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new p8.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 p8.Envelope)return t;var n=new p8.Envelope;return t.publicKey!=null&&(typeof t.publicKey=="string"?gr.base64.decode(t.publicKey,n.publicKey=gr.newBuffer(gr.base64.length(t.publicKey)),0):t.publicKey.length&&(n.publicKey=t.publicKey)),t.payloadType!=null&&(typeof t.payloadType=="string"?gr.base64.decode(t.payloadType,n.payloadType=gr.newBuffer(gr.base64.length(t.payloadType)),0):t.payloadType.length&&(n.payloadType=t.payloadType)),t.payload!=null&&(typeof t.payload=="string"?gr.base64.decode(t.payload,n.payload=gr.newBuffer(gr.base64.length(t.payload)),0):t.payload.length&&(n.payload=t.payload)),t.signature!=null&&(typeof t.signature=="string"?gr.base64.decode(t.signature,n.signature=gr.newBuffer(gr.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=gr.newBuffer(i.publicKey))),n.bytes===String?i.payloadType="":(i.payloadType=[],n.bytes!==Array&&(i.payloadType=gr.newBuffer(i.payloadType))),n.bytes===String?i.payload="":(i.payload=[],n.bytes!==Array&&(i.payload=gr.newBuffer(i.payload))),n.bytes===String?i.signature="":(i.signature=[],n.bytes!==Array&&(i.signature=gr.newBuffer(i.signature)))),t.publicKey!=null&&t.hasOwnProperty("publicKey")&&(i.publicKey=n.bytes===String?gr.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?gr.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?gr.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?gr.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,ch.default.util.toJSONOptions)},r})();u();var pl=_(Qo(),1),m8=pl.default.Reader,iG=pl.default.Writer,Nr=pl.default.util,vo=pl.default.roots.default||(pl.default.roots.default={}),sG=vo.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=Nr.newBuffer([]),r.prototype.seq=Nr.Long?Nr.Long.fromBits(0,0,!0):0,r.prototype.addresses=Nr.emptyArray,r.encode=function(t,n){if(n||(n=iG.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)vo.PeerRecord.AddressInfo.encode(t.addresses[i],n.uint32(26).fork()).ldelim();return n},r.decode=function(t,n){t instanceof m8||(t=m8.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new vo.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(vo.PeerRecord.AddressInfo.decode(t,t.uint32()));break;default:t.skipType(o&7);break}}return s},r.fromObject=function(t){if(t instanceof vo.PeerRecord)return t;var n=new vo.PeerRecord;if(t.peerId!=null&&(typeof t.peerId=="string"?Nr.base64.decode(t.peerId,n.peerId=Nr.newBuffer(Nr.base64.length(t.peerId)),0):t.peerId.length&&(n.peerId=t.peerId)),t.seq!=null&&(Nr.Long?(n.seq=Nr.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 Nr.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]=vo.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=Nr.newBuffer(i.peerId))),Nr.Long){var s=new Nr.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?Nr.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?Nr.Long.prototype.toString.call(t.seq):n.longs===Number?new Nr.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]=vo.PeerRecord.AddressInfo.toObject(t.addresses[o],n)}return i},r.prototype.toJSON=function(){return this.constructor.toObject(this,pl.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=Nr.newBuffer([]),e.encode=function(n,i){return i||(i=iG.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),i},e.decode=function(n,i){n instanceof m8||(n=m8.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new vo.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 vo.PeerRecord.AddressInfo)return n;var i=new vo.PeerRecord.AddressInfo;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?Nr.base64.decode(n.multiaddr,i.multiaddr=Nr.newBuffer(Nr.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=Nr.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?Nr.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,pl.default.util.toJSONOptions)},e}(),r})();OT.default.util.Long=void 0;OT.default.configure();async function y8e(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]=o.split("/");if(a==="peers"&&!!["protos","addrs","metadata","keys"].includes(c)&&!!l)if(t[l]=t[l]||{addresses:[],protocols:[],metadata:[]},c==="protos"){let h=CT.decode(s);t[l].protocols=h.protocols.sort()}else if(c==="addrs"){let h=PT.decode(s);t[l].addresses=h.addrs.sort((p,d)=>ee(p.multiaddr).toString().localeCompare(ee(d.multiaddr).toString())),h.certifiedRecord&&h.certifiedRecord.raw&&(t[l].peerRecordEnvelope=h.certifiedRecord.raw)}else c==="metadata"?t[l].metadata.push({key:f,value:s}):c==="keys"&&(t[l].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=NT.encode(s).finish();await r.datastore.put(new ie(`/peers/${i}`),o)}await r.datastore.close(),e(100,"Stored each peerstore key under a single datastore key")}async function g8e(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]=o.split("/");t[a]=NT.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 ie(`/peers/protos/${i}`),CT.encode({protocols:s.protocols}).finish()),s.addresses&&s.addresses.length>0){let o=s.peerRecordEnvelope,a;if(o){let c=nG.decode(o),l=sG.decode(c.payload);a={raw:o,seq:l.seq}}await r.datastore.put(new ie(`/peers/addrs/${i}`),PT.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 ie(`/peers/metadata/${i}/${o}`),a);s.pubKey&&await r.datastore.put(new ie(`/peers/keys/${i}`),s.pubKey)}await r.datastore.close(),e(100,"Stored each peerstore key under multiple datastore keys")}var oG={version:12,description:"Store each peerstore peer under a single datastore key",migrate:y8e,revert:g8e};var uh={description:"Empty migration.",migrate:()=>{},revert:()=>{},empty:!0},y8=[Object.assign({version:1},uh),Object.assign({version:2},uh),Object.assign({version:3},uh),Object.assign({version:4},uh),Object.assign({version:5},uh),Object.assign({version:6},uh),Object.assign({version:7},uh),FH,jH,ZH,eG,oG];u();u();var aG=_(Ci(),1);var LT={};Re(LT,{InvalidValueError:()=>Xp,MissingRepoOptionsError:()=>_a,NonReversibleMigrationError:()=>Yp,NotInitializedRepoError:()=>ml,RequiredParameterError:()=>Qp});u();var Yp=class extends Error{constructor(e){super(e),this.name="NonReversibleMigrationError",this.code=Yp.code,this.message=e}};Yp.code="ERR_NON_REVERSIBLE_MIGRATION";var ml=class extends Error{constructor(e){super(e),this.name="NotInitializedRepoError",this.code=ml.code,this.message=e}};ml.code="ERR_NOT_INITIALIZED_REPO";var Qp=class extends Error{constructor(e){super(e),this.name="RequiredParameterError",this.code=Qp.code,this.message=e}};Qp.code="ERR_REQUIRED_PARAMETER";var Xp=class extends Error{constructor(e){super(e),this.name="InvalidValueError",this.code=Xp.code,this.message=e}};Xp.code="ERR_INVALID_VALUE";var _a=class extends Error{constructor(e){super(e),this.name="MissingRepoOptionsError",this.code=_a.code,this.message=e}};_a.code="ERR_MISSING_REPO_OPTIONS";var BT=(0,aG.default)("ipfs:repo:migrator:repo:init");async function cG(r){if(!r)throw new _a("Please pass repo options when trying to open a repo");let e=r.root;try{await e.open();let t=await e.has(K2),n=await e.has(YH);return!t||!n?(BT(`Version entry present: ${t}`),BT(`Config entry present: ${n}`),!1):!0}catch(t){return BT("While checking if repo is initialized error was thrown: "+t.message),!1}finally{if(e!==void 0)try{await e.close()}catch{}}}async function MT(r){if(!await cG(r))throw new ml("Repo is not initialized!");let e=r.root;await e.open();try{return parseInt(K(await e.get(K2)))}finally{await e.close()}}async function q2(r,e){if(!e)throw new _a("Please pass repo options when trying to open a repo");let t=e.root;await t.open(),await t.put(K2,z(String(r))),await t.close()}var uG=_(Ci(),1),So=(0,uG.default)("ipfs:repo:migrator");function E8e(r){return r=r||y8,!Array.isArray(r)||r.length===0?0:r[r.length-1].version}async function lG(r,e,t,n,i={}){let s=i.ignoreLock??!1,o=i.onProgress,a=i.isDryRun??!1,c=i.migrations??y8;if(!r)throw new Os.RequiredParameterError("Path argument is required!");if(!t)throw new Os.RequiredParameterError("repoOptions argument is required!");if(!n)throw new Os.RequiredParameterError("toVersion argument is required!");if(!Number.isInteger(n)||n<=0)throw new Os.InvalidValueError("Version has to be positive integer!");e=RT(e);let l=await MT(e);if(l===n){So("Nothing to migrate.");return}if(l>n)throw new Os.InvalidValueError(`Current repo's version (${l}) is higher then toVersion (${n}), you probably wanted to revert it?`);hG(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)){So(`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 So(`An exception was raised during execution of migration. Setting the repo's version to last successfully migrated version: ${d}`),await q2(d,e),new Error(`During migration to version ${h.version} exception was raised: ${p.stack||p.message||p}`)}So(`Migrating to version ${h.version} finished`)}}a||await q2(n||E8e(c),e),So("Repo successfully migrated",n!==void 0?`to version ${n}!`:"to latest version!")}finally{!a&&!s&&f&&await f.close()}}async function fG(r,e,t,n,i={}){let s=i.ignoreLock??!1,o=i.onProgress,a=i.isDryRun??!1,c=i.migrations??y8;if(!r)throw new Os.RequiredParameterError("Path argument is required!");if(!t)throw new Os.RequiredParameterError("repoOptions argument is required!");if(!n)throw new Os.RequiredParameterError("When reverting migrations, you have to specify to which version to revert!");if(!Number.isInteger(n)||n<=0)throw new Os.InvalidValueError("Version has to be positive integer!");e=RT(e);let l=await MT(e);if(l===n){So("Nothing to revert.");return}if(l<n)throw new Os.InvalidValueError(`Current repo's version (${l}) is lower then toVersion (${n}), you probably wanted to migrate it?`);hG(c,n,l,!0);let f;!a&&!s&&(f=await t.repoLock.lock(r)),So(`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)){So(`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 So(`An exception was raised during execution of migration. Setting the repo's version to last successfully reverted version: ${m}`),await q2(m,e),d.message=`During reversion to version ${p.version} exception was raised: ${d.message}`,d}So(`Reverting to version ${p.version} finished`)}}a||await q2(n,e),So(`All migrations successfully reverted to version ${n}!`)}finally{!a&&!s&&f&&await f.close()}}function hG(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 Os.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 Os.InvalidValueError(`The ipfs-repo-migrations package does not have all migration to migrate from version ${e} to ${t}`)}var Os=LT;var QG=_(mG(),1);u();var EG=_(Ci(),1);u();u();var lh=class extends Error{constructor(e){super(e),this.name="LockExistsError",this.code=lh.code}};lh.code="ERR_LOCK_EXISTS";var Wi=class extends Error{constructor(e){super(e),this.name="NotFoundError",this.code=Wi.code}};Wi.code="ERR_NOT_FOUND";var fh=class extends Error{constructor(e){super(e),this.name="InvalidRepoVersionError",this.code=fh.code}};fh.code="ERR_INVALID_REPO_VERSION";var hh="ERR_REPO_NOT_INITIALIZED",yG="ERR_REPO_ALREADY_OPEN",gG="ERR_REPO_ALREADY_CLOSED";async function w8(r,e,t){let n=await e(r);if(n)return n;let i=wG(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 E8(r,e,t,n){if(await t(r))return e(r);let i=wG(n);if(!i)throw new Wi;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 Wi)}})}function wG(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 I8e=(0,EG.default)("ipfs:repo:version"),UT=new ie("version");function bG(r){return{async exists(){return w8(UT,r.has.bind(r),r)},async get(){let e=await E8(UT,r.get.bind(r),r.has.bind(r),r);return parseInt(K(e),10)},set(e){return r.put(UT,z(String(e)))},async check(e){let t=await this.get();return I8e("comparing version: %s and %s",t,e),t===e||(t===6&&e===7||e===6&&t===7)}}}u();u();var CG=_(Ru(),1);u();var $2=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},FT=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},_G=r=>globalThis.DOMException===void 0?new FT(r):new DOMException(r),vG=r=>{let e=r.reason===void 0?_G("This operation was aborted."):r.reason;return e instanceof Error?e:_G(e)};function VT(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(vG(c)),c.addEventListener("abort",()=>{a(vG(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 $2(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 KT(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 dh=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)},Pc,H2=class{constructor(){Pc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&dh(this,Pc,"f")[this.size-1].priority>=t.priority){dh(this,Pc,"f").push(n);return}let i=KT(dh(this,Pc,"f"),n,(s,o)=>o.priority-s.priority);dh(this,Pc,"f").splice(i,0,n)}dequeue(){let e=dh(this,Pc,"f").shift();return e?.run}filter(e){return dh(this,Pc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return dh(this,Pc,"f").length}};Pc=new WeakMap;var Ar=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},be=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)},Yr,W2,j2,wl,T8,Y2,b8,xo,G2,ji,_8,Yi,Q2,gl,v8,SG,xG,RG,TG,IG,AG,S8,zT,qT,I8,x8,A8e=new $2,$T=class extends Error{},ph=class extends CG.default{constructor(e){var t,n,i,s;if(super(),Yr.add(this),W2.set(this,void 0),j2.set(this,void 0),wl.set(this,0),T8.set(this,void 0),Y2.set(this,void 0),b8.set(this,0),xo.set(this,void 0),G2.set(this,void 0),ji.set(this,void 0),_8.set(this,void 0),Yi.set(this,0),Q2.set(this,void 0),gl.set(this,void 0),v8.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:H2,...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})`);Ar(this,W2,e.carryoverConcurrencyCount,"f"),Ar(this,j2,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Ar(this,T8,e.intervalCap,"f"),Ar(this,Y2,e.interval,"f"),Ar(this,ji,new e.queueClass,"f"),Ar(this,_8,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Ar(this,v8,e.throwOnTimeout===!0,"f"),Ar(this,gl,e.autoStart===!1,"f")}get concurrency(){return be(this,Q2,"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})`);Ar(this,Q2,e,"f"),be(this,Yr,"m",I8).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Ar(this,Yi,(a=be(this,Yi,"f"),a++,a),"f"),Ar(this,wl,(c=be(this,wl,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new $T("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):VT(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?be(this,v8,"f"):t.throwOnTimeout)&&i(A8e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}be(this,Yr,"m",RG).call(this)};be(this,ji,"f").enqueue(s,t),be(this,Yr,"m",S8).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return be(this,gl,"f")?(Ar(this,gl,!1,"f"),be(this,Yr,"m",I8).call(this),this):this}pause(){Ar(this,gl,!0,"f")}clear(){Ar(this,ji,new(be(this,_8,"f")),"f")}async onEmpty(){be(this,ji,"f").size!==0&&await be(this,Yr,"m",x8).call(this,"empty")}async onSizeLessThan(e){be(this,ji,"f").size<e||await be(this,Yr,"m",x8).call(this,"next",()=>be(this,ji,"f").size<e)}async onIdle(){be(this,Yi,"f")===0&&be(this,ji,"f").size===0||await be(this,Yr,"m",x8).call(this,"idle")}get size(){return be(this,ji,"f").size}sizeBy(e){return be(this,ji,"f").filter(e).length}get pending(){return be(this,Yi,"f")}get isPaused(){return be(this,gl,"f")}};W2=new WeakMap,j2=new WeakMap,wl=new WeakMap,T8=new WeakMap,Y2=new WeakMap,b8=new WeakMap,xo=new WeakMap,G2=new WeakMap,ji=new WeakMap,_8=new WeakMap,Yi=new WeakMap,Q2=new WeakMap,gl=new WeakMap,v8=new WeakMap,Yr=new WeakSet,SG=function(){return be(this,j2,"f")||be(this,wl,"f")<be(this,T8,"f")},xG=function(){return be(this,Yi,"f")<be(this,Q2,"f")},RG=function(){var e;Ar(this,Yi,(e=be(this,Yi,"f"),e--,e),"f"),be(this,Yr,"m",S8).call(this),this.emit("next")},TG=function(){this.emit("empty"),be(this,Yi,"f")===0&&this.emit("idle")},IG=function(){be(this,Yr,"m",qT).call(this),be(this,Yr,"m",zT).call(this),Ar(this,G2,void 0,"f")},AG=function(){let e=Date.now();if(be(this,xo,"f")===void 0){let t=be(this,b8,"f")-e;if(t<0)Ar(this,wl,be(this,W2,"f")?be(this,Yi,"f"):0,"f");else return be(this,G2,"f")===void 0&&Ar(this,G2,setTimeout(()=>{be(this,Yr,"m",IG).call(this)},t),"f"),!0}return!1},S8=function(){if(be(this,ji,"f").size===0)return be(this,xo,"f")&&clearInterval(be(this,xo,"f")),Ar(this,xo,void 0,"f"),be(this,Yr,"m",TG).call(this),!1;if(!be(this,gl,"f")){let e=!be(this,Yr,"a",AG);if(be(this,Yr,"a",SG)&&be(this,Yr,"a",xG)){let t=be(this,ji,"f").dequeue();return t?(this.emit("active"),t(),e&&be(this,Yr,"m",zT).call(this),!0):!1}}return!1},zT=function(){be(this,j2,"f")||be(this,xo,"f")!==void 0||(Ar(this,xo,setInterval(()=>{be(this,Yr,"m",qT).call(this)},be(this,Y2,"f")),"f"),Ar(this,b8,Date.now()+be(this,Y2,"f"),"f"))},qT=function(){be(this,wl,"f")===0&&be(this,Yi,"f")===0&&be(this,xo,"f")&&(clearInterval(be(this,xo,"f")),Ar(this,xo,void 0,"f")),Ar(this,wl,be(this,W2,"f")?be(this,Yi,"f"):0,"f"),be(this,Yr,"m",I8).call(this)},I8=function(){for(;be(this,Yr,"m",S8).call(this););},x8=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var A8=_(V(),1);var R8e=ph.default?ph.default:ph,HT=new ie("config");function DG(r){let e=new R8e({concurrency:1}),t={async getAll(s={}){let o=await E8(HT,r.get.bind(r),r.has.bind(r),r);return JSON.parse(K(o))},async get(s,o={}){if(s==null)throw new Wi(`Key ${s} does not exist in config`);let a=await this.getAll(o),c=U2(a,s);if(c===void 0)throw new Wi(`Key ${s} does not exist in config`);return c},set(s,o,a={}){if(typeof s!="string"&&!(s instanceof String))throw(0,A8.default)(new Error("Invalid key type: "+typeof s),"ERR_INVALID_KEY");if(o===void 0||o instanceof Uint8Array)throw(0,A8.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,A8.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 w8(HT,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&&mr(l,a,c),i(l)}return i(c)}function i(s){let o=z(JSON.stringify(s,null,2));return r.put(HT,o)}}u();u();u();function X2(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 GT(r,e={}){if(!X2(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):X2(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&&X2(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 WT=new ie("datastore_spec");function PG(r){return{exists(){return r.has(WT)},async get(){let e=await r.get(WT);return JSON.parse(K(e))},async set(e){return r.put(WT,z(JSON.stringify(GT(e,{deep:!0}))))}}}u();var jT=new ie("api");function kG(r){return{async get(){let e=await r.get(jT);return e&&e.toString()},set(e){return r.put(jT,z(e.toString()))},delete(){return r.delete(jT)}}}u();var NG=_(V(),1);function OG(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=El(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}=El(e);i||await r.put(e,t,n)},async*putMany(e,t){let n=Vt({objectMode:!0});(globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.setImmediate||globalThis.setTimeout)(async()=>{try{await yn(r.putMany(async function*(){for await(let{key:s,value:o}of e)El(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}=El(e);return n?Promise.resolve(!0):r.has(e,t)},delete(e,t){let{isIdentity:n}=El(e);return n?Promise.resolve():r.delete(e,t)},deleteMany(e,t){return r.deleteMany(Dn(e,n=>!El(n).isIdentity),t)},batch(){let e=r.batch();return{put(t,n){let{isIdentity:i}=El(t);i||e.put(t,n)},delete(t){let{isIdentity:n}=El(t);n||e.delete(t)},commit:t=>e.commit(t)}}}}function El(r){let e=A.asCID(r);if(e==null)throw(0,NG.default)(new Error("Not a valid cid"),"ERR_INVALID_CID");return e.multihash.code!==rn.code?{isIdentity:!1}:{isIdentity:!0,digest:e.multihash.digest}}u();u();var LG=_(Ci(),1),BG=(0,LG.default)("ipfs:repo:lock:memory"),MG="repo.lock",Z2={};async function C8e(r){let e=r+"/"+MG;if(BG("locking %s",e),Z2[e]===!0)throw new lh(`Lock already being held for file: ${e}`);return Z2[e]=!0,{async close(){Z2[e]&&delete Z2[e]}}}async function D8e(r){let e=r+"/"+MG;return BG(`checking lock: ${e}`),Boolean(Z2[e])}var R8={lock:C8e,locked:D8e};var UG={autoMigrate:!0,onMigrationProgress:()=>{},repoOwner:!0,repoLock:R8};u();var YT={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 KG=_(V(),1),zG=_(Ci(),1);u();var FG=_(V(),1);function J2(r){let e=A.asCID(r);if(e==null)throw(0,FG.default)(new Error("Not a valid cid"),"ERR_INVALID_CID");let t=dt.encode(e.multihash.bytes);return new ie("/"+t.slice(1).toUpperCase(),!1)}function QT(r){return Jt(dt.decode(`b${r.toString().toLowerCase().substring(1)}`))}u();var VG=_(Ci(),1);var P8e=(0,VG.default)("ipfs:repo:utils:walk-dag");async function*Zp(r,e,t,n){try{let i=await e.get(r,n),s=await t(r.code),o=Lp({bytes:i,cid:r,codec:s});for(let[,a]of o.links())yield a,yield*Zp(a,e,t,n)}catch(i){throw P8e("Could not walk DAG for CID",r.toString(),i),i}}u();var ey=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 k8e=2048;function N8e(r){let e=`Invalid type '${r}', must be one of {direct, indirect, recursive, all}`;return(0,KG.default)(new Error(e),"ERR_INVALID_PIN_TYPE")}var C8=class{constructor({pinstore:e,blockstore:t,loadCodec:n}){this.pinstore=e,this.blockstore=t,this.loadCodec=n,this.log=(0,zG.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!==rt&&(n.codec=e.code),t.metadata&&(n.metadata=t.metadata),this.pinstore.put(J2(e),to(n))}unpin(e,t){return this.pinstore.delete(J2(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!==rt&&(n.codec=e.code),t.metadata&&(n.metadata=t.metadata),await this.pinstore.put(J2(e),to(n))}async*directKeys(e){for await(let t of this.pinstore.query({filters:[n=>$n(n.value).depth===0]})){let n=$n(t.value),i=n.version||0,s=n.codec!=null?n.codec:rt,o=QT(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=>$n(n.value).depth===1/0]})){let n=$n(t.value),i=n.version||0,s=n.codec!=null?n.codec:rt,o=QT(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 Zp(t,this.blockstore,this.loadCodec,e)){let i=[pt.recursive];(await this.isPinnedWithType(n,i)).pinned||(yield n)}}async isPinnedWithType(e,t,n){Array.isArray(t)||(t=[t]);let i=t.includes(pt.all),s=t.includes(pt.direct),o=t.includes(pt.recursive),a=t.includes(pt.indirect);if(o||s||i){let f=await kn(this.pinstore.query({prefix:J2(e).toString(),filters:[h=>{if(i)return!0;let p=$n(h.value);return t.includes(p.depth===0?pt.direct:pt.recursive)}],limit:1}));if(f){let h=$n(f.value);return{cid:e,pinned:!0,reason:h.depth===0?pt.direct:pt.recursive,metadata:h.metadata}}}let c=this;async function*l(f,h){for await(let{cid:p}of h)for await(let d of Zp(p,c.blockstore,c.loadCodec))if(d.equals(f)){yield p;return}}if(i||a){let f=await kn(l(e,this.recursiveKeys()));if(f)return{cid:e,pinned:!0,reason:pt.indirect,parent:f}}return{cid:e,pinned:!1}}async fetchCompleteDag(e,t={}){let n=new ey({maxSize:t.cidCacheMaxSize??k8e}),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=Lp({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(pt).includes(e))throw N8e(e);return!0}};u();var $G=_(V(),1);function HG(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 qG(t,r),e.delete(t,n)},deleteMany(t,n){return e.deleteMany(dr(t,async i=>(await qG(i,r),i)),n)},batch(){return e.batch()}}}async function qG(r,e){let{pinned:t,reason:n}=await e.isPinnedWithType(r,pt.all);if(t)throw(0,$G.default)(new Error(`pinned: ${n}`),"ERR_BLOCK_PINNED")}u();var GG=_(Ci(),1);u();async function*To(...r){let e=Vt({objectMode:!0});Promise.resolve().then(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)}}),yield*e}var ty=(0,GG.default)("ipfs:repo:gc"),O8e=mn().code,L8e=256,B8e=new ie("/local/filesroot");function WG({gcLock:r,pins:e,blockstore:t,root:n,loadCodec:i}){async function*s(){let o=Date.now();ty("Creating set of marked blocks");let a=await r.writeLock();try{let c=await M8e({pins:e,blockstore:t,root:n,loadCodec:i}),l=t.queryKeys({});yield*U8e({blockstore:t},c,l),ty(`Complete (${Date.now()-o}ms)`)}finally{a()}}return s}async function M8e({pins:r,blockstore:e,loadCodec:t,root:n}){let i=async function*(){let a;try{a=await n.get(B8e)}catch(l){if(l.code===O8e){ty("No blocks in MFS");return}throw l}let c=A.decode(a);yield c,yield*Zp(c,e,t)}(),s=To(dr(r.recursiveKeys(),({cid:a})=>a),r.indirectKeys(),dr(r.directKeys(),({cid:a})=>a),i),o=new Set;for await(let a of To(s,i))o.add(dt.encode(a.multihash.bytes));return o}async function*U8e({blockstore:r},e,t){let n=0,i=0;yield*de(Bf(dr(t,async o=>async function(){n++;try{let c=dt.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 ty(l,c),{err:new Error(l+`: ${c.message}`)}}}),L8e),o=>Dn(o,Boolean)),ty(`Marked set has ${e.size} unique blocks. Blockstore has ${n} blocks. Deleted ${i} blocks.`)}var xi=(0,YG.default)("ipfs:repo"),F8e=Number.MAX_SAFE_INTEGER,V8e="repoAutoMigrate",XT=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=ze(UG,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 C8({pinstore:o,blockstore:s,loadCodec:t});let a=HG(this.pins,s);this.blocks=OG(a),this.version=bG(this.root),this.config=DG(this.root),this.spec=PG(this.root),this.apiAddr=kG(this.root),this.gcLock=eh({name:e,singleProcess:this.options.repoOwner!==!1}),this.gc=WG({gcLock:this.gcLock,pins:this.pins,blockstore:this.blocks,root:this.root,loadCodec:t})}async init(e){xi("initializing at: %s",this.path),await this._openRoot(),await this.config.replace(K8e(e)),await this.spec.set(z8e(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,mh.default)(new Error("repo is already open"),yG);xi("opening at: %s",this.path);try{if(await this._openRoot(),await this._checkInitialized(),this._lockfile=await this._openLock(),xi("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 fh("Incompatible repo versions. Automatic migrations disabled. Please migrate the repo manually.");xi("creating datastore"),await this.datastore.open(),xi("creating blocks"),await this.blocks.open(),xi("creating keystore"),await this.keys.open(),xi("creating pins"),await this.pins.pinstore.open(),this.closed=!1,xi("all opened")}catch(e){if(this._lockfile)try{await this._closeLock(),this._lockfile=null}catch(t){xi("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,mh.default)(new Error("Locks must have a close method"),"ERR_NO_CLOSE_FUNCTION");return e}_closeLock(){return this._lockfile&&this._lockfile.close()}async _checkInitialized(){xi("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,mh.default)(new Error("repo is not initialized yet"),hh,{path:this.path}):t}if(!e)throw(0,mh.default)(new Error("repo is not initialized yet"),hh,{path:this.path})}async close(){if(this.closed)throw(0,mh.default)(new Error("repo is already closed"),gG);xi("closing at: %s",this.path);try{await this.apiAddr.delete()}catch(e){if(e.code!==hh&&!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())),xi("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(),jG(this.datastore),jG(this.keys)]),o=t.size+i+s;return{repoPath:this.path,storageMax:e,version:n,numObjects:t.count,repoSize:o}}throw(0,mh.default)(new Error("repo is not initialized yet"),hh,{path:this.path})}async _isAutoMigrationEnabled(){if(this.options.autoMigrate!==void 0)return this.options.autoMigrate;let e;try{e=await this.config.get(V8e)}catch(t){if(t.code===Wi.code)e=!0;else throw t}return e}async _migrate(e,t){return await this.version.get()>e?(xi(`reverting to version ${e}`),fG(this.path,t,this.options,e,{ignoreLock:!0,onProgress:this.options.onMigrationProgress})):(xi(`migrating to version ${e}`),lG(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,QG.default)(e))}catch{return BigInt(F8e)}}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 jG(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 XG(r,e,t,n){return new XT(r,e,t,n)}function K8e(r){return r.Datastore=Object.assign({},YT,U2(r,"datastore")),r}function z8e(r){let e={...YT.Spec,...U2(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 vy=_(JG(),1),Ej=_(tW(),1),qI=_(Ep(),1),$I=_(sW(),1),bj=_(wj(),1),Cl=class extends _i{constructor(e,t={}){super(),this.db=typeof e=="string"?new bj.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 Bi.dbOpenFailedError(e)}}async put(e,t){try{await this.db.put(e.toString(),t)}catch(n){throw Bi.dbWriteFailedError(n)}}async get(e){let t;try{t=await this.db.get(e.toString())}catch(n){throw n.notFound?Bi.notFoundError(n):Bi.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 Bi.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,vy.default)(s,o),t)),Array.isArray(e.orders)&&(t=e.orders.reduce((s,o)=>(0,$I.default)(s,o),t));let{offset:n,limit:i}=e;if(n){let s=0;t=(0,vy.default)(t,()=>s++>=n)}return i&&(t=(0,qI.default)(t,i)),t}queryKeys(e){let t=(0,Ej.default)(this._query({values:!1,prefix:e.prefix}),({key:s})=>s);Array.isArray(e.filters)&&(t=e.filters.reduce((s,o)=>(0,vy.default)(s,o),t)),Array.isArray(e.orders)&&(t=e.orders.reduce((s,o)=>(0,$I.default)(s,o),t));let{offset:n,limit:i}=e;if(n){let s=0;t=(0,vy.default)(t,()=>s++>=n)}return i&&(t=(0,qI.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 J5e(n);if(n.next!=null&&n.end!=null)return eEe(n);throw new Error("Level returned incompatible iterator")}};async function*J5e(r){for await(let[e,t]of r)yield{key:new ie(e,!1),value:t};await r.close()}function eEe(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 ie(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 Cj=_(V(),1);u();var HI=_(vj(),1),Dh=_(xj(),1),GI=_(Ep(),1),Rj=_(Ij(),1),Aj=(r,e)=>async function*(){yield*(await(0,Rj.default)(r)).sort(e)}(),Ta=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,HI.default)(this.putMany(e,n)),e=[],await(0,HI.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,Dh.default)(n,i=>i.key.toString().startsWith(e.prefix||""))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Dh.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Aj(i,s),n)),e.offset!=null){let i=0;n=(0,Dh.default)(n,()=>i++>=(e.offset||0))}return e.limit!=null&&(n=(0,GI.default)(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(e.prefix!=null&&(n=(0,Dh.default)(n,i=>i.toString().startsWith(e.prefix||""))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Dh.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Aj(i,s),n)),e.offset!=null){let i=0;n=(0,Dh.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,GI.default)(n,e.limit)),n}};function l0(r){let e=A.asCID(r);if(!e)throw(0,Cj.default)(new Error("Not a valid cid"),"ERR_INVALID_CID");return new ie("/"+dt.encode(e.multihash.bytes).slice(1).toUpperCase(),!1)}function Dl(r){return A.createV1(xn,Jt(dt.decode("b"+r.toString().slice(1).toLowerCase())))}function WI(r){let e=r.substring(0,1);if(e==="/")return WI(r.substring(1));let t;e.toLowerCase()==="b"?t=s=>dt.decode(s.toLowerCase()).subarray(2):e.toLowerCase()==="c"?t=s=>__.decode(s.toLowerCase()).subarray(2):e==="z"?t=s=>Ce.decode(s).subarray(2):e==="Q"?t=s=>Ce.decode("z"+s):t=s=>dt.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=`/${dt.encode(n).slice(1,-1).toUpperCase()||"C"}`),i}function iEe(r){return{...r,prefix:r.prefix?WI(r.prefix):void 0,filters:r.filters?r.filters.map(e=>t=>e({key:Dl(t.key),value:t.value})):void 0,orders:r.orders?r.orders.map(e=>(t,n)=>e({key:Dl(t.key),value:t.value},{key:Dl(n.key),value:n.value})):void 0}}function sEe(r){return{...r,prefix:r.prefix?WI(r.prefix):void 0,filters:r.filters?r.filters.map(e=>t=>e(Dl(t))):void 0,orders:r.orders?r.orders.map(e=>(t,n)=>e(Dl(t),Dl(n))):void 0}}var n5=class extends Ta{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(iEe(e),t))yield{key:Dl(n),value:i}}async*queryKeys(e,t){for await(let n of this.child.queryKeys(sEe(e),t))yield Dl(n)}async get(e,t){return this.child.get(l0(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(l0(e),t,n)}async*putMany(e,t){let n=Vt({objectMode:!0});(globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.setImmediate||globalThis.setTimeout)(async()=>{try{let s=this.child;await yn(this.child.putMany(async function*(){for await(let o of e){let a=l0(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(l0(e),t)}delete(e,t){return this.child.delete(l0(e),t)}deleteMany(e,t){let n=Vt({objectMode:!0});return yn(this.child.deleteMany(async function*(){for await(let i of e)yield l0(i),n.push(i);n.end()}(),t)).catch(i=>{n.end(i)}),n}};function Dj(r,e,t){let n=t.path||"ipfs";return XG(n,i=>e.getCodec(i),{root:new Cl(n,{prefix:"",version:2}),blocks:new n5(new Cl(`${n}/blocks`,{prefix:"",version:2})),datastore:new Cl(`${n}/datastore`,{prefix:"",version:2}),keys:new Cl(`${n}/keys`,{prefix:"",version:2}),pins:new Cl(`${n}/pins`,{prefix:"",version:2})},{autoMigrate:t.autoMigrate,onMigrationProgress:t.onMigrationProgress||r,repoLock:R8})}u();var Mt=_(A6(),1);var Xae=_(V(),1);u();u();u();u();var Nj=_(V(),1);u();var Pj={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};u();var Sy;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.publicKey!=null&&t.publicKey.byteLength>0)&&(n.uint32(10),n.bytes(t.publicKey)),(i.writeDefaults===!0||t.payloadType!=null&&t.payloadType.byteLength>0)&&(n.uint32(18),n.bytes(t.payloadType)),(i.writeDefaults===!0||t.payload!=null&&t.payload.byteLength>0)&&(n.uint32(26),n.bytes(t.payload)),(i.writeDefaults===!0||t.signature!=null&&t.signature.byteLength>0)&&(n.uint32(42),n.bytes(t.signature)),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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(Sy||(Sy={}));u();u();u();function i5(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 kj=4294967296,Ji=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 Ji(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 Ji(t,n)}toBytes(e,t=0){let n=i5(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 Ji;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>kj&&(i=0,++n>kj&&(n=0))),new Ji(n,i)}static fromNumber(e){if(e===0)return new Ji;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 Ji(i,n)}static fromBytes(e,t=0){let n=i5(e),i=new Ji,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")}};var oEe=Math.pow(2,7),aEe=Math.pow(2,14),cEe=Math.pow(2,21),uEe=Math.pow(2,28),lEe=Math.pow(2,35),fEe=Math.pow(2,42),hEe=Math.pow(2,49),dEe=Math.pow(2,56),pEe=Math.pow(2,63),Co={encodingLength(r){return r<oEe?1:r<aEe?2:r<cEe?3:r<uEe?4:r<lEe?5:r<fEe?6:r<hEe?7:r<dEe?8:r<pEe?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=so(Co.encodingLength(r))),Ji.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return Ji.fromBytes(r,e).toNumber(!0)}};var mEe,Qr=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=Sy.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return Be(this.marshal(),e.marshal())}async validate(e){let t=Oj(e,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return await Ei(this.peerId.publicKey).verify(t.subarray(),this.signature)}};mEe=Qr;Qr.createFromProtobuf=async r=>{let e=Sy.decode(r),t=await sn(e.publicKey);return new Qr({peerId:t,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};Qr.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=Oj(t,n,i),a=await(await Cn(e.privateKey)).sign(s.subarray());return new Qr({peerId:e,payloadType:n,payload:i,signature:a})};Qr.openAndCertify=async(r,e)=>{let t=await Qr.createFromProtobuf(r);if(!await t.validate(e))throw(0,Nj.default)(new Error("envelope signature is not valid for the given domain"),Pj.ERR_SIGNATURE_NOT_VALID);return t};var Oj=(r,e,t)=>{let n=z(r),i=Co.encode(n.byteLength),s=Co.encode(e.length),o=Co.encode(t.length);return new et(i,n,s,e,o,t)};u();u();function Lj(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 xy;(function(r){let e;(function(n){let i;n.codec=()=>(i==null&&(i=ct((s,o,a={})=>{a.lengthDelimited!==!1&&o.fork(),(a.writeDefaults===!0||s.multiaddr!=null&&s.multiaddr.byteLength>0)&&(o.uint32(10),o.bytes(s.multiaddr)),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}}return a})),i),n.encode=s=>at(s,n.codec()),n.decode=s=>ot(s,n.codec())})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=ct((n,i,s={})=>{if(s.lengthDelimited!==!1&&i.fork(),(s.writeDefaults===!0||n.peerId!=null&&n.peerId.byteLength>0)&&(i.uint32(10),i.bytes(n.peerId)),(s.writeDefaults===!0||n.seq!==0n)&&(i.uint32(16),i.uint64(n.seq)),n.addresses!=null)for(let o of n.addresses)i.uint32(26),r.AddressInfo.codec().encode(o,i,{writeDefaults:!0});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}}return s})),t),r.encode=n=>at(n,r.codec()),r.decode=n=>ot(n,r.codec())})(xy||(xy={}));u();var Bj="libp2p-peer-record",Mj=Uint8Array.from([3,1]);var an=class{constructor(e){this.domain=an.DOMAIN,this.codec=an.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=xy.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this.marshaled}equals(e){return!(!(e instanceof an)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!Lj(this.multiaddrs,e.multiaddrs))}};an.createFromProtobuf=r=>{let e=xy.decode(r),t=_r(e.peerId),n=(e.addresses??[]).map(s=>ee(s.multiaddr)),i=e.seq;return new an({peerId:t,multiaddrs:n,seqNumber:i})};an.DOMAIN=Bj;an.CODEC=Mj;u();u();var s5=Symbol.for("@libp2p/topology");function Uj(r){return r!=null&&Boolean(r[s5])}var Fj=()=>{},jI=class{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??Fj,this.onDisconnect=e.onDisconnect??Fj}get[Symbol.toStringTag](){return s5.toString()}get[s5](){return!0}async setRegistrar(e){this.registrar=e}disconnect(e){this.onDisconnect(e)}};function f0(r){return new jI(r)}u();var Ph=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)},Fc,Fe=class extends EventTarget{constructor(){super(...arguments),Fc.set(this,new Map)}listenerCount(e){let t=Ph(this,Fc,"f").get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=Ph(this,Fc,"f").get(e);i==null&&(i=[],Ph(this,Fc,"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=Ph(this,Fc,"f").get(e);i!=null&&(i=i.filter(({callback:s})=>s!==t),Ph(this,Fc,"f").set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=Ph(this,Fc,"f").get(e.type);return n==null||(n=n.filter(({once:i})=>!i),Ph(this,Fc,"f").set(e.type,n)),t}};Fc=new WeakMap;var YI=class extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}},J=globalThis.CustomEvent??YI;u();var o5=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 EY=_(wY(),1),{RPC:h0}=EY.default;u();var cA="/floodsub/1.0.0",uA="/meshsub/1.0.0",lA="/meshsub/1.1.0";var bY="ERR_TOPIC_VALIDATOR_REJECT",_Y="ERR_TOPIC_VALIDATOR_IGNORE";u();u();function Ra(r=[],e){return{subscriptions:[],messages:r,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}u();function Ca(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();u();u();u();var mA={};Re(mA,{identity:()=>CEe});u();u();u();function xEe(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,E=m.length;w!==E&&m[w]===0;)w++,y++;for(var v=(E-w)*f+1>>>0,x=new Uint8Array(v);w!==E;){for(var I=m[w],T=0,S=v-1;(I!==0||T<g)&&S!==-1;S--,T++)I+=256*x[S]>>>0,x[S]=I%a>>>0,I=I/a>>>0;if(I!==0)throw new Error("Non-zero carry");g=T,w++}for(var C=v-g;C!==v&&x[C]===0;)C++;for(var B=c.repeat(y);C<v;++C)B+=r.charAt(x[C]);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 E=(m.length-y)*l+1>>>0,v=new Uint8Array(E);m[y];){var x=t[m.charCodeAt(y)];if(x===255)return;for(var I=0,T=E-1;(x!==0||I<w)&&T!==-1;T--,I++)x+=a*v[T]>>>0,v[T]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");w=I,y++}if(m[y]!==" "){for(var S=E-w;S!==E&&v[S]===0;)S++;for(var C=new Uint8Array(g+(E-S)),B=g;S!==E;)C[B++]=v[S++];return C}}}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 TEe=xEe,IEe=TEe,vY=IEe;u();var Ydt=new Uint8Array(0);var SY=(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},Vc=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var xY=r=>new TextEncoder().encode(r),TY=r=>new TextDecoder().decode(r);var fA=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")}},hA=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 AY(this,e)}},dA=class{constructor(e){this.decoders=e}or(e){return AY(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`)}},AY=(r,e)=>new dA({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),pA=class{constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new fA(e,t,n),this.decoder=new hA(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},d0=({name:r,prefix:e,encode:t,decode:n})=>new pA(r,e,t,n),Ol=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:i}=vY(t,e);return d0({prefix:r,name:e,encode:n,decode:s=>Vc(i(s))})},AEe=(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},REe=(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},Or=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>d0({prefix:e,name:r,encode(i){return REe(i,n,t)},decode(i){return AEe(i,n,t,r)}});var CEe=d0({prefix:"\0",name:"identity",encode:r=>TY(r),decode:r=>xY(r)});var yA={};Re(yA,{base2:()=>DEe});u();var DEe=Or({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var gA={};Re(gA,{base8:()=>PEe});u();var PEe=Or({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var wA={};Re(wA,{base10:()=>kEe});u();var kEe=Ol({prefix:"9",name:"base10",alphabet:"0123456789"});var EA={};Re(EA,{base16:()=>NEe,base16upper:()=>OEe});u();var NEe=Or({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),OEe=Or({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bA={};Re(bA,{base32:()=>p0,base32hex:()=>UEe,base32hexpad:()=>VEe,base32hexpadupper:()=>KEe,base32hexupper:()=>FEe,base32pad:()=>BEe,base32padupper:()=>MEe,base32upper:()=>LEe,base32z:()=>zEe});u();var p0=Or({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),LEe=Or({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),BEe=Or({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),MEe=Or({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),UEe=Or({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),FEe=Or({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),VEe=Or({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),KEe=Or({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zEe=Or({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _A={};Re(_A,{base36:()=>qEe,base36upper:()=>$Ee});u();var qEe=Ol({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$Ee=Ol({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var vA={};Re(vA,{base58btc:()=>Da,base58flickr:()=>HEe});u();var Da=Ol({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),HEe=Ol({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var SA={};Re(SA,{base64:()=>GEe,base64pad:()=>WEe,base64url:()=>jEe,base64urlpad:()=>YEe});u();var GEe=Or({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),WEe=Or({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),jEe=Or({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),YEe=Or({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xA={};Re(xA,{base256emoji:()=>ebe});u();var RY=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}"),QEe=RY.reduce((r,e,t)=>(r[t]=e,r),[]),XEe=RY.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ZEe(r){return r.reduce((e,t)=>(e+=QEe[t],e),"")}function JEe(r){let e=[];for(let t of r){let n=XEe[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ebe=d0({prefix:"\u{1F680}",name:"base256emoji",encode:ZEe,decode:JEe});var CA={};Re(CA,{sha256:()=>RA,sha512:()=>Ebe});u();u();u();u();u();var tbe=PY,CY=128,rbe=127,nbe=~rbe,ibe=Math.pow(2,31);function PY(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ibe;)e[t++]=r&255|CY,r/=128;for(;r&nbe;)e[t++]=r&255|CY,r>>>=7;return e[t]=r|0,PY.bytes=t-n+1,e}var sbe=TA,obe=128,DY=127;function TA(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw TA.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&DY)<<i:(o&DY)*Math.pow(2,i),i+=7}while(o>=obe);return TA.bytes=s-n,t}var abe=Math.pow(2,7),cbe=Math.pow(2,14),ube=Math.pow(2,21),lbe=Math.pow(2,28),fbe=Math.pow(2,35),hbe=Math.pow(2,42),dbe=Math.pow(2,49),pbe=Math.pow(2,56),mbe=Math.pow(2,63),ybe=function(r){return r<abe?1:r<cbe?2:r<ube?3:r<lbe?4:r<fbe?5:r<hbe?6:r<dbe?7:r<pbe?8:r<mbe?9:10},gbe={encode:tbe,decode:sbe,encodingLength:ybe},wbe=gbe,Cy=wbe;var Dy=(r,e=0)=>[Cy.decode(r,e),Cy.decode.bytes],m0=(r,e,t=0)=>(Cy.encode(r,e,t),e),y0=r=>Cy.encodingLength(r);var Oh=(r,e)=>{let t=e.byteLength,n=y0(r),i=n+y0(t),s=new Uint8Array(i+t);return m0(r,s,0),m0(t,s,n),s.set(e,i),new g0(r,t,e,s)},kY=r=>{let e=Vc(r),[t,n]=Dy(e),[i,s]=Dy(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new g0(t,i,o,e)},NY=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&SY(r.bytes,e.bytes),g0=class{constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var AA=({name:r,code:e,encode:t})=>new IA(r,e,t),IA=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?Oh(this.code,t):t.then(n=>Oh(this.code,n))}else throw Error("Unknown type, must be binary type")}};var LY=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),RA=AA({name:"sha2-256",code:18,encode:LY("SHA-256")}),Ebe=AA({name:"sha2-512",code:19,encode:LY("SHA-512")});var DA={};Re(DA,{identity:()=>vbe});u();var BY=0,bbe="identity",MY=Vc,_be=r=>Oh(BY,MY(r)),vbe={code:BY,name:bbe,encode:MY,digest:_be};u();u();var Lpt=new TextEncoder,Bpt=new TextDecoder;u();u();var wn=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:f5,byteLength:f5,code:l5,version:l5,multihash:l5,bytes:l5,_baseCache:f5,asCID:f5})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==ky)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Rbe)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return wn.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Oh(e,t);return wn.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&&NY(this.multihash,e.multihash)}toString(e){let{bytes:t,version:n,_baseCache:i}=this;switch(n){case 0:return Ibe(t,i,e||Da.encoder);default:return Abe(t,i,e||p0.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 Dbe(/^0\.0/,Pbe),!!(e&&(e[FY]||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 wn)return e;if(e!=null&&e.asCID===e){let{version:t,code:n,multihash:i,bytes:s}=e;return new wn(t,n,i,s||UY(t,n,i.bytes))}else if(e!=null&&e[FY]===!0){let{version:t,multihash:n,code:i}=e,s=kY(n);return wn.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!==ky)throw new Error(`Version 0 CID must use dag-pb (code: ${ky}) block encoding`);return new wn(e,t,n,n.bytes)}case 1:{let i=UY(e,t,n.bytes);return new wn(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return wn.create(0,ky,e)}static createV1(e,t){return wn.create(1,e,t)}static decode(e){let[t,n]=wn.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=wn.inspectBytes(e),n=t.size-t.multihashSize,i=Vc(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 g0(t.multihashCode,t.digestSize,s,i);return[t.version===0?wn.createV0(o):wn.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[h,p]=Dy(e.subarray(t));return t+=p,h},i=n(),s=ky;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]=Tbe(e,t),s=wn.decode(i);return s._baseCache.set(n,e),s}},Tbe=(r,e)=>{switch(r[0]){case"Q":{let t=e||Da;return[Da.prefix,t.decode(`${Da.prefix}${r}`)]}case Da.prefix:{let t=e||Da;return[Da.prefix,t.decode(r)]}case p0.prefix:{let t=e||p0;return[p0.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)]}}},Ibe=(r,e,t)=>{let{prefix:n}=t;if(n!==Da.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},Abe=(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},ky=112,Rbe=18,UY=(r,e,t)=>{let n=y0(r),i=n+y0(e),s=new Uint8Array(i+t.byteLength);return m0(r,s,0),m0(e,s,n),s.set(t,i),s},FY=Symbol.for("@ipld/js-cid/CID"),l5={writable:!1,configurable:!1,enumerable:!0},f5={writable:!1,enumerable:!1,configurable:!1},Cbe="0.0.0-dev",Dbe=(r,e)=>{if(r.test(Cbe))console.warn(e);else throw new Error(e)},Pbe=`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)
}
`;var PA={...mA,...yA,...gA,...wA,...EA,...bA,..._A,...vA,...SA,...xA},Wpt={...CA,...DA};u();u();function w0(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function h5(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?w0(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function KY(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var VY=KY("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),kA=KY("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=h5(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),kbe={utf8:VY,"utf-8":VY,hex:PA.base16,latin1:kA,ascii:kA,binary:kA,...PA},d5=kbe;function Ny(r,e="utf8"){let t=d5[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)}function zY(r){return Ny(r,"base64")}u();u();var Lh="StrictSign",E0="StrictNoSign";u();var qY;(function(r){r.StrictSign="StrictSign",r.StrictNoSign="StrictNoSign"})(qY||(qY={}));var Ll;(function(r){r[r.Signing=0]="Signing",r[r.Anonymous=1]="Anonymous"})(Ll||(Ll={}));var Pa;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Pa||(Pa={}));var ai;(function(r){r.Error="error",r.Ignore="ignore",r.Reject="reject",r.Blacklisted="blacklisted"})(ai||(ai={}));var Qn;(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"})(Qn||(Qn={}));var Us;(function(r){r.duplicate="duplicate",r.invalid="invalid",r.valid="valid"})(Us||(Us={}));function NA(r){switch(r){case Pa.Ignore:return ai.Ignore;case Pa.Reject:return ai.Reject}}async function OA(r,e){switch(r){case Lh:{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 Cn(e.privateKey);return{type:Ll.Signing,author:e,key:e.publicKey,privateKey:t}}case E0:return{type:Ll.Anonymous};default:throw new Error(`Unknown signature policy "${r}"`)}}u();u();u();var Wt="ERR_INVALID_PEER_SCORE_PARAMS";var jt=_(V(),1),Nbe={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},Obe={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 $Y(r={}){return{...Nbe,...r,topics:r.topics?Object.entries(r.topics).reduce((e,[t,n])=>(e[t]=Lbe(n),e),{}):{}}}function Lbe(r={}){return{...Obe,...r}}function HY(r){for(let[e,t]of Object.entries(r.topics))try{Bbe(t)}catch(n){throw(0,jt.default)(new Error(`invalid score parameters for topic ${e}: ${n.message}`),Wt)}if(r.topicScoreCap<0)throw(0,jt.default)(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),Wt);if(r.appSpecificScore===null||r.appSpecificScore===void 0)throw(0,jt.default)(new Error("missing application specific score function"),Wt);if(r.IPColocationFactorWeight>0)throw(0,jt.default)(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Wt);if(r.IPColocationFactorWeight!==0&&r.IPColocationFactorThreshold<1)throw(0,jt.default)(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Wt);if(r.behaviourPenaltyWeight>0)throw(0,jt.default)(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Wt);if(r.behaviourPenaltyWeight!==0&&(r.behaviourPenaltyDecay<=0||r.behaviourPenaltyDecay>=1))throw(0,jt.default)(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Wt);if(r.decayInterval<1e3)throw(0,jt.default)(new Error("invalid DecayInterval; must be at least 1s"),Wt);if(r.decayToZero<=0||r.decayToZero>=1)throw(0,jt.default)(new Error("invalid DecayToZero; must be between 0 and 1"),Wt)}function Bbe(r){if(r.topicWeight<0)throw(0,jt.default)(new Error("invalid topic weight; must be >= 0"),Wt);if(r.timeInMeshQuantum===0)throw(0,jt.default)(new Error("invalid TimeInMeshQuantum; must be non zero"),Wt);if(r.timeInMeshWeight<0)throw(0,jt.default)(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Wt);if(r.timeInMeshWeight!==0&&r.timeInMeshQuantum<=0)throw(0,jt.default)(new Error("invalid TimeInMeshQuantum; must be positive"),Wt);if(r.timeInMeshWeight!==0&&r.timeInMeshCap<=0)throw(0,jt.default)(new Error("invalid TimeInMeshCap; must be positive"),Wt);if(r.firstMessageDeliveriesWeight<0)throw(0,jt.default)(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Wt);if(r.firstMessageDeliveriesWeight!==0&&(r.firstMessageDeliveriesDecay<=0||r.firstMessageDeliveriesDecay>=1))throw(0,jt.default)(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Wt);if(r.firstMessageDeliveriesWeight!==0&&r.firstMessageDeliveriesCap<=0)throw(0,jt.default)(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Wt);if(r.meshMessageDeliveriesWeight>0)throw(0,jt.default)(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Wt);if(r.meshMessageDeliveriesWeight!==0&&(r.meshMessageDeliveriesDecay<=0||r.meshMessageDeliveriesDecay>=1))throw(0,jt.default)(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Wt);if(r.meshMessageDeliveriesWeight!==0&&r.meshMessageDeliveriesCap<=0)throw(0,jt.default)(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Wt);if(r.meshMessageDeliveriesWeight!==0&&r.meshMessageDeliveriesThreshold<=0)throw(0,jt.default)(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Wt);if(r.meshMessageDeliveriesWindow<0)throw(0,jt.default)(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Wt);if(r.meshMessageDeliveriesWeight!==0&&r.meshMessageDeliveriesActivation<1e3)throw(0,jt.default)(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Wt);if(r.meshFailurePenaltyWeight>0)throw(0,jt.default)(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Wt);if(r.meshFailurePenaltyWeight!==0&&(r.meshFailurePenaltyDecay<=0||r.meshFailurePenaltyDecay>=1))throw(0,jt.default)(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Wt);if(r.invalidMessageDeliveriesWeight>0)throw(0,jt.default)(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Wt);if(r.invalidMessageDeliveriesDecay<=0||r.invalidMessageDeliveriesDecay>=1)throw(0,jt.default)(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Wt)}u();var Mbe=_(V(),1),Ube={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function GY(r={}){return{...Ube,...r}}u();u();function WY(r,e,t,n){let i=0;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,m=d*d;l+=m*c.meshMessageDeliveriesWeight}let h=a.meshFailurePenalty;l+=h*c.meshFailurePenaltyWeight;let p=a.invalidMessageDeliveries*a.invalidMessageDeliveries;l+=p*c.invalidMessageDeliveriesWeight,i+=l*c.topicWeight}),t.topicScoreCap>0&&i>t.topicScoreCap&&(i=t.topicScoreCap);let s=t.appSpecificScore(r);if(i+=s*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,f=l*l;i+=f*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){let o=e.behaviourPenalty-t.behaviourPenaltyThreshold,a=o*o;i+=a*t.behaviourPenaltyWeight}return i}u();var QY=_(YY(),1),ci;(function(r){r[r.unknown=0]="unknown",r[r.valid=1]="valid",r[r.invalid=2]="invalid",r[r.ignored=3]="ignored"})(ci||(ci={}));var p5=class{constructor(){this.records=new Map,this.queue=new QY.default}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:ci.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 li=_(V(),1);u();function Xn(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}function ui(r){return r!=null&&typeof r.init=="function"}var b0=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),e.dialer!=null&&this.setDialer(e.dialer)}isStarted(){return this.started}async beforeStart(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.beforeStart!=null&&await e.beforeStart()}))}async start(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{await e.start()})),this.started=!0}async afterStart(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async beforeStop(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.beforeStop!=null&&await e.beforeStop()}))}async stop(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{await e.stop()})),this.started=!1}async afterStop(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.afterStop!=null&&await e.afterStop()}))}setPeerId(e){return this.peerId=e,e}getPeerId(){if(this.peerId==null)throw(0,li.default)(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,ui(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,ui(e)&&e.init(this),e}getAddressManager(){if(this.addressManager==null)throw(0,li.default)(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,ui(e)&&e.init(this),e}getPeerStore(){if(this.peerStore==null)throw(0,li.default)(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,ui(e)&&e.init(this),e}getUpgrader(){if(this.upgrader==null)throw(0,li.default)(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,ui(e)&&e.init(this),e}getRegistrar(){if(this.registrar==null)throw(0,li.default)(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,ui(e)&&e.init(this),e}getConnectionManager(){if(this.connectionManager==null)throw(0,li.default)(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,ui(e)&&e.init(this),e}getTransportManager(){if(this.transportManager==null)throw(0,li.default)(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,ui(e)&&e.init(this),e}getConnectionGater(){if(this.connectionGater==null)throw(0,li.default)(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,ui(e)&&e.init(this),e}getContentRouting(){if(this.contentRouting==null)throw(0,li.default)(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,ui(e)&&e.init(this),e}getPeerRouting(){if(this.peerRouting==null)throw(0,li.default)(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,ui(e)&&e.init(this),e}getDatastore(){if(this.datastore==null)throw(0,li.default)(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,ui(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,ui(e)&&e.init(this),e}getDHT(){if(this.dht==null)throw(0,li.default)(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,ui(e)&&e.init(this),e}getPubSub(){if(this.pubsub==null)throw(0,li.default)(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,ui(e)&&e.init(this),e}getDialer(){if(this.dialer==null)throw(0,li.default)(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}};var _0=D("libp2p:gossipsub:score"),m5=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 p5,this.components=new b0,HY(e),this.scoreCacheValidityMs=n.scoreCacheValidityMs,this.computeScore=n.computeScore??WY}init(e){this.components=e}get size(){return this.peerStats.size}start(){if(this._backgroundInterval){_0("Peer score already running");return}this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),_0("started")}stop(){if(!this._backgroundInterval){_0("Peer score already stopped");return}clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),_0("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!==ci.unknown){_0("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,ci[i.status]);return}i.status=ci.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 ai.Error:this.markInvalidMessageDelivery(e,n);return;case ai.Blacklisted:return}let s=this.deliveryRecords.ensureRecord(t);if(s.status!==ci.unknown){_0("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,ci[s.status]);return}if(i===ai.Ignore){s.status=ci.ignored,s.peers.clear();return}s.status=ci.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 ci.unknown:i.peers.add(e);break;case ci.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,n,i.validated);break;case ci.invalid:this.markInvalidMessageDelivery(e,n);break;case ci.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(ce(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 y5=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 ai.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 v0=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 XY;(function(r){r.forward="forward",r.publish="publish"})(XY||(XY={}));var Kc;(function(r){r.Fanout="fanout",r.Random="random",r.Subscribed="subscribed",r.Outbound="outbound",r.NotEnough="not_enough",r.Opportunistic="opportunistic"})(Kc||(Kc={}));var Bh;(function(r){r.Dc="disconnected",r.BadScore="bad_score",r.Prune="prune",r.Unsub="unsubscribed",r.Excess="excess"})(Bh||(Bh={}));var x0;(function(r){r.GraftBackoff="graft_backoff",r.BrokenPromise="broken_promise",r.MessageDeficit="message_deficit",r.IPColocation="IP_colocation"})(x0||(x0={}));var T0;(function(r){r.LowScore="low_score",r.MaxIhave="max_ihave",r.MaxIasked="max_iasked"})(T0||(T0={}));var S0;(function(r){r.graylist="graylist",r.publish="publish",r.gossip="gossip",r.mesh="mesh"})(S0||(S0={}));function ZY(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===ai.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:S0.graylist},s),this.peersByScoreThreshold.set({threshold:S0.publish},o),this.peersByScoreThreshold.set({threshold:S0.gossip},a),this.peersByScoreThreshold.set({threshold:S0.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();u();function LA(r,e){e||(e=r.reduce((i,s)=>i+s.length,0));let t=h5(e),n=0;for(let i of r)t.set(i,n),n+=i.length;return w0(t)}u();function JY(r,e="utf8"){let t=d5[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?w0(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}u();u();u();var S1t=_(Jd(),1),Vbe=_(ut(),1);u();var zbe=_(V(),1);u();var tQ=_(O9(),1),rQ=_(er(),1),nQ=_(V(),1),eQ={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function Oy(r,e,t,n,i){if(i!=="sha1"&&i!=="sha2-256"&&i!=="sha2-512"){let a=Object.keys(eQ).join(" / ");throw(0,nQ.default)(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}let s=eQ[i],o=(0,tQ.default)(r,e,t,n,s);return rQ.default.encode64(o,null)}u();function iQ(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 sQ=JY("libp2p-pubsub:");async function oQ(r,e,t,n){switch(r.type){case Ll.Signing:{let i={from:r.author.toBytes(),data:n,seqno:gi(8),topic:e,signature:void 0,key:void 0},s=LA([sQ,h0.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${Ny(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key};return{raw:i,msg:o}}case Ll.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 aQ(r,e){switch(r){case E0:return e.signature!=null?{valid:!1,error:Qn.SignaturePresent}:e.seqno!=null?{valid:!1,error:Qn.SeqnoPresent}:e.key!=null?{valid:!1,error:Qn.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case Lh:{if(e.seqno==null)return{valid:!1,error:Qn.InvalidSeqno};if(e.seqno.length!==8)return{valid:!1,error:Qn.InvalidSeqno};if(e.signature==null)return{valid:!1,error:Qn.InvalidSignature};if(e.from==null)return{valid:!1,error:Qn.InvalidPeerId};let t;try{t=_r(e.from)}catch{return{valid:!1,error:Qn.InvalidPeerId}}let n;if(e.key){if(n=Ei(e.key),t.publicKey!==void 0&&!iQ(n.bytes,t.publicKey))return{valid:!1,error:Qn.InvalidPeerId}}else{if(t.publicKey==null)return{valid:!1,error:Qn.InvalidPeerId};n=Ei(t.publicKey)}let i={from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0},s=LA([sQ,h0.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${Ny(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??Cm(n)}}:{valid:!1,error:Qn.InvalidSignature}}}}u();u();u();u();u();var VA={};Re(VA,{identity:()=>Ybe});u();u();u();function $be(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,E=m.length;w!==E&&m[w]===0;)w++,y++;for(var v=(E-w)*f+1>>>0,x=new Uint8Array(v);w!==E;){for(var I=m[w],T=0,S=v-1;(I!==0||T<g)&&S!==-1;S--,T++)I+=256*x[S]>>>0,x[S]=I%a>>>0,I=I/a>>>0;if(I!==0)throw new Error("Non-zero carry");g=T,w++}for(var C=v-g;C!==v&&x[C]===0;)C++;for(var B=c.repeat(y);C<v;++C)B+=r.charAt(x[C]);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 E=(m.length-y)*l+1>>>0,v=new Uint8Array(E);m[y];){var x=t[m.charCodeAt(y)];if(x===255)return;for(var I=0,T=E-1;(x!==0||I<w)&&T!==-1;T--,I++)x+=a*v[T]>>>0,v[T]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");w=I,y++}if(m[y]!==" "){for(var S=E-w;S!==E&&v[S]===0;)S++;for(var C=new Uint8Array(g+(E-S)),B=g;S!==E;)C[B++]=v[S++];return C}}}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 Hbe=$be,Gbe=Hbe,cQ=Gbe;u();var rmt=new Uint8Array(0);var uQ=(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},zc=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var lQ=r=>new TextEncoder().encode(r),fQ=r=>new TextDecoder().decode(r);var BA=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")}},MA=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 dQ(this,e)}},UA=class{constructor(e){this.decoders=e}or(e){return dQ(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`)}},dQ=(r,e)=>new UA({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),FA=class{constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new BA(e,t,n),this.decoder=new MA(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},I0=({name:r,prefix:e,encode:t,decode:n})=>new FA(r,e,t,n),Bl=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:i}=cQ(t,e);return I0({prefix:r,name:e,encode:n,decode:s=>zc(i(s))})},Wbe=(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},jbe=(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})=>I0({prefix:e,name:r,encode(i){return jbe(i,n,t)},decode(i){return Wbe(i,n,t,r)}});var Ybe=I0({prefix:"\0",name:"identity",encode:r=>fQ(r),decode:r=>lQ(r)});var KA={};Re(KA,{base2:()=>Qbe});u();var Qbe=Br({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zA={};Re(zA,{base8:()=>Xbe});u();var Xbe=Br({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qA={};Re(qA,{base10:()=>Zbe});u();var Zbe=Bl({prefix:"9",name:"base10",alphabet:"0123456789"});var $A={};Re($A,{base16:()=>Jbe,base16upper:()=>e7e});u();var Jbe=Br({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),e7e=Br({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var HA={};Re(HA,{base32:()=>A0,base32hex:()=>i7e,base32hexpad:()=>o7e,base32hexpadupper:()=>a7e,base32hexupper:()=>s7e,base32pad:()=>r7e,base32padupper:()=>n7e,base32upper:()=>t7e,base32z:()=>c7e});u();var A0=Br({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),t7e=Br({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),r7e=Br({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),n7e=Br({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),i7e=Br({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),s7e=Br({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),o7e=Br({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),a7e=Br({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),c7e=Br({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var GA={};Re(GA,{base36:()=>u7e,base36upper:()=>l7e});u();var u7e=Bl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),l7e=Bl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var WA={};Re(WA,{base58btc:()=>ka,base58flickr:()=>f7e});u();var ka=Bl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),f7e=Bl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jA={};Re(jA,{base64:()=>h7e,base64pad:()=>d7e,base64url:()=>p7e,base64urlpad:()=>m7e});u();var h7e=Br({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),d7e=Br({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),p7e=Br({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),m7e=Br({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var YA={};Re(YA,{base256emoji:()=>b7e});u();var pQ=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}"),y7e=pQ.reduce((r,e,t)=>(r[t]=e,r),[]),g7e=pQ.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function w7e(r){return r.reduce((e,t)=>(e+=y7e[t],e),"")}function E7e(r){let e=[];for(let t of r){let n=g7e[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var b7e=I0({prefix:"\u{1F680}",name:"base256emoji",encode:w7e,decode:E7e});var JA={};Re(JA,{sha256:()=>vQ,sha512:()=>F7e});u();u();u();u();u();var _7e=gQ,mQ=128,v7e=127,S7e=~v7e,x7e=Math.pow(2,31);function gQ(r,e,t){e=e||[],t=t||0;for(var n=t;r>=x7e;)e[t++]=r&255|mQ,r/=128;for(;r&S7e;)e[t++]=r&255|mQ,r>>>=7;return e[t]=r|0,gQ.bytes=t-n+1,e}var T7e=QA,I7e=128,yQ=127;function QA(r,n){var t=0,n=n||0,i=0,s=n,o,a=r.length;do{if(s>=a)throw QA.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=i<28?(o&yQ)<<i:(o&yQ)*Math.pow(2,i),i+=7}while(o>=I7e);return QA.bytes=s-n,t}var A7e=Math.pow(2,7),R7e=Math.pow(2,14),C7e=Math.pow(2,21),D7e=Math.pow(2,28),P7e=Math.pow(2,35),k7e=Math.pow(2,42),N7e=Math.pow(2,49),O7e=Math.pow(2,56),L7e=Math.pow(2,63),B7e=function(r){return r<A7e?1:r<R7e?2:r<C7e?3:r<D7e?4:r<P7e?5:r<k7e?6:r<N7e?7:r<O7e?8:r<L7e?9:10},M7e={encode:_7e,decode:T7e,encodingLength:B7e},U7e=M7e,Ly=U7e;var By=(r,e=0)=>[Ly.decode(r,e),Ly.decode.bytes],R0=(r,e,t=0)=>(Ly.encode(r,e,t),e),C0=r=>Ly.encodingLength(r);var Mh=(r,e)=>{let t=e.byteLength,n=C0(r),i=n+C0(t),s=new Uint8Array(i+t);return R0(r,s,0),R0(t,s,n),s.set(e,i),new D0(r,t,e,s)},wQ=r=>{let e=zc(r),[t,n]=By(e),[i,s]=By(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new D0(t,i,o,e)},EQ=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&uQ(r.bytes,e.bytes),D0=class{constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};var ZA=({name:r,code:e,encode:t})=>new XA(r,e,t),XA=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?Mh(this.code,t):t.then(n=>Mh(this.code,n))}else throw Error("Unknown type, must be binary type")}};var _Q=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),vQ=ZA({name:"sha2-256",code:18,encode:_Q("SHA-256")}),F7e=ZA({name:"sha2-512",code:19,encode:_Q("SHA-512")});var eR={};Re(eR,{identity:()=>z7e});u();var SQ=0,V7e="identity",xQ=zc,K7e=r=>Mh(SQ,xQ(r)),z7e={code:SQ,name:V7e,encode:xQ,digest:K7e};u();u();var zmt=new TextEncoder,qmt=new TextDecoder;u();u();var En=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:E5,byteLength:E5,code:w5,version:w5,multihash:w5,bytes:w5,_baseCache:E5,asCID:E5})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==Uy)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==j7e)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return En.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Mh(e,t);return En.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&&EQ(this.multihash,e.multihash)}toString(e){let{bytes:t,version:n,_baseCache:i}=this;switch(n){case 0:return G7e(t,i,e||ka.encoder);default:return W7e(t,i,e||A0.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 Q7e(/^0\.0/,X7e),!!(e&&(e[IQ]||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 En)return e;if(e!=null&&e.asCID===e){let{version:t,code:n,multihash:i,bytes:s}=e;return new En(t,n,i,s||TQ(t,n,i.bytes))}else if(e!=null&&e[IQ]===!0){let{version:t,multihash:n,code:i}=e,s=wQ(n);return En.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!==Uy)throw new Error(`Version 0 CID must use dag-pb (code: ${Uy}) block encoding`);return new En(e,t,n,n.bytes)}case 1:{let i=TQ(e,t,n.bytes);return new En(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return En.create(0,Uy,e)}static createV1(e,t){return En.create(1,e,t)}static decode(e){let[t,n]=En.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=En.inspectBytes(e),n=t.size-t.multihashSize,i=zc(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 D0(t.multihashCode,t.digestSize,s,i);return[t.version===0?En.createV0(o):En.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[h,p]=By(e.subarray(t));return t+=p,h},i=n(),s=Uy;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]=H7e(e,t),s=En.decode(i);return s._baseCache.set(n,e),s}},H7e=(r,e)=>{switch(r[0]){case"Q":{let t=e||ka;return[ka.prefix,t.decode(`${ka.prefix}${r}`)]}case ka.prefix:{let t=e||ka;return[ka.prefix,t.decode(r)]}case A0.prefix:{let t=e||A0;return[A0.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)]}}},G7e=(r,e,t)=>{let{prefix:n}=t;if(n!==ka.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},W7e=(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},Uy=112,j7e=18,TQ=(r,e,t)=>{let n=C0(r),i=n+C0(e),s=new Uint8Array(i+t.byteLength);return R0(r,s,0),R0(e,s,n),s.set(t,i),s},IQ=Symbol.for("@ipld/js-cid/CID"),w5={writable:!1,configurable:!1,enumerable:!0},E5={writable:!1,enumerable:!1,configurable:!1},Y7e="0.0.0-dev",Q7e=(r,e)=>{if(r.test(Y7e))console.warn(e);else throw new Error(e)},X7e=`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)
}
`;var tR={...VA,...KA,...zA,...qA,...$A,...HA,...GA,...WA,...jA,...YA},e2t={...JA,...eR};u();u();function b5(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function AQ(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?b5(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function CQ(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var RQ=CQ("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),rR=CQ("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=AQ(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Z7e={utf8:RQ,"utf-8":RQ,hex:tR.base16,latin1:rR,ascii:rR,binary:rR,...tR},nR=Z7e;function DQ(r,e="utf8"){let t=nR[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?b5(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}u();u();var J7e=_(V(),1);var PQ=(r,e)=>{let t=DQ(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 kQ(r){if(r.type!=="signed")throw new Error("expected signed message type");if(r.sequenceNumber==null)throw Error("missing seqno field");return PQ(r.from.toBytes(),r.sequenceNumber)}async function NQ(r){return await RA.encode(r.data)}u();function e_e(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,E=0,v=0,x=0,I=0;if(d.inMesh){let B=Math.max(d.meshTime/y.timeInMeshQuantum,y.timeInMeshCap);w+=B*y.timeInMeshWeight}let T=d.firstMessageDeliveries;if(T>y.firstMessageDeliveriesCap&&(T=y.firstMessageDeliveriesCap),E+=T*y.firstMessageDeliveriesWeight,d.meshMessageDeliveriesActive&&d.meshMessageDeliveries<y.meshMessageDeliveriesThreshold){let B=y.meshMessageDeliveriesThreshold-d.meshMessageDeliveries,q=B*B;v+=q*y.meshMessageDeliveriesWeight}let S=d.meshFailurePenalty;x+=S*y.meshFailurePenaltyWeight;let C=d.invalidMessageDeliveries*d.invalidMessageDeliveries;I+=C*y.invalidMessageDeliveriesWeight,s+=(w+E+v+x+I)*y.topicWeight,g.p1w+=w,g.p2w+=E,g.p3w+=v,g.p3bw+=x,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,f=t.appSpecificScore(r);a+=f*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,g=y*y;c+=g*t.IPColocationFactorWeight}});let h=e.behaviourPenalty*e.behaviourPenalty;return l+=h*t.behaviourPenaltyWeight,s+=a+c+l,{byTopic:o,p5w:a,p6w:c,p7w:l,score:s}}function OQ(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=e_e(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 _5(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 LQ(r,e){return _5(r,e,()=>!0)}u();u();u();var Ml=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};u();function BQ(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 Mr(r,e,t){let n=t??{},i=BQ(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 Ml(f,h)}let l=new Promise((f,h)=>{o=()=>{let{abortMessage:p,abortCode:d}=n;h(new Ml(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 t_e(r,e,t){return n=>r(Mr(n,e,t))}function Zn(r,e,t){return{sink:t_e(r.sink,e,{...t,onAbort:void 0}),source:Mr(r.source,e,t)}}u();u();u();function MQ(r){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var v5=r=>{let e=Co.encodingLength(r),t=MQ(e);return Co.encode(r,t),v5.bytes=e,t};v5.bytes=0;function cr(r){r=r??{};let e=r.lengthEncoder??v5;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}}}cr.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??v5;return new et(t(r.byteLength),r)};u();var Fy=_(V(),1),r_e=8,n_e=1024*1024*4,Uh;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Uh||(Uh={}));var iR=r=>{let e=Co.decode(r);return iR.bytes=Co.encodingLength(e),e};iR.bytes=0;function ur(r){return async function*(t){let n=new et,i=Uh.LENGTH,s=-1,o=r?.lengthDecoder??iR,a=r?.maxLengthLength??r_e,c=r?.maxDataLength??n_e;for await(let l of t)for(n.append(l);n.byteLength>0;){if(i===Uh.LENGTH)try{if(s=o(n),s<0)throw(0,Fy.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>c)throw(0,Fy.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=Uh.DATA}catch(f){if(f instanceof RangeError){if(n.byteLength>a)throw(0,Fy.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw f}if(i===Uh.DATA){if(n.byteLength<s)break;let f=n.sublist(0,s);n.consume(s),r?.onData!=null&&r.onData(f),yield f,i=Uh.LENGTH}}if(n.byteLength>0)throw(0,Fy.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}ur.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 ur({...e??{},onLength:s=>{t=s}})(n)};var S5=class{constructor(e,t,n){this.rawStream=e,this.pushable=Vt({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=n.maxBufferSize??1/0,de(Mr(this.pushable,this.closeController.signal,{returnOnAbort:!0}),cr(),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()}},x5=class{constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=Mr(de(this.rawStream,ur()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}};var es;(function(r){r[r.started=0]="started",r[r.stopped=1]="stopped"})(es||(es={}));var Vy=class extends Fe{constructor(e={}){super(),this.multicodecs=[lA,uA],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=Vt({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 b0,this.directPeerInitial=null,this.status={code:es.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===es.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:$Y(e.scoreParams),scoreThresholds:GY(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??Lh,t.fallbackToFloodsub&&this.multicodecs.push(cA),this.log=D(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(n=>n.id.toString())),this.seenCache=new v0({validityMs:t.seenTTL}),this.publishedMessageIds=new v0({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case Lh:this.msgIdFn=kQ;break;case E0:this.msgIdFn=NQ;break}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new v0({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??zY,this.mcache=e.messageCache||new o5(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=ZY(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 y5(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new m5(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>ce(e))}isStarted(){return this.status.code===es.started}async init(e){this.components=e,this.score.init(e)}async start(){if(this.isStarted())return;this.log("starting"),this.publishConfig=await OA(this.globalSignaturePolicy,this.components.getPeerId()),this.outboundInflightQueue=Vt({objectMode:!0}),de(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=f0({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:es.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!==es.started)return;let{registrarTopologyIds:e}=this.status;this.status={code:es.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 S5(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===cA&&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 x5(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,Bh.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===es.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=>ce(n))}getTopics(){return Array.from(this.subscriptions)}async pipePeerReadStream(e,t){try{await de(t,async n=>{for await(let i of n)try{let s=i.subarray(),o=h0.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 J("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 Us.duplicate:this.score.duplicateMessage(e.toString(),n.msgIdStr,t.topic),this.mcache.observeDuplicate(n.msgIdStr,e.toString());return;case Us.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 Us.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 J("gossipsub:message",{detail:{propagationSource:e,msgId:n.messageId.msgIdStr,msg:n.msg}})),super.dispatchEvent(new J("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:Us.duplicate,msgIdStr:i};let s=await aQ(this.globalSignaturePolicy,t);if(!s.valid)return{code:Us.invalid,reason:ai.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:Us.invalid,reason:ai.Error,error:Qn.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:Us.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===_Y&&(h=Pa.Ignore),d===bY?h=Pa.Reject:h=Pa.Ignore}if(h!==Pa.Accept)return{code:Us.invalid,reason:NA(h),msgIdStr:c}}return{code:Us.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,Ra(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:T0.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:T0.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:T0.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 Ca(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,x0.GraftBackoff),o=!1;let f=l+this.opts.graftFloodThreshold-this.opts.pruneBackoff;s<f&&this.score.addPenalty(e,1,x0.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,Kc.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,Bh.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,x0.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&&(Ca(e),e=e.slice(0,this.opts.prunePeers));let t=[];await Promise.all(e.map(async n=>{if(!n.peerID)return;let i=_r(n.peerID).toString();if(!this.peers.has(i)){if(!n.signedPeerRecord){t.push(i);return}try{let s=await Qr.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=ce(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!==es.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!==es.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!==es.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,Kc.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,Kc.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!==es.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=Ra([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 oQ(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=Ra([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 J("gossipsub:message",{detail:{propagationSource:this.components.getPeerId(),msgId:a,msg:s}})),super.dispatchEvent(new J("message",{detail:s}))),{recipients:Array.from(c.values()).map(p=>ce(p))}}reportMessageValidationResult(e,t,n){if(n===Pa.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=NA(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=Ra([],{graft:[{topicID:t}]});this.sendRpc(e,i)}async sendPrune(e,t){let n=[await this.makePrune(e,t,this.opts.doPX)],i=Ra([],{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=h0.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=Ra([],{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=Ra([],{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||(Ca(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=Ca(Array.from(o)).slice(0,i),o.forEach(a=>{let c=n;n.length>5e3&&(c=Ca(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,Ra([],{ihave:t}));for(let[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,Ra([],{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===uA)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=ce(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,E=new Set;if(p.set(y,E),g){let I=Ca(Array.from(g)),T=this.backoff.get(y);for(let S of I){let C=this.streamsOutbound.get(S);if(C&&this.multicodecs.includes(C.protocol)&&!m.has(S)&&!this.direct.has(S)){let B=c(S);(!T||!T.has(S))&&B>=0&&w.add(S),B>=this.opts.scoreThresholds.gossipThreshold&&E.add(S)}}}let v=(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&&E.add(I),this.metrics?.onRemoveFromMesh(y,T,1);let S=f.get(I);S?S.push(y):f.set(I,[y])},x=(I,T)=>{this.log("HEARTBEAT: Add mesh link to %s in %s",I,y),this.score.graft(I,y),m.add(I),E.delete(I),this.metrics?.onAddToMesh(y,T,1);let S=l.get(I);S?S.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),v(I,Bh.BadScore),h.set(I,!0))}),m.size<t){let I=e-m.size;LQ(w,I).forEach(S=>{x(S,Kc.NotEnough)})}if(m.size>n){let I=Array.from(m);I.sort((S,C)=>c(C)-c(S)),I=I.slice(0,i).concat(Ca(I.slice(i)));let T=0;if(I.slice(0,e).forEach(S=>{this.outbound.get(S)&&T++}),T<s){let S=B=>{let q=I[B];for(let W=B;W>0;W--)I[W]=I[W-1];I[0]=q};if(T>0){let B=T;for(let q=1;q<e&&B>0;q++)this.outbound.get(I[q])&&(S(q),B--)}let C=e-T;for(let B=e;B<I.length&&C>0;B++)this.outbound.get(I[B])&&(S(B),C--)}I.slice(e).forEach(S=>{v(S,Bh.Excess)})}if(m.size>=t){let I=0;if(m.forEach(T=>{this.outbound.get(T)&&I++}),I<s){let T=s-I;_5(w,T,C=>this.outbound.get(C)===!0).forEach(C=>{x(C,Kc.Outbound)})}}if(this.heartbeatTicks%this.opts.opportunisticGraftTicks===0&&m.size>1){let I=Array.from(m).sort((C,B)=>c(C)-c(B)),T=Math.floor(m.size/2),S=c(I[T]);if(S<this.opts.scoreThresholds.opportunisticGraftThreshold){let C=this.opts.opportunisticGraftPeers,B=_5(w,C,q=>c(q)>S);for(let q of B)this.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",q,y),x(q,Kc.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(x=>{(!g.has(x)||c(x)<this.opts.scoreThresholds.publishThreshold)&&m.delete(x)});let w=this.topics.get(y),E=[],v=new Set;if(p.set(y,v),w){let x=Ca(Array.from(w));for(let I of x){let T=this.streamsOutbound.get(I);if(T&&this.multicodecs.includes(T.protocol)&&!m.has(I)&&!this.direct.has(I)){let S=c(I);S>=this.opts.scoreThresholds.publishThreshold&&E.push(I),S>=this.opts.scoreThresholds.gossipThreshold&&v.add(I)}}}if(m.size<e){let x=e-m.size;E.slice(0,x).forEach(I=>{m.add(I),v?.delete(I)})}}),this.emitGossip(p),await this.sendGraftPrune(l,f,h),this.flush(),this.mcache.shift(),this.dispatchEvent(new J("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=Ca(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=OQ(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}};Vy.multicodec=lA;var FQ=()=>({gossipsub:r=>{let e=new Vy({allowPublishToZeroPeers:!0,fallbackToFloodsub:!0,emitSelf:!0,maxInboundStreams:64,maxOutboundStreams:128});return e.init({getPeerId(){return r.peerId},getPeerStore(){return r.peerStore},getRegistrar(){return r.registrar},getConnectionManager(){return r.connectionManager}}),e}});u();u();var jQ=_(Ru(),1);u();var Ky=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},sR=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},VQ=r=>globalThis.DOMException===void 0?new sR(r):new DOMException(r),KQ=r=>{let e=r.reason===void 0?VQ("This operation was aborted."):r.reason;return e instanceof Error?e:VQ(e)};function oR(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(KQ(c)),c.addEventListener("abort",()=>{a(KQ(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 Ky(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 aR(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 Fh=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)},qc,zy=class{constructor(){qc.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Fh(this,qc,"f")[this.size-1].priority>=t.priority){Fh(this,qc,"f").push(n);return}let i=aR(Fh(this,qc,"f"),n,(s,o)=>o.priority-s.priority);Fh(this,qc,"f").splice(i,0,n)}dequeue(){let e=Fh(this,qc,"f").shift();return e?.run}filter(e){return Fh(this,qc,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Fh(this,qc,"f").length}};qc=new WeakMap;var Rr=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)},Zr,$y,Hy,Vl,D5,Gy,T5,Po,qy,ts,I5,rs,Wy,Fl,A5,zQ,qQ,WQ,$Q,HQ,GQ,R5,cR,uR,P5,C5,P_e=new Ky,lR=class extends Error{},jy=class extends jQ.default{constructor(e){var t,n,i,s;if(super(),Zr.add(this),$y.set(this,void 0),Hy.set(this,void 0),Vl.set(this,0),D5.set(this,void 0),Gy.set(this,void 0),T5.set(this,0),Po.set(this,void 0),qy.set(this,void 0),ts.set(this,void 0),I5.set(this,void 0),rs.set(this,0),Wy.set(this,void 0),Fl.set(this,void 0),A5.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:zy,...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})`);Rr(this,$y,e.carryoverConcurrencyCount,"f"),Rr(this,Hy,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Rr(this,D5,e.intervalCap,"f"),Rr(this,Gy,e.interval,"f"),Rr(this,ts,new e.queueClass,"f"),Rr(this,I5,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Rr(this,A5,e.throwOnTimeout===!0,"f"),Rr(this,Fl,e.autoStart===!1,"f")}get concurrency(){return _e(this,Wy,"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})`);Rr(this,Wy,e,"f"),_e(this,Zr,"m",P5).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Rr(this,rs,(a=_e(this,rs,"f"),a++,a),"f"),Rr(this,Vl,(c=_e(this,Vl,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new lR("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):oR(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?_e(this,A5,"f"):t.throwOnTimeout)&&i(P_e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}_e(this,Zr,"m",WQ).call(this)};_e(this,ts,"f").enqueue(s,t),_e(this,Zr,"m",R5).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return _e(this,Fl,"f")?(Rr(this,Fl,!1,"f"),_e(this,Zr,"m",P5).call(this),this):this}pause(){Rr(this,Fl,!0,"f")}clear(){Rr(this,ts,new(_e(this,I5,"f")),"f")}async onEmpty(){_e(this,ts,"f").size!==0&&await _e(this,Zr,"m",C5).call(this,"empty")}async onSizeLessThan(e){_e(this,ts,"f").size<e||await _e(this,Zr,"m",C5).call(this,"next",()=>_e(this,ts,"f").size<e)}async onIdle(){_e(this,rs,"f")===0&&_e(this,ts,"f").size===0||await _e(this,Zr,"m",C5).call(this,"idle")}get size(){return _e(this,ts,"f").size}sizeBy(e){return _e(this,ts,"f").filter(e).length}get pending(){return _e(this,rs,"f")}get isPaused(){return _e(this,Fl,"f")}};$y=new WeakMap,Hy=new WeakMap,Vl=new WeakMap,D5=new WeakMap,Gy=new WeakMap,T5=new WeakMap,Po=new WeakMap,qy=new WeakMap,ts=new WeakMap,I5=new WeakMap,rs=new WeakMap,Wy=new WeakMap,Fl=new WeakMap,A5=new WeakMap,Zr=new WeakSet,zQ=function(){return _e(this,Hy,"f")||_e(this,Vl,"f")<_e(this,D5,"f")},qQ=function(){return _e(this,rs,"f")<_e(this,Wy,"f")},WQ=function(){var e;Rr(this,rs,(e=_e(this,rs,"f"),e--,e),"f"),_e(this,Zr,"m",R5).call(this),this.emit("next")},$Q=function(){this.emit("empty"),_e(this,rs,"f")===0&&this.emit("idle")},HQ=function(){_e(this,Zr,"m",uR).call(this),_e(this,Zr,"m",cR).call(this),Rr(this,qy,void 0,"f")},GQ=function(){let e=Date.now();if(_e(this,Po,"f")===void 0){let t=_e(this,T5,"f")-e;if(t<0)Rr(this,Vl,_e(this,$y,"f")?_e(this,rs,"f"):0,"f");else return _e(this,qy,"f")===void 0&&Rr(this,qy,setTimeout(()=>{_e(this,Zr,"m",HQ).call(this)},t),"f"),!0}return!1},R5=function(){if(_e(this,ts,"f").size===0)return _e(this,Po,"f")&&clearInterval(_e(this,Po,"f")),Rr(this,Po,void 0,"f"),_e(this,Zr,"m",$Q).call(this),!1;if(!_e(this,Fl,"f")){let e=!_e(this,Zr,"a",GQ);if(_e(this,Zr,"a",zQ)&&_e(this,Zr,"a",qQ)){let t=_e(this,ts,"f").dequeue();return t?(this.emit("active"),t(),e&&_e(this,Zr,"m",cR).call(this),!0):!1}}return!1},cR=function(){_e(this,Hy,"f")||_e(this,Po,"f")!==void 0||(Rr(this,Po,setInterval(()=>{_e(this,Zr,"m",uR).call(this)},_e(this,Gy,"f")),"f"),Rr(this,T5,Date.now()+_e(this,Gy,"f"),"f"))},uR=function(){_e(this,Vl,"f")===0&&_e(this,rs,"f")===0&&_e(this,Po,"f")&&(clearInterval(_e(this,Po,"f")),Rr(this,Po,void 0,"f")),Rr(this,Vl,_e(this,$y,"f")?_e(this,rs,"f"):0,"f"),_e(this,Zr,"m",P5).call(this)},P5=function(){for(;_e(this,Zr,"m",R5).call(this););},C5=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var ZQ=_(V(),1),fR=_(ri(),1);var Vh=D("libp2p-delegated-peer-routing"),YQ=3e4,k_e=4,QQ;(function(r){r[r.SENDING_QUERY=0]="SENDING_QUERY",r[r.PEER_RESPONSE=1]="PEER_RESPONSE",r[r.FINAL_PEER=2]="FINAL_PEER",r[r.QUERY_ERROR=3]="QUERY_ERROR",r[r.PROVIDER=4]="PROVIDER",r[r.VALUE=5]="VALUE",r[r.ADDING_PEER=6]="ADDING_PEER",r[r.DIALING_PEER=7]="DIALING_PEER"})(QQ||(QQ={}));var XQ;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(XQ||(XQ={}));var hR=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 jy({concurrency:k_e});let{protocol:t,host:n,port:i}=e.getEndpointConfig();Vh(`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={}){Vh("findPeer starts: %p",e),t.timeout=t.timeout??YQ,t.signal=(0,fR.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[]));let n=Lt(),i=Lt();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 Vh.error("findPeer errored: %o",s),s}finally{i.resolve(),Vh("findPeer finished: %p",e)}throw(0,ZQ.default)(new Error("Not found"),"ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){let n,i=A.asCID(e);i!=null?n=i:n=_r(e),Vh("getClosestPeers starts: %s",n),t.timeout=t.timeout??YQ,t.signal=(0,fR.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[]));let s=Lt(),o=Lt();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 Vh.error("getClosestPeers errored:",a),a}finally{o.resolve(),Vh("getClosestPeers finished: %b",e)}}};function JQ(r){return()=>new hR(r)}u();var ER=_(tX(),1);u();var lX=_(Ru(),1);u();var Yy=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},dR=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},rX=r=>globalThis.DOMException===void 0?new dR(r):new DOMException(r),nX=r=>{let e=r.reason===void 0?rX("This operation was aborted."):r.reason;return e instanceof Error?e:rX(e)};function pR(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(nX(c)),c.addEventListener("abort",()=>{a(nX(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 Yy(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 mR(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)},$c,Qy=class{constructor(){$c.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&Kh(this,$c,"f")[this.size-1].priority>=t.priority){Kh(this,$c,"f").push(n);return}let i=mR(Kh(this,$c,"f"),n,(s,o)=>o.priority-s.priority);Kh(this,$c,"f").splice(i,0,n)}dequeue(){let e=Kh(this,$c,"f").shift();return e?.run}filter(e){return Kh(this,$c,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Kh(this,$c,"f").length}};$c=new WeakMap;var Cr=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},ve=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)},Jr,Zy,Jy,zl,M5,eg,k5,ko,Xy,ns,N5,is,tg,Kl,O5,iX,sX,uX,oX,aX,cX,L5,yR,gR,U5,B5,O_e=new Yy,wR=class extends Error{},k0=class extends lX.default{constructor(e){var t,n,i,s;if(super(),Jr.add(this),Zy.set(this,void 0),Jy.set(this,void 0),zl.set(this,0),M5.set(this,void 0),eg.set(this,void 0),k5.set(this,0),ko.set(this,void 0),Xy.set(this,void 0),ns.set(this,void 0),N5.set(this,void 0),is.set(this,0),tg.set(this,void 0),Kl.set(this,void 0),O5.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:Qy,...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})`);Cr(this,Zy,e.carryoverConcurrencyCount,"f"),Cr(this,Jy,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Cr(this,M5,e.intervalCap,"f"),Cr(this,eg,e.interval,"f"),Cr(this,ns,new e.queueClass,"f"),Cr(this,N5,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Cr(this,O5,e.throwOnTimeout===!0,"f"),Cr(this,Kl,e.autoStart===!1,"f")}get concurrency(){return ve(this,tg,"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})`);Cr(this,tg,e,"f"),ve(this,Jr,"m",U5).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Cr(this,is,(a=ve(this,is,"f"),a++,a),"f"),Cr(this,zl,(c=ve(this,zl,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new wR("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):pR(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?ve(this,O5,"f"):t.throwOnTimeout)&&i(O_e)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}ve(this,Jr,"m",uX).call(this)};ve(this,ns,"f").enqueue(s,t),ve(this,Jr,"m",L5).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return ve(this,Kl,"f")?(Cr(this,Kl,!1,"f"),ve(this,Jr,"m",U5).call(this),this):this}pause(){Cr(this,Kl,!0,"f")}clear(){Cr(this,ns,new(ve(this,N5,"f")),"f")}async onEmpty(){ve(this,ns,"f").size!==0&&await ve(this,Jr,"m",B5).call(this,"empty")}async onSizeLessThan(e){ve(this,ns,"f").size<e||await ve(this,Jr,"m",B5).call(this,"next",()=>ve(this,ns,"f").size<e)}async onIdle(){ve(this,is,"f")===0&&ve(this,ns,"f").size===0||await ve(this,Jr,"m",B5).call(this,"idle")}get size(){return ve(this,ns,"f").size}sizeBy(e){return ve(this,ns,"f").filter(e).length}get pending(){return ve(this,is,"f")}get isPaused(){return ve(this,Kl,"f")}};Zy=new WeakMap,Jy=new WeakMap,zl=new WeakMap,M5=new WeakMap,eg=new WeakMap,k5=new WeakMap,ko=new WeakMap,Xy=new WeakMap,ns=new WeakMap,N5=new WeakMap,is=new WeakMap,tg=new WeakMap,Kl=new WeakMap,O5=new WeakMap,Jr=new WeakSet,iX=function(){return ve(this,Jy,"f")||ve(this,zl,"f")<ve(this,M5,"f")},sX=function(){return ve(this,is,"f")<ve(this,tg,"f")},uX=function(){var e;Cr(this,is,(e=ve(this,is,"f"),e--,e),"f"),ve(this,Jr,"m",L5).call(this),this.emit("next")},oX=function(){this.emit("empty"),ve(this,is,"f")===0&&this.emit("idle")},aX=function(){ve(this,Jr,"m",gR).call(this),ve(this,Jr,"m",yR).call(this),Cr(this,Xy,void 0,"f")},cX=function(){let e=Date.now();if(ve(this,ko,"f")===void 0){let t=ve(this,k5,"f")-e;if(t<0)Cr(this,zl,ve(this,Zy,"f")?ve(this,is,"f"):0,"f");else return ve(this,Xy,"f")===void 0&&Cr(this,Xy,setTimeout(()=>{ve(this,Jr,"m",aX).call(this)},t),"f"),!0}return!1},L5=function(){if(ve(this,ns,"f").size===0)return ve(this,ko,"f")&&clearInterval(ve(this,ko,"f")),Cr(this,ko,void 0,"f"),ve(this,Jr,"m",oX).call(this),!1;if(!ve(this,Kl,"f")){let e=!ve(this,Jr,"a",cX);if(ve(this,Jr,"a",iX)&&ve(this,Jr,"a",sX)){let t=ve(this,ns,"f").dequeue();return t?(this.emit("active"),t(),e&&ve(this,Jr,"m",yR).call(this),!0):!1}}return!1},yR=function(){ve(this,Jy,"f")||ve(this,ko,"f")!==void 0||(Cr(this,ko,setInterval(()=>{ve(this,Jr,"m",gR).call(this)},ve(this,eg,"f")),"f"),Cr(this,k5,Date.now()+ve(this,eg,"f"),"f"))},gR=function(){ve(this,zl,"f")===0&&ve(this,is,"f")===0&&ve(this,ko,"f")&&(clearInterval(ve(this,ko,"f")),Cr(this,ko,void 0,"f")),Cr(this,zl,ve(this,Zy,"f")?ve(this,is,"f"):0,"f"),ve(this,Jr,"m",U5).call(this)},U5=function(){for(;ve(this,Jr,"m",L5).call(this););},B5=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var dX=_(V(),1),rg=_(ri(),1),Na=D("libp2p:delegated-content-routing"),F5=3e4,L_e=4,B_e=2,fX;(function(r){r[r.SENDING_QUERY=0]="SENDING_QUERY",r[r.PEER_RESPONSE=1]="PEER_RESPONSE",r[r.FINAL_PEER=2]="FINAL_PEER",r[r.QUERY_ERROR=3]="QUERY_ERROR",r[r.PROVIDER=4]="PROVIDER",r[r.VALUE=5]="VALUE",r[r.ADDING_PEER=6]="ADDING_PEER",r[r.DIALING_PEER=7]="DIALING_PEER"})(fX||(fX={}));var hX;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(hX||(hX={}));var bR=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 k0({concurrency:L_e}),this.httpQueueRefs=new k0({concurrency:B_e});let{protocol:t,host:n,port:i}=e.getEndpointConfig();Na(`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={}){Na("findProviders starts: %c",e),t.timeout=t.timeout??F5,t.signal=(0,rg.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[]));let n=Lt(),i=Lt();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 Na.error("findProviders errored:",s),s}finally{i.resolve(),Na("findProviders finished: %c",e)}}async provide(e,t={}){Na("provide starts: %c",e),t.timeout=t.timeout??F5,t.signal=(0,rg.default)([this.abortController.signal].concat(t.signal!=null?[t.signal]:[])),await this.httpQueueRefs.add(async()=>{await this.client.block.stat(e,t),await(0,ER.default)(this.client.dht.provide(e,t))}),Na("provide finished: %c",e)}async put(e,t,n={}){Na("put value start: %b",e),n.timeout=n.timeout??F5,n.signal=(0,rg.default)([this.abortController.signal].concat(n.signal!=null?[n.signal]:[])),await this.httpQueue.add(async()=>{await(0,ER.default)(this.client.dht.put(e,t,n))}),Na("put value finished: %b",e)}async get(e,t={}){return Na("get value start: %b",e),t.timeout=t.timeout??F5,t.signal=(0,rg.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 Na("get value finished: %b",e),n.value;throw(0,dX.default)(new Error("Not found"),"ERR_NOT_FOUND")})}};function pX(r){return()=>new bR(r)}u();u();var M_e=r=>Promise.reject(new Error(`No base found for "${r}"`)),N0=class{constructor(e){this._basesByName={},this._basesByPrefix={},this._loadBase=e.loadBase||M_e;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 U_e=r=>Promise.reject(new Error(`No codec found for "${r}"`)),O0=class{constructor(e){this._codecsByName={},this._codecsByCode={},this._loadCodec=e.loadCodec||U_e;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 F_e=r=>Promise.reject(new Error(`No hasher found for "${r}"`)),L0=class{constructor(e){this._hashersByName={},this._hashersByCode={},this._loadHasher=e.loadHasher||F_e;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 Oa=_(l_(),1);var zh=_(Hd(),1);u();function _R(r){try{r=Mp(ee(r))}catch{}return r=r.toString(),r}u();var mX=()=>{};var yX=D("ipfs-http-client:lib:error-handler"),V_e=ze.bind({ignoreUndefined:!0}),K_e=Oa.isBrowser||Oa.isWebWorker?location.protocol:"http",z_e=Oa.isBrowser||Oa.isWebWorker?location.hostname:"localhost",q_e=Oa.isBrowser||Oa.isWebWorker?location.port:"5001",$_e=(r={})=>{let e,t={},n;if(typeof r=="string"||oc(r))e=new URL(_R(r));else if(r instanceof URL)e=r;else if(typeof r.url=="string"||oc(r.url))e=new URL(_R(r.url)),t=r;else if(r.url instanceof URL)e=r.url,t=r;else{t=r||{};let i=(t.protocol||K_e).replace(":",""),s=(t.host||z_e).split(":")[0],o=t.port||q_e;e=new URL(`${i}://${s}:${o}`)}if(t.apiPath?e.pathname=t.apiPath:(e.pathname==="/"||e.pathname===void 0)&&(e.pathname="api/v0"),Oa.isNode){let i=mX(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}},H_e=async r=>{let e;try{if((r.headers.get("Content-Type")||"").startsWith("application/json")){let n=await r.json();yX(n),e=n.Message||n.message}else e=await r.text()}catch(n){yX("Failed to parse error response",n),e=n.message}let t=new zh.default.HTTPError(r);throw e&&(e.includes("deadline has elapsed")&&(t=new zh.default.TimeoutError),e&&e.includes("context deadline exceeded")&&(t=new zh.default.TimeoutError)),e&&e.includes("request timed out")&&(t=new zh.default.TimeoutError),e&&(t.message=e),t},G_e=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,gX=r=>r.replace(G_e,function(e){return"-"+e.toLowerCase()}),W_e=r=>typeof r=="string"?Tu(r):r,ql=class extends zh.default{constructor(e={}){let t=$_e(e);super({timeout:W_e(t.timeout||0)||void 0,headers:t.headers,base:`${t.url}`,handleError:H_e,transformSearchParams:i=>{let s=new URLSearchParams;for(let[o,a]of i)a!=="undefined"&&a!=="null"&&o!=="signal"&&s.append(gX(o),a),o==="timeout"&&!isNaN(a)&&s.append(gX(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,V_e(s,{method:"POST"})))}},zgt=zh.default.HTTPError;var P=r=>e=>r(new ql(e),e);u();u();function V5(r){if(r!=null)return typeof r=="string"?r:r.toString(8).padStart(4,"0")}u();var wX=_(V(),1);function K5(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,wX.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return e}}function N({arg:r,searchParams:e,hashAlg:t,mtime:n,mode:i,...s}={}){e&&(s={...s,...e}),t&&(s.hash=t),n!=null&&(n=K5(n),s.mtime=n.secs,s.mtimeNsecs=n.nsecs),i!=null&&(s.mode=V5(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 EX=P(r=>{async function e(t={}){return((await(await r.post("bitswap/wantlist",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()).Keys||[]).map(i=>A.parse(i["/"]))}return e});u();var bX=P(r=>{async function e(t,n={}){return((await(await r.post("bitswap/wantlist",{signal:n.signal,searchParams:N({...n,peer:t.toString()}),headers:n.headers})).json()).Keys||[]).map(s=>A.parse(s["/"]))}return e});u();var z5=P(r=>{async function e(t={}){let n=await r.post("bitswap/stat",{searchParams:N(t),signal:t.signal,headers:t.headers});return j_e(await n.json())}return e});function j_e(r){return{provideBufLen:r.ProvideBufLen,wantlist:(r.Wantlist||[]).map(e=>A.parse(e["/"])),peers:(r.Peers||[]).map(e=>ce(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 _X=P(r=>{async function e(t,n={}){return(await r.post("bitswap/unwant",{signal:n.signal,searchParams:N({arg:t.toString(),...n}),headers:n.headers})).json()}return e});function vX(r){return{wantlist:EX(r),wantlistForPeer:bX(r),unwant:_X(r),stat:z5(r)}}u();u();var q5=P(r=>{async function e(t,n={}){let i=await r.post("block/get",{signal:n.signal,searchParams:N({arg:t.toString(),...n}),headers:n.headers});return new Uint8Array(await i.arrayBuffer())}return e});u();u();u();u();var xX=_(V(),1);async function TX(r){if(Ds(r))return new Blob([r]);if(typeof r=="string"||r instanceof String)return new Blob([r.toString()]);if(_c(r))return r;if(vc(r)&&(r=Cs(r)),Symbol.iterator in r||Symbol.asyncIterator in r){let e=go(r),{value:t,done:n}=await e.peek();if(n)return SX(e);if(e.push(t),Number.isInteger(t))return new Blob([Uint8Array.from(await oi(e))]);if(Ds(t)||typeof t=="string"||t instanceof String)return SX(e)}throw(0,xX.default)(new Error(`Unexpected input: ${r}`),"ERR_UNEXPECTED_INPUT")}async function SX(r){let e=[];for await(let t of r)e.push(t);return new Blob(e)}function IX(r){return J6(r,TX,!0)}u();function AX(r){if(r!=null)return typeof r=="string"?r:r.toString(8).padStart(4,"0")}async function cn(r,e,t={}){let n=[],i=new FormData,s=0,o=0;for await(let{content:a,path:c,mode:l,mtime:f}of IX(r)){let h="",p=a?"file":"dir";s>0&&(h=`-${s}`);let d=p+h,m=[];if(l!=null&&m.push(`mode=${AX(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 RX=_(ri(),1);function Y_e(r){return r.filter(Boolean)}function un(...r){return(0,RX.anySignal)(Y_e(r))}var CX=P(r=>{async function e(t,n={}){let i=new AbortController,s=un(i.signal,n.signal),o;try{o=await(await r.post("block/put",{signal:s,searchParams:N(n),...await cn([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 DX=P(r=>{async function*e(t,n={}){Array.isArray(t)||(t=[t]);let i=await r.post("block/rm",{signal:n.signal,searchParams:N({arg:t.map(s=>s.toString()),"stream-channels":!0,...n}),headers:n.headers});for await(let s of i.ndjson())yield Q_e(s)}return e});function Q_e(r){let e={cid:A.parse(r.Hash)};return r.Error&&(e.error=new Error(r.Error)),e}u();var PX=P(r=>{async function e(t,n={}){let s=await(await r.post("block/stat",{signal:n.signal,searchParams:N({arg:t.toString(),...n}),headers:n.headers})).json();return{cid:A.parse(s.Key),size:s.Size}}return e});function kX(r){return{get:q5(r),put:CX(r),rm:DX(r),stat:PX(r)}}u();u();var NX=P(r=>{async function e(t,n={}){let i=await r.post("bootstrap/add",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers}),{Peers:s}=await i.json();return{Peers:s.map(o=>ee(o))}}return e});u();var OX=P(r=>{async function e(t={}){let n=await r.post("bootstrap/rm",{signal:t.signal,searchParams:N({...t,all:!0}),headers:t.headers}),{Peers:i}=await n.json();return{Peers:i.map(s=>ee(s))}}return e});u();var LX=P(r=>{async function e(t={}){let n=await r.post("bootstrap/list",{signal:t.signal,searchParams:N(t),headers:t.headers}),{Peers:i}=await n.json();return{Peers:i.map(s=>ee(s))}}return e});u();var BX=P(r=>{async function e(t={}){let n=await r.post("bootstrap/add",{signal:t.signal,searchParams:N({...t,default:!0}),headers:t.headers}),{Peers:i}=await n.json();return{Peers:i.map(s=>ee(s))}}return e});u();var MX=P(r=>{async function e(t,n={}){let i=await r.post("bootstrap/rm",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers}),{Peers:s}=await i.json();return{Peers:s.map(o=>ee(o))}}return e});function UX(r){return{add:NX(r),clear:OX(r),list:LX(r),reset:BX(r),rm:MX(r)}}u();u();u();var FX=P(r=>{async function e(t,n={}){let s=await(await r.post("config/profile/apply",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).json();return{original:s.OldCfg,updated:s.NewCfg}}return e});u();u();function mt(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 VX=P(r=>{async function e(t={}){return(await(await r.post("config/profile/list",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()).map(s=>mt(s))}return e});function KX(r){return{apply:FX(r),list:VX(r)}}u();var zX=P(r=>async(t,n={})=>{if(!t)throw new Error("key argument is required");return(await(await r.post("config",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).json()).Value});u();var qX=P(r=>async(t={})=>await(await r.post("config/show",{signal:t.signal,searchParams:N({...t}),headers:t.headers})).json());u();var $X=P(r=>async(t,n={})=>{let i=new AbortController,s=un(i.signal,n.signal);await(await r.post("config/replace",{signal:s,searchParams:N(n),...await cn([z(JSON.stringify(t))],i,n.headers)})).text()});u();var HX=P(r=>async(t,n,i={})=>{if(typeof t!="string")throw new Error("Invalid key type");let s={...i,...X_e(t,n)};await(await r.post("config",{signal:i.signal,searchParams:N(s),headers:i.headers})).text()}),X_e=(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 GX(r){return{getAll:qX(r),get:zX(r),set:HX(r),replace:$X(r),profiles:KX(r)}}u();u();var WX=P(r=>{async function*e(t,n={}){yield*(await r.post("dag/export",{signal:n.signal,searchParams:N({arg:t.toString()}),headers:n.headers})).iterator()}return e});u();u();var vR=_(V(),1);async function*SR(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,vR.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,vR.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 jX=_(V(),1);var YX=(r,e)=>P((n,i)=>{let s=q5(i);return async(a,c={})=>{if(c.path){let d=c.localResolve?await kn(SR(a,c.path,r,s,c)):await Xt(SR(a,c.path,r,s,c));if(!d)throw(0,jX.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 QX=P(r=>{async function*e(t,n={}){let i=new AbortController,s=un(i.signal,n.signal),{headers:o,body:a}=await cn(t,i,n.headers),c=await r.post("dag/import",{signal:s,headers:o,body:a,searchParams:N({"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 $5=(r,e)=>P(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=un(l.signal,a.signal),p=await(await n.post("dag/put",{timeout:a.timeout,signal:f,searchParams:N(a),...await cn([c],l,a.headers)})).json();return A.parse(p.Cid["/"])})(e);u();var XX=P(r=>async(t,n={})=>{let s=await(await r.post("dag/resolve",{signal:n.signal,searchParams:N({arg:`${t}${n.path?`/${n.path}`.replace(/\/[/]+/g,"/"):""}`,...n}),headers:n.headers})).json();return{cid:A.parse(s.Cid["/"]),remainderPath:s.RemPath}});function ZX(r,e){return{export:WX(e),get:YX(r,e),import:QX(e),put:$5(r,e),resolve:XX(e)}}u();u();u();u();var Fs=r=>{if(r.Type===0)return{name:"SENDING_QUERY",type:r.Type};if(r.Type===1)return{from:ce(r.ID),name:"PEER_RESPONSE",type:r.Type,messageType:0,messageName:"PUT_VALUE",closer:(r.Responses||[]).map(({ID:e,Addrs:t})=>({id:ce(e),multiaddrs:t.map(n=>ee(n)),protocols:[]})),providers:(r.Responses||[]).map(({ID:e,Addrs:t})=>({id:ce(e),multiaddrs:t.map(n=>ee(n)),protocols:[]}))};if(r.Type===2){let e={id:r.ID??ce(r.ID),multiaddrs:[],protocols:[]};return r.Responses&&r.Responses.length&&(e={id:ce(r.Responses[0].ID),multiaddrs:r.Responses[0].Addrs.map(t=>ee(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:ce(e),multiaddrs:t.map(n=>ee(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})=>ce(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:ce(r.ID)};throw new Error("Unknown DHT event type")};var JX=P(r=>{async function*e(t,n={}){let i=await r.post("dht/findpeer",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers});for await(let s of i.ndjson())yield Fs(s)}return e});u();var eZ=P(r=>{async function*e(t,n={}){let i=await r.post("dht/findprovs",{signal:n.signal,searchParams:N({arg:t.toString(),...n}),headers:n.headers});for await(let s of i.ndjson())yield Fs(s)}return e});u();var tZ=P(r=>{async function*e(t,n={}){let i=await r.post("dht/get",{signal:n.signal,searchParams:N({arg:t instanceof Uint8Array?K(t):t.toString(),...n}),headers:n.headers});for await(let s of i.ndjson())yield Fs(s)}return e});u();var rZ=P(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:N({arg:i.map(o=>o.toString()),...n}),headers:n.headers});for await(let o of s.ndjson())yield Fs(o)}return e});u();var nZ=P(r=>{async function*e(t,n,i={}){let s=new AbortController,o=un(s.signal,i.signal),a=await r.post("dht/put",{signal:o,searchParams:N({arg:t instanceof Uint8Array?K(t):t.toString(),...i}),...await cn([n],s,i.headers)});for await(let c of a.ndjson())yield Fs(c)}return e});u();var iZ=P(r=>{async function*e(t,n={}){let i=await r.post("dht/query",{signal:n.signal,searchParams:N({arg:t.toString(),...n}),headers:n.headers});for await(let s of i.ndjson())yield Fs(s)}return e});function sZ(r){return{findPeer:JX(r),findProvs:eZ(r),get:tZ(r),provide:rZ(r),put:nZ(r),query:iZ(r)}}u();u();var oZ=P(r=>{async function e(t={}){return(await r.post("diag/cmds",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()}return e});u();var aZ=P(r=>{async function e(t={}){return(await r.post("diag/net",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()}return e});u();var cZ=P(r=>{async function e(t={}){return(await r.post("diag/sys",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()}return e});function uZ(r){return{cmds:oZ(r),net:aZ(r),sys:cZ(r)}}u();u();var lZ=P(r=>{async function e(t,n,i={}){await(await r.post("files/chmod",{signal:i.signal,searchParams:N({arg:t,mode:n,...i}),headers:i.headers})).text()}return e});u();var fZ=P(r=>{async function e(t,n,i={}){let s=Array.isArray(t)?t:[t];await(await r.post("files/cp",{signal:i.signal,searchParams:N({arg:s.concat(n).map(a=>A.asCID(a)?`/ipfs/${a}`:a),...i}),headers:i.headers})).text()}return e});u();var hZ=P(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:N({arg:t,...n}),headers:n.headers})).json();return A.parse(s.Cid)}return e});u();u();function ng(r){let e=mt(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 pZ=P(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:N({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 dZ(ng(o));else yield dZ(ng(s))}return e});function dZ(r){return r.hash&&(r.cid=A.parse(r.hash)),delete r.hash,r.type=r.type===1?"directory":"file",r}u();var mZ=P(r=>{async function e(t,n={}){await(await r.post("files/mkdir",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).text()}return e});u();var yZ=P(r=>{async function e(t,n,i={}){Array.isArray(t)||(t=[t]),await(await r.post("files/mv",{signal:i.signal,searchParams:N({arg:t.concat(n),...i}),headers:i.headers})).text()}return e});u();var EZ=_(wZ(),1),bZ=P(r=>{async function*e(t,n={}){let i=await r.post("files/read",{signal:n.signal,searchParams:N({arg:t,count:n.length,...n}),headers:n.headers});yield*(0,EZ.default)(i.body)}return e});u();var _Z=_(Hd(),1),vZ=P(r=>{async function e(t,n={}){let i=await r.post("files/rm",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers}),s=await i.text();if(s!==""){let o=new _Z.default.HTTPError(i);throw o.message=s,o}}return e});u();var H5=P(r=>{async function e(t,n={}){let s=await(await r.post("files/stat",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).json();return s.WithLocality=s.WithLocality||!1,ove(ng(s))}return e});function ove(r){return r.cid=A.parse(r.hash),delete r.hash,r}u();var SZ=P(r=>{async function e(t,n={}){await(await r.post("files/touch",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).text()}return e});u();var xZ=P(r=>{async function e(t,n,i={}){let s=new AbortController,o=un(s.signal,i.signal);await(await r.post("files/write",{signal:o,searchParams:N({arg:t,streamChannels:!0,count:i.length,...i}),...await cn([{content:n,path:"arg",mode:V5(i.mode),mtime:K5(i.mtime)}],s,i.headers)})).text()}return e});function TZ(r){return{chmod:lZ(r),cp:fZ(r),flush:hZ(r),ls:pZ(r),mkdir:mZ(r),mv:yZ(r),read:bZ(r),rm:vZ(r),stat:H5(r),touch:SZ(r),write:xZ(r)}}u();u();var IZ=_(V(),1),AZ=P(r=>async(t,n,i={})=>{throw(0,IZ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});u();var RZ=P(r=>{async function e(t,n={type:"Ed25519"}){let s=await(await r.post("key/gen",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).json();return mt(s)}return e});u();var CZ=P(r=>{async function e(t,n,i,s={}){let a=await(await r.post("key/import",{signal:s.signal,searchParams:N({arg:t,pem:n,password:i,...s}),headers:s.headers})).json();return mt(a)}return e});u();var DZ=_(V(),1),PZ=P(r=>async(t,n={})=>{throw(0,DZ.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});u();var kZ=P(r=>{async function e(t={}){return((await(await r.post("key/list",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()).Keys||[]).map(s=>mt(s))}return e});u();var NZ=P(r=>{async function e(t,n,i={}){let s=await r.post("key/rename",{signal:i.signal,searchParams:N({arg:[t,n],...i}),headers:i.headers});return mt(await s.json())}return e});u();var OZ=P(r=>{async function e(t,n={}){let s=await(await r.post("key/rm",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).json();return mt(s.Keys[0])}return e});function LZ(r){return{export:AZ(r),gen:RZ(r),import:CZ(r),info:PZ(r),list:kZ(r),rename:NZ(r),rm:OZ(r)}}u();u();var BZ=P(r=>{async function e(t,n,i={}){let s=await r.post("log/level",{signal:i.signal,searchParams:N({arg:[t,n],...i}),headers:i.headers});return mt(await s.json())}return e});u();var MZ=P(r=>{async function e(t={}){return(await(await r.post("log/ls",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()).Strings}return e});u();var UZ=P(r=>{async function*e(t={}){yield*(await r.post("log/tail",{signal:t.signal,searchParams:N(t),headers:t.headers})).ndjson()}return e});function FZ(r){return{level:BZ(r),ls:MZ(r),tail:UZ(r)}}u();u();var VZ=P(r=>{async function e(t,n={}){let i=await r.post("name/publish",{signal:n.signal,searchParams:N({arg:`${t}`,...n}),headers:n.headers});return mt(await i.json())}return e});u();var KZ=P(r=>{async function*e(t,n={}){let i=await r.post("name/resolve",{signal:n.signal,searchParams:N({arg:t,stream:!0,...n}),headers:n.headers});for await(let s of i.ndjson())yield s.Path}return e});u();u();var zZ=P(r=>{async function e(t,n={}){let i=await r.post("name/pubsub/cancel",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers});return mt(await i.json())}return e});u();var qZ=P(r=>{async function e(t={}){let n=await r.post("name/pubsub/state",{signal:t.signal,searchParams:N(t),headers:t.headers});return mt(await n.json())}return e});u();var $Z=P(r=>{async function e(t={}){return(await(await r.post("name/pubsub/subs",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()).Strings||[]}return e});function HZ(r){return{cancel:zZ(r),state:qZ(r),subs:$Z(r)}}function GZ(r){return{publish:VZ(r),resolve:KZ(r),pubsub:HZ(r)}}u();u();var WZ=P(r=>{async function e(t,n={}){let s=await(await r.post("object/data",{signal:n.signal,searchParams:N({arg:`${t instanceof Uint8Array?A.decode(t):t}`,...n}),headers:n.headers})).arrayBuffer();return new Uint8Array(s,0,s.byteLength)}return e});u();var jZ=P(r=>{async function e(t,n={}){let s=await(await r.post("object/get",{signal:n.signal,searchParams:N({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 YZ=P(r=>{async function e(t,n={}){return((await(await r.post("object/links",{signal:n.signal,searchParams:N({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 QZ=P(r=>{async function e(t={}){let n=await r.post("object/new",{signal:t.signal,searchParams:N({arg:t.template,...t}),headers:t.headers}),{Hash:i}=await n.json();return A.parse(i)}return e});u();var XZ=(r,e)=>P(n=>{let i=$5(r,e);async function s(o,a={}){return i(o,{...a,storeCodec:"dag-pb",hashAlg:"sha2-256",version:1})}return s})(e);u();var ZZ=P(r=>{async function e(t,n={}){let s=await(await r.post("object/stat",{signal:n.signal,searchParams:N({arg:`${t}`,...n}),headers:n.headers})).json();return{...s,Hash:A.parse(s.Hash)}}return e});u();u();var JZ=P(r=>{async function e(t,n,i={}){let s=await r.post("object/patch/add-link",{signal:i.signal,searchParams:N({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 eJ=P(r=>{async function e(t,n,i={}){let s=new AbortController,o=un(s.signal,i.signal),a=await r.post("object/patch/append-data",{signal:o,searchParams:N({arg:`${t}`,...i}),...await cn([n],s,i.headers)}),{Hash:c}=await a.json();return A.parse(c)}return e});u();var tJ=P(r=>{async function e(t,n,i={}){let s=await r.post("object/patch/rm-link",{signal:i.signal,searchParams:N({arg:[`${t}`,n.Name||n.name||null],...i}),headers:i.headers}),{Hash:o}=await s.json();return A.parse(o)}return e});u();var rJ=P(r=>{async function e(t,n,i={}){let s=new AbortController,o=un(s.signal,i.signal),a=await r.post("object/patch/set-data",{signal:o,searchParams:N({arg:[`${t}`],...i}),...await cn([n],s,i.headers)}),{Hash:c}=await a.json();return A.parse(c)}return e});function nJ(r){return{addLink:JZ(r),appendData:eJ(r),rmLink:tJ(r),setData:rJ(r)}}function iJ(r,e){return{data:WZ(e),get:jZ(e),links:YZ(e),new:QZ(e),put:XZ(r,e),stat:ZZ(e),patch:nJ(e)}}u();u();var G5=P(r=>{async function*e(t,n={}){for await(let{path:i,recursive:s,metadata:o}of ra(t)){let a=await r.post("pin/add",{signal:n.signal,searchParams:N({...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();function sJ(r){let e=G5(r);return P(()=>{async function t(n,i={}){return Xt(e([{path:n,...i}],i))}return t})(r)}u();function oJ(r,e,t){let n={type:r,cid:A.parse(e)};return t&&(n.metadata=t),n}var aJ=P(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:N({...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 oJ(s.Keys[o].Type,o,s.Keys[o].Metadata);return}yield oJ(s.Type,s.Cid,s.Metadata)}}return e});u();var W5=P(r=>{async function*e(t,n={}){for await(let{path:i,recursive:s}of ra(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:N({...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 cJ=r=>{let e=W5(r);return P(()=>{async function t(n,i={}){return Xt(e([{path:n,...i}],i))}return t})(r)};u();u();u();var j5=({Name:r,Status:e,Cid:t})=>({cid:A.parse(t),name:r,status:e}),uJ=r=>{if(typeof r=="string"&&r!=="")return r;throw new TypeError("service name must be passed")},lJ=r=>{if(A.asCID(r))return r.toString();throw new TypeError(`CID instance expected instead of ${typeof r}`)},B0=({service:r,cid:e,name:t,status:n,all:i})=>{let s=N({service:uJ(r),name:t,force:i?!0:void 0});if(e)for(let o of e)s.append("cid",lJ(o));if(n)for(let o of n)s.append("status",o);return s},fJ=({cid:r,service:e,background:t,name:n,origins:i})=>{let s=N({arg:lJ(r),service:uJ(e),name:n,background:t?!0:void 0});if(i)for(let o of i)s.append("origin",o.toString());return s};function hJ(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:fJ({cid:t,...o})});return j5(await a.json())}return e}u();function dJ(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:B0(s)});for await(let a of o.ndjson())yield j5(a)}return e}u();function pJ(r){async function e({timeout:t,signal:n,headers:i,...s}){await r.post("pin/remote/rm",{timeout:t,signal:n,headers:i,searchParams:B0({...s,all:!1})})}return e}u();function mJ(r){async function e({timeout:t,signal:n,headers:i,...s}){await r.post("pin/remote/rm",{timeout:t,signal:n,headers:i,searchParams:B0({...s,all:!0})})}return e}u();u();u();function yJ(r){let e=String(r);if(e==="undefined")throw Error("endpoint is required");return e[e.length-1]==="/"?e.slice(0,-1):e}function gJ(r){return{service:r.Service,endpoint:new URL(r.ApiEndpoint),...r.Stat&&{stat:ave(r.Stat)}}}function ave(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 wJ(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:N({arg:[t,yJ(i),s]}),headers:o})}return e}u();function EJ(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?N({stat:n}):void 0}),{RemoteServices:c}=await a.json();return c.map(gJ)}return e}u();function bJ(r){async function e(t,n={}){await r.post("pin/remote/service/rm",{signal:n.signal,headers:n.headers,searchParams:N({arg:t})})}return e}function _J(r){let e=new ql(r);return{add:wJ(e),ls:EJ(e),rm:bJ(e)}}function vJ(r){let e=new ql(r);return{add:hJ(e),ls:dJ(e),rm:pJ(e),rmAll:mJ(e),service:_J(r)}}function SJ(r){return{addAll:G5(r),add:sJ(r),ls:aJ(r),rmAll:W5(r),rm:cJ(r),remote:vJ(r)}}u();u();u();var xJ=r=>Array.isArray(r)?r.map(Y5):r,Y5=r=>K(M0(r)),M0=r=>mu.decode(r),TJ=r=>BigInt(`0x${K(mu.decode(r),"base16")}`),U0=r=>mu.encode(z(r));var IJ=P(r=>{async function e(t={}){let{Strings:n}=await(await r.post("pubsub/ls",{signal:t.signal,searchParams:N(t),headers:t.headers})).json();return xJ(n)||[]}return e});u();var AJ=P(r=>{async function e(t,n={}){let i=await r.post("pubsub/peers",{signal:n.signal,searchParams:N({arg:U0(t),...n}),headers:n.headers}),{Strings:s}=await i.json();return s||[]}return e});u();var RJ=P(r=>{async function e(t,n,i={}){let s=N({arg:U0(t),...i}),o=new AbortController,a=un(o.signal,i.signal);await(await r.post("pubsub/pub",{signal:a,searchParams:s,...await cn([n],o,i.headers)})).text()}return e});u();var cve=D("ipfs-http-client:pubsub:subscribe"),CJ=(r,e)=>P(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:N({arg:U0(i),...o}),headers:o.headers}).catch(h=>{e.unsubscribe(i,s),c(h)}).then(h=>{clearTimeout(f),h&&(uve(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 uve(r,{onMessage:e,onEnd:t,onError:n}){n=n||cve;try{for await(let i of r.ndjson())try{if(!i.from)continue;i.from!=null&&i.seqno!=null?e({type:"signed",from:ce(i.from),data:M0(i.data),sequenceNumber:TJ(i.seqno),topic:Y5(i.topicIDs[0]),key:M0(i.key??"u"),signature:M0(i.signature??"u")}):e({type:"unsigned",data:M0(i.data),topic:Y5(i.topicIDs[0])})}catch(s){s.message=`Failed to parse pubsub message: ${s.message}`,n(s,!1,i)}}catch(i){lve(i)||n(i,!0)}finally{t()}}var lve=r=>{switch(r.type){case"aborted":return!0;case"abort":return!0;default:return r.name==="AbortError"}};u();var DJ=(r,e)=>{async function t(n,i){e.unsubscribe(n,i)}return t};u();var Q5=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 PJ(r){let e=new Q5;return{ls:IJ(r),peers:AJ(r),publish:RJ(r),subscribe:CJ(r,e),unsubscribe:DJ(r,e)}}u();u();var kJ=P(r=>{async function*e(t={}){yield*(await r.post("refs/local",{signal:t.signal,transform:mt,searchParams:N(t),headers:t.headers})).ndjson()}return e});var NJ=P((r,e)=>Object.assign(async function*(n,i={}){let s=Array.isArray(n)?n:[n];yield*(await r.post("refs",{signal:i.signal,searchParams:N({arg:s.map(a=>`${a instanceof Uint8Array?A.decode(a):a}`),...i}),headers:i.headers,transform:mt})).ndjson()},{local:kJ(e)}));u();u();var OJ=P(r=>{async function*e(t={}){yield*(await r.post("repo/gc",{signal:t.signal,searchParams:N(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 X5=P(r=>{async function e(t={}){let i=await(await r.post("repo/stat",{signal:t.signal,searchParams:N(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 LJ=P(r=>{async function e(t={}){return(await(await r.post("repo/version",{signal:t.signal,searchParams:N(t),headers:t.headers})).json()).Version}return e});function BJ(r){return{gc:OJ(r),stat:X5(r),version:LJ(r)}}u();u();var MJ=P(r=>{async function*e(t={}){yield*(await r.post("stats/bw",{signal:t.signal,searchParams:N(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 UJ(r){return{bitswap:z5(r),repo:X5(r),bw:MJ(r)}}u();u();var FJ=P(r=>{async function e(t={}){let n=await r.post("swarm/addrs",{signal:t.signal,searchParams:N(t),headers:t.headers}),{Addrs:i}=await n.json();return Object.keys(i).map(s=>({id:ce(s),addrs:(i[s]||[]).map(o=>ee(o))}))}return e});u();var VJ=P(r=>{async function e(t,n={}){let i=await r.post("swarm/connect",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers}),{Strings:s}=await i.json();return s||[]}return e});u();var KJ=P(r=>{async function e(t,n={}){let i=await r.post("swarm/disconnect",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers}),{Strings:s}=await i.json();return s||[]}return e});u();var zJ=P(r=>{async function e(t={}){let n=await r.post("swarm/addrs/local",{signal:t.signal,searchParams:N(t),headers:t.headers}),{Strings:i}=await n.json();return(i||[]).map(s=>ee(s))}return e});u();var qJ=P(r=>{async function e(t={}){let n=await r.post("swarm/peers",{signal:t.signal,searchParams:N(t),headers:t.headers}),{Peers:i}=await n.json();return(i||[]).map(s=>({addr:ee(s.Addr),peer:ce(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 $J(r){return{addrs:FJ(r),connect:VJ(r),disconnect:KJ(r),localAddrs:zJ(r),peers:qJ(r)}}u();u();var Z5=P(r=>{async function*e(t,n={}){let i=new AbortController,s=un(i.signal,n.signal),{headers:o,body:a,total:c,parts:l}=await cn(t,i,n.headers),[f,h]=typeof n.progress=="function"?fve(c,l,n.progress):[void 0,void 0],p=await r.post("add",{searchParams:N({"stream-channels":!0,...n,progress:Boolean(f)}),onUploadProgress:h,signal:s,headers:o,body:a});for await(let d of p.ndjson())d=mt(d),d.hash!==void 0?yield dve(d):f&&f(d.bytes||0,d.name)}return e}),fve=(r,e,t)=>e?[void 0,hve(r,e,t)]:[t,void 0],hve=(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 dve({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}function HJ(r){let e=Z5(r);return P(()=>{async function t(n,i={}){return await Xt(e(j6(n),i))}return t})(r)}u();var GJ=P(r=>{async function*e(t,n={}){yield*(await r.post("cat",{signal:n.signal,searchParams:N({arg:t.toString(),...n}),headers:n.headers})).iterator()}return e});u();var WJ=P(r=>async(t={})=>(await r.post("commands",{signal:t.signal,searchParams:N(t),headers:t.headers})).json());u();var jJ=P(r=>async(t,n={})=>(await(await r.post("dns",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers})).json()).Path);u();var YJ=P(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 QJ=P(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:N(i),headers:n.headers})).iterator()}return e});u();var J5=P(r=>{async function e(t={}){let i=await(await r.post("id",{signal:t.signal,searchParams:N({arg:t.peerId?t.peerId.toString():void 0,...t}),headers:t.headers})).json(),s={...mt(i)};return s.id=ce(s.id),s.addresses&&(s.addresses=s.addresses.map(o=>ee(o))),s}return e});u();var XJ=r=>{let e=J5(r);async function t(n={}){let i=await e(n);return Boolean(i&&i.addresses&&i.addresses.length)}return t};u();var ZJ=P((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 H5(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:pve(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:N({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 pve(r){switch(r.Type){case 1:case 5:return"dir";case 2:return"file";default:return"file"}}u();var JJ=P(r=>{async function e(t={}){let n=await r.post("dns",{signal:t.signal,searchParams:N(t),headers:t.headers});return mt(await n.json())}return e});u();var eee=P(r=>{async function*e(t,n={}){yield*(await r.post("ping",{signal:n.signal,searchParams:N({arg:`${t}`,...n}),headers:n.headers,transform:mt})).ndjson()}return e});u();var tee=P(r=>{async function e(t,n={}){let i=await r.post("resolve",{signal:n.signal,searchParams:N({arg:t,...n}),headers:n.headers}),{Path:s}=await i.json();return s}return e});u();var ree=_(V(),1),nee=P(r=>async(t={})=>{throw(0,ree.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});u();var iee=P(r=>{async function e(t={}){await(await r.post("shutdown",{signal:t.signal,searchParams:N(t),headers:t.headers})).text()}return e});u();var see=P(r=>{async function e(t={}){let n=await r.post("version",{signal:t.signal,searchParams:N(t),headers:t.headers});return{...mt(await n.json()),"ipfs-http-client":"1.0.0"}}return e});var wve=_(xR(),1),Eve=_(TR(),1);function aee(r={}){let e={name:rn.name,code:rn.code,encode:l=>l,decode:l=>l},t=Object.values(_s);(r.ipld&&r.ipld.bases?r.ipld.bases:[]).forEach(l=>t.push(l));let n=new N0({bases:t,loadBase:r.ipld&&r.ipld.loadBase}),i=Object.values(r4);[gt,tc,Ud,K1,e].concat(r.ipld&&r.ipld.codecs||[]).forEach(l=>i.push(l));let s=new O0({codecs:i,loadCodec:r.ipld&&r.ipld.loadCodec}),o=Object.values(t4);(r.ipld&&r.ipld.hashers?r.ipld.hashers:[]).forEach(l=>o.push(l));let a=new L0({hashers:o,loadHasher:r.ipld&&r.ipld.loadHasher});return{add:HJ(r),addAll:Z5(r),bitswap:vX(r),block:kX(r),bootstrap:UX(r),cat:GJ(r),commands:WJ(r),config:GX(r),dag:ZX(s,r),dht:sZ(r),diag:uZ(r),dns:jJ(r),files:TZ(r),get:QJ(r),getEndpointConfig:YJ(r),id:J5(r),isOnline:XJ(r),key:LZ(r),log:FZ(r),ls:ZJ(r),mount:JJ(r),name:GZ(r),object:iJ(s,r),pin:SJ(r),ping:eee(r),pubsub:PJ(r),refs:NJ(r),repo:BJ(r),resolve:tee(r),start:nee(r),stats:UJ(r),stop:iee(r),swarm:$J(r),version:see(r),bases:n,codecs:s,hashers:a}}u();u();u();var yg=_(V(),1);u();u();var Yee=_(V(),1);u();u();u();u();u();u();u();u();u();u();var No=Object.create(null);No.open="0";No.close="1";No.ping="2";No.pong="3";No.message="4";No.upgrade="5";No.noop="6";var ig=Object.create(null);Object.keys(No).forEach(r=>{ig[No[r]]=r});var cee={type:"error",data:"parser error"};var bve=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",_ve=typeof ArrayBuffer=="function",vve=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer,Sve=({type:r,data:e},t,n)=>bve&&e instanceof Blob?t?n(e):uee(e,n):_ve&&(e instanceof ArrayBuffer||vve(e))?t?n(e):uee(new Blob([e]),n):n(No[r]+(e||"")),uee=(r,e)=>{let t=new FileReader;return t.onload=function(){let n=t.result.split(",")[1];e("b"+n)},t.readAsDataURL(r)},eE=Sve;u();u();var lee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sg=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let r=0;r<lee.length;r++)sg[lee.charCodeAt(r)]=r;var fee=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=sg[r.charCodeAt(n)],o=sg[r.charCodeAt(n+1)],a=sg[r.charCodeAt(n+2)],c=sg[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 xve=typeof ArrayBuffer=="function",Tve=(r,e)=>{if(typeof r!="string")return{type:"message",data:hee(r,e)};let t=r.charAt(0);return t==="b"?{type:"message",data:Ive(r.substring(1),e)}:ig[t]?r.length>1?{type:ig[t],data:r.substring(1)}:{type:ig[t]}:cee},Ive=(r,e)=>{if(xve){let t=fee(r);return hee(t,e)}else return{base64:!0,data:r}},hee=(r,e)=>{switch(e){case"blob":return r instanceof ArrayBuffer?new Blob([r]):r;case"arraybuffer":default:return r}},tE=Tve;var dee=String.fromCharCode(30),pee=(r,e)=>{let t=r.length,n=new Array(t),i=0;r.forEach((s,o)=>{eE(s,!1,a=>{n[o]=a,++i===t&&e(n.join(dee))})})},mee=(r,e)=>{let t=r.split(dee),n=[];for(let i=0;i<t.length;i++){let s=tE(t[i],e);if(n.push(s),s.type==="error")break}return n},IR=4;u();function rr(r){if(r)return Ave(r)}function Ave(r){for(var e in rr.prototype)r[e]=rr.prototype[e];return r}rr.prototype.on=rr.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};rr.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};rr.prototype.off=rr.prototype.removeListener=rr.prototype.removeAllListeners=rr.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};rr.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};rr.prototype.emitReserved=rr.prototype.emit;rr.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};rr.prototype.hasListeners=function(r){return!!this.listeners(r).length};u();u();var Vs=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function rE(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var Rve=setTimeout,Cve=clearTimeout;function Hc(r,e){e.useNativeTimers?(r.setTimeoutFn=Rve.bind(Vs),r.clearTimeoutFn=Cve.bind(Vs)):(r.setTimeoutFn=setTimeout.bind(Vs),r.clearTimeoutFn=clearTimeout.bind(Vs))}var Dve=1.33;function yee(r){return typeof r=="string"?Pve(r):Math.ceil((r.byteLength||r.size)*Dve)}function Pve(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 AR=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}},qh=class extends rr{constructor(e){super(),this.writable=!1,Hc(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new AR(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=tE(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}};u();var bee="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),RR=64,kve={},gee=0,nE=0,wee;function Eee(r){let e="";do e=bee[r%RR]+e,r=Math.floor(r/RR);while(r>0);return e}function iE(){let r=Eee(+new Date);return r!==wee?(gee=0,wee=r):r+"."+Eee(gee++)}for(;nE<RR;nE++)kve[bee[nE]]=nE;u();function sE(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function _ee(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 vee=!1;try{vee=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var See=vee;function CR(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||See))return new XMLHttpRequest}catch{}if(!e)try{return new Vs[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Nve(){}var Ove=function(){return new CR({xdomain:!1}).responseType!=null}(),oE=class extends qh{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=Ove&&!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)};mee(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,pee(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=sE(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 Ks(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}},Ks=class extends rr{constructor(e,t){super(),Hc(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=rE(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 CR(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=Ks.requestsCount++,Ks.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=Nve,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Ks.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()}};Ks.requestsCount=0;Ks.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",xee);else if(typeof addEventListener=="function"){let r="onpagehide"in Vs?"pagehide":"unload";addEventListener(r,xee,!1)}}function xee(){for(let r in Ks.requests)Ks.requests.hasOwnProperty(r)&&Ks.requests[r].abort()}u();u();var og=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),ag=Vs.WebSocket||Vs.MozWebSocket,aE=!0,Tee="arraybuffer";var Iee=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",cE=class extends qh{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=Iee?{}:rE(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=aE&&!Iee?t?new ag(e,t):new ag(e):new ag(e,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType||Tee,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;eE(n,this.supportsBinary,s=>{let o={};aE||(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{aE?this.ws.send(s):this.ws.send(s,o)}catch{}i&&og(()=>{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=sE(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!!ag}};var DR={websocket:cE,polling:oE};u();var Lve=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Bve=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function F0(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=Lve.exec(r||""),s={},o=14;for(;o--;)s[Bve[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=Mve(s,s.path),s.queryKey=Uve(s,s.query),s}function Mve(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Uve(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,s){i&&(t[i]=s)}),t}var ss=class extends rr{constructor(e,t={}){super(),e&&typeof e=="object"&&(t=e,e=null),e?(e=F0(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=F0(t.host).host),Hc(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=_ee(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!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=IR,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 DR[e](n)}open(){let e;if(this.opts.rememberUpgrade&&ss.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;ss.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;ss.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",ss.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+=yee(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){ss.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("beforeunload",this.beforeunloadEventListener,!1),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}};ss.protocol=IR;var lAt=ss.protocol;function Aee(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=F0(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 LR={};Re(LR,{Decoder:()=>lg,Encoder:()=>NR,PacketType:()=>Et,protocol:()=>Pee});u();u();u();var Fve=typeof ArrayBuffer=="function",Vve=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Ree=Object.prototype.toString,Kve=typeof Blob=="function"||typeof Blob<"u"&&Ree.call(Blob)==="[object BlobConstructor]",zve=typeof File=="function"||typeof File<"u"&&Ree.call(File)==="[object FileConstructor]";function ug(r){return Fve&&(r instanceof ArrayBuffer||Vve(r))||Kve&&r instanceof Blob||zve&&r instanceof File}function cg(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if(cg(r[t]))return!0;return!1}if(ug(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return cg(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&cg(r[t]))return!0;return!1}function Cee(r){let e=[],t=r.data,n=r;return n.data=PR(t,e),n.attachments=e.length,{packet:n,buffers:e}}function PR(r,e){if(!r)return r;if(ug(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]=PR(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]=PR(r[n],e));return t}return r}function Dee(r,e){return r.data=kR(r.data,e),r.attachments=void 0,r}function kR(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]=kR(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=kR(r[t],e));return r}var Pee=5,Et;(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"})(Et||(Et={}));var NR=class{constructor(e){this.replacer=e}encode(e){return(e.type===Et.EVENT||e.type===Et.ACK)&&cg(e)?(e.type=e.type===Et.EVENT?Et.BINARY_EVENT:Et.BINARY_ACK,this.encodeAsBinary(e)):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===Et.BINARY_EVENT||e.type===Et.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=Cee(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}},lg=class extends rr{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===Et.BINARY_EVENT||t.type===Et.BINARY_ACK?(this.reconstructor=new OR(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ug(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(Et[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Et.BINARY_EVENT||n.type===Et.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(lg.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 Et.CONNECT:return typeof t=="object";case Et.DISCONNECT:return t===void 0;case Et.CONNECT_ERROR:return typeof t=="string"||typeof t=="object";case Et.EVENT:case Et.BINARY_EVENT:return Array.isArray(t)&&t.length>0;case Et.ACK:case Et.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}},OR=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=Dee(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};u();function os(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var qve=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),V0=class extends rr{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=[os(e,"open",this.onopen.bind(this)),os(e,"packet",this.onpacket.bind(this)),os(e,"error",this.onerror.bind(this)),os(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(qve.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');t.unshift(e);let n={type:Et.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:Et.CONNECT,data:e})}):this.packet({type:Et.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 Et.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 Et.EVENT:case Et.BINARY_EVENT:this.onevent(e);break;case Et.ACK:case Et.BINARY_ACK:this.onack(e);break;case Et.DISCONNECT:this.ondisconnect();break;case Et.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:Et.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:Et.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 $h(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}$h.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};$h.prototype.reset=function(){this.attempts=0};$h.prototype.setMin=function(r){this.ms=r};$h.prototype.setMax=function(r){this.max=r};$h.prototype.setJitter=function(r){this.jitter=r};var K0=class extends rr{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,Hc(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 $h({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||LR;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 ss(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let i=os(t,"open",function(){n.onopen(),e&&e()}),s=os(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(os(e,"ping",this.onping.bind(this)),os(e,"data",this.ondata.bind(this)),os(e,"error",this.onerror.bind(this)),os(e,"close",this.onclose.bind(this)),os(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){og(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n||(n=new V0(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 fg={};function hg(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=Aee(r,e.path||"/socket.io"),n=t.source,i=t.id,s=t.path,o=fg[i]&&s in fg[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?c=new K0(n,e):(fg[i]||(fg[i]=new K0(n,e)),c=fg[i]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(hg,{Manager:K0,Socket:V0,io:hg,connect:hg});u();u();u();var dg=_(V(),1),Uee=_(uE(),1);u();var Oee=_(V(),1);var Nee=64*1024,Hve=5*1e3,lE=class{constructor(e,t){this.label=e.label,this.open=Lt(),this.channel=e,this.channel.binaryType="arraybuffer",this.log=t.log,typeof this.channel.bufferedAmountLowThreshold=="number"&&(this.channel.bufferedAmountLowThreshold=Nee),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,Oee.default)(s,"ERR_DATA_CHANNEL"))});let n=!1;this.closingInterval=setInterval(()=>{e.readyState==="closing"?(n&&t.onClose(),n=!0):n=!1},Hve)}async send(e){await this.open.promise,this.channel.send(e),this.channel.bufferedAmount>Nee&&(this.log("start backpressure: bufferedAmount %d",this.channel.bufferedAmount),this.open=Lt())}close(){clearInterval(this.closingInterval),this.channel.close()}get bufferedAmount(){return this.channel.bufferedAmount}};var Fee=_(UR(),1),Wve={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}]};function jve(){if(typeof globalThis>"u")throw(0,dg.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,dg.default)(new Error("No WebRTC support detected"),"ERR_WEBRTC_SUPPORT");return r}var Hh=class extends Fe{constructor(e){super(),this.id=e.id??K((0,Uee.default)(4),"hex").slice(0,7),this.log=D(`libp2p:webrtc-peer:${e.logPrefix}:${this.id}`),this.wrtc=e.wrtc??jve(),this.peerConnection=new this.wrtc.RTCPeerConnection(Object.assign({},Wve,e.peerConnectionConfig)),this.closed=!1,this.connected=Lt(),this.source=Vt(),this.sink=async t=>{if(await this.connected.promise,this.channel==null)throw(0,dg.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,dg.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 lE(t,{log:this.log,onMessage:n=>{this.source.push(new Uint8Array(n.data))},onOpen:()=>{this.connected.resolve(),this.dispatchEvent(new J("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,Fee.default)(100);this.channel?.close(),this.peerConnection.close(),this.source.end(e),this.dispatchEvent(new J("close"))}};u();var Vee=_(V(),1),z0=class extends Fe{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,Vee.default)(n,"ERR_ADD_ICE_CANDIDATE")}}};var Kee=D("libp2p:webrtc-peer:receiver"),pg=class extends Hh{constructor(e={}){super({...e,logPrefix:"receiver"}),this.handshake=new FR({log:this.log,peerConnection:this.peerConnection,wrtc:this.wrtc,answerOptions:e.answerOptions}),this.handshake.addEventListener("signal",t=>this.dispatchEvent(new J("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)})}},FR=class extends z0{constructor(e){super(e),this.options=e,this.status="idle",this.iceCandidates=[]}async handleRenegotiate(){Kee.trace("renegotiate"),this.dispatchEvent(new J("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),Kee.trace("handle offer",this.peerConnection.localDescription),this.dispatchEvent(new J("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 Hee=_(uE(),1);u();u();var fE=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},VR=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},zee=r=>globalThis.DOMException===void 0?new VR(r):new DOMException(r),qee=r=>{let e=r.reason===void 0?zee("This operation was aborted."):r.reason;return e instanceof Error?e:zee(e)};function KR(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(qee(c)),c.addEventListener("abort",()=>{a(qee(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 fE(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 Yve=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 Qve(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}=Yve(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=KR(i,t.timeout);return s.cancel=n,s}return i}function $ee(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=Qve(r,e,t),i=n.then(s=>s[0]);return i.cancel=n.cancel,i}var Gee=_(UR(),1);var zR=D("libp2p:webrtc-peer:initator"),Xve=1e3,mg=class extends Hh{constructor(e={}){super({...e,logPrefix:"initiator"}),this.handleDataChannelEvent({channel:this.peerConnection.createDataChannel(e.dataChannelLabel??K((0,Hee.default)(20),"hex").slice(0,7),e.dataChannelInit)}),this.handshake=new qR({log:this.log,peerConnection:this.peerConnection,wrtc:this.wrtc,offerOptions:e.offerOptions}),this.handshake.addEventListener("signal",t=>{this.dispatchEvent(new J("signal",{detail:t.detail}))})}handleSignal(e){this.handshake.handleSignal(e).catch(t=>{this.log("error handling signal %o %o",e,t)})}},qR=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 J("signal",{detail:n})),this.dispatchEvent(new J("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 $ee(this,"ice-candidate"),await(0,Gee.default)(Xve),zR.trace("renegotiate",this.peerConnection.localDescription),this.dispatchEvent(new J("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 $R=D("libp2p:webrtc-star:socket");function hE(r,e){let{sink:t,source:n}=r,i={remoteAddr:e.remoteAddr,async sink(s){e.signal!=null&&(s=Mr(s,e.signal));try{await t(s)}catch(o){o.type!=="aborted"&&$R.error(o)}},source:e.signal!=null?Mr(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();$R("timeout closing socket to %s:%s after %dms, destroying it manually",a,c,Date.now()-s)}r.closed||r.close().catch(a=>{$R.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 dE(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(!NL(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 Wee(r){let e="/libp2p-webrtc-star";if(r.startsWith(e)){r=r.substring(e.length,r.length);let t=ee(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 Jn=D("libp2p:webrtc-star:listener"),Jve={transports:["websocket"],path:"/socket.io-next/"},HR=class extends Fe{constructor(e,t,n,i,s){super(),this.signallingAddr=t,this.socket=hg(e,Jve),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 J("error",{detail:a}))}),this.socket.on("error",a=>{this.dispatchEvent(new J("error",{detail:a}))}),this.socket.on("ws-handshake",this.handleWsHandshake),this.socket.on("ws-peer",a=>{this.dispatchEvent(new J("peer",{detail:a}))}),this.socket.on("connect",()=>{this.socket.emit("ss-join",this.signallingAddr.toString()),o&&this.dispatchEvent(new J("reconnect"))}),this.socket.once("connect",()=>{o=!0,this.dispatchEvent(new J("listening"))}),this.socket.on("disconnect",()=>{this.dispatchEvent(new J("disconnect"))})}_createChannel(e,t,n){let i={...this.channelOptions},s=new pg(i),o=a=>{let c=a.detail;Jn.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=hE(s,{remoteAddr:this.signallingAddr});Jn("new inbound connection %s",a.remoteAddr);try{this.upgrader.upgradeInbound(a).then(c=>{Jn("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 J("connection",{detail:c})),this.handler(c)}).catch(c=>{Jn.error("inbound connection failed to upgrade",c),a.close().catch(l=>{Jn.error("inbound connection failed to close after failing to upgrade",l)})})}catch(c){Jn.error("inbound connection failed to upgrade",c),a.close().catch(l=>{Jn.error("inbound connection failed to close after failing to upgrade",l)})}},{once:!0}),s}handleWsHandshake(e){if(Jn('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"){Jn("handshake is not an offer and channel does not exist, buffering until we receive an offer");return}Jn("creating new channel to handle offer handshake"),i=this._createChannel(e.intentId,e.srcMultiaddr,e.dstMultiaddr),this.channels.set(t,i)}else Jn("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 J("close"))}},GR=class extends Fe{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,Yee.default)(new Error("listener already in use"),"ERR_ALREADY_LISTENING");let t=Lt();this.listeningAddr=e;let n;e.protoCodes().includes(421)?n=e:n=e.encapsulate(`/p2p/${this.peerId.toString()}`);let i=this.signallingUrl=dE(e);Jn("connecting to signalling server on: %s",this.signallingUrl);let s=new HR(this.signallingUrl,n,this.upgrader,this.handler,this.options.channelOptions);return s.addEventListener("error",o=>{let a=o.detail;Jn("error connecting to signalling server %o",a),s.close().catch(c=>{Jn.error("error closing server after error",c)}),t.reject(a)}),s.addEventListener("listening",()=>{Jn("connected to signalling server"),this.dispatchEvent(new J("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){Jn.error("could not determine remote address",c)}this.dispatchEvent(new J("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 J("close")),this.listeningAddr=void 0}getAddrs(){return this.listeningAddr!=null?[this.listeningAddr]:[]}};function Qee(r,e,t,n,i){return new GR(r,e,t,n,i)}var Xee=_(uE(),1);u();u();function Gc(r,e){if(r.length!==e.length)throw new Error("Inputs should have the same length");let t=so(r.length);for(let n=0;n<r.length;n++)t[n]=r[n]^e[n];return ic(t)}u();var q0=Symbol.for("@libp2p/transport");u();var La=Symbol.for("@libp2p/peer-discovery");var t9e="RTCPeerConnection"in globalThis,Gh=D("libp2p:webrtc-star"),r9e=()=>{},WR=class extends Fe{constructor(){super(...arguments),this.started=!1}get[La](){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}},pE=class{constructor(e){e?.wrtc!=null&&(this.wrtc=e.wrtc),this.sigServers=new Map,this._discovery=new WR,this.discovery=()=>this._discovery,this.peerDiscovered=this.peerDiscovered.bind(this)}get[q0](){return!0}get[Symbol.toStringTag](){return"@libp2p/webrtc-star"}async dial(e,t){let n=await this._connect(e,t),i=hE(n,{remoteAddr:e,signal:t.signal});Gh("new outbound connection %s",i.remoteAddr);let s=await t.upgrader.upgradeOutbound(i);return Gh("outbound connection %s upgraded",i.remoteAddr),s}async _connect(e,t){if(t.signal?.aborted===!0)throw new Ml;let n={...t.channelOptions??{}};this.wrtc!=null&&(n.wrtc=this.wrtc);let i=e.toOptions(),s=K((0,Xee.default)(36),"hex");return await new Promise((o,a)=>{let c=this.sigServers.get(dE(e));if(c?.socket==null)return a((0,yg.default)(new Error("unknown signal server to use"),"ERR_UNKNOWN_SIGNAL_SERVER"));let l=!1;Gh("dialing %s:%s",i.host,i.port);let f=new mg(n),h=y=>{let g=y.detail;if(!l){let w=`connection error ${i.host}:${i.port}: ${g.message}`;Gh.error(w),m(g)}},p=()=>{l=!0,Gh("connection opened %s:%s",i.host,i.port),m()},d=()=>{Gh.error("connection aborted %s:%s",i.host,i.port),f.close().finally(()=>{m(new Ml)})},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,yg.default)(new Error(y.err),"ERR_SIGNALLING_FAILED"))}),!(y.intentId!==s||y.answer==null||f.closed)&&f.handleSignal(y.signal)})})}createListener(e){if(!t9e&&this.wrtc==null)throw(0,yg.default)(new Error("no WebRTC support"),"ERR_NO_WEBRTC_SUPPORT");if(e.channelOptions=e.channelOptions??{},this.wrtc!=null&&(e.channelOptions.wrtc=this.wrtc),this.peerId==null)throw(0,yg.default)(new Error("PeerId not set"),"ERR_MISSING_PEER_ID");return Qee(e.upgrader,e.handler??r9e,this.peerId,this,e)}filter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>t.protoCodes().includes(290)?!1:d4.matches(t))}peerDiscovered(e){Gh("peer discovered: %s",e),e=Wee(e);let t=ee(e),n=t.getPeerId();if(n==null)return;let i=ce(n);this._discovery.dispatchEvent(new J("peer",{detail:{id:i,multiaddrs:[t],protocols:[]}}))}};function Zee(r={}){let e=new pE(r);return{transport:t=>(e.peerId=t.peerId,e),discovery:e.discovery}}function Jee(){let r=Zee();return{transports:[r.transport],peerDiscovery:[r.discovery],connectionManager:{maxParallelDials:150,maxDialsPerPeer:4,dialTimeout:1e4,autoDial:!0},nat:{enabled:!1},metrics:{enabled:!0}}}u();u();u();var wg=_(V(),1);u();var ht;(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"})(ht||(ht={}));var U;(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",r.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED"})(U||(U={}));u();var ete=_(V(),1);async function*gg(r,e){yield*dr(r,async t=>(await e.addressBook.add(t.id,t.multiaddrs),t))}function mE(r){let e=new Set;return Dn(r,t=>e.has(t.id.toString())?!1:(e.add(t.id.toString()),!0))}async function*yE(r,e=1){let t=0;for await(let n of r)t++,yield n;if(t<e)throw(0,ete.default)(new Error("not found"),"NOT_FOUND")}var nte=_(pn(),1);var wE=_(jR(),1),ite=_(qn(),1),rte=D("libp2p:peer-routing"),gE=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,wE.setDelayedInterval)(this._findClosestPeersTask,this.refreshManagerInit.interval,this.refreshManagerInit.bootDelay),this.started=!0)}async _findClosestPeersTask(){if(this.abortController==null)try{this.abortController=new nte.TimeoutController(this.refreshManagerInit.timeout??1e4);try{(0,ite.setMaxListeners)?.(1/0,this.abortController.signal)}catch{}await yn(this.getClosestPeers(this.components.peerId.toBytes(),{signal:this.abortController.signal}))}catch(e){rte.error(e)}finally{this.abortController?.clear(),this.abortController=void 0}}async stop(){(0,wE.clearDelayedInterval)(this.timeoutId),this.abortController?.abort(),this.started=!1}async findPeer(e,t){if(this.routers.length===0)throw(0,wg.default)(new Error("No peer routers available"),U.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.peerId.toString())throw(0,wg.default)(new Error("Should not try to find self"),U.ERR_FIND_SELF);let n=await de(To(...this.routers.map(i=>async function*(){try{yield await i.findPeer(e,t)}catch(s){rte.error(s)}}())),i=>Dn(i,Boolean),i=>gg(i,this.components.peerStore),async i=>await kn(i));if(n!=null)return n;throw(0,wg.default)(new Error(ht.NOT_FOUND),U.ERR_NOT_FOUND)}async*getClosestPeers(e,t){if(this.routers.length===0)throw(0,wg.default)(new Error("No peer routers available"),U.ERR_NO_ROUTERS_AVAILABLE);yield*de(To(...this.routers.map(n=>n.getClosestPeers(e,t))),n=>gg(n,this.components.peerStore),n=>mE(n),n=>yE(n))}};u();var $l=_(V(),1);var EE=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,$l.default)(new Error("No content this.routers available"),U.ERR_NO_ROUTERS_AVAILABLE);yield*de(To(...this.routers.map(n=>n.findProviders(e,t))),n=>gg(n,this.components.peerStore),n=>mE(n),n=>yE(n))}async provide(e,t={}){if(this.routers.length===0)throw(0,$l.default)(new Error("No content routers available"),U.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,$l.default)(new Error(ht.NOT_STARTED_YET),U.DHT_NOT_STARTED);let i=this.components.dht;i!=null&&await yn(i.put(e,t,n))}async get(e,t){if(!this.isStarted())throw(0,$l.default)(new Error(ht.NOT_STARTED_YET),U.DHT_NOT_STARTED);let n=this.components.dht;if(n!=null){for await(let i of n.get(e,t))if(i.name==="VALUE")return i.value}throw(0,$l.default)(new Error(ht.NOT_FOUND),U.ERR_NOT_FOUND)}async*getMany(e,t,n){if(!this.isStarted())throw(0,$l.default)(new Error(ht.NOT_STARTED_YET),U.DHT_NOT_STARTED);if(t==null||t===0)return;let i=0,s=this.components.dht;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,$l.default)(new Error(ht.NOT_FOUND),U.ERR_NOT_FOUND)}};u();var YR=_(V(),1);function a9e(r){let e=r.getPeerId();if(e==null)throw(0,YR.default)(new Error(`${r.toString()} does not have a valid peer type`),U.ERR_INVALID_MULTIADDR);try{return ce(e)}catch{throw(0,YR.default)(new Error(`${r.toString()} is not a valid peer type`),U.ERR_INVALID_MULTIADDR)}}function Wh(r){if(vs(r))return{id:r,multiaddrs:[],protocols:[]};typeof r=="string"&&(r=ee(r));let e;return oc(r)&&(e=r,r=a9e(r)),{id:r,multiaddrs:e!=null?[e]:[],protocols:[]}}u();var c9e=r=>r,bE=class extends Fe{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??c9e}getListenAddrs(){return Array.from(this.listen).map(e=>ee(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>ee(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>ee(e))}confirmObservedAddr(e){}removeObservedAddr(e){}addObservedAddr(e){let t=ee(e),n=t.getPeerId();n!=null&&ce(n).equals(this.components.peerId)&&(t=t.decapsulate(ee(`/p2p/${this.components.peerId.toString()}`)));let i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new J("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(n=>n.toString());e.length===0&&(e=this.components.transportManager.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=>ee(n))).map(n=>n.getPeerId()===this.components.peerId.toString()?n:n.encapsulate(`/p2p/${this.components.peerId.toString()}`))}};u();var dC=_(V(),1);u();u();var ste=D("libp2p:connection-manager:latency-monitor:visibility-change-emitter"),_E=class extends Fe{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"?ste("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;ste(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new J("visibilityChange",{detail:e}))}};var Wc=D("libp2p:connection-manager:latency-monitor"),vE=class extends Fe{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,Wc("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),this.dataEmitIntervalMs!=null?Wc("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):Wc("Not emitting summaries"),this.asyncTestFn=i,globalThis.process?.hrtime!=null?(Wc("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?(Wc("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(Wc("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){u9e()&&(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 J("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(),Wc.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,Wc.trace("MS: %s Data: %O",i,this.latencyData)};Wc.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 u9e(){return typeof globalThis.window<"u"}var pC=_(z1(),1);var IE=_(qn(),1);u();var SE="OPEN",QR="CLOSING",xE="CLOSED";u();u();u();function jc(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 Eg=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 jc(this.map.entries(),e=>[ce(e[0]),e[1]])}forEach(e){this.map.forEach((t,n)=>{e(t,ce(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 jc(this.map.keys(),e=>ce(e))}values(){return this.map.values()}get size(){return this.map.size}};u();var Ai=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 jc(this.set.entries(),e=>{let t=ce(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=ce(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return jc(this.set.values(),e=>ce(e))}intersection(e){let t=new Ai;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new Ai;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new Ai;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};u();var H0=class{constructor(e){if(this.list=[],e!=null)for(let t of e)this.list.push(t.toString())}[Symbol.iterator](){return jc(this.list.entries(),e=>ce(e[1]))}concat(e){let t=new H0(this);for(let n of e)t.push(n);return t}entries(){return jc(this.list.entries(),e=>[e[0],ce(e[1])])}every(e){return this.list.every((t,n)=>e(ce(t),n,this))}filter(e){let t=new H0;return this.list.forEach((n,i)=>{let s=ce(n);e(s,i,this)&&t.push(s)}),t}find(e){let t=this.list.find((n,i)=>e(ce(n),i,this));if(t!=null)return ce(t)}findIndex(e){return this.list.findIndex((t,n)=>e(ce(t),n,this))}forEach(e){this.list.forEach((t,n)=>{e(ce(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 ce(e)}push(...e){for(let t of e)this.list.push(t.toString())}shift(){let e=this.list.shift();if(e!=null)return ce(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 mC=_(pn(),1);u();var ote="keep-alive";var tre=_(lC(),1),ln=D("libp2p:connection-manager"),G9e={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,inboundConnectionThreshold:5,maxIncomingPendingConnections:10},fC="libp2p",hC="connection-manager",W9e=6e4,AE=class extends Fe{constructor(e,t){if(super(),this.opts=ze.call({ignoreUndefined:!0},G9e,t),this.opts.maxConnections<this.opts.minConnections)throw(0,dC.default)(new Error("Connection Manager maxConnections must be greater than minConnections"),U.ERR_INVALID_PARAMETERS);ln("options: %o",this.opts),this.components=e,this.connections=new Map,this.started=!1,this._checkMetrics=this._checkMetrics.bind(this),this.latencyMonitor=new vE({latencyCheckIntervalMs:t.pollInterval,dataEmitIntervalMs:t.pollInterval});try{(0,IE.setMaxListeners)?.(1/0,this)}catch{}this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.startupReconnectTimeout=t.startupReconnectTimeout??W9e,this.dialTimeout=t.dialTimeout??3e4,this.allow=(t.allow??[]).map(n=>ee(n)),this.deny=(t.deny??[]).map(n=>ee(n)),this.inboundConnectionRateLimiter=new tre.RateLimiterMemory({points:this.opts.inboundConnectionThreshold,duration:1}),this.incomingPendingConnections=0}isStarted(){return this.started}async start(){this.components.metrics!=null&&(this.timer=this.timer??(0,pC.default)(this._checkMetrics,this.opts.pollInterval)),this.components.metrics?.updateComponentMetric({system:fC,component:hC,metric:"connections",label:"direction",value:()=>{let e={inbound:0,outbound:0};for(let t of this.connections.values())for(let n of t)n.stat.direction==="inbound"?e.inbound++:e.outbound++;return e}}),this.components.metrics?.updateComponentMetric({system:fC,component:hC,metric:"protocol-streams-total",label:"protocol",value:()=>{let e={};for(let t of this.connections.values())for(let n of t)for(let i of n.streams){let s=`${i.stat.direction} ${i.stat.protocol??"unnegotiated"}`;e[s]=(e[s]??0)+1}return e}}),this.components.metrics?.updateComponentMetric({system:fC,component:hC,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{let e={};for(let n of this.connections.values())for(let i of n){let s={};for(let o of i.streams){let a=`${o.stat.direction} ${o.stat.protocol??"unnegotiated"}`;s[a]=(s[a]??0)+1}for(let[o,a]of Object.entries(s))e[o]=e[o]??[],e[o].push(a)}let t={};for(let[n,i]of Object.entries(e)){i=i.sort((o,a)=>o-a);let s=Math.floor(i.length*.9);t[n]=i[s]}return t}}),this.latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this.latencyMonitor.addEventListener("data",this._onLatencyMeasure),this.started=!0,ln("started")}async afterStart(){this.components.upgrader.addEventListener("connection",this.onConnect),this.components.upgrader.addEventListener("connectionEnd",this.onDisconnect),Promise.resolve().then(async()=>{let e=[];for(let t of await this.components.peerStore.all())(await this.components.peerStore.getTags(t.id)).filter(s=>s.name===ote).length>0&&e.push(t.id);this.connectOnStartupController?.clear(),this.connectOnStartupController=new mC.TimeoutController(this.startupReconnectTimeout);try{(0,IE.setMaxListeners)?.(1/0,this.connectOnStartupController.signal)}catch{}await Promise.all(e.map(async t=>{await this.openConnection(t,{signal:this.connectOnStartupController?.signal}).catch(n=>{ln.error(n)})}))}).catch(e=>{ln.error(e)}).finally(()=>{this.connectOnStartupController?.clear()})}async beforeStop(){this.connectOnStartupController?.abort(),this.components.upgrader.removeEventListener("connection",this.onConnect),this.components.upgrader.removeEventListener("connectionEnd",this.onDisconnect)}async stop(){this.timer?.clear(),this.latencyMonitor.removeEventListener("data",this._onLatencyMeasure),this.latencyMonitor.stop(),this.started=!1,await this._close(),ln("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){ln.error(i)}})());ln("closing %d connections",e.length),await Promise.all(e),this.connections.clear()}async _checkMetrics(){let e=this.components.metrics;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),ln.trace("metrics update",s)}finally{this.timer=(0,pC.default)(this._checkMetrics,this.opts.pollInterval)}}onConnect(e){this._onConnect(e).catch(t=>{ln.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.peerStore.keyBook.set(n,n.publicKey);let o=this.getConnections().length,a=o-this.opts.maxConnections;await this._checkMaxLimit("maxConnections",o,a),this.dispatchEvent(new J("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 J("peer:disconnect",{detail:t})),this.components.metrics?.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={}){ln("dial to %p",e);let n=this.getConnections(e);if(n.length>0)return ln("had an existing connection to %p",e),n[0];let i;if(t?.signal==null){i=new mC.TimeoutController(this.dialTimeout),t.signal=i.signal;try{(0,IE.setMaxListeners)?.(1/0,i.signal)}catch{}}try{let s=await this.components.dialer.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(!vs(e))throw(0,dC.default)(new Error("peerId must be an instance of peer-id"),U.ERR_INVALID_PARAMETERS);let t=e.toString(),n=this.connections.get(t);return n!=null?n.filter(i=>i.stat.status===SE):[]}_onLatencyMeasure(e){let{detail:t}=e;this._checkMaxLimit("maxEventLoopDelay",t.avgMs,1).catch(n=>{ln.error(n)})}async _checkMaxLimit(e,t,n=1){let i=this.opts[e];ln.trace("checking limit of %s. current value: %d of %d",e,t,i),t>i&&(ln("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",this.components.peerId,e,t,i,n),await this._pruneConnections(n))}async _pruneConnections(e){let t=this.getConnections(),n=new Eg;for(let o of t){let a=o.remotePeer;if(n.has(a))continue;let c=await this.components.peerStore.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(ln("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){ln.error(a)}this.onDisconnect(new J("connectionEnd",{detail:o}))}))}async acceptIncomingConnection(e){if(this.deny.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return ln("connection from %s refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.opts.maxIncomingPendingConnections)return ln("connection from %s refused - incomingPendingConnections exceeded by peer %s",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){let i=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(i,1)}catch{return ln("connection from %s refused - inboundConnectionThreshold exceeded by host %s",i,e.remoteAddr),!1}}return this.getConnections().length<this.opts.maxConnections?(this.incomingPendingConnections++,!0):(ln("connection from %s refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}};u();var yC=_(z1(),1);u();async function*jh(r,e){yield*(await oi(r)).sort(e)}var Hl=D("libp2p:connection-manager:auto-dialler"),j9e={enabled:!0,minConnections:0,autoDialInterval:1e4},RE=class{constructor(e,t){this.components=e,this.options=ze.call({ignoreUndefined:!0},j9e,t),this.running=!1,this._autoDial=this._autoDial.bind(this),Hl("options: %j",this.options)}isStarted(){return this.running}async start(){if(!this.options.enabled){Hl("not enabled");return}this.running=!0,this._autoDial().catch(e=>{Hl.error("could start autodial",e)}),Hl("started")}async stop(){if(!this.options.enabled){Hl("not enabled");return}this.running=!1,this.autoDialTimeout!=null&&this.autoDialTimeout.clear(),Hl("stopped")}async _autoDial(){this.autoDialTimeout!=null&&this.autoDialTimeout.clear();let e=this.options.minConnections;if(this.components.connectionManager.getConnections().length>=e){this.autoDialTimeout=(0,yC.default)(this._autoDial,this.options.autoDialInterval);return}let t=await this.components.peerStore.all(),n=await de(t.sort(()=>Math.random()>.5?1:-1),i=>Dn(i,s=>!s.id.equals(this.components.peerId)),i=>jh(i,(s,o)=>o.protocols.length>s.protocols.length||o.id.publicKey!=null&&s.id.publicKey==null?1:-1),async i=>await oi(i));for(let i=0;this.running&&i<n.length&&this.components.connectionManager.getConnections().length<e;i++){if(!this.running)return;let s=n[i];if(this.components.connectionManager.getConnections(s.id).length===0){Hl("connecting to a peerStore stored peer %p",s.id);try{await this.components.connectionManager.openConnection(s.id)}catch(o){Hl.error("could not connect to peerStore stored peer",o)}}}!this.running||(this.autoDialTimeout=(0,yC.default)(this._autoDial,this.options.autoDialInterval))}};u();var lre=_(V(),1);u();var We;(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=()=>Mi(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=()=>Mi(i)}(n=r.Type||(r.Type={}));let s;(function(a){let c;a.codec=()=>(c==null&&(c=ct((l,f,h={})=>{if(h.lengthDelimited!==!1&&f.fork(),(h.writeDefaults===!0||l.id!=null&&l.id.byteLength>0)&&(f.uint32(10),f.bytes(l.id)),l.addrs!=null)for(let p of l.addrs)f.uint32(18),f.bytes(p);h.lengthDelimited!==!1&&f.ldelim()},(l,f)=>{let h={id:new Uint8Array(0),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;default:l.skipType(d&7);break}}return h})),c),a.encode=l=>at(l,a.codec()),a.decode=l=>ot(l,a.codec())})(s=r.Peer||(r.Peer={}));let o;r.codec=()=>(o==null&&(o=ct((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,{writeDefaults:!1})),a.dstPeer!=null&&(c.uint32(26),r.Peer.codec().encode(a.dstPeer,c,{writeDefaults:!1})),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=>at(a,r.codec()),r.decode=a=>ot(a,r.codec())})(We||(We={}));u();var Y9e=D("libp2p:stream:converter");function gC(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=Mr(l,e.signal));try{await i(l),await c()}catch(f){f.type!=="aborted"&&Y9e(f)}},source:e.signal!=null?Mr(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 Ba="/libp2p/circuit/relay/0.1.0";u();function rre(r){let e=new Map;async function t(s){let o=s.toString().split("/p2p-circuit").find(p=>p!==""),a=ee(o),c=a.getPeerId();if(c==null)throw new Error("Could not determine relay peer from multiaddr");let l=ce(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 J("listening"))}function n(){let s=[];for(let o of e.values())s.push(o);return s}let i=Object.assign(new Fe,{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 J("close"))}),i}u();var wC=_(V(),1);u();function nre(r,e){r.write({type:We.Type.STATUS,code:e})}function CE(r,e){try{r.dstPeer?.addrs!=null&&r.dstPeer.addrs.forEach(t=>ee(t))}catch(t){throw nre(e,r.type===We.Type.HOP?We.Status.HOP_DST_MULTIADDR_INVALID:We.Status.STOP_DST_MULTIADDR_INVALID),t}try{r.srcPeer?.addrs!=null&&r.srcPeer.addrs.forEach(t=>ee(t))}catch(t){throw nre(e,r.type===We.Type.HOP?We.Status.HOP_SRC_MULTIADDR_INVALID:We.Status.STOP_SRC_MULTIADDR_INVALID),t}}u();u();function Gl(r){let e=Vt(),t=dw(r.source),n=Lt(),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 vg=D("libp2p:circuit:stream-handler"),Yc=class{constructor(e){let{stream:t,maxLength:n=4096}=e;this.stream=t,this.shake=Gl(this.stream),this.decoder=ur.fromReader(this.shake.reader,{maxDataLength:n})}async read(){let e=await this.decoder.next();if(e.value!=null){let t=We.decode(e.value);return vg("read message type",t.type),t}vg("read received no value, closing stream"),this.close()}write(e){vg("write message type %s",e.type),this.shake.write(cr.single(We.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){vg("closing the stream"),this.rest().sink([]).catch(e=>{vg.error(e)})}};u();var Sg=D("libp2p:circuit:stop");function ire(r){let{connection:e,request:t,streamHandler:n}=r;try{CE(t,n)}catch(i){Sg.error("invalid stop request via peer %p %o",e.remotePeer,i);return}return Sg("stop request is valid"),n.write({type:We.Type.STATUS,code:We.Status.SUCCESS}),n.rest()}async function sre(r){let{connection:e,request:t,signal:n}=r,i=await e.newStream(Ba,{signal:n});Sg("starting stop request to %p",e.remotePeer);let s=new Yc({stream:i});s.write(t);let o=await s.read();if(o==null){s.close();return}if(o.code===We.Status.SUCCESS)return Sg("stop request to %p was successful",e.remotePeer),s.rest();Sg("stop request failed with code %d",o.code),s.close()}var qs=D("libp2p:circuit:hop");async function ore(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:We.Type.STATUS,code:We.Status.HOP_CANT_SPEAK_RELAY});try{CE(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=_r(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:We.Type.STATUS,code:We.Status.HOP_NO_CONN_TO_DST});if(a.length===0)return qs("did not have connection to remote peer"),n.end({type:We.Type.STATUS,code:We.Status.HOP_NO_CONN_TO_DST});let c={type:We.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer},l;try{qs("performing STOP request");let h=await sre({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:We.Type.STATUS,code:We.Status.SUCCESS});let f=n.rest();return qs("creating related connections"),await de(f,l,f)}async function are(r){let{connection:e,request:t,signal:n}=r,i=await e.newStream(Ba,{signal:n}),s=new Yc({stream:i});s.write(t);let o=await s.read();if(o==null)throw(0,wC.default)(new Error("HOP request had no response"),U.ERR_HOP_REQUEST_FAILED);if(o.code===We.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,wC.default)(new Error(`HOP request failed with code "${o.code??"unknown"}"`),U.ERR_HOP_REQUEST_FAILED)}async function cre(r){let{connection:e,signal:t}=r,n=await e.newStream(Ba,{signal:t}),i=new Yc({stream:n});i.write({type:We.Type.CAN_HOP});let s=await i.read();return await i.close(),!(s==null||s.code!==We.Status.SUCCESS)}function ure(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:We.Type.STATUS,code:i?We.Status.SUCCESS:We.Status.HOP_CANT_SPEAK_RELAY})}var fre=_(pn(),1),hre=_(qn(),1),$s=D("libp2p:circuit"),DE=class{constructor(e,t){this._init=t,this.components=e,this._started=!1}isStarted(){return this._started}async start(){this._started||(this._started=!0,await this.components.registrar.handle(Ba,e=>{this._onProtocol(e).catch(t=>{$s.error(t)})}).catch(e=>{$s.error(e)}))}async stop(){await this.components.registrar.unhandle(Ba)}hopEnabled(){return!0}hopActive(){return!0}get[q0](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}async _onProtocol(e){let{connection:t,stream:n}=e,i=new fre.TimeoutController(this._init.hop.timeout);try{(0,hre.setMaxListeners)?.(1/0,i.signal)}catch{}try{let s=Zn(n,i.signal),o=new Yc({stream:{...n,...s}}),a=await o.read();if(a==null){$s("request was invalid, could not read from stream"),o.write({type:We.Type.STATUS,code:We.Status.MALFORMED_MESSAGE}),o.close();return}let c;switch(a.type){case We.Type.CAN_HOP:{$s("received CAN_HOP request from %p",t.remotePeer),await ure({circuit:this,connection:t,streamHandler:o});break}case We.Type.HOP:{$s("received HOP request from %p",t.remotePeer),await ore({connection:t,request:a,streamHandler:o,circuit:this,connectionManager:this.components.connectionManager});break}case We.Type.STOP:{$s("received STOP request from %p",t.remotePeer),c=await ire({connection:t,request:a,streamHandler:o});break}default:{$s("Request of type %s not supported",a.type),o.write({type:We.Type.STATUS,code:We.Status.MALFORMED_MESSAGE}),o.close();return}}if(c!=null){let l=t.remoteAddr.encapsulate("/p2p-circuit").encapsulate(ee(a.dstPeer?.addrs[0])),f=ee(a.srcPeer?.addrs[0]),h=gC({stream:c,remoteAddr:l,localAddr:f}),p=a.type===We.Type.HOP?"relay":"inbound";$s("new %s connection %s",p,h.remoteAddr);let d=await this.components.upgrader.upgradeInbound(h);$s("%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=ee(n[0]),s=ee(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 $s.error(d),(0,lre.default)(new Error(d),U.ERR_RELAYED_DIAL)}let c=ce(o),l=ce(a),f=!1,p=this.components.connectionManager.getConnections(c)[0];p==null&&(await this.components.peerStore.addressBook.add(c,[i]),p=await this.components.connectionManager.openConnection(c,t),f=!0);try{let d=await are({...t,connection:p,request:{type:We.Type.HOP,srcPeer:{id:this.components.peerId.toBytes(),addrs:this.components.addressManager.getAddresses().map(g=>g.bytes)},dstPeer:{id:l.toBytes(),addrs:[ee(s).bytes]}}}),m=i.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`),y=gC({stream:d,remoteAddr:e,localAddr:m});return $s("new outbound connection %s",y.remoteAddr),await this.components.upgrader.upgradeOutbound(y)}catch(d){throw $s.error("Circuit relay dial failed",d),f&&await p.close(),d}}createListener(e){return this.handler=e.handler,rre({connectionManager:this.components.connectionManager,peerStore:this.components.peerStore})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(t=>mf.matches(t))}};u();var UE=_(jR(),1);u();u();async function PE(r){let e=new TextEncoder().encode(r),t=await Ke.digest(e);return A.createV0(t)}u();var EC="hop_relay",bC="true",kE="/libp2p/relay";u();u();var Tre=_(LE(),1);function xC(r){let{address:e}=r.nodeAddress();return Boolean((0,Tre.default)(e))}function X0(r,e){let t=xC(r.multiaddr),n=xC(e.multiaddr);return t&&!n?1:!t&&n||r.isCertified&&!e.isCertified?-1:!r.isCertified&&e.isCertified?1:0}var Ig=D("libp2p:auto-relay"),aSe=()=>{},BE=class{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??X0,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??aSe,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.peerStore.addEventListener("change:protocols",n=>{this._onProtocolChange(n).catch(i=>{Ig.error(i)})}),this.components.connectionManager.addEventListener("peer:disconnect",this._onPeerDisconnected)}async _onProtocolChange(e){let{peerId:t,protocols:n}=e.detail,i=t.toString();if(n.find(o=>o===Ba)==null){this.listenRelays.has(i)&&await this._removeListenRelay(i);return}if(!this.listenRelays.has(i))try{let o=this.components.connectionManager.getConnections(t);if(o.length===0)return;let a=o[0];if(a.remoteAddr.protoCodes().includes(290)){Ig(`relayed connection to ${i} will not be used to hop on`);return}await cre({connection:a})&&(await this.components.peerStore.metadataBook.setValue(t,EC,z(bC)),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=>{Ig.error(s)})}async _addListenRelay(e,t){try{if(this.listenRelays.size>=this.maxListeners)return;let n=await de(await this.components.peerStore.addressBook.get(e.remotePeer),s=>jh(s,this.addressSorter),async s=>await oi(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.transportManager.listen([o]),!0}catch(o){Ig.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.peerStore.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(EC);if(a==null||K(a)!==bC)continue;let c=this.components.connectionManager.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 PE(kE);for await(let s of this.components.contentRouting.findProviders(i)){if(s.multiaddrs.length===0)continue;let o=s.id;if(!o.equals(this.components.peerId)&&(await this.components.peerStore.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.connectionManager.openConnection(e);await this._addListenRelay(t,e.toString())}catch(t){Ig.error("Could not use %p as relay",e,t),this.onError(t,`could not connect and listen on known hop relay ${e.toString()}`)}}};var Ire=D("libp2p:relay"),ME=class{constructor(e,t){this.components=e,this.autoRelay=t.autoRelay?.enabled!==!1?new BE(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,UE.setDelayedInterval)(this._advertiseService,this.init.advertise.ttl,this.init.advertise.bootDelay)),this.started=!0}async stop(){this.timeout!=null&&(0,UE.clearDelayedInterval)(this.timeout),this.started=!1}async _advertiseService(){try{let e=await PE(kE);await this.components.contentRouting.provide(e)}catch(e){e.code===U.ERR_NO_ROUTERS_AVAILABLE?(Ire.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),await this.stop()):Ire.error(e)}}};u();var ine=_(Lre(),1);u();var VOt=_(Jre(),1),KOt=_($9(),1),Qc=_(ut(),1);u();var MOt=_(IC(),1),tne=_(ut(),1),ene=tne.default.pki,rne=(r,e)=>{let t=ene.rsa.setPublicKey(e.n,e.e),n=ene.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 nne(r,e){let t=r.map(e),i=(await Promise.all(t)).findIndex(s=>s);return r[i]}var Xc=_(V(),1);var MSe=D("libp2p:keychain:cms"),CC=new WeakMap,zE=class{constructor(e,t){if(e==null)throw(0,Xc.default)(new Error("keychain is required"),U.ERR_KEYCHAIN_REQUIRED);this.keychain=e,CC.set(this,{dek:t})}async encrypt(e,t){if(!(t instanceof Uint8Array))throw(0,Xc.default)(new Error("Plain data must be a Uint8Array"),U.ERR_INVALID_PARAMETERS);let n=await this.keychain.findKeyByName(e),i=await this.keychain.getPrivateKey(e),s=CC.get(this);if(s==null)throw(0,Xc.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let o=s.dek,a=Qc.default.pki.decryptRsaPrivateKey(i,o),c=await rne(n,a),l=Qc.default.pkcs7.createEnvelopedData();l.addRecipient(c),l.content=Qc.default.util.createBuffer(t),l.encrypt();let f=Qc.default.asn1.toDer(l.toAsn1()).getBytes();return z(f,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw(0,Xc.default)(new Error("CMS data is required"),U.ERR_INVALID_PARAMETERS);let t;try{let f=Qc.default.util.createBuffer(K(e,"ascii")),h=Qc.default.asn1.fromDer(f);t=Qc.default.pkcs7.messageFromAsn1(h)}catch(f){throw MSe.error(f),(0,Xc.default)(new Error("Invalid CMS"),U.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 nne(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,Xc.default)(new Error(`Decryption needs one of the key(s): ${f.join(", ")}`),U.ERR_MISSING_KEYS,{missingKeys:f})}let s=await this.keychain.findKeyById(i.keyId);if(s==null)throw(0,Xc.default)(new Error("No key available to decrypto"),U.ERR_NO_KEY);let o=await this.keychain.getPrivateKey(s.name),a=CC.get(this);if(a==null)throw(0,Xc.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let c=a.dek,l=Qc.default.pki.decryptRsaPrivateKey(o,c);return t.decrypt(i.recipient,l),z(t.content.getBytes(),"ascii")}};var Pt=_(V(),1);var qE=D("libp2p:keychain"),USe="/pkcs8/",sne="/info/",Yl=new WeakMap,Xh={minKeyLength:112/8,minSaltLength:128/8,minIterationCount:1e3},DC={dek:{keyLength:512/8,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function Zc(r){return r==null||typeof r!="string"?!1:r===(0,ine.default)(r.trim())&&r.length>0}async function Yt(){let t=Math.random()*800+200;await new Promise(n=>setTimeout(n,t))}function Ma(r){return new ie(USe+r)}function Jc(r){return new ie(sne+r)}var Ag=class{constructor(e,t){if(this.components=e,this.init=ze(DC,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<Xh.minKeyLength)throw new Error(`dek.keyLength must be least ${Xh.minKeyLength} bytes`);if(this.init.dek?.salt?.length!=null&&this.init.dek.salt.length<Xh.minSaltLength)throw new Error(`dek.saltLength must be least ${Xh.minSaltLength} bytes`);if(this.init.dek?.iterationCount!=null&&this.init.dek.iterationCount<Xh.minIterationCount)throw new Error(`dek.iterationCount must be least ${Xh.minIterationCount}`);let n=this.init.pass!=null&&this.init.dek?.salt!=null?Oy(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Yl.set(this,{dek:n}),this.started=!1}isStarted(){return this.started}async start(){let e=Jc("self");await this.components.datastore.has(e)||await this.importPeer("self",this.components.peerId),this.started=!0}stop(){this.started=!1}get cms(){let e=Yl.get(this);if(e==null)throw(0,Pt.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let t=e.dek;return new zE(this,t)}static generateOptions(){let e=Object.assign({},DC),t=Math.ceil(Xh.minSaltLength/3)*3;return e.dek.salt=K(gi(t),"base64"),e}static get options(){return DC}async createKey(e,t,n=2048){if(!Zc(e)||e==="self")throw await Yt(),(0,Pt.default)(new Error("Invalid key name"),U.ERR_INVALID_KEY_NAME);if(typeof t!="string")throw await Yt(),(0,Pt.default)(new Error("Invalid key type"),U.ERR_INVALID_KEY_TYPE);let i=Ma(e);if(await this.components.datastore.has(i))throw await Yt(),(0,Pt.default)(new Error("Key name already exists"),U.ERR_KEY_ALREADY_EXISTS);switch(t.toLowerCase()){case"rsa":if(!Number.isSafeInteger(n)||n<2048)throw await Yt(),(0,Pt.default)(new Error("Invalid RSA key size"),U.ERR_INVALID_KEY_SIZE);break;default:break}let o;try{let a=await mp(t,n),c=await a.id(),l=Yl.get(this);if(l==null)throw(0,Pt.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let f=l.dek,h=await a.export(f);o={name:e,id:c};let p=this.components.datastore.batch();p.put(i,z(h)),p.put(Jc(e),z(JSON.stringify(o))),await p.commit()}catch(a){throw await Yt(),a}return o}async listKeys(){let e={prefix:sne},t=[];for await(let n of this.components.datastore.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 Yt(),t}}async findKeyByName(e){if(!Zc(e))throw await Yt(),(0,Pt.default)(new Error(`Invalid key name '${e}'`),U.ERR_INVALID_KEY_NAME);let t=Jc(e);try{let n=await this.components.datastore.get(t);return JSON.parse(K(n))}catch(n){throw await Yt(),qE.error(n),(0,Pt.default)(new Error(`Key '${e}' does not exist.`),U.ERR_KEY_NOT_FOUND)}}async removeKey(e){if(!Zc(e)||e==="self")throw await Yt(),(0,Pt.default)(new Error(`Invalid key name '${e}'`),U.ERR_INVALID_KEY_NAME);let t=Ma(e),n=await this.findKeyByName(e),i=this.components.datastore.batch();return i.delete(t),i.delete(Jc(e)),await i.commit(),n}async renameKey(e,t){if(!Zc(e)||e==="self")throw await Yt(),(0,Pt.default)(new Error(`Invalid old key name '${e}'`),U.ERR_OLD_KEY_NAME_INVALID);if(!Zc(t)||t==="self")throw await Yt(),(0,Pt.default)(new Error(`Invalid new key name '${t}'`),U.ERR_NEW_KEY_NAME_INVALID);let n=Ma(e),i=Ma(t),s=Jc(e),o=Jc(t);if(await this.components.datastore.has(i))throw await Yt(),(0,Pt.default)(new Error(`Key '${t}' already exists`),U.ERR_KEY_ALREADY_EXISTS);try{let c=await this.components.datastore.get(n),l=await this.components.datastore.get(s),f=JSON.parse(K(l));f.name=t;let h=this.components.datastore.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 Yt(),c}}async exportKey(e,t){if(!Zc(e))throw await Yt(),(0,Pt.default)(new Error(`Invalid key name '${e}'`),U.ERR_INVALID_KEY_NAME);if(t==null)throw await Yt(),(0,Pt.default)(new Error("Password is required"),U.ERR_PASSWORD_REQUIRED);let n=Ma(e);try{let i=await this.components.datastore.get(n),s=K(i),o=Yl.get(this);if(o==null)throw(0,Pt.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let a=o.dek;return await(await wc(s,a)).export(t)}catch(i){throw await Yt(),i}}async importKey(e,t,n){if(!Zc(e)||e==="self")throw await Yt(),(0,Pt.default)(new Error(`Invalid key name '${e}'`),U.ERR_INVALID_KEY_NAME);if(t==null)throw await Yt(),(0,Pt.default)(new Error("PEM encoded key is required"),U.ERR_PEM_REQUIRED);let i=Ma(e);if(await this.components.datastore.has(i))throw await Yt(),(0,Pt.default)(new Error(`Key '${e}' already exists`),U.ERR_KEY_ALREADY_EXISTS);let o;try{o=await wc(t,n)}catch{throw await Yt(),(0,Pt.default)(new Error("Cannot read the key, most likely the password is wrong"),U.ERR_CANNOT_READ_KEY)}let a;try{a=await o.id();let f=Yl.get(this);if(f==null)throw(0,Pt.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let h=f.dek;t=await o.export(h)}catch(f){throw await Yt(),f}let c={name:e,id:a},l=this.components.datastore.batch();return l.put(i,z(t)),l.put(Jc(e),z(JSON.stringify(c))),await l.commit(),c}async importPeer(e,t){try{if(!Zc(e))throw(0,Pt.default)(new Error(`Invalid key name '${e}'`),U.ERR_INVALID_KEY_NAME);if(t==null)throw(0,Pt.default)(new Error("PeerId is required"),U.ERR_MISSING_PRIVATE_KEY);if(t.privateKey==null)throw(0,Pt.default)(new Error("PeerId.privKey is required"),U.ERR_MISSING_PRIVATE_KEY);let n=await Cn(t.privateKey),i=Ma(e);if(await this.components.datastore.has(i))throw await Yt(),(0,Pt.default)(new Error(`Key '${e}' already exists`),U.ERR_KEY_ALREADY_EXISTS);let o=Yl.get(this);if(o==null)throw(0,Pt.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let a=o.dek,c=await n.export(a),l={name:e,id:t.toString()},f=this.components.datastore.batch();return f.put(i,z(c)),f.put(Jc(e),z(JSON.stringify(l))),await f.commit(),l}catch(n){throw await Yt(),n}}async getPrivateKey(e){if(!Zc(e))throw await Yt(),(0,Pt.default)(new Error(`Invalid key name '${e}'`),U.ERR_INVALID_KEY_NAME);try{let t=Ma(e),n=await this.components.datastore.get(t);return K(n)}catch(t){throw await Yt(),qE.error(t),(0,Pt.default)(new Error(`Key '${e}' does not exist.`),U.ERR_KEY_NOT_FOUND)}}async rotateKeychainPass(e,t){if(typeof e!="string")throw await Yt(),(0,Pt.default)(new Error(`Invalid old pass type '${typeof e}'`),U.ERR_INVALID_OLD_PASS_TYPE);if(typeof t!="string")throw await Yt(),(0,Pt.default)(new Error(`Invalid new pass type '${typeof t}'`),U.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw await Yt(),(0,Pt.default)(new Error(`Invalid pass length ${t.length}`),U.ERR_INVALID_PASS_LENGTH);qE("recreating keychain");let n=Yl.get(this);if(n==null)throw(0,Pt.default)(new Error("dek missing"),U.ERR_INVALID_PARAMETERS);let i=n.dek;this.init.pass=t;let s=t!=null&&this.init.dek?.salt!=null?Oy(t,this.init.dek.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Yl.set(this,{dek:s});let o=await this.listKeys();for(let a of o){let c=await this.components.datastore.get(Ma(a.name)),l=K(c),f=await wc(l,i),h=s.toString(),p=await f.export(h),d=this.components.datastore.batch(),m={name:a.name,id:a.id};d.put(Ma(a.name),z(p)),d.put(Jc(a.name),z(JSON.stringify(m))),await d.commit()}qE("keychain reconstructed")}};u();u();async function*$E(r,e){for await(let t of r)await e(t),yield t}var cne=_(qd(),1);u();var one={computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50};u();u();var PC=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 kC(r){return new PC(r)}var ane=_(z1(),1),t1=class extends Fe{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]=kC(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,ane.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 J("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]=kC(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 VSe=["dataReceived","dataSent"],KSe={in:"dataReceived",out:"dataSent"},HE=class{constructor(e){this.enabled=e.enabled,this.statsInit={...e,initialCounters:VSe},this.globalStats=new t1(this.statsInit),this.peerStats=new Map,this.protocolStats=new Map,this.oldPeers=(0,cne.default)(e.maxOldPeersRetention??one.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=KSe[i],a=this.forPeer(t);if(a==null){let c=new t1(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 t1(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=zSe(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=$E(s,a=>this._onMessage({remotePeer:n,protocol:i,direction:"in",dataLength:a.byteLength}));let o=t.sink;t.sink=async a=>await de(a,c=>$E(c,l=>{this._onMessage({remotePeer:n,protocol:i,direction:"out",dataLength:l.byteLength})}),o)}};function zSe(r,e){return r.stop(),e.stop(),r.queue=[...r.queue,...e.queue],r}u();u();u();async function Rg(r){try{return{status:"fulfilled",value:await r,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}u();u();var NC=class{value;next;constructor(e){this.value=e}},Cg=class{#e;#t;#r;constructor(){this.clear()}enqueue(e){let t=new NC(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 OC(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 Cg,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 LC(r,e={}){let{concurrency:t=Number.POSITIVE_INFINITY}=e,n=OC(t);return Promise.all(r.map(i=>i&&typeof i.then=="function"?Rg(i):typeof i=="function"?Rg(n(()=>i())):Rg(Promise.resolve(i))))}var r1=_(V(),1);u();var BC=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 cs(r){let{system:e,component:t,metric:n,metrics:i}=r,s;return i!=null?s=new BC({system:e,component:t,metric:n,metrics:i}):s=new Map,s}var Zh=D("libp2p:transports"),GE=class extends Fe{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=cs({component:"transport-manager",metric:"listeners",metrics:this.components.metrics}),this.faultTolerance=t.faultTolerance??Jh.FATAL_ALL}add(e){let t=e[Symbol.toStringTag];if(t==null)throw(0,r1.default)(new Error("Transport must have a valid tag"),U.ERR_INVALID_KEY);if(this.transports.has(t))throw(0,r1.default)(new Error("There is already a transport with this tag"),U.ERR_DUPLICATE_TRANSPORT);Zh("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.addressManager.getListenAddrs();await this.listen(e),this.started=!0}async stop(){let e=[];for(let[t,n]of this.listeners)for(Zh("closing listeners for %s",t);n.length>0;){let i=n.pop();i!=null&&e.push(i.close())}await Promise.all(e),Zh("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,r1.default)(new Error(`No transport available for address ${String(e)}`),U.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(e,{...t,upgrader:this.components.upgrader})}catch(i){throw i.code==null&&(i.code=U.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){Zh("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){Zh("creating listener for %s on %s",n,l);let f=i.createListener({upgrader:this.components.upgrader}),h=this.listeners.get(n);h==null&&(h=[],this.listeners.set(n,h)),h.push(f),f.addEventListener("listening",()=>{this.dispatchEvent(new J("listener:listening",{detail:f}))}),f.addEventListener("close",()=>{this.dispatchEvent(new J("listener:close",{detail:f}))}),o.push(f.listen(l))}if(o.length===0){t.push(n);continue}if((await LC(o)).find(l=>l.isFulfilled)==null&&this.faultTolerance!==Jh.NO_FATAL)throw(0,r1.default)(new Error(`Transport (${n}) could not listen on any available address`),U.ERR_NO_VALID_ADDRESSES)}if(t.length===this.transports.size){let n=`no valid addresses were provided for transports [${t.join(", ")}]`;if(this.faultTolerance===Jh.FATAL_ALL)throw(0,r1.default)(new Error(n),U.ERR_NO_VALID_ADDRESSES);Zh(`libp2p in dial mode only: ${n}`)}}async remove(e){Zh("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)}},Jh;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Jh||(Jh={}));u();var Ln=_(V(),1);u();u();var eu="/multistream/1.0.0";u();var Ene=_(V(),1);u();var MC=_(V(),1);var fne=_(lne(),1);var hne=z(`
`);function Dg(r){let e=new et(r,hne);return cr.single(e)}function ed(r,e,t={}){let n=Dg(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function dne(r,e,t={}){let n=new et;for(let i of e)n.append(Dg(i));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function $Se(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>await r.next(t)},i=n;e?.signal!=null&&(i=Mr(n,e.signal));let o=await de(i,ur({onLength:a=>{t=a}}),async a=>await(0,fne.default)(a));if(o==null)throw(0,MC.default)(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==hne[0])throw(0,MC.default)(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}async function n1(r,e){let t=await $Se(r,e);return K(t.subarray())}var WSe=_(wne(),1);var Pg=D("libp2p:mss:select");async function kg(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:i,rest:s,stream:o}=Gl(r),a=e.shift();if(a==null)throw new Error("At least one protocol must be specified");Pg('select: write ["%s", "%s"]',eu,a);let c=z(eu),l=z(a);dne(i,[c,l],t);let f=await n1(n,t);if(Pg('select: read "%s"',f),f===eu&&(f=await n1(n,t),Pg('select: read "%s"',f)),f===a)return s(),{stream:o,protocol:a};for(let h of e){Pg('select: write "%s"',h),ed(i,z(h),t);let p=await n1(n,t);if(Pg('select: read "%s" for "%s"',p,h),p===h)return s(),{stream:o,protocol:h}}throw s(),(0,Ene.default)(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}u();var Ng=D("libp2p:mss:handle");async function Og(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:i,rest:s,stream:o}=Gl(r);for(;;){let a=await n1(i,t);if(Ng('read "%s"',a),a===eu){Ng('respond with "%s" for "%s"',eu,a),ed(n,z(eu),t);continue}if(e.includes(a))return ed(n,z(a),t),Ng('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};if(a==="ls"){ed(n,new et(...e.map(c=>Dg(z(c)))),t),Ng('respond with "%s" for %s',e,a);continue}ed(n,z("na"),t),Ng('respond with "na" for "%s"',a)}}var qC=_(_ne(),1);u();var FC=_(V(),1);u();var vne=Symbol.for("@libp2p/connection");var QSe=D("libp2p:connection"),VC=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:SE},this._newStream=i,this._close=s,this._getStreams=o,this.tags=[],this._closing=!1}get[Symbol.toStringTag](){return"Connection"}get[vne](){return!0}get streams(){return this._getStreams()}async newStream(e,t){if(this.stat.status===QR)throw(0,FC.default)(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===xE)throw(0,FC.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===xE||this._closing)){this.stat.status=QR;try{this.streams.forEach(e=>e.close())}catch(e){QSe.error(e)}this._closing=!0,await this._close(),this._closing=!1,this.stat.timeline.close=Date.now(),this.stat.status=xE}}};function Sne(r){return new VC(r)}u();var WE=_(V(),1);var xne=D("libp2p:registrar"),KC=32,zC=64,jE=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.connectionManager.addEventListener("peer:disconnect",this._onDisconnect),this.components.peerStore.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,WE.default)(new Error(`No handler registered for protocol ${e}`),U.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,WE.default)(new Error(`Handler already registered for protocol ${e}`),U.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);let i=ze.bind({ignoreUndefined:!0})({maxInboundStreams:KC,maxOutboundStreams:zC},n);this.handlers.set(e,{handler:t,options:i}),await this.components.peerStore.protoBook.add(this.components.peerId,[e])}async unhandle(e){let t=Array.isArray(e)?e:[e];t.forEach(n=>{this.handlers.delete(n)}),await this.components.peerStore.protoBook.remove(this.components.peerId,t)}async register(e,t){if(!Uj(t))throw xne.error("topology must be an instance of interfaces/topology"),(0,WE.default)(new Error("topology must be an instance of interfaces/topology"),U.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.peerStore.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=>{xne.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.connectionManager.getConnections(t)[0];f!=null&&l.onConnect(t,f)}}}};var $C=_(pn(),1);var HC=_(qn(),1),nr=D("libp2p:upgrader");function XSe(r,e){try{let{options:t}=e.getHandler(r);return t.maxInboundStreams}catch(t){if(t.code!==U.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return KC}function ZSe(r,e){try{let{options:t}=e.getHandler(r);return t.maxOutboundStreams}catch(t){if(t.code!==U.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return zC}function Tne(r,e,t){let n=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===r&&n++}),n}var YE=class extends Fe{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){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw(0,Ln.default)(new Error("connection denied"),U.ERR_CONNECTION_DENIED);let n,i,s,o,a,c,l,f=this.components.metrics,h=new $C.TimeoutController(this.inboundUpgradeTimeout);try{(0,HC.setMaxListeners)?.(1/0,h.signal)}catch{}try{let p=Zn(e,h.signal);if(e.source=p.source,e.sink=p.sink,await this.components.connectionGater.denyInboundConnection(e))throw(0,Ln.default)(new Error("The multiaddr connection is blocked by gater.acceptConnection"),U.ERR_CONNECTION_INTERCEPTED);if(f!=null){({setTarget:c,proxy:l}=(0,qC.default)());let y=`${(Math.random()*1e9).toString(36)}${Date.now()}`;c({toString:()=>y}),f.trackStream({stream:e,remotePeer:l})}nr("starting the inbound connection upgrade");let d=e,m=this.components.connectionProtector;m!=null&&(nr("protecting the inbound connection"),d=await m.protect(e));try{if({conn:n,remotePeer:i,protocol:a}=await this._encryptInbound(d),await this.components.connectionGater.denyInboundEncryptedConnection(i,{...d,...n}))throw(0,Ln.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),U.ERR_CONNECTION_INTERCEPTED);if(this.muxers.size>0){let y=await this._multiplexInbound({...d,...n},this.muxers);o=y.muxerFactory,s=y.stream}else s=n}catch(y){throw nr.error("Failed to upgrade inbound connection",y),y}if(await this.components.connectionGater.denyInboundUpgradedConnection(i,{...d,...n}))throw(0,Ln.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),U.ERR_CONNECTION_INTERCEPTED);return f!=null&&(f.updatePlaceholder(l,i),c(i)),nr("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{this.components.connectionManager.afterUpgradeInbound(),h.clear()}}async upgradeOutbound(e,t){let n=e.remoteAddr.getPeerId();if(n==null)throw(0,Ln.default)(new Error("outbound connection must have a peer id"),U.ERR_INVALID_MULTIADDR);let i=ce(n);if(await this.components.connectionGater.denyOutboundConnection(i,e))throw(0,Ln.default)(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),U.ERR_CONNECTION_INTERCEPTED);let s,o,a,c,l,f,h,p=this.components.metrics;if(p!=null){({setTarget:f,proxy:h}=(0,qC.default)());let m=`${(Math.random()*1e9).toString(36)}${Date.now()}`;f({toB58String:()=>m}),p.trackStream({stream:e,remotePeer:h})}nr("Starting the outbound connection upgrade");let d=e;if(t?.skipProtection!==!0){let m=this.components.connectionProtector;m!=null&&(d=await m.protect(e))}try{if(s=d,t?.skipEncryption!==!0){if({conn:s,remotePeer:o,protocol:c}=await this._encryptOutbound(d,i),await this.components.connectionGater.denyOutboundEncryptedConnection(o,{...d,...s}))throw(0,Ln.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),U.ERR_CONNECTION_INTERCEPTED)}else c="native",o=i;if(a=s,t?.muxerFactory!=null)l=t.muxerFactory;else if(this.muxers.size>0){let m=await this._multiplexOutbound({...d,...s},this.muxers);l=m.muxerFactory,a=m.stream}}catch(m){throw nr.error("Failed to upgrade outbound connection",m),await e.close(m),m}if(await this.components.connectionGater.denyOutboundUpgradedConnection(o,{...d,...s}))throw(0,Ln.default)(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),U.ERR_CONNECTION_INTERCEPTED);return p!=null&&(p.updatePlaceholder(h,o),f(o)),nr("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:l,remotePeer:o})}_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.registrar.getProtocols(),{stream:y,protocol:g}=await Og(d,m);nr("%s: incoming stream opened on %s",n,g);let w=this.components.metrics;if(w?.trackStream({stream:y,remotePeer:o,protocol:g}),f==null)return;let E=XSe(g,this.components.registrar);if(Tne(g,"inbound",f)===E){d.abort((0,Ln.default)(new Error(`Too many inbound protocol streams for protocol "${g}" - limit ${E}`),U.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS));return}d.source=y.source,d.sink=y.sink,d.stat.protocol=g,this.components.peerStore.protoBook.add(o,[g]).catch(x=>nr.error(x)),f.addStream(d),this._onStream({connection:f,stream:d,protocol:g})}).catch(m=>{nr.error(m),d.stat.timeline.close==null&&d.close()})},onStreamEnd:d=>{f?.removeStream(d.id)}}),l=async(d,m={})=>{if(c==null)throw(0,Ln.default)(new Error("Stream is not multiplexed"),U.ERR_MUXER_UNAVAILABLE);nr("%s: starting new stream on %s",n,d);let y=await c.newStream(),g=this.components.metrics,w;try{if(m.signal==null){nr("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",d),w=new $C.TimeoutController(3e4),m.signal=w.signal;try{(0,HC.setMaxListeners)?.(1/0,w.signal)}catch{}}let{stream:E,protocol:v}=await kg(y,d,m);g?.trackStream({stream:E,remotePeer:o,protocol:v});let x=ZSe(v,this.components.registrar);if(Tne(v,"outbound",f)===x){let T=(0,Ln.default)(new Error(`Too many outbound protocol streams for protocol "${v}" - limit ${x}`),U.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw y.abort(T),T}return this.components.peerStore.protoBook.add(o,[v]).catch(T=>nr.error(T)),y.source=E.source,y.sink=E.sink,y.stat.protocol=v,y}catch(E){throw nr.error("could not create new stream",E),y.stat.timeline.close==null&&y.close(),E.code!=null?E:(0,Ln.default)(E,U.ERR_UNSUPPORTED_PROTOCOL)}finally{w?.clear()}},de(s,c,s).catch(nr.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){nr.error(m)}finally{this.dispatchEvent(new J("connectionEnd",{detail:f}))}})().catch(m=>{nr.error(m)}),Reflect.set(...d))}),i.timeline.upgraded=Date.now();let p=()=>{throw(0,Ln.default)(new Error("connection is not multiplexed"),U.ERR_CONNECTION_NOT_MULTIPLEXED)};return f=Sne({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 J("connection",{detail:f})),f}_onStream(e){let{connection:t,stream:n,protocol:i}=e,{handler:s}=this.components.registrar.getHandler(i);s({connection:t,stream:n})}async _encryptInbound(e){let t=Array.from(this.connectionEncryption.keys());nr("handling inbound crypto protocol selection",t);try{let{stream:n,protocol:i}=await Og(e,t,{writeBytes:!0}),s=this.connectionEncryption.get(i);if(s==null)throw new Error(`no crypto module found for ${i}`);return nr("encrypting inbound connection..."),{...await s.secureInbound(this.components.peerId,n),protocol:i}}catch(n){throw(0,Ln.default)(n,U.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){let n=Array.from(this.connectionEncryption.keys());nr("selecting outbound crypto protocol",n);try{let{stream:i,protocol:s}=await kg(e,n,{writeBytes:!0}),o=this.connectionEncryption.get(s);if(o==null)throw new Error(`no crypto module found for ${s}`);return nr("encrypting outbound connection to %p",t),{...await o.secureOutbound(this.components.peerId,i,t),protocol:s}}catch(i){throw(0,Ln.default)(i,U.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){let n=Array.from(t.keys());nr("outbound selecting muxer %s",n);try{let{stream:i,protocol:s}=await kg(e,n,{writeBytes:!0});nr("%s selected as muxer protocol",s);let o=t.get(s);return{stream:i,muxerFactory:o}}catch(i){throw nr.error("error multiplexing outbound stream",i),(0,Ln.default)(i,U.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){let n=Array.from(t.keys());nr("inbound handling muxers %s",n);try{let{stream:i,protocol:s}=await Og(e,n,{writeBytes:!0}),o=t.get(s);return{stream:i,muxerFactory:o}}catch(i){throw nr.error("error multiplexing inbound stream",i),(0,Ln.default)(i,U.ERR_MUXER_UNAVAILABLE)}}};u();var rd=_(V(),1);u();var td;(function(r){let e;r.codec=()=>(e==null&&(e=ct((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);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);t.signedPeerRecord!=null&&(n.uint32(66),n.bytes(t.signedPeerRecord)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={listenAddrs:[],protocols:[]},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.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(td||(td={}));u();u();var QE="0.0.0",Ine="libp2p";var GC=`js-libp2p/${QE}`;var Ane="0.1.0",Rne="id",Cne="id/push",Dne="1.0.0",Pne="1.0.0";var Lg=_(pn(),1);var Bg=_(qn(),1),Zt=D("libp2p:identify"),kne=1024*8,i1=class{constructor(e,t){this.components=e,this.started=!1,this.init=t,this.identifyProtocolStr=`/${t.protocolPrefix}/${Rne}/${Dne}`,this.identifyPushProtocolStr=`/${t.protocolPrefix}/${Cne}/${Pne}`,this.host={protocolVersion:`${t.protocolPrefix}/${Ane}`,...t.host},this.components.connectionManager.addEventListener("peer:connect",n=>{let i=n.detail;this.identify(i).catch(Zt.error)}),this.components.peerStore.addEventListener("change:multiaddrs",n=>{let{peerId:i}=n.detail;this.components.peerId.equals(i)&&this.pushToPeerStore().catch(s=>Zt.error(s))}),this.components.peerStore.addEventListener("change:protocols",n=>{let{peerId:i}=n.detail;this.components.peerId.equals(i)&&this.pushToPeerStore().catch(s=>Zt.error(s))})}isStarted(){return this.started}async start(){this.started||(await this.components.peerStore.metadataBook.setValue(this.components.peerId,"AgentVersion",z(this.host.agentVersion)),await this.components.peerStore.metadataBook.setValue(this.components.peerId,"ProtocolVersion",z(this.host.protocolVersion)),await this.components.registrar.handle(this.identifyProtocolStr,e=>{this._handleIdentify(e).catch(t=>{Zt.error(t)})},{maxInboundStreams:this.init.maxInboundStreams,maxOutboundStreams:this.init.maxOutboundStreams}),await this.components.registrar.handle(this.identifyPushProtocolStr,e=>{this._handlePush(e).catch(t=>{Zt.error(t)})},{maxInboundStreams:this.init.maxPushIncomingStreams,maxOutboundStreams:this.init.maxPushOutgoingStreams}),this.started=!0)}async stop(){await this.components.registrar.unhandle(this.identifyProtocolStr),await this.components.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async push(e){let t=await this.components.peerStore.addressBook.getRawEnvelope(this.components.peerId),n=this.components.addressManager.getAddresses().map(o=>o.bytes),i=await this.components.peerStore.protoBook.get(this.components.peerId),s=e.map(async o=>{let a,c=new Lg.TimeoutController(this.init.timeout);try{(0,Bg.setMaxListeners)?.(1/0,c.signal)}catch{}try{a=await o.newStream([this.identifyPushProtocolStr],{signal:c.signal}),await Zn(a,c.signal).sink(de([td.encode({listenAddrs:n,signedPeerRecord:t,protocols:i})],cr()))}catch(l){Zt.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.connectionManager.getConnections()){let n=t.remotePeer;!(await this.components.peerStore.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 Lg.TimeoutController(this.init.timeout),i=n.signal;try{(0,Bg.setMaxListeners)?.(1/0,n.signal)}catch{}}try{s=await e.newStream([this.identifyProtocolStr],{signal:i});let o=Zn(s,i),a=await de([],o,ur({maxDataLength:this.init.maxIdentifyMessageSize??kne}),async c=>await kn(c));if(a==null)throw(0,rd.default)(new Error("No data could be retrieved"),U.ERR_CONNECTION_ENDED);try{return td.decode(a)}catch(c){throw(0,rd.default)(c,U.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,rd.default)(new Error("public key was missing from identify message"),U.ERR_MISSING_PUBLIC_KEY);let h=await sn(i);if(!e.remotePeer.equals(h))throw(0,rd.default)(new Error("identified peer does not match the expected peer"),U.ERR_INVALID_PEER);if(this.components.peerId.equals(h))throw(0,rd.default)(new Error("identified peer is our own peer id?"),U.ERR_INVALID_PEER);let p=i1.getCleanMultiaddr(a);if(c!=null){Zt("received signed peer record from %p",h);try{let d=await Qr.openAndCertify(c,an.DOMAIN);if(!d.peerId.equals(h))throw(0,rd.default)(new Error("identified peer does not match the expected peer"),U.ERR_INVALID_PEER);if(await this.components.peerStore.addressBook.consumePeerRecord(d)){await this.components.peerStore.protoBook.set(h,o),l!=null&&await this.components.peerStore.metadataBook.setValue(h,"AgentVersion",z(l)),f!=null&&await this.components.peerStore.metadataBook.setValue(h,"ProtocolVersion",z(f)),Zt("identify completed for peer %p and protocols %o",h,o);return}}catch(d){Zt("received invalid envelope, discard it and fallback to listenAddrs is available",d)}}else Zt("no signed peer record received from %p",h);Zt("falling back to legacy addresses from %p",h);try{await this.components.peerStore.addressBook.set(h,s.map(d=>ee(d)))}catch(d){Zt.error("received invalid addrs",d)}await this.components.peerStore.protoBook.set(h,o),l!=null&&await this.components.peerStore.metadataBook.setValue(h,"AgentVersion",z(l)),f!=null&&await this.components.peerStore.metadataBook.setValue(h,"ProtocolVersion",z(f)),Zt("identify completed for peer %p and protocols %o",h,o),Zt("received observed address of %s",p?.toString())}async _handleIdentify(e){let{connection:t,stream:n}=e,i=new Lg.TimeoutController(this.init.timeout);try{(0,Bg.setMaxListeners)?.(1/0,i.signal)}catch{}try{let s=this.components.peerId.publicKey??new Uint8Array(0),o=await this.components.peerStore.get(this.components.peerId),a=this.components.addressManager.getAddresses().map(p=>p.decapsulateCode(Ht("p2p").code)),c=o.peerRecordEnvelope;if(a.length>0&&c==null){let p=new an({peerId:this.components.peerId,multiaddrs:a}),d=await Qr.seal(p,this.components.peerId);await this.components.peerStore.addressBook.consumePeerRecord(d),c=d.marshal().subarray()}let l=td.encode({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:s,listenAddrs:a.map(p=>p.bytes),signedPeerRecord:c,observedAddr:t.remoteAddr.bytes,protocols:o.protocols}),f=Zn(n,i.signal),h=de([l],cr());await f.sink(h)}catch(s){Zt.error("could not respond to identify request",s)}finally{n.close(),i.clear()}}async _handlePush(e){let{connection:t,stream:n}=e,i=new Lg.TimeoutController(this.init.timeout);try{(0,Bg.setMaxListeners)?.(1/0,i.signal)}catch{}let s;try{let a=Zn(n,i.signal),c=await de([],a,ur({maxDataLength:this.init.maxIdentifyMessageSize??kne}),async l=>await kn(l));c!=null&&(s=td.decode(c))}catch(a){return Zt.error("received invalid message",a)}finally{n.close(),i.clear()}if(s==null)return Zt.error("received invalid message");let o=t.remotePeer;if(this.components.peerId.equals(o)){Zt("received push from ourselves?");return}if(Zt("received push from %p",o),s.signedPeerRecord!=null){Zt("received signedPeerRecord in push");try{let a=await Qr.openAndCertify(s.signedPeerRecord,an.DOMAIN);if(await this.components.peerStore.addressBook.consumePeerRecord(a)){Zt("consumed signedPeerRecord sent in push"),await this.components.peerStore.protoBook.set(o,s.protocols);return}else Zt("failed to consume signedPeerRecord sent in push")}catch(a){Zt("received invalid envelope, discard it and fallback to listenAddrs is available",a)}}else Zt("did not receive signedPeerRecord in push");try{await this.components.peerStore.addressBook.set(o,s.listenAddrs.map(a=>ee(a)))}catch(a){Zt.error("received invalid addrs",a)}try{await this.components.peerStore.protoBook.set(o,s.protocols)}catch(a){Zt.error("received invalid protocols",a)}Zt("handled push from %p",o)}static getCleanMultiaddr(e){if(e!=null&&e.length>0)try{return ee(e)}catch{}}};u();var s1=_(V(),1);u();var Mg;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.identifier!=="")&&(n.uint32(10),n.string(t.identifier)),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={identifier:""},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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(Mg||(Mg={}));var Lo;(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=()=>Mi(t)}(e=r.StatusCode||(r.StatusCode={}));let n;r.codec=()=>(n==null&&(n=ct((i,s,o={})=>{o.lengthDelimited!==!1&&s.fork(),(o.writeDefaults===!0||i.status!=null&&t[i.status]!==0)&&(s.uint32(8),r.StatusCode.codec().encode(i.status,s)),(o.writeDefaults===!0||i.data!=null&&i.data.byteLength>0)&&(s.uint32(18),s.bytes(i.data)),o.lengthDelimited!==!1&&s.ldelim()},(i,s)=>{let o={status:e.OK,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.status=r.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(c&7);break}}return o})),n),r.encode=i=>at(i,r.codec()),r.decode=i=>ot(i,r.codec())})(Lo||(Lo={}));u();var Nne="0.0.1",One="fetch";var Bne=_(pn(),1),Mne=_(qn(),1),Lne=D("libp2p:fetch"),XE=class{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/${One}/${Nne}`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}async start(){await this.components.registrar.handle(this.protocol,e=>{this.handleMessage(e).catch(t=>{Lne.error(t)}).finally(()=>{e.stream.close()})},{maxInboundStreams:this.init.maxInboundStreams,maxOutboundStreams:this.init.maxOutboundStreams}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}async fetch(e,t,n={}){Lne("dialing %s to %p",this.protocol,e);let i=await this.components.connectionManager.openConnection(e,n),s,o=n.signal,a;if(o==null){s=new Bne.TimeoutController(this.init.timeout),o=s.signal;try{(0,Mne.setMaxListeners)?.(1/0,s.signal)}catch{}}try{a=await i.newStream([this.protocol],{signal:o});let c=Zn(a,o);return await de([Mg.encode({identifier:t})],cr(),c,ur(),async function(f){let h=await kn(f);if(h==null)throw(0,s1.default)(new Error("No data received"),U.ERR_INVALID_MESSAGE);let p=Lo.decode(h);switch(p.status){case Lo.StatusCode.OK:return p.data;case Lo.StatusCode.NOT_FOUND:return null;case Lo.StatusCode.ERROR:{let d=new TextDecoder().decode(p.data);throw(0,s1.default)(new Error("Error in fetch protocol response: "+d),U.ERR_INVALID_PARAMETERS)}default:throw(0,s1.default)(new Error("Unknown response status"),U.ERR_INVALID_MESSAGE)}})??null}finally{s?.clear(),a?.close()}}async handleMessage(e){let{stream:t}=e,n=this;await de(t,ur(),async function*(i){let s=await kn(i);if(s==null)throw(0,s1.default)(new Error("No data received"),U.ERR_INVALID_MESSAGE);let o=Mg.decode(s),a,c=n._getLookupFunction(o.identifier);if(c!=null){let l=await c(o.identifier);l!=null?a={status:Lo.StatusCode.OK,data:l}:a={status:Lo.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{let l=new TextEncoder().encode("No lookup function registered for key: "+o.identifier);a={status:Lo.StatusCode.ERROR,data:l}}yield Lo.encode(a)},cr(),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,s1.default)(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),U.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 Kne=_(V(),1);u();var Une="1.0.0",Fne="ping";var zne=_(pn(),1),qne=_(qn(),1),Vne=D("libp2p:ping"),ZE=class{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/${Fne}/${Une}`,this.init=t}async start(){await this.components.registrar.handle(this.protocol,this.handleMessage,{maxInboundStreams:this.init.maxInboundStreams,maxOutboundStreams:this.init.maxOutboundStreams}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}handleMessage(e){let{stream:t}=e;de(t,t).catch(n=>{Vne.error(n)})}async ping(e,t={}){Vne("dialing %s to %p",this.protocol,e);let n=Date.now(),i=gi(32),s=await this.components.connectionManager.openConnection(e,t),o,a=t.signal,c;if(a==null){o=new zne.TimeoutController(this.init.timeout),a=o.signal;try{(0,qne.setMaxListeners)?.(1/0,o.signal)}catch{}}try{c=await s.newStream([this.protocol],{signal:a});let l=Zn(c,a),f=await de([i],l,async p=>await kn(p)),h=Date.now();if(f==null||!Be(i,f.subarray()))throw(0,Kne.default)(new Error("Received wrong ping ack"),U.ERR_WRONG_PING_ACK);return h-n}finally{o?.clear(),c?.close()}}};u();u();async function $ne(){throw new Error("Not supported in browsers")}u();var Hne=_(u_(),1),WC=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,JE=(0,Hne.default)(),nd=WC&&!JE,Gne=JE&&!WC,Wne=JE&&WC,jne=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!JE,eb=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,qMt=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",Yne=typeof navigator<"u"&&navigator.product==="ReactNative";var Zne=_(LE(),1);var Jne=_(V(),1);u();u();function Qne(r){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(r)||/^::1$/.test(r)}function Xne(r){let{address:e}=r.nodeAddress();return Qne(e)}var jC=D("libp2p:nat"),YC=7200;function txe(r=1024,e=65535){return Math.floor(Math.random()*(e-r+1)+r)}var tb=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??`${Ine}@${QE} ${this.components.peerId.toString()}`,this.ttl=t.ttl??YC,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<YC)throw(0,Jne.default)(new Error(`NatManager ttl should be at least ${YC} seconds`),U.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){nd||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{jC.error(e)}))}async _start(){let e=this.components.transportManager.getAddrs();for(let t of e){let{family:n,host:i,port:s,transport:o}=t.toOptions();if(!t.isThinWaistAddress()||o!=="tcp"||Xne(t)||n!==4)continue;let a=await this._getClient(),c=this.externalAddress??await a.externalIp();if((0,Zne.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=txe();jC(`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.addressManager.addObservedAddr(kL({family:4,address:c,port:l},o))}}async _getClient(){return this.client!=null?this.client:(this.client=await $ne({description:this.description,ttl:this.ttl,keepAlive:this.keepAlive,gateway:this.gateway}),this.client)}async stop(){if(!(nd||this.client==null))try{await this.client.close(),this.client=void 0}catch(e){jC.error(e)}}};u();var rxe=D("libp2p:peer-record-updater"),rb=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.transportManager.addEventListener("listener:listening",this.update),this.components.transportManager.addEventListener("listener:close",this.update),this.components.addressManager.addEventListener("change:addresses",this.update)}async stop(){this.started=!1,this.components.transportManager.removeEventListener("listener:listening",this.update),this.components.transportManager.removeEventListener("listener:close",this.update),this.components.addressManager.removeEventListener("change:addresses",this.update)}update(){Promise.resolve().then(async()=>{let e=new an({peerId:this.components.peerId,multiaddrs:this.components.addressManager.getAddresses().map(n=>n.decapsulateCode(Ht("p2p").code))}),t=await Qr.seal(e,this.components.peerId);await this.components.peerStore.addressBook.consumePeerRecord(t)}).catch(e=>{rxe.error("Could not update self peer record: %o",e)})}};u();var eie=_(V(),1);var nb=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,eie.default)(new Error(ht.NOT_FOUND),U.ERR_NOT_FOUND)}async*getClosestPeers(e,t={}){for await(let n of this.dht.getClosestPeers(e,t))n.name==="FINAL_PEER"&&(yield n.peer)}};u();u();var sb=_(V(),1);u();var it={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_NOT_FOUND:"ERR_NOT_FOUND"};var uie=_(rie(),1),lie=_(iie(),1),fie=_(oie(),1),hie=_(cie(),1);var Qt=D("libp2p:peer-store:address-book"),ib="change:multiaddrs";async function axe(){return!0}var ob=class{constructor(e,t,n){this.dispatchEvent=e,this.store=t,this.addressFilter=n??axe}async consumePeerRecord(e){Qt.trace("consumePeerRecord await write lock");let t=await this.store.lock.writeLock();Qt.trace("consumePeerRecord got write lock");let n,i,s;try{let o;try{o=an.createFromProtobuf(e.payload)}catch{return Qt.error("invalid peer record received"),!1}n=o.peerId;let a=o.multiaddrs;if(!n.equals(e.peerId))return Qt("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 Qr.createFromProtobuf(i.peerRecordEnvelope),f=an.createFromProtobuf(l.payload);if(f.seqNumber>=o.seqNumber)return Qt("sequence number was lower or equal to existing sequence number - stored: %d received: %d",f.seqNumber,o.seqNumber),!1}let c=await QC(n,a,this.addressFilter,!0);s=await this.store.patchOrCreate(n,{addresses:c,peerRecordEnvelope:e.marshal().subarray()}),Qt("stored provided peer record for %p",o.peerId)}finally{Qt.trace("consumePeerRecord release write lock"),t()}return this.dispatchEvent(new J(ib,{detail:{peerId:n,multiaddrs:s.addresses.map(({multiaddr:o})=>o),oldMultiaddrs:i==null?[]:i.addresses.map(({multiaddr:o})=>o)}})),!0}async getRawEnvelope(e){Qt.trace("getRawEnvelope await read lock");let t=await this.store.lock.readLock();Qt.trace("getRawEnvelope got read lock");try{return(await this.store.load(e)).peerRecordEnvelope}catch(n){if(n.code!==it.ERR_NOT_FOUND)throw n}finally{Qt.trace("getRawEnvelope release read lock"),t()}}async getPeerRecord(e){let t=await this.getRawEnvelope(e);if(t!=null)return await Qr.createFromProtobuf(t)}async get(e){e=Hr(e),Qt.trace("get wait for read lock");let t=await this.store.lock.readLock();Qt.trace("get got read lock");try{return(await this.store.load(e)).addresses}catch(n){if(n.code!==it.ERR_NOT_FOUND)throw n}finally{Qt.trace("get release read lock"),t()}return[]}async set(e,t){if(e=Hr(e),!Array.isArray(t))throw Qt.error("multiaddrs must be an array of Multiaddrs"),(0,sb.default)(new Error("multiaddrs must be an array of Multiaddrs"),it.ERR_INVALID_PARAMETERS);Qt.trace("set await write lock");let n=await this.store.lock.writeLock();Qt.trace("set got write lock");let i=!1,s,o;try{let a=await QC(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!==it.ERR_NOT_FOUND)throw c}o=await this.store.patchOrCreate(e,{addresses:a}),Qt("set multiaddrs for %p",e)}finally{Qt.trace("set multiaddrs for %p",e),Qt("set release write lock"),n()}this.dispatchEvent(new J(ib,{detail:{peerId:e,multiaddrs:o.addresses.map(a=>a.multiaddr),oldMultiaddrs:s==null?[]:s.addresses.map(({multiaddr:a})=>a)}})),i||this.dispatchEvent(new J("peer",{detail:{id:e,multiaddrs:o.addresses.map(a=>a.multiaddr),protocols:o.protocols}}))}async add(e,t){if(e=Hr(e),!Array.isArray(t))throw Qt.error("multiaddrs must be an array of Multiaddrs"),(0,sb.default)(new Error("multiaddrs must be an array of Multiaddrs"),it.ERR_INVALID_PARAMETERS);Qt.trace("add await write lock");let n=await this.store.lock.writeLock();Qt.trace("add got write lock");let i,s,o;try{let a=await QC(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!==it.ERR_NOT_FOUND)throw c}o=await this.store.mergeOrCreate(e,{addresses:a}),Qt("added multiaddrs for %p",e)}finally{Qt.trace("set release write lock"),n()}this.dispatchEvent(new J(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 J("peer",{detail:{id:e,multiaddrs:o.addresses.map(a=>a.multiaddr),protocols:o.protocols}}))}async delete(e){e=Hr(e),Qt.trace("delete await write lock");let t=await this.store.lock.writeLock();Qt.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==it.ERR_NOT_FOUND)throw i}await this.store.patchOrCreate(e,{addresses:[]})}finally{Qt.trace("delete release write lock"),t()}n!=null&&this.dispatchEvent(new J(ib,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:n==null?[]:n.addresses.map(({multiaddr:i})=>i)}}))}};async function QC(r,e,t,n=!1){return await de(e,i=>(0,hie.default)(i,s=>{if(!oc(s))throw Qt.error("multiaddr must be an instance of Multiaddr"),(0,sb.default)(new Error("multiaddr must be an instance of Multiaddr"),it.ERR_INVALID_PARAMETERS)}),i=>(0,lie.default)(i,async s=>await t(r,s)),i=>(0,fie.default)(i,s=>({multiaddr:s,isCertified:n})),async i=>await(0,uie.default)(i))}u();var pie=_(V(),1);var Ua=D("libp2p:peer-store:key-book"),die="change:pubkey",ab=class{constructor(e,t){this.dispatchEvent=e,this.store=t}async set(e,t){if(e=Hr(e),!(t instanceof Uint8Array))throw Ua.error("publicKey must be an instance of Uint8Array to store data"),(0,pie.default)(new Error("publicKey must be an instance of PublicKey"),it.ERR_INVALID_PARAMETERS);Ua.trace("set await write lock");let n=await this.store.lock.writeLock();Ua.trace("set got write lock");let i=!1,s;try{try{if(s=await this.store.load(e),s.pubKey!=null&&Be(s.pubKey,t))return}catch(o){if(o.code!==it.ERR_NOT_FOUND)throw o}await this.store.patchOrCreate(e,{pubKey:t}),i=!0}finally{Ua.trace("set release write lock"),n()}i&&this.dispatchEvent(new J(die,{detail:{peerId:e,publicKey:t,oldPublicKey:s?.pubKey}}))}async get(e){e=Hr(e),Ua.trace("get await write lock");let t=await this.store.lock.readLock();Ua.trace("get got write lock");try{return(await this.store.load(e)).pubKey}catch(n){if(n.code!==it.ERR_NOT_FOUND)throw n}finally{Ua("get release write lock"),t()}}async delete(e){e=Hr(e),Ua.trace("delete await write lock");let t=await this.store.lock.writeLock();Ua.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==it.ERR_NOT_FOUND)throw i}await this.store.patchOrCreate(e,{pubKey:void 0})}catch(i){if(i.code!==it.ERR_NOT_FOUND)throw i}finally{Ua.trace("delete release write lock"),t()}this.dispatchEvent(new J(die,{detail:{peerId:e,publicKey:void 0,oldPublicKey:n?.pubKey}}))}};u();var XC=_(V(),1);var hn=D("libp2p:peer-store:metadata-book"),cb="change:metadata",ub=class{constructor(e,t){this.dispatchEvent=e,this.store=t}async get(e){e=Hr(e),hn.trace("get await read lock");let t=await this.store.lock.readLock();hn.trace("get got read lock");try{return(await this.store.load(e)).metadata}catch(n){if(n.code!==it.ERR_NOT_FOUND)throw n}finally{hn.trace("get release read lock"),t()}return new Map}async getValue(e,t){e=Hr(e),hn.trace("getValue await read lock");let n=await this.store.lock.readLock();hn.trace("getValue got read lock");try{return(await this.store.load(e)).metadata.get(t)}catch(i){if(i.code!==it.ERR_NOT_FOUND)throw i}finally{hn.trace("getValue release write lock"),n()}}async set(e,t){if(e=Hr(e),!(t instanceof Map))throw hn.error("valid metadata must be provided to store data"),(0,XC.default)(new Error("valid metadata must be provided"),it.ERR_INVALID_PARAMETERS);hn.trace("set await write lock");let n=await this.store.lock.writeLock();hn.trace("set got write lock");let i;try{try{i=await this.store.load(e)}catch(s){if(s.code!==it.ERR_NOT_FOUND)throw s}await this.store.mergeOrCreate(e,{metadata:t})}finally{hn.trace("set release write lock"),n()}this.dispatchEvent(new J(cb,{detail:{peerId:e,metadata:t,oldMetadata:i==null?new Map:i.metadata}}))}async setValue(e,t,n){if(e=Hr(e),typeof t!="string"||!(n instanceof Uint8Array))throw hn.error("valid key and value must be provided to store data"),(0,XC.default)(new Error("valid key and value must be provided"),it.ERR_INVALID_PARAMETERS);hn.trace("setValue await write lock");let i=await this.store.lock.writeLock();hn.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&&Be(n,a))return}catch(a){if(a.code!==it.ERR_NOT_FOUND)throw a}o=await this.store.mergeOrCreate(e,{metadata:new Map([[t,n]])})}finally{hn.trace("setValue release write lock"),i()}this.dispatchEvent(new J(cb,{detail:{peerId:e,metadata:o.metadata,oldMetadata:s==null?new Map:s.metadata}}))}async delete(e){e=Hr(e),hn.trace("delete await write lock");let t=await this.store.lock.writeLock();hn.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==it.ERR_NOT_FOUND)throw i}n!=null&&await this.store.patch(e,{metadata:new Map})}finally{hn.trace("delete release write lock"),t()}n!=null&&this.dispatchEvent(new J(cb,{detail:{peerId:e,metadata:new Map,oldMetadata:n.metadata}}))}async deleteValue(e,t){e=Hr(e),hn.trace("deleteValue await write lock");let n=await this.store.lock.writeLock();hn.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!==it.ERR_NOT_FOUND)throw o}finally{hn.trace("deleteValue release write lock"),n()}i!=null&&this.dispatchEvent(new J(cb,{detail:{peerId:e,metadata:i,oldMetadata:s==null?new Map:s.metadata}}))}};u();var fb=_(V(),1);var dn=D("libp2p:peer-store:proto-book"),lb="change:protocols",hb=class{constructor(e,t){this.dispatchEvent=e,this.store=t}async get(e){dn.trace("get wait for read lock");let t=await this.store.lock.readLock();dn.trace("get got read lock");try{return(await this.store.load(e)).protocols}catch(n){if(n.code!==it.ERR_NOT_FOUND)throw n}finally{dn.trace("get release read lock"),t()}return[]}async set(e,t){if(e=Hr(e),!Array.isArray(t))throw dn.error("protocols must be provided to store data"),(0,fb.default)(new Error("protocols must be provided"),it.ERR_INVALID_PARAMETERS);dn.trace("set await write lock");let n=await this.store.lock.writeLock();dn.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!==it.ERR_NOT_FOUND)throw o}s=await this.store.patchOrCreate(e,{protocols:t}),dn("stored provided protocols for %p",e)}finally{dn.trace("set release write lock"),n()}this.dispatchEvent(new J(lb,{detail:{peerId:e,protocols:s.protocols,oldProtocols:i==null?[]:i.protocols}}))}async add(e,t){if(e=Hr(e),!Array.isArray(t))throw dn.error("protocols must be provided to store data"),(0,fb.default)(new Error("protocols must be provided"),it.ERR_INVALID_PARAMETERS);dn.trace("add await write lock");let n=await this.store.lock.writeLock();dn.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!==it.ERR_NOT_FOUND)throw o}s=await this.store.mergeOrCreate(e,{protocols:t}),dn("added provided protocols for %p",e)}finally{dn.trace("add release write lock"),n()}this.dispatchEvent(new J(lb,{detail:{peerId:e,protocols:s.protocols,oldProtocols:i==null?[]:i.protocols}}))}async remove(e,t){if(e=Hr(e),!Array.isArray(t))throw dn.error("protocols must be provided to store data"),(0,fb.default)(new Error("protocols must be provided"),it.ERR_INVALID_PARAMETERS);dn.trace("remove await write lock");let n=await this.store.lock.writeLock();dn.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!==it.ERR_NOT_FOUND)throw o}s=await this.store.patchOrCreate(e,{protocols:t})}finally{dn.trace("remove release write lock"),n()}this.dispatchEvent(new J(lb,{detail:{peerId:e,protocols:s.protocols,oldProtocols:i==null?[]:i.protocols}}))}async delete(e){e=Hr(e),dn.trace("delete await write lock");let t=await this.store.lock.writeLock();dn.trace("delete got write lock");let n;try{try{n=await this.store.load(e)}catch(i){if(i.code!==it.ERR_NOT_FOUND)throw i}await this.store.patchOrCreate(e,{protocols:[]})}finally{dn.trace("delete release write lock"),t()}n!=null&&this.dispatchEvent(new J(lb,{detail:{peerId:e,protocols:[],oldProtocols:n.protocols}}))}};u();var ZC=_(V(),1);u();var Ug;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.addresses!=null)for(let s of t.addresses)n.uint32(10),db.codec().encode(s,n,{writeDefaults:!0});if(t.protocols!=null)for(let s of t.protocols)n.uint32(18),n.string(s);if(t.metadata!=null)for(let s of t.metadata)n.uint32(26),pb.codec().encode(s,n,{writeDefaults:!0});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(db.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(pb.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=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(Ug||(Ug={}));var db;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.multiaddr!=null&&t.multiaddr.byteLength>0)&&(n.uint32(10),n.bytes(t.multiaddr)),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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(db||(db={}));var pb;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.key!=="")&&(n.uint32(10),n.string(t.key)),(i.writeDefaults===!0||t.value!=null&&t.value.byteLength>0)&&(n.uint32(18),n.bytes(t.value)),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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(pb||(pb={}));var mie=D("libp2p:peer-store:store"),yie="/peers/",mb=class{constructor(e){this.components=e,this.lock=eh({name:"peer-store",singleProcess:!0})}_peerIdToDatastoreKey(e){if(e.type==null)throw mie.error("peerId must be an instance of peer-id to store data"),(0,ZC.default)(new Error("peerId must be an instance of peer-id"),it.ERR_INVALID_PARAMETERS);let t=e.toCID().toString();return new ie(`${yie}${t}`)}async has(e){return await this.components.datastore.has(this._peerIdToDatastoreKey(e))}async delete(e){await this.components.datastore.delete(this._peerIdToDatastoreKey(e))}async load(e){let t=await this.components.datastore.get(this._peerIdToDatastoreKey(e)),n=Ug.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:ee(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&&!Be(e.pubKey,e.id.publicKey))throw mie.error("peer publicKey bytes do not match peer id publicKey bytes"),(0,ZC.default)(new Error("publicKey bytes do not match peer id publicKey bytes"),it.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=Ug.encode({addresses:n,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:i,peerRecordEnvelope:e.peerRecordEnvelope});return await this.components.datastore.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!==it.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!==it.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:ee(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.datastore.queryKeys({prefix:yie})){let t=e.toString().split("/")[2],n=dt.decode(t);yield this.load(_r(n))}}};var JC=_(V(),1);u();var tu;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.tags!=null)for(let s of t.tags)n.uint32(10),yb.codec().encode(s,n,{writeDefaults:!0});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(yb.codec().decode(t,t.uint32()));break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(tu||(tu={}));var yb;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.name!=="")&&(n.uint32(10),n.string(t.name)),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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(yb||(yb={}));var Gs=D("libp2p:peer-store"),gb=class extends Fe{constructor(e,t={}){super(),this.components=e,this.store=new mb(e),this.addressBook=new ob(this.dispatchEvent.bind(this),this.store,t.addressFilter),this.keyBook=new ab(this.dispatchEvent.bind(this),this.store),this.metadataBook=new ub(this.dispatchEvent.bind(this),this.store),this.protoBook=new hb(this.dispatchEvent.bind(this),this.store)}async forEach(e){Gs.trace("getPeers await read lock");let t=await this.store.lock.readLock();Gs.trace("getPeers got read lock");try{for await(let n of this.store.all())n.id.equals(this.components.peerId)||e(n)}finally{Gs.trace("getPeers release read lock"),t()}}async all(){let e=[];return await this.forEach(t=>{e.push(t)}),e}async delete(e){Gs.trace("delete await write lock");let t=await this.store.lock.writeLock();Gs.trace("delete got write lock");try{await this.store.delete(e)}finally{Gs.trace("delete release write lock"),t()}}async get(e){Gs.trace("get await read lock");let t=await this.store.lock.readLock();Gs.trace("get got read lock");try{return await this.store.load(e)}finally{Gs.trace("get release read lock"),t()}}async has(e){Gs.trace("has await read lock");let t=await this.store.lock.readLock();Gs.trace("has got read lock");try{return await this.store.has(e)}finally{Gs.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,JC.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=tu.decode(a).tags);for(let l of c)if(l.name===t)throw(0,JC.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",tu.encode({tags:c}).subarray())}async unTagPeer(e,t){let n=await this.metadataBook.getValue(e,"tags"),i=[];n!=null&&(i=tu.decode(n).tags),i=i.filter(s=>s.name!==t),await this.metadataBook.setValue(e,"tags",tu.encode({tags:i}).subarray())}async getTags(e){let t=await this.metadataBook.getValue(e,"tags"),n=[];t!=null&&(n=tu.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",tu.encode({tags:s}).subarray()),s.map(o=>({name:o.name,value:o.value??0}))}};u();var gie=_(V(),1),wb=class{constructor(e){this.dht=e}async provide(e){await yn(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 yn(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,gie.default)(new Error("Not found"),"ERR_NOT_FOUND")}};u();var us=_(V(),1);var Eb=class{constructor(e={}){this._started=!1,this._peerId=e.peerId,this._addressManager=e.addressManager,this._peerStore=e.peerStore,this._upgrader=e.upgrader,this._metrics=e.metrics,this._registrar=e.registrar,this._connectionManager=e.connectionManager,this._transportManager=e.transportManager,this._connectionGater=e.connectionGater,this._contentRouting=e.contentRouting,this._peerRouting=e.peerRouting,this._datastore=e.datastore,this._connectionProtector=e.connectionProtector,this._dht=e.dht,this._pubsub=e.pubsub,this._dialer=e.dialer}isStarted(){return this._started}async beforeStart(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.beforeStart!=null&&await e.beforeStart()}))}async start(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{await e.start()})),this._started=!0}async afterStart(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async beforeStop(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.beforeStop!=null&&await e.beforeStop()}))}async stop(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{await e.stop()})),this._started=!1}async afterStop(){await Promise.all(Object.values(this).filter(e=>Xn(e)).map(async e=>{e.afterStop!=null&&await e.afterStop()}))}get peerId(){if(this._peerId==null)throw(0,us.default)(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this._peerId}set peerId(e){this._peerId=e}get addressManager(){if(this._addressManager==null)throw(0,us.default)(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this._addressManager}set addressManager(e){this._addressManager=e}get peerStore(){if(this._peerStore==null)throw(0,us.default)(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this._peerStore}set peerStore(e){this._peerStore=e}get upgrader(){if(this._upgrader==null)throw(0,us.default)(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this._upgrader}set upgrader(e){this._upgrader=e}get registrar(){if(this._registrar==null)throw(0,us.default)(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this._registrar}set registrar(e){this._registrar=e}get connectionManager(){if(this._connectionManager==null)throw(0,us.default)(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this._connectionManager}set connectionManager(e){this._connectionManager=e}get transportManager(){if(this._transportManager==null)throw(0,us.default)(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this._transportManager}set transportManager(e){this._transportManager=e}get connectionGater(){if(this._connectionGater==null)throw(0,us.default)(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this._connectionGater}set connectionGater(e){this._connectionGater=e}get contentRouting(){if(this._contentRouting==null)throw(0,us.default)(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this._contentRouting}set contentRouting(e){this._contentRouting=e}get peerRouting(){if(this._peerRouting==null)throw(0,us.default)(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this._peerRouting}set peerRouting(e){this._peerRouting=e}get datastore(){if(this._datastore==null)throw(0,us.default)(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this._datastore}set datastore(e){this._datastore=e}get connectionProtector(){return this._connectionProtector}set connectionProtector(e){this._connectionProtector=e}get dialer(){if(this._dialer==null)throw(0,us.default)(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this._dialer}set dialer(e){this._dialer=e}get metrics(){return this._metrics}set metrics(e){this._metrics=e}get dht(){return this._dht}set dht(e){this._dht=e}get pubsub(){return this._pubsub}set pubsub(e){this._pubsub=e}};u();u();u();u();var tD=_(Ci(),1),rD=_(bie(),1);u();u();var _ie=globalThis.fetch,vie=globalThis.Headers,NFt=globalThis.Request,OFt=globalThis.Response;function bb(r,e,t){return`${r}?name=${e}&type=${t}`}async function Sie(r,e){return await(await _ie(r,{headers:new vie({accept:"application/dns-json"}),signal:e})).json()}function id(r,e){return`${e}_${r}`}var eD=Object.assign((0,tD.default)("dns-over-http-resolver"),{error:(0,tD.default)("dns-over-http-resolver:error")}),nD=class{constructor(e={}){this._cache=new rD.default({max:e?.maxCache??100}),this._TXTcache=new rD.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??Sie,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(id(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(bb(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(id(e,t),c,{ttl:l}),c}catch{o.signal.aborted&&(i=!0),eD.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(id(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(bb(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(id(e,t),c,{ttl:l}),c}catch{o.signal.aborted&&(i=!0),eD.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(id(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(bb(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(id(e,t),c,{ttl:l}),c}catch{o.signal.aborted&&(i=!0),eD.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()}},xie=nD;var Tie=xie;var{code:hxe}=Ht("dnsaddr");async function Iie(r,e={}){let t=new Tie;e.signal!=null&&e.signal.addEventListener("abort",()=>{t.cancel()});let n=r.getPeerId(),[,i]=r.stringTuples().find(([a])=>a===hxe)??[];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 _b=_(V(),1);var yxe={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:Iie},addressSorter:X0},connectionGater:{},transportManager:{faultTolerance:Jh.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:GC},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 Aie(r){let e=ze(yxe,r);if(e.transports==null||e.transports.length<1)throw(0,_b.default)(new Error(ht.ERR_TRANSPORTS_REQUIRED),U.ERR_TRANSPORTS_REQUIRED);if(e.connectionEncryption==null||e.connectionEncryption.length===0)throw(0,_b.default)(new Error(ht.CONN_ENCRYPTION_REQUIRED),U.CONN_ENCRYPTION_REQUIRED);if(e.connectionProtector===null&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw(0,_b.default)(new Error(ht.ERR_PROTECTOR_REQUIRED),U.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===GC&&(jne||Gne?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(nd||eb||Wne||Yne)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}u();u();var aD;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.id!=null&&t.id.byteLength>0)&&(n.uint32(10),n.bytes(t.id)),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}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(aD||(aD={}));var vb=async()=>{let r=await mp("Ed25519"),e=await Cie(r);if(e.type==="Ed25519")return e;throw new Error(`Generated unexpected PeerId type "${e.type}"`)};var Rie=async r=>{let e=await mp("RSA",r?.bits??2048),t=await Cie(e);if(t.type==="RSA")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function Cie(r){return await sn(Cm(r.public),bS(r))}var Vg=_(V(),1);u();var Ws=_(V(),1);var Sb=class extends Fe{get[La](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}get lan(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}get(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}findProviders(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}findPeer(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}getClosestPeers(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}provide(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}put(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}async getMode(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}async setMode(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}async refreshRoutingTable(){throw(0,Ws.default)(new Error(ht.DHT_DISABLED),U.DHT_DISABLED)}};u();var ru=_(V(),1);var xb=class extends Fe{constructor(){super(...arguments),this.topicValidators=new Map}isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}get multicodecs(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}getPeers(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}getTopics(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}subscribe(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}unsubscribe(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}getSubscribers(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}async publish(){throw(0,ru.default)(new Error(ht.PUBSUB_DISABLED),U.ERR_PUBSUB_DISABLED)}};u();var o1=_(V(),1);var Vie=_(pn(),1);u();var Fa=class extends Error{constructor(e="The operation was aborted"){super(e),this.code=Fa.code,this.type=Fa.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}};var Kie=_(ri(),1),zie=_(qn(),1);u();var Fg=_(V(),1),Mie=_(ri(),1),Uie=_(Lie(),1),cD=_(qn(),1);var Bie=D("libp2p:dialer:dial-request"),Tb=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,Fg.default)(new Error("No dial tokens available"),U.ERR_NO_DIAL_TOKENS);let n=new Uie.default;for(let a of t)n.push(a).catch(c=>{Bie.error(c)});let i=this.addrs.map(()=>{let a=new AbortController;try{(0,cD.setMaxListeners)?.(1/0,a.signal)}catch{}return a});if(e.signal!=null)try{(0,cD.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,Fg.default)(new Error("dialAction already succeeded"),U.ERR_ALREADY_SUCCEEDED);let f=i[c];if(f==null)throw(0,Fg.default)(new Error("dialAction did not come with an AbortController"),U.ERR_INVALID_PARAMETERS);let h;try{let p=f.signal;h=await this.dialAction(a,{...e,signal:e.signal!=null?(0,Mie.anySignal)([p,e.signal]):p}),i[c]=void 0}finally{s++,this.addrs.length-s>=t.length?n.push(l).catch(p=>{Bie.error(p)}):this.dialer.releaseToken(t.splice(t.indexOf(l),1)[0])}if(h==null)throw(0,Fg.default)(new Error("dialAction led to empty object"),U.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 Bo=D("libp2p:dialer"),Fie="dialler",Exe="pending-dials",bxe="pending-dial-targets",Ib=class{constructor(e,t={}){this.started=!1,this.addressSorter=t.addressSorter??X0,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=cs({component:Fie,metric:Exe,metrics:t.metrics}),this.pendingDialTargets=cs({component:Fie,metric:bxe,metrics:e.metrics});for(let[n,i]of Object.entries(t.resolvers??{}))zv.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){Bo.error(t)}this.pendingDials.clear();for(let e of this.pendingDialTargets.values())e.reject(new Fa("Dialer was destroyed"));this.pendingDialTargets.clear()}async dial(e,t={}){let{id:n,multiaddrs:i}=Wh(e);if(this.components.peerId.equals(n))throw(0,o1.default)(new Error("Tried to dial self"),U.ERR_DIALED_SELF);if(Bo("check multiaddrs %p",n),i!=null&&i.length>0&&(Bo("storing multiaddrs %p",n,i),await this.components.peerStore.addressBook.add(n,i)),await this.components.connectionGater.denyDialPeer(n))throw(0,o1.default)(new Error("The dial request is blocked by gater.allowDialPeer"),U.ERR_PEER_DIAL_INTERCEPTED);Bo("creating dial target for %p",n);let s=await this._createCancellableDialTarget(n,t);if(s.addrs.length===0)throw(0,o1.default)(new Error("The dial request has no valid addresses"),U.ERR_NO_VALID_ADDRESSES);let o=this.pendingDials.get(s.id)??this._createPendingDial(s,t);try{let a=await o.promise;return Bo("dial succeeded to %s",s.id),a}catch(a){throw Bo("dial failed to %s",s.id,a),o.controller.signal.aborted&&(a.code=U.ERR_TIMEOUT),Bo.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=this._resolve.bind(this),i=await de(await this.components.peerStore.addressBook.get(e),s=>Dn(s,async o=>!await this.components.connectionGater.denyDialMultiaddr(e,o.multiaddr)),s=>jh(s,this.addressSorter),async function*(o){for await(let a of o)yield*await n(a.multiaddr,t)},s=>Dn(s,o=>Boolean(this.components.transportManager.transportForMultiaddr(o))),s=>dr(s,o=>e.toString()===o.getPeerId()?o:o.encapsulate(`/p2p/${e.toString()}`)),async s=>await oi(s));if(i.length>this.maxAddrsToDial)throw await this.components.peerStore.delete(e),(0,o1.default)(new Error("dial with more addresses than allowed"),U.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:i}}_createPendingDial(e,t={}){let n=async(l,f={})=>{if(f.signal?.aborted===!0)throw(0,o1.default)(new Error("already aborted"),U.ERR_ALREADY_ABORTED);return await this.components.transportManager.dial(l,f).catch(h=>{throw Bo.error("dial to %s failed",l,h),h})},i=new Tb({addrs:e.addrs,dialAction:n,dialer:this}),s=new Vie.TimeoutController(this.timeout),o=[s.signal];t.signal!=null&&o.push(t.signal);let a=(0,Kie.anySignal)(o);try{(0,zie.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 Bo("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),n}releaseToken(e){this.tokens.includes(e)||(Bo("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=ee(e.toString()),await e.resolve(t)}catch(n){return Bo.error(`multiaddr ${e.toString()} could not be resolved`,n),[]}}};var nu=D("libp2p"),uD=class extends Fe{constructor(e){super(),this.started=!1,this.peerId=e.peerId;let t=this.components=new Eb({peerId:e.peerId,datastore:e.datastore??new Um,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}});t.peerStore=new gb(t,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore}),this.services=[t],e.metrics.enabled&&(this.metrics=this.components.metrics=new HE(e.metrics)),this.peerStore=this.components.peerStore,this.peerStore.addEventListener("peer",o=>{let{detail:a}=o;this.dispatchEvent(new J("peer:discovery",{detail:a}))}),e.connectionProtector!=null&&(this.components.connectionProtector=e.connectionProtector(t)),this.components.upgrader=new YE(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o(this.components))),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o(this.components))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.components.dialer=new Ib(this.components,e.connectionManager),this.connectionManager=this.components.connectionManager=new AE(this.components,e.connectionManager),this.registrar=this.components.registrar=new jE(this.components),this.components.transportManager=new GE(this.components,e.transportManager),this.components.addressManager=new bE(this.components,e.addresses),this.configureComponent(new rb(this.components)),this.configureComponent(new RE(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));let n=Ag.generateOptions();this.keychain=this.configureComponent(new Ag(this.components,{...n,...e.keychain})),this.services.push(new tb(this.components,e.nat)),e.transports.forEach(o=>{this.components.transportManager.add(this.configureComponent(o(this.components)))}),this.identifyService=new i1(this.components,{...e.identify}),this.configureComponent(this.identifyService),e.dht!=null?this.dht=this.components.dht=e.dht(this.components):this.dht=new Sb,e.pubsub!=null?this.pubsub=this.components.pubsub=e.pubsub(this.components):this.pubsub=new xb;let i=(e.peerRouters??[]).map(o=>this.configureComponent(o(this.components)));e.dht!=null&&(i.push(this.configureComponent(new nb(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.peerRouting=this.configureComponent(new gE(this.components,{...e.peerRouting,routers:i}));let s=(e.contentRouters??[]).map(o=>this.configureComponent(o(this.components)));e.dht!=null&&s.push(this.configureComponent(new wb(this.dht))),this.contentRouting=this.components.contentRouting=this.configureComponent(new EE(this.components,{routers:s})),e.relay.enabled&&(this.components.transportManager.add(this.configureComponent(new DE(this.components,e.relay))),this.configureComponent(new ME(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new XE(this.components,{...e.fetch})),this.pingService=this.configureComponent(new ZE(this.components,{...e.ping}));for(let o of e.peerDiscovery??[])this.configureComponent(o(this.components)).addEventListener("peer",c=>{this.onDiscoveryPeer(c)})}configureComponent(e){return Xn(e)&&this.services.push(e),e}async start(){if(!this.started){this.started=!0,nu("libp2p is starting");try{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()})),nu("libp2p has started")}catch(e){throw nu.error("An error occurred starting libp2p",e),await this.stop(),e}}}async stop(){!this.started||(nu("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()})),nu("libp2p has stopped"))}isStarted(){return this.started}getConnections(e){return this.components.connectionManager.getConnections(e)}getPeers(){let e=new Ai;for(let t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e,t={}){let{id:n,multiaddrs:i}=Wh(e);return await this.components.peerStore.addressBook.add(n,i),await this.components.connectionManager.openConnection(n,t)}async dialProtocol(e,t,n={}){if(t==null)throw(0,Vg.default)(new Error("no protocols were provided to open a stream"),U.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(t=Array.isArray(t)?t:[t],t.length===0)throw(0,Vg.default)(new Error("no protocols were provided to open a stream"),U.ERR_INVALID_PROTOCOLS_FOR_STREAM);return await(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}async hangUp(e){let{id:t}=Wh(e);await this.components.connectionManager.closeConnections(t)}async getPublicKey(e,t={}){if(nu("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,Vg.default)(new Error("Public key was not in the peer store and the DHT is not enabled"),U.ERR_NO_ROUTERS_AVAILABLE);let i=De([z("/pk/"),e.multihash.digest]);for await(let s of this.dht.get(i,t))if(s.name==="VALUE"){let o=Ei(s.value);return await this.peerStore.keyBook.set(e,s.value),o.bytes}throw(0,Vg.default)(new Error(`Node not responding with its public key: ${e.toString()}`),U.ERR_INVALID_RECORD)}async fetch(e,t,n={}){let{id:i,multiaddrs:s}=Wh(e);return s!=null&&await this.components.peerStore.addressBook.add(i,s),await this.fetchService.fetch(i,t,n)}async ping(e,t={}){let{id:n,multiaddrs:i}=Wh(e);return i.length>0&&await this.components.peerStore.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.registrar.handle(i,t,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async t=>{await this.components.registrar.unhandle(t)}))}onDiscoveryPeer(e){let{detail:t}=e;if(t.id.toString()===this.peerId.toString()){nu.error(new Error(U.ERR_DISCOVERED_SELF));return}t.multiaddrs.length>0&&this.components.peerStore.addressBook.add(t.id,t.multiaddrs).catch(n=>nu.error(n)),t.protocols.length>0&&this.components.peerStore.protoBook.set(t.id,t.protocols).catch(n=>nu.error(n)),this.dispatchEvent(new J("peer:discovery",{detail:t}))}};async function qie(r){return r.peerId==null&&(r.peerId=await vb()),new uD(Aie(r))}async function $ie(r){return await qie(r)}u();u();u();var _se=_(Xie(),1);u();var mD=_(LE(),1);u();var Zie="/lan",Jie="/ipfs",ese="/kad/1.0.0",tse="/dht/record",pD="/dht/provider";var rse=Number(3e5),nse=Number(30*1e3),ise=Number(5*6e4),sse=Number(30*1e3),ose=Number(30*1e3);var Axe=z("/pk/");function c1(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();return t!==4&&t!==6||n==null?!1:!(0,mD.default)(n)})}}function u1(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();return t!==4&&t!==6||n==null?!1:(0,mD.default)(n)})}}async function Ka(r){return(await Ke.digest(r)).digest}async function ls(r){return await Ka(r.toBytes())}function iu(r){return new ie(`${tse}/${K(r,"base32")}`,!1)}function ase(r){return De([Axe,r.toBytes()])}function cse(r){return K(r.subarray(0,4))==="/pk/"}function use(r){return _r(r.subarray(4))}function yD(r,e){let t=new Date;return new Sr(r,e,t).serialize()}function lse(r,e=100){let t;return()=>{clearTimeout(t),t=setTimeout(()=>r(),e)}}u();var Ese=_(Ru(),1);u();var zg=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},wD=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},fse=r=>globalThis.DOMException===void 0?new wD(r):new DOMException(r),hse=r=>{let e=r.reason===void 0?fse("This operation was aborted."):r.reason;return e instanceof Error?e:fse(e)};function ED(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(hse(c)),c.addEventListener("abort",()=>{a(hse(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 zg(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 bD(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 od=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)},su,qg=class{constructor(){su.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&od(this,su,"f")[this.size-1].priority>=t.priority){od(this,su,"f").push(n);return}let i=bD(od(this,su,"f"),n,(s,o)=>o.priority-s.priority);od(this,su,"f").splice(i,0,n)}dequeue(){let e=od(this,su,"f").shift();return e?.run}filter(e){return od(this,su,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return od(this,su,"f").length}};su=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},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)},en,Hg,Gg,Zl,Ob,Wg,Cb,Mo,$g,fs,Db,hs,jg,Xl,Pb,dse,pse,wse,mse,yse,gse,kb,_D,vD,Lb,Nb,Rxe=new zg,SD=class extends Error{},ou=class extends Ese.default{constructor(e){var t,n,i,s;if(super(),en.add(this),Hg.set(this,void 0),Gg.set(this,void 0),Zl.set(this,0),Ob.set(this,void 0),Wg.set(this,void 0),Cb.set(this,0),Mo.set(this,void 0),$g.set(this,void 0),fs.set(this,void 0),Db.set(this,void 0),hs.set(this,0),jg.set(this,void 0),Xl.set(this,void 0),Pb.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:qg,...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,Hg,e.carryoverConcurrencyCount,"f"),Dr(this,Gg,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),Dr(this,Ob,e.intervalCap,"f"),Dr(this,Wg,e.interval,"f"),Dr(this,fs,new e.queueClass,"f"),Dr(this,Db,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Dr(this,Pb,e.throwOnTimeout===!0,"f"),Dr(this,Xl,e.autoStart===!1,"f")}get concurrency(){return Se(this,jg,"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,jg,e,"f"),Se(this,en,"m",Lb).call(this)}async add(e,t={}){return new Promise((n,i)=>{let s=async()=>{var o,a,c;Dr(this,hs,(a=Se(this,hs,"f"),a++,a),"f"),Dr(this,Zl,(c=Se(this,Zl,"f"),c++,c),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted){i(new SD("The task was aborted."));return}let f=await(this.timeout===void 0&&t.timeout===void 0?e({signal:t.signal}):ED(Promise.resolve(e({signal:t.signal})),t.timeout===void 0?this.timeout:t.timeout,()=>{(t.throwOnTimeout===void 0?Se(this,Pb,"f"):t.throwOnTimeout)&&i(Rxe)}));n(f),this.emit("completed",f)}catch(l){i(l),this.emit("error",l)}Se(this,en,"m",wse).call(this)};Se(this,fs,"f").enqueue(s,t),Se(this,en,"m",kb).call(this),this.emit("add")})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return Se(this,Xl,"f")?(Dr(this,Xl,!1,"f"),Se(this,en,"m",Lb).call(this),this):this}pause(){Dr(this,Xl,!0,"f")}clear(){Dr(this,fs,new(Se(this,Db,"f")),"f")}async onEmpty(){Se(this,fs,"f").size!==0&&await Se(this,en,"m",Nb).call(this,"empty")}async onSizeLessThan(e){Se(this,fs,"f").size<e||await Se(this,en,"m",Nb).call(this,"next",()=>Se(this,fs,"f").size<e)}async onIdle(){Se(this,hs,"f")===0&&Se(this,fs,"f").size===0||await Se(this,en,"m",Nb).call(this,"idle")}get size(){return Se(this,fs,"f").size}sizeBy(e){return Se(this,fs,"f").filter(e).length}get pending(){return Se(this,hs,"f")}get isPaused(){return Se(this,Xl,"f")}};Hg=new WeakMap,Gg=new WeakMap,Zl=new WeakMap,Ob=new WeakMap,Wg=new WeakMap,Cb=new WeakMap,Mo=new WeakMap,$g=new WeakMap,fs=new WeakMap,Db=new WeakMap,hs=new WeakMap,jg=new WeakMap,Xl=new WeakMap,Pb=new WeakMap,en=new WeakSet,dse=function(){return Se(this,Gg,"f")||Se(this,Zl,"f")<Se(this,Ob,"f")},pse=function(){return Se(this,hs,"f")<Se(this,jg,"f")},wse=function(){var e;Dr(this,hs,(e=Se(this,hs,"f"),e--,e),"f"),Se(this,en,"m",kb).call(this),this.emit("next")},mse=function(){this.emit("empty"),Se(this,hs,"f")===0&&this.emit("idle")},yse=function(){Se(this,en,"m",vD).call(this),Se(this,en,"m",_D).call(this),Dr(this,$g,void 0,"f")},gse=function(){let e=Date.now();if(Se(this,Mo,"f")===void 0){let t=Se(this,Cb,"f")-e;if(t<0)Dr(this,Zl,Se(this,Hg,"f")?Se(this,hs,"f"):0,"f");else return Se(this,$g,"f")===void 0&&Dr(this,$g,setTimeout(()=>{Se(this,en,"m",yse).call(this)},t),"f"),!0}return!1},kb=function(){if(Se(this,fs,"f").size===0)return Se(this,Mo,"f")&&clearInterval(Se(this,Mo,"f")),Dr(this,Mo,void 0,"f"),Se(this,en,"m",mse).call(this),!1;if(!Se(this,Xl,"f")){let e=!Se(this,en,"a",gse);if(Se(this,en,"a",dse)&&Se(this,en,"a",pse)){let t=Se(this,fs,"f").dequeue();return t?(this.emit("active"),t(),e&&Se(this,en,"m",_D).call(this),!0):!1}}return!1},_D=function(){Se(this,Gg,"f")||Se(this,Mo,"f")!==void 0||(Dr(this,Mo,setInterval(()=>{Se(this,en,"m",vD).call(this)},Se(this,Wg,"f")),"f"),Dr(this,Cb,Date.now()+Se(this,Wg,"f"),"f"))},vD=function(){Se(this,Zl,"f")===0&&Se(this,hs,"f")===0&&Se(this,Mo,"f")&&(clearInterval(Se(this,Mo,"f")),Dr(this,Mo,void 0,"f")),Dr(this,Zl,Se(this,Hg,"f")?Se(this,hs,"f"):0,"f"),Se(this,en,"m",Lb).call(this)},Lb=function(){for(;Se(this,en,"m",kb).call(this););},Nb=async function(e,t){return new Promise(n=>{let i=()=>{t&&!t()||(this.off(e,i),n())};this.on(e,i)})};var vse=_(pn(),1);var Cxe="kad-close",Dxe=50,bse=20,Pxe=1e4,kxe=10,xD="routing-table-size",Nxe="ping-queue-size",Oxe="ping-running",Bb=class{constructor(e,t){let{kBucketSize:n,pingTimeout:i,lan:s,pingConcurrency:o,protocol:a,tagName:c,tagValue:l}=t;this.components=e,this.log=D(`libp2p:kad-dht:${s?"lan":"wan"}:routing-table`),this.kBucketSize=n??bse,this.pingTimeout=i??Pxe,this.pingConcurrency=o??kxe,this.lan=s,this.running=!1,this.protocol=a,this.tagName=c??Cxe,this.tagValue=l??Dxe;let f=()=>{this.components.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:Nxe,value:this.pingQueue.size}),this.components.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:Oxe,value:this.pingQueue.pending})};this.pingQueue=new ou({concurrency:this.pingConcurrency}),this.pingQueue.addListener("add",f),this.pingQueue.addListener("next",f),this._onPing=this._onPing.bind(this)}isStarted(){return this.running}async start(){this.running=!0;let e=new _se.default({localNodeId:await ls(this.components.peerId),numberOfNodesPerKBucket:this.kBucketSize,numberOfNodesToPing:1});this.kb=e,e.on("ping",this._onPing),this._tagPeers(e)}async stop(){this.running=!1,this.pingQueue.clear(),this.kb=void 0}_tagPeers(e){let t=new Ai,n=lse(()=>{let i=new Ai(e.closest(e.localNodeId,bse).map(a=>a.peer)),s=i.difference(t),o=t.difference(i);Promise.resolve().then(async()=>{for(let a of s)await this.components.peerStore.tagPeer(a,this.tagName,{value:this.tagValue});for(let a of o)await this.components.peerStore.unTagPeer(a,this.tagName)}).catch(a=>{this.log.error("Could not update peer tags",a)}),t=i});e.on("added",()=>{n()}),e.on("removed",()=>{n()})}_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 vse.TimeoutController(this.pingTimeout);let o={signal:s.signal};this.log("pinging old contact %p",i.peer),(await(await this.components.connectionManager.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.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:xD,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 ls(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 ls(e);this.kb.add({id:t,peer:e}),this.log("added %p with kad id %b",e,t),this.components.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:xD,value:this.size})}async remove(e){if(this.kb==null)throw new Error("RoutingTable is not started");let t=await ls(e);this.kb.remove(t),this.components.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:xD,value:this.size})}};u();u();var Sse=[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 Tse=_(TD(),1),Ise=_(pn(),1);var Mb=15,Ub=class{constructor(e){let{peerRouting:t,routingTable:n,refreshInterval:i,refreshQueryTimeout:s,lan:o}=e;this.log=D(`libp2p:kad-dht:${o?"lan":"wan"}:routing-table:refresh`),this.peerRouting=t,this.routingTable=n,this.refreshInterval=i??ise,this.refreshQueryTimeout=s??sse,this.commonPrefixLengthRefreshedAt=[],this.refreshTable=this.refreshTable.bind(this)}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 Ise.TimeoutController(this.refreshQueryTimeout);try{let o=await(0,Tse.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>Mb&&(e=Mb);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=gi(2),n=(t[1]<<8)+t[0],i=await this._makePeerId(this.routingTable.kb.localNodeId,n,e);return _r(i)}async _makePeerId(e,t,n){if(n>Mb)throw new Error(`Cannot generate peer ID for common prefix length greater than ${Mb}`);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=Sse[c],f=new ArrayBuffer(34),h=new DataView(f,0,f.byteLength);return h.setUint8(0,Ke.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=Gc(this.routingTable.kb.localNodeId,e),n=0;for(let i of t)if(i===0)n++;else break;yield n}}};u();var Lse=_(V(),1);var Bse=_(Rse(),1),Mse=_(Dse(),1);u();u();var Pse;(function(r){let e;r.codec=()=>(e==null&&(e=ct((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=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(Pse||(Pse={}));var Jl;(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=()=>Mi(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=()=>Mi(i)}(n=r.ConnectionType||(r.ConnectionType={}));let s;(function(a){let c;a.codec=()=>(c==null&&(c=ct((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=>at(l,a.codec()),a.decode=l=>ot(l,a.codec())})(s=r.Peer||(r.Peer={}));let o;r.codec=()=>(o==null&&(o=ct((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=>at(a,r.codec()),r.decode=a=>ot(a,r.codec())})(Jl||(Jl={}));var tn=Jl.MessageType,Uxe=Jl.ConnectionType,Ose=Object.keys(tn),wr=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 Jl.encode({key:this.key,type:this.type,clusterLevelRaw:this.clusterLevelRaw,closerPeers:this.closerPeers.map(kse),providerPeers:this.providerPeers.map(kse),record:this.record==null?void 0:this.record.serialize().subarray()})}static deserialize(e){let t=Jl.decode(e),n=new wr(t.type??Jl.MessageType.PUT_VALUE,t.key??Uint8Array.from([]),t.clusterLevelRaw??0);return n.closerPeers=t.closerPeers.map(Nse),n.providerPeers=t.providerPeers.map(Nse),t.record?.length!=null&&(n.record=Sr.deserialize(t.record)),n}};function kse(r){return{id:r.id.toBytes(),addrs:(r.multiaddrs??[]).map(t=>t.bytes),connection:Uxe.CONNECTED}}function Nse(r){if(r.id==null)throw new Error("Invalid peer in message");return{id:_r(r.id),multiaddrs:(r.addrs??[]).map(e=>ee(e)),protocols:[]}}u();function ID(r){return{...r,name:"SENDING_QUERY",type:0,messageName:r.type,messageType:Ose.indexOf(r.type.toString())}}function Yg(r){return{...r,name:"PEER_RESPONSE",type:1,messageName:r.messageType,closer:r.closer!=null?r.closer:[],providers:r.providers!=null?r.providers:[]}}function Qg(r){return{...r,name:"FINAL_PEER",type:2}}function hi(r){return{...r,name:"QUERY_ERROR",type:3}}function AD(r){return{...r,name:"PROVIDER",type:4}}function Xg(r){return{...r,name:"VALUE",type:5}}function RD(r){return{...r,name:"DIALING_PEER",type:7}}var Fb=class extends Fe{constructor(e,t){super();let{protocol:n,lan:i}=t;this.components=e,this.log=D(`libp2p:kad-dht:${i?"lan":"wan"}:network`),this.running=!1,this.protocol=n}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 RD({peer:e}),yield ID({to:e,type:t.type});let i;try{let o=await(await this.components.connectionManager.openConnection(e,n)).newStream(this.protocol,n),a=await this._writeReadMessage(o,t.serialize(),n);yield Yg({from:e,messageType:a.type,closer:a.closerPeers,providers:a.providerPeers,record:a.record})}catch(s){yield hi({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 RD({peer:e}),yield ID({to:e,type:t.type});let i;try{let o=await(await this.components.connectionManager.openConnection(e,n)).newStream(this.protocol,n);await this._writeMessage(o,t.serialize(),n),yield Yg({from:e,messageType:t.type})}catch(s){yield hi({from:e,error:s})}finally{i?.close()}}async _writeMessage(e,t,n){n.signal!=null&&(e=Zn(e,n.signal)),await de([t],cr(),e,Bse.default)}async _writeReadMessage(e,t,n){n.signal!=null&&(e=Zn(e,n.signal));let i=await de([t],cr(),e,ur(),async o=>{let a=await(0,Mse.default)(o);if(a!=null)return a;throw(0,Lse.default)(new Error("No message received"),"ERR_NO_MESSAGE_RECEIVED")}),s=wr.deserialize(i);return s.closerPeers.forEach(o=>{this.dispatchEvent(new J("peer",{detail:o}))}),s.providerPeers.forEach(o=>{this.dispatchEvent(new J("peer",{detail:o}))}),s}};u();var qb=_(V(),1);u();var l1=_(V(),1);function f1(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,l1.default)(new Error(o),"ERR_INVALID_RECORD_KEY_TYPE")}return s(t,e.value)}var Fxe=async(r,e)=>{if(!(r instanceof Uint8Array))throw(0,l1.default)(new Error('"key" must be a Uint8Array'),"ERR_INVALID_RECORD_KEY_NOT_BUFFER");if(r.byteLength<5)throw(0,l1.default)(new Error("invalid public key record"),"ERR_INVALID_RECORD_KEY_TOO_SHORT");if(K(r.subarray(0,4))!=="/pk/")throw(0,l1.default)(new Error("key was not prefixed with /pk/"),"ERR_INVALID_RECORD_KEY_BAD_PREFIX");let n=r.slice(4),i=await Ke.digest(e);if(!Be(n,i.bytes))throw(0,l1.default)(new Error("public key does not match passed in key"),"ERR_INVALID_RECORD_HASH_MISMATCH")},Use={pk:Fxe};u();var Vb=_(V(),1);function Fse(r,e,t){if(t.length===0){let o="No records given";throw(0,Vb.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,Vb.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,Vb.default)(new Error(o),"ERR_UNRECOGNIZED_KEY_PREFIX")}return t.length===1?0:s(e,t)}function Vxe(r,e){return 0}var Vse={pk:Vxe};var Hse=_(CD(),1),Gse=_(DD(),1);var $b=class{constructor(e,t){let{validators:n,selectors:i,peerRouting:s,queryManager:o,routingTable:a,network:c,lan:l}=t;this.components=e,this.log=D(`libp2p:kad-dht:${l?"lan":"wan"}:content-fetching`),this.validators=n,this.selectors=i,this.peerRouting=s,this.queryManager=o,this.routingTable=a,this.network=c}async putLocal(e,t){let n=iu(e);await this.components.datastore.put(n,t)}async getLocal(e){this.log("getLocal %b",e);let t=iu(e);this.log("fetching record for key %k",t);let n=await this.components.datastore.get(t);this.log("found %k in local datastore",t);let i=Sr.deserialize(n);return await f1(this.validators,i),i}async*sendCorrectionRecord(e,t,n,i={}){this.log("sendCorrection for %b",e);let s=await yD(e,n);for(let{value:o,from:a}of t){if(Be(o,n)){this.log("record was ok");continue}if(this.components.peerId.equals(a)){try{let f=iu(e);this.log(`Storing corrected record for key ${f.toString()}`),await this.components.datastore.put(f,s.subarray())}catch(f){this.log.error("Failed error correcting self",f)}continue}let c=!1,l=new wr(tn.PUT_VALUE,e,0);l.record=Sr.deserialize(s);for await(let f of this.network.sendRequest(a,l,i))f.name==="PEER_RESPONSE"&&f.record!=null&&Be(f.record.value,Sr.deserialize(s).value)&&(c=!0),yield f;c||(yield hi({from:a,error:(0,qb.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 yD(e,t),s=iu(e);this.log(`storing record for key ${s.toString()}`),await this.components.datastore.put(s,i.subarray()),yield*de(this.peerRouting.getClosestPeers(e,{signal:n.signal}),o=>(0,Gse.default)(o,a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[],l=new wr(tn.PUT_VALUE,e,0);l.record=Sr.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&&Be(f.record.value,Sr.deserialize(i).value)||c.push(hi({from:a.peer.id,error:(0,qb.default)(new Error("value not put correctly"),"ERR_PUT_VALUE_INVALID")})));return c}),o=>(0,Hse.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=Fse(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,qb.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 Xg({value:a.value,from:this.components.peerId})}catch(a){this.log("error getting local value for %b",e,a)}let n=await Ka(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 Xg({from:a,value:l.record.value}))};yield*this.queryManager.run(e,i,o,t)}};u();var Wse=_(CD(),1),jse=_(DD(),1);var Hb=class{constructor(e,t){let{network:n,peerRouting:i,queryManager:s,routingTable:o,providers:a,lan:c}=t;this.components=e,this.log=D(`libp2p:kad-dht:${c?"lan":"wan"}:content-routing`),this.network=n,this.peerRouting=i,this.queryManager=s,this.routingTable=o,this.providers=a}async*provide(e,t,n={}){this.log("provide %s",e),await this.providers.addProvider(e,this.components.peerId);let i=new wr(tn.ADD_PROVIDER,e.bytes,0);i.providerPeers=[{id:this.components.peerId,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(hi({from:a.peer.id,error:l}))}return c};yield*de(this.peerRouting.getClosestPeers(e.multihash.bytes,n),a=>(0,jse.default)(a,c=>o(c)),a=>(0,Wse.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 Ka(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.peerStore.addressBook.get(h)??[]).map(p=>p.multiaddr),protocols:[]});yield Yg({from:this.components.peerId,messageType:tn.GET_PROVIDERS,providers:f}),yield AD({from:this.components.peerId,providers:f})}if(a.length>=n)return;let c=async function*({peer:f,signal:h}){let p=new wr(tn.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 AD({from:f.from,providers:h})),l.size===n)return}}};u();var ad=_(V(),1);u();var Gb=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 ls(e),n={peerId:e,distance:Gc(this.originDhtKey,t)};this.peerDistances.push(n),this.peerDistances.sort((i,s)=>Vf(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(ls)),n=this.peerDistances[this.peerDistances.length-1].distance;for(let i of t){let s=Gc(this.originDhtKey,i);if(Vf(s,n)<0)return!0}return!1}};var Wb=class{constructor(e,t){let{routingTable:n,network:i,validators:s,queryManager:o,lan:a}=t;this.components=e,this.routingTable=n,this.network=i,this.validators=s,this.queryManager=o,this.log=D(`libp2p:kad-dht:${a?"lan":"wan"}:peer-routing`)}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.peerStore.get(n)}catch(i){if(i.code!=="ERR_NOT_FOUND")throw i}}if(t==null)try{t=await this.components.peerStore.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 wr(tn.GET_VALUE,t,0);yield*this.network.sendRequest(e,i,n)}async*getPublicKeyFromNode(e,t={}){let n=ase(e);for await(let i of this._getValueSingle(e,n,t))if(yield i,i.name==="PEER_RESPONSE"&&i.record!=null){let s=await sn(w6.marshalPublicKey({bytes:i.record.value}));if(!s.equals(e))throw(0,ad.default)(new Error("public key does not match id"),"ERR_PUBLIC_KEY_DOES_NOT_MATCH_ID");if(s.publicKey==null)throw(0,ad.default)(new Error("public key missing"),"ERR_PUBLIC_KEY_MISSING");yield Xg({from:e,value:s.publicKey})}throw(0,ad.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 Qg({from:this.components.peerId,peer:n});return}let i=await ls(e),s=this.routingTable.closestPeers(i);if(s.find(f=>f.equals(e))!=null)try{let f=await this.components.peerStore.get(e);this.log("found in peerStore"),yield Qg({from:this.components.peerId,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 wr(tn.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 Qg({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 hi({from:this.components.peerId,error:(0,ad.default)(new Error("Not found"),"ERR_NOT_FOUND")}))}async*getClosestPeers(e,t={}){this.log("getClosestPeers to %b",e);let n=await Ka(e),i=this.routingTable.closestPeers(n),s=this,o=new Gb(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 wr(tn.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 Qg({from:this.components.peerId,peer:{id:c,multiaddrs:(await this.components.peerStore.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 hi({from:i.from,error:(0,ad.default)(new Error(o),"ERR_INVALID_RECORD")});continue}yield i}}async _verifyRecordOnline(e){if(e.timeReceived==null)throw(0,ad.default)(new Error("invalid record received"),"ERR_INVALID_RECORD");await f1(this.validators,new Sr(e.key,e.value,e.timeReceived))}async getCloserPeersOffline(e,t){let n=await Ka(e),i=this.routingTable.closestPeers(n),s=[];for(let o of i)if(!o.equals(t))try{let a=await this.components.peerStore.addressBook.get(o),c=await this.components.peerStore.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 Yse=_(qd(),1),PD=_(Jo(),1);var au=D("libp2p:kad-dht:providers"),jb=class{constructor(e,t={}){let{cacheSize:n,cleanupInterval:i,provideValidity:s}=t;this.components=e,this.cleanupInterval=i??36e5,this.provideValidity=s??864e5,this.cache=(0,Yse.default)(n??256),this.syncQueue=new ou({concurrency:1}),this.started=!1}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cleaner=setInterval(()=>{this._cleanup().catch(e=>{au.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.datastore.batch(),o=this.components.datastore.query({prefix:pD});for await(let a of o)try{let{cid:c,peerId:l}=Qse(a.key),f=Xse(a.value).getTime(),h=Date.now(),p=h-f,d=p>this.provideValidity;if(au("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){au.error(c.message)}i.size>0?(au("deleting %d / %d entries",n,t),await s.commit()):au("nothing to delete");for(let[a,c]of i){let l=Zg(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)}}au("Cleanup successful (%dms)",Date.now()-e)})}async _getProvidersMap(e){let t=Zg(e),n=this.cache.get(t);return n==null&&(n=await jxe(this.components.datastore,e),this.cache.set(t,n)),n}async addProvider(e,t){return await this.syncQueue.add(async()=>{au("%p provides %s",t,e);let n=await this._getProvidersMap(e);au("loaded %s provs",n.size);let i=new Date;n.set(t.toString(),i);let s=Zg(e);this.cache.set(s,n),await Wxe(this.components.datastore,e,t,i)})}async getProviders(e){return await this.syncQueue.add(async()=>(au("get providers for %s",e),[...(await this._getProvidersMap(e)).keys()].map(n=>ce(n))))}};function Zg(r){let e=typeof r=="string"?r:K(r.multihash.bytes,"base32");return`${pD}/${e}`}async function Wxe(r,e,t,n){let i=[Zg(e),"/",t.toString()].join(""),s=new ie(i),o=Uint8Array.from(PD.default.encode(n.getTime()));return await r.put(s,o)}function Qse(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 jxe(r,e){let t=new Map,n=r.query({prefix:Zg(e)});for await(let i of n){let{peerId:s}=Qse(i.key);t.set(s,Xse(i.value))}return t}function Xse(r){return new Date(PD.default.decode(r))}u();var ooe=_(pn(),1),aoe=_(ri(),1);u();var Zse=_(V(),1);var Jse=_(pn(),1),eoe=_(ri(),1);var Yxe=BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");async function*toe(r){let{key:e,startingPeer:t,ourPeerId:n,signal:i,query:s,alpha:o,pathIndex:a,numPaths:c,cleanUp:l,queryFuncTimeout:f,log:h,peersSeen:p}=r,d=new ou({concurrency:o}),m=await Ka(e);function y(g,w){if(g==null)return;p.add(g);let E=BigInt("0x"+K(Gc(w,m),"base16"));d.add(async()=>{let v,x=[i];f!=null&&(v=new Jse.TimeoutController(f),x.push(v.signal));let I=(0,eoe.anySignal)(x);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 S of T.closer){if(p.has(S.id)){h("already seen %p in query",S.id);continue}if(n.equals(S.id)){h("not querying ourselves");continue}let C=await ls(S.id);if(BigInt("0x"+K(Gc(C,m),"base16"))>E){h("skipping %p as they are not closer to %b than %p",S.id,e,g);continue}h("querying closer peer %p",S.id),y(S.id,C)}d.emit("completed",T)}v?.clear()}catch(T){i.aborted?d.emit("error",T):d.emit("completed",hi({from:g,error:T}))}finally{v?.clear()}},{priority:Yxe-E}).catch(v=>{h.error(v)})}y(t,await ls(t)),yield*Qxe(d,i,l,h)}async function*Qxe(r,e,t,n){let i=Lt(),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,Zse.default)(new Error("Query aborted"),"ERR_QUERY_ABORTED"))}),t.addEventListener("cleanup",()=>{a(),i.resolve()});s;)for(await i.promise,i=Lt();o.length>0;){let c=o.shift();c!=null&&(yield c)}yield*o}var coe=_(ND(),1),Jg=_(qn(),1);var soe="running-queries",Qb=class{constructor(e,t){let{lan:n=!1,disjointPaths:i=20,alpha:s=3}=t;this.components=e,this.disjointPaths=i??20,this.controllers=new Set,this.running=!1,this.alpha=s??3,this.lan=n,this.queries=0}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 ooe.TimeoutController(ose),i.signal=s.signal;try{Jg.setMaxListeners!=null&&(0,Jg.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,aoe.anySignal)(a);try{Jg.setMaxListeners!=null&&(0,Jg.setMaxListeners)(1/0,c)}catch{}let l=D(`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 Fe;try{if(l("query:start"),this.queries++,this.components.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:soe,value:this.queries}),t.length===0){l.error("Running query with no peers");return}let d=new Ai,m=f.map((y,g)=>toe({key:e,startingPeer:y,ourPeerId:this.components.peerId,signal:c,query:n,pathIndex:g,numPaths:f.length,alpha:this.alpha,cleanUp:p,queryFuncTimeout:i.queryFuncTimeout,log:l,peersSeen:d}));for await(let y of(0,coe.default)(...m))yield y,y.name==="QUERY_ERROR"&&l("error",y.error)}catch(d){if(!(!this.running&&d.code==="ERR_QUERY_ABORTED"))throw d}finally{this.controllers.delete(o),s?.clear(),this.queries--,this.components.metrics?.updateComponentMetric({system:"libp2p",component:`kad-dht-${this.lan?"lan":"wan"}`,metric:soe,value:this.queries}),p.dispatchEvent(new J("cleanup")),l("query:done in %dms",Date.now()-h)}}};u();u();var OD=_(V(),1);var e3=D("libp2p:kad-dht:rpc:handlers:add-provider"),Xb=class{constructor(e){let{providers:t}=e;this.providers=t}async handle(e,t){if(e3("start"),t.key==null||t.key.length===0)throw(0,OD.default)(new Error("Missing key"),"ERR_MISSING_KEY");let n;try{n=A.decode(t.key)}catch{throw(0,OD.default)(new Error("Invalid CID"),"ERR_INVALID_CID")}(t.providerPeers==null||t.providerPeers.length===0)&&e3.error("no providers found in message"),await Promise.all(t.providerPeers.map(async i=>{if(!i.id.equals(e)){e3("invalid provider peer %p from %p",i.id,e);return}if(i.multiaddrs.length<1){e3("no valid addresses for provider %p. Ignore",e);return}e3("received provider %p for %s (addrs %s)",e,n,i.multiaddrs.map(s=>s.toString())),await this.providers.addProvider(n,i.id)}))}};u();var uoe=D("libp2p:kad-dht:rpc:handlers:find-node"),Zb=class{constructor(e,t){let{peerRouting:n,lan:i}=t;this.components=e,this.peerRouting=n,this.lan=Boolean(i)}async handle(e,t){uoe("incoming request from %p for peers closer to %b",e,t.key);let n=[];Be(this.components.peerId.toBytes(),t.key)?n=[{id:this.components.peerId,multiaddrs:this.components.addressManager.getAddresses().map(s=>s.decapsulateCode(Ht("p2p").code)),protocols:[]}]:n=await this.peerRouting.getCloserPeersOffline(t.key,e),n=n.map(this.lan?u1:c1).filter(({multiaddrs:s})=>s.length);let i=new wr(t.type,new Uint8Array(0),t.clusterLevel);return n.length>0?i.closerPeers=n:uoe("could not find any peers closer to %b than %p",t.key,e),i}};u();var foe=_(V(),1);var loe=D("libp2p:kad-dht:rpc:handlers:get-providers"),Jb=class{constructor(e,t){let{peerRouting:n,providers:i,lan:s}=t;this.components=e,this.peerRouting=n,this.providers=i,this.lan=Boolean(s)}async handle(e,t){let n;try{n=A.decode(t.key)}catch{throw(0,foe.default)(new Error("Invalid CID"),"ERR_INVALID_CID")}loe("%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 wr(t.type,t.key,t.clusterLevel);return o.length>0&&(c.providerPeers=o),a.length>0&&(c.closerPeers=a),loe("got %s providers %s closerPeers",o.length,a.length),c}async _getAddresses(e){return(await this.components.peerStore.addressBook.get(e)).map(n=>n.multiaddr)}async _getPeers(e){let t=[],n=this.lan?u1:c1;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 e7=_(V(),1);var d1=D("libp2p:kad-dht:rpc:handlers:get-value"),t7=class{constructor(e,t){let{peerRouting:n}=t;this.components=e,this.peerRouting=n}async handle(e,t){let n=t.key;if(d1("%p asked for key %b",e,n),n==null||n.length===0)throw(0,e7.default)(new Error("Invalid key"),"ERR_INVALID_KEY");let i=new wr(tn.GET_VALUE,n,t.clusterLevel);if(cse(n)){d1("is public key");let a=use(n),c;try{let l=await this.components.peerStore.keyBook.get(a);if(l==null)throw(0,e7.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 d1("returning found public key"),i.record=new Sr(n,c,new Date),i}let[s,o]=await Promise.all([this._checkLocalDatastore(n),this.peerRouting.getCloserPeersOffline(t.key,e)]);return s!=null&&(d1("had record for %b in local datastore",n),i.record=s),o.length>0&&(d1("had %s closer peers in routing table",o.length),i.closerPeers=o),i}async _checkLocalDatastore(e){d1("checkLocalDatastore looking for %b",e);let t=iu(e),n;try{n=await this.components.datastore.get(t)}catch(s){if(s.code==="ERR_NOT_FOUND")return;throw s}let i=Sr.deserialize(n);if(i==null)throw(0,e7.default)(new Error("Invalid record"),"ERR_INVALID_RECORD");if(i.timeReceived==null||Date.now()-i.timeReceived.getTime()>1296e5){await this.components.datastore.delete(t);return}return i}};u();var eTe=D("libp2p:kad-dht:rpc:handlers:ping"),r7=class{async handle(e,t){return eTe("ping from %p",e),t}};u();var hoe=_(V(),1);var n7=class{constructor(e,t){let{validators:n}=t;this.components=e,this.log=D("libp2p:kad-dht:rpc:handlers:put-value"),this.validators=n}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,hoe.default)(new Error(s),"ERR_EMPTY_RECORD")}try{await f1(this.validators,i),i.timeReceived=new Date;let s=iu(i.key);await this.components.datastore.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 i7=class{constructor(e,t){let{providers:n,peerRouting:i,validators:s,lan:o}=t;this.log=D("libp2p:kad-dht:rpc"),this.routingTable=t.routingTable,this.handlers={[tn.GET_VALUE]:new t7(e,{peerRouting:i}),[tn.PUT_VALUE]:new n7(e,{validators:s}),[tn.FIND_NODE]:new Zb(e,{peerRouting:i,lan:o}),[tn.ADD_PROVIDER]:new Xb({providers:n}),[tn.GET_PROVIDERS]:new Jb(e,{peerRouting:i,providers:n,lan:o}),[tn.PING]:new r7}}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 de(t,ur(),async function*(o){for await(let a of o){let c=wr.deserialize(a);s.log("incoming %s from %p",c.type,i);let l=await s.handleMessage(i,c);l!=null&&(yield l.serialize())}},cr(),t)}).catch(t=>{this.log.error(t)})}};u();var s7=class extends Fe{constructor(e,t){super();let{protocol:n,lan:i}=t;this.components=e,this.log=D(`libp2p:kad-dht:topology-listener:${i?"lan":"wan"}`),this.running=!1,this.protocol=n}isStarted(){return this.running}async start(){if(this.running)return;this.running=!0;let e=f0({onConnect:t=>{this.log("observed peer %p with protocol %s",t,this.protocol),this.dispatchEvent(new J("peer",{detail:t}))}});this.registrarId=await this.components.registrar.register(this.protocol,e)}stop(){this.running=!1,this.registrarId!=null&&(this.components.registrar.unregister(this.registrarId),this.registrarId=void 0)}};u();var LD=_(qn(),1),doe=_(Ep(),1),poe=_(TD(),1);var moe=_(pn(),1),yoe=_(ri(),1);var o7=class{constructor(e,t){let{peerRouting:n,lan:i,count:s,interval:o,queryTimeout:a}=t;this.components=e,this.log=D(`libp2p:kad-dht:${i?"lan":"wan"}:query-self`),this.running=!1,this.peerRouting=n,this.count=s??20,this.interval=o??rse,this.queryTimeout=a??nse}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 moe.TimeoutController(this.queryTimeout);try{this.controller=new AbortController;let t=(0,yoe.anySignal)([this.controller.signal,e.signal]);try{LD.setMaxListeners!=null&&(0,LD.setMaxListeners)(1/0,t)}catch{}let n=await de(this.peerRouting.getClosestPeers(this.components.peerId.toBytes(),{signal:t}),i=>(0,doe.default)(i,this.count),async i=>await(0,poe.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 tTe=32,rTe=64,t3=class extends Fe{constructor(e,t){super();let{kBucketSize:n,clientMode:i,validators:s,selectors:o,querySelfInterval:a,lan:c,protocolPrefix:l,pingTimeout:f,pingConcurrency:h,maxInboundStreams:p,maxOutboundStreams:d}=t;this.running=!1,this.components=e,this.lan=Boolean(c),this.log=D(`libp2p:kad-dht:${c===!0?"lan":"wan"}`),this.protocol=`${l??Jie}${c===!0?Zie:""}${ese}`,this.kBucketSize=n??20,this.clientMode=i??!0,this.maxInboundStreams=p??tTe,this.maxOutboundStreams=d??rTe,this.routingTable=new Bb(e,{kBucketSize:n,lan:this.lan,pingTimeout:f,pingConcurrency:h,protocol:this.protocol}),this.providers=new jb(e),this.validators={...Use,...s},this.selectors={...Vse,...o},this.network=new Fb(e,{protocol:this.protocol,lan:this.lan}),this.queryManager=new Qb(e,{disjointPaths:Math.ceil(this.kBucketSize/2),lan:c}),this.peerRouting=new Wb(e,{routingTable:this.routingTable,network:this.network,validators:this.validators,queryManager:this.queryManager,lan:this.lan}),this.contentFetching=new $b(e,{validators:this.validators,selectors:this.selectors,peerRouting:this.peerRouting,queryManager:this.queryManager,routingTable:this.routingTable,network:this.network,lan:this.lan}),this.contentRouting=new Hb(e,{network:this.network,peerRouting:this.peerRouting,queryManager:this.queryManager,routingTable:this.routingTable,providers:this.providers,lan:this.lan}),this.routingTableRefresh=new Ub({peerRouting:this.peerRouting,routingTable:this.routingTable,lan:this.lan}),this.rpc=new i7(e,{routingTable:this.routingTable,providers:this.providers,peerRouting:this.peerRouting,validators:this.validators,lan:this.lan}),this.topologyListener=new s7(e,{protocol:this.protocol,lan:this.lan}),this.querySelf=new o7(e,{peerRouting:this.peerRouting,interval:a,lan:this.lan}),this.network.addEventListener("peer",m=>{let y=m.detail;this.onPeerConnect(y).catch(g=>{this.log.error("could not add %p to routing table",y.id,g)}),this.dispatchEvent(new J("peer",{detail:y}))}),this.topologyListener.addEventListener("peer",m=>{let y=m.detail;Promise.resolve().then(async()=>{let g=await this.components.peerStore.addressBook.get(y),w={id:y,multiaddrs:g.map(E=>E.multiaddr),protocols:[]};await this.onPeerConnect(w)}).catch(g=>{this.log.error("could not add %p to routing table",y,g)})})}get[La](){return!0}get[Symbol.toStringTag](){return"@libp2p/kad-dht"}async onPeerConnect(e){if(this.log("peer %p connected with protocols %s",e.id,e.protocols),this.lan?e=u1(e):e=c1(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.registrar.unhandle(this.protocol),e==="client"?(this.log("enabling client mode"),this.clientMode=!0):(this.log("enabling server mode"),this.clientMode=!1,await this.components.registrar.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.addressManager.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 p1=_(V(),1),cd=_(ND(),1);var nTe=D("libp2p:kad-dht"),a7=class extends Fe{constructor(e,t,n){super(),this.components=e,this.wan=t,this.lan=n,this.wan.addEventListener("peer",i=>{this.dispatchEvent(new J("peer",{detail:i.detail}))}),this.lan.addEventListener("peer",i=>{this.dispatchEvent(new J("peer",{detail:i.detail}))})}get[La](){return!0}get[Symbol.toStringTag](){return"@libp2p/dual-kad-dht"}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,cd.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,cd.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,p1.default)(new Error("No peers found in routing table!"),"ERR_NO_PEERS_IN_ROUTING_TABLE");i||(yield hi({from:this.components.peerId,error:(0,p1.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,cd.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"&&(nTe("sent provider record for %s to %p",e,a.from),i++);if(i===0)throw s.length>0?(0,p1.default)(new Error(`Failed to provide to ${s.length} of ${n} peers`),"ERR_PROVIDES_FAILED",{errors:s}):(0,p1.default)(new Error("Failed to provide - no peers found"),"ERR_PROVIDES_FAILED")}async*findProviders(e,t={}){yield*(0,cd.default)(this.lan.findProviders(e,t),this.wan.findProviders(e,t))}async*findPeer(e,t={}){let n=!1;for await(let i of(0,cd.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,p1.default)(new Error("Peer lookup failed"),"ERR_LOOKUP_FAILED")}async*getClosestPeers(e,t={}){yield*(0,cd.default)(this.lan.getClosestPeers(e,t),this.wan.getClosestPeers(e,t))}async refreshRoutingTable(){await Promise.all([this.lan.refreshRoutingTable(),this.wan.refreshRoutingTable()])}};var BD=class extends a7{constructor(e,t){super(e,new t3(e,{protocolPrefix:"/ipfs",...t,lan:!1}),new t3(e,{protocolPrefix:"/ipfs",...t,clientMode:!1,lan:!0}))}};function goe(r){return e=>new BD(e,r)}u();var c7=D("libp2p:bootstrap"),iTe="bootstrap",sTe=50,oTe=12e4,aTe=1e3,u7=class extends Fe{constructor(e,t={list:[]}){if(t.list==null||t.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=e,this.timeout=t.timeout??aTe,this.list=[];for(let n of t.list){if(!p4.matches(n)){c7.error("Invalid multiaddr");continue}let i=ee(n),s=i.getPeerId();if(s==null){c7.error("Invalid bootstrap multiaddr without peer id");continue}let o={id:ce(s),multiaddrs:[i],protocols:[]};this.list.push(o)}this._init=t}get[La](){return!0}get[Symbol.toStringTag](){return"@libp2p/bootstrap"}isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(c7("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(e=>{c7.error(e)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let e of this.list){if(await this.components.peerStore.tagPeer(e.id,this._init.tagName??iTe,{value:this._init.tagValue??sTe,ttl:this._init.tagTTL??oTe}),this.timer==null)return;this.dispatchEvent(new J("peer",{detail:e}))}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};u7.tag="bootstrap";function woe(r){return e=>new u7(e,r)}u();u();u();var Eoe=WebSocket;u();u();var Soe=_(_oe(),1);function voe(r){return r instanceof ArrayBuffer||r?.constructor?.name==="ArrayBuffer"&&typeof r?.byteLength=="number"}var xoe=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 Soe.EventIterator(({push:o,stop:a,fail:c})=>{let l=h=>{let p=null;typeof h.data=="string"&&(p=z(h.data)),voe(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 voe(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 Toe=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 Ioe=(r,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let i of n){try{await Toe(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 Aoe=(r,e)=>{e=e??{};let t=xoe(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:Ioe(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 Roe=_(y4(),1),uTe={http:"ws",https:"wss"},lTe="ws",Coe=(r,e)=>(0,Roe.relative)(r,e,uTe,lTe);function Doe(r,e){let t=typeof window>"u"?"":window.location;e=e??{};let n=Coe(r,t.toString()),i=new Eoe(n,e.websocket);return Aoe(i,e)}u();function Poe(){throw new Error("WebSocket Servers can not be created in the browser!")}u();u();var koe=D("libp2p:websockets:socket");function Noe(r,e,t){t=t??{};let n={async sink(i){t?.signal!=null&&(i=Mr(i,t.signal));try{await r.sink(i)}catch(s){s.type!=="aborted"&&koe.error(s)}},source:t.signal!=null?Mr(r.source,t.signal):r.source,remoteAddr:e,timeline:{open:Date.now()},async close(){let i=Date.now();try{await P2(r.close(),{milliseconds:2e3})}catch{let{host:o,port:a}=n.remoteAddr.toOptions();koe("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 Boe(r){return r.filter(e=>{if(e.protoCodes().includes(290))return!1;let t=e.decapsulateCode(421);return yf.matches(t)||Su.matches(t)})}function Moe(r){return r.filter(e=>{if(e.protoCodes().includes(290))return!1;let t=e.decapsulateCode(421);return Su.matches(t)&&xu.matches(t.decapsulateCode(6).decapsulateCode(478))})}var ef=D("libp2p:websockets"),FD=class{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[q0](){return!0}async dial(e,t){ef("dialing %s",e),t=t??{};let n=await this._connect(e,t),i=Noe(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 Fa;let n=e.toOptions();ef("dialing %s:%s",n.host,n.port);let i=Lt(),s=l=>{ef.error("connection error:",l),i.reject(l)},o=Doe(Mp(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 Fa),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 Poe({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):nd||eb?Moe(e):Boe(e)}};function Uoe(r={}){return()=>new FD(r)}u();u();u();var m1=_(Jo(),1);u();function VD(r){return new Uint8Array(r)}u();var tt;(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"})(tt||(tt={}));var n3=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),KD=Object.freeze({NEW_STREAM:tt.NEW_STREAM,MESSAGE:tt.MESSAGE_INITIATOR,CLOSE:tt.CLOSE_INITIATOR,RESET:tt.RESET_INITIATOR}),Foe=Object.freeze({MESSAGE:tt.MESSAGE_RECEIVER,CLOSE:tt.CLOSE_RECEIVER,RESET:tt.RESET_RECEIVER});var zD=10*1024,qD=class{constructor(){this._pool=VD(zD),this._poolOffset=0}write(e){let t=this._pool,n=this._poolOffset;m1.default.encode(e.id<<3|e.type,t,n),n+=m1.default.encode.bytes,(e.type===tt.NEW_STREAM||e.type===tt.MESSAGE_INITIATOR||e.type===tt.MESSAGE_RECEIVER)&&e.data!=null?m1.default.encode(e.data.length,t,n):m1.default.encode(0,t,n),n+=m1.default.encode.bytes;let i=t.subarray(this._poolOffset,n);return zD-n<100?(this._pool=VD(zD),this._poolOffset=0):this._poolOffset=n,(e.type===tt.NEW_STREAM||e.type===tt.MESSAGE_INITIATOR||e.type===tt.MESSAGE_RECEIVER)&&e.data!=null?[i,...e.data instanceof Uint8Array?[e.data]:e.data]:[i]}},Voe=new qD;async function*Koe(r){for await(let e of r)if(Array.isArray(e))for(let t of e)yield*Voe.write(t);else yield*Voe.write(e)}u();var $D=class{constructor(){this._buffer=new et,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===tt.NEW_STREAM||i===tt.MESSAGE_INITIATOR||i===tt.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}=qoe(e),{value:i,offset:s}=qoe(e,n),o=t&7;if(n3[o]==null)throw new Error(`Invalid type received: ${o}`);return{id:t>>3,type:o,offset:n+s,length:i}}},mTe=128,zoe=127;function qoe(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&zoe)<<n:(s&zoe)*Math.pow(2,n),n+=7}while(s>=mTe);return e=i-e,{value:t,offset:e}}async function*$oe(r){let e=new $D;for await(let t of r){let n=e.write(t);n.length>0&&(yield n)}}u();var HD=1<<20;function Hoe(r){let e=r??HD,t=n=>{if(!(n.type!==tt.NEW_STREAM&&n.type!==tt.MESSAGE_INITIATOR&&n.type!==tt.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 h7=_(V(),1);var Goe=_(ri(),1);var Uo=D("libp2p:mplex:stream"),GD="ERR_STREAM_RESET",yTe="ERR_STREAM_ABORT",gTe="ERR_SINK_ENDED",wTe="ERR_DOUBLE_SINK";function Woe(r){let{id:e,name:t,send:n,onEnd:i,type:s="initiator",maxMsgSize:o=HD}=r,a=new AbortController,c=new AbortController,l=new AbortController,f=s==="initiator"?KD:Foe,h=s==="initiator"?`i${e}`:`r${e}`,p=`${t??e}`,d=!1,m=!1,y=!1,g,w={open:Date.now()},E=T=>{d||(d=!0,Uo.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)))},v=T=>{m||(m=!0,Uo.trace("%s stream %s sink end - err: %o",s,p,T),T!=null&&g==null&&(g=T),d&&(w.close=Date.now(),i?.(g)))},x=Vt({onEnd:E}),I={close:()=>{Uo.trace("%s stream %s close",s,p),I.closeRead(),I.closeWrite()},closeRead:()=>{Uo.trace("%s stream %s closeRead",s,p),!d&&x.end()},closeWrite:()=>{if(Uo.trace("%s stream %s closeWrite",s,p),!m){l.abort();try{n({id:e,type:f.CLOSE})}catch(T){Uo.trace("%s stream %s error sending close",s,t,T)}v()}},abort:T=>{Uo.trace("%s stream %s abort",s,p,T),x.end(T),a.abort(),v(T)},reset:()=>{let T=(0,h7.default)(new Error("stream reset"),GD);c.abort(),x.end(T),v(T)},sink:async T=>{if(y)throw(0,h7.default)(new Error("sink already called on stream"),wTe);if(y=!0,m)throw(0,h7.default)(new Error("stream closed for writing"),gTe);T=Mr(T,(0,Goe.anySignal)([a.signal,c.signal,l.signal]));try{s==="initiator"&&n({id:e,type:KD.NEW_STREAM,data:new et(z(p))});let S=new et;for await(let C of T)if(C.length<=o)n({id:e,type:f.MESSAGE,data:C instanceof et?C:new et(C)});else for(S.append(C);S.length!==0;){if(S.length<=o){n({id:e,type:f.MESSAGE,data:S.sublist()}),S.consume(S.length);break}n({id:e,type:f.MESSAGE,data:S.sublist(0,o)}),S.consume(o)}}catch(S){if(S.type==="aborted"&&S.message==="The operation was aborted"){if(l.signal.aborted)return;c.signal.aborted&&(S.message="stream reset",S.code=GD),a.signal.aborted&&(S.message="stream aborted",S.code=yTe)}if(S.code===GD)Uo.trace("%s stream %s reset",s,t);else{Uo.trace("%s stream %s error",s,t,S);try{n({id:e,type:f.RESET})}catch(C){Uo.trace("%s stream %s error sending reset",s,t,C)}}x.end(S),v(S);return}try{n({id:e,type:f.CLOSE})}catch(S){Uo.trace("%s stream %s error sending close",s,t,S)}v()},source:x,sourcePush:T=>{x.push(T)},sourceReadableLength(){return x.readableLength},stat:{direction:s==="initiator"?"outbound":"inbound",timeline:w},metadata:{},id:h};return I}var WD=_(V(),1),Yoe=_(lC(),1),Qoe=_(ri(),1),Fo=D("libp2p:mplex"),ETe=1024,bTe=1024,_Te=1024*1024*4,vTe=5;function joe(r){let e={...r,type:`${n3[r.type]} (${r.type})`};return r.type===tt.NEW_STREAM&&(e.data=K(r.data instanceof Uint8Array?r.data:r.data.subarray())),(r.type===tt.MESSAGE_INITIATOR||r.type===tt.MESSAGE_RECEIVER)&&(e.data=K(r.data instanceof Uint8Array?r.data:r.data.subarray(),"base16")),e}var d7=class{constructor(e){this.protocol="/mplex/6.7.0",e=e??{},this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=e,this.sink=this._createSink();let t=this._createSource();this._source=t,this.source=t,this.closeController=new AbortController,this.rateLimiter=new Yoe.RateLimiterMemory({points:e.disconnectThreshold??vTe,duration:1})}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(Fo("new %s stream %s %s",i,t),i==="initiator"&&this._streams.initiators.size===(this._init.maxOutboundStreams??bTe))throw(0,WD.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=Woe({id:t,name:n,send:l=>{Fo.enabled&&Fo.trace("%s stream %s send",i,t,joe(l)),this._source.push(l)},type:i,onEnd:()=>{Fo("%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=Mr(t,(0,Qoe.default)(n));try{await de(t,$oe,Hoe(this._init.maxMsgSize),async i=>{for await(let s of i)await this._handleIncoming(s)}),this._source.end()}catch(i){Fo("error in sink",i),this._source.end(i)}}}_createSource(){let t=XF({objectMode:!0,onEnd:n=>{this.close(n)}});return Object.assign(Koe(t),{push:t.push,end:t.end,return:t.return})}async _handleIncoming(e){let{id:t,type:n}=e;if(Fo.enabled&&Fo.trace("incoming message",joe(e)),e.type===tt.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??ETe)){Fo("too many inbound streams open"),this._source.push({id:t,type:tt.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{Fo("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){Fo("missing stream %s for message type %s",t,n3[n]);return}let o=this._init.maxStreamBufferSize??_Te;switch(n){case tt.MESSAGE_INITIATOR:case tt.MESSAGE_RECEIVER:if(s.sourceReadableLength()>o){this._source.push({id:e.id,type:n===tt.MESSAGE_INITIATOR?tt.RESET_RECEIVER:tt.RESET_INITIATOR});let a=(0,WD.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 tt.CLOSE_INITIATOR:case tt.CLOSE_RECEIVER:s.closeRead();break;case tt.RESET_INITIATOR:case tt.RESET_RECEIVER:s.reset();break;default:Fo("unknown message type %s",n)}}};var jD=class{constructor(e={}){this.protocol="/mplex/6.7.0",this._init=e}createStreamMuxer(e={}){return new d7({...e,...this._init})}};function Xoe(r={}){return()=>new jD(r)}u();u();u();function YD(r,e={}){let t=Gl(r),n=ur.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(cr.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 QD(){let r=Lt(),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 Zoe(){let r=QD(),e=QD();return[{source:r.source,sink:e.sink},{source:e.source,sink:r.sink}]}u();var Joe=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);u();var Oae=_(oae(),1),g1=_(xae(),1),A7=_(Iae(),1),hP=_(Nae(),1),Lae={hashSHA256(r){return(0,A7.hash)(r)},getHKDF(r,e){let i=new Oae.HKDF(A7.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=g1.generateKeyPair();return{publicKey:r.publicKey,privateKey:r.secretKey}},generateX25519KeyPairFromSeed(r){let e=g1.generateKeyPairFromSeed(r);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey(r,e){return g1.sharedKey(r,e)},chaCha20Poly1305Encrypt(r,e,t,n){return new hP.ChaCha20Poly1305(n).seal(e,r,t)},chaCha20Poly1305Decrypt(r,e,t,n){return new hP.ChaCha20Poly1305(n).open(e,r,t)}};u();function Mae(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 Uae(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();var PIe=r=>globalThis.Buffer?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r),l3=r=>{let e=PIe(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(0,r,!1),e};l3.bytes=2;var f3=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)};f3.bytes=2;function Fae(r){return De([r.ne,r.ciphertext],r.ne.length+r.ciphertext.length)}function Vae(r){return De([r.ne,r.ns,r.ciphertext],r.ne.length+r.ns.length+r.ciphertext.length)}function Kae(r){return De([r.ns,r.ciphertext],r.ns.length+r.ciphertext.length)}function zae(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 qae(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 $ae(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 ud=class extends Error{constructor(e="Unexpected Peer"){super(e),this.code=ud.code}static get code(){return"ERR_UNEXPECTED_PEER"}},fu=class extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=fu.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}};u();u();u();var R7;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{if(i.lengthDelimited!==!1&&n.fork(),t.webtransportCerthashes!=null)for(let s of t.webtransportCerthashes)n.uint32(10),n.bytes(s);i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={webtransportCerthashes:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let o=t.uint32();switch(o>>>3){case 1:i.webtransportCerthashes.push(t.bytes());break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(R7||(R7={}));var h3;(function(r){let e;r.codec=()=>(e==null&&(e=ct((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),(i.writeDefaults===!0||t.identityKey!=null&&t.identityKey.byteLength>0)&&(n.uint32(10),n.bytes(t.identityKey)),(i.writeDefaults===!0||t.identitySig!=null&&t.identitySig.byteLength>0)&&(n.uint32(18),n.bytes(t.identitySig)),t.extensions!=null&&(n.uint32(34),R7.codec().encode(t.extensions,n,{writeDefaults:!1})),i.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let i={identityKey:new Uint8Array(0),identitySig: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.identityKey=t.bytes();break;case 2:i.identitySig=t.bytes();break;case 4:i.extensions=R7.codec().decode(t,t.uint32());break;default:t.skipType(o&7);break}}return i})),e),r.encode=t=>at(t,r.codec()),r.decode=t=>ot(t,r.codec())})(h3||(h3={}));async function Hae(r,e,t){let n=await NIe(r,Gae(e));if(r.publicKey==null)throw new Error("PublicKey was missing from local PeerId");return kIe(r.publicKey,n,t)}function kIe(r,e,t){return h3.encode({identityKey:r,identitySig:e,extensions:t??{webtransportCerthashes:[]}}).subarray()}async function NIe(r,e){if(r.privateKey==null)throw new Error("PrivateKey was missing from PeerId");return await(await Cn(r.privateKey)).sign(e)}async function dP(r){return await sn(r.identityKey)}function pP(r){return h3.decode(r)}function Gae(r){let e=z("noise-libp2p-static-key:");return De([e,r],e.length+r.length)}async function mP(r,e,t){let n=await sn(e.identityKey);if(!n.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");let i=Gae(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 Ei(n.publicKey).verify(i,e.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return n}function d3(r){return!(!(r instanceof Uint8Array)||r.length!==32)}u();u();var Bn=D("libp2p:noise");var js;Joe?js=Bn:js=Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});function Wae(r){js(`LOCAL_STATIC_PUBLIC_KEY ${K(r.publicKey,"hex")}`),js(`LOCAL_STATIC_PRIVATE_KEY ${K(r.privateKey,"hex")}`)}function yP(r){r?(js(`LOCAL_PUBLIC_EPHEMERAL_KEY ${K(r.publicKey,"hex")}`),js(`LOCAL_PRIVATE_EPHEMERAL_KEY ${K(r.privateKey,"hex")}`)):js("Missing local ephemeral keys.")}function jae(r){js(`REMOTE_STATIC_PUBLIC_KEY ${K(r,"hex")}`)}function gP(r){js(`REMOTE_EPHEMERAL_PUBLIC_KEY ${K(r,"hex")}`)}function Yae(r){r.cs1&&r.cs2?(js(`CIPHER_STATE_1 ${r.cs1.n.getUint64()} ${K(r.cs1.k,"hex")}`),js(`CIPHER_STATE_2 ${r.cs2.n.getUint64()} ${K(r.cs2.k,"hex")}`)):js("Missing cipher state.")}u();var OIe="Cipherstate has reached maximum n, a new handshake must be performed",C7=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(OIe)}};var D7=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 Be(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 Bn(n.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(De([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 C7}}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 P7=class extends D7{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 d3(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(d3(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&&d3(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&&d3(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 k7=class{constructor(e,t,n,i,s,o,a,c){this.remoteExtensions={webtransportCerthashes:[]},this.isInitiator=e,this.payload=t,this.prologue=n,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=c??new P7(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){if(Wae(this.session.hs.s),this.isInitiator){Bn("Stage 0 - Initiator starting to send first message.");let e=this.xx.sendMessage(this.session,new Uint8Array(0));this.connection.writeLP(Fae(e)),Bn("Stage 0 - Initiator finished sending first message."),yP(this.session.hs.e)}else{Bn("Stage 0 - Responder waiting to receive first message...");let e=zae((await this.connection.readLP()).subarray()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new fu("xx handshake stage 0 validation fail");Bn("Stage 0 - Responder received first message."),gP(this.session.hs.re)}}async exchange(){if(this.isInitiator){Bn("Stage 1 - Initiator waiting to receive first message from responder...");let e=qae((await this.connection.readLP()).subarray()),{plaintext:t,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new fu("xx handshake stage 1 validation fail");Bn("Stage 1 - Initiator received the message."),gP(this.session.hs.re),jae(this.session.hs.rs),Bn("Initiator going to check remote's signature...");try{let i=pP(t);this.remotePeer=this.remotePeer||await dP(i),await mP(this.session.hs.rs,i,this.remotePeer),this.setRemoteNoiseExtension(i.extensions)}catch(i){let s=i;throw new ud(`Error occurred while verifying signed payload: ${s.message}`)}Bn("All good with the signature!")}else{Bn("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(Vae(e)),Bn("Stage 1 - Responder sent the second handshake message with signed payload."),yP(this.session.hs.e)}}async finish(){if(this.isInitiator){Bn("Stage 2 - Initiator sending third handshake message.");let e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(Kae(e)),Bn("Stage 2 - Initiator sent message with signed payload.")}else{Bn("Stage 2 - Responder waiting for third handshake message...");let e=$ae((await this.connection.readLP()).subarray()),{plaintext:t,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new fu("xx handshake stage 2 validation fail");Bn("Stage 2 - Responder received the message, finished handshake.");try{let i=pP(t);this.remotePeer=this.remotePeer||await dP(i),await mP(this.session.hs.rs,i,this.remotePeer),this.setRemoteNoiseExtension(i.extensions)}catch(i){let s=i;throw new ud(`Error occurred while verifying signed payload: ${s.message}`)}}Yae(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 fu("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteNoiseExtension(e){e&&(this.remoteExtensions=e)}};var N7=class{constructor(e={}){this.protocol="/noise";let{staticNoiseKey:t,extensions:n,crypto:i,prologueBytes:s}=e;this.crypto=i??Lae,this.extensions=n,t?this.staticKeys=this.crypto.generateX25519KeyPairFromSeed(t):this.staticKeys=this.crypto.generateX25519KeyPair(),this.prologue=s??new Uint8Array(0)}async secureOutbound(e,t,n){let i=YD(t,{lengthEncoder:l3,lengthDecoder:f3,maxDataLength:65535}),s=await this.performHandshake({connection:i,isInitiator:!0,localPeer:e,remotePeer:n});return{conn:await this.createSecureConnection(i,s),remoteExtensions:s.remoteExtensions,remotePeer:s.remotePeer}}async secureInbound(e,t,n){let i=YD(t,{lengthEncoder:l3,lengthDecoder:f3,maxDataLength:65535}),s=await this.performHandshake({connection:i,isInitiator:!1,localPeer:e,remotePeer:n});return{conn:await this.createSecureConnection(i,s),remotePeer:s.remotePeer,remoteExtensions:s.remoteExtensions}}async performHandshake(e){let t=await Hae(e.localPeer,this.staticKeys.publicKey,this.extensions);return await this.performXXHandshake(e,t)}async performXXHandshake(e,t){let{isInitiator:n,remotePeer:i,connection:s}=e,o=new k7(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]=Zoe(),s=e.unwrap();return await de(n,Mae(t),cr({lengthEncoder:l3}),s,ur({lengthDecoder:f3}),Uae(t),n),i}};u();function Qae(r={}){return()=>new N7(r)}var LIe=ze.bind({ignoreUndefined:!0,concatArrays:!0});function p3({options:r={},peerId:e,multiaddrs:t=[],repo:n,keychainConfig:i={},config:s={}}){let{datastore:o}=n,a=BIe({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}):$ie(a)}function BIe({options:r,config:e,datastore:t,keychainConfig:n,peerId:i,multiaddrs:s}){let o=()=>{let d=(0,Mt.default)(e,"Pubsub.Router")||"gossipsub",m=FQ();if(!m[d])throw(0,Xae.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,Mt.default)(r,"addresses.announce",(0,Mt.default)(e,"Addresses.Announce",[])),noAnnounce:(0,Mt.default)(r,"addresses.noAnnounce",(0,Mt.default)(e,"Addresses.NoAnnounce",[]))},connectionManager:(0,Mt.default)(r,"connectionManager",{maxConnections:(0,Mt.default)(r,"config.Swarm.ConnMgr.HighWater",(0,Mt.default)(e,"Swarm.ConnMgr.HighWater")),minConnections:(0,Mt.default)(r,"config.Swarm.ConnMgr.LowWater",(0,Mt.default)(e,"Swarm.ConnMgr.LowWater"))}),keychain:n,identify:{host:{agentVersion:`js-ipfs/${Yf}`}},contentRouters:[],peerRouters:[],peerDiscovery:[],transports:[],streamMuxers:[Xoe({maxInboundStreams:256,maxOutboundStreams:1024})],connectionEncryption:[Qae()],relay:{enabled:(0,Mt.default)(r,"relay.enabled",(0,Mt.default)(e,"relay.enabled",!0)),hop:{enabled:(0,Mt.default)(r,"relay.hop.enabled",(0,Mt.default)(e,"relay.hop.enabled",!1)),active:(0,Mt.default)(r,"relay.hop.active",(0,Mt.default)(e,"relay.hop.active",!1))}},nat:{enabled:!(0,Mt.default)(e,"Swarm.DisableNatPortMap",!1)}};(0,Mt.default)(r,"config.Pubsub.Enabled",(0,Mt.default)(e,"Pubsub.Enabled",!0))&&(c.pubsub=o()),(0,Mt.default)(e,"Routing.Type","dhtclient")!=="none"&&(c.dht=goe({clientMode:(0,Mt.default)(e,"Routing.Type","dht")!=="dhtserver",kBucketSize:(0,Mt.default)(r,"dht.kBucketSize",20),validators:{ipns:gp},selectors:{ipns:R6}}));let l=(0,Mt.default)(r,"config.Bootstrap",(0,Mt.default)(e,"Bootstrap",[]));l.length>0&&c.peerDiscovery?.push(woe({list:l}));let f=(0,Mt.default)(r,"libp2p",void 0);typeof f=="function"&&(f=void 0);let h=LIe(a,Jee(),c,f),p=(0,Mt.default)(r,"config.Addresses.Delegates",(0,Mt.default)(e,"Addresses.Delegates",[]));if(p.length>0){let d=p[Math.floor(Math.random()*p.length)],m=ee(d).toOptions(),y={host:m.host,protocol:parseInt(m.port)===443?"https":"http",port:m.port},g=aee(y);h.contentRouters?.push(pX(g)),h.peerRouters?.push(JQ(g))}return(0,Mt.default)(r,"config.Discovery.MDNS.Enabled",(0,Mt.default)(e,"Discovery.MDNS.Enabled",!0))||(h.peerDiscovery=h.peerDiscovery?.filter(d=>{try{if(typeof d=="function")return d({})[Symbol.toStringTag]!=="@libp2p/mdns"}catch{}return!0})),h.transports==null&&(h.transports=[]),h.transports.find(d=>{try{if(typeof d=="function")return d({})[Symbol.toStringTag]==="@libp2p/websockets"}catch{}return!1})==null&&h.transports.push(Uoe()),h}var wP=_(V(),1);var Jae=ze.bind({ignoreUndefined:!0}),m3=D("ipfs:components:peer:storage"),w1=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?Dj(e,t,{path:s,autoMigrate:i,onMigrationProgress:o}):s,{peerId:c,keychain:l,isNew:f}=await MIe(e,a,n);return new w1(c,l,a,e,f)}},MIe=async(r,e,t)=>{if(!e.closed)return{...await Zae(e,t),isNew:!1};try{return await e.open(),{...await Zae(e,t),isNew:!1}}catch(n){if(n.code!==hh)throw n;if(t.init&&t.init.allowNew===!1)throw new io("Initialization of new repos disabled by config, pass `config.init.isNew: true` to enable it");return{...await UIe(r,e,t),isNew:!0}}},UIe=async(r,e,t)=>{let n=t.init||{},i=await e.exists();if(m3("repo exists?",i),i===!0)throw new Error("repo already exists");let s=n.privateKey?await FIe(n.privateKey):await VIe(r,n),o=KIe(s);m3("peer identity: %s",o.PeerID);let a={...Jae(ece(bc(),n.profiles),t.config),Identity:o};await e.init(a),await e.open(),m3("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 p3({options:void 0,multiaddrs:void 0,peerId:s,repo:e,config:a,keychainConfig:c});return await e.datastore.has(new ie("/info/self"))||await l.keychain.importPeer("self",s),await e.config.set("Keychain",{DEK:l.keychain.init.dek}),{peerId:s,keychain:l.keychain}},FIe=async r=>{if(m3("using user-supplied private-key"),vs(r))return r;let e=z(r,"base64pad"),t=await Cn(e);return await sn(t.public.bytes,t.bytes)},VIe=(r,{algorithm:e="Ed25519",bits:t=2048})=>{if(r("generating %s keypair...",e),e==="Ed25519")return vb();if(e==="RSA")return Rie({bits:t});throw(0,wP.default)(new Error("Unknown PeerId algorithm"),"ERR_UNKNOWN_PEER_ID_ALGORITHM")},KIe=r=>{if(r.privateKey==null)throw(0,wP.default)(new Error("Private key missing"),"ERR_MISSING_PRIVATE_KEY");return{PeerID:r.toString(),PrivKey:K(r.privateKey,"base64pad")}},Zae=async(r,e)=>{let t=e.config,n=e.init&&e.init.profiles||[],i=e.pass,s=await r.config.getAll(),o=zIe(ece(s,n),t);if(s!==o&&await r.config.replace(o),!o.Identity||!o.Identity.PrivKey)throw new rc("No private key was found in the config, please intialize the repo");let a=z(o.Identity.PrivKey,"base64pad"),c=await Cn(a),l=await sn(c.public.bytes,c.bytes),f=await p3({options:void 0,multiaddrs:void 0,peerId:l,repo:r,config:o,keychainConfig:{pass:i,...o.Keychain}});return{peerId:l,keychain:f.keychain}},zIe=(r,e)=>e?Jae(r,e):r,ece=(r,e)=>(e||[]).reduce((t,n)=>{let i=Op[n];if(!i)throw new Error(`Could not find profile with name '${n}'`);return m3("applying profile %s",n),i.transform(t)},r);u();u();u();u();u();var gce=_(pce(),1);u();var y3=_(Jo(),1);function rAe(r){let e=new Uint8Array(r.reduce((n,i)=>n+y3.default.encodingLength(i),0)),t=0;for(let n of r)e=y3.encode(n,e,t),t+=y3.default.encodingLength(n);return e}var mce=rAe;u();var bP=_(Ci(),1);u();u();u();var g3=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(Ce)}, 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 Vo=_(Qo(),1),Ha=Vo.default.Reader,w3=Vo.default.Writer,kt=Vo.default.util,Tt=Vo.default.roots["ipfs-bitswap"]||(Vo.default.roots["ipfs-bitswap"]={}),ps=Tt.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=kt.emptyArray,r.prototype.payload=kt.emptyArray,r.prototype.blockPresences=kt.emptyArray,r.prototype.pendingBytes=0,r.encode=function(t,n){if(n||(n=w3.create()),t.wantlist!=null&&Object.hasOwnProperty.call(t,"wantlist")&&Tt.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)Tt.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)Tt.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 Ha||(t=Ha.create(t));for(var i=n===void 0?t.len:t.pos+n,s=new Tt.Message;t.pos<i;){var o=t.uint32();switch(o>>>3){case 1:{s.wantlist=Tt.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(Tt.Message.Block.decode(t,t.uint32()));break}case 4:{s.blockPresences&&s.blockPresences.length||(s.blockPresences=[]),s.blockPresences.push(Tt.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 Tt.Message)return t;var n=new Tt.Message;if(t.wantlist!=null){if(typeof t.wantlist!="object")throw TypeError(".Message.wantlist: object expected");n.wantlist=Tt.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"?kt.base64.decode(t.blocks[i],n.blocks[i]=kt.newBuffer(kt.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]=Tt.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]=Tt.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=Tt.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?kt.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]=Tt.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]=Tt.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,Vo.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=kt.emptyArray,e.prototype.full=!1,e.encode=function(n,i){if(i||(i=w3.create()),n.entries!=null&&n.entries.length)for(var s=0;s<n.entries.length;++s)Tt.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 Ha||(n=Ha.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Tt.Message.Wantlist;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:{o.entries&&o.entries.length||(o.entries=[]),o.entries.push(Tt.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 Tt.Message.Wantlist)return n;var i=new Tt.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]=Tt.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]=Tt.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,Vo.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=kt.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=w3.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 Ha||(i=Ha.create(i));for(var o=s===void 0?i.len:i.pos+s,a=new Tt.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 Tt.Message.Wantlist.Entry)return i;var s=new Tt.Message.Wantlist.Entry;switch(i.block!=null&&(typeof i.block=="string"?kt.base64.decode(i.block,s.block=kt.newBuffer(kt.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=kt.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?kt.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?Tt.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,Vo.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=kt.newBuffer([]),e.prototype.data=kt.newBuffer([]),e.encode=function(n,i){return i||(i=w3.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 Ha||(n=Ha.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Tt.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 Tt.Message.Block)return n;var i=new Tt.Message.Block;return n.prefix!=null&&(typeof n.prefix=="string"?kt.base64.decode(n.prefix,i.prefix=kt.newBuffer(kt.base64.length(n.prefix)),0):n.prefix.length>=0&&(i.prefix=n.prefix)),n.data!=null&&(typeof n.data=="string"?kt.base64.decode(n.data,i.data=kt.newBuffer(kt.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=kt.newBuffer(s.prefix))),i.bytes===String?s.data="":(s.data=[],i.bytes!==Array&&(s.data=kt.newBuffer(s.data)))),n.prefix!=null&&n.hasOwnProperty("prefix")&&(s.prefix=i.bytes===String?kt.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?kt.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,Vo.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=kt.newBuffer([]),e.prototype.type=0,e.encode=function(n,i){return i||(i=w3.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 Ha||(n=Ha.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new Tt.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 Tt.Message.BlockPresence)return n;var i=new Tt.Message.BlockPresence;switch(n.cid!=null&&(typeof n.cid=="string"?kt.base64.decode(n.cid,i.cid=kt.newBuffer(kt.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=kt.newBuffer(s.cid))),s.type=i.enums===String?"Have":0),n.cid!=null&&n.hasOwnProperty("cid")&&(s.cid=i.bytes===String?kt.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?Tt.Message.BlockPresenceType[n.type]:n.type),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Vo.default.util.toJSONOptions)},e.getTypeUrl=function(n){return n===void 0&&(n="type.googleapis.com"),n+"/Message.BlockPresence"},e}(),r})();var yce={Block:ps.Wantlist.WantType.Block,Have:ps.Wantlist.WantType.Have},nAe=(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}),Ko=class{constructor(e,t){this.set=t?cs({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(Ce),s=this.set.get(i);s?(s.inc(),s.priority=t,s.wantType===yce.Have&&n===yce.Block&&(s.wantType=n)):(this.set.set(i,new g3(e,t,n)),this._stats&&this._stats.push(null,"wantListSize",1))}remove(e){let t=e.toString(Ce),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(nAe(e=>e[1].key,Array.from(this.set.entries())))}contains(e){let t=e.toString(Ce);return this.set.has(t)}get(e){let t=e.toString(Ce);return this.set.get(t)}};Ko.Entry=g3;var iAe=Ko.Entry,rf=class{constructor(e,t,n,i,s){this.entry=new iAe(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(Ce)} <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 Ys=(r,e)=>{let t=["bitswap"];return e&&t.push(e),r&&t.push(`${r.toString().slice(0,8)}`),Object.assign((0,bP.default)(t.join(":")),{error:(0,bP.default)(t.concat(["error"]).join(":"))})};var O7=(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&&!Be(n,i)||n instanceof rf&&i instanceof rf&&!n.equals(i))return!1}return!0};var wce=_(V(),1),Ut=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=Ut.WantType.Block);let o=e.toString(Ce),a=this.wantlist.get(o);a?(a.wantType===n&&(a.priority=t),i&&(a.cancel=Boolean(i)),s&&(a.sendDontHave=Boolean(s)),n===Ut.WantType.Block&&a.wantType===Ut.WantType.Have&&(a.wantType=n)):this.wantlist.set(o,new rf(e,t,n,i,s))}addBlock(e,t){let n=e.toString(Ce);this.blocks.set(n,t)}addHave(e){let t=e.toString(Ce);this.blockPresences.has(t)||this.blockPresences.set(t,Ut.BlockPresenceType.Have)}addDontHave(e){let t=e.toString(Ce);this.blockPresences.has(t)||this.blockPresences.set(t,Ut.BlockPresenceType.DontHave)}cancel(e){let t=e.toString(Ce);this.wantlist.delete(t),this.addEntry(e,0,Ut.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 ps.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=mce([s,o,a,c]);e.payload.push(new ps.Block({prefix:l,data:n}))}for(let[t,n]of this.blockPresences)e.blockPresences.push(new ps.BlockPresence({cid:A.parse(t).bytes,type:n}));return this.pendingBytes>0&&(e.pendingBytes=this.pendingBytes),ps.encode(e).finish()}equals(e){return!(this.full!==e.full||this.pendingBytes!==e.pendingBytes||!O7(this.wantlist,e.wantlist)||!O7(this.blocks,e.blocks)||!O7(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}>`}};Ut.deserialize=async(r,e)=>{let t=ps.decode(r),n=t.wantlist&&t.wantlist.full||!1,i=new Ut(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===Ut.BlockPresenceType.Have?i.addHave(o):i.addDontHave(o)}),t.blocks.length>0?(await Promise.all(t.blocks.map(async s=>{let o=await Ke.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,gce.default)(s.prefix),a=o[0],c=o[1],l=o[2],f=l===Ke.code?Ke:e&&await e.getHasher(l);if(!f)throw(0,wce.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)};Ut.blockPresenceSize=r=>r.bytes.length+1;Ut.Entry=rf;Ut.WantType={Block:ps.Wantlist.WantType.Block,Have:ps.Wantlist.WantType.Have};Ut.BlockPresenceType={Have:ps.BlockPresenceType.Have,DontHave:ps.BlockPresenceType.DontHave};u();var Ece=Math.pow(2,31)-1,bce=1e3,_ce=1;u();u();var vce=sAe;function sAe(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 L7=class{constructor(e,t,n){this.peerId=t,this.network=n,this.refcnt=1,this._entries=[],this._log=Ys(e,"msgqueue"),this.sendEntries=vce(this._sendEntries.bind(this),_ce)}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 Ut(!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 B7=class{constructor(e,t,n,i){this.peers=cs({system:"ipfs",component:"bitswap",metric:"want-manager-peers",metrics:i.metrics}),this.wantlist=new Ko(n,i),this.network=t,this._stats=n,this._peerId=e,this._log=Ys(e,"want")}_addEntries(e,t,n){let i=e.map((s,o)=>new Ut.Entry(s,Ece-o,Ut.WantType.Block,t));i.forEach(s=>{s.cancel?n?this.wantlist.removeForce(s.cid.toString(Ce)):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 L7(this._peerId,e,this.network);let n=new Ut(!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 Sce=_(pn(),1);var vP="/ipfs/bitswap/1.0.0",SP="/ipfs/bitswap/1.1.0",xP="/ipfs/bitswap/1.2.0",aAe=32,cAe=128,uAe=3e4,M7=class{constructor(e,t,n,i={}){this._log=Ys(e.peerId,"network"),this._libp2p=e,this._bitswap=t,this._protocols=[vP],i.b100Only||(this._protocols.unshift(SP),this._protocols.unshift(xP)),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??aAe,this._maxOutboundStreams=i.maxOutboundStreams??cAe,this._incomingStreamTimeout=i.incomingStreamTimeout??uAe}async start(){this._running=!0,await this._libp2p.handle(this._protocols,this._onConnection,{maxInboundStreams:this._maxInboundStreams,maxOutboundStreams:this._maxOutboundStreams});let e=f0({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 Sce.TimeoutController(this._incomingStreamTimeout);Promise.resolve().then(async()=>{this._log("incoming new bitswap %s connection from %p",e.stat.protocol,t.remotePeer),await de(Mr(e.source,n.signal),ur(),async i=>{for await(let s of i){try{let o=await Ut.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([xP,SP,vP]);await lAe(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 lAe(r,e,t){try{let n;switch(r.stat.protocol){case vP:n=e.serializeToBitswap100();break;case SP:case xP:n=e.serializeToBitswap110();break;default:throw new Error("Unknown protocol: "+r.stat.protocol)}await de([n],cr(),r)}catch(n){t(n)}finally{r.close()}}u();u();var U7=class{constructor(e){this.partner=e,this.wantlist=new Ko,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 E3=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 fAe={hasNewInfo(){return!1},merge(){}},F7=class{constructor(e=fAe){this._taskMerger=e,this._byPeer=new E3([],V7.compare)}pushTasks(e,t){let n=this._byPeer.get(e.toString());n||(n=new V7(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)}},V7=class{constructor(e,t){this.peerId=e,this._taskMerger=t,this._activeTotalSize=0,this._pending=new TP,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}},TP=class{constructor(){this._tasks=new E3([],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 xce={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 Tce=Ut.WantType,hAe=16*1024,dAe=1024,K7=class{constructor(e,t,n,i,s,o={}){this._log=Ys(e,"engine"),this.blockstore=t,this.network=n,this._stats=i,this._opts=this._processOpts(o),this.ledgerMap=cs({system:"ipfs",component:"bitswap",metric:"ledger-map",metrics:s.metrics}),this._running=!1,this._requestQueue=new F7(xce)}_processOpts(e){return{maxSizeReplaceHasWithBlock:dAe,targetMessageSize:hAe,...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 Ut(!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=Ut.blockPresenceSize(i.cid)),this._requestQueue.pushTasks(t.partner,[{topic:i.cid.toString(Ce),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 Ko),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(Ce),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(Ce),a=n.get(o);if(a==null)s.sendDontHave&&i.push({topic:o,priority:s.priority,size:Ut.blockPresenceSize(s.cid),data:{isWantBlock:s.wantType===Tce.Block,blockSize:0,haveBlock:!1,sendDontHave:s.sendDontHave}});else{let c=this._sendAsBlock(s.wantType,a),l=a;c||(l=Ut.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===Tce.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(Ce),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 U7(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 Rce=_(qn(),1);var Ice=r=>`unwant:${K(r.multihash.bytes,"base64")}`,Ace=r=>`block:${K(r.multihash.bytes,"base64")}`,z7=class extends Rce.EventEmitter{constructor(e){super(),this.setMaxListeners(bce),this._log=Ys(e,"notif")}hasBlock(e,t){let n=Ace(e);this._log(n),this.emit(n,t)}wantBlock(e,t={}){if(!e)throw new Error("Not a valid cid");let n=Ace(e),i=Ice(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=Ice(e);this._log(t),this.emit(t)}};u();var Oce=_(qn(),1);u();var kce=_(qn(),1),IP=_(Pce(),1),b3=class extends kce.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,IP.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,IP.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 Nce={enabled:!1,computeThrottleTimeout:1e3,computeThrottleMaxQueueSize:1e3,movingAverageIntervals:[60*1e3,5*60*1e3,15*60*1e3]},q7=class extends Oce.EventEmitter{constructor(e,t=[],n=Nce){super();let i=Object.assign({},Nce,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 b3(t,i),this._global.on("update",s=>this.emit("update",s)),this._peers=cs({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 b3(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 Lce=_(ri(),1);var mAe={statsEnabled:!1,statsComputeThrottleTimeout:1e3,statsComputeThrottleMaxQueueSize:1e3},yAe=["blocksReceived","dataReceived","dupBlksReceived","dupDataReceived","blocksSent","dataSent","providesBufferLength","wantListLength","peerCount"],$7=class extends Ta{constructor(e,t,n={}){super(),this._libp2p=e,this._log=Ys(this.peerId),this._options=Object.assign({},mAe,n),this._stats=new q7(e,yAe,{enabled:this._options.statsEnabled,computeThrottleTimeout:this._options.statsComputeThrottleTimeout,computeThrottleMaxQueueSize:this._options.statsComputeThrottleMaxQueueSize}),this.network=new M7(e,this,this._stats,{hashLoader:n.hashLoader,maxInboundStreams:n.maxInboundStreams,maxOutboundStreams:n.maxOutboundStreams,incomingStreamTimeout:n.incomingStreamTimeout}),this.blockstore=t,this.engine=new K7(this.peerId,t,this.network,this._stats,e),this.wm=new B7(this.peerId,this.network,this._stats,e),this.notifications=new z7(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,Lce.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 Bce=(r,e,t={})=>new $7(r,e,t);var Uce=_(V(),1);u();u();var H7={};Re(H7,{abortedError:()=>gAe,notFoundError:()=>Mce});u();var AP=_(V(),1);function Mce(r){return r=r||new Error("Not Found"),(0,AP.default)(r,"ERR_NOT_FOUND")}function gAe(r){return r=r||new Error("Aborted"),(0,AP.default)(r,"ERR_ABORTED")}u();var xZt={...H7};var G7=class extends Ta{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=Dn(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=Vt({objectMode:!0}),i=Vt({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*To(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 E1=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 p3({options:s,repo:t,peerId:e,multiaddrs:wAe(e,o),config:o,keychainConfig:void 0});await a.start();for(let f of a.getMultiaddrs())n(`Swarm listening on ${f.toString()}`);let c=Bce(a,t.blocks,{statsEnabled:!0,hashLoader:i,maxInboundStreams:1024,maxOutboundStreams:1024});await c.start();let l=new G7(t.blocks,c);return t.blocks=l,t.pins.blockstore=l,new E1(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()}},wAe=(r,e)=>{let t=r.toString(),n=[],i=e.Addresses&&e.Addresses.Swarm||[];for(let s of i){let o=ee(s);if(o.protoCodes().includes(EAe))throw(0,Uce.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},EAe=479;u();u();function Fce({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 Vce({network:r}){async function e(t,n={}){let{libp2p:i}=await r.use(n);await i.dial(t,n)}return M(e)}u();function Kce({network:r}){async function e(t,n={}){let{libp2p:i}=await r.use(n);await i.hangUp(t)}return M(e)}u();function zce({network:r}){async function e(t={}){let{libp2p:n}=await r.use(t);return n.getMultiaddrs()}return M(e)}u();function qce({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 W7=class{constructor({network:e}){this.addrs=Fce({network:e}),this.connect=Vce({network:e}),this.disconnect=Kce({network:e}),this.localAddrs=zce({network:e}),this.peers=qce({network:e})}};u();var _3={success:!0,time:0,text:""};function $ce({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{..._3,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{..._3,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{..._3,time:f}}catch(f){yield{..._3,success:!1,text:f.toString()}}if(a){let l=c/a;yield{..._3,text:`Average latency: ${l}ms`}}}return M(e)}u();var hu=_(V(),1);var RP="/ipns/";function Hce(r){r.startsWith(RP)&&(r=r.substring(RP.length));let e;if((r[0]==="1"||r[0]==="Q")&&(r=`z${r}`),r[0]==="z"&&(e=Ce.decode(r)),r[0]==="k"&&(e=Fd.decode(r)),!e)throw new Error("Could not parse string");if(e[0]!==1&&e[1]!==114&&(e=De([[1,114],e])),e.length!==40)throw new Error("Incorrect length "+e.length);return De([z(RP),e.subarray(2)])}function Gce({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 b1(r,t,f),p=l instanceof Uint8Array?l:Hce(l);if(h.dht==null)throw(0,hu.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 b1(r,t,h),d=l instanceof Uint8Array?l:Hce(l);if(p.dht==null)throw(0,hu.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 b1(r,t,f);if(h.dht==null)throw(0,hu.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 b1(r,t,f);if(h.dht==null)throw(0,hu.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 b1(r,t,f);if(!await e.blocks.has(l))throw(0,hu.default)(new Error("block(s) not found locally, cannot provide"),"ERR_BLOCK_NOT_FOUND");if(f.recursive)throw(0,hu.default)(new Error("not implemented yet"),"ERR_NOT_IMPLEMENTED_YET");if(h.dht==null)throw(0,hu.default)(new Error("dht not configured"),"ERR_DHT_NOT_CONFIGURED");yield*h.dht.provide(l)},async*query(l,f={}){let{libp2p:h}=await b1(r,t,f),p,d=A.asCID(l);if(d!=null?p=d.multihash.bytes:p=ce(l.toString()).toBytes(),h.dht==null)throw(0,hu.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 b1=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 io("dht not enabled")}};return{libp2p:{dht:{get:i,put:i,findProviders:i,findPeer:i,provide:i,getClosestPeers:i}}}}};u();var Wce=_(V(),1);var jce=_(A6(),1);function Yce({network:r,config:e}){let t=(0,jce.default)(e||{},"Pubsub.Enabled",!0),n={},i;return{subscribe:t?M(s):v3,unsubscribe:t?M(o):v3,publish:t?M(a):v3,ls:t?M(c):v3,peers:t?M(l):v3};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,Wce.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 v3=async()=>{throw new io("pubsub not enabled")};var bAe=ze.bind({ignoreUndefined:!0}),nf=D("ipfs"),_Ae=3e4,CP=class{constructor({print:e,storage:t,codecs:n,options:i}){let{peerId:s,repo:o,keychain:a}=t,c=Gn.create(E1),l=_$(i.preload),f=FB(),h=VB({network:c}),p=new N6(i),d=Object.values(t4);(i.ipld&&i.ipld.hashers?i.ipld.hashers:[]).forEach(Ve=>d.push(Ve)),this.hashers=new L0({hashers:d,loadHasher:i.ipld&&i.ipld.loadHasher});let m=Object.values(_s);(i.ipld&&i.ipld.bases?i.ipld.bases:[]).forEach(Ve=>m.push(Ve)),this.bases=new N0({bases:m,loadBase:i.ipld&&i.ipld.loadBase});let y=new B4({repo:o,codecs:n}),g=new q6({codecs:n,hashers:this.hashers,preload:l,repo:o}),w=new B6({dns:f,ipns:p,repo:o,codecs:n,peerId:s,isOnline:h,keychain:a,options:i}),E=$B({repo:o,codecs:n,bases:this.bases,name:w}),v=new Vw({repo:o,codecs:n,hashers:this.hashers,preload:l}),x=Object.assign(LV({repo:o,codecs:n,resolve:E,preload:l}),{local:BV({repo:t.repo})}),{add:I,addAll:T,cat:S,get:C,ls:B}=new Pw({preload:l,repo:o,options:i.EXPERIMENTAL,hashers:this.hashers}),q=dH({repo:o,preload:l,hashers:this.hashers,options:i}),W=v$({files:q,preload:l,options:i.preload});this.preload=l,this.name=w,this.ipns=p,this.pin=y,this.resolve=E,this.block=g,this.refs=x,this.start=uB({network:c,peerId:s,repo:o,preload:l,ipns:p,mfsPreload:W,print:e,keychain:a,hashers:this.hashers,options:i}),this.stop=lB({network:c,preload:l,mfsPreload:W,ipns:p,repo:o}),this.dht=Gce({network:c,repo:o,peerId:s}),this.pubsub=Yce({network:c,config:i.config}),this.dns=f,this.isOnline=h,this.id=Qq({network:c,peerId:s}),this.version=Yq({repo:o}),this.bitswap=new U6({network:c}),this.bootstrap=new V6({repo:o}),this.config=Zq({repo:o}),this.ping=$ce({network:c}),this.add=I,this.addAll=T,this.cat=S,this.get=C,this.ls=B,this.dag=v,this.files=q,this.key=new r8({keychain:a}),this.object=new i8({preload:l,codecs:n,repo:o}),this.repo=new o8({repo:o,hashers:this.hashers}),this.stats=new a8({repo:o,network:c}),this.swarm=new W7({network:c}),Object.defineProperty(this,"libp2p",{get(){let Ve=c.try();return Ve?Ve.libp2p:void 0}});let oe=()=>Promise.reject((0,j7.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")),te=async function*(){throw(0,j7.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")};this.commands=oe,this.diag={cmds:oe,net:oe,sys:oe},this.log={level:oe,ls:oe,tail:te},this.mount=oe,this.codecs=n}async init(){throw new no}},vAe=async r=>{let e=qe({Data:new $e({type:"directory"}).marshal(),Links:[]}),t=await r.block.put(e,{mhtype:"sha2-256",format:"dag-pb"});return await r.pin.add(t),t},SAe=()=>({start:!0,EXPERIMENTAL:{},preload:{enabled:!Qce.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 Zce(r={}){r=bAe(SAe(),r);let e=r.init||{},t={name:rn.name,code:rn.code,encode:l=>l,decode:l=>l},n=Object.values(r4);[gt,tc,Ud,K1,t].concat(r.ipld&&r.ipld.codecs||[]).forEach(l=>n.push(l));let i=new O0({codecs:n,loadCodec:r.ipld&&r.ipld.loadCodec}),s=r.silent?nf:console.log;nf("creating repo");let o=await w1.start(s,i,r);nf("getting repo config");let a=await o.repo.config.getAll(),c=new CP({storage:o,print:s,codecs:i,options:{...r,config:a}});if(nf("starting preload"),await c.preload.start(),nf("starting storage"),c.ipns.startOffline(o),o.isNew&&!e.emptyRepo){let l=await vAe(c);if(nf("adding default assets"),await(c.addAll,void 0),nf("initializing IPNS keyspace"),o.peerId.publicKey==null)throw(0,j7.default)(new Error("Public key missing"),"ERR_MISSING_PUBLIC_KEY");let f=new Xce.TimeoutController(_Ae);try{await c.ipns.initializeKeyspace(o.peerId,z(`/ipfs/${l}`),{signal:f.signal})}finally{f.clear()}}return r.start!==!1&&(nf("starting node"),await c.start()),c}var Jce=_(xR(),1),eue=_(TR(),1),xAe=Zce,TAe=Jce.default,IAe=eue.default;return aue(AAe);})();
/*!
* 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 IpfsCore}));