@libp2p/dcutr 1.0.5-230afea4b → 1.0.5-28587d24f

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/README.md CHANGED
@@ -17,7 +17,7 @@ at precisely the same moment.
17
17
 
18
18
  ## Example
19
19
 
20
- ```ts
20
+ ```TypeScript
21
21
  import { createLibp2p } from 'libp2p'
22
22
  import { circuitRelayTransport } from 'libp2p/circuit-relay'
23
23
  import { tcp } from '@libp2p/tcp'
package/dist/index.min.js CHANGED
@@ -1,14 +1,14 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDcutr = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PDcutr=(()=>{var go=Object.create;var Mt=Object.defineProperty;var wo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var xo=Object.getPrototypeOf,yo=Object.prototype.hasOwnProperty;var he=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),$=(r,t)=>{for(var e in t)Mt(r,e,{get:t[e],enumerable:!0})},Dr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bo(t))!yo.call(r,o)&&o!==e&&Mt(r,o,{get:()=>t[o],enumerable:!(n=wo(t,o))||n.enumerable});return r};var de=(r,t,e)=>(e=r!=null?go(xo(r)):{},Dr(t||!r||!r.__esModule?Mt(e,"default",{value:r,enumerable:!0}):e,r)),Io=r=>Dr(Mt({},"__esModule",{value:!0}),r);var Dn=he((Au,Un)=>{"use strict";function Nn(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function is(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return Nn(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Nn(new o,e)}}Un.exports=is});var no=he(Bt=>{(function(){var r,t,e,n,o,i,a,f;f=function(d){var h,b,w,p;return h=(d&255<<24)>>>24,b=(d&255<<16)>>>16,w=(d&65280)>>>8,p=d&255,[h,b,w,p].join(".")},a=function(d){var h,b,w,p,s,c;for(h=[],w=p=0;p<=3&&d.length!==0;w=++p){if(w>0){if(d[0]!==".")throw new Error("Invalid IP");d=d.substring(1)}c=t(d),s=c[0],b=c[1],d=d.substring(b),h.push(s)}if(d.length!==0)throw new Error("Invalid IP");switch(h.length){case 1:if(h[0]>4294967295)throw new Error("Invalid IP");return h[0]>>>0;case 2:if(h[0]>255||h[1]>16777215)throw new Error("Invalid IP");return(h[0]<<24|h[1])>>>0;case 3:if(h[0]>255||h[1]>255||h[2]>65535)throw new Error("Invalid IP");return(h[0]<<24|h[1]<<16|h[2])>>>0;case 4:if(h[0]>255||h[1]>255||h[2]>255||h[3]>255)throw new Error("Invalid IP");return(h[0]<<24|h[1]<<16|h[2]<<8|h[3])>>>0;default:throw new Error("Invalid IP")}},e=function(d){return d.charCodeAt(0)},n=e("0"),i=e("a"),o=e("A"),t=function(d){var h,b,w,p,s;for(p=0,h=10,b="9",w=0,d.length>1&&d[w]==="0"&&(d[w+1]==="x"||d[w+1]==="X"?(w+=2,h=16):"0"<=d[w+1]&&d[w+1]<="9"&&(w++,h=8,b="7")),s=w;w<d.length;){if("0"<=d[w]&&d[w]<=b)p=p*h+(e(d[w])-n)>>>0;else if(h===16)if("a"<=d[w]&&d[w]<="f")p=p*h+(10+e(d[w])-i)>>>0;else if("A"<=d[w]&&d[w]<="F")p=p*h+(10+e(d[w])-o)>>>0;else break;else break;if(p>4294967295)throw new Error("too large");w++}if(w===s)throw new Error("empty octet");return[p,w]},r=function(){function d(h,b){var w,p,s,c;if(typeof h!="string")throw new Error("Missing `net' parameter");if(b||(c=h.split("/",2),h=c[0],b=c[1]),b||(b=32),typeof b=="string"&&b.indexOf(".")>-1){try{this.maskLong=a(b)}catch(l){throw w=l,new Error("Invalid mask: "+b)}for(p=s=32;s>=0;p=--s)if(this.maskLong===4294967295<<32-p>>>0){this.bitmask=p;break}}else if(b||b===0)this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(a(h)&this.maskLong)>>>0}catch(l){throw w=l,new Error("Invalid net address: "+h)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=f(this.netLong),this.mask=f(this.maskLong),this.hostmask=f(~this.maskLong),this.first=this.bitmask<=30?f(this.netLong+1):this.base,this.last=this.bitmask<=30?f(this.netLong+this.size-2):f(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?f(this.netLong+this.size-1):void 0}return d.prototype.contains=function(h){return typeof h=="string"&&(h.indexOf("/")>0||h.split(".").length!==4)&&(h=new d(h)),h instanceof d?this.contains(h.base)&&this.contains(h.broadcast||h.last):(a(h)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},d.prototype.next=function(h){return h==null&&(h=1),new d(f(this.netLong+this.size*h),this.mask)},d.prototype.forEach=function(h){var b,w,p;for(p=a(this.first),w=a(this.last),b=0;p<=w;)h(f(p),p,b),b++,p++},d.prototype.toString=function(){return this.base+"/"+this.bitmask},d}(),Bt.ip2long=a,Bt.long2ip=f,Bt.Netmask=r}).call(Bt)});var ao=he((so,fe)=>{(function(r){"use strict";let t="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},n=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),i="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",f={zoneIndex:new RegExp(i,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${i})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${i})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${t}\\.${t}\\.${t}\\.${t}(${i})?$`,"i")};function d(s,c){if(s.indexOf("::")!==s.lastIndexOf("::"))return null;let l=0,u=-1,m=(s.match(f.zoneIndex)||[])[0],g,x;for(m&&(m=m.substring(1),s=s.replace(/%.+$/,""));(u=s.indexOf(":",u+1))>=0;)l++;if(s.substr(0,2)==="::"&&l--,s.substr(-2,2)==="::"&&l--,l>c)return null;for(x=c-l,g=":";x--;)g+="0:";return s=s.replace("::",g),s[0]===":"&&(s=s.slice(1)),s[s.length-1]===":"&&(s=s.slice(0,-1)),c=function(){let T=s.split(":"),C=[];for(let B=0;B<T.length;B++)C.push(parseInt(T[B],16));return C}(),{parts:c,zoneId:m}}function h(s,c,l,u){if(s.length!==c.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let m=0,g;for(;u>0;){if(g=l-u,g<0&&(g=0),s[m]>>g!==c[m]>>g)return!1;u-=l,m+=1}return!0}function b(s){if(o.test(s))return parseInt(s,16);if(s[0]==="0"&&!isNaN(parseInt(s[1],10))){if(n.test(s))return parseInt(s,8);throw new Error(`ipaddr: cannot parse ${s} as octal`)}return parseInt(s,10)}function w(s,c){for(;s.length<c;)s=`0${s}`;return s}let p={};p.IPv4=function(){function s(c){if(c.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let l,u;for(l=0;l<c.length;l++)if(u=c[l],!(0<=u&&u<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=c}return s.prototype.SpecialRanges={unspecified:[[new s([0,0,0,0]),8]],broadcast:[[new s([255,255,255,255]),32]],multicast:[[new s([224,0,0,0]),4]],linkLocal:[[new s([169,254,0,0]),16]],loopback:[[new s([127,0,0,0]),8]],carrierGradeNat:[[new s([100,64,0,0]),10]],private:[[new s([10,0,0,0]),8],[new s([172,16,0,0]),12],[new s([192,168,0,0]),16]],reserved:[[new s([192,0,0,0]),24],[new s([192,0,2,0]),24],[new s([192,88,99,0]),24],[new s([198,18,0,0]),15],[new s([198,51,100,0]),24],[new s([203,0,113,0]),24],[new s([240,0,0,0]),4]]},s.prototype.kind=function(){return"ipv4"},s.prototype.match=function(c,l){let u;if(l===void 0&&(u=c,c=u[0],l=u[1]),c.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return h(this.octets,c.octets,8,l)},s.prototype.prefixLengthFromSubnetMask=function(){let c=0,l=!1,u={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},m,g,x;for(m=3;m>=0;m-=1)if(g=this.octets[m],g in u){if(x=u[g],l&&x!==0)return null;x!==8&&(l=!0),c+=x}else return null;return 32-c},s.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){return this.octets.slice(0)},s.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},s.prototype.toNormalizedString=function(){return this.toString()},s.prototype.toString=function(){return this.octets.join(".")},s}(),p.IPv4.broadcastAddressFromCIDR=function(s){try{let c=this.parseCIDR(s),l=c[0].toByteArray(),u=this.subnetMaskFromPrefixLength(c[1]).toByteArray(),m=[],g=0;for(;g<4;)m.push(parseInt(l[g],10)|parseInt(u[g],10)^255),g++;return new this(m)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},p.IPv4.isIPv4=function(s){return this.parser(s)!==null},p.IPv4.isValid=function(s){try{return new this(this.parser(s)),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(s){return!!(p.IPv4.isValid(s)&&s.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.networkAddressFromCIDR=function(s){let c,l,u,m,g;try{for(c=this.parseCIDR(s),u=c[0].toByteArray(),g=this.subnetMaskFromPrefixLength(c[1]).toByteArray(),m=[],l=0;l<4;)m.push(parseInt(u[l],10)&parseInt(g[l],10)),l++;return new this(m)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},p.IPv4.parse=function(s){let c=this.parser(s);if(c===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(c)},p.IPv4.parseCIDR=function(s){let c;if(c=s.match(/^(.+)\/(\d+)$/)){let l=parseInt(c[2]);if(l>=0&&l<=32){let u=[this.parse(c[1]),l];return Object.defineProperty(u,"toString",{value:function(){return this.join("/")}}),u}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},p.IPv4.parser=function(s){let c,l,u;if(c=s.match(e.fourOctet))return function(){let m=c.slice(1,6),g=[];for(let x=0;x<m.length;x++)l=m[x],g.push(b(l));return g}();if(c=s.match(e.longValue)){if(u=b(c[1]),u>4294967295||u<0)throw new Error("ipaddr: address outside defined range");return function(){let m=[],g;for(g=0;g<=24;g+=8)m.push(u>>g&255);return m}().reverse()}else return(c=s.match(e.twoOctet))?function(){let m=c.slice(1,4),g=[];if(u=b(m[1]),u>16777215||u<0)throw new Error("ipaddr: address outside defined range");return g.push(b(m[0])),g.push(u>>16&255),g.push(u>>8&255),g.push(u&255),g}():(c=s.match(e.threeOctet))?function(){let m=c.slice(1,5),g=[];if(u=b(m[2]),u>65535||u<0)throw new Error("ipaddr: address outside defined range");return g.push(b(m[0])),g.push(b(m[1])),g.push(u>>8&255),g.push(u&255),g}():null},p.IPv4.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>32)throw new Error("ipaddr: invalid IPv4 prefix length");let c=[0,0,0,0],l=0,u=Math.floor(s/8);for(;l<u;)c[l]=255,l++;return u<4&&(c[u]=Math.pow(2,s%8)-1<<8-s%8),new this(c)},p.IPv6=function(){function s(c,l){let u,m;if(c.length===16)for(this.parts=[],u=0;u<=14;u+=2)this.parts.push(c[u]<<8|c[u+1]);else if(c.length===8)this.parts=c;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(u=0;u<this.parts.length;u++)if(m=this.parts[u],!(0<=m&&m<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");l&&(this.zoneId=l)}return s.prototype.SpecialRanges={unspecified:[new s([0,0,0,0,0,0,0,0]),128],linkLocal:[new s([65152,0,0,0,0,0,0,0]),10],multicast:[new s([65280,0,0,0,0,0,0,0]),8],loopback:[new s([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new s([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new s([0,0,0,0,0,65535,0,0]),96],rfc6145:[new s([0,0,0,0,65535,0,0,0]),96],rfc6052:[new s([100,65435,0,0,0,0,0,0]),96],"6to4":[new s([8194,0,0,0,0,0,0,0]),16],teredo:[new s([8193,0,0,0,0,0,0,0]),32],reserved:[[new s([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new s([8193,2,0,0,0,0,0,0]),48],amt:[new s([8193,3,0,0,0,0,0,0]),32],as112v6:[new s([8193,4,274,0,0,0,0,0]),48],deprecated:[new s([8193,16,0,0,0,0,0,0]),28],orchid2:[new s([8193,32,0,0,0,0,0,0]),28]},s.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},s.prototype.kind=function(){return"ipv6"},s.prototype.match=function(c,l){let u;if(l===void 0&&(u=c,c=u[0],l=u[1]),c.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return h(this.parts,c.parts,16,l)},s.prototype.prefixLengthFromSubnetMask=function(){let c=0,l=!1,u={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},m,g;for(let x=7;x>=0;x-=1)if(m=this.parts[x],m in u){if(g=u[m],l&&g!==0)return null;g!==16&&(l=!0),c+=g}else return null;return 128-c},s.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){let c,l=[],u=this.parts;for(let m=0;m<u.length;m++)c=u[m],l.push(c>>8),l.push(c&255);return l},s.prototype.toFixedLengthString=function(){let c=function(){let u=[];for(let m=0;m<this.parts.length;m++)u.push(w(this.parts[m].toString(16),4));return u}.call(this).join(":"),l="";return this.zoneId&&(l=`%${this.zoneId}`),c+l},s.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let c=this.parts.slice(-2),l=c[0],u=c[1];return new p.IPv4([l>>8,l&255,u>>8,u&255])},s.prototype.toNormalizedString=function(){let c=function(){let u=[];for(let m=0;m<this.parts.length;m++)u.push(this.parts[m].toString(16));return u}.call(this).join(":"),l="";return this.zoneId&&(l=`%${this.zoneId}`),c+l},s.prototype.toRFC5952String=function(){let c=/((^|:)(0(:|$)){2,})/g,l=this.toNormalizedString(),u=0,m=-1,g;for(;g=c.exec(l);)g[0].length>m&&(u=g.index,m=g[0].length);return m<0?l:`${l.substring(0,u)}::${l.substring(u+m)}`},s.prototype.toString=function(){return this.toRFC5952String()},s}(),p.IPv6.broadcastAddressFromCIDR=function(s){try{let c=this.parseCIDR(s),l=c[0].toByteArray(),u=this.subnetMaskFromPrefixLength(c[1]).toByteArray(),m=[],g=0;for(;g<16;)m.push(parseInt(l[g],10)|parseInt(u[g],10)^255),g++;return new this(m)}catch(c){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${c})`)}},p.IPv6.isIPv6=function(s){return this.parser(s)!==null},p.IPv6.isValid=function(s){if(typeof s=="string"&&s.indexOf(":")===-1)return!1;try{let c=this.parser(s);return new this(c.parts,c.zoneId),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(s){let c,l,u,m,g;try{for(c=this.parseCIDR(s),u=c[0].toByteArray(),g=this.subnetMaskFromPrefixLength(c[1]).toByteArray(),m=[],l=0;l<16;)m.push(parseInt(u[l],10)&parseInt(g[l],10)),l++;return new this(m)}catch(x){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${x})`)}},p.IPv6.parse=function(s){let c=this.parser(s);if(c.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(c.parts,c.zoneId)},p.IPv6.parseCIDR=function(s){let c,l,u;if((l=s.match(/^(.+)\/(\d+)$/))&&(c=parseInt(l[2]),c>=0&&c<=128))return u=[this.parse(l[1]),c],Object.defineProperty(u,"toString",{value:function(){return this.join("/")}}),u;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},p.IPv6.parser=function(s){let c,l,u,m,g,x;if(u=s.match(f.deprecatedTransitional))return this.parser(`::ffff:${u[1]}`);if(f.native.test(s))return d(s,8);if((u=s.match(f.transitional))&&(x=u[6]||"",c=d(u[1].slice(0,-1)+x,6),c.parts)){for(g=[parseInt(u[2]),parseInt(u[3]),parseInt(u[4]),parseInt(u[5])],l=0;l<g.length;l++)if(m=g[l],!(0<=m&&m<=255))return null;return c.parts.push(g[0]<<8|g[1]),c.parts.push(g[2]<<8|g[3]),{parts:c.parts,zoneId:c.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>128)throw new Error("ipaddr: invalid IPv6 prefix length");let c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],l=0,u=Math.floor(s/8);for(;l<u;)c[l]=255,l++;return u<16&&(c[u]=Math.pow(2,s%8)-1<<8-s%8),new this(c)},p.fromByteArray=function(s){let c=s.length;if(c===4)return new p.IPv4(s);if(c===16)return new p.IPv6(s);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},p.isValid=function(s){return p.IPv6.isValid(s)||p.IPv4.isValid(s)},p.parse=function(s){if(p.IPv6.isValid(s))return p.IPv6.parse(s);if(p.IPv4.isValid(s))return p.IPv4.parse(s);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},p.parseCIDR=function(s){try{return p.IPv6.parseCIDR(s)}catch{try{return p.IPv4.parseCIDR(s)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},p.process=function(s){let c=this.parse(s);return c.kind()==="ipv6"&&c.isIPv4MappedAddress()?c.toIPv4Address():c},p.subnetMatch=function(s,c,l){let u,m,g,x;l==null&&(l="unicast");for(m in c)if(Object.prototype.hasOwnProperty.call(c,m)){for(g=c[m],g[0]&&!(g[0]instanceof Array)&&(g=[g]),u=0;u<g.length;u++)if(x=g[u],s.kind()===x[0].kind()&&s.match.apply(s,x))return m}return l},typeof fe<"u"&&fe.exports?fe.exports=p:r.ipaddr=p})(so)});var Fs={};$(Fs,{dcutr:()=>Ts,multicodec:()=>At});var Cs=Symbol.for("@libp2p/connection");var Bs=Symbol.for("@libp2p/content-routing");var Os=Symbol.for("@libp2p/peer-discovery");var Vs=Symbol.for("@libp2p/peer-id");var js=Symbol.for("@libp2p/peer-routing");var Tr;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Tr||(Tr={}));var Xs=Symbol.for("@libp2p/transport");var Fr;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Fr||(Fr={}));var _=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ot="ERR_INVALID_MESSAGE";var pe=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Js=globalThis.CustomEvent??pe;var xe={};$(xe,{base58btc:()=>P,base58flickr:()=>Po});function Ao(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 i=r.charAt(o),a=i.charCodeAt(0);if(e[a]!==255)throw new TypeError(i+" is ambiguous");e[a]=o}var f=r.length,d=r.charAt(0),h=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function w(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var l=0,u=0,m=0,g=c.length;m!==g&&c[m]===0;)m++,l++;for(var x=(g-m)*b+1>>>0,T=new Uint8Array(x);m!==g;){for(var C=c[m],B=0,O=x-1;(C!==0||B<u)&&O!==-1;O--,B++)C+=256*T[O]>>>0,T[O]=C%f>>>0,C=C/f>>>0;if(C!==0)throw new Error("Non-zero carry");u=B,m++}for(var X=x-u;X!==x&&T[X]===0;)X++;for(var kt=d.repeat(l);X<x;++X)kt+=r.charAt(T[X]);return kt}function p(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var l=0;if(c[l]!==" "){for(var u=0,m=0;c[l]===d;)u++,l++;for(var g=(c.length-l)*h+1>>>0,x=new Uint8Array(g);c[l];){var T=e[c.charCodeAt(l)];if(T===255)return;for(var C=0,B=g-1;(T!==0||C<m)&&B!==-1;B--,C++)T+=f*x[B]>>>0,x[B]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");m=C,l++}if(c[l]!==" "){for(var O=g-m;O!==g&&x[O]===0;)O++;for(var X=new Uint8Array(u+(g-O)),kt=u;O!==g;)X[kt++]=x[O++];return X}}}function s(c){var l=p(c);if(l)return l;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:p,decode:s}}var Eo=Ao,vo=Eo,Rr=vo;var Pa=new Uint8Array(0);var Cr=(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},H=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var $r=r=>new TextEncoder().encode(r),Br=r=>new TextDecoder().decode(r);var me=class{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")}},ge=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),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 Mr(this,t)}},we=class{constructor(t){this.decoders=t}or(t){return Mr(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Mr=(r,t)=>new we({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),be=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new me(t,e,n),this.decoder=new ge(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ut=({name:r,prefix:t,encode:e,decode:n})=>new be(r,t,e,n),Z=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Rr(e,t);return ut({prefix:r,name:t,encode:n,decode:i=>H(o(i))})},So=(r,t,e,n)=>{let o={};for(let b=0;b<t.length;++b)o[t[b]]=b;let i=r.length;for(;r[i-1]==="=";)--i;let a=new Uint8Array(i*e/8|0),f=0,d=0,h=0;for(let b=0;b<i;++b){let w=o[r[b]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<e|w,f+=e,f>=8&&(f-=8,a[h++]=255&d>>f)}if(f>=e||255&d<<8-f)throw new SyntaxError("Unexpected end of data");return a},Lo=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",a=0,f=0;for(let d=0;d<r.length;++d)for(f=f<<8|r[d],a+=8;a>e;)a-=e,i+=t[o&f>>a];if(a&&(i+=t[o&f<<e-a]),n)for(;i.length*e&7;)i+="=";return i},A=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>ut({prefix:t,name:r,encode(o){return Lo(o,n,e)},decode(o){return So(o,n,e,r)}});var P=Z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Po=Z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ye={};$(ye,{base32:()=>Q,base32hex:()=>To,base32hexpad:()=>Ro,base32hexpadupper:()=>Co,base32hexupper:()=>Fo,base32pad:()=>Uo,base32padupper:()=>Do,base32upper:()=>No,base32z:()=>$o});var Q=A({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),No=A({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Uo=A({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Do=A({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),To=A({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fo=A({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ro=A({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Co=A({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),$o=A({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bo=Vr,Or=128,ko=127,Mo=~ko,Oo=Math.pow(2,31);function Vr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Oo;)t[e++]=r&255|Or,r/=128;for(;r&Mo;)t[e++]=r&255|Or,r>>>=7;return t[e]=r|0,Vr.bytes=e-n+1,t}var _o=Ie,Vo=128,_r=127;function Ie(r,n){var e=0,n=n||0,o=0,i=n,a,f=r.length;do{if(i>=f)throw Ie.bytes=0,new RangeError("Could not decode varint");a=r[i++],e+=o<28?(a&_r)<<o:(a&_r)*Math.pow(2,o),o+=7}while(a>=Vo);return Ie.bytes=i-n,e}var zo=Math.pow(2,7),jo=Math.pow(2,14),Go=Math.pow(2,21),Wo=Math.pow(2,28),qo=Math.pow(2,35),Xo=Math.pow(2,42),Ho=Math.pow(2,49),Qo=Math.pow(2,56),Jo=Math.pow(2,63),Ko=function(r){return r<zo?1:r<jo?2:r<Go?3:r<Wo?4:r<qo?5:r<Xo?6:r<Ho?7:r<Qo?8:r<Jo?9:10},Zo={encode:Bo,decode:_o,encodingLength:Ko},Yo=Zo,Et=Yo;var vt=(r,t=0)=>[Et.decode(r,t),Et.decode.bytes],lt=(r,t,e=0)=>(Et.encode(r,t,e),t),ht=r=>Et.encodingLength(r);var it=(r,t)=>{let e=t.byteLength,n=ht(r),o=n+ht(e),i=new Uint8Array(o+e);return lt(r,i,0),lt(e,i,n),i.set(t,o),new dt(r,e,t,i)},_t=r=>{let t=H(r),[e,n]=vt(t),[o,i]=vt(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new dt(e,o,a,t)},zr=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Cr(r.bytes,e.bytes)}},dt=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var jr=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return ei(e,Ae(r),t||P.encoder);default:return ri(e,Ae(r),t||Q.encoder)}};var Gr=new WeakMap,Ae=r=>{let t=Gr.get(r);if(t==null){let e=new Map;return Gr.set(r,e),e}return t},Y=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}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!==St)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ni)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=it(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&&t.code===n.code&&t.version===n.version&&zr(t.multihash,n.multihash)}toString(t){return jr(this,t)}toJSON(){return{"/":jr(this)}}link(){return this}get[Symbol.toStringTag](){return"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:i,bytes:a}=e;return new r(n,o,i,a||Wr(n,o,i.bytes))}else if(e[oi]===!0){let{version:n,multihash:o,code:i}=e,a=_t(o);return r.create(n,i,a)}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!==St)throw new Error(`Version 0 CID must use dag-pb (code: ${St}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Wr(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,St,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=H(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),a=new dt(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(a):r.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,p]=vt(t.subarray(e));return e+=p,w},o=n(),i=St;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=e,f=n(),d=n(),h=e+d,b=h-a;return{version:o,codec:i,multihashCode:f,digestSize:d,multihashSize:b,size:h}}static parse(t,e){let[n,o]=ti(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ae(i).set(n,t),i}},ti=(r,t)=>{switch(r[0]){case"Q":{let e=t||P;return[P.prefix,e.decode(`${P.prefix}${r}`)]}case P.prefix:{let e=t||P;return[P.prefix,e.decode(r)]}case Q.prefix:{let e=t||Q;return[Q.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},ei=(r,t,e)=>{let{prefix:n}=e;if(n!==P.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},ri=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},St=112,ni=18,Wr=(r,t,e)=>{let n=ht(r),o=n+ht(t),i=new Uint8Array(o+e.byteLength);return lt(r,i,0),lt(t,i,n),i.set(e,o),i},oi=Symbol.for("@ipld/js-cid/CID");function qr(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 Ee={};$(Ee,{base10:()=>ii});var ii=Z({prefix:"9",name:"base10",alphabet:"0123456789"});var ve={};$(ve,{base16:()=>si,base16upper:()=>ai});var si=A({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ai=A({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Se={};$(Se,{base2:()=>ci});var ci=A({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Le={};$(Le,{base256emoji:()=>di});var Xr=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}"),fi=Xr.reduce((r,t,e)=>(r[e]=t,r),[]),ui=Xr.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function li(r){return r.reduce((t,e)=>(t+=fi[e],t),"")}function hi(r){let t=[];for(let e of r){let n=ui[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var di=ut({prefix:"\u{1F680}",name:"base256emoji",encode:li,decode:hi});var Pe={};$(Pe,{base36:()=>pi,base36upper:()=>mi});var pi=Z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mi=Z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ue={};$(Ue,{base64:()=>gi,base64pad:()=>wi,base64url:()=>Ne,base64urlpad:()=>bi});var gi=A({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wi=A({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ne=A({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bi=A({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var De={};$(De,{base8:()=>xi});var xi=A({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Te={};$(Te,{identity:()=>yi});var yi=ut({prefix:"\0",name:"identity",encode:r=>Br(r),decode:r=>$r(r)});var Ka=new TextEncoder,Za=new TextDecoder;var Fe={};$(Fe,{identity:()=>Si});var Hr=0,Ei="identity",Qr=H,vi=r=>it(Hr,Qr(r)),Si={code:Hr,name:Ei,encode:Qr,digest:vi};var $e={};$($e,{sha256:()=>Li,sha512:()=>Pi});var Ce=({name:r,code:t,encode:e})=>new Re(r,t,e),Re=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?it(this.code,e):e.then(n=>it(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Kr=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),Li=Ce({name:"sha2-256",code:18,encode:Kr("SHA-256")}),Pi=Ce({name:"sha2-512",code:19,encode:Kr("SHA-512")});var tt={...Te,...Se,...De,...Ee,...ve,...ye,...Pe,...xe,...Ue,...Le},sc={...$e,...Fe};function mt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Vt(r=0){return globalThis.Buffer?.allocUnsafe!=null?mt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Yr(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Zr=Yr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Be=Yr("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=Vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ni={utf8:Zr,"utf-8":Zr,hex:tt.base16,latin1:Be,ascii:Be,binary:Be,...tt},zt=Ni;function F(r,t="utf8"){let e=zt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}function tn(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function en(r=0){return globalThis.Buffer?.allocUnsafe!=null?tn(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var Ui=Math.pow(2,7),Di=Math.pow(2,14),Ti=Math.pow(2,21),ke=Math.pow(2,28),Me=Math.pow(2,35),Oe=Math.pow(2,42),_e=Math.pow(2,49),y=128,N=127;function U(r){if(r<Ui)return 1;if(r<Di)return 2;if(r<Ti)return 3;if(r<ke)return 4;if(r<Me)return 5;if(r<Oe)return 6;if(r<_e)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Fi(r,t,e=0){switch(U(r)){case 8:t[e++]=r&255|y,r/=128;case 7:t[e++]=r&255|y,r/=128;case 6:t[e++]=r&255|y,r/=128;case 5:t[e++]=r&255|y,r/=128;case 4:t[e++]=r&255|y,r>>>=7;case 3:t[e++]=r&255|y,r>>>=7;case 2:t[e++]=r&255|y,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ri(r,t,e=0){switch(U(r)){case 8:t.set(e++,r&255|y),r/=128;case 7:t.set(e++,r&255|y),r/=128;case 6:t.set(e++,r&255|y),r/=128;case 5:t.set(e++,r&255|y),r/=128;case 4:t.set(e++,r&255|y),r>>>=7;case 3:t.set(e++,r&255|y),r>>>=7;case 2:t.set(e++,r&255|y),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Ci(r,t){let e=r[t],n=0;if(n+=e&N,e<y||(e=r[t+1],n+=(e&N)<<7,e<y)||(e=r[t+2],n+=(e&N)<<14,e<y)||(e=r[t+3],n+=(e&N)<<21,e<y)||(e=r[t+4],n+=(e&N)*ke,e<y)||(e=r[t+5],n+=(e&N)*Me,e<y)||(e=r[t+6],n+=(e&N)*Oe,e<y)||(e=r[t+7],n+=(e&N)*_e,e<y))return n;throw new RangeError("Could not decode varint")}function $i(r,t){let e=r.get(t),n=0;if(n+=e&N,e<y||(e=r.get(t+1),n+=(e&N)<<7,e<y)||(e=r.get(t+2),n+=(e&N)<<14,e<y)||(e=r.get(t+3),n+=(e&N)<<21,e<y)||(e=r.get(t+4),n+=(e&N)*ke,e<y)||(e=r.get(t+5),n+=(e&N)*Me,e<y)||(e=r.get(t+6),n+=(e&N)*Oe,e<y)||(e=r.get(t+7),n+=(e&N)*_e,e<y))return n;throw new RangeError("Could not decode varint")}function et(r,t,e=0){return t==null&&(t=en(U(r))),t instanceof Uint8Array?Fi(r,t,e):Ri(r,t,e)}function V(r,t=0){return r instanceof Uint8Array?Ci(r,t):$i(r,t)}function J(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Vt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return mt(e)}var jt=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 i=0,a=0,f=this.peekChar();if(f===void 0)return;let d=f==="0",h=2**(8*o)-1;for(;;){let b=this.readAtomically(()=>{let w=this.readChar();if(w===void 0)return;let p=Number.parseInt(w,t);if(!Number.isNaN(p))return p});if(b===void 0)break;if(i*=t,i+=b,i>h||(a+=1,e!==void 0&&a>e))return}if(a!==0)return!n&&d&&a>1?void 0:i})}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 a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return e[o]=a[0],e[o+1]=a[1],e[o+2]=a[2],e[o+3]=a[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&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 i=new Uint8Array(14),a=16-(n+2),[f]=t(i.subarray(0,a));return e.set(i.subarray(0,f),16-f),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var rn=45,Bi=15,gt=new jt;function Ve(r){if(!(r.length>Bi))return gt.new(r).parseWith(()=>gt.readIPv4Addr())}function ze(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>rn))return gt.new(r).parseWith(()=>gt.readIPv6Addr())}function Gt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>rn))return gt.new(r).parseWith(()=>gt.readIPAddr())}var Fc=parseInt("0xFFFF",16),Rc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function je(r,t="utf8"){let e=zt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?mt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Wt(r){return!!Ve(r)}function qt(r){return!!ze(r)}function wt(r){return!!Gt(r)}var sn=Wt,Vi=qt,Ge=function(r){let t=0;if(r=r.toString().trim(),sn(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Vi(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=sn(e[n]),a;i&&(a=Ge(e[n]),e[n]=F(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,F(a.slice(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 i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},an=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var bt={},We={},ji=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];ji.forEach(r=>{let t=Gi(...r);We[t.code]=t,bt[t.name]=t});function Gi(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function I(r){if(typeof r=="number"){if(We[r]!=null)return We[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(bt[r]!=null)return bt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var yf=I("ip4"),If=I("ip6"),Af=I("ipcidr");function Xe(r,t){switch(I(r).code){case 4:case 41:return qi(t);case 42:return un(t);case 6:case 273:case 33:case 132:return hn(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return un(t);case 421:return Ji(t);case 444:return ln(t);case 445:return ln(t);case 466:return Qi(t);default:return F(t,"base16")}}function He(r,t){switch(I(r).code){case 4:return cn(t);case 41:return cn(t);case 42:return fn(t);case 6:case 273:case 33:case 132:return Qe(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fn(t);case 421:return Xi(t);case 444:return Ki(t);case 445:return Zi(t);case 466:return Hi(t);default:return je(t,"base16")}}var qe=Object.values(tt).map(r=>r.decoder),Wi=function(){let r=qe[0].or(qe[1]);return qe.slice(2).forEach(t=>r=r.or(t)),r}();function cn(r){if(!wt(r))throw new Error("invalid ip address");return Ge(r)}function qi(r){let t=an(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!wt(t))throw new Error("invalid ip address");return t}function Qe(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function hn(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function fn(r){let t=je(r),e=Uint8Array.from(et(t.length));return J([e,t],e.length+t.length)}function un(r){let t=V(r);if(r=r.slice(U(t)),r.length!==t)throw new Error("inconsistent lengths");return F(r)}function Xi(r){let t;r[0]==="Q"||r[0]==="1"?t=_t(P.decode(`z${r}`)).bytes:t=Y.parse(r).multihash.bytes;let e=Uint8Array.from(et(t.length));return J([e,t],e.length+t.length)}function Hi(r){let t=Wi.decode(r),e=Uint8Array.from(et(t.length));return J([e,t],e.length+t.length)}function Qi(r){let t=V(r),e=r.slice(U(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+F(e,"base64url")}function Ji(r){let t=V(r),e=r.slice(U(t));if(e.length!==t)throw new Error("inconsistent lengths");return F(e,"base58btc")}function Ki(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=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=Qe(n);return J([e,o],e.length+o.length)}function Zi(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=Qe(n);return J([e,o],e.length+o.length)}function ln(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=F(t,"base32"),o=hn(e);return`${n}:${o}`}function dn(r){r=Je(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let a=o[i],f=I(a);if(f.size===0){t.push([f.code]),e.push([f.code]);continue}if(i++,i>=o.length)throw mn("invalid address: "+r);if(f.path===!0){n=Je(o.slice(i).join("/")),t.push([f.code,He(f.code,n)]),e.push([f.code,n]);break}let d=He(f.code,o[i]);t.push([f.code,d]),e.push([f.code,Xe(f.code,d)])}return{string:pn(e),bytes:Ze(t),tuples:t,stringTuples:e,path:n}}function Ke(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=V(r,o),a=U(i),f=I(i),d=Yi(f,r.slice(o+a));if(d===0){t.push([i]),e.push([i]),o+=a;continue}let h=r.slice(o+a,o+a+d);if(o+=d+a,o>r.length)throw mn("Invalid address Uint8Array: "+F(r,"base16"));t.push([i,h]);let b=Xe(i,h);if(e.push([i,b]),f.path===!0){n=b;break}}return{bytes:Uint8Array.from(r),string:pn(e),tuples:t,stringTuples:e,path:n}}function pn(r){let t=[];return r.map(e=>{let n=I(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Je(t.join("/"))}function Ze(r){return J(r.map(t=>{let e=I(t[0]),n=Uint8Array.from(et(e.code));return t.length>1&&t[1]!=null&&(n=J([n,t[1]])),n}))}function Yi(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=V(t instanceof Uint8Array?t:Uint8Array.from(t));return e+U(e)}}function Je(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function mn(r){return new Error("Error parsing address: "+r)}var ts=Symbol.for("nodejs.util.inspect.custom"),Ye=Symbol.for("@multiformats/js-multiaddr/multiaddr"),es=[I("dns").code,I("dns4").code,I("dns6").code,I("dnsaddr").code],Xt=class r{bytes;#e;#t;#r;#n;[Ye]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ke(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=dn(t)}else if(wn(t))e=Ke(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",a=I("tcp"),f=I("udp"),d=I("ip4"),h=I("ip6"),b=I("dns6"),w=I("ip6zone");for(let[s,c]of this.stringTuples())s===w.code&&(i=`%${c??""}`),es.includes(s)&&(e=a.name,o=443,n=`${c??""}${i}`,t=s===b.code?6:4),(s===a.code||s===f.code)&&(e=I(s).name,o=parseInt(c??"")),(s===d.code||s===h.code)&&(e=I(s).name,n=`${c??""}${i}`,t=s===h.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},I(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>I(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ze(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===bt.p2p.code&&t.push([n,o]),n===bt["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?F(P.decode(`z${n}`),"base58btc"):F(Y.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return qr(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=gn.get(e.name);if(n==null)throw new _(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>new r(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[ts](){return`Multiaddr(${this.#e})`}};var gn=new Map;function wn(r){return!!r?.[Ye]}function tr(r){return new Xt(r)}var bn=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},rs=new WeakMap;function ns({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(bn());let i,a,f,d=r??clearTimeout,h=()=>{d(i),f(bn())},b=()=>{o&&o.removeEventListener("abort",h)},w=new Promise((p,s)=>{a=()=>{b(),p(n)},f=s,i=(t??setTimeout)(a,e)});return o&&o.addEventListener("abort",h,{once:!0}),rs.set(w,()=>{d(i),i=null,a()}),w}}var os=ns(),xn=os;function Pt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function K(r=0){return globalThis.Buffer?.alloc!=null?Pt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Nt(r=0){return globalThis.Buffer?.allocUnsafe!=null?Pt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function er(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Nt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return Pt(e)}function yn(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 An=Symbol.for("@achingbrain/uint8arraylist");function In(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 Ht(r){return!!r?.[An]}var k=class r{bufs;length;[An]=!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(Ht(n))e+=n.byteLength,this.bufs.push(...n.bufs);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(Ht(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=In(this.bufs,t);return e.buf[e.index]}set(t,e){let n=In(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(Ht(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 er(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:er(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_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 i=0;i<this.bufs.length;i++){let a=this.bufs[i],f=o,d=f+a.byteLength;if(o=d,t>=d)continue;let h=t>=f&&t<d,b=e>f&&e<=d;if(h&&b){if(t===f&&e===d){n.push(a);break}let w=t-f;n.push(a.subarray(w,w+(e-t)));break}if(h){if(t===0){n.push(a);continue}n.push(a.subarray(t-f));continue}if(b){if(e===d){n.push(a);break}n.push(a.subarray(0,e-f));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Ht(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 i=256,a=new Int32Array(i);for(let w=0;w<i;w++)a[w]=-1;for(let w=0;w<o;w++)a[n[w]]=w;let f=a,d=this.byteLength-n.byteLength,h=n.byteLength-1,b;for(let w=e;w<=d;w+=b){b=0;for(let p=h;p>=0;p--){let s=this.get(w+p);if(n[p]!==s){b=Math.max(1,p-f[s]);break}}if(b===0)return w}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=Nt(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=K(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=K(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=K(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=Nt(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=K(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=K(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=K(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=K(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=K(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(!yn(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,i)=>o+i.byteLength,0)),n.length=e,n}};function xt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Qt=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=e??"ABORT_ERR"}};async function En(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Qt(e?.errorMessage,e?.errorCode));let n,o=new Qt(e?.errorMessage,e?.errorCode);try{return await Promise.race([r,new Promise((i,a)=>{n=()=>{a(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var rr=class{needNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.needNext=xt(),this.haveNext=xt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("Have next but next was undefined");let t=this.nextResult;return this.nextResult=void 0,this.needNext.resolve(),this.needNext=xt(),t}async throw(t){return this.ended=!0,t!=null&&this.haveNext.reject(t),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");this.nextResult!=null&&await this.needNext.promise,t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=xt(),await En(this.needNext.promise,e?.signal,e)}};function vn(){return new rr}var Jt=class extends Error{code;constructor(t,e){super(t),this.code=e}},nr=class extends Jt{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted"}};function Sn(r,t){let e=vn();r.sink(e).catch(async a=>{await e.end(a)}),r.sink=async a=>{for await(let f of a)await e.push(f);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new k;return{read:async(a,f)=>{f?.signal?.throwIfAborted();let d,h=new Promise((b,w)=>{d=()=>{w(new nr("Read aborted"))},f?.signal?.addEventListener("abort",d)});try{if(a==null){let{done:w,value:p}=await Promise.race([n.next(),h]);return w===!0?new k:p}for(;o.byteLength<a;){let{value:w,done:p}=await Promise.race([n.next(),h]);if(p===!0)throw new Jt("unexpected end of input","ERR_UNEXPECTED_EOF");o.append(w)}let b=o.sublist(0,a);return o.consume(a),b}finally{d!=null&&f?.signal?.removeEventListener("abort",d)}},write:async(a,f)=>{f?.signal?.throwIfAborted(),a instanceof Uint8Array?await e.push(a,f):await e.push(a.subarray(),f)},unwrap:()=>{if(o.byteLength>0){let a=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*a}()}return r}}}function Ln(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Pn(r=0){return globalThis.Buffer?.allocUnsafe!=null?Ln(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Kt(r){return r[Symbol.asyncIterator]!=null}var Zt=r=>{let t=U(r),e=Pn(t);return et(r,e),Zt.bytes=t,e};Zt.bytes=0;function Ut(r,t){t=t??{};let e=t.lengthEncoder??Zt;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return Kt(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Ut.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Zt;return new k(e(r.byteLength),r)};var yt=de(Dn(),1);var ss=8,as=1024*1024*4,st;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(st||(st={}));var ir=r=>{let t=V(r);return ir.bytes=U(t),t};ir.bytes=0;function or(r,t){let e=new k,n=st.LENGTH,o=-1,i=t?.lengthDecoder??ir,a=t?.maxLengthLength??ss,f=t?.maxDataLength??as;function*d(){for(;e.byteLength>0;){if(n===st.LENGTH)try{if(o=i(e),o<0)throw(0,yt.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>f)throw(0,yt.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let h=i.bytes;e.consume(h),t?.onLength!=null&&t.onLength(o),n=st.DATA}catch(h){if(h instanceof RangeError){if(e.byteLength>a)throw(0,yt.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw h}if(n===st.DATA){if(e.byteLength<o)break;let h=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(h),yield h,n=st.LENGTH}}}return Kt(r)?async function*(){for await(let h of r)e.append(h),yield*d();if(e.byteLength>0)throw(0,yt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let h of r)e.append(h),yield*d();if(e.byteLength>0)throw(0,yt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}or.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:a}=await r.next(e);if(i===!0)return;a!=null&&(yield a)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return or(n,{...t??{},onLength:i=>{e=i}})};var Yt=class extends Error{code;constructor(t,e){super(t),this.code=e}},Tn=r=>V(r);Tn.bytes=0;function Fn(r,t={}){let e=Sn(r,t);return t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=U(t.maxDataLength)),{read:async o=>{let i=-1,a=new k,f=t?.lengthDecoder??Tn;for(;;){a.append(await e.read(1,o));try{i=f(a)}catch(d){if(d instanceof RangeError)continue;throw d}if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new Yt("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(i>-1)break}if(t?.maxDataLength!=null&&i>t.maxDataLength)throw new Yt("message length too long","ERR_MSG_DATA_TOO_LONG");return e.read(i,o)},write:async(o,i)=>{await e.write(Ut.single(o,t),i)},writeV:async(o,i)=>{let a=new k(...o.map(f=>Ut.single(f,t)));await e.write(a,i)},unwrap:()=>e.unwrap()}}function sr(r,t){let e=Fn(r,t),n={read:async(o,i)=>{let a=await e.read(i);return o.decode(a)},write:async(o,i,a)=>{await e.write(i.encode(o),a)},writeV:async(o,i,a)=>{await e.writeV(o.map(f=>i.encode(f)),a)},pb:o=>({read:async i=>n.read(o,i),write:async(i,a)=>n.write(i,o,a),writeV:async(i,a)=>n.writeV(i,o,a),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var ar=new Float32Array([-0]),rt=new Uint8Array(ar.buffer);function Rn(r,t,e){ar[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3]}function Cn(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],ar[0]}var cr=new Float64Array([-0]),D=new Uint8Array(cr.buffer);function $n(r,t,e){cr[0]=r,t[e]=D[0],t[e+1]=D[1],t[e+2]=D[2],t[e+3]=D[3],t[e+4]=D[4],t[e+5]=D[5],t[e+6]=D[6],t[e+7]=D[7]}function Bn(r,t){return D[0]=r[t],D[1]=r[t+1],D[2]=r[t+2],D[3]=r[t+3],D[4]=r[t+4],D[5]=r[t+5],D[6]=r[t+6],D[7]=r[t+7],cr[0]}var fs=BigInt(Number.MAX_SAFE_INTEGER),us=BigInt(Number.MIN_SAFE_INTEGER),R=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return at;if(t<fs&&t>us)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>kn&&(o=0n,++n>kn&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return at;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):at}},at=new R(0,0);at.toBigInt=function(){return 0n};at.zzEncode=at.zzDecode=function(){return this};at.length=function(){return 1};var kn=4294967296n;function Mn(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function On(r,t,e){if(e-t<1)return"";let o,i=[],a=0,f;for(;t<e;)f=r[t++],f<128?i[a++]=f:f>191&&f<224?i[a++]=(f&31)<<6|r[t++]&63:f>239&&f<365?(f=((f&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[a++]=55296+(f>>10),i[a++]=56320+(f&1023)):i[a++]=(f&15)<<12|(r[t++]&63)<<6|r[t++]&63,a>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),a=0);return o!=null?(a>0&&o.push(String.fromCharCode.apply(String,i.slice(0,a))),o.join("")):String.fromCharCode.apply(String,i.slice(0,a))}function fr(r,t,e){let n=e,o,i;for(let a=0;a<r.length;++a)o=r.charCodeAt(a),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(a+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++a,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function z(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function te(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ur=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,z(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw z(this,4);return te(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw z(this,4);return te(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw z(this,4);let t=Cn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw z(this,4);let t=Bn(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw z(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return On(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw z(this,t);this.pos+=t}else do if(this.pos>=this.len)throw z(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new R(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw z(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw z(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw z(this,8);let t=te(this.buf,this.pos+=4),e=te(this.buf,this.pos+=4);return new R(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function lr(r){return new ur(r instanceof Uint8Array?r:r.subarray())}function hr(r,t){let e=lr(r);return t.decode(e)}function ee(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ct(r=0){return globalThis.Buffer?.allocUnsafe!=null?ee(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function zn(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Vn=zn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),dr=zn("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=ct(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ls={utf8:Vn,"utf-8":Vn,hex:tt.base16,latin1:dr,ascii:dr,binary:dr,...tt},jn=ls;function Gn(r,t="utf8"){let e=jn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ee(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function pr(r){let t=r??8192,e=t>>>1,n,o=t;return function(a){if(a<1||a>e)return ct(a);o+a>t&&(n=ct(t),o=0);let f=n.subarray(o,o+=a);return o&7&&(o=(o|7)+1),f}}var ft=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function mr(){}var wr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},hs=pr();function ds(r){return globalThis.Buffer!=null?ct(r):hs(r)}var Ft=class{len;head;tail;states;constructor(){this.len=0,this.head=new ft(mr,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ft(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new br((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Dt,10,R.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=R.fromBigInt(t);return this._push(Dt,e.length(),e)}uint64Number(t){let e=R.fromNumber(t);return this._push(Dt,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=R.fromBigInt(t).zzEncode();return this._push(Dt,e.length(),e)}sint64Number(t){let e=R.fromNumber(t).zzEncode();return this._push(Dt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(gr,1,t?1:0)}fixed32(t){return this._push(Tt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=R.fromBigInt(t);return this._push(Tt,4,e.lo)._push(Tt,4,e.hi)}fixed64Number(t){let e=R.fromNumber(t);return this._push(Tt,4,e.lo)._push(Tt,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Rn,4,t)}double(t){return this._push($n,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(gr,1,0):this.uint32(e)._push(ms,e,t)}string(t){let e=Mn(t);return e!==0?this.uint32(e)._push(fr,e,t):this._push(gr,1,0)}fork(){return this.states=new wr(this),this.head=this.tail=new ft(mr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ft(mr,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=ds(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function gr(r,t,e){t[e]=r&255}function ps(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var br=class extends ft{next;constructor(t,e){super(ps,t,e),this.next=void 0}};function Dt(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Tt(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ms(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ft.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(gs,t,r),this},Ft.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ws,t,r),this});function gs(r,t,e){t.set(r,e)}function ws(r,t,e){r.length<40?fr(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Gn(r),e)}function xr(){return new Ft}function yr(r,t){let e=xr();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var It;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(It||(It={}));function re(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Ir(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,a){let f=t(i);a.int32(f)},n=function(i){let a=i.int32();return t(a)};return re("enum",It.VARINT,e,n)}function Ar(r,t){return re("message",It.LENGTH_DELIMITED,r,t)}var j;(function(r){let t;(function(o){o.UNUSED="UNUSED",o.CONNECT="CONNECT",o.SYNC="SYNC"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNUSED=0]="UNUSED",o[o.CONNECT=100]="CONNECT",o[o.SYNC=300]="SYNC"})(e||(e={})),function(o){o.codec=()=>Ir(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Ar((o,i,a={})=>{if(a.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.observedAddresses!=null)for(let f of o.observedAddresses)i.uint32(18),i.bytes(f);a.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let a={observedAddresses:[]},f=i==null?o.len:o.pos+i;for(;o.pos<f;){let d=o.uint32();switch(d>>>3){case 1:a.type=r.Type.codec().decode(o);break;case 2:a.observedAddresses.push(o.bytes());break;default:o.skipType(d&7);break}}return a})),n),r.encode=o=>yr(o,r.codec()),r.decode=o=>hr(o,r.codec())})(j||(j={}));var bs=r=>r.toString().split("/").slice(1),Rt=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),E=r=>({match:t=>Rt(e=>e===r).match(t),pattern:r}),ie=()=>({match:r=>Rt(t=>typeof t=="string").match(r),pattern:"{string}"}),Wn=()=>({match:r=>Rt(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),M=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{P.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),ne=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Ne.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),W=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),q=(...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},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),v=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function L(...r){function t(o){let i=bs(o);for(let a of r){let f=a.match(i);if(f===!1)return!1;i=f}return i}function e(o){return t(o)!==!1}function n(o){let i=t(o);return i===!1?!1:i.length===0}return{matches:e,exactMatch:n}}var vr=v(E("dns4"),ie()),Sr=v(E("dns6"),ie()),Lr=v(E("dnsaddr"),ie()),qn=v(E("dns"),ie()),El=L(vr),vl=L(Sr),Sl=L(Lr),Xn=L(q(qn,Lr,vr,Sr)),Hn=v(E("ip4"),Rt(Wt)),Qn=v(E("ip6"),Rt(qt)),Jn=q(Hn,Qn),Ct=q(Jn,qn,vr,Sr,Lr),Ll=L(Ct),Pl=L(Hn),Nl=L(Qn),Kn=L(Jn),se=v(Ct,E("tcp"),Wn()),$t=v(Ct,E("udp"),Wn()),xs=q(se,$t),Ul=L(se),Dl=L($t),Pr=v($t,E("quic")),ae=v($t,E("quic-v1")),ys=q(Pr,ae),Tl=L(Pr),Fl=L(ae),Er=q(Ct,se,$t,Pr,ae),Zn=q(v(Er,E("ws"),W(M()))),Rl=L(Zn),Yn=q(v(Er,E("wss"),W(M())),v(Er,E("tls"),E("ws"),W(M()))),Cl=L(Yn),to=v(xs,E("webrtc-direct"),ne(),W(ne()),W(M())),$l=L(to),eo=v(ae,E("webtransport"),ne(),ne(),W(M())),Bl=L(eo),oe=q(Zn,Yn,v(se,W(M())),v(ys,W(M())),v(Ct,W(M())),to,eo,M()),kl=L(oe),Is=v(oe,E("p2p-circuit"),M()),ro=L(Is),As=q(v(oe,E("p2p-circuit"),E("webrtc"),M()),v(oe,E("webrtc"),W(M())),E("webrtc")),Ml=L(As);var fo=de(no(),1);var oo="[a-fA-F\\d:]",nt=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${oo})|(?<=${oo})(?=\\s|$))`:"",G="(?: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}",S="[a-fA-F\\d]{1,4}",ce=`
2
+ "use strict";var Libp2PDcutr=(()=>{var Si=Object.create;var Zt=Object.defineProperty;var Li=Object.getOwnPropertyDescriptor;var Ui=Object.getOwnPropertyNames;var Di=Object.getPrototypeOf,Ni=Object.prototype.hasOwnProperty;var Ue=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),U=(r,t)=>{for(var e in t)Zt(r,e,{get:t[e],enumerable:!0})},wn=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ui(t))!Ni.call(r,o)&&o!==e&&Zt(r,o,{get:()=>t[o],enumerable:!(n=Li(t,o))||n.enumerable});return r};var De=(r,t,e)=>(e=r!=null?Si(Di(r)):{},wn(t||!r||!r.__esModule?Zt(e,"default",{value:r,enumerable:!0}):e,r)),Ci=r=>wn(Zt({},"__esModule",{value:!0}),r);var mo=Ue((Wl,po)=>{"use strict";function lo(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function ma(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return lo(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),lo(new o,e)}}po.exports=ma});var di=Ue(Kt=>{(function(){var r,t,e,n,o,i,a,f;f=function(l){var d,w,b,g;return d=(l&255<<24)>>>24,w=(l&255<<16)>>>16,b=(l&65280)>>>8,g=l&255,[d,w,b,g].join(".")},a=function(l){var d,w,b,g,c,s;for(d=[],b=g=0;g<=3&&l.length!==0;b=++g){if(b>0){if(l[0]!==".")throw new Error("Invalid IP");l=l.substring(1)}s=t(l),c=s[0],w=s[1],l=l.substring(w),d.push(c)}if(l.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},e=function(l){return l.charCodeAt(0)},n=e("0"),i=e("a"),o=e("A"),t=function(l){var d,w,b,g,c;for(g=0,d=10,w="9",b=0,l.length>1&&l[b]==="0"&&(l[b+1]==="x"||l[b+1]==="X"?(b+=2,d=16):"0"<=l[b+1]&&l[b+1]<="9"&&(b++,d=8,w="7")),c=b;b<l.length;){if("0"<=l[b]&&l[b]<=w)g=g*d+(e(l[b])-n)>>>0;else if(d===16)if("a"<=l[b]&&l[b]<="f")g=g*d+(10+e(l[b])-i)>>>0;else if("A"<=l[b]&&l[b]<="F")g=g*d+(10+e(l[b])-o)>>>0;else break;else break;if(g>4294967295)throw new Error("too large");b++}if(b===c)throw new Error("empty octet");return[g,b]},r=function(){function l(d,w){var b,g,c,s;if(typeof d!="string")throw new Error("Missing `net' parameter");if(w||(s=d.split("/",2),d=s[0],w=s[1]),w||(w=32),typeof w=="string"&&w.indexOf(".")>-1){try{this.maskLong=a(w)}catch(h){throw b=h,new Error("Invalid mask: "+w)}for(g=c=32;c>=0;g=--c)if(this.maskLong===4294967295<<32-g>>>0){this.bitmask=g;break}}else if(w||w===0)this.bitmask=parseInt(w,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(a(d)&this.maskLong)>>>0}catch(h){throw b=h,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+w);this.size=Math.pow(2,32-this.bitmask),this.base=f(this.netLong),this.mask=f(this.maskLong),this.hostmask=f(~this.maskLong),this.first=this.bitmask<=30?f(this.netLong+1):this.base,this.last=this.bitmask<=30?f(this.netLong+this.size-2):f(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?f(this.netLong+this.size-1):void 0}return l.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new l(d)),d instanceof l?this.contains(d.base)&&this.contains(d.broadcast||d.last):(a(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},l.prototype.next=function(d){return d==null&&(d=1),new l(f(this.netLong+this.size*d),this.mask)},l.prototype.forEach=function(d){var w,b,g;for(g=a(this.first),b=a(this.last),w=0;g<=b;)d(f(g),g,w),w++,g++},l.prototype.toString=function(){return this.base+"/"+this.bitmask},l}(),Kt.ip2long=a,Kt.long2ip=f,Kt.Netmask=r}).call(Kt)});var wi=Ue((gi,Ee)=>{(function(r){"use strict";let t="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},n=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),i="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",f={zoneIndex:new RegExp(i,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${i})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${i})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${t}\\.${t}\\.${t}\\.${t}(${i})?$`,"i")};function l(c,s){if(c.indexOf("::")!==c.lastIndexOf("::"))return null;let h=0,u=-1,p=(c.match(f.zoneIndex)||[])[0],m,x;for(p&&(p=p.substring(1),c=c.replace(/%.+$/,""));(u=c.indexOf(":",u+1))>=0;)h++;if(c.substr(0,2)==="::"&&h--,c.substr(-2,2)==="::"&&h--,h>s)return null;for(x=s-h,m=":";x--;)m+="0:";return c=c.replace("::",m),c[0]===":"&&(c=c.slice(1)),c[c.length-1]===":"&&(c=c.slice(0,-1)),s=function(){let y=c.split(":"),v=[];for(let I=0;I<y.length;I++)v.push(parseInt(y[I],16));return v}(),{parts:s,zoneId:p}}function d(c,s,h,u){if(c.length!==s.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let p=0,m;for(;u>0;){if(m=h-u,m<0&&(m=0),c[p]>>m!==s[p]>>m)return!1;u-=h,p+=1}return!0}function w(c){if(o.test(c))return parseInt(c,16);if(c[0]==="0"&&!isNaN(parseInt(c[1],10))){if(n.test(c))return parseInt(c,8);throw new Error(`ipaddr: cannot parse ${c} as octal`)}return parseInt(c,10)}function b(c,s){for(;c.length<s;)c=`0${c}`;return c}let g={};g.IPv4=function(){function c(s){if(s.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let h,u;for(h=0;h<s.length;h++)if(u=s[h],!(0<=u&&u<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=s}return c.prototype.SpecialRanges={unspecified:[[new c([0,0,0,0]),8]],broadcast:[[new c([255,255,255,255]),32]],multicast:[[new c([224,0,0,0]),4]],linkLocal:[[new c([169,254,0,0]),16]],loopback:[[new c([127,0,0,0]),8]],carrierGradeNat:[[new c([100,64,0,0]),10]],private:[[new c([10,0,0,0]),8],[new c([172,16,0,0]),12],[new c([192,168,0,0]),16]],reserved:[[new c([192,0,0,0]),24],[new c([192,0,2,0]),24],[new c([192,88,99,0]),24],[new c([198,18,0,0]),15],[new c([198,51,100,0]),24],[new c([203,0,113,0]),24],[new c([240,0,0,0]),4]]},c.prototype.kind=function(){return"ipv4"},c.prototype.match=function(s,h){let u;if(h===void 0&&(u=s,s=u[0],h=u[1]),s.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return d(this.octets,s.octets,8,h)},c.prototype.prefixLengthFromSubnetMask=function(){let s=0,h=!1,u={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},p,m,x;for(p=3;p>=0;p-=1)if(m=this.octets[p],m in u){if(x=u[m],h&&x!==0)return null;x!==8&&(h=!0),s+=x}else return null;return 32-s},c.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},c.prototype.toByteArray=function(){return this.octets.slice(0)},c.prototype.toIPv4MappedAddress=function(){return g.IPv6.parse(`::ffff:${this.toString()}`)},c.prototype.toNormalizedString=function(){return this.toString()},c.prototype.toString=function(){return this.octets.join(".")},c}(),g.IPv4.broadcastAddressFromCIDR=function(c){try{let s=this.parseCIDR(c),h=s[0].toByteArray(),u=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),p=[],m=0;for(;m<4;)p.push(parseInt(h[m],10)|parseInt(u[m],10)^255),m++;return new this(p)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.isIPv4=function(c){return this.parser(c)!==null},g.IPv4.isValid=function(c){try{return new this(this.parser(c)),!0}catch{return!1}},g.IPv4.isValidFourPartDecimal=function(c){return!!(g.IPv4.isValid(c)&&c.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},g.IPv4.networkAddressFromCIDR=function(c){let s,h,u,p,m;try{for(s=this.parseCIDR(c),u=s[0].toByteArray(),m=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),p=[],h=0;h<4;)p.push(parseInt(u[h],10)&parseInt(m[h],10)),h++;return new this(p)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.parse=function(c){let s=this.parser(c);if(s===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(s)},g.IPv4.parseCIDR=function(c){let s;if(s=c.match(/^(.+)\/(\d+)$/)){let h=parseInt(s[2]);if(h>=0&&h<=32){let u=[this.parse(s[1]),h];return Object.defineProperty(u,"toString",{value:function(){return this.join("/")}}),u}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},g.IPv4.parser=function(c){let s,h,u;if(s=c.match(e.fourOctet))return function(){let p=s.slice(1,6),m=[];for(let x=0;x<p.length;x++)h=p[x],m.push(w(h));return m}();if(s=c.match(e.longValue)){if(u=w(s[1]),u>4294967295||u<0)throw new Error("ipaddr: address outside defined range");return function(){let p=[],m;for(m=0;m<=24;m+=8)p.push(u>>m&255);return p}().reverse()}else return(s=c.match(e.twoOctet))?function(){let p=s.slice(1,4),m=[];if(u=w(p[1]),u>16777215||u<0)throw new Error("ipaddr: address outside defined range");return m.push(w(p[0])),m.push(u>>16&255),m.push(u>>8&255),m.push(u&255),m}():(s=c.match(e.threeOctet))?function(){let p=s.slice(1,5),m=[];if(u=w(p[2]),u>65535||u<0)throw new Error("ipaddr: address outside defined range");return m.push(w(p[0])),m.push(w(p[1])),m.push(u>>8&255),m.push(u&255),m}():null},g.IPv4.subnetMaskFromPrefixLength=function(c){if(c=parseInt(c),c<0||c>32)throw new Error("ipaddr: invalid IPv4 prefix length");let s=[0,0,0,0],h=0,u=Math.floor(c/8);for(;h<u;)s[h]=255,h++;return u<4&&(s[u]=Math.pow(2,c%8)-1<<8-c%8),new this(s)},g.IPv6=function(){function c(s,h){let u,p;if(s.length===16)for(this.parts=[],u=0;u<=14;u+=2)this.parts.push(s[u]<<8|s[u+1]);else if(s.length===8)this.parts=s;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(u=0;u<this.parts.length;u++)if(p=this.parts[u],!(0<=p&&p<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");h&&(this.zoneId=h)}return c.prototype.SpecialRanges={unspecified:[new c([0,0,0,0,0,0,0,0]),128],linkLocal:[new c([65152,0,0,0,0,0,0,0]),10],multicast:[new c([65280,0,0,0,0,0,0,0]),8],loopback:[new c([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new c([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new c([0,0,0,0,0,65535,0,0]),96],rfc6145:[new c([0,0,0,0,65535,0,0,0]),96],rfc6052:[new c([100,65435,0,0,0,0,0,0]),96],"6to4":[new c([8194,0,0,0,0,0,0,0]),16],teredo:[new c([8193,0,0,0,0,0,0,0]),32],reserved:[[new c([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new c([8193,2,0,0,0,0,0,0]),48],amt:[new c([8193,3,0,0,0,0,0,0]),32],as112v6:[new c([8193,4,274,0,0,0,0,0]),48],deprecated:[new c([8193,16,0,0,0,0,0,0]),28],orchid2:[new c([8193,32,0,0,0,0,0,0]),28]},c.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},c.prototype.kind=function(){return"ipv6"},c.prototype.match=function(s,h){let u;if(h===void 0&&(u=s,s=u[0],h=u[1]),s.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return d(this.parts,s.parts,16,h)},c.prototype.prefixLengthFromSubnetMask=function(){let s=0,h=!1,u={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},p,m;for(let x=7;x>=0;x-=1)if(p=this.parts[x],p in u){if(m=u[p],h&&m!==0)return null;m!==16&&(h=!0),s+=m}else return null;return 128-s},c.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},c.prototype.toByteArray=function(){let s,h=[],u=this.parts;for(let p=0;p<u.length;p++)s=u[p],h.push(s>>8),h.push(s&255);return h},c.prototype.toFixedLengthString=function(){let s=function(){let u=[];for(let p=0;p<this.parts.length;p++)u.push(b(this.parts[p].toString(16),4));return u}.call(this).join(":"),h="";return this.zoneId&&(h=`%${this.zoneId}`),s+h},c.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let s=this.parts.slice(-2),h=s[0],u=s[1];return new g.IPv4([h>>8,h&255,u>>8,u&255])},c.prototype.toNormalizedString=function(){let s=function(){let u=[];for(let p=0;p<this.parts.length;p++)u.push(this.parts[p].toString(16));return u}.call(this).join(":"),h="";return this.zoneId&&(h=`%${this.zoneId}`),s+h},c.prototype.toRFC5952String=function(){let s=/((^|:)(0(:|$)){2,})/g,h=this.toNormalizedString(),u=0,p=-1,m;for(;m=s.exec(h);)m[0].length>p&&(u=m.index,p=m[0].length);return p<0?h:`${h.substring(0,u)}::${h.substring(u+p)}`},c.prototype.toString=function(){return this.toRFC5952String()},c}(),g.IPv6.broadcastAddressFromCIDR=function(c){try{let s=this.parseCIDR(c),h=s[0].toByteArray(),u=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),p=[],m=0;for(;m<16;)p.push(parseInt(h[m],10)|parseInt(u[m],10)^255),m++;return new this(p)}catch(s){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${s})`)}},g.IPv6.isIPv6=function(c){return this.parser(c)!==null},g.IPv6.isValid=function(c){if(typeof c=="string"&&c.indexOf(":")===-1)return!1;try{let s=this.parser(c);return new this(s.parts,s.zoneId),!0}catch{return!1}},g.IPv6.networkAddressFromCIDR=function(c){let s,h,u,p,m;try{for(s=this.parseCIDR(c),u=s[0].toByteArray(),m=this.subnetMaskFromPrefixLength(s[1]).toByteArray(),p=[],h=0;h<16;)p.push(parseInt(u[h],10)&parseInt(m[h],10)),h++;return new this(p)}catch(x){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${x})`)}},g.IPv6.parse=function(c){let s=this.parser(c);if(s.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(s.parts,s.zoneId)},g.IPv6.parseCIDR=function(c){let s,h,u;if((h=c.match(/^(.+)\/(\d+)$/))&&(s=parseInt(h[2]),s>=0&&s<=128))return u=[this.parse(h[1]),s],Object.defineProperty(u,"toString",{value:function(){return this.join("/")}}),u;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},g.IPv6.parser=function(c){let s,h,u,p,m,x;if(u=c.match(f.deprecatedTransitional))return this.parser(`::ffff:${u[1]}`);if(f.native.test(c))return l(c,8);if((u=c.match(f.transitional))&&(x=u[6]||"",s=l(u[1].slice(0,-1)+x,6),s.parts)){for(m=[parseInt(u[2]),parseInt(u[3]),parseInt(u[4]),parseInt(u[5])],h=0;h<m.length;h++)if(p=m[h],!(0<=p&&p<=255))return null;return s.parts.push(m[0]<<8|m[1]),s.parts.push(m[2]<<8|m[3]),{parts:s.parts,zoneId:s.zoneId}}return null},g.IPv6.subnetMaskFromPrefixLength=function(c){if(c=parseInt(c),c<0||c>128)throw new Error("ipaddr: invalid IPv6 prefix length");let s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0,u=Math.floor(c/8);for(;h<u;)s[h]=255,h++;return u<16&&(s[u]=Math.pow(2,c%8)-1<<8-c%8),new this(s)},g.fromByteArray=function(c){let s=c.length;if(s===4)return new g.IPv4(c);if(s===16)return new g.IPv6(c);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},g.isValid=function(c){return g.IPv6.isValid(c)||g.IPv4.isValid(c)},g.parse=function(c){if(g.IPv6.isValid(c))return g.IPv6.parse(c);if(g.IPv4.isValid(c))return g.IPv4.parse(c);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},g.parseCIDR=function(c){try{return g.IPv6.parseCIDR(c)}catch{try{return g.IPv4.parseCIDR(c)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},g.process=function(c){let s=this.parse(c);return s.kind()==="ipv6"&&s.isIPv4MappedAddress()?s.toIPv4Address():s},g.subnetMatch=function(c,s,h){let u,p,m,x;h==null&&(h="unicast");for(p in s)if(Object.prototype.hasOwnProperty.call(s,p)){for(m=s[p],m[0]&&!(m[0]instanceof Array)&&(m=[m]),u=0;u<m.length;u++)if(x=m[u],c.kind()===x[0].kind()&&c.match.apply(c,x))return p}return h},typeof Ee<"u"&&Ee.exports?Ee.exports=g:r.ipaddr=g})(gi)});var tf={};U(tf,{dcutr:()=>Yc,multicodec:()=>Ft});var rf=Symbol.for("@libp2p/connection");var of=Symbol.for("@libp2p/content-routing");var cf=Symbol.for("@libp2p/peer-discovery");var hf=Symbol.for("@libp2p/peer-id");var lf=Symbol.for("@libp2p/peer-routing");var bn;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(bn||(bn={}));var gf=Symbol.for("@libp2p/transport");var xn;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(xn||(xn={}));var G=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ft="ERR_INVALID_MESSAGE";var Ne=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},xf=globalThis.CustomEvent??Ne;var Re={};U(Re,{base58btc:()=>$,base58flickr:()=>ki});var Qf=new Uint8Array(0);function yn(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 Z(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function vn(r){return new TextEncoder().encode(r)}function An(r){return new TextDecoder().decode(r)}function Pi(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 i=r.charAt(o),a=i.charCodeAt(0);if(e[a]!==255)throw new TypeError(i+" is ambiguous");e[a]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),w=Math.log(256)/Math.log(f);function b(s){if(s instanceof Uint8Array||(ArrayBuffer.isView(s)?s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Array.isArray(s)&&(s=Uint8Array.from(s))),!(s instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(s.length===0)return"";for(var h=0,u=0,p=0,m=s.length;p!==m&&s[p]===0;)p++,h++;for(var x=(m-p)*w+1>>>0,y=new Uint8Array(x);p!==m;){for(var v=s[p],I=0,A=x-1;(v!==0||I<u)&&A!==-1;A--,I++)v+=256*y[A]>>>0,y[A]=v%f>>>0,v=v/f>>>0;if(v!==0)throw new Error("Non-zero carry");u=I,p++}for(var S=x-u;S!==x&&y[S]===0;)S++;for(var B=l.repeat(h);S<x;++S)B+=r.charAt(y[S]);return B}function g(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var h=0;if(s[h]!==" "){for(var u=0,p=0;s[h]===l;)u++,h++;for(var m=(s.length-h)*d+1>>>0,x=new Uint8Array(m);s[h];){var y=e[s.charCodeAt(h)];if(y===255)return;for(var v=0,I=m-1;(y!==0||v<p)&&I!==-1;I--,v++)y+=f*x[I]>>>0,x[I]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");p=v,h++}if(s[h]!==" "){for(var A=m-p;A!==m&&x[A]===0;)A++;for(var S=new Uint8Array(u+(m-A)),B=u;A!==m;)S[B++]=x[A++];return S}}}function c(s){var h=g(s);if(h)return h;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:g,decode:c}}var Ti=Pi,Fi=Ti,En=Fi;var Ce=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")}},Pe=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),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 Sn(this,t)}},Te=class{decoders;constructor(t){this.decoders=t}or(t){return Sn(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 Sn(r,t){return new Te({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Fe=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 Ce(t,e,n),this.decoder=new Pe(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function wt({name:r,prefix:t,encode:e,decode:n}){return new Fe(r,t,e,n)}function nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=En(e,r);return wt({prefix:t,name:r,encode:n,decode:i=>Z(o(i))})}function Ri(r,t,e,n){let o={};for(let w=0;w<t.length;++w)o[t[w]]=w;let i=r.length;for(;r[i-1]==="=";)--i;let a=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let w=0;w<i;++w){let b=o[r[w]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,f+=e,f>=8&&(f-=8,a[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return a}function Mi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",a=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],a+=8;a>e;)a-=e,i+=t[o&f>>a];if(a!==0&&(i+=t[o&f<<e-a]),n)for(;i.length*e&7;)i+="=";return i}function D({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return wt({prefix:t,name:r,encode(o){return Mi(o,n,e)},decode(o){return Ri(o,n,e,r)}})}var $=nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ki=nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Me={};U(Me,{base32:()=>Y,base32hex:()=>zi,base32hexpad:()=>_i,base32hexpadupper:()=>ji,base32hexupper:()=>Vi,base32pad:()=>$i,base32padupper:()=>Oi,base32upper:()=>Bi,base32z:()=>Gi});var Y=D({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Bi=D({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$i=D({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oi=D({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zi=D({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vi=D({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_i=D({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ji=D({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gi=D({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var qi=Dn,Ln=128,Wi=127,Xi=~Wi,Ji=Math.pow(2,31);function Dn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ji;)t[e++]=r&255|Ln,r/=128;for(;r&Xi;)t[e++]=r&255|Ln,r>>>=7;return t[e]=r|0,Dn.bytes=e-n+1,t}var Qi=ke,Hi=128,Un=127;function ke(r,n){var e=0,n=n||0,o=0,i=n,a,f=r.length;do{if(i>=f)throw ke.bytes=0,new RangeError("Could not decode varint");a=r[i++],e+=o<28?(a&Un)<<o:(a&Un)*Math.pow(2,o),o+=7}while(a>=Hi);return ke.bytes=i-n,e}var Ki=Math.pow(2,7),Zi=Math.pow(2,14),Yi=Math.pow(2,21),ts=Math.pow(2,28),es=Math.pow(2,35),rs=Math.pow(2,42),ns=Math.pow(2,49),os=Math.pow(2,56),is=Math.pow(2,63),ss=function(r){return r<Ki?1:r<Zi?2:r<Yi?3:r<ts?4:r<es?5:r<rs?6:r<ns?7:r<os?8:r<is?9:10},as={encode:qi,decode:Qi,encodingLength:ss},cs=as,Rt=cs;function Mt(r,t=0){return[Rt.decode(r,t),Rt.decode.bytes]}function bt(r,t,e=0){return Rt.encode(r,t,e),t}function xt(r){return Rt.encodingLength(r)}function ht(r,t){let e=t.byteLength,n=xt(r),o=n+xt(e),i=new Uint8Array(o+e);return bt(r,i,0),bt(e,i,n),i.set(t,o),new yt(r,e,t,i)}function te(r){let t=Z(r),[e,n]=Mt(t),[o,i]=Mt(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new yt(e,o,a,t)}function Nn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&yn(r.bytes,e.bytes)}}var yt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Cn(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return hs(e,Be(r),t??$.encoder);default:return us(e,Be(r),t??Y.encoder)}}var Pn=new WeakMap;function Be(r){let t=Pn.get(r);if(t==null){let e=new Map;return Pn.set(r,e),e}return t}var ot=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}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!==kt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ls)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=ht(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&&Nn(t.multihash,n.multihash)}toString(t){return Cn(this,t)}toJSON(){return{"/":Cn(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:i,bytes:a}=e;return new r(n,o,i,a??Tn(n,o,i.bytes))}else if(e[ds]===!0){let{version:n,multihash:o,code:i}=e,a=te(o);return r.create(n,i,a)}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!==kt)throw new Error(`Version 0 CID must use dag-pb (code: ${kt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Tn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,kt,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=Z(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),a=new yt(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(a):r.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,g]=Mt(t.subarray(e));return e+=g,b},o=n(),i=kt;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=e,f=n(),l=n(),d=e+l,w=d-a;return{version:o,codec:i,multihashCode:f,digestSize:l,multihashSize:w,size:d}}static parse(t,e){let[n,o]=fs(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Be(i).set(n,t),i}};function fs(r,t){switch(r[0]){case"Q":{let e=t??$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t??$;return[$.prefix,e.decode(r)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function hs(r,t,e){let{prefix:n}=e;if(n!==$.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function us(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var kt=112,ls=18;function Tn(r,t,e){let n=xt(r),o=n+xt(t),i=new Uint8Array(o+e.byteLength);return bt(r,i,0),bt(t,i,n),i.set(e,o),i}var ds=Symbol.for("@ipld/js-cid/CID");function Fn(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 $e={};U($e,{base10:()=>ps});var ps=nt({prefix:"9",name:"base10",alphabet:"0123456789"});var Oe={};U(Oe,{base16:()=>ms,base16upper:()=>gs});var ms=D({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gs=D({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ze={};U(ze,{base2:()=>ws});var ws=D({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ve={};U(Ve,{base256emoji:()=>As});var Rn=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}"),bs=Rn.reduce((r,t,e)=>(r[e]=t,r),[]),xs=Rn.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function ys(r){return r.reduce((t,e)=>(t+=bs[e],t),"")}function vs(r){let t=[];for(let e of r){let n=xs[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var As=wt({prefix:"\u{1F680}",name:"base256emoji",encode:ys,decode:vs});var _e={};U(_e,{base36:()=>Is,base36upper:()=>Es});var Is=nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Es=nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var je={};U(je,{base64:()=>Ss,base64pad:()=>Ls,base64url:()=>Us,base64urlpad:()=>Ds});var Ss=D({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ls=D({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Us=D({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ds=D({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ge={};U(Ge,{base8:()=>Ns});var Ns=D({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qe={};U(qe,{identity:()=>Cs});var Cs=wt({prefix:"\0",name:"identity",encode:r=>An(r),decode:r=>vn(r)});var yh=new TextEncoder,vh=new TextDecoder;var We={};U(We,{identity:()=>Ms});var Mn=0,Fs="identity",kn=Z;function Rs(r){return ht(Mn,kn(r))}var Ms={code:Mn,name:Fs,encode:kn,digest:Rs};var Qe={};U(Qe,{sha256:()=>ks,sha512:()=>Bs});function Je({name:r,code:t,encode:e}){return new Xe(r,t,e)}var Xe=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?ht(this.code,e):e.then(n=>ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};function $n(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ks=Je({name:"sha2-256",code:18,encode:$n("SHA-256")}),Bs=Je({name:"sha2-512",code:19,encode:$n("SHA-512")});var Bt={...qe,...ze,...Ge,...$e,...Oe,...Me,..._e,...Re,...je,...Ve},Rh={...Qe,...We};function ut(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ee(r=0){return globalThis.Buffer?.allocUnsafe!=null?ut(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function zn(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var On=zn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),He=zn("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=ee(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),$s={utf8:On,"utf-8":On,hex:Bt.base16,latin1:He,ascii:He,binary:He,...Bt},re=$s;function O(r,t="utf8"){let e=re[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}function Vn(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function _n(r=0){return globalThis.Buffer?.allocUnsafe!=null?Vn(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var Os=Math.pow(2,7),zs=Math.pow(2,14),Vs=Math.pow(2,21),Ke=Math.pow(2,28),Ze=Math.pow(2,35),Ye=Math.pow(2,42),tr=Math.pow(2,49),E=128,R=127;function M(r){if(r<Os)return 1;if(r<zs)return 2;if(r<Vs)return 3;if(r<Ke)return 4;if(r<Ze)return 5;if(r<Ye)return 6;if(r<tr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function _s(r,t,e=0){switch(M(r)){case 8:t[e++]=r&255|E,r/=128;case 7:t[e++]=r&255|E,r/=128;case 6:t[e++]=r&255|E,r/=128;case 5:t[e++]=r&255|E,r/=128;case 4:t[e++]=r&255|E,r>>>=7;case 3:t[e++]=r&255|E,r>>>=7;case 2:t[e++]=r&255|E,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function js(r,t,e=0){switch(M(r)){case 8:t.set(e++,r&255|E),r/=128;case 7:t.set(e++,r&255|E),r/=128;case 6:t.set(e++,r&255|E),r/=128;case 5:t.set(e++,r&255|E),r/=128;case 4:t.set(e++,r&255|E),r>>>=7;case 3:t.set(e++,r&255|E),r>>>=7;case 2:t.set(e++,r&255|E),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Gs(r,t){let e=r[t],n=0;if(n+=e&R,e<E||(e=r[t+1],n+=(e&R)<<7,e<E)||(e=r[t+2],n+=(e&R)<<14,e<E)||(e=r[t+3],n+=(e&R)<<21,e<E)||(e=r[t+4],n+=(e&R)*Ke,e<E)||(e=r[t+5],n+=(e&R)*Ze,e<E)||(e=r[t+6],n+=(e&R)*Ye,e<E)||(e=r[t+7],n+=(e&R)*tr,e<E))return n;throw new RangeError("Could not decode varint")}function qs(r,t){let e=r.get(t),n=0;if(n+=e&R,e<E||(e=r.get(t+1),n+=(e&R)<<7,e<E)||(e=r.get(t+2),n+=(e&R)<<14,e<E)||(e=r.get(t+3),n+=(e&R)<<21,e<E)||(e=r.get(t+4),n+=(e&R)*Ke,e<E)||(e=r.get(t+5),n+=(e&R)*Ze,e<E)||(e=r.get(t+6),n+=(e&R)*Ye,e<E)||(e=r.get(t+7),n+=(e&R)*tr,e<E))return n;throw new RangeError("Could not decode varint")}function it(r,t,e=0){return t==null&&(t=_n(M(r))),t instanceof Uint8Array?_s(r,t,e):js(r,t,e)}function q(r,t=0){return r instanceof Uint8Array?Gs(r,t):qs(r,t)}function tt(r,t){if(globalThis.Buffer!=null)return ut(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=ee(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return ut(e)}var ne=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 i=0,a=0,f=this.peekChar();if(f===void 0)return;let l=f==="0",d=2**(8*o)-1;for(;;){let w=this.readAtomically(()=>{let b=this.readChar();if(b===void 0)return;let g=Number.parseInt(b,t);if(!Number.isNaN(g))return g});if(w===void 0)break;if(i*=t,i+=w,i>d||(a+=1,e!==void 0&&a>e))return}if(a!==0)return!n&&l&&a>1?void 0:i})}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 a=this.readSeparator(":",n,()=>this.readIPv4Addr());if(a!==void 0)return e[o]=a[0],e[o+1]=a[1],e[o+2]=a[2],e[o+3]=a[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&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 i=new Uint8Array(14),a=16-(n+2),[f]=t(i.subarray(0,a));return e.set(i.subarray(0,f),16-f),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var jn=45,Ws=15,At=new ne;function er(r){if(!(r.length>Ws))return At.new(r).parseWith(()=>At.readIPv4Addr())}function rr(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>jn))return At.new(r).parseWith(()=>At.readIPv6Addr())}function oe(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>jn))return At.new(r).parseWith(()=>At.readIPAddr())}var su=parseInt("0xFFFF",16),au=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function nr(r,t="utf8"){let e=re[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ut(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function ie(r){return!!er(r)}function se(r){return!!rr(r)}function It(r){return!!oe(r)}var Wn=ie,Ks=se,or=function(r){let t=0;if(r=r.toString().trim(),Wn(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Ks(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Wn(e[n]),a;i&&(a=or(e[n]),e[n]=O(a.slice(0,2),"base16")),a!=null&&++n<8&&e.splice(n,0,O(a.slice(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 i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Xn=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Et={},ir={},Ys=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Ys.forEach(r=>{let t=ta(...r);ir[t.code]=t,Et[t.name]=t});function ta(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function L(r){if(typeof r=="number"){if(ir[r]!=null)return ir[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Et[r]!=null)return Et[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Xu=L("ip4"),Ju=L("ip6"),Qu=L("ipcidr");function ar(r,t){switch(L(r).code){case 4:case 41:return ra(t);case 42:return Hn(t);case 6:case 273:case 33:case 132:return Zn(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Hn(t);case 421:return sa(t);case 444:return Kn(t);case 445:return Kn(t);case 466:return ia(t);default:return O(t,"base16")}}function cr(r,t){switch(L(r).code){case 4:return Jn(t);case 41:return Jn(t);case 42:return Qn(t);case 6:case 273:case 33:case 132:return fr(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qn(t);case 421:return na(t);case 444:return aa(t);case 445:return ca(t);case 466:return oa(t);default:return nr(t,"base16")}}var sr=Object.values(Bt).map(r=>r.decoder),ea=function(){let r=sr[0].or(sr[1]);return sr.slice(2).forEach(t=>r=r.or(t)),r}();function Jn(r){if(!It(r))throw new Error("invalid ip address");return or(r)}function ra(r){let t=Xn(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!It(t))throw new Error("invalid ip address");return t}function fr(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Zn(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Qn(r){let t=nr(r),e=Uint8Array.from(it(t.length));return tt([e,t],e.length+t.length)}function Hn(r){let t=q(r);if(r=r.slice(M(t)),r.length!==t)throw new Error("inconsistent lengths");return O(r)}function na(r){let t;r[0]==="Q"||r[0]==="1"?t=te($.decode(`z${r}`)).bytes:t=ot.parse(r).multihash.bytes;let e=Uint8Array.from(it(t.length));return tt([e,t],e.length+t.length)}function oa(r){let t=ea.decode(r),e=Uint8Array.from(it(t.length));return tt([e,t],e.length+t.length)}function ia(r){let t=q(r),e=r.slice(M(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+O(e,"base64url")}function sa(r){let t=q(r),e=r.slice(M(t));if(e.length!==t)throw new Error("inconsistent lengths");return O(e,"base58btc")}function aa(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=Y.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=fr(n);return tt([e,o],e.length+o.length)}function ca(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=Y.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=fr(n);return tt([e,o],e.length+o.length)}function Kn(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=O(t,"base32"),o=Zn(e);return`${n}:${o}`}function Yn(r){r=hr(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let a=o[i],f=L(a);if(f.size===0){t.push([f.code]),e.push([f.code]);continue}if(i++,i>=o.length)throw eo("invalid address: "+r);if(f.path===!0){n=hr(o.slice(i).join("/")),t.push([f.code,cr(f.code,n)]),e.push([f.code,n]);break}let l=cr(f.code,o[i]);t.push([f.code,l]),e.push([f.code,ar(f.code,l)])}return{string:to(e),bytes:lr(t),tuples:t,stringTuples:e,path:n}}function ur(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=q(r,o),a=M(i),f=L(i),l=fa(f,r.slice(o+a));if(l===0){t.push([i]),e.push([i]),o+=a;continue}let d=r.slice(o+a,o+a+l);if(o+=l+a,o>r.length)throw eo("Invalid address Uint8Array: "+O(r,"base16"));t.push([i,d]);let w=ar(i,d);if(e.push([i,w]),f.path===!0){n=w;break}}return{bytes:Uint8Array.from(r),string:to(e),tuples:t,stringTuples:e,path:n}}function to(r){let t=[];return r.map(e=>{let n=L(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),hr(t.join("/"))}function lr(r){return tt(r.map(t=>{let e=L(t[0]),n=Uint8Array.from(it(e.code));return t.length>1&&t[1]!=null&&(n=tt([n,t[1]])),n}))}function fa(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=q(t instanceof Uint8Array?t:Uint8Array.from(t));return e+M(e)}}function hr(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function eo(r){return new Error("Error parsing address: "+r)}var ha=Symbol.for("nodejs.util.inspect.custom"),dr=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ua=[L("dns").code,L("dns4").code,L("dns6").code,L("dnsaddr").code],ae=class r{bytes;#e;#t;#r;#n;[dr]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ur(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Yn(t)}else if(no(t))e=ur(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",a=L("tcp"),f=L("udp"),l=L("ip4"),d=L("ip6"),w=L("dns6"),b=L("ip6zone");for(let[c,s]of this.stringTuples())c===b.code&&(i=`%${s??""}`),ua.includes(c)&&(e=a.name,o=443,n=`${s??""}${i}`,t=c===w.code?6:4),(c===a.code||c===f.code)&&(e=L(c).name,o=parseInt(s??"")),(c===l.code||c===d.code)&&(e=L(c).name,n=`${s??""}${i}`,t=c===d.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},L(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>L(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(lr(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Et.p2p.code&&t.push([n,o]),n===Et["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?O($.decode(`z${n}`),"base58btc"):O(ot.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Fn(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=ro.get(e.name);if(n==null)throw new G(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(i=>new r(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[ha](){return`Multiaddr(${this.#e})`}};var ro=new Map;function no(r){return!!r?.[dr]}function pr(r){return new ae(r)}var oo=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},la=new WeakMap;function da({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(oo());let i,a,f,l=r??clearTimeout,d=()=>{l(i),f(oo())},w=()=>{o&&o.removeEventListener("abort",d)},b=new Promise((g,c)=>{a=()=>{w(),g(n)},f=c,i=(t??setTimeout)(a,e)});return o&&o.addEventListener("abort",d,{once:!0}),la.set(b,()=>{l(i),i=null,a()}),b}}var pa=da(),io=pa;function lt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function et(r=0){return globalThis.Buffer?.alloc!=null?lt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function z(r=0){return globalThis.Buffer?.allocUnsafe!=null?lt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function mr(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=z(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return lt(e)}function so(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 co=Symbol.for("@achingbrain/uint8arraylist");function ao(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 ce(r){return!!r?.[co]}var _=class r{bufs;length;[co]=!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(ce(n))e+=n.byteLength,this.bufs.push(...n.bufs);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(ce(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=ao(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ao(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(ce(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 mr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:mr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_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 i=0;i<this.bufs.length;i++){let a=this.bufs[i],f=o,l=f+a.byteLength;if(o=l,t>=l)continue;let d=t>=f&&t<l,w=e>f&&e<=l;if(d&&w){if(t===f&&e===l){n.push(a);break}let b=t-f;n.push(a.subarray(b,b+(e-t)));break}if(d){if(t===0){n.push(a);continue}n.push(a.subarray(t-f));continue}if(w){if(e===l){n.push(a);break}n.push(a.subarray(0,e-f));break}n.push(a)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ce(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 i=256,a=new Int32Array(i);for(let b=0;b<i;b++)a[b]=-1;for(let b=0;b<o;b++)a[n[b]]=b;let f=a,l=this.byteLength-n.byteLength,d=n.byteLength-1,w;for(let b=e;b<=l;b+=w){w=0;for(let g=d;g>=0;g--){let c=this.get(b+g);if(n[g]!==c){w=Math.max(1,g-f[c]);break}}if(w===0)return b}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=z(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=et(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=et(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=et(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=z(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=et(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=et(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=et(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=et(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=et(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(!so(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,i)=>o+i.byteLength,0)),n.length=e,n}};function St(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var fe=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=e??"ABORT_ERR"}};async function fo(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new fe(e?.errorMessage,e?.errorCode));let n,o=new fe(e?.errorMessage,e?.errorCode);try{return await Promise.race([r,new Promise((i,a)=>{n=()=>{a(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var gr=class{needNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.needNext=St(),this.haveNext=St()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("Have next but next was undefined");let t=this.nextResult;return this.nextResult=void 0,this.needNext.resolve(),this.needNext=St(),t}async throw(t){return this.ended=!0,t!=null&&this.haveNext.reject(t),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");this.nextResult!=null&&await this.needNext.promise,t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=St(),await fo(this.needNext.promise,e?.signal,e)}};function ho(){return new gr}var he=class extends Error{code;constructor(t,e){super(t),this.code=e}},wr=class extends he{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted"}};function uo(r,t){let e=ho();r.sink(e).catch(async a=>{await e.end(a)}),r.sink=async a=>{for await(let f of a)await e.push(f);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new _;return{read:async(a,f)=>{f?.signal?.throwIfAborted();let l,d=new Promise((w,b)=>{l=()=>{b(new wr("Read aborted"))},f?.signal?.addEventListener("abort",l)});try{if(a==null){let{done:b,value:g}=await Promise.race([n.next(),d]);return b===!0?new _:g}for(;o.byteLength<a;){let{value:b,done:g}=await Promise.race([n.next(),d]);if(g===!0)throw new he("unexpected end of input","ERR_UNEXPECTED_EOF");o.append(b)}let w=o.sublist(0,a);return o.consume(a),w}finally{l!=null&&f?.signal?.removeEventListener("abort",l)}},write:async(a,f)=>{f?.signal?.throwIfAborted(),a instanceof Uint8Array?await e.push(a,f):await e.push(a.subarray(),f)},unwrap:()=>{if(o.byteLength>0){let a=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*a}()}return r}}}function ue(r){return r[Symbol.asyncIterator]!=null}var le=r=>{let t=M(r),e=z(t);return it(r,e),le.bytes=t,e};le.bytes=0;function Ot(r,t){t=t??{};let e=t.lengthEncoder??le;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return ue(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Ot.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??le;return new _(e(r.byteLength),r)};var Lt=De(mo(),1);var ga=8,wa=1024*1024*4,dt;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(dt||(dt={}));var xr=r=>{let t=q(r);return xr.bytes=M(t),t};xr.bytes=0;function br(r,t){let e=new _,n=dt.LENGTH,o=-1,i=t?.lengthDecoder??xr,a=t?.maxLengthLength??ga,f=t?.maxDataLength??wa;function*l(){for(;e.byteLength>0;){if(n===dt.LENGTH)try{if(o=i(e),o<0)throw(0,Lt.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>f)throw(0,Lt.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=i.bytes;e.consume(d),t?.onLength!=null&&t.onLength(o),n=dt.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>a)throw(0,Lt.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===dt.DATA){if(e.byteLength<o)break;let d=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(d),yield d,n=dt.LENGTH}}}return ue(r)?async function*(){for await(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,Lt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,Lt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}br.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:a}=await r.next(e);if(i===!0)return;a!=null&&(yield a)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return br(n,{...t??{},onLength:i=>{e=i}})};var de=class extends Error{code;constructor(t,e){super(t),this.code=e}},go=r=>q(r);go.bytes=0;function wo(r,t={}){let e=uo(r,t);return t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=M(t.maxDataLength)),{read:async o=>{let i=-1,a=new _,f=t?.lengthDecoder??go;for(;;){a.append(await e.read(1,o));try{i=f(a)}catch(l){if(l instanceof RangeError)continue;throw l}if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new de("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(i>-1)break}if(t?.maxDataLength!=null&&i>t.maxDataLength)throw new de("message length too long","ERR_MSG_DATA_TOO_LONG");return e.read(i,o)},write:async(o,i)=>{await e.write(Ot.single(o,t),i)},writeV:async(o,i)=>{let a=new _(...o.map(f=>Ot.single(f,t)));await e.write(a,i)},unwrap:()=>e.unwrap()}}function yr(r,t){let e=wo(r,t),n={read:async(o,i)=>{let a=await e.read(i);return o.decode(a)},write:async(o,i,a)=>{await e.write(i.encode(o),a)},writeV:async(o,i,a)=>{await e.writeV(o.map(f=>i.encode(f)),a)},pb:o=>({read:async i=>n.read(o,i),write:async(i,a)=>n.write(i,o,a),writeV:async(i,a)=>n.writeV(i,o,a),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var vr=new Float32Array([-0]),st=new Uint8Array(vr.buffer);function bo(r,t,e){vr[0]=r,t[e]=st[0],t[e+1]=st[1],t[e+2]=st[2],t[e+3]=st[3]}function xo(r,t){return st[0]=r[t],st[1]=r[t+1],st[2]=r[t+2],st[3]=r[t+3],vr[0]}var Ar=new Float64Array([-0]),k=new Uint8Array(Ar.buffer);function yo(r,t,e){Ar[0]=r,t[e]=k[0],t[e+1]=k[1],t[e+2]=k[2],t[e+3]=k[3],t[e+4]=k[4],t[e+5]=k[5],t[e+6]=k[6],t[e+7]=k[7]}function vo(r,t){return k[0]=r[t],k[1]=r[t+1],k[2]=r[t+2],k[3]=r[t+3],k[4]=r[t+4],k[5]=r[t+5],k[6]=r[t+6],k[7]=r[t+7],Ar[0]}var xa=BigInt(Number.MAX_SAFE_INTEGER),ya=BigInt(Number.MIN_SAFE_INTEGER),V=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return pt;if(t<xa&&t>ya)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Ao&&(o=0n,++n>Ao&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return pt;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):pt}},pt=new V(0,0);pt.toBigInt=function(){return 0n};pt.zzEncode=pt.zzDecode=function(){return this};pt.length=function(){return 1};var Ao=4294967296n;function Io(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Eo(r,t,e){if(e-t<1)return"";let o,i=[],a=0,f;for(;t<e;)f=r[t++],f<128?i[a++]=f:f>191&&f<224?i[a++]=(f&31)<<6|r[t++]&63:f>239&&f<365?(f=((f&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[a++]=55296+(f>>10),i[a++]=56320+(f&1023)):i[a++]=(f&15)<<12|(r[t++]&63)<<6|r[t++]&63,a>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),a=0);return o!=null?(a>0&&o.push(String.fromCharCode.apply(String,i.slice(0,a))),o.join("")):String.fromCharCode.apply(String,i.slice(0,a))}function Ir(r,t,e){let n=e,o,i;for(let a=0;a<r.length;++a)o=r.charCodeAt(a),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(a+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++a,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function W(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function pe(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Er=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,W(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw W(this,4);return pe(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw W(this,4);return pe(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw W(this,4);let t=xo(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw W(this,4);let t=vo(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw W(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Eo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw W(this,t);this.pos+=t}else do if(this.pos>=this.len)throw W(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new V(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw W(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw W(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw W(this,8);let t=pe(this.buf,this.pos+=4),e=pe(this.buf,this.pos+=4);return new V(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Sr(r){return new Er(r instanceof Uint8Array?r:r.subarray())}function Lr(r,t){let e=Sr(r);return t.decode(e)}var Pr={};U(Pr,{base10:()=>La});function va(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 i=r.charAt(o),a=i.charCodeAt(0);if(e[a]!==255)throw new TypeError(i+" is ambiguous");e[a]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),w=Math.log(256)/Math.log(f);function b(s){if(s instanceof Uint8Array||(ArrayBuffer.isView(s)?s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Array.isArray(s)&&(s=Uint8Array.from(s))),!(s instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(s.length===0)return"";for(var h=0,u=0,p=0,m=s.length;p!==m&&s[p]===0;)p++,h++;for(var x=(m-p)*w+1>>>0,y=new Uint8Array(x);p!==m;){for(var v=s[p],I=0,A=x-1;(v!==0||I<u)&&A!==-1;A--,I++)v+=256*y[A]>>>0,y[A]=v%f>>>0,v=v/f>>>0;if(v!==0)throw new Error("Non-zero carry");u=I,p++}for(var S=x-u;S!==x&&y[S]===0;)S++;for(var B=l.repeat(h);S<x;++S)B+=r.charAt(y[S]);return B}function g(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var h=0;if(s[h]!==" "){for(var u=0,p=0;s[h]===l;)u++,h++;for(var m=(s.length-h)*d+1>>>0,x=new Uint8Array(m);s[h];){var y=e[s.charCodeAt(h)];if(y===255)return;for(var v=0,I=m-1;(y!==0||v<p)&&I!==-1;I--,v++)y+=f*x[I]>>>0,x[I]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");p=v,h++}if(s[h]!==" "){for(var A=m-p;A!==m&&x[A]===0;)A++;for(var S=new Uint8Array(u+(m-A)),B=u;A!==m;)S[B++]=x[A++];return S}}}function c(s){var h=g(s);if(h)return h;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:g,decode:c}}var Aa=va,Ia=Aa,Lo=Ia;var ud=new Uint8Array(0);var Uo=(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},rt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Do=r=>new TextEncoder().encode(r),No=r=>new TextDecoder().decode(r);var Ur=class{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")}},Dr=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),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 Po(this,t)}},Nr=class{constructor(t){this.decoders=t}or(t){return Po(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Po=(r,t)=>new Nr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Cr=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ur(t,e,n),this.decoder=new Dr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Ut=({name:r,prefix:t,encode:e,decode:n})=>new Cr(r,t,e,n),at=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Lo(e,t);return Ut({prefix:r,name:t,encode:n,decode:i=>rt(o(i))})},Ea=(r,t,e,n)=>{let o={};for(let w=0;w<t.length;++w)o[t[w]]=w;let i=r.length;for(;r[i-1]==="=";)--i;let a=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let w=0;w<i;++w){let b=o[r[w]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,f+=e,f>=8&&(f-=8,a[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return a},Sa=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",a=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],a+=8;a>e;)a-=e,i+=t[o&f>>a];if(a&&(i+=t[o&f<<e-a]),n)for(;i.length*e&7;)i+="=";return i},N=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Ut({prefix:t,name:r,encode(o){return Sa(o,n,e)},decode(o){return Ea(o,n,e,r)}});var La=at({prefix:"9",name:"base10",alphabet:"0123456789"});var Tr={};U(Tr,{base16:()=>Ua,base16upper:()=>Da});var Ua=N({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Da=N({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fr={};U(Fr,{base2:()=>Na});var Na=N({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rr={};U(Rr,{base256emoji:()=>Ra});var To=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}"),Ca=To.reduce((r,t,e)=>(r[e]=t,r),[]),Pa=To.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ta(r){return r.reduce((t,e)=>(t+=Ca[e],t),"")}function Fa(r){let t=[];for(let e of r){let n=Pa[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Ra=Ut({prefix:"\u{1F680}",name:"base256emoji",encode:Ta,decode:Fa});var Mr={};U(Mr,{base32:()=>Dt,base32hex:()=>$a,base32hexpad:()=>za,base32hexpadupper:()=>Va,base32hexupper:()=>Oa,base32pad:()=>ka,base32padupper:()=>Ba,base32upper:()=>Ma,base32z:()=>_a});var Dt=N({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ma=N({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ka=N({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ba=N({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$a=N({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Oa=N({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),za=N({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Va=N({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_a=N({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kr={};U(kr,{base36:()=>ja,base36upper:()=>Ga});var ja=at({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ga=at({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Br={};U(Br,{base58btc:()=>Q,base58flickr:()=>qa});var Q=at({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qa=at({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $r={};U($r,{base64:()=>Wa,base64pad:()=>Xa,base64url:()=>Ja,base64urlpad:()=>Qa});var Wa=N({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xa=N({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ja=N({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qa=N({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Or={};U(Or,{base8:()=>Ha});var Ha=N({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zr={};U(zr,{identity:()=>Ka});var Ka=Ut({prefix:"\0",name:"identity",encode:r=>No(r),decode:r=>Do(r)});var Ld=new TextEncoder,Ud=new TextDecoder;var _r={};U(_r,{identity:()=>yc});var tc=Mo,Fo=128,ec=127,rc=~ec,nc=Math.pow(2,31);function Mo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=nc;)t[e++]=r&255|Fo,r/=128;for(;r&rc;)t[e++]=r&255|Fo,r>>>=7;return t[e]=r|0,Mo.bytes=e-n+1,t}var oc=Vr,ic=128,Ro=127;function Vr(r,n){var e=0,n=n||0,o=0,i=n,a,f=r.length;do{if(i>=f)throw Vr.bytes=0,new RangeError("Could not decode varint");a=r[i++],e+=o<28?(a&Ro)<<o:(a&Ro)*Math.pow(2,o),o+=7}while(a>=ic);return Vr.bytes=i-n,e}var sc=Math.pow(2,7),ac=Math.pow(2,14),cc=Math.pow(2,21),fc=Math.pow(2,28),hc=Math.pow(2,35),uc=Math.pow(2,42),lc=Math.pow(2,49),dc=Math.pow(2,56),pc=Math.pow(2,63),mc=function(r){return r<sc?1:r<ac?2:r<cc?3:r<fc?4:r<hc?5:r<uc?6:r<lc?7:r<dc?8:r<pc?9:10},gc={encode:tc,decode:oc,encodingLength:mc},wc=gc,zt=wc;var Vt=(r,t=0)=>[zt.decode(r,t),zt.decode.bytes],Nt=(r,t,e=0)=>(zt.encode(r,t,e),t),Ct=r=>zt.encodingLength(r);var mt=(r,t)=>{let e=t.byteLength,n=Ct(r),o=n+Ct(e),i=new Uint8Array(o+e);return Nt(r,i,0),Nt(e,i,n),i.set(t,o),new Pt(r,e,t,i)},ko=r=>{let t=rt(r),[e,n]=Vt(t),[o,i]=Vt(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new Pt(e,o,a,t)},Bo=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Uo(r.bytes,e.bytes)}},Pt=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var $o=0,bc="identity",Oo=rt,xc=r=>mt($o,Oo(r)),yc={code:$o,name:bc,encode:Oo,digest:xc};var qr={};U(qr,{sha256:()=>vc,sha512:()=>Ac});var Gr=({name:r,code:t,encode:e})=>new jr(r,t,e),jr=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?mt(this.code,e):e.then(n=>mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Vo=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),vc=Gr({name:"sha2-256",code:18,encode:Vo("SHA-256")}),Ac=Gr({name:"sha2-512",code:19,encode:Vo("SHA-512")});var _o=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Ec(e,Wr(r),t||Q.encoder);default:return Sc(e,Wr(r),t||Dt.encoder)}};var jo=new WeakMap,Wr=r=>{let t=jo.get(r);if(t==null){let e=new Map;return jo.set(r,e),e}return t},ge=class r{constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}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!==jt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Lc)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=mt(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&&t.code===n.code&&t.version===n.version&&Bo(t.multihash,n.multihash)}toString(t){return _o(this,t)}toJSON(){return{"/":_o(this)}}link(){return this}get[Symbol.toStringTag](){return"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:i,bytes:a}=e;return new r(n,o,i,a||Go(n,o,i.bytes))}else if(e[Uc]===!0){let{version:n,multihash:o,code:i}=e,a=ko(o);return r.create(n,i,a)}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!==jt)throw new Error(`Version 0 CID must use dag-pb (code: ${jt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Go(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,jt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=rt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),a=new Pt(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(a):r.createV1(e.codec,a),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[b,g]=Vt(t.subarray(e));return e+=g,b},o=n(),i=jt;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=e,f=n(),l=n(),d=e+l,w=d-a;return{version:o,codec:i,multihashCode:f,digestSize:l,multihashSize:w,size:d}}static parse(t,e){let[n,o]=Ic(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wr(i).set(n,t),i}},Ic=(r,t)=>{switch(r[0]){case"Q":{let e=t||Q;return[Q.prefix,e.decode(`${Q.prefix}${r}`)]}case Q.prefix:{let e=t||Q;return[Q.prefix,e.decode(r)]}case Dt.prefix:{let e=t||Dt;return[Dt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},Ec=(r,t,e)=>{let{prefix:n}=e;if(n!==Q.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o},Sc=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o},jt=112,Lc=18,Go=(r,t,e)=>{let n=Ct(r),o=n+Ct(t),i=new Uint8Array(o+e.byteLength);return Nt(r,i,0),Nt(t,i,n),i.set(e,o),i},Uc=Symbol.for("@ipld/js-cid/CID");var Xr={...zr,...Fr,...Or,...Pr,...Tr,...Mr,...kr,...Br,...$r,...Rr},jd={...qr,..._r};function Wo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var qo=Wo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Jr=Wo("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=z(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Dc={utf8:qo,"utf-8":qo,hex:Xr.base16,latin1:Jr,ascii:Jr,binary:Jr,...Xr},Xo=Dc;function Jo(r,t="utf8"){let e=Xo[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?lt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Qr(r){let t=r??8192,e=t>>>1,n,o=t;return function(a){if(a<1||a>e)return z(a);o+a>t&&(n=z(t),o=0);let f=n.subarray(o,o+=a);return o&7&&(o=(o|7)+1),f}}var gt=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Hr(){}var Zr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Nc=Qr();function Cc(r){return globalThis.Buffer!=null?z(r):Nc(r)}var Wt=class{len;head;tail;states;constructor(){this.len=0,this.head=new gt(Hr,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new gt(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Yr((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Gt,10,V.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=V.fromBigInt(t);return this._push(Gt,e.length(),e)}uint64Number(t){let e=V.fromNumber(t);return this._push(Gt,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=V.fromBigInt(t).zzEncode();return this._push(Gt,e.length(),e)}sint64Number(t){let e=V.fromNumber(t).zzEncode();return this._push(Gt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Kr,1,t?1:0)}fixed32(t){return this._push(qt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=V.fromBigInt(t);return this._push(qt,4,e.lo)._push(qt,4,e.hi)}fixed64Number(t){let e=V.fromNumber(t);return this._push(qt,4,e.lo)._push(qt,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(bo,4,t)}double(t){return this._push(yo,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Kr,1,0):this.uint32(e)._push(Tc,e,t)}string(t){let e=Io(t);return e!==0?this.uint32(e)._push(Ir,e,t):this._push(Kr,1,0)}fork(){return this.states=new Zr(this),this.head=this.tail=new gt(Hr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new gt(Hr,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Cc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Kr(r,t,e){t[e]=r&255}function Pc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Yr=class extends gt{next;constructor(t,e){super(Pc,t,e),this.next=void 0}};function Gt(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function qt(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Tc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Wt.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Fc,t,r),this},Wt.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Rc,t,r),this});function Fc(r,t,e){t.set(r,e)}function Rc(r,t,e){r.length<40?Ir(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Jo(r),e)}function tn(){return new Wt}function en(r,t){let e=tn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Tt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Tt||(Tt={}));function we(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function rn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,a){let f=t(i);a.int32(f)},n=function(i){let a=i.int32();return t(a)};return we("enum",Tt.VARINT,e,n)}function nn(r,t){return we("message",Tt.LENGTH_DELIMITED,r,t)}var X;(function(r){let t;(function(o){o.UNUSED="UNUSED",o.CONNECT="CONNECT",o.SYNC="SYNC"})(t=r.Type||(r.Type={}));let e;(function(o){o[o.UNUSED=0]="UNUSED",o[o.CONNECT=100]="CONNECT",o[o.SYNC=300]="SYNC"})(e||(e={})),function(o){o.codec=()=>rn(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=nn((o,i,a={})=>{if(a.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.observedAddresses!=null)for(let f of o.observedAddresses)i.uint32(18),i.bytes(f);a.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let a={observedAddresses:[]},f=i==null?o.len:o.pos+i;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:a.type=r.Type.codec().decode(o);break;case 2:a.observedAddresses.push(o.bytes());break;default:o.skipType(l&7);break}}return a})),n),r.encode=o=>en(o,r.codec()),r.decode=o=>Lr(o,r.codec())})(X||(X={}));function Mc(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 i=r.charAt(o),a=i.charCodeAt(0);if(e[a]!==255)throw new TypeError(i+" is ambiguous");e[a]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),w=Math.log(256)/Math.log(f);function b(s){if(s instanceof Uint8Array||(ArrayBuffer.isView(s)?s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Array.isArray(s)&&(s=Uint8Array.from(s))),!(s instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(s.length===0)return"";for(var h=0,u=0,p=0,m=s.length;p!==m&&s[p]===0;)p++,h++;for(var x=(m-p)*w+1>>>0,y=new Uint8Array(x);p!==m;){for(var v=s[p],I=0,A=x-1;(v!==0||I<u)&&A!==-1;A--,I++)v+=256*y[A]>>>0,y[A]=v%f>>>0,v=v/f>>>0;if(v!==0)throw new Error("Non-zero carry");u=I,p++}for(var S=x-u;S!==x&&y[S]===0;)S++;for(var B=l.repeat(h);S<x;++S)B+=r.charAt(y[S]);return B}function g(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;var h=0;if(s[h]!==" "){for(var u=0,p=0;s[h]===l;)u++,h++;for(var m=(s.length-h)*d+1>>>0,x=new Uint8Array(m);s[h];){var y=e[s.charCodeAt(h)];if(y===255)return;for(var v=0,I=m-1;(y!==0||v<p)&&I!==-1;I--,v++)y+=f*x[I]>>>0,x[I]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");p=v,h++}if(s[h]!==" "){for(var A=m-p;A!==m&&x[A]===0;)A++;for(var S=new Uint8Array(u+(m-A)),B=u;A!==m;)S[B++]=x[A++];return S}}}function c(s){var h=g(s);if(h)return h;throw new Error(`Non-${t} character`)}return{encode:b,decodeUnsafe:g,decode:c}}var kc=Mc,Bc=kc,Qo=Bc;var Ap=new Uint8Array(0);var Ho=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var on=class{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")}},sn=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),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 Ko(this,t)}},an=class{constructor(t){this.decoders=t}or(t){return Ko(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ko=(r,t)=>new an({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),cn=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new on(t,e,n),this.decoder=new sn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Zo=({name:r,prefix:t,encode:e,decode:n})=>new cn(r,t,e,n),fn=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Qo(e,t);return Zo({prefix:r,name:t,encode:n,decode:i=>Ho(o(i))})},$c=(r,t,e,n)=>{let o={};for(let w=0;w<t.length;++w)o[t[w]]=w;let i=r.length;for(;r[i-1]==="=";)--i;let a=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let w=0;w<i;++w){let b=o[r[w]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|b,f+=e,f>=8&&(f-=8,a[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return a},Oc=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",a=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],a+=8;a>e;)a-=e,i+=t[o&f>>a];if(a&&(i+=t[o&f<<e-a]),n)for(;i.length*e&7;)i+="=";return i},Xt=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Zo({prefix:t,name:r,encode(o){return Oc(o,n,e)},decode(o){return $c(o,n,e,r)}});var Yo=fn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dp=fn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pp=Xt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tp=Xt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ti=Xt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fp=Xt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zc=r=>r.toString().split("/").slice(1),Jt=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),C=r=>({match:t=>Jt(e=>e===r).match(t),pattern:r}),ye=()=>({match:r=>Jt(t=>typeof t=="string").match(r),pattern:"{string}"}),ei=()=>({match:r=>Jt(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),j=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{Yo.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),be=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{ti.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),H=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),K=(...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},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),P=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function F(...r){function t(o){let i=zc(o);for(let a of r){let f=a.match(i);if(f===!1)return!1;i=f}return i}function e(o){return t(o)!==!1}function n(o){let i=t(o);return i===!1?!1:i.length===0}return{matches:e,exactMatch:n}}var un=P(C("dns4"),ye()),ln=P(C("dns6"),ye()),dn=P(C("dnsaddr"),ye()),ri=P(C("dns"),ye()),Op=F(un),zp=F(ln),Vp=F(dn),ni=F(K(ri,dn,un,ln)),oi=P(C("ip4"),Jt(ie)),ii=P(C("ip6"),Jt(se)),si=K(oi,ii),Qt=K(si,ri,un,ln,dn),_p=F(Qt),jp=F(oi),Gp=F(ii),ai=F(si),ve=P(Qt,C("tcp"),ei()),Ht=P(Qt,C("udp"),ei()),Vc=K(ve,Ht),qp=F(ve),Wp=F(Ht),pn=P(Ht,C("quic")),Ae=P(Ht,C("quic-v1")),_c=K(pn,Ae),Xp=F(pn),Jp=F(Ae),hn=K(Qt,ve,Ht,pn,Ae),ci=K(P(hn,C("ws"),H(j()))),Qp=F(ci),fi=K(P(hn,C("wss"),H(j())),P(hn,C("tls"),C("ws"),H(j()))),Hp=F(fi),hi=P(Vc,C("webrtc-direct"),be(),H(be()),H(j())),Kp=F(hi),ui=P(Ae,C("webtransport"),be(),be(),H(j())),Zp=F(ui),xe=K(ci,fi,P(ve,H(j())),P(_c,H(j())),P(Qt,H(j())),hi,ui,j()),Yp=F(xe),jc=P(xe,C("p2p-circuit"),j()),li=F(jc),Gc=K(P(xe,C("p2p-circuit"),C("webrtc"),j()),P(xe,C("webrtc"),H(j())),C("webrtc")),t0=F(Gc);var xi=De(di(),1);var pi="[a-fA-F\\d:]",ct=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${pi})|(?<=${pi})(?=\\s|$))`:"",J="(?: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}",T="[a-fA-F\\d]{1,4}",Ie=`
3
3
  (?:
4
- (?:${S}:){7}(?:${S}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
- (?:${S}:){6}(?:${G}|:${S}|:)| // 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
- (?:${S}:){5}(?::${G}|(?::${S}){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
- (?:${S}:){4}(?:(?::${S}){0,1}:${G}|(?::${S}){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
- (?:${S}:){3}(?:(?::${S}){0,2}:${G}|(?::${S}){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
- (?:${S}:){2}(?:(?::${S}){0,3}:${G}|(?::${S}){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
- (?:${S}:){1}(?:(?::${S}){0,4}:${G}|(?::${S}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
- (?::(?:(?::${S}){0,5}:${G}|(?::${S}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
4
+ (?:${T}:){7}(?:${T}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
+ (?:${T}:){6}(?:${J}|:${T}|:)| // 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
+ (?:${T}:){5}(?::${J}|(?::${T}){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
+ (?:${T}:){4}(?:(?::${T}){0,1}:${J}|(?::${T}){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
+ (?:${T}:){3}(?:(?::${T}){0,2}:${J}|(?::${T}){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
+ (?:${T}:){2}(?:(?::${T}){0,3}:${J}|(?::${T}){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
+ (?:${T}:){1}(?:(?::${T}){0,4}:${J}|(?::${T}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
+ (?::(?:(?::${T}){0,5}:${J}|(?::${T}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
12
12
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
13
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Es=new RegExp(`(?:^${G}$)|(?:^${ce}$)`),vs=new RegExp(`^${G}$`),Ss=new RegExp(`^${ce}$`),Nr=r=>r&&r.exact?Es:new RegExp(`(?:${nt(r)}${G}${nt(r)})|(?:${nt(r)}${ce}${nt(r)})`,"g");Nr.v4=r=>r&&r.exact?vs:new RegExp(`${nt(r)}${G}${nt(r)}`,"g");Nr.v6=r=>r&&r.exact?Ss:new RegExp(`${nt(r)}${ce}${nt(r)}`,"g");var io=Nr;var uo=de(ao(),1),{isValid:Ls,parse:Ps}=uo.default,Ns=["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"],Us=Ns.map(r=>new fo.Netmask(r));function Ds(r){for(let t of Us)if(t.contains(r))return!0;return!1}function co(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}var lo=r=>{if(Ls(r)){let t=Ps(r);if(t.kind()==="ipv4")return Ds(t.toNormalizedString());if(t.kind()==="ipv6")return co(r)}else if(wt(r)&&io.v6().test(r))return co(r)};var ho=lo;function Ur(r,t){return ro.matches(r)||t.transportForMultiaddr(r)==null?!1:Xn.matches(r)?!0:Kn.matches(r)?ho(r.toOptions().host)===!1:!1}var po=1024*4,mo=100,ue={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},le=class{started;timeout;retries;maxInboundStreams;maxOutboundStreams;peerStore;registrar;connectionManager;addressManager;transportManager;topologyId;log;constructor(t,e){this.log=t.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.transportManager=t.transportManager,this.timeout=e.timeout??ue.timeout,this.retries=e.retries??ue.retries,this.maxInboundStreams=e.maxInboundStreams??ue.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??ue.maxOutboundStreams}isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(At,{notifyOnTransient:!0,onConnect:(t,e)=>{e.transient&&e.direction==="inbound"&&this.upgradeInbound(e).catch(n=>{this.log.error("error during outgoing DCUtR attempt",n)})}}),await this.registrar.handle(At,t=>{this.handleIncomingUpgrade(t.stream,t.connection).catch(e=>{this.log.error("error during incoming DCUtR attempt",e),t.stream.abort(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:!0}),this.started=!0)}async stop(){await this.registrar.unhandle(At),this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async upgradeInbound(t){if(await this.attemptUnilateralConnectionUpgrade(t))return;let e;for(let n=0;n<this.retries;n++){let o={signal:AbortSignal.timeout(this.timeout)};try{e=await t.newStream([At],{signal:o.signal,runOnTransientConnection:!0});let i=sr(e,{maxDataLength:po}).pb(j);this.log("B sending connect to %p",t.remotePeer);let a=Date.now();await i.write({type:j.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(w=>w.bytes)},o),this.log("B receiving connect from %p",t.remotePeer);let f=await i.read(o);if(f.type!==j.Type.CONNECT)throw this.log("A sent wrong message type"),new _("DCUtR message type was incorrect",ot);let d=this.getDialableMultiaddrs(f.observedAddresses);if(d.length===0)throw this.log("A did not have any dialable multiaddrs"),new _("DCUtR connect message had no multiaddrs",ot);let h=Date.now()-a;this.log("A sending sync, rtt %dms",h),await i.write({type:j.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await xn(h/2),this.log("B dialing",d);let b=await this.connectionManager.openConnection(d,{signal:o.signal,priority:mo});this.log("DCUtR to %p succeeded to address %a, closing relayed connection",t.remotePeer,b.remoteAddr),await t.close(o);break}catch(i){if(this.log.error("error while attempting DCUtR on attempt %d of %d",n+1,this.retries,i),e?.abort(i),n===this.retries)throw i}finally{e!=null&&await e.close(o)}}}async attemptUnilateralConnectionUpgrade(t){let n=(await this.peerStore.get(t.remotePeer)).addresses.map(o=>{let i=o.multiaddr;return i.getPeerId()==null?i.encapsulate(`/p2p/${t.remotePeer}`):i}).filter(o=>Ur(o,this.transportManager));if(n.length>0){let o=AbortSignal.timeout(this.timeout);try{this.log("attempting unilateral connection upgrade to %a",n);let i=await this.connectionManager.openConnection(n,{signal:o,force:!0});if(i.transient)throw new Error("Could not open a new, non-transient, connection");return this.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",t.remotePeer,i.remoteAddr),await t.close({signal:o}),!0}catch(i){this.log.error("unilateral connection upgrade to %p on addresses %a failed",t.remotePeer,n,i)}}else this.log("peer %p has no public addresses, not attempting unilateral connection upgrade",t.remotePeer);return!1}async handleIncomingUpgrade(t,e){let n={signal:AbortSignal.timeout(this.timeout)};try{let o=sr(t,{maxDataLength:po}).pb(j);this.log("A receiving connect");let i=await o.read(n);if(i.type!==j.Type.CONNECT)throw this.log("B sent wrong message type"),new _("DCUtR message type was incorrect",ot);if(i.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new _("DCUtR connect message had no multiaddrs",ot);let a=this.getDialableMultiaddrs(i.observedAddresses);if(a.length===0)throw this.log("B had no dialable multiaddrs"),new _("DCUtR connect message had no dialable multiaddrs",ot);if(this.log("A sending connect"),await o.write({type:j.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(h=>h.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==j.Type.SYNC)throw new _("DCUtR message type was incorrect",ot);this.log("A dialing",a);let d=await this.connectionManager.openConnection(a,{signal:n.signal,priority:mo,force:!0});this.log("DCUtR to %p succeeded via %a, closing relayed connection",e.remotePeer,d.remoteAddr),await e.close(n)}catch(o){this.log.error("incoming DCUtR from %p failed",e.remotePeer,o),t.abort(o)}finally{await t.close(n)}}getDialableMultiaddrs(t){let e=[];for(let n of t)if(!(n==null||n.length===0))try{let o=tr(n);if(!Ur(o,this.transportManager))continue;e.push(o)}catch{}return e}};var At="/libp2p/dcutr";function Ts(r={}){return t=>new le(t,r)}return Io(Fs);})();
13
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),qc=new RegExp(`(?:^${J}$)|(?:^${Ie}$)`),Wc=new RegExp(`^${J}$`),Xc=new RegExp(`^${Ie}$`),mn=r=>r&&r.exact?qc:new RegExp(`(?:${ct(r)}${J}${ct(r)})|(?:${ct(r)}${Ie}${ct(r)})`,"g");mn.v4=r=>r&&r.exact?Wc:new RegExp(`${ct(r)}${J}${ct(r)}`,"g");mn.v6=r=>r&&r.exact?Xc:new RegExp(`${ct(r)}${Ie}${ct(r)}`,"g");var mi=mn;var yi=De(wi(),1),{isValid:Jc,parse:Qc}=yi.default,Hc=["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"],Kc=Hc.map(r=>new xi.Netmask(r));function Zc(r){for(let t of Kc)if(t.contains(r))return!0;return!1}function bi(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}var vi=r=>{if(Jc(r)){let t=Qc(r);if(t.kind()==="ipv4")return Zc(t.toNormalizedString());if(t.kind()==="ipv6")return bi(r)}else if(It(r)&&mi.v6().test(r))return bi(r)};var Ai=vi;function gn(r,t){return li.matches(r)||t.transportForMultiaddr(r)==null?!1:ni.matches(r)?!0:ai.matches(r)?Ai(r.toOptions().host)===!1:!1}var Ii=1024*4,Ei=100,Se={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},Le=class{started;timeout;retries;maxInboundStreams;maxOutboundStreams;peerStore;registrar;connectionManager;addressManager;transportManager;topologyId;log;constructor(t,e){this.log=t.logger.forComponent("libp2p:dcutr"),this.started=!1,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.transportManager=t.transportManager,this.timeout=e.timeout??Se.timeout,this.retries=e.retries??Se.retries,this.maxInboundStreams=e.maxInboundStreams??Se.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Se.maxOutboundStreams}isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(Ft,{notifyOnTransient:!0,onConnect:(t,e)=>{e.transient&&e.direction==="inbound"&&this.upgradeInbound(e).catch(n=>{this.log.error("error during outgoing DCUtR attempt",n)})}}),await this.registrar.handle(Ft,t=>{this.handleIncomingUpgrade(t.stream,t.connection).catch(e=>{this.log.error("error during incoming DCUtR attempt",e),t.stream.abort(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:!0}),this.started=!0)}async stop(){await this.registrar.unhandle(Ft),this.topologyId!=null&&this.registrar.unregister(this.topologyId),this.started=!1}async upgradeInbound(t){if(await this.attemptUnilateralConnectionUpgrade(t))return;let e;for(let n=0;n<this.retries;n++){let o={signal:AbortSignal.timeout(this.timeout)};try{e=await t.newStream([Ft],{signal:o.signal,runOnTransientConnection:!0});let i=yr(e,{maxDataLength:Ii}).pb(X);this.log("B sending connect to %p",t.remotePeer);let a=Date.now();await i.write({type:X.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(b=>b.bytes)},o),this.log("B receiving connect from %p",t.remotePeer);let f=await i.read(o);if(f.type!==X.Type.CONNECT)throw this.log("A sent wrong message type"),new G("DCUtR message type was incorrect",ft);let l=this.getDialableMultiaddrs(f.observedAddresses);if(l.length===0)throw this.log("A did not have any dialable multiaddrs"),new G("DCUtR connect message had no multiaddrs",ft);let d=Date.now()-a;this.log("A sending sync, rtt %dms",d),await i.write({type:X.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await io(d/2),this.log("B dialing",l);let w=await this.connectionManager.openConnection(l,{signal:o.signal,priority:Ei});this.log("DCUtR to %p succeeded to address %a, closing relayed connection",t.remotePeer,w.remoteAddr),await t.close(o);break}catch(i){if(this.log.error("error while attempting DCUtR on attempt %d of %d",n+1,this.retries,i),e?.abort(i),n===this.retries)throw i}finally{e!=null&&await e.close(o)}}}async attemptUnilateralConnectionUpgrade(t){let n=(await this.peerStore.get(t.remotePeer)).addresses.map(o=>{let i=o.multiaddr;return i.getPeerId()==null?i.encapsulate(`/p2p/${t.remotePeer}`):i}).filter(o=>gn(o,this.transportManager));if(n.length>0){let o=AbortSignal.timeout(this.timeout);try{this.log("attempting unilateral connection upgrade to %a",n);let i=await this.connectionManager.openConnection(n,{signal:o,force:!0});if(i.transient)throw new Error("Could not open a new, non-transient, connection");return this.log("unilateral connection upgrade to %p succeeded via %a, closing relayed connection",t.remotePeer,i.remoteAddr),await t.close({signal:o}),!0}catch(i){this.log.error("unilateral connection upgrade to %p on addresses %a failed",t.remotePeer,n,i)}}else this.log("peer %p has no public addresses, not attempting unilateral connection upgrade",t.remotePeer);return!1}async handleIncomingUpgrade(t,e){let n={signal:AbortSignal.timeout(this.timeout)};try{let o=yr(t,{maxDataLength:Ii}).pb(X);this.log("A receiving connect");let i=await o.read(n);if(i.type!==X.Type.CONNECT)throw this.log("B sent wrong message type"),new G("DCUtR message type was incorrect",ft);if(i.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new G("DCUtR connect message had no multiaddrs",ft);let a=this.getDialableMultiaddrs(i.observedAddresses);if(a.length===0)throw this.log("B had no dialable multiaddrs"),new G("DCUtR connect message had no dialable multiaddrs",ft);if(this.log("A sending connect"),await o.write({type:X.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(d=>d.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==X.Type.SYNC)throw new G("DCUtR message type was incorrect",ft);this.log("A dialing",a);let l=await this.connectionManager.openConnection(a,{signal:n.signal,priority:Ei,force:!0});this.log("DCUtR to %p succeeded via %a, closing relayed connection",e.remotePeer,l.remoteAddr),await e.close(n)}catch(o){this.log.error("incoming DCUtR from %p failed",e.remotePeer,o),t.abort(o)}finally{await t.close(n)}}getDialableMultiaddrs(t){let e=[];for(let n of t)if(!(n==null||n.length===0))try{let o=pr(n);if(!gn(o,this.transportManager))continue;e.push(o)}catch{}return e}};var Ft="/libp2p/dcutr";function Yc(r={}){return t=>new Le(t,r)}return Ci(tf);})();
14
14
  return Libp2PDcutr}));
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @example
13
13
  *
14
- * ```ts
14
+ * ```TypeScript
15
15
  * import { createLibp2p } from 'libp2p'
16
16
  * import { circuitRelayTransport } from 'libp2p/circuit-relay'
17
17
  * import { tcp } from '@libp2p/tcp'
package/dist/src/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @example
13
13
  *
14
- * ```ts
14
+ * ```TypeScript
15
15
  * import { createLibp2p } from 'libp2p'
16
16
  * import { circuitRelayTransport } from 'libp2p/circuit-relay'
17
17
  * import { tcp } from '@libp2p/tcp'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/dcutr",
3
- "version": "1.0.5-230afea4b",
3
+ "version": "1.0.5-28587d24f",
4
4
  "description": "Implementation of the DCUtR Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-dcutr#readme",
@@ -51,8 +51,8 @@
51
51
  "dep-check": "aegir dep-check"
52
52
  },
53
53
  "dependencies": {
54
- "@libp2p/interface": "1.0.2-230afea4b",
55
- "@libp2p/interface-internal": "1.0.3-230afea4b",
54
+ "@libp2p/interface": "1.0.2-28587d24f",
55
+ "@libp2p/interface-internal": "1.0.3-28587d24f",
56
56
  "@multiformats/multiaddr": "^12.1.10",
57
57
  "@multiformats/multiaddr-matcher": "^1.1.0",
58
58
  "delay": "^6.0.0",
package/src/index.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @example
13
13
  *
14
- * ```ts
14
+ * ```TypeScript
15
15
  * import { createLibp2p } from 'libp2p'
16
16
  * import { circuitRelayTransport } from 'libp2p/circuit-relay'
17
17
  * import { tcp } from '@libp2p/tcp'