@helia/trustless-gateway-client 0.0.0 → 1.0.0-3d869e9d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,33 +1,23 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaTrustlessGatewayClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaTrustlessGatewayClient=(()=>{var ss=Object.create;var ae=Object.defineProperty;var is=Object.getOwnPropertyDescriptor;var as=Object.getOwnPropertyNames;var cs=Object.getPrototypeOf,ls=Object.prototype.hasOwnProperty;var ce=(r,t)=>()=>{try{return t||r((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}},M=(r,t)=>{for(var e in t)ae(r,e,{get:t[e],enumerable:!0})},In=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of as(t))!ls.call(r,o)&&o!==e&&ae(r,o,{get:()=>t[o],enumerable:!(n=is(t,o))||n.enumerable});return r};var Sn=(r,t,e)=>(e=r!=null?ss(cs(r)):{},In(t||!r||!r.__esModule?ae(e,"default",{value:r,enumerable:!0}):e,r)),us=r=>In(ae({},"__esModule",{value:!0}),r);var to=ce((tu,Zn)=>{Zn.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,e=Object.create(null),n=Object.create(null);function o(s,i){e[s]=i,t++,t>=r&&(t=0,n=e,e=Object.create(null))}return{has:function(s){return e[s]!==void 0||n[s]!==void 0},remove:function(s){e[s]!==void 0&&(e[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=e[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){e[s]!==void 0?e[s]=i:o(s,i)},clear:function(){e=Object.create(null),n=Object.create(null)}}}});var Ur=ce(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.Netmask4Impl=void 0;Lt.ip2long=Ft;Lt.long2ip=Y;function Y(r){let t=(r&-16777216)>>>24,e=(r&255<<16)>>>16,n=(r&65280)>>>8,o=r&255;return[t,e,n,o].join(".")}var da=48,pa=97,ma=65;function ga(r){let t=0,e=10,n="9",o=0;r.length>1&&r[o]==="0"&&(r[o+1]==="x"||r[o+1]==="X"?(o+=2,e=16):"0"<=r[o+1]&&r[o+1]<="9"&&(o++,e=8,n="7"));let s=o;for(;o<r.length;){if("0"<=r[o]&&r[o]<=n)t=t*e+(r.charCodeAt(o)-da)>>>0;else if(e===16)if("a"<=r[o]&&r[o]<="f")t=t*e+(10+r.charCodeAt(o)-pa)>>>0;else if("A"<=r[o]&&r[o]<="F")t=t*e+(10+r.charCodeAt(o)-ma)>>>0;else break;else break;if(t>4294967295)throw new Error("too large");o++}if(o===s)throw new Error("empty octet");return[t,o]}function Ft(r){let t=[];for(let e=0;e<=3&&r.length!==0;e++){if(e>0){if(r[0]!==".")throw new Error("Invalid IP");r=r.substring(1)}let[n,o]=ga(r);r=r.substring(o),t.push(n)}if(r.length!==0)throw new Error("Invalid IP");switch(t.length){case 1:if(t[0]>4294967295)throw new Error("Invalid IP");return t[0]>>>0;case 2:if(t[0]>255||t[1]>16777215)throw new Error("Invalid IP");return(t[0]<<24|t[1])>>>0;case 3:if(t[0]>255||t[1]>255||t[2]>65535)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2])>>>0;case 4:if(t[0]>255||t[1]>255||t[2]>255||t[3]>255)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;default:throw new Error("Invalid IP")}}var $r=class r{constructor(t,e){if(typeof t!="string")throw new Error("Missing `net' parameter");let n=e;if(!n){let o=t.split("/",2);t=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=Ft(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(Ft(t)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+t)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=Y(this.netLong),this.mask=Y(this.maskLong),this.hostmask=Y(~this.maskLong),this.first=this.bitmask<=30?Y(this.netLong+1):this.base,this.last=this.bitmask<=30?Y(this.netLong+this.size-2):Y(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Y(this.netLong+this.size-1):void 0}contains(t){return typeof t=="string"&&(t.indexOf("/")>0||t.split(".").length!==4)&&(t=new r(t)),t instanceof r?this.contains(t.base)&&this.contains(t.broadcast||t.last):(Ft(t)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(t=1){return new r(Y(this.netLong+this.size*t),this.mask)}forEach(t){let e=Ft(this.first),n=Ft(this.last),o=0;for(;e<=n;)t(Y(e),e,o),o++,e++}toString(){return this.base+"/"+this.bitmask}};Lt.Netmask4Impl=$r});var go=ce(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.Netmask6Impl=void 0;Nt.ip6bigint=Mr;Nt.bigint2ip6=wt;var ya=Ur(),Rr=(1n<<128n)-1n;function Mr(r){let t=r.indexOf("%");t!==-1&&(r=r.substring(0,t));let e=r.lastIndexOf(":");if(e!==-1&&r.indexOf(".",e)!==-1){let n=r.substring(e+1),o=(0,ya.ip2long)(n),s=r.substring(0,e+1)+"0:0";return mo(s)&~0xffffffffn|BigInt(o)}return mo(r)}function mo(r){let t=r.indexOf("::"),e;if(t!==-1){let o=r.substring(0,t),s=r.substring(t+2),i=o===""?[]:o.split(":"),a=s===""?[]:s.split(":"),c=8-i.length-a.length;if(c<0)throw new Error("Invalid IPv6: too many groups");e=[...i,...Array(c).fill("0"),...a]}else e=r.split(":");if(e.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+e.length);let n=0n;for(let o=0;o<8;o++){let s=e[o];if(s.length===0||s.length>4)throw new Error('Invalid IPv6: bad group "'+s+'"');let i=parseInt(s,16);if(isNaN(i)||i<0||i>65535)throw new Error('Invalid IPv6: bad group "'+s+'"');n=n<<16n|BigInt(i)}return n}function wt(r){if(r<0n||r>Rr)throw new Error("Invalid IPv6 address value");let t=[];for(let i=0;i<8;i++)t.unshift(Number(r&0xffffn)),r>>=16n;let e=-1,n=0,o=-1,s=0;for(let i=0;i<8;i++)t[i]===0?o===-1?(o=i,s=1):s++:(s>n&&s>=2&&(e=o,n=s),o=-1,s=0);if(s>n&&s>=2&&(e=o,n=s),e!==-1&&e+n===8&&e>0)return t.slice(0,e).map(a=>a.toString(16)).join(":")+"::";if(e===0)return"::"+t.slice(n).map(a=>a.toString(16)).join(":");if(e>0){let i=t.slice(0,e).map(c=>c.toString(16)),a=t.slice(e+n).map(c=>c.toString(16));return i.join(":")+"::"+a.join(":")}else return t.map(i=>i.toString(16)).join(":")}var Br=class r{constructor(t,e){if(typeof t!="string")throw new Error("Missing `net' parameter");let n=e;if(n==null){let o=t.indexOf("/");o!==-1?(n=parseInt(t.substring(o+1),10),t=t.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=Rr>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=Mr(t)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+t)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=wt(this.netBigint),this.mask=wt(this.maskBigint),this.hostmask=wt(~this.maskBigint&Rr),this.first=this.base,this.last=wt(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(t){return typeof t=="string"&&t.indexOf("/")>0&&(t=new r(t)),t instanceof r?this.contains(t.base)&&this.contains(t.last):(Mr(t)&this.maskBigint)===this.netBigint}next(t=1){let e=1n<<BigInt(128-this.bitmask);return new r(wt(this.netBigint+e*BigInt(t)),this.bitmask)}forEach(t){let e=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,s=0;for(;e<=o;)t(wt(e),Number(e),s),s++,e++}toString(){return this.base+"/"+this.bitmask}};Nt.Netmask6Impl=Br});var yo=ce(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.long2ip=ct.ip2long=ct.Netmask=void 0;var Ce=Ur();Object.defineProperty(ct,"ip2long",{enumerable:!0,get:function(){return Ce.ip2long}});Object.defineProperty(ct,"long2ip",{enumerable:!0,get:function(){return Ce.long2ip}});var wa=go(),zr=class r{constructor(t,e){if(typeof t!="string")throw new Error("Missing `net' parameter");(t.indexOf("/")!==-1?t.substring(0,t.indexOf("/")):t).indexOf(":")!==-1?this._impl=new wa.Netmask6Impl(t,e):this._impl=new Ce.Netmask4Impl(t,e),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof Ce.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(t){return typeof t=="string"&&(t.indexOf("/")>0?t=new r(t):t.indexOf(":")===-1&&t.split(".").length!==4&&(t=new r(t))),t instanceof r?this.contains(t.base)&&this.contains(t.broadcast||t.last):this._impl.contains(t)}next(t=1){let e=this._impl.next(t);return new r(e.base,e.bitmask)}forEach(t){this._impl.forEach(t)}toString(){return this._impl.toString()}};ct.Netmask=zr});var Ic={};M(Ic,{DEFAULT_ALLOW_INSECURE:()=>se,DEFAULT_ALLOW_LOCAL:()=>ie,DEFAULT_MAX_SIZE:()=>_n,trustlessGatewayBlockBroker:()=>Cc});function B(r=0){return new Uint8Array(r)}function J(r=0){return new Uint8Array(r)}var fs=Math.pow(2,7),hs=Math.pow(2,14),ds=Math.pow(2,21),Qe=Math.pow(2,28),Xe=Math.pow(2,35),Je=Math.pow(2,42),Ye=Math.pow(2,49),I=128,L=127;function Et(r){if(r<fs)return 1;if(r<hs)return 2;if(r<ds)return 3;if(r<Qe)return 4;if(r<Xe)return 5;if(r<Je)return 6;if(r<Ye)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ze(r,t,e=0){switch(Et(r)){case 8:t[e++]=r&255|I,r/=128;case 7:t[e++]=r&255|I,r/=128;case 6:t[e++]=r&255|I,r/=128;case 5:t[e++]=r&255|I,r/=128;case 4:t[e++]=r&255|I,r>>>=7;case 3:t[e++]=r&255|I,r>>>=7;case 2:t[e++]=r&255|I,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ps(r,t){let e=r[t],n=0;if(n+=e&L,e<I||(e=r[t+1],n+=(e&L)<<7,e<I)||(e=r[t+2],n+=(e&L)<<14,e<I)||(e=r[t+3],n+=(e&L)<<21,e<I)||(e=r[t+4],n+=(e&L)*Qe,e<I)||(e=r[t+5],n+=(e&L)*Xe,e<I)||(e=r[t+6],n+=(e&L)*Je,e<I)||(e=r[t+7],n+=(e&L)*Ye,e<I))return n;throw new RangeError("Could not decode varint")}function ms(r,t){let e=r.get(t),n=0;if(n+=e&L,e<I||(e=r.get(t+1),n+=(e&L)<<7,e<I)||(e=r.get(t+2),n+=(e&L)<<14,e<I)||(e=r.get(t+3),n+=(e&L)<<21,e<I)||(e=r.get(t+4),n+=(e&L)*Qe,e<I)||(e=r.get(t+5),n+=(e&L)*Xe,e<I)||(e=r.get(t+6),n+=(e&L)*Je,e<I)||(e=r.get(t+7),n+=(e&L)*Ye,e<I))return n;throw new RangeError("Could not decode varint")}function tr(r,t=0){return r instanceof Uint8Array?ps(r,t):ms(r,t)}function ys(r){return r.buffer instanceof ArrayBuffer}function er(r){return ys(r)?r:r.slice()}var ir={};M(ir,{base10:()=>Is});var Tc=new Uint8Array(0);function An(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function tt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return ht(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return ht(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function Pn(r){return new TextEncoder().encode(r)}function Dn(r){return new TextDecoder().decode(r)}function ws(r){return r?.buffer instanceof ArrayBuffer}function ht(r){return ws(r)?r:r.slice()}function bs(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var x=0,p=0,w=0,C=g.length;w!==C&&g[w]===0;)w++,x++;for(var S=(C-w)*u+1>>>0,O=new Uint8Array(S);w!==C;){for(var k=g[w],Z=0,$=S-1;(k!==0||Z<p)&&$!==-1;$--,Z++)k+=256*O[$]>>>0,O[$]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");p=Z,w++}for(var V=S-p;V!==S&&O[V]===0;)V++;for(var ft=c.repeat(x);V<S;++V)ft+=r.charAt(O[V]);return ft}function l(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var x=0;if(g[x]!==" "){for(var p=0,w=0;g[x]===c;)p++,x++;for(var C=(g.length-x)*h+1>>>0,S=new Uint8Array(C);g[x];){var O=e[g.charCodeAt(x)];if(O===255)return;for(var k=0,Z=C-1;(O!==0||k<w)&&Z!==-1;Z--,k++)O+=a*S[Z]>>>0,S[Z]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");w=k,x++}if(g[x]!==" "){for(var $=C-w;$!==C&&S[$]===0;)$++;for(var V=new Uint8Array(p+(C-$)),ft=p;$!==C;)V[ft++]=S[$++];return V}}}function m(g){var x=l(g);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:l,decode:m}}var xs=bs,Es=xs,kn=Es;var rr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},nr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Fn(this,t)}},or=class{decoders;constructor(t){this.decoders=t}or(t){return Fn(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Fn(r,t){return new or({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var sr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new rr(t,e,n),this.decoder=new nr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function vt({name:r,prefix:t,encode:e,decode:n}){return new sr(r,t,e,n)}function it({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=kn(e,r);return vt({prefix:t,name:r,encode:n,decode:s=>tt(o(s))})}function vs(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let h=0;h<o;++h){let u=t[r[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function _s(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Cs(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function A({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Cs(n);return vt({prefix:t,name:r,encode(s){return _s(s,n,e)},decode(s){return vs(s,o,e,r)}})}var Is=it({prefix:"9",name:"base10",alphabet:"0123456789"});var ar={};M(ar,{base16:()=>Ss,base16upper:()=>As});var Ss=A({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),As=A({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var cr={};M(cr,{base2:()=>Ps});var Ps=A({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var lr={};M(lr,{base256emoji:()=>Ls});var Ln=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}"),Ds=Ln.reduce((r,t,e)=>(r[e]=t,r),[]),Ts=Ln.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function ks(r){return r.reduce((t,e)=>(t+=Ds[e],t),"")}function Fs(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ts[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ls=vt({prefix:"\u{1F680}",name:"base256emoji",encode:ks,decode:Fs});var ur={};M(ur,{base32:()=>q,base32hex:()=>Us,base32hexpad:()=>Ms,base32hexpadupper:()=>Bs,base32hexupper:()=>Rs,base32pad:()=>Os,base32padupper:()=>$s,base32upper:()=>Ns,base32z:()=>zs});var q=A({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ns=A({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Os=A({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$s=A({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Us=A({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rs=A({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ms=A({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Bs=A({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zs=A({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fr={};M(fr,{base36:()=>Bt,base36upper:()=>Vs});var Bt=it({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Vs=it({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var hr={};M(hr,{base58btc:()=>z,base58flickr:()=>qs});var z=it({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qs=it({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var pr={};M(pr,{base64:()=>dt,base64pad:()=>js,base64url:()=>dr,base64urlpad:()=>Ws});var dt=A({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),js=A({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dr=A({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ws=A({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var mr={};M(mr,{base8:()=>Hs});var Hs=A({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gr={};M(gr,{identity:()=>Ks});var Ks=vt({prefix:"\0",name:"identity",encode:r=>Dn(r),decode:r=>Pn(r)});var Hc=new TextEncoder,Kc=new TextDecoder;var xr={};M(xr,{identity:()=>br});var Qs=Un,On=128,Xs=127,Js=~Xs,Ys=Math.pow(2,31);function Un(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ys;)t[e++]=r&255|On,r/=128;for(;r&Js;)t[e++]=r&255|On,r>>>=7;return t[e]=r|0,Un.bytes=e-n+1,t}var Zs=yr,ti=128,$n=127;function yr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw yr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&$n)<<o:(i&$n)*Math.pow(2,o),o+=7}while(i>=ti);return yr.bytes=s-n,e}var ei=Math.pow(2,7),ri=Math.pow(2,14),ni=Math.pow(2,21),oi=Math.pow(2,28),si=Math.pow(2,35),ii=Math.pow(2,42),ai=Math.pow(2,49),ci=Math.pow(2,56),li=Math.pow(2,63),ui=function(r){return r<ei?1:r<ri?2:r<ni?3:r<oi?4:r<si?5:r<ii?6:r<ai?7:r<ci?8:r<li?9:10},fi={encode:Qs,decode:Zs,encodingLength:ui},hi=fi,zt=hi;function Vt(r,t=0){return[zt.decode(r,t),zt.decode.bytes]}function _t(r,t,e=0){return zt.encode(r,t,e),t}function Ct(r){return zt.encodingLength(r)}function St(r,t){let e=t.byteLength,n=Ct(r),o=n+Ct(e),s=new Uint8Array(o+e);return _t(r,s,0),_t(e,s,n),s.set(t,o),new It(r,e,t,s)}function wr(r){let t=tt(r),[e,n]=Vt(t),[o,s]=Vt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new It(e,o,i,t)}function Rn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&An(r.bytes,e.bytes)}}var It=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=ht(n),this.bytes=ht(o)}};var Mn=0,di="identity",Bn=tt;function pi(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return St(Mn,Bn(r))}var br={code:Mn,name:di,encode:Bn,digest:pi};var _r={};M(_r,{sha256:()=>gi,sha512:()=>yi});var mi=20;function vr({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new Er(r,t,e,n,o)}var Er=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??mi,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?zn(n,this.code,e?.truncate):n.then(o=>zn(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function zn(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return St(t,r)}function qn(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var gi=vr({name:"sha2-256",code:18,encode:qn("SHA-256")}),yi=vr({name:"sha2-512",code:19,encode:qn("SHA-512")});function jn(r,t){let{bytes:e,version:n}=r;return n===0?bi(e,Cr(r),t??z.encoder):xi(e,Cr(r),t??q.encoder)}var Wn=new WeakMap;function Cr(r){let t=Wn.get(r);if(t==null){let e=new Map;return Wn.set(r,e),e}return t}var j=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=ht(o),this["/"]=this.bytes}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:t,multihash:e}=this;if(t!==qt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ei)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=St(t,e);return r.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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Rn(t.multihash,n.multihash)}toString(t){return jn(this,t)}toJSON(){return{"/":jn(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Hn(n,o,s.bytes))}else if(e[vi]===!0){let{version:n,multihash:o,code:s}=e,i=wr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==qt)throw new Error(`Version 0 CID must use dag-pb (code: ${qt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Hn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,qt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new It(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[f,l]=Vt(t.subarray(e));return e+=l,f},o=n(),s=qt;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),h=e+c,u=h-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:h}}static parse(t,e){let[n,o]=wi(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Cr(s).set(n,t),s}};function wi(r,t){switch(r[0]){case"Q":{let e=t??z;return[z.prefix,e.decode(`${z.prefix}${r}`)]}case z.prefix:{let e=t??z;return[z.prefix,e.decode(r)]}case q.prefix:{let e=t??q;return[q.prefix,e.decode(r)]}case Bt.prefix:{let e=t??Bt;return[Bt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function bi(r,t,e){let{prefix:n}=e;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function xi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var qt=112,Ei=18;function Hn(r,t,e){let n=Ct(r),o=n+Ct(t),s=new Uint8Array(o+e.byteLength);return _t(r,s,0),_t(t,s,n),s.set(e,o),s}var vi=Symbol.for("@ipld/js-cid/CID");var jt={...gr,...cr,...mr,...ir,...ar,...ur,...fr,...hr,...pr,...lr},ml={..._r,...xr};function Gn(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Kn=Gn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ir=Gn("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=J(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),_i={utf8:Kn,"utf-8":Kn,hex:jt.base16,latin1:Ir,ascii:Ir,binary:Ir,...jt},ue=_i;function P(r,t="utf8"){let e=ue[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function W(r,t="utf8"){let e=ue[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var et="/",Qn=new TextEncoder().encode(et),fe=Qn[0],at=class r{_buf;constructor(t,e){if(typeof t=="string")this._buf=P(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(e==null&&(e=!0),e&&this.clean(),this._buf.byteLength===0||this._buf[0]!==fe)throw new Error("Invalid key")}toString(t="utf8"){return W(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new r(t.join(et))}static random(){return new r(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new r(t):typeof t.uint8Array=="function"?new r(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Qn),this._buf[0]!==fe){let t=new Uint8Array(this._buf.byteLength+1);t.fill(fe,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===fe;)this._buf=this._buf.subarray(0,-1)}less(t){let e=this.list(),n=t.list();for(let o=0;o<e.length;o++){if(n.length<o+1)return!1;let s=e[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return e.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(et).slice(1)}type(){return Ci(this.baseNamespace())}name(){return Ii(this.baseNamespace())}instance(t){return new r(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(et)||(t+=et),t+=this.type(),new r(t)}parent(){let t=this.list();return t.length===1?new r(et):new r(t.slice(0,-1).join(et))}child(t){return this.toString()===et?t:t.toString()===et?this:new r(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return r.withNamespaces([...this.namespaces(),...Si(t.map(e=>e.namespaces()))])}};function Ci(r){let t=r.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function Ii(r){let t=r.split(":");return t[t.length-1]}function Si(r){return[].concat(...r)}function Ai(r){return r?.buffer instanceof ArrayBuffer}function Sr(r){if(Ai(r))return r;let t=r.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function rt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=J(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return Sr(e)}function pt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Jn=Symbol.for("@achingbrain/uint8arraylist");function Xn(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function he(r){return!!r?.[Jn]}var de=class r{bufs;length;[Jn]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(he(n)){e+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(he(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Xn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Xn(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(he(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return rt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:rt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let h=t>=a&&t<c,u=e>a&&e<=c;if(h&&u){if(t===a&&e===c){n.push(i);break}let f=t-a;n.push(i.subarray(f,f+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!he(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let f=0;f<s;f++)i[f]=-1;for(let f=0;f<o;f++)i[n[f]]=f;let a=i,c=this.byteLength-n.byteLength,h=n.byteLength-1,u;for(let f=e;f<=c;f+=u){u=0;for(let l=h;l>=0;l--){let m=this.get(f+l);if(n[l]!==m){u=Math.max(1,l-a[m]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=J(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=B(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=B(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=J(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=B(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=B(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=B(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!pt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var H=class extends Error{static name="AbortError";constructor(t="The operation was aborted"){super(t),this.name="AbortError"}};var pe=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}};function Pi(r){return typeof r?.handleEvent=="function"}function Di(r){return(r!==!0&&r!==!1&&r?.once)??!1}var Pt=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){let o=Di(n);super.addEventListener(t,i=>{if(o){let a=this.#t.get(i.type);a!=null&&(a=a.filter(({callback:c})=>c!==e),this.#t.set(i.type,a))}Pi(e)?e.handleEvent(i):e(i)},n);let s=this.#t.get(t);s==null&&(s=[],this.#t.set(t,s)),s.push({callback:e,once:o})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var U=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var Ar=class r extends Error{name="TimeoutError";constructor(t,e){super(t,e),Error.captureStackTrace?.(this,r)}},Yn=r=>r.reason??new DOMException("This operation was aborted.","AbortError");function Pr(r,t){let{milliseconds:e,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout},signal:i}=t,a,c,u=new Promise((f,l)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(i?.aborted){l(Yn(i));return}if(i&&(c=()=>{l(Yn(i))},i.addEventListener("abort",c,{once:!0})),r.then(f,l),e===Number.POSITIVE_INFINITY)return;let m=new Ar;a=s.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(g){l(g)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${e} milliseconds`,l(m))},e)}).finally(()=>{u.clear(),c&&i&&i.removeEventListener("abort",c)});return u.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},u}var Fi=Sn(to(),1);var Dt;(function(r){r[r.A=1]="A",r[r.CNAME=5]="CNAME",r[r.TXT=16]="TXT",r[r.AAAA=28]="AAAA"})(Dt||(Dt={}));function me(r,t){if(typeof r=="string")return Li(r);if(typeof r=="number")return $i(r,t);throw new Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(r)}`)}function Li(r){if(typeof r!="string"||r.length===0||r.length>100)throw new Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(r)}`);let t=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(r);if(!t?.groups)return NaN;let{value:e,unit:n="ms"}=t.groups,o=parseFloat(e),s=n.toLowerCase();switch(s){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw new Error(`Unknown unit "${s}" provided to ms.parse(). value=${JSON.stringify(r)}`)}}function Ni(r){let t=Math.abs(r);return t>=315576e5?`${Math.round(r/315576e5)}y`:t>=26298e5?`${Math.round(r/26298e5)}mo`:t>=6048e5?`${Math.round(r/6048e5)}w`:t>=864e5?`${Math.round(r/864e5)}d`:t>=36e5?`${Math.round(r/36e5)}h`:t>=6e4?`${Math.round(r/6e4)}m`:t>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function Oi(r){let t=Math.abs(r);return t>=315576e5?mt(r,t,315576e5,"year"):t>=26298e5?mt(r,t,26298e5,"month"):t>=6048e5?mt(r,t,6048e5,"week"):t>=864e5?mt(r,t,864e5,"day"):t>=36e5?mt(r,t,36e5,"hour"):t>=6e4?mt(r,t,6e4,"minute"):t>=1e3?mt(r,t,1e3,"second"):`${r} ms`}function $i(r,t){if(typeof r!="number"||!Number.isFinite(r))throw new Error("Value provided to ms.format() must be of type number.");return t?.long?Oi(r):Ni(r)}function mt(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Dr(r){e.debug=e,e.default=e,e.coerce=c,e.disable=s,e.enable=o,e.enabled=i,e.humanize=me,e.destroy=h,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let f=0;for(let l=0;l<u.length;l++)f=(f<<5)-f+u.charCodeAt(l),f|=0;return e.colors[Math.abs(f)%e.colors.length]}e.selectColor=t;function e(u,f){let l,m=null,g,x;function p(...w){if(!p.enabled)return;let C=p,S=Number(new Date),O=S-(l||S);C.diff=O,C.prev=l,C.curr=S,l=S,w[0]=e.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let k=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,($,V)=>{if($==="%%")return"%";k++;let ft=e.formatters[V];if(typeof ft=="function"){let os=w[k];$=ft.call(C,os),w.splice(k,1),k--}return $}),e.formatArgs.call(C,w),f?.onLog!=null&&f.onLog(...w),(C.log||e.log).apply(C,w)}return p.namespace=u,p.useColors=e.useColors(),p.color=e.selectColor(u),p.extend=n,p.destroy=e.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(g!==e.namespaces&&(g=e.namespaces,x=e.enabled(u)),x),set:w=>{m=w}}),typeof e.init=="function"&&e.init(p),p}function n(u,f){let l=e(this.namespace+(typeof f>"u"?":":f)+u);return l.log=this.log,l}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let f,l=(typeof u=="string"?u:"").split(/[\s,]+/),m=l.length;for(f=0;f<m;f++)l[f]&&(u=l[f].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.substr(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...e.names.map(a),...e.skips.map(a).map(f=>"-"+f)].join(",");return e.enable(""),u}function i(u){if(u[u.length-1]==="*")return!0;let f,l;for(f=0,l=e.skips.length;f<l;f++)if(e.skips[f].test(u))return!1;for(f=0,l=e.names.length;f<l;f++)if(e.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.setupFormatters(e.formatters),e.enable(e.load()),e}var ge=qi(),Ui=["#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 Ri(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Mi(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+me(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}var Bi=console.debug??console.log??(()=>{});function zi(r){try{r?ge?.setItem("debug",r):ge?.removeItem("debug")}catch{}}function Vi(){let r;try{r=ge?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function qi(){try{return localStorage}catch{}}function ji(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var eo=Dr({formatArgs:Mi,save:zi,load:Vi,useColors:Ri,setupFormatters:ji,colors:Ui,storage:ge,log:Bi});var R=eo;R.formatters.b=r=>r==null?"undefined":z.baseEncode(r);R.formatters.t=r=>r==null?"undefined":q.baseEncode(r);R.formatters.m=r=>r==null?"undefined":dt.baseEncode(r);R.formatters.p=r=>r==null?"undefined":r.toString();R.formatters.c=r=>r==null?"undefined":r.toString();R.formatters.k=r=>r==null?"undefined":r.toString();R.formatters.a=r=>r==null?"undefined":r.toString();function ro(r,t=""){let e=no(r.message),n=no(r.stack);return e!=null&&n!=null?n.includes(e)?`${n.split(`
3
- `).join(`
4
- ${t}`)}`:`${e}
5
- ${t}${n.split(`
6
- `).join(`
7
- ${t}`)}`:n!=null?`${n.split(`
8
- `).join(`
9
- ${t}`)}`:e!=null?`${e}`:`${r.toString()}`}function Hi(r){return r instanceof AggregateError||r?.name==="AggregateError"&&Array.isArray(r.errors)}function oo(r,t=""){if(Hi(r)){let e=ro(r,t);return r.errors.length>0?(t=`${t} `,e+=`
10
- ${t}${r.errors.map(n=>`${oo(n,`${t}`)}`).join(`
11
- ${t}`)}`):e+=`
12
- ${t}[Error list was empty]`,e.trim()}return ro(r,t)}R.formatters.e=r=>r==null?"undefined":oo(r);function Ki(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t.useColors=()=>!1,t}function Ht(r,t){let e=Ki(`${r}:trace`);return R.enabled(`${r}:trace`)&&R.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(e=R(`${r}:trace`,t)),Object.assign(R(r,t),{error:R(`${r}:error`,t),trace:e,newScope:n=>Ht(`${r}:${n}`,t)})}function no(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}function nt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}function Qi(r){return r.reason}async function Kt(r,t,e){if(t==null)return r;let n=e?.translateError??Qi;if(t.aborted)return r.catch(()=>{}),Promise.reject(n(t));let o;try{return await Promise.race([r,new Promise((s,i)=>{o=()=>{i(n(t))},t.addEventListener("abort",o)})])}finally{o!=null&&t.removeEventListener("abort",o)}}var af=Ht("blockstore:core:tiered");var ao="SHARDING";var ye=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Tt=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new ye(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new ye(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var kr=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function Fr(r={}){return ea(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function ea(r,t){t=t??{};let e=t.onEnd,n=new Tt,o,s,i,a=nt(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,w)=>{s=C=>{s=null,n.push(C);try{p(r(n))}catch(S){w(S)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=nt()})}},h=p=>s!=null?s(p):(n.push(p),o),u=p=>(n=new Tt,s!=null?s({error:p}):(n.push({error:p}),o)),f=p=>{if(i)return o;if(t?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:p})},l=p=>i?o:(i=!0,p!=null?u(p):h({done:!0})),m=()=>(n=new Tt,l(),{done:!0}),g=p=>(l(p),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:m,throw:g,push:f,end:l,get readableLength(){return n.size},onEmpty:async p=>{let w=p?.signal;if(w?.throwIfAborted(),n.isEmpty())return;let C,S;w!=null&&(C=new Promise((O,k)=>{S=()=>{k(new kr)},w.addEventListener("abort",S)}));try{await Promise.race([a.promise,C])}finally{S!=null&&w!=null&&w?.removeEventListener("abort",S)}}},e==null)return o;let x=o;return o={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(p){return x.throw(p),e!=null&&(e(p),e=void 0),{done:!0}},return(){return x.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(p){return x.end(p),e!=null&&(e(p),e=void 0),o},get readableLength(){return x.readableLength},onEmpty:p=>x.onEmpty(p)},o}var Zf=new at(ao);var dh=Ht("datastore:core:tiered");var Lr={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},lo={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},uo=new globalThis.TextEncoder;function oa(r,t){let e=Lr[t],n=lo[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function sa(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Lr[t],o=lo[t],s=r;for(;s.length>0;){let i=uo.encodeInto(s,e);s=s.slice(i.read);for(let a=0;a<i.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function Nr(r,{size:t=32,utf8Buffer:e}={}){if(!Lr[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return sa(r,t,e);r=uo.encode(r)}return oa(r,t)}var Qt={hash:r=>Number(Nr(r,{size:32})),hashV:(r,t)=>ia(Qt.hash(r,t))};function ia(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),P(t,"base16")}var Or=64,K=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Or)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=B(o);for(let a=0;a<i.length;a++)i[a]=s[a];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?pt(this.fp,t.fp):!1}};function gt(r,t){return Math.floor(Math.random()*(t-r))+r}var yt=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof K))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof K))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof K))throw new TypeError("Invalid Fingerprint");let e=gt(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof K))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var aa=500,Xt=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??Qt,this.seed=t.seed??gt(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=P(t));let e=new K(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new yt(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new yt(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[gt(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new yt(this.bucketSize));for(let a=0;a<aa;a++){let c=this.buckets[i].swap(e);if(c!=null&&(i=(i^c.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new yt(this.bucketSize)),this.buckets[i].add(c)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=P(t));let e=new K(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=P(t));let e=new K(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},ca={1:.5,2:.84,4:.95,8:.98};function la(r=.001){return r>.002?2:r>1e-5?4:8}function fo(r,t=.001){let e=la(t),n=ca[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Or);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var we=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??Qt,this.seed=t.seed??gt(0,Math.pow(2,10)),this.filterSeries=[new Xt({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=P(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Xt({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=P(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=P(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function be(r,t=.001,e){return new we({...fo(r,t),...e??{}})}function ua(r){let t=r.getComponents(),e={},n=0;return t[n]?.name==="ip6zone"&&(e.zone=`${t[n].value}`,n++),t[n]?.name==="ip4"||t[n]?.name==="ip6"||t[n]?.name==="dns"||t[n]?.name==="dns4"||t[n]?.name==="dns6"?(e.type=t[n].name,e.host=t[n].value,n++):t[n]?.name==="dnsaddr"&&(e.type=t[n].name,e.host=`_dnsaddr.${t[n].value}`,n++),(t[n]?.name==="tcp"||t[n]?.name==="udp")&&(e.protocol=t[n].name==="tcp"?"tcp":"udp",e.port=parseInt(`${t[n].value}`),n++),t[n]?.name==="ipcidr"&&(e.type==="ip4"?e.cidr=parseInt(`${t[n].value}`):e.type==="ip6"&&(e.cidr=`${t[n].value}`),n++),e.type==null||e.host==null?null:(t[n]?.name==="tls"&&t[n+1]?.name==="sni"&&(e.sni=t[n+1].value,n+=2),e)}function xe(r){let t=ua(r);if(t==null)throw new pe(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return t}var Ee=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",h=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let l=Number.parseInt(f,t);if(!Number.isNaN(l))return l});if(u===void 0)break;if(s*=t,s+=u,s>h||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var fa=45,ha=15,ve=new Ee;function ho(r){if(!(r.length>ha))return ve.new(r).parseWith(()=>ve.readIPv4Addr())}function po(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>fa))return ve.new(r).parseWith(()=>ve.readIPv6Addr())}function kt(r){return!!ho(r)}function _e(r){return!!po(r)}var wo=Sn(yo(),1),ba=["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"],xa=ba.map(r=>new wo.Netmask(r));function Vr(r){for(let t of xa)if(t.contains(r))return!0;return!1}function Ea(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function va(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Vr(o)}function _a(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Ca(r){let t=r.split(":"),e=t[t.length-1];return Vr(e)}function Ia(r){return/^::$/.test(r)||/^::1$/.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)}function bo(r){if(kt(r))return Vr(r);if(Ea(r))return va(r);if(_a(r))return Ca(r);if(_e(r))return Ia(r)}function xo(r){try{let t=xe(r);switch(t.type){case"ip4":case"ip6":return bo(t.host)??!1;default:return t.host==="localhost"}}catch{return!1}}var F=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ot=class extends Error{static name="ValidationError";name="ValidationError"},Ie=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Se=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function jr(r){return t=>W(t,r)}function Wr(r){return t=>P(t,r)}function Ot(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function bt(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(t)}function Eo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=P(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=bt(n);return rt([e,o],e.length+o.length)}function vo(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=q.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=bt(n);return rt([e,o],e.length+o.length)}function Hr(r){let t=r.subarray(0,r.length-2),e=r.subarray(r.length-2),n=W(t,"base32"),o=Ot(e);return`${n}:${o}`}var Kr=function(r){r=r.toString().trim();let t=new Uint8Array(4);return r.split(/\./g).forEach((e,n)=>{let o=parseInt(e,10);if(isNaN(o)||o<0||o>255)throw new F("Invalid byte value in IP address");t[n]=o}),t},_o=function(r){let t=0;r=r.toString().trim();let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=kt(e[n]),i;s&&(i=Kr(e[n]),e[n]=W(i.subarray(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,W(i.subarray(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){e[n]===""&&(e[n]="0");let s=parseInt(e[n],16);if(isNaN(s)||s<0||s>65535)throw new F("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Co=function(r){if(r.byteLength!==4)throw new F("IPv4 address was incorrect length");let t=[];for(let e=0;e<r.byteLength;e++)t.push(r[e]);return t.join(".")},Io=function(r){if(r.byteLength!==16)throw new F("IPv6 address was incorrect length");let t=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let e=t.join(":");try{let n=new URL(`http://[${e}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new F(`Invalid IPv6 address "${e}"`)}};function So(r){try{let t=new URL(`http://[${r}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new F(`Invalid IPv6 address "${r}"`)}}var qr=Object.values(jt).map(r=>r.decoder),Sa=(function(){let r=qr[0].or(qr[1]);return qr.slice(2).forEach(t=>r=r.or(t)),r})();function Ao(r){return Sa.decode(r)}function Po(r){return t=>r.encoder.encode(t)}function Aa(r){if(parseInt(r).toString()!==r)throw new ot("Value must be an integer")}function Pa(r){if(r<0)throw new ot("Value must be a positive integer, or zero")}function Da(r){return t=>{if(t>r)throw new ot(`Value must be smaller than or equal to ${r}`)}}function Ta(...r){return t=>{for(let e of r)e(t)}}var Jt=Ta(Aa,Pa,Da(65535));var T=-1,Gr=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let e;if(typeof t=="string"?e=this.protocolsByName.get(t):e=this.protocolsByCode.get(t),e==null)throw new Se(`Protocol ${t} was unknown`);return e}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(e=>{this.protocolsByName.set(e,t)})}removeProtocol(t){let e=this.protocolsByCode.get(t);e!=null&&(this.protocolsByCode.delete(e.code),this.protocolsByName.delete(e.name),e.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},st=new Gr,ja=[{code:4,name:"ip4",size:32,valueToBytes:Kr,bytesToValue:Co,validate:r=>{if(!kt(r))throw new ot(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:bt,bytesToValue:Ot,validate:Jt},{code:273,name:"udp",size:16,valueToBytes:bt,bytesToValue:Ot,validate:Jt},{code:33,name:"dccp",size:16,valueToBytes:bt,bytesToValue:Ot,validate:Jt},{code:41,name:"ip6",size:128,valueToBytes:_o,bytesToValue:Io,stringToValue:So,validate:r=>{if(!_e(r))throw new ot(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:T},{code:43,name:"ipcidr",size:8,bytesToValue:jr("base10"),valueToBytes:Wr("base10")},{code:53,name:"dns",size:T},{code:54,name:"dns4",size:T},{code:55,name:"dns6",size:T},{code:56,name:"dnsaddr",size:T},{code:132,name:"sctp",size:16,valueToBytes:bt,bytesToValue:Ot,validate:Jt},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:T,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:T,bytesToValue:jr("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Wr("base58btc")(r):j.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Hr,valueToBytes:Eo},{code:445,name:"onion3",size:296,bytesToValue:Hr,valueToBytes:vo},{code:446,name:"garlic64",size:T},{code:447,name:"garlic32",size:T},{code:448,name:"tls"},{code:449,name:"sni",size:T},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:T,bytesToValue:Po(dr),valueToBytes:Ao},{code:480,name:"http"},{code:481,name:"http-path",size:T,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:T}];ja.forEach(r=>{st.addProtocol(r)});function Do(r){let t=[],e=0;for(;e<r.length;){let n=tr(r,e),o=st.getProtocol(n),s=Et(n),i=Wa(o,r,e+s),a=0;i>0&&o.size===T&&(a=Et(i));let c=s+a+i,h={code:n,name:o.name,bytes:er(r.subarray(e,e+c))};if(i>0){let u=e+s+a,f=r.subarray(u,u+i);h.value=o.bytesToValue?.(f)??W(f)}t.push(h),e+=c}return t}function To(r){let t=0,e=[];for(let n of r){if(n.bytes==null){let o=st.getProtocol(n.code),s=Et(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??P(n.value),a=i.byteLength,o.size===T&&(c=Et(a)));let h=new Uint8Array(s+c+a),u=0;Ze(n.code,h,u),u+=s,i!=null&&(o.size===T&&(Ze(a,h,u),u+=c),h.set(i,u)),n.bytes=h}e.push(n.bytes),t+=n.bytes.byteLength}return rt(e,t)}function ko(r){if(r.charAt(0)!=="/")throw new F('String multiaddr must start with "/"');let t=[],e="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(e==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=st.getProtocol(o);if(e==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",e="protocol";continue}else if(a)throw new F(`Component ${o} was missing value`);e="value"}else if(e==="value"){let h={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new F(`Component ${o} was missing value`);h.value=c.stringToValue?.(n)??n}t.push(h),n="",o="",e="protocol"}}}if(o!==""&&n!=="")throw new F("Incomplete multiaddr");return t}function Fo(r){return`/${r.flatMap(t=>{if(t.value==null)return t.name;let e=st.getProtocol(t.code);if(e==null)throw new F(`Unknown protocol code ${t.code}`);return[t.name,e.valueToString?.(t.value)??t.value]}).join("/")}`}function Wa(r,t,e){return r.size==null||r.size===0?0:r.size>0?r.size/8:tr(t,e)}var Ha=Symbol.for("nodejs.util.inspect.custom"),an=Symbol.for("@multiformats/multiaddr");function Ka(r){if(r==null&&(r="/"),Lo(r))return r.getComponents();if(r instanceof Uint8Array)return Do(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),ko(r);if(Array.isArray(r))return r;throw new F("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Fe=class r{[an]=!0;#t;#e;#r;constructor(t="/",e={}){this.#t=Ka(t),e.validate!==!1&&Ga(this)}get bytes(){return this.#r==null&&(this.#r=To(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=Fo(this.#t)),this.#e}toJSON(){return this.toString()}getComponents(){return[...this.#t.map(t=>({...t}))]}encapsulate(t){let e=new r(t);return new r([...this.#t,...e.getComponents()],{validate:!1})}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Ie(`Address ${this.toString()} does not contain subaddress: ${e}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(t){let e;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){e=n;break}return new r(this.#t.slice(0,e),{validate:!1})}equals(t){return pt(this.bytes,t.bytes)}[Ha](){return`Multiaddr(${this.toString()})`}};function Ga(r){r.getComponents().forEach(t=>{let e=st.getProtocol(t.code);t.value!=null&&e.validate?.(t.value)})}function Lo(r){return!!r?.[an]}function Le(r){return new Fe(r)}var v=r=>({match:t=>{let e=t[0];return e==null||e.code!==r||e.value!=null?!1:t.slice(1)}}),d=(r,t)=>({match:e=>{let n=e[0];return n?.code!==r||n.value==null||t!=null&&n.value!==t?!1:e.slice(1)}}),No=r=>({match:t=>r.match(t)===!1?t:!1}),y=r=>({match:t=>{let e=r.match(t);return e===!1?t:e}}),N=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1}}),b=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t}});function _(...r){function t(o){if(o==null)return!1;let s=o.getComponents();for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var Qa=d(421),Ep=_(Qa),Oe=d(54),$e=d(55),Ue=d(56),ln=d(53),vp=_(Oe,y(d(421))),_p=_($e,y(d(421))),Cp=_(Ue,y(d(421))),Oo=_(N(ln,Ue,Oe,$e),y(d(421))),$o=b(d(4),y(d(43))),Uo=b(y(d(42)),d(41),y(d(43))),un=N($o,Uo),Rt=N(un,ln,Oe,$e,Ue),Ip=_(N(un,b(N(ln,Ue,Oe,$e),y(d(421))))),Sp=_($o),Ap=_(Uo),Pp=_(un),fn=b(Rt,d(6)),ne=b(Rt,d(273)),Dp=_(b(fn,y(d(421)))),Tp=_(ne),hn=b(ne,v(460),y(d(421))),Re=b(ne,v(461),y(d(421))),Xa=N(hn,Re),kp=_(hn),Fp=_(Re),cn=N(Rt,fn,ne,hn,Re),Ro=N(b(cn,v(477),y(d(421)))),Lp=_(Ro),Mo=N(b(cn,v(478),y(d(421))),b(cn,v(448),y(d(449)),v(477),y(d(421)))),Np=_(Mo),Bo=b(ne,v(280),y(d(466)),y(d(466)),y(d(421))),Op=_(Bo),zo=b(Re,v(465),y(d(466)),y(d(466)),y(d(421))),$p=_(zo),Ne=N(Ro,Mo,b(fn,y(d(421))),b(Xa,y(d(421))),b(Rt,y(d(421))),Bo,zo,d(421)),Up=_(Ne),Ja=b(y(Ne),v(290),No(v(281)),y(d(421))),Rp=_(Ja),Ya=N(b(Ne,v(290),v(281),y(d(421))),b(Ne,v(281),y(d(421))),b(v(281),y(d(421)))),Mp=_(Ya),Za=b(Rt,N(b(d(6,"80")),b(d(6),v(480)),v(480)),y(d(481)),y(d(421))),Vo=_(Za),tc=b(Rt,N(b(d(6,"443")),b(d(6,"443"),v(480)),b(d(6),v(443)),b(d(6),v(448),v(480)),b(v(448),v(480)),v(448),v(443)),y(d(481)),y(d(421))),qo=_(tc),ec=N(b(d(777),y(d(421)))),Bp=_(ec),rc=N(b(d(400),y(d(421)))),zp=_(rc);var nc=r=>{let t=r.addEventListener||r.on||r.addListener,e=r.removeEventListener||r.off||r.removeListener;if(!t||!e)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(r),removeListener:e.bind(r)}};function oc(r,t,e){let n,o=new Promise((s,i)=>{if(e={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...e},!(e.count>=0&&(e.count===Number.POSITIVE_INFINITY||Number.isInteger(e.count))))throw new TypeError("The `count` option should be at least 0 or more");e.signal?.throwIfAborted();let a=[t].flat(),c=[],{addListener:h,removeListener:u}=nc(r),f=async(...m)=>{let g=e.multiArgs?m:m[0];if(e.filter)try{if(!await e.filter(g))return}catch(x){n(),i(x);return}c.push(g),e.count===c.length&&(n(),s(c))},l=(...m)=>{n(),i(e.rejectionMultiArgs?m:m[0])};n=()=>{for(let m of a)u(m,f);for(let m of e.rejectionEvents)a.includes(m)||u(m,l)};for(let m of a)h(m,f);for(let m of e.rejectionEvents)a.includes(m)||h(m,l);e.signal&&e.signal.addEventListener("abort",()=>{l(e.signal.reason)},{once:!0}),e.resolveImmediately&&s(c)});if(o.cancel=n,typeof e.timeout=="number"){let s=Pr(o,{milliseconds:e.timeout});return s.cancel=()=>{n(),s.clear()},s}return o}function Me(r,t,e){typeof e=="function"&&(e={filter:e}),e={...e,count:1,resolveImmediately:!1};let n=oc(r,t,e),o=n.then(s=>s[0]);return o.cancel=n.cancel,o}function dn(r,t){let e,n=function(){let o=function(){e=void 0,r()};clearTimeout(e),e=setTimeout(o,t)};return n.start=()=>{},n.stop=()=>{clearTimeout(e)},n}var Be=class extends Error{static name="QueueFullError";constructor(t="The queue was full"){super(t),this.name="QueueFullError"}};var ze=class{deferred;signal;onProgress;constructor(t){this.signal=t?.signal,this.onProgress=t?.onProgress,this.deferred=nt(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new H)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function sc(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var Ve=class{id;fn;options;recipients;status;timeline;controller;dispatchingProgress;constructor(t,e){this.id=sc(),this.status="queued",this.fn=t,this.options=e,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.dispatchingProgress=!1,this.onAbort=this.onAbort.bind(this)}abort(t){this.controller.abort(t)}onAbort(){this.recipients.reduce((e,n)=>e&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new H),this.cleanup())}async join(t){let e=new ze(t);return this.recipients.push(e),t?.signal?.addEventListener("abort",this.onAbort),e.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let t=await Kt(this.fn({...this.options??{},signal:this.controller.signal,onProgress:e=>{if(!this.dispatchingProgress){this.dispatchingProgress=!0;try{this.recipients.forEach(n=>{n.onProgress?.(e)})}finally{this.dispatchingProgress=!1}}}}),this.controller.signal);this.recipients.forEach(e=>{e.deferred.resolve(t)}),this.status="complete"}catch(t){this.recipients.forEach(e=>{e.deferred.reject(t)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(t=>{t.cleanup(),t.signal?.removeEventListener("abort",this.onAbort)})}};var qe=class extends Pt{concurrency;maxSize;queue;pending;sort;paused;constructor(t={}){super(),this.concurrency=t.concurrency??Number.POSITIVE_INFINITY,this.maxSize=t.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,t.metricName!=null&&t.metrics?.registerMetricGroup(t.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=t.sort,this.queue=[],this.emitEmpty=dn(this.emitEmpty.bind(this),1),this.emitIdle=dn(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let t;for(let e of this.queue)if(e.status==="queued"){t=e;break}return t==null?!1:(this.safeDispatchEvent("active"),this.pending++,t.run().finally(()=>{for(let e=0;e<this.queue.length;e++)if(this.queue[e]===t){this.queue.splice(e,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(t){this.queue.push(t),this.sort!=null&&this.queue.sort(this.sort)}async add(t,e){if(e?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Be;let n=new Ve(t,e);this.enqueue(n),this.safeDispatchEvent("add");let o=n.join(e).then(s=>(this.safeDispatchEvent("completed",{detail:s}),this.safeDispatchEvent("success",{detail:{job:n,result:s}}),s)).catch(s=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:s}}),s});return this.tryToStartAnother(),o}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(t=>{t.abort(new H)}),this.clear()}async onEmpty(t){this.size!==0&&await Me(this,"empty",t)}async onSizeLessThan(t,e){this.size<t||await Me(this,"next",{...e,filter:()=>this.size<t})}async onIdle(t){this.pending===0&&this.size===0||await Me(this,"idle",t)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(t){t?.signal?.throwIfAborted();let e=Fr({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),e.end(c)},o=c=>{c.detail!=null&&e.push(c.detail)},s=c=>{n(c.detail.error)},i=()=>{n()},a=()=>{n(new H("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",s),this.addEventListener("idle",i),t?.signal?.addEventListener("abort",a);try{yield*e}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",s),this.removeEventListener("idle",i),t?.signal?.removeEventListener("abort",a),n()}}};var je=class extends Error{static name="InsufficientProvidersError";constructor(t="Insufficient providers found"){super(t),this.name="InsufficientProvidersError"}};var oe=class extends Pt{initialPeerSearchComplete;requests;logName;log;logger;minProviders;maxProviders;providers;evictionFilter;initialProviders;cidPeerFilterSize;constructor(t,e){super(),this.logName=e.name,this.logger=t.logger,this.log=t.logger.forComponent(this.logName),this.requests=new Map,this.minProviders=e.minProviders??1,this.maxProviders=e.maxProviders??5,this.cidPeerFilterSize=e.cidPeerFilterSize??100,this.providers=[],this.evictionFilter=be(this.maxProviders),this.initialProviders=[...e.providers??[]]}async retrieve(t,e={}){let n=dt.encode(t.multihash.bytes),o=this.requests.get(n);if(o!=null)return this.log("join existing request for %c",t),o.observers++,o.promise;let s=nt(),i={promise:s.promise,observers:1,queryFilter:be(this.cidPeerFilterSize)};this.requests.set(n,i);let a=!1;this.initialPeerSearchComplete==null&&(a=!0,this.log=this.logger.forComponent(`${this.logName}:${t}`),this.initialPeerSearchComplete=this.findProviders(t,this.minProviders,e));let c=!1,h=new qe({concurrency:this.maxProviders});h.addEventListener("failure",l=>{this.log.error("error querying provider %s, evicting from session - %e",l.detail.job.options.provider,l.detail.error),this.evict(l.detail.job.options.provider)}),h.addEventListener("success",l=>{c=!0,s.resolve(l.detail.result)}),h.addEventListener("idle",()=>{if(c){this.log.trace("session idle, found block");return}if(e.signal?.aborted===!0){this.log.trace("session idle, signal aborted");return}Promise.resolve().then(async()=>{this.log("no session peers had block for for %c, finding new providers",t);for(let l=0;l<this.minProviders&&this.providers.length!==0;l++){let m=this.providers[Math.floor(Math.random()*this.providers.length)];this.evict(m)}await this.findProviders(t,this.minProviders,e),this.log("found new providers re-retrieving %c",t),this.requests.delete(n),s.resolve(await this.retrieve(t,e))}).catch(l=>{this.log.error("could not find new providers for %c - %e",t,l),s.reject(l)})});let u=l=>{let m=this.toFilterKey(l.detail);i.queryFilter.has(m)||(i.queryFilter.add(m),this.emitFoundProviderProgressEvent(t,l.detail,e),h.add(async()=>this.queryProvider(t,l.detail,e),{provider:l.detail}).catch(g=>{e.signal?.aborted!==!0&&this.log.error("error retrieving session block for %c - %e",t,g)}))};if(this.addEventListener("provider",u),a)try{await Kt(this.initialPeerSearchComplete,e.signal),a&&this.log("found initial session peers for %c",t)}catch(l){throw a&&this.log("failed to find initial session peers for %c - %e",t,l),this.requests.delete(n),i.observers>1&&s.reject(l),l}Promise.all([...this.providers].filter(l=>{let m=this.toFilterKey(l),g=i.queryFilter.has(m);return g||i.queryFilter.add(this.toFilterKey(l)),!g}).map(async l=>h.add(async()=>this.queryProvider(t,l,e),{provider:l}))).catch(l=>{e.signal?.aborted!==!0&&this.log.error("error retrieving session block for %c - %e",t,l)});let f=()=>{s.reject(new H(e.signal?.reason??"Session aborted")),h.abort()};e.signal?.addEventListener("abort",f);try{return await s.promise}finally{this.removeEventListener("provider",u),e.signal?.removeEventListener("abort",f),h.clear(),this.requests.delete(n)}}evict(t){this.evictionFilter.add(this.toFilterKey(t));let e=this.providers.findIndex(n=>this.equals(n,t));e!==-1&&this.providers.splice(e,1)}isEvicted(t){return this.evictionFilter.has(this.toFilterKey(t))}hasProvider(t){return!!(this.providers.find(e=>this.equals(e,t))!=null||this.isEvicted(t))}async addPeer(t,e){let n=await this.convertToProvider(t,"manually-added",e);n==null||this.hasProvider(n)||(this.providers.push(n),this.safeDispatchEvent("provider",{detail:n}))}async findProviders(t,e,n){let o=nt(),s=0;return Promise.resolve().then(async()=>{this.log("finding %d-%d new provider(s) for %c - %d initial providers",e,this.maxProviders,t,this.initialProviders.length);let i=this,a=async function*(){for(;i.initialProviders.length>0;){let h=i.initialProviders.pop();if(h==null)continue;let u=await i.convertToProvider(h,"manual",n);u!=null&&(yield u)}},c=async function*(){yield*a(),yield*i.findNewProviders(t,n)};for await(let h of c()){if(this.providers.length===this.maxProviders||n.signal?.aborted===!0)break;if(!this.hasProvider(h)&&(this.log("found %d providers, %d in session",s,this.providers.length),this.providers.push(h),this.safeDispatchEvent("provider",{detail:h}),s++,this.providers.length===e&&(this.log("session is ready with %d peer(s), new peers present",this.providers.length),o.resolve()),this.providers.length===this.maxProviders)){this.log("found max session peers %d",this.providers.length);break}}if(this.log("found %d new session peers while trying to find %d, %d in session",s,e,this.providers.length),this.providers.length<e)throw new je(`Found ${s} of ${e} ${this.name} providers for ${t}, ${this.providers.length} in session after evictions`)}).catch(i=>{this.log.error("error searching routing for potential session peers for %c - %e",t,i),o.reject(i)}),o.promise}};function pn(r){return r==null?!1:j.asCID(r)!=null}var lc=[6,53,56,54,55];function jo(r){return Ko("sni",r)?.value}function Wo(r){let t=Ko("tcp",r)?.value;return t==null?"":`:${t}`}function Ko(r,t){return t.find(e=>e.name===r)}function Ho(r){return r.some(({code:t})=>t===448)}function Q(r,t){let e=Go[r.name];if(e==null)throw new Error(`Can't interpret protocol ${r.name}`);let n=e(r,t);return r.code===41?`[${n}]`:n}var Go={ip4:(r,t)=>r.value,ip6:(r,t)=>t.length===0?r.value:`[${r.value}]`,tcp:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");return`tcp://${Q(e,t)}:${r.value}`},udp:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");return`udp://${Q(e,t)}:${r.value}`},dnsaddr:(r,t)=>r.value,dns4:(r,t)=>r.value,dns6:(r,t)=>r.value,dns:(r,t)=>r.value,ipfs:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");return`${Q(e,t)}`},p2p:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");return`${Q(e,t)}`},http:(r,t)=>{let e=Ho(t),n=jo(t),o=Wo(t);if(e&&n!=null)return`https://${n}${o}`;let s=e?"https://":"http://",i=t.pop();if(i==null)throw new Error("Unexpected end of multiaddr");let a=Q(i,t);return a=a?.replace("tcp://",""),`${s}${a}`},"http-path":(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");let n=Q(e,t),o=decodeURIComponent(r.value??"");return`${n}${o}`},tls:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");return Q(e,t)},sni:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");return Q(e,t)},https:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");let n=Q(e,t);return n=n?.replace("tcp://",""),`https://${n}`},ws:(r,t)=>{let e=Ho(t),n=jo(t),o=Wo(t);if(e&&n!=null)return`wss://${n}${o}`;let s=e?"wss://":"ws://",i=t.pop();if(i==null)throw new Error("Unexpected end of multiaddr");let a=Q(i,t);return a=a?.replace("tcp://",""),`${s}${a}`},wss:(r,t)=>{let e=t.pop();if(e==null)throw new Error("Unexpected end of multiaddr");let n=Q(e,t);return n=n?.replace("tcp://",""),`wss://${n}`}};function We(r,t){let n=Le(r).getComponents(),o=n.pop();if(o==null)throw new Error("Unexpected end of multiaddr");let s=Go[o.name];if(s==null)throw new Error(`No interpreter found for ${o.name}`);let i=s(o,n)??"";return t?.assumeHttp!==!1&&lc.includes(o.code)&&(i=i.replace(/^.*:\/\//,""),o.value==="443"?i=`https://${i}`:i=`http://${i}`),(i.startsWith("http://")||i.startsWith("https://")||i.startsWith("ws://")||i.startsWith("wss://"))&&(i=new URL(i).toString(),i.endsWith("/")&&(i=i.substring(0,i.length-1))),i}var Qo="[a-fA-F\\d:]",ut=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${Qo})|(?<=${Qo})(?=\\s|$))`:"",X="(?: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}",D="[a-fA-F\\d]{1,4}",He=`
2
+ "use strict";var HeliaTrustlessGatewayClient=(()=>{var Uo=Object.create;var et=Object.defineProperty;var $o=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var zo=Object.getPrototypeOf,Bo=Object.prototype.hasOwnProperty;var Bt=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},F=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},hn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ro(e))!Bo.call(r,o)&&o!==t&&et(r,o,{get:()=>e[o],enumerable:!(n=$o(e,o))||n.enumerable});return r};var Mo=(r,e,t)=>(t=r!=null?Uo(zo(r)):{},hn(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Vo=r=>hn(et({},"__esModule",{value:!0}),r);var vr=Bt(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.Netmask4Impl=void 0;Pe.ip2long=Ce;Pe.long2ip=Y;function Y(r){let e=(r&-16777216)>>>24,t=(r&255<<16)>>>16,n=(r&65280)>>>8,o=r&255;return[e,t,n,o].join(".")}var mi=48,gi=97,bi=65;function wi(r){let e=0,t=10,n="9",o=0;r.length>1&&r[o]==="0"&&(r[o+1]==="x"||r[o+1]==="X"?(o+=2,t=16):"0"<=r[o+1]&&r[o+1]<="9"&&(o++,t=8,n="7"));let s=o;for(;o<r.length;){if("0"<=r[o]&&r[o]<=n)e=e*t+(r.charCodeAt(o)-mi)>>>0;else if(t===16)if("a"<=r[o]&&r[o]<="f")e=e*t+(10+r.charCodeAt(o)-gi)>>>0;else if("A"<=r[o]&&r[o]<="F")e=e*t+(10+r.charCodeAt(o)-bi)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===s)throw new Error("empty octet");return[e,o]}function Ce(r){let e=[];for(let t=0;t<=3&&r.length!==0;t++){if(t>0){if(r[0]!==".")throw new Error("Invalid IP");r=r.substring(1)}let[n,o]=wi(r);r=r.substring(o),e.push(n)}if(r.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var Er=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=t;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=Ce(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(Ce(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=Y(this.netLong),this.mask=Y(this.maskLong),this.hostmask=Y(~this.maskLong),this.first=this.bitmask<=30?Y(this.netLong+1):this.base,this.last=this.bitmask<=30?Y(this.netLong+this.size-2):Y(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Y(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new r(e)),e instanceof r?this.contains(e.base)&&this.contains(e.broadcast||e.last):(Ce(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new r(Y(this.netLong+this.size*e),this.mask)}forEach(e){let t=Ce(this.first),n=Ce(this.last),o=0;for(;t<=n;)e(Y(t),t,o),o++,t++}toString(){return this.base+"/"+this.bitmask}};Pe.Netmask4Impl=Er});var jn=Bt(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.Netmask6Impl=void 0;Ae.ip6bigint=Ir;Ae.bigint2ip6=me;var xi=vr(),_r=(1n<<128n)-1n;function Ir(r){let e=r.indexOf("%");e!==-1&&(r=r.substring(0,e));let t=r.lastIndexOf(":");if(t!==-1&&r.indexOf(".",t)!==-1){let n=r.substring(t+1),o=(0,xi.ip2long)(n),s=r.substring(0,t+1)+"0:0";return qn(s)&~0xffffffffn|BigInt(o)}return qn(r)}function qn(r){let e=r.indexOf("::"),t;if(e!==-1){let o=r.substring(0,e),s=r.substring(e+2),i=o===""?[]:o.split(":"),a=s===""?[]:s.split(":"),c=8-i.length-a.length;if(c<0)throw new Error("Invalid IPv6: too many groups");t=[...i,...Array(c).fill("0"),...a]}else t=r.split(":");if(t.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+t.length);let n=0n;for(let o=0;o<8;o++){let s=t[o];if(s.length===0||s.length>4)throw new Error('Invalid IPv6: bad group "'+s+'"');let i=parseInt(s,16);if(isNaN(i)||i<0||i>65535)throw new Error('Invalid IPv6: bad group "'+s+'"');n=n<<16n|BigInt(i)}return n}function me(r){if(r<0n||r>_r)throw new Error("Invalid IPv6 address value");let e=[];for(let i=0;i<8;i++)e.unshift(Number(r&0xffffn)),r>>=16n;let t=-1,n=0,o=-1,s=0;for(let i=0;i<8;i++)e[i]===0?o===-1?(o=i,s=1):s++:(s>n&&s>=2&&(t=o,n=s),o=-1,s=0);if(s>n&&s>=2&&(t=o,n=s),t!==-1&&t+n===8&&t>0)return e.slice(0,t).map(a=>a.toString(16)).join(":")+"::";if(t===0)return"::"+e.slice(n).map(a=>a.toString(16)).join(":");if(t>0){let i=e.slice(0,t).map(c=>c.toString(16)),a=e.slice(t+n).map(c=>c.toString(16));return i.join(":")+"::"+a.join(":")}else return e.map(i=>i.toString(16)).join(":")}var Sr=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=t;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=_r>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=Ir(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=me(this.netBigint),this.mask=me(this.maskBigint),this.hostmask=me(~this.maskBigint&_r),this.first=this.base,this.last=me(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new r(e)),e instanceof r?this.contains(e.base)&&this.contains(e.last):(Ir(e)&this.maskBigint)===this.netBigint}next(e=1){let t=1n<<BigInt(128-this.bitmask);return new r(me(this.netBigint+t*BigInt(e)),this.bitmask)}forEach(e){let t=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,s=0;for(;t<=o;)e(me(t),Number(t),s),s++,t++}toString(){return this.base+"/"+this.bitmask}};Ae.Netmask6Impl=Sr});var Wn=Bt(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.long2ip=ae.ip2long=ae.Netmask=void 0;var dt=vr();Object.defineProperty(ae,"ip2long",{enumerable:!0,get:function(){return dt.ip2long}});Object.defineProperty(ae,"long2ip",{enumerable:!0,get:function(){return dt.long2ip}});var yi=jn(),Cr=class r{constructor(e,t){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new yi.Netmask6Impl(e,t):this._impl=new dt.Netmask4Impl(e,t),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof dt.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new r(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new r(e))),e instanceof r?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let t=this._impl.next(e);return new r(t.base,t.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};ae.Netmask=Cr});var Ta={};F(Ta,{DEFAULT_ALLOW_INSECURE:()=>Je,DEFAULT_ALLOW_LOCAL:()=>Ye,DEFAULT_MAX_SIZE:()=>ln,trustlessGatewayBlockBroker:()=>Aa});var La=new Uint8Array(0);function pn(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function R(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return fe(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return fe(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function mn(r){let e=new Uint8Array(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}var dn=4096;function gn(r){let e=r.length;if(e<=dn)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.subarray(n,n+=dn));return t}function qo(r){return r?.buffer instanceof ArrayBuffer}function fe(r){return qo(r)?r:r.slice()}var Wt={};F(Wt,{base32:()=>ie,base32hex:()=>Zo,base32hexpad:()=>ts,base32hexpadupper:()=>rs,base32hexupper:()=>es,base32pad:()=>Jo,base32padupper:()=>Yo,base32upper:()=>Ko,base32z:()=>ns});function jo(r,e,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<r.length;s++){var i=r.charAt(s),a=i.charCodeAt(0);if(n[a]!==255)throw new TypeError(i+" is ambiguous");if(n[a]=s,t){var c=i.toLowerCase().charCodeAt(0),l=i.toUpperCase().charCodeAt(0);c!==a&&(n[c]=s),l!==a&&(n[l]=s)}}var h=r.length,d=r.charAt(0),u=Math.log(h)/Math.log(256),p=Math.log(256)/Math.log(h);function L(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var S=0,k=0,N=0,U=g.length;N!==U&&g[N]===0;)N++,S++;for(var G=(U-N)*p+1>>>0,$=new Uint8Array(G);N!==U;){for(var Q=g[N],oe=0,B=G-1;(Q!==0||oe<k)&&B!==-1;B--,oe++)Q+=256*$[B]>>>0,$[B]=Q%h>>>0,Q=Q/h>>>0;if(Q!==0)throw new Error("Non-zero carry");k=oe,N++}for(var Z=G-k;Z!==G&&$[Z]===0;)Z++;for(var Ze=d.repeat(S);Z<G;++Z)Ze+=r.charAt($[Z]);return Ze}function O(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var S=0;if(g[S]!==" "){for(var k=0,N=0;g[S]===d;)k++,S++;for(var U=(g.length-S)*u+1>>>0,G=new Uint8Array(U);g[S];){var $=n[g.charCodeAt(S)];if($===255)return;for(var Q=0,oe=U-1;($!==0||Q<N)&&oe!==-1;oe--,Q++)$+=h*G[oe]>>>0,G[oe]=$%256>>>0,$=$/256>>>0;if($!==0)throw new Error("Non-zero carry");N=Q,S++}if(g[S]!==" "){for(var B=U-N;B!==U&&G[B]===0;)B++;for(var Z=new Uint8Array(k+(U-B)),Ze=k;B!==U;)Z[Ze++]=G[B++];return Z}}}function x(g){var S=O(g);if(S)return S;throw new Error(`Non-${e} character`)}return{encode:L,decodeUnsafe:O,decode:x}}var Wo=jo,Ho=Wo,wn=Ho;var Mt=class{name;prefix;baseEncode;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")}},Vt=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 xn(this,e)}},qt=class{decoders;constructor(e){this.decoders=e}or(e){return xn(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function xn(r,e){return new qt({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var jt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Mt(e,t,n),this.decoder=new Vt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function we({name:r,prefix:e,encode:t,decode:n}){return new jt(r,e,t,n)}function se({name:r,prefix:e,alphabet:t,caseInsensitive:n=!1}){let{encode:o,decode:s}=wn(t,r,n);return we({prefix:e,name:r,encode:o,decode:i=>R(s(i))})}function Go(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let h=e[r[l]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|h,i+=t,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=t||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Qo(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;(s.length*t&7)!==0;)s+="=";return s}function Xo(r,e){let t={};for(let n=0;n<r.length;++n)if(t[r[n]]=n,e){let o=r[n].toLowerCase(),s=r[n].toUpperCase();o!==r[n]&&(t[o]=n),s!==r[n]&&(t[s]=n)}return t}function _({name:r,prefix:e,bitsPerChar:t,alphabet:n,caseInsensitive:o=!1}){let s=Xo(n,o);return we({prefix:e,name:r,encode(i){return Qo(i,n,t)},decode(i){return Go(i,s,t,r)}})}var ie=_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Ko=_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Jo=_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Yo=_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Zo=_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),es=_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),ts=_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),rs=_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),ns=_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ht={};F(Ht,{base36:()=>Ne,base36upper:()=>os});var Ne=se({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),os=se({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var Gt={};F(Gt,{base58btc:()=>X,base58flickr:()=>ss});var X=se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ss=se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var is=vn,yn=128,as=127,cs=~as,us=Math.pow(2,31);function vn(r,e,t){e=e||[],t=t||0;for(var n=t;r>=us;)e[t++]=r&255|yn,r/=128;for(;r&cs;)e[t++]=r&255|yn,r>>>=7;return e[t]=r|0,vn.bytes=t-n+1,e}var ls=Qt,fs=128,En=127;function Qt(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Qt.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&En)<<o:(i&En)*Math.pow(2,o),o+=7}while(i>=fs);return Qt.bytes=s-n,t}var hs=Math.pow(2,7),ds=Math.pow(2,14),ps=Math.pow(2,21),ms=Math.pow(2,28),gs=Math.pow(2,35),bs=Math.pow(2,42),ws=Math.pow(2,49),xs=Math.pow(2,56),ys=Math.pow(2,63),Es=function(r){return r<hs?1:r<ds?2:r<ps?3:r<ms?4:r<gs?5:r<bs?6:r<ws?7:r<xs?8:r<ys?9:10},vs={encode:is,decode:ls,encodingLength:Es},_s=vs,Ue=_s;function $e(r,e=0){return[Ue.decode(r,e),Ue.decode.bytes]}function xe(r,e,t=0){return Ue.encode(r,e,t),e}function ye(r){return Ue.encodingLength(r)}function ve(r,e){let t=e.byteLength,n=ye(r),o=n+ye(t),s=new Uint8Array(o+t);return xe(r,s,0),xe(t,s,n),s.set(e,o),new Ee(r,t,e,s)}function _n(r){let e=R(r),[t,n]=$e(e),[o,s]=$e(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ee(t,o,i,e)}function In(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&pn(r.bytes,t.bytes)}}var Ee=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=fe(n),this.bytes=fe(o)}};function Sn(r,e){let{bytes:t,version:n}=r;return n===0?Ss(t,Xt(r),e??X.encoder):Cs(t,Xt(r),e??ie.encoder)}var Cn=new WeakMap;function Xt(r){let e=Cn.get(r);if(e==null){let t=new Map;return Cn.set(r,t),t}return e}var K=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=fe(o),this["/"]=this.bytes}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!==ze)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ps)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.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=ve(e,t);return r.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 r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&In(e.multihash,n.multihash)}toString(e){return Sn(this,e)}toJSON(){return{"/":Sn(this)}}link(){return this}[Symbol.toStringTag]="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 r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??Pn(n,o,s.bytes))}else if(t[As]===!0){let{version:n,multihash:o,code:s}=t,i=_n(o);return r.create(n,s,i)}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!==ze)throw new Error(`Version 0 CID must use dag-pb (code: ${ze}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Pn(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ze,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=R(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Ee(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[d,u]=$e(e.subarray(t));return t+=u,d},o=n(),s=ze;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),l=t+c,h=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:h,size:l}}static parse(e,t){let[n,o]=Is(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xt(s).set(n,e),s}};function Is(r,e){switch(r[0]){case"Q":{let t=e??X;return[X.prefix,t.decode(`${X.prefix}${r}`)]}case X.prefix:{let t=e??X;return[X.prefix,t.decode(r)]}case ie.prefix:{let t=e??ie;return[ie.prefix,t.decode(r)]}case Ne.prefix:{let t=e??Ne;return[Ne.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ss(r,e,t){let{prefix:n}=t;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function Cs(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var ze=112,Ps=18;function Pn(r,e,t){let n=ye(r),o=n+ye(e),s=new Uint8Array(o+t.byteLength);return xe(r,s,0),xe(e,s,n),s.set(t,o),s}var As=Symbol.for("@ipld/js-cid/CID");var Ts=20;function Jt({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new Kt(r,e,t,n,o)}var Kt=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,s){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??Ts,this.maxDigestLength=s}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?An(n,this.code,t?.truncate):n.then(o=>An(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function An(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return ve(e,r)}var Zt={};F(Zt,{base64:()=>Be,base64pad:()=>Ds,base64url:()=>Yt,base64urlpad:()=>Ls});var Be=_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ds=_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yt=_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ls=_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var tr={};F(tr,{identity:()=>er});var Dn=0,ks="identity",Ln=R;function Os(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return ve(Dn,Ln(r))}var er={code:Dn,name:ks,encode:Ln,digest:Os};function z(r=0){return new Uint8Array(r)}function J(r=0){return new Uint8Array(r)}function Fs(r){return r?.buffer instanceof ArrayBuffer}function rr(r){if(Fs(r))return r;let e=r.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function ee(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=J(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return rr(t)}function he(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var On=Symbol.for("@achingbrain/uint8arraylist");function kn(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function rt(r){return!!r?.[On]}var nt=class r{bufs;length;[On]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(rt(n)){t+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}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(rt(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=kn(this.bufs,e);return t.buf[t.index]}set(e,t){let n=kn(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(rt(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return ee(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:ee(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new r;return s.length=o,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=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,e>=c)continue;let l=e>=a&&e<c,h=t>a&&t<=c;if(l&&h){if(e===a&&t===c){n.push(i);break}let d=e-a;n.push(i.subarray(d,d+(t-e)));break}if(l){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(h){if(t===c){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!rt(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let d=0;d<s;d++)i[d]=-1;for(let d=0;d<o;d++)i[n[d]]=d;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,h;for(let d=t;d<=c;d+=h){h=0;for(let u=l;u>=0;u--){let p=this.get(d+u);if(n[u]!==p){h=Math.max(1,u-a[p]);break}}if(h===0)return d}return-1}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=J(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 o=z(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,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 o=z(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,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 o=z(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,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=J(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 o=z(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,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 o=z(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,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 o=z(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,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 o=z(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,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 o=z(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!he(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function Ns(r){return r.buffer instanceof ArrayBuffer}function nr(r){return Ns(r)?r:r.slice()}var Us=Math.pow(2,7),$s=Math.pow(2,14),Rs=Math.pow(2,21),or=Math.pow(2,28),sr=Math.pow(2,35),ir=Math.pow(2,42),ar=Math.pow(2,49),v=128,T=127;function _e(r){if(r<Us)return 1;if(r<$s)return 2;if(r<Rs)return 3;if(r<or)return 4;if(r<sr)return 5;if(r<ir)return 6;if(r<ar)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cr(r,e,t=0){switch(_e(r)){case 8:e[t++]=r&255|v,r/=128;case 7:e[t++]=r&255|v,r/=128;case 6:e[t++]=r&255|v,r/=128;case 5:e[t++]=r&255|v,r/=128;case 4:e[t++]=r&255|v,r>>>=7;case 3:e[t++]=r&255|v,r>>>=7;case 2:e[t++]=r&255|v,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function zs(r,e){let t=r[e],n=0;if(n+=t&T,t<v||(t=r[e+1],n+=(t&T)<<7,t<v)||(t=r[e+2],n+=(t&T)<<14,t<v)||(t=r[e+3],n+=(t&T)<<21,t<v)||(t=r[e+4],n+=(t&T)*or,t<v)||(t=r[e+5],n+=(t&T)*sr,t<v)||(t=r[e+6],n+=(t&T)*ir,t<v)||(t=r[e+7],n+=(t&T)*ar,t<v))return n;throw new RangeError("Could not decode varint")}function Bs(r,e){let t=r.get(e),n=0;if(n+=t&T,t<v||(t=r.get(e+1),n+=(t&T)<<7,t<v)||(t=r.get(e+2),n+=(t&T)<<14,t<v)||(t=r.get(e+3),n+=(t&T)<<21,t<v)||(t=r.get(e+4),n+=(t&T)*or,t<v)||(t=r.get(e+5),n+=(t&T)*sr,t<v)||(t=r.get(e+6),n+=(t&T)*ir,t<v)||(t=r.get(e+7),n+=(t&T)*ar,t<v))return n;throw new RangeError("Could not decode varint")}function ur(r,e=0){return r instanceof Uint8Array?zs(r,e):Bs(r,e)}var lr={};F(lr,{base10:()=>Vs});var Vs=se({prefix:"9",name:"base10",alphabet:"0123456789"});var fr={};F(fr,{base16:()=>qs,base16upper:()=>js});var qs=_({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),js=_({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var hr={};F(hr,{base2:()=>Ws});var Ws=_({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dr={};F(dr,{base256emoji:()=>Ks});var Fn=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}"),Hs=Fn.reduce((r,e,t)=>(r[t]=e,r),[]),Gs=Fn.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Qs(r){return r.reduce((e,t)=>(e+=Hs[t],e),"")}function Xs(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=Gs[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Ks=we({prefix:"\u{1F680}",name:"base256emoji",encode:Qs,decode:Xs});var pr={};F(pr,{base8:()=>Js});var Js=_({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mr={};F(mr,{identity:()=>Ys});var Ys=we({prefix:"\0",name:"identity",encode:r=>gn(R(r)),decode:r=>R(mn(r))});var _c=new TextEncoder,Ic=new TextDecoder;var gr={};F(gr,{sha256:()=>ti,sha512:()=>ri});function Nn(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ti=Jt({name:"sha2-256",code:18,encode:Nn("SHA-256")}),ri=Jt({name:"sha2-512",code:19,encode:Nn("SHA-512")});var Me={...mr,...hr,...pr,...lr,...fr,...Wt,...Ht,...Gt,...Zt,...dr},Ac={...gr,...tr};function $n(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Un=$n("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),br=$n("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=J(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ni={utf8:Un,"utf-8":Un,hex:Me.base16,latin1:br,ascii:br,binary:br,...Me},ot=ni;function C(r,e="utf8"){let t=ot[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var st=class extends Error{static name="InsufficientProvidersError";constructor(e="Insufficient providers found"){super(e),this.name="InsufficientProvidersError"}};var M=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var it=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};function oi(r){return typeof r?.handleEvent=="function"}function si(r){return(r!==!0&&r!==!1&&r?.once)??!1}var Ie=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){let o=si(n);super.addEventListener(e,i=>{if(o){let a=this.#e.get(i.type);a!=null&&(a=a.filter(({callback:c})=>c!==t),this.#e.set(i.type,a))}oi(t)?t.handleEvent(i):t(i)},n);let s=this.#e.get(e);s==null&&(s=[],this.#e.set(e,s)),s.push({callback:t,once:o})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var wr={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Rn={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},zn=new globalThis.TextEncoder;function ii(r,e){let t=wr[e],n=Rn[e];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(e,n*t);return n}function ai(r,e,t){if(t.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=wr[e],o=Rn[e],s=r;for(;s.length>0;){let i=zn.encodeInto(s,t);s=s.slice(i.read);for(let a=0;a<i.written;a++)o^=BigInt(t[a]),o=BigInt.asUintN(e,o*n)}return o}function xr(r,{size:e=32,utf8Buffer:t}={}){if(!wr[e])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(t)return ai(r,e,t);r=zn.encode(r)}return ii(r,e)}var Ve={hash:r=>Number(xr(r,{size:32})),hashV:(r,e)=>ci(Ve.hash(r,e))};function ci(r){let e=r.toString(16);return e.length%2===1&&(e=`0${e}`),C(e,"base16")}var yr=64,V=class{fp;h;seed;constructor(e,t,n,o=2){if(o>yr)throw new TypeError("Invalid Fingerprint Size");let s=t.hashV(e,n),i=z(o);for(let a=0;a<i.length;a++)i[a]=s[a];i.length===0&&(i[0]=7),this.fp=i,this.h=t,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(e){return e?.fp instanceof Uint8Array?he(this.fp,e.fp):!1}};function de(r,e){return Math.floor(Math.random()*(e-r))+r}var pe=class{contents;constructor(e){this.contents=new Array(e).fill(null)}has(e){if(!(e instanceof V))throw new TypeError("Invalid Fingerprint");return this.contents.some(t=>e.equals(t))}add(e){if(!(e instanceof V))throw new TypeError("Invalid Fingerprint");for(let t=0;t<this.contents.length;t++)if(this.contents[t]==null)return this.contents[t]=e,!0;return!0}swap(e){if(!(e instanceof V))throw new TypeError("Invalid Fingerprint");let t=de(0,this.contents.length-1),n=this.contents[t];return this.contents[t]=e,n}remove(e){if(!(e instanceof V))throw new TypeError("Invalid Fingerprint");let t=this.contents.findIndex(n=>e.equals(n));return t>-1?(this.contents[t]=null,!0):!1}};var ui=500,qe=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(e){this.filterSize=e.filterSize,this.bucketSize=e.bucketSize??4,this.fingerprintSize=e.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=e.hash??Ve,this.seed=e.seed??de(0,Math.pow(2,10))}add(e){typeof e=="string"&&(e=C(e));let t=new V(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=(n^t.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new pe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new pe(this.bucketSize)),this.buckets[n].add(t)||this.buckets[o].add(t))return this.count++,!0;let s=[n,o],i=s[de(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new pe(this.bucketSize));for(let a=0;a<ui;a++){let c=this.buckets[i].swap(t);if(c!=null&&(i=(i^c.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new pe(this.bucketSize)),this.buckets[i].add(c)))return this.count++,!0}return!1}has(e){typeof e=="string"&&(e=C(e));let t=new V(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=this.buckets[n]?.has(t)??!1;if(o)return o;let s=(n^t.hash())%this.filterSize;return this.buckets[s]?.has(t)??!1}remove(e){typeof e=="string"&&(e=C(e));let t=new V(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,o=this.buckets[n]?.remove(t)??!1;if(o)return this.count--,o;let s=(n^t.hash())%this.filterSize,i=this.buckets[s]?.remove(t)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},li={1:.5,2:.84,4:.95,8:.98};function fi(r=.001){return r>.002?2:r>1e-5?4:8}function Bn(r,e=.001){let t=fi(e),n=li[t],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/e)+Math.log2(2*t)),yr);return{filterSize:o,bucketSize:t,fingerprintSize:s}}var at=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(e){this.bucketSize=e.bucketSize??4,this.filterSize=e.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=e.fingerprintSize??2,this.scale=e.scale??2,this.hash=e.hash??Ve,this.seed=e.seed??de(0,Math.pow(2,10)),this.filterSeries=[new qe({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(e){if(typeof e=="string"&&(e=C(e)),this.has(e))return!0;let t=this.filterSeries.find(n=>n.reliable);if(t==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);t=new qe({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(t)}return t.add(e)}has(e){typeof e=="string"&&(e=C(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].has(e))return!0;return!1}remove(e){typeof e=="string"&&(e=C(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].remove(e))return!0;return!1}get count(){return this.filterSeries.reduce((e,t)=>e+t.count,0)}};function ct(r,e=.001,t){return new at({...Bn(r,e),...t??{}})}function hi(r){let e=r.getComponents(),t={},n=0;return e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t)}function ut(r){let e=hi(r);if(e==null)throw new it(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var lt=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let h=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let u=Number.parseInt(d,e);if(!Number.isNaN(u))return u});if(h===void 0)break;if(s*=e,s+=h,s>l||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var di=45,pi=15,ft=new lt;function Mn(r){if(!(r.length>pi))return ft.new(r).parseWith(()=>ft.readIPv4Addr())}function Vn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>di))return ft.new(r).parseWith(()=>ft.readIPv6Addr())}function Se(r){return!!Mn(r)}function ht(r){return!!Vn(r)}var Hn=Mo(Wn(),1),Ei=["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"],vi=Ei.map(r=>new Hn.Netmask(r));function Pr(r){for(let e of vi)if(e.contains(r))return!0;return!1}function _i(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Ii(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return Pr(o)}function Si(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Ci(r){let e=r.split(":"),t=e[e.length-1];return Pr(t)}function Pi(r){return/^::$/.test(r)||/^::1$/.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)}function Gn(r){if(Se(r))return Pr(r);if(_i(r))return Ii(r);if(Si(r))return Ci(r);if(ht(r))return Pi(r)}function Qn(r){try{let e=ut(r);switch(e.type){case"ip4":case"ip6":return Gn(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}function ce(r,e="utf8"){let t=ot[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var A=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},te=class extends Error{static name="ValidationError";name="ValidationError"},pt=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},mt=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function Tr(r){return e=>ce(e,r)}function Dr(r){return e=>C(e,r)}function Te(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ge(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function Xn(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=C(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ge(n);return ee([t,o],t.length+o.length)}function Kn(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=ie.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 o=ge(n);return ee([t,o],t.length+o.length)}function Lr(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=ce(e,"base32"),o=Te(t);return`${n}:${o}`}var kr=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new A("Invalid byte value in IP address");e[n]=o}),e},Jn=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=Se(t[n]),i;s&&(i=kr(t[n]),t[n]=ce(i.subarray(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,ce(i.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let s=parseInt(t[n],16);if(isNaN(s)||s<0||s>65535)throw new A("Invalid byte value in IP address");o[e++]=s>>8&255,o[e++]=s&255}return o},Yn=function(r){if(r.byteLength!==4)throw new A("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},Zn=function(r){if(r.byteLength!==16)throw new A("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;e.push(i)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new A(`Invalid IPv6 address "${t}"`)}};function eo(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new A(`Invalid IPv6 address "${r}"`)}}var Ar=Object.values(Me).map(r=>r.decoder),Ai=(function(){let r=Ar[0].or(Ar[1]);return Ar.slice(2).forEach(e=>r=r.or(e)),r})();function to(r){return Ai.decode(r)}function ro(r){return e=>r.encoder.encode(e)}function Ti(r){if(parseInt(r).toString()!==r)throw new te("Value must be an integer")}function Di(r){if(r<0)throw new te("Value must be a positive integer, or zero")}function Li(r){return e=>{if(e>r)throw new te(`Value must be smaller than or equal to ${r}`)}}function ki(...r){return e=>{for(let t of r)t(e)}}var je=ki(Ti,Di,Li(65535));var P=-1,Or=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new mt(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},re=new Or,Hi=[{code:4,name:"ip4",size:32,valueToBytes:kr,bytesToValue:Yn,validate:r=>{if(!Se(r))throw new te(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ge,bytesToValue:Te,validate:je},{code:273,name:"udp",size:16,valueToBytes:ge,bytesToValue:Te,validate:je},{code:33,name:"dccp",size:16,valueToBytes:ge,bytesToValue:Te,validate:je},{code:41,name:"ip6",size:128,valueToBytes:Jn,bytesToValue:Zn,stringToValue:eo,validate:r=>{if(!ht(r))throw new te(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:P},{code:43,name:"ipcidr",size:8,bytesToValue:Tr("base10"),valueToBytes:Dr("base10")},{code:53,name:"dns",size:P},{code:54,name:"dns4",size:P},{code:55,name:"dns6",size:P},{code:56,name:"dnsaddr",size:P},{code:132,name:"sctp",size:16,valueToBytes:ge,bytesToValue:Te,validate:je},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:P,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:P,bytesToValue:Tr("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Dr("base58btc")(r):K.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Lr,valueToBytes:Xn},{code:445,name:"onion3",size:296,bytesToValue:Lr,valueToBytes:Kn},{code:446,name:"garlic64",size:P},{code:447,name:"garlic32",size:P},{code:448,name:"tls"},{code:449,name:"sni",size:P},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:P,bytesToValue:ro(Yt),valueToBytes:to},{code:480,name:"http"},{code:481,name:"http-path",size:P,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:P}];Hi.forEach(r=>{re.addProtocol(r)});function no(r){let e=[],t=0;for(;t<r.length;){let n=ur(r,t),o=re.getProtocol(n),s=_e(n),i=Gi(o,r,t+s),a=0;i>0&&o.size===P&&(a=_e(i));let c=s+a+i,l={code:n,name:o.name,bytes:nr(r.subarray(t,t+c))};if(i>0){let h=t+s+a,d=r.subarray(h,h+i);l.value=o.bytesToValue?.(d)??ce(d)}e.push(l),t+=c}return e}function oo(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=re.getProtocol(n.code),s=_e(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??C(n.value),a=i.byteLength,o.size===P&&(c=_e(a)));let l=new Uint8Array(s+c+a),h=0;cr(n.code,l,h),h+=s,i!=null&&(o.size===P&&(cr(a,l,h),h+=c),l.set(i,h)),n.bytes=l}t.push(n.bytes),e+=n.bytes.byteLength}return ee(t,e)}function so(r){if(r.charAt(0)!=="/")throw new A('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(t==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=re.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new A(`Component ${o} was missing value`);t="value"}else if(t==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new A(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}e.push(l),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new A("Incomplete multiaddr");return e}function io(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=re.getProtocol(e.code);if(t==null)throw new A(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function Gi(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:ur(e,t)}var Qi=Symbol.for("nodejs.util.inspect.custom"),Wr=Symbol.for("@multiformats/multiaddr");function Xi(r){if(r==null&&(r="/"),ao(r))return r.getComponents();if(r instanceof Uint8Array)return no(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),so(r);if(Array.isArray(r))return r;throw new A("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Et=class r{[Wr]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=Xi(e),t.validate!==!1&&Ki(this)}get bytes(){return this.#r==null&&(this.#r=oo(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=io(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new pt(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}equals(e){return he(this.bytes,e.bytes)}[Qi](){return`Multiaddr(${this.toString()})`}};function Ki(r){r.getComponents().forEach(e=>{let t=re.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function ao(r){return!!r?.[Wr]}function vt(r){return new Et(r)}var y=r=>({match:e=>{let t=e[0];return t==null||t.code!==r||t.value!=null?!1:e.slice(1)}}),f=(r,e)=>({match:t=>{let n=t[0];return n?.code!==r||n.value==null||e!=null&&n.value!==e?!1:t.slice(1)}}),co=r=>({match:e=>r.match(e)===!1?e:!1}),m=r=>({match:e=>{let t=r.match(e);return t===!1?e:t}}),D=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1}}),b=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e}});function E(...r){function e(o){if(o==null)return!1;let s=o.getComponents();for(let i of r){let a=i.match(s);if(a===!1)return!1;s=a}return s}function t(o){return e(o)!==!1}function n(o){let s=e(o);return s===!1?!1:s.length===0}return{matchers:r,matches:t,exactMatch:n}}var Ji=f(421),Dl=E(Ji),It=f(54),St=f(55),Ct=f(56),Gr=f(53),Ll=E(It,m(f(421))),kl=E(St,m(f(421))),Ol=E(Ct,m(f(421))),uo=E(D(Gr,Ct,It,St),m(f(421))),lo=b(f(4),m(f(43))),fo=b(m(f(42)),f(41),m(f(43))),Qr=D(lo,fo),ke=D(Qr,Gr,It,St,Ct),Fl=E(D(Qr,b(D(Gr,Ct,It,St),m(f(421))))),Nl=E(lo),Ul=E(fo),$l=E(Qr),Xr=b(ke,f(6)),Ke=b(ke,f(273)),Rl=E(b(Xr,m(f(421)))),zl=E(Ke),Kr=b(Ke,y(460),m(f(421))),Pt=b(Ke,y(461),m(f(421))),Yi=D(Kr,Pt),Bl=E(Kr),Ml=E(Pt),Hr=D(ke,Xr,Ke,Kr,Pt),ho=D(b(Hr,y(477),m(f(421)))),Vl=E(ho),po=D(b(Hr,y(478),m(f(421))),b(Hr,y(448),m(f(449)),y(477),m(f(421)))),ql=E(po),mo=b(Ke,y(280),m(f(466)),m(f(466)),m(f(421))),jl=E(mo),go=b(Pt,y(465),m(f(466)),m(f(466)),m(f(421))),Wl=E(go),_t=D(ho,po,b(Xr,m(f(421))),b(Yi,m(f(421))),b(ke,m(f(421))),mo,go,f(421)),Hl=E(_t),Zi=b(m(_t),y(290),co(y(281)),m(f(421))),Gl=E(Zi),ea=D(b(_t,y(290),y(281),m(f(421))),b(_t,y(281),m(f(421))),b(y(281),m(f(421)))),Ql=E(ea),ta=b(ke,D(b(f(6,"80")),b(f(6),y(480)),y(480)),m(f(481)),m(f(421))),bo=E(ta),ra=b(ke,D(b(f(6,"443")),b(f(6,"443"),y(480)),b(f(6),y(443)),b(f(6),y(448),y(480)),b(y(448),y(480)),y(448),y(443)),m(f(481)),m(f(421))),wo=E(ra),na=D(b(f(777),m(f(421)))),Xl=E(na),oa=D(b(f(400),m(f(421)))),Kl=E(oa);function ne(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var At=class{buffer;mask;top;btm;next;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}},Oe=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new At(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 At(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()}};var Jr=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function xo(r={}){return sa(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 sa(r,e){e=e??{};let t=e.onEnd,n=new Oe,o,s,i,a=ne(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((x,g)=>{s=S=>{s=null,n.push(S);try{x(r(n))}catch(k){g(k)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=ne()})}},l=x=>s!=null?s(x):(n.push(x),o),h=x=>(n=new Oe,s!=null?s({error:x}):(n.push({error:x}),o)),d=x=>{if(i)return o;if(e?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:x})},u=x=>i?o:(i=!0,x!=null?h(x):l({done:!0})),p=()=>(n=new Oe,u(),{done:!0}),L=x=>(u(x),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:p,throw:L,push:d,end:u,get readableLength(){return n.size},onEmpty:async x=>{let g=x?.signal;if(g?.throwIfAborted(),n.isEmpty())return;let S,k;g!=null&&(S=new Promise((N,U)=>{k=()=>{U(new Jr)},g.addEventListener("abort",k)}));try{await Promise.race([a.promise,S])}finally{k!=null&&g!=null&&g?.removeEventListener("abort",k)}}},t==null)return o;let O=o;return o={[Symbol.asyncIterator](){return this},next(){return O.next()},throw(x){return O.throw(x),t!=null&&(t(x),t=void 0),{done:!0}},return(){return O.return(),t!=null&&(t(),t=void 0),{done:!0}},push:d,end(x){return O.end(x),t!=null&&(t(x),t=void 0),o},get readableLength(){return O.readableLength},onEmpty:x=>O.onEmpty(x)},o}var Yr=class r extends Error{name="TimeoutError";constructor(e,t){super(e,t),Error.captureStackTrace?.(this,r)}},yo=r=>r.reason??new DOMException("This operation was aborted.","AbortError");function Zr(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout},signal:i}=e,a,c,h=new Promise((d,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(i?.aborted){u(yo(i));return}if(i&&(c=()=>{u(yo(i))},i.addEventListener("abort",c,{once:!0})),r.then(d,u),t===Number.POSITIVE_INFINITY)return;let p=new Yr;a=s.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(L){u(L)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?d():o instanceof Error?u(o):(p.message=o??`Promise timed out after ${t} milliseconds`,u(p))},t)}).finally(()=>{h.clear(),c&&i&&i.removeEventListener("abort",c)});return h.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},h}var ia=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function aa(r,e,t){let n,o=new Promise((s,i)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:l,removeListener:h}=ia(r),d=async(...p)=>{let L=t.multiArgs?p:p[0];if(t.filter)try{if(!await t.filter(L))return}catch(O){n(),i(O);return}c.push(L),t.count===c.length&&(n(),s(c))},u=(...p)=>{n(),i(t.rejectionMultiArgs?p:p[0])};n=()=>{for(let p of a)h(p,d);for(let p of t.rejectionEvents)a.includes(p)||h(p,u)};for(let p of a)l(p,d);for(let p of t.rejectionEvents)a.includes(p)||l(p,u);t.signal&&t.signal.addEventListener("abort",()=>{u(t.signal.reason)},{once:!0}),t.resolveImmediately&&s(c)});if(o.cancel=n,typeof t.timeout=="number"){let s=Zr(o,{milliseconds:t.timeout});return s.cancel=()=>{n(),s.clear()},s}return o}function Tt(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=aa(r,e,t),o=n.then(s=>s[0]);return o.cancel=n.cancel,o}function en(r,e){let t,n=function(){let o=function(){t=void 0,r()};clearTimeout(t),t=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(t)},n}var Dt=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};function ca(r){return r.reason}async function Lt(r,e,t){if(e==null)return r;let n=t?.translateError??ca;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((s,i)=>{o=()=>{i(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var kt=class{deferred;signal;onProgress;constructor(e){this.signal=e?.signal,this.onProgress=e?.onProgress,this.deferred=ne(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new M)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function ua(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var Ot=class{id;fn;options;recipients;status;timeline;controller;dispatchingProgress;constructor(e,t){this.id=ua(),this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.dispatchingProgress=!1,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((t,n)=>t&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new M),this.cleanup())}async join(e){let t=new kt(e);return this.recipients.push(t),e?.signal?.addEventListener("abort",this.onAbort),t.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await Lt(this.fn({...this.options??{},signal:this.controller.signal,onProgress:t=>{if(!this.dispatchingProgress){this.dispatchingProgress=!0;try{this.recipients.forEach(n=>{n.onProgress?.(t)})}finally{this.dispatchingProgress=!1}}}}),this.controller.signal);this.recipients.forEach(t=>{t.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(t=>{t.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var Ft=class extends Ie{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=en(this.emitEmpty.bind(this),1),this.emitIdle=en(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let t of this.queue)if(t.status==="queued"){e=t;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,t){if(t?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Dt;let n=new Ot(e,t);this.enqueue(n),this.safeDispatchEvent("add");let o=n.join(t).then(s=>(this.safeDispatchEvent("completed",{detail:s}),this.safeDispatchEvent("success",{detail:{job:n,result:s}}),s)).catch(s=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:s}}),s});return this.tryToStartAnother(),o}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new M)}),this.clear()}async onEmpty(e){this.size!==0&&await Tt(this,"empty",e)}async onSizeLessThan(e,t){this.size<e||await Tt(this,"next",{...t,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await Tt(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let t=xo({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),t.end(c)},o=c=>{c.detail!=null&&t.push(c.detail)},s=c=>{n(c.detail.error)},i=()=>{n()},a=()=>{n(new M("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",s),this.addEventListener("idle",i),e?.signal?.addEventListener("abort",a);try{yield*t}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",s),this.removeEventListener("idle",i),e?.signal?.removeEventListener("abort",a),n()}}};var Nt=class extends Ie{initialPeerSearchComplete;requests;logName;log;logger;minProviders;maxProviders;providers;evictionFilter;initialProviders;cidPeerFilterSize;constructor(e,t){super(),this.logName=t.name,this.logger=e.logger,this.log=e.logger.forComponent(this.logName),this.requests=new Map,this.minProviders=t.minProviders??1,this.maxProviders=t.maxProviders??5,this.cidPeerFilterSize=t.cidPeerFilterSize??100,this.providers=[],this.evictionFilter=ct(this.maxProviders),this.initialProviders=[...t.providers??[]]}async retrieve(e,t={}){let n=Be.encode(e.multihash.bytes),o=this.requests.get(n);if(o!=null)return this.log("join existing request for %c",e),o.observers++,o.promise;let s=ne(),i={promise:s.promise,observers:1,queryFilter:ct(this.cidPeerFilterSize)};this.requests.set(n,i);let a=!1;this.initialPeerSearchComplete==null&&(a=!0,this.log=this.logger.forComponent(`${this.logName}:${e}`),this.initialPeerSearchComplete=this.findProviders(e,this.minProviders,t));let c=!1,l=new Ft({concurrency:this.maxProviders});l.addEventListener("failure",u=>{this.log.error("error querying provider %s, evicting from session - %e",u.detail.job.options.provider,u.detail.error),this.evict(u.detail.job.options.provider)}),l.addEventListener("success",u=>{c=!0,s.resolve(u.detail.result)}),l.addEventListener("idle",()=>{if(c){this.log.trace("session idle, found block");return}if(t.signal?.aborted===!0){this.log.trace("session idle, signal aborted");return}Promise.resolve().then(async()=>{this.log("no session peers had block for for %c, finding new providers",e);for(let u=0;u<this.minProviders&&this.providers.length!==0;u++){let p=this.providers[Math.floor(Math.random()*this.providers.length)];this.evict(p)}await this.findProviders(e,this.minProviders,t),this.log("found new providers re-retrieving %c",e),this.requests.delete(n),s.resolve(await this.retrieve(e,t))}).catch(u=>{this.log.error("could not find new providers for %c - %e",e,u),s.reject(u)})});let h=u=>{let p=this.toFilterKey(u.detail);i.queryFilter.has(p)||(i.queryFilter.add(p),this.emitFoundProviderProgressEvent(e,u.detail,t),l.add(async()=>this.queryProvider(e,u.detail,t),{provider:u.detail}).catch(L=>{t.signal?.aborted!==!0&&this.log.error("error retrieving session block for %c - %e",e,L)}))};if(this.addEventListener("provider",h),a)try{await Lt(this.initialPeerSearchComplete,t.signal),a&&this.log("found initial session peers for %c",e)}catch(u){throw a&&this.log("failed to find initial session peers for %c - %e",e,u),this.requests.delete(n),i.observers>1&&s.reject(u),u}Promise.all([...this.providers].filter(u=>{let p=this.toFilterKey(u),L=i.queryFilter.has(p);return L||i.queryFilter.add(this.toFilterKey(u)),!L}).map(async u=>l.add(async()=>this.queryProvider(e,u,t),{provider:u}))).catch(u=>{t.signal?.aborted!==!0&&this.log.error("error retrieving session block for %c - %e",e,u)});let d=()=>{s.reject(new M(t.signal?.reason??"Session aborted")),l.abort()};t.signal?.addEventListener("abort",d);try{return await s.promise}finally{this.removeEventListener("provider",h),t.signal?.removeEventListener("abort",d),l.clear(),this.requests.delete(n)}}evict(e){this.evictionFilter.add(this.toFilterKey(e));let t=this.providers.findIndex(n=>this.equals(n,e));t!==-1&&this.providers.splice(t,1)}isEvicted(e){return this.evictionFilter.has(this.toFilterKey(e))}hasProvider(e){return!!(this.providers.find(t=>this.equals(t,e))!=null||this.isEvicted(e))}async addPeer(e,t){let n=await this.convertToProvider(e,"manually-added",t);n==null||this.hasProvider(n)||(this.providers.push(n),this.safeDispatchEvent("provider",{detail:n}))}async findProviders(e,t,n){let o=ne(),s=0;return Promise.resolve().then(async()=>{this.log("finding %d-%d new provider(s) for %c - %d initial providers",t,this.maxProviders,e,this.initialProviders.length);let i=this,a=async function*(){for(;i.initialProviders.length>0;){let l=i.initialProviders.pop();if(l==null)continue;let h=await i.convertToProvider(l,"manual",n);h!=null&&(yield h)}},c=async function*(){yield*a(),yield*i.findNewProviders(e,n)};for await(let l of c()){if(this.providers.length===this.maxProviders||n.signal?.aborted===!0)break;if(!this.hasProvider(l)&&(this.log("found %d providers, %d in session",s,this.providers.length),this.providers.push(l),this.safeDispatchEvent("provider",{detail:l}),s++,this.providers.length===t&&(this.log("session is ready with %d peer(s), new peers present",this.providers.length),o.resolve()),this.providers.length===this.maxProviders)){this.log("found max session peers %d",this.providers.length);break}}if(this.log("found %d new session peers while trying to find %d, %d in session",s,t,this.providers.length),this.providers.length<t)throw new st(`Found ${s} of ${t} ${this.name} providers for ${e}, ${this.providers.length} in session after evictions`)}).catch(i=>{this.log.error("error searching routing for potential session peers for %c - %e",e,i),o.reject(i)}),o.promise}};function Eo(r){return r==null?!1:K.asCID(r)!=null}var da=[6,53,56,54,55];function vo(r){return So("sni",r)?.value}function _o(r){let e=So("tcp",r)?.value;return e==null?"":`:${e}`}function So(r,e){return e.find(t=>t.name===r)}function Io(r){return r.some(({code:e})=>e===448)}function j(r,e){let t=Co[r.name];if(t==null)throw new Error(`Can't interpret protocol ${r.name}`);let n=t(r,e);return r.code===41?`[${n}]`:n}var Co={ip4:(r,e)=>r.value,ip6:(r,e)=>e.length===0?r.value:`[${r.value}]`,tcp:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`tcp://${j(t,e)}:${r.value}`},udp:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`udp://${j(t,e)}:${r.value}`},dnsaddr:(r,e)=>r.value,dns4:(r,e)=>r.value,dns6:(r,e)=>r.value,dns:(r,e)=>r.value,ipfs:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`${j(t,e)}`},p2p:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`${j(t,e)}`},http:(r,e)=>{let t=Io(e),n=vo(e),o=_o(e);if(t&&n!=null)return`https://${n}${o}`;let s=t?"https://":"http://",i=e.pop();if(i==null)throw new Error("Unexpected end of multiaddr");let a=j(i,e);return a=a?.replace("tcp://",""),`${s}${a}`},"http-path":(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");let n=j(t,e),o=decodeURIComponent(r.value??"");return`${n}${o}`},tls:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return j(t,e)},sni:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return j(t,e)},https:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");let n=j(t,e);return n=n?.replace("tcp://",""),`https://${n}`},ws:(r,e)=>{let t=Io(e),n=vo(e),o=_o(e);if(t&&n!=null)return`wss://${n}${o}`;let s=t?"wss://":"ws://",i=e.pop();if(i==null)throw new Error("Unexpected end of multiaddr");let a=j(i,e);return a=a?.replace("tcp://",""),`${s}${a}`},wss:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");let n=j(t,e);return n=n?.replace("tcp://",""),`wss://${n}`}};function Ut(r,e){let n=vt(r).getComponents(),o=n.pop();if(o==null)throw new Error("Unexpected end of multiaddr");let s=Co[o.name];if(s==null)throw new Error(`No interpreter found for ${o.name}`);let i=s(o,n)??"";return e?.assumeHttp!==!1&&da.includes(o.code)&&(i=i.replace(/^.*:\/\//,""),o.value==="443"?i=`https://${i}`:i=`http://${i}`),(i.startsWith("http://")||i.startsWith("https://")||i.startsWith("ws://")||i.startsWith("wss://"))&&(i=new URL(i).toString(),i.endsWith("/")&&(i=i.substring(0,i.length-1))),i}var W=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var Po="[a-fA-F\\d:]",le=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${Po})|(?<=${Po})(?=\\s|$))`:"",H="(?: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}",I="[a-fA-F\\d]{1,4}",$t=`
13
3
  (?:
14
- (?:${D}:){7}(?:${D}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
15
- (?:${D}:){6}(?:${X}|:${D}|:)| // 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
16
- (?:${D}:){5}(?::${X}|(?::${D}){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
17
- (?:${D}:){4}(?:(?::${D}){0,1}:${X}|(?::${D}){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
18
- (?:${D}:){3}(?:(?::${D}){0,2}:${X}|(?::${D}){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
19
- (?:${D}:){2}(?:(?::${D}){0,3}:${X}|(?::${D}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
20
- (?:${D}:){1}(?:(?::${D}){0,4}:${X}|(?::${D}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
21
- (?::(?:(?::${D}){0,5}:${X}|(?::${D}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
4
+ (?:${I}:){7}(?:${I}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
+ (?:${I}:){6}(?:${H}|:${I}|:)| // 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
6
+ (?:${I}:){5}(?::${H}|(?::${I}){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
7
+ (?:${I}:){4}(?:(?::${I}){0,1}:${H}|(?::${I}){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
8
+ (?:${I}:){3}(?:(?::${I}){0,2}:${H}|(?::${I}){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
9
+ (?:${I}:){2}(?:(?::${I}){0,3}:${H}|(?::${I}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
10
+ (?:${I}:){1}(?:(?::${I}){0,4}:${H}|(?::${I}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
+ (?::(?:(?::${I}){0,5}:${H}|(?::${I}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
22
12
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
23
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),uc=new RegExp(`(?:^${X}$)|(?:^${He}$)`),fc=new RegExp(`^${X}$`),hc=new RegExp(`^${He}$`),mn=r=>r&&r.exact?uc:new RegExp(`(?:${ut(r)}${X}${ut(r)})|(?:${ut(r)}${He}${ut(r)})`,"g");mn.v4=r=>r&&r.exact?fc:new RegExp(`${ut(r)}${X}${ut(r)}`,"g");mn.v6=r=>r&&r.exact?hc:new RegExp(`${ut(r)}${He}${ut(r)}`,"g");var gn=mn;function yn(r){let t=(...e)=>r(...e);return Object.defineProperty(t,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),t}function Xo(){return!1}var{toString:dc}=Object.prototype;function wn(r){return dc.call(r)==="[object RegExp]"}var Jo={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function bn(r,t={}){if(!wn(r))throw new TypeError("Expected a RegExp instance");let e=Object.keys(Jo).map(o=>(typeof t[o]=="boolean"?t[o]:r[o])?Jo[o]:"").join(""),n=new RegExp(t.source||r.source,e);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:r.lastIndex,n}function xn(r,t,{timeout:e}={}){try{return yn(()=>bn(r).test(t),{timeout:e})()}catch(n){if(Xo(n))return!1;throw n}}var pc=15,mc=45,Yo={timeout:400};function En(r){return r.length>mc?!1:xn(gn.v6({exact:!0}),r,Yo)}function Zo(r){return r.length>pc?!1:xn(gn.v4({exact:!0}),r,Yo)}var ts={http:"80",https:"443",ws:"80",wss:"443"},gc=["http","https","ws","wss"];function es(r,t){t=t??{};let e=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:s,path:i}=yc(r),a=[wc(o,e),bc(s,n),xc(n)];i!=null&&a.push(Ec(i));let c="/"+a.filter(h=>!!h).reduce((h,u)=>h.concat(u),[]).join("/");return Le(c)}function yc(r){let[t]=r.split(":");gc.includes(t)||(r="http"+r.substring(t.length));let{protocol:e,hostname:n,port:o,pathname:s,search:i}=new URL(r);if(o==null||o===""){let c=vc(t);c!=null&&(o=c),c==null&&e==="http:"&&(o="80")}let a;return s!=null&&s!==""&&s!=="/"&&(s.startsWith("/")&&(s=s.substring(1)),a=s),i!=null&&i!==""&&(a=a??"",a+=i),{scheme:t,hostname:n,port:o,path:a}}function wc(r,t){if(!(r==null||r==="")){if(Zo(r))return["ip4",r];if(En(r))return["ip6",r];if(r[0]==="["){let e=r.substring(1,r.length-1);if(En(e))return["ip6",e]}return[t,r]}}function bc(r,t){if(!(r==null||r===""))return t==="udp"?["udp",r]:["tcp",r]}function xc(r){if(r.match(/^tcp$|^udp$/)==null)return r==="https"?["/tls/http"]:r==="wss"?["/tls/ws"]:[r]}function Ec(r){if(!(r==null||r===""))return["http-path",encodeURIComponent(r)]}function vc(r){if(!(r==null||r===""||ts[r]==null))return ts[r]}function vn(r,t,e){return r.filter(n=>{let o=qo.exactMatch(n),s=Vo.exactMatch(n);if(!o&&!s)return!1;if(o||t&&s)return e||Oo.matches(n)?!0:xo(n)===!1;if(!t&&e){let{host:i}=xe(n);if(i==="127.0.0.1"||i==="localhost"||i.endsWith(".localhost"))return!0}return!1})}async function*Ke(r,t,e,n,o,s={}){for await(let i of t.findProviders(r,s)){let a=vn(i.multiaddrs,n,o);if(a.length===0)continue;let c=new URL(We(a[0]));yield new Mt(c,{logger:e,transformRequestInit:s.transformRequestInit,routing:i.routing})}}async function rs(r,t,e){let{signal:n,log:o}=e??{},s=r.headers.get("content-length");if(s!=null){let c=parseInt(s,10);if(c>t)throw o?.error("content-length header (%d) is greater than the limit (%d)",c,t),r.body!=null&&await r.body.cancel().catch(h=>{o?.error("error cancelling response body after content-length check - %e",h)}),new Error(`Content-Length header (${c}) is greater than the limit (${t}).`)}let i=r.body?.getReader();if(i==null)throw new Error("Response body is not readable");let a=new de;try{for(;;){if(n?.aborted===!0)throw new Error("Response body read was aborted.");let{done:c,value:h}=await i.read();if(c)break;if(a.append(h),a.byteLength>t)throw new Error(`Response body is greater than the limit (${t}), received ${a.byteLength} bytes.`)}}finally{i.cancel().catch(c=>{o?.error("error cancelling reader - %e",c)}).finally(()=>{i.releaseLock()})}return a.subarray()}var _c=2336,Mt=class{url;peer;#t=0;#e=0;#r=0;#o=0;#n=new Map;log;transformRequestInit;routing;constructor(t,{logger:e,transformRequestInit:n,routing:o}){this.url=t instanceof URL?t:new URL(t),this.transformRequestInit=n,this.log=e.forComponent(`helia:trustless-gateway-block-broker:${this.url.host}`),this.routing=o,this.peer=j.createV1(_c,br.digest(P(this.url.toString())))}#s(t){let e=t.multihash.bytes;return dt.encode(e)}async getRawBlock(t,e={}){let n=new URL(this.url.toString());n.pathname=`/ipfs/${t.toString()}`;let o=e.maxSize??_n;if(n.search="?format=raw",e.signal?.aborted===!0)throw new Error(`Signal to fetch raw block for CID ${t} from gateway ${this.url} was aborted prior to fetch`);let s=this.#s(t),i=new AbortController,a=()=>{i.abort()};e.signal?.addEventListener("abort",a);try{let c=this.#n.get(s);if(c==null){this.#t++;let h={signal:i.signal,headers:{Accept:"application/vnd.ipld.raw"},cache:"force-cache"},u=this.transformRequestInit!=null?await this.transformRequestInit(h):h,f=new Headers(u.headers);this.log(`sending request
13
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),pa=new RegExp(`(?:^${H}$)|(?:^${$t}$)`),ma=new RegExp(`^${H}$`),ga=new RegExp(`^${$t}$`),tn=r=>r&&r.exact?pa:new RegExp(`(?:${le(r)}${H}${le(r)})|(?:${le(r)}${$t}${le(r)})`,"g");tn.v4=r=>r&&r.exact?ma:new RegExp(`${le(r)}${H}${le(r)}`,"g");tn.v6=r=>r&&r.exact?ga:new RegExp(`${le(r)}${$t}${le(r)}`,"g");var rn=tn;function nn(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function Ao(){return!1}var{toString:ba}=Object.prototype;function on(r){return ba.call(r)==="[object RegExp]"}var To={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function sn(r,e={}){if(!on(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(To).map(o=>(typeof e[o]=="boolean"?e[o]:r[o])?To[o]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function an(r,e,{timeout:t}={}){try{return nn(()=>sn(r).test(e),{timeout:t})()}catch(n){if(Ao(n))return!1;throw n}}var wa=15,xa=45,Do={timeout:400};function cn(r){return r.length>xa?!1:an(rn.v6({exact:!0}),r,Do)}function Lo(r){return r.length>wa?!1:an(rn.v4({exact:!0}),r,Do)}var ko={http:"80",https:"443",ws:"80",wss:"443"},ya=["http","https","ws","wss"];function Oo(r,e){e=e??{};let t=e.defaultDnsType??"dns",{scheme:n,hostname:o,port:s,path:i}=Ea(r),a=[va(o,t),_a(s,n),Ia(n)];i!=null&&a.push(Sa(i));let c="/"+a.filter(l=>!!l).reduce((l,h)=>l.concat(h),[]).join("/");return vt(c)}function Ea(r){let[e]=r.split(":");ya.includes(e)||(r="http"+r.substring(e.length));let{protocol:t,hostname:n,port:o,pathname:s,search:i}=new URL(r);if(o==null||o===""){let c=Ca(e);c!=null&&(o=c),c==null&&t==="http:"&&(o="80")}let a;return s!=null&&s!==""&&s!=="/"&&(s.startsWith("/")&&(s=s.substring(1)),a=s),i!=null&&i!==""&&(a=a??"",a+=i),{scheme:e,hostname:n,port:o,path:a}}function va(r,e){if(!(r==null||r==="")){if(Lo(r))return["ip4",r];if(cn(r))return["ip6",r];if(r[0]==="["){let t=r.substring(1,r.length-1);if(cn(t))return["ip6",t]}return[e,r]}}function _a(r,e){if(!(r==null||r===""))return e==="udp"?["udp",r]:["tcp",r]}function Ia(r){if(r.match(/^tcp$|^udp$/)==null)return r==="https"?["/tls/http"]:r==="wss"?["/tls/ws"]:[r]}function Sa(r){if(!(r==null||r===""))return["http-path",encodeURIComponent(r)]}function Ca(r){if(!(r==null||r===""||ko[r]==null))return ko[r]}function un(r,e,t){return r.filter(n=>{let o=wo.exactMatch(n),s=bo.exactMatch(n);if(!o&&!s)return!1;if(o||e&&s)return t||uo.matches(n)?!0:Qn(n)===!1;if(!e&&t){let{host:i}=ut(n);if(i==="127.0.0.1"||i==="localhost"||i.endsWith(".localhost"))return!0}return!1})}async function*Rt(r,e,t,n,o,s={}){for await(let i of e.findProviders(r,s)){let a=un(i.multiaddrs,n,o);if(a.length===0)continue;let c=new URL(Ut(a[0]));yield new Fe(c,{logger:t,transformRequestInit:s.transformRequestInit,routing:i.routing})}}async function Fo(r,e,t){let{signal:n,log:o}=t??{},s=r.headers.get("content-length");if(s!=null){let c=parseInt(s,10);if(c>e)throw o?.error("content-length header (%d) is greater than the limit (%d)",c,e),r.body!=null&&await r.body.cancel().catch(l=>{o?.error("error cancelling response body after content-length check - %e",l)}),new Error(`Content-Length header (${c}) is greater than the limit (${e}).`)}let i=r.body?.getReader();if(i==null)throw new Error("Response body is not readable");let a=new nt;try{for(;;){if(n?.aborted===!0)throw new Error("Response body read was aborted.");let{done:c,value:l}=await i.read();if(c)break;if(a.append(l),a.byteLength>e)throw new Error(`Response body is greater than the limit (${e}), received ${a.byteLength} bytes.`)}}finally{i.cancel().catch(c=>{o?.error("error cancelling reader - %e",c)}).finally(()=>{i.releaseLock()})}return a.subarray()}var Pa=2336,Fe=class{url;peer;#e=0;#t=0;#r=0;#o=0;#n=new Map;log;transformRequestInit;routing;constructor(e,{logger:t,transformRequestInit:n,routing:o}){this.url=e instanceof URL?e:new URL(e),this.transformRequestInit=n,this.log=t.forComponent(`helia:trustless-gateway-block-broker:${this.url.host}`),this.routing=o,this.peer=K.createV1(Pa,er.digest(C(this.url.toString())))}#s(e){let t=e.multihash.bytes;return Be.encode(t)}async getRawBlock(e,t={}){let n=new URL(this.url.toString());n.pathname=`/ipfs/${e.toString()}`;let o=t.maxSize??ln;if(n.search="?format=raw",t.signal?.aborted===!0)throw new Error(`Signal to fetch raw block for CID ${e} from gateway ${this.url} was aborted prior to fetch`);let s=this.#s(e),i=new AbortController,a=()=>{i.abort()};t.signal?.addEventListener("abort",a);try{let c=this.#n.get(s);if(c==null){this.#e++;let l={signal:i.signal,headers:{Accept:"application/vnd.ipld.raw"},cache:"force-cache"},h=this.transformRequestInit!=null?await this.transformRequestInit(l):l,d=new Headers(h.headers);this.log(`sending request
24
14
  %s %s HTTP/1.1
25
15
  %s
26
- `,u.method??"GET",n,[...f.entries()].map(([l,m])=>`${l}: ${m}`).join(`
27
- `)),e.onProgress?.(new U("helia:block-broker:connect",{broker:"trustless-gateway",type:"connect",provider:this.peer,cid:t})),c=fetch(n.toString(),u).then(async l=>{if(this.log(`received response
16
+ `,h.method??"GET",n,[...d.entries()].map(([u,p])=>`${u}: ${p}`).join(`
17
+ `)),t.onProgress?.(new W("helia:block-broker:connect",{broker:"trustless-gateway",type:"connect",provider:this.peer,cid:e})),c=fetch(n.toString(),h).then(async u=>{if(this.log(`received response
28
18
  HTTP/1.1 %d %s
29
19
  %s
30
- `,l.status,l.statusText,[...l.headers.entries()].map(([g,x])=>`${g}: ${x}`).join(`
31
- `)),!l.ok)throw this.#e++,new Error(`Unable to fetch raw block for CID ${t} from gateway ${this.url}, received ${l.status} ${l.statusText}`);e.onProgress?.(new U("helia:block-broker:connected",{broker:"trustless-gateway",type:"connected",provider:this.peer,address:es(n.toString()),cid:t})),e.onProgress?.(new U("helia:block-broker:request-block",{broker:"trustless-gateway",type:"request-block",provider:this.peer,cid:t}));let m=await rs(l,o,{signal:i.signal,log:this.log});return e.onProgress?.(new U("helia:block-broker:receive-block",{broker:"trustless-gateway",type:"receive-block",provider:this.peer,cid:t})),this.#o++,m}),this.#n.set(s,c)}return await c}catch(c){throw e.signal?.aborted===!0?new Error(`Fetching raw block for CID ${t} from gateway ${this.url} was aborted`):(this.#e++,new Error(`Unable to fetch raw block for CID ${t} - ${c.message}`))}finally{e.signal?.removeEventListener("abort",a),this.#n.delete(s)}}reliability(){return this.#t===0?1:this.#r>0?-1/0:this.#o/(this.#t+this.#e*3)}incrementInvalidBlocks(){this.#r++}getStats(){return{attempts:this.#t,errors:this.#e,invalidBlocks:this.#r,successes:this.#o,pendingResponses:this.#n.size}}toString(){return`TrustlessGateway(${this.url})`}};var Cn=class extends oe{name="trustless-gateway-session";routing;allowInsecure;allowLocal;transformRequestInit;constructor(t,e){super(t,{...e,name:"helia:trustless-gateway:session"}),this.routing=t.routing,this.allowInsecure=e.allowInsecure??se,this.allowLocal=e.allowLocal??ie,this.transformRequestInit=e.transformRequestInit}async queryProvider(t,e,n){this.log("fetching BLOCK for %c from %s",t,e.url),n?.onProgress?.(new U("helia:block-brokers:query-provider:start",{blockBroker:"trustless-gateway",provider:e.url,transport:"http",cid:t}));let o;try{o=await e.getRawBlock(t,n),this.log.trace("got block for %c from %s",t,e.url)}finally{n?.onProgress?.(new U("helia:block-brokers:query-provider:end",{blockBroker:"trustless-gateway",provider:e.url,transport:"http",cid:t}))}return await n.validateFn?.(o),o}async*findNewProviders(t,e={}){yield*Ke(t,this.routing,this.logger,this.allowInsecure,this.allowLocal,{...e,transformRequestInit:this.transformRequestInit})}toFilterKey(t){return t.url.toString()}equals(t,e){return t.url.toString()===e.url.toString()}async convertToProvider(t,e,n){if(n?.signal?.throwIfAborted(),pn(t))return;let o=vn(Array.isArray(t)?t:[t],this.allowInsecure,this.allowLocal);if(o.length===0)return;let s=We(o[0]);return new Mt(s,{logger:this.logger,transformRequestInit:this.transformRequestInit,routing:e})}emitFoundProviderProgressEvent(t,e,n){n?.onProgress?.(new U("trustless-gateway:found-provider",{type:"trustless-gateway",cid:t,url:e.url.toJSON(),routing:e.routing}))}};function ns(r,t){return new Cn(r,t)}var Ge=class{name="trustless-gateway";allowInsecure;allowLocal;transformRequestInit;routing;log;logger;constructor(t,e={}){this.log=t.logger.forComponent("helia:trustless-gateway-block-broker"),this.logger=t.logger,this.routing=t.routing,this.allowInsecure=e.allowInsecure??se,this.allowLocal=e.allowLocal??ie,this.transformRequestInit=e.transformRequestInit}async retrieve(t,e={}){let n=[];for await(let o of Ke(t,this.routing,this.logger,this.allowInsecure,this.allowLocal,{...e,transformRequestInit:this.transformRequestInit})){this.log("getting block for %c from %s",t,o.url);try{let s=await o.getRawBlock(t,e);this.log.trace("got block for %c from %s",t,o.url);try{await e.validateFn?.(s)}catch(i){this.log.error("failed to validate block for %c from %s - %e",t,o.url,i);continue}return s}catch(s){if(this.log.error("failed to get block for %c from %s - %e",t,o.url,s),s instanceof Error?n.push(s):n.push(new Error(`Unable to fetch raw block for CID ${t} from gateway ${o.url}`)),e.signal?.aborted===!0){this.log.trace("request aborted while fetching raw block for CID %c from gateway %s",t,o.url);break}}}throw n.length>0?new AggregateError(n,`Unable to fetch raw block for CID ${t} from any gateway`):new Error(`Unable to fetch raw block for CID ${t} from any gateway`)}createSession(t={}){return ns({logger:this.logger,routing:this.routing},{...t,allowLocal:this.allowLocal,allowInsecure:this.allowInsecure,transformRequestInit:this.transformRequestInit})}};var se=!1,ie=!1,_n=2097152;function Cc(r={}){return t=>new Ge(t,r)}return us(Ic);})();
20
+ `,u.status,u.statusText,[...u.headers.entries()].map(([L,O])=>`${L}: ${O}`).join(`
21
+ `)),!u.ok)throw this.#t++,new Error(`Unable to fetch raw block for CID ${e} from gateway ${this.url}, received ${u.status} ${u.statusText}`);t.onProgress?.(new W("helia:block-broker:connected",{broker:"trustless-gateway",type:"connected",provider:this.peer,address:Oo(n.toString()),cid:e})),t.onProgress?.(new W("helia:block-broker:request-block",{broker:"trustless-gateway",type:"request-block",provider:this.peer,cid:e}));let p=await Fo(u,o,{signal:i.signal,log:this.log});return t.onProgress?.(new W("helia:block-broker:receive-block",{broker:"trustless-gateway",type:"receive-block",provider:this.peer,cid:e})),this.#o++,p}),this.#n.set(s,c)}return await c}catch(c){throw t.signal?.aborted===!0?new Error(`Fetching raw block for CID ${e} from gateway ${this.url} was aborted`):(this.#t++,new Error(`Unable to fetch raw block for CID ${e} - ${c.message}`))}finally{t.signal?.removeEventListener("abort",a),this.#n.delete(s)}}reliability(){return this.#e===0?1:this.#r>0?-1/0:this.#o/(this.#e+this.#t*3)}incrementInvalidBlocks(){this.#r++}getStats(){return{attempts:this.#e,errors:this.#t,invalidBlocks:this.#r,successes:this.#o,pendingResponses:this.#n.size}}toString(){return`TrustlessGateway(${this.url})`}};var fn=class extends Nt{name="trustless-gateway-session";routing;allowInsecure;allowLocal;transformRequestInit;constructor(e,t){super(e,{...t,name:"helia:trustless-gateway:session"}),this.routing=e.routing,this.allowInsecure=t.allowInsecure??Je,this.allowLocal=t.allowLocal??Ye,this.transformRequestInit=t.transformRequestInit}async queryProvider(e,t,n){this.log("fetching BLOCK for %c from %s",e,t.url),n?.onProgress?.(new W("helia:block-brokers:query-provider:start",{blockBroker:"trustless-gateway",provider:t.url,transport:"http",cid:e}));let o;try{o=await t.getRawBlock(e,n),this.log.trace("got block for %c from %s",e,t.url)}finally{n?.onProgress?.(new W("helia:block-brokers:query-provider:end",{blockBroker:"trustless-gateway",provider:t.url,transport:"http",cid:e}))}return await n.validateFn?.(o),o}async*findNewProviders(e,t={}){yield*Rt(e,this.routing,this.logger,this.allowInsecure,this.allowLocal,{...t,transformRequestInit:this.transformRequestInit})}toFilterKey(e){return e.url.toString()}equals(e,t){return e.url.toString()===t.url.toString()}async convertToProvider(e,t,n){if(n?.signal?.throwIfAborted(),Eo(e))return;let o=un(Array.isArray(e)?e:[e],this.allowInsecure,this.allowLocal);if(o.length===0)return;let s=Ut(o[0]);return new Fe(s,{logger:this.logger,transformRequestInit:this.transformRequestInit,routing:t})}emitFoundProviderProgressEvent(e,t,n){n?.onProgress?.(new W("trustless-gateway:found-provider",{type:"trustless-gateway",cid:e,url:t.url.toJSON(),routing:t.routing}))}};function No(r,e){return new fn(r,e)}var zt=class{name="trustless-gateway";allowInsecure;allowLocal;transformRequestInit;routing;log;logger;constructor(e,t={}){this.log=e.logger.forComponent("helia:trustless-gateway-block-broker"),this.logger=e.logger,this.routing=e.routing,this.allowInsecure=t.allowInsecure??Je,this.allowLocal=t.allowLocal??Ye,this.transformRequestInit=t.transformRequestInit}async retrieve(e,t={}){let n=[];for await(let o of Rt(e,this.routing,this.logger,this.allowInsecure,this.allowLocal,{...t,transformRequestInit:this.transformRequestInit})){this.log("getting block for %c from %s",e,o.url);try{let s=await o.getRawBlock(e,t);this.log.trace("got block for %c from %s",e,o.url);try{await t.validateFn?.(s)}catch(i){this.log.error("failed to validate block for %c from %s - %e",e,o.url,i);continue}return s}catch(s){if(this.log.error("failed to get block for %c from %s - %e",e,o.url,s),s instanceof Error?n.push(s):n.push(new Error(`Unable to fetch raw block for CID ${e} from gateway ${o.url}`)),t.signal?.aborted===!0){this.log.trace("request aborted while fetching raw block for CID %c from gateway %s",e,o.url);break}}}throw n.length>0?new AggregateError(n,`Unable to fetch raw block for CID ${e} from any gateway`):new Error(`Unable to fetch raw block for CID ${e} from any gateway`)}createSession(e={}){return No({logger:this.logger,routing:this.routing},{...e,allowLocal:this.allowLocal,allowInsecure:this.allowInsecure,transformRequestInit:this.transformRequestInit})}};var Je=!1,Ye=!1,ln=2097152;function Aa(r={}){return e=>new zt(e,r)}return Vo(Ta);})();
32
22
  return HeliaTrustlessGatewayClient}));
33
23
  //# sourceMappingURL=index.min.js.map