diff --git a/www/ipfs.js b/www/ipfs.js new file mode 100644 index 00000000..91c79a25 --- /dev/null +++ b/www/ipfs.js @@ -0,0 +1,120 @@ +(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;sf0)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>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;sa?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<>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<>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<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=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);si.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;tt&&(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;h2147483647?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;lo&&(t=o-a),l=t;l>=0;l--){let f=!0;for(let h=0;hi&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o>>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(;i239?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(;nn)&&(t=n);let i="";for(let s=e;sn&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),tt)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>>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)<>>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)<>>0,t=t>>>0,n||bn(e,t,this.length);let i=this[e],s=1,o=0;for(;++o=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)<>>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)<>>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||er.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>>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>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=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>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=t;s2**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||r3?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;o55295&&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>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=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=[];++A31)for(var t=1;t{({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!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{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"-"+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{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{"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>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;a1)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{"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;i191&&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>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-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{"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>>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>>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)<>>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)<>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<>>0,r}if(this.len-this.pos>4){for(;e<5;++e)if(r.hi=(r.hi|(this.buf[this.pos]&127)<>>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)<>>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{"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)<=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{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{"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;s0&&(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||s1?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(ae9?"":" ")+(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;i0;)a.push(l%s),l=l/s|0}for(i=0;r[i]===0&&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>=8;for(;l>0;)o.push(l&255),l>>=8}for(var f=0;r[f]===s&&f0;)s.push(a%n),a=a/n|0}var c="";for(t=0;r.at(t)===0&&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;tBpe&&(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<0);return e};O.ByteStringBuffer.prototype.getSignedInt=function(r){var e=this.getInt(r),t=2<=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=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>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<0);return e};O.DataBuffer.prototype.getSignedInt=function(r){var e=this.getInt(r),t=2<=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;e0;)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>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>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>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>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>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"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");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;tt[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()d.st&&f.stf.st&&d.st{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;oe){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;s1&&(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>>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=-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&&o0&&(n+=` +`);for(var i="",s=0;s1?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()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)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()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)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;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0)r.read-=this.blockSize;else for(var i=0;i0&&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;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0)r.read-=this.blockSize;else for(var i=0;i0&&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;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0)r.read-=this.blockSize;else for(var i=0;i0&&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;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0&&(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;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i0&&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(n0))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;i0;--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>>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;s4){var t=r;r=In.util.createBuffer();for(var n=0;n{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>>2;for(var n=0;n>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>>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>>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>>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>>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>>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>>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;ce.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{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+=yc)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{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;i65&&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>>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>>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()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()>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>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<>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=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<=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):this.data[this.t-1]|=o<=this.DB&&(s-=this.DB)}t==8&&(r[0]&128)!=0&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<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<0)for(a>a)>0&&(i=!0,s=VM(n));o>=0;)a>(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=0;--a)e.data[a+s+1]=this.data[a]>>n|o,o=(this.data[a]&i)<=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;for(var o=t+1;o>n;n>0&&(e.data[this.t-t-1]|=(this.s&s)<>=this.DB;if(r.t>=this.DB;n+=this.s}else{for(n+=this.s;t>=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=0;)r.data[t]=0;for(t=0;t=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.t0?(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<1?s.data[l-2]>>this.F2:0),p=this.FV/h,d=(1<=0&&(t.data[t.t++]=1,t.subTo(w,t)),j.ONE.dlShiftTo(l,w),w.subTo(s,s);s.t=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))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<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>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<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)<>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=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<0)for(t>t)!=(this.s&this.DM)>>t&&(e[i++]=n|this.s<=0;)t<8?(n=(this.data[r]&(1<>(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>=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?this.s!=0:(this.data[e]&1<>=this.DB;if(r.t>=this.DB;n+=this.s}else{for(n+=this.s;t>=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=0;)t.data[n]=0;for(n=Math.max(e-this.t,0);n2*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<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<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<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=0);var a=s.modPow(n,this);if(a.compareTo(j.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++{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>>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>>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>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;vp&&(h=l(p,d)),h.isProbablePrime(y))return w(null,h);h.dAddOffset(t[m++%8],0)}while(g<0||+new Date-E"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;Th&&(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>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||ac?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;c0;){for(var l=0,f=Pe.random.getBytes(o),c=0;c"u")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var l=0;l1;){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{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=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{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>>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>>0,d+=p,c.putInt32(d>>>0),d=h>>>0;c.putInt32(d);for(var y=new Array(t.length),m=0;m=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{"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;m255)return!1;return!0}function i(d,m){return(d&65535)*m+(((d>>>16)*m&65535)<<16)}function s(d,m){return 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]<>>32-m,d[1]<>>32-m]:(m-=32,[d[1]<>>32-m,d[0]<>>32-m])}function f(d,m){return m%=64,m===0?d:m<32?[d[0]<>>32-m,d[1]<>>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>>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>>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>>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):""}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>>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<>>2]=o(W),te[oe+4>>>2]=W,te[oe+8>>>2]=q<>>2]=q);let Ve=m(B,C&1024,C&2048);if(C&8192)for(let me=0;me>>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>>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._bitArrays.length)return-1;let i=this._bitArrays[n],s=e-n*7;if(!((i&1<0))return-1;let a=this._bitArrays.slice(0,n).reduce(Eye,0),c=~(4294967295<=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,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>>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;n0&&(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;n0&&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=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{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{"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{"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(;tt&&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{if(l)return n(l);try{for(let h=0;hthis.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{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{"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{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{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{"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=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-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{"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>>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>>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)<>>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)<>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<>>0,r}if(this.len-this.pos>4){for(;e<5;++e)if(r.hi=(r.hi|(this.buf[this.pos]&127)<>>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)<>>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>>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>>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>>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>>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>>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>>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>>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>>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>>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>>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>>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._headthis._capacity&&this.pop(),this._head1e4&&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._head1e4&&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(e0;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;c0;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(n0;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||n0&&(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;sthis._tail){for(s=this._head;s>>=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(;tr?(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{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{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{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{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>>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;T0;){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=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;v4294967295||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=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>8),y.push(m&255);return y},d.prototype.toFixedLengthString=function(){let m=function(){let g=[];for(let w=0;w>8,y&255,g>>8,g&255])},d.prototype.toNormalizedString=function(){let m=function(){let g=[];for(let w=0;ww&&(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;y128)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{"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;cn)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=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{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>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>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{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;o2)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;t1&&(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;o1&&(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"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"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;f128)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"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=RSe&&r0&&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"u"&&(i=new Date);var s=!0,o=null,a=0;do{var c=e.shift(),l=null,f=!1;if(i&&(ic.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&&mg.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;s0&&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;p0){for(var t=k.create(k.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n=t&&i{"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{"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{"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;tt.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=0?(this._update(n,i,e),this):n.contacts.length0&&n.length[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=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{"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>>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{"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{"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{"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{"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{"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<>>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=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{"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;a0;a++){let c=o[a];c{"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>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{"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._bufferLength0;)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;a0?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>>=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=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(var s=0;s{"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.length0&&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{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)<=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{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>>0,x=new Uint8Array(v);w!==E;){for(var I=m[w],T=0,S=v-1;(I!==0||T>>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>>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>>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{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=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;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<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>>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>>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>>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>>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>>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>>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)<=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[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)<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(;nt)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(;te)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!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;e0&&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.majore.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;t55295&&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(;e239?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(;nn.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>>8,n&255])}else if(t>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(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 et.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 nt.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.lengthe.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;ito(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;s32?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;on)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{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=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=r.substring(1);let e=so(r.length);for(let t=0;tr&&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||""})`,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;n0;n--)s.push("0");t.splice.apply(t,s)}let i=new Uint8Array(e+16);for(n=0;n>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{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)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(;tr.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;te.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(;ne.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""}};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(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;io)return!1}return t.lengtht.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.expireglobalThis.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").sizege(this,Oi,"f").size{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>>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>>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(;pc&&(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>=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;ne.toString(16).padStart(2,"0"));function op(r){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)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 _t0)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>=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;ne.toString(16).padStart(2,"0"));function xm(r){if(!(r instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;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{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;ngc){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>>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(){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.expireasync 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(sf.getTime()?-1:l.getTime()({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-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>>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:"",edges:" -> "};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(//g,r.toString());return i=i.replace(//g,e.toString()),i=i.replace(//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(ps[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;mdr(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>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.currentDepthi.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(e0&&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;n0;)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=c)continue;let l=e>=a&&ea&&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;ti+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=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;tl+(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<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._availableBits0;){let i=this._buffers[this._currentBufferIndex],s=Math.min(i.availableBits(),t),o=i.take(s);n=(n<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=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;aox({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&&n=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").sizewe(this,Ki,"f").size{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=p&&i=p&&s<=d||id)&&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;te[t])return 1}return r.byteLength>e.byteLength?1:r.byteLength=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<>wx-r.bi_valid,r.bi_valid+=t-wx):(r.bi_buf|=e<{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;lc&&(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>=7;n{let e;for(e=0;e{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]{let n=r.heap[t],i=t<<1;for(;i<=r.heap_len&&(i{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{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>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{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{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{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{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>>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<{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]&&no){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{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=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{let t,n,i;for(;;){if(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_length4096)&&(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{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]&&ir.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<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.gzindext&&(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.gzindext&&(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=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>>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{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;n4){s[i++]=65533,n+=a-1;continue}for(o&=a===2?31:a===3?15:7;a>1&&n1){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<>>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,m-=x),m<15&&(d+=B[n++]<>>24,d>>>=x,m-=x,x=v>>>16&255,x&16){if(T=v&65535,x&=15,mc){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,x2;)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<>3,n-=I,m-=I<<3,d&=(1<{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=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;h0&&(r===Lz||p!==1))return-1;for(oe[1]=0,l=1;lNz||r===Bz&&w>Oz)return 1;for(;;){me=l-y,o[f]q?(Ae=te[Ve+o[f]],$=C[B+o[f]]):(Ae=32+64,$=0),v=1<>y)+x]=me<<24|Ae<<16|$|0;while(x!==0);for(v=1<>=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<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.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{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++]<>>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<>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++]<>>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++]<>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++]<>>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>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&7,f-=f&7,t.mode=Ax;break}for(;f<3;){if(a===0)break e;a--,l+=n[s++]<>>=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++]<>>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++]<>>=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>>=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>>24,E=g>>>16&255,v=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<>>=w,f-=w,t.lens[t.have++]=v;else{if(v===16){for(W=w+2;f>>=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,f-=w,S=0,d=3+(l&7),l>>>=3,f-=3}else{for(W=w+7;f>>=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<>>24,E=g>>>16&255,v=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<>x)],w=g>>>24,E=g>>>16&255,v=g&65535,!(x+w<=f);){if(a===0)break e;a--,l+=n[s++]<>>=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>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=eq;case eq:for(;g=t.distcode[l&(1<>>24,E=g>>>16&255,v=g&65535,!(w<=f);){if(a===0)break e;a--,l+=n[s++]<>x)],w=g>>>24,E=g>>>16&255,v=g&65535,!(x+w<=f);){if(a===0)break e;a--,l+=n[s++]<>>=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>>=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++]<{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(;tt&&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-ne&&(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").sizeEe(this,qi,"f").size{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{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(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.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(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{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{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(){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{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>>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(no.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({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{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>>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{function r(e){if(this.addrs=[],e)for(var t=Object.keys(e),n=0;n>>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>>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>>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>>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{function r(t){if(t)for(var n=Object.keys(t),i=0;i>>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>>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>>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>>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>>0,t.seq.high>>>0).toNumber(!0):t.seq),t.addresses&&t.addresses.length){i.addresses=[];for(var o=0;o>>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(ll)){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").sizebe(this,ji,"f").size{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;st=>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>>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)<>>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)<>>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)<>>0,n.get(t++)<128)return i}else if(t=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(n.get(t)&127)<>>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 rNumber.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>>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>>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{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;tCEe});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>>0,x=new Uint8Array(v);w!==E;){for(var I=m[w],T=0,S=v-1;(I!==0||T>>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>>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>>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{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=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;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<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)<=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[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=r.substring(1);let e=h5(r.length);for(let t=0;t0,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.meshMessageDeliveries0&&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.expireXn(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.firstMessageDeliveriesa.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),n.behaviourPenalty*=this.params.behaviourPenaltyDecay,n.behaviourPenaltyn)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{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=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"