@libp2p/dcutr 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.min.js +10 -10
  2. package/package.json +4 -4
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 bo=Object.create;var _t=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var yo=Object.getOwnPropertyNames;var Io=Object.getPrototypeOf,Ao=Object.prototype.hasOwnProperty;var le=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),B=(r,t)=>{for(var e in t)_t(r,e,{get:t[e],enumerable:!0})},Rr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yo(t))!Ao.call(r,o)&&o!==e&&_t(r,o,{get:()=>t[o],enumerable:!(n=xo(t,o))||n.enumerable});return r};var de=(r,t,e)=>(e=r!=null?bo(Io(r)):{},Rr(t||!r||!r.__esModule?_t(e,"default",{value:r,enumerable:!0}):e,r)),vo=r=>Rr(_t({},"__esModule",{value:!0}),r);var Dn=le((Fu,Pn)=>{"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 cs(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)}}Pn.exports=cs});var io=le(Ot=>{(function(){var r,t,e,n,o,i,c,f;f=function(l){var d,b,w,g;return d=(l&255<<24)>>>24,b=(l&255<<16)>>>16,w=(l&65280)>>>8,g=l&255,[d,b,w,g].join(".")},c=function(l){var d,b,w,g,s,a;for(d=[],w=g=0;g<=3&&l.length!==0;w=++g){if(w>0){if(l[0]!==".")throw new Error("Invalid IP");l=l.substring(1)}a=t(l),s=a[0],b=a[1],l=l.substring(b),d.push(s)}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,b,w,g,s;for(g=0,d=10,b="9",w=0,l.length>1&&l[w]==="0"&&(l[w+1]==="x"||l[w+1]==="X"?(w+=2,d=16):"0"<=l[w+1]&&l[w+1]<="9"&&(w++,d=8,b="7")),s=w;w<l.length;){if("0"<=l[w]&&l[w]<=b)g=g*d+(e(l[w])-n)>>>0;else if(d===16)if("a"<=l[w]&&l[w]<="f")g=g*d+(10+e(l[w])-i)>>>0;else if("A"<=l[w]&&l[w]<="F")g=g*d+(10+e(l[w])-o)>>>0;else break;else break;if(g>4294967295)throw new Error("too large");w++}if(w===s)throw new Error("empty octet");return[g,w]},r=function(){function l(d,b){var w,g,s,a;if(typeof d!="string")throw new Error("Missing `net' parameter");if(b||(a=d.split("/",2),d=a[0],b=a[1]),b||(b=32),typeof b=="string"&&b.indexOf(".")>-1){try{this.maskLong=c(b)}catch(u){throw w=u,new Error("Invalid mask: "+b)}for(g=s=32;s>=0;g=--s)if(this.maskLong===4294967295<<32-g>>>0){this.bitmask=g;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=(c(d)&this.maskLong)>>>0}catch(u){throw w=u,new Error("Invalid net address: "+d)}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 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):(c(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 b,w,g;for(g=c(this.first),w=c(this.last),b=0;g<=w;)d(f(g),g,b),b++,g++},l.prototype.toString=function(){return this.base+"/"+this.bitmask},l}(),Ot.ip2long=c,Ot.long2ip=f,Ot.Netmask=r}).call(Ot)});var fo=le((co,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,}",c="(?:[0-9a-f]+::?)+",f={zoneIndex:new RegExp(i,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${i})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${i})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${i})?$`,"i")};function l(s,a){if(s.indexOf("::")!==s.lastIndexOf("::"))return null;let u=0,h=-1,p=(s.match(f.zoneIndex)||[])[0],m,x;for(p&&(p=p.substring(1),s=s.replace(/%.+$/,""));(h=s.indexOf(":",h+1))>=0;)u++;if(s.substr(0,2)==="::"&&u--,s.substr(-2,2)==="::"&&u--,u>a)return null;for(x=a-u,m=":";x--;)m+="0:";return s=s.replace("::",m),s[0]===":"&&(s=s.slice(1)),s[s.length-1]===":"&&(s=s.slice(0,-1)),a=function(){let I=s.split(":"),v=[];for(let L=0;L<I.length;L++)v.push(parseInt(I[L],16));return v}(),{parts:a,zoneId:p}}function d(s,a,u,h){if(s.length!==a.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let p=0,m;for(;h>0;){if(m=u-h,m<0&&(m=0),s[p]>>m!==a[p]>>m)return!1;h-=u,p+=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,a){for(;s.length<a;)s=`0${s}`;return s}let g={};g.IPv4=function(){function s(a){if(a.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let u,h;for(u=0;u<a.length;u++)if(h=a[u],!(0<=h&&h<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=a}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(a,u){let h;if(u===void 0&&(h=a,a=h[0],u=h[1]),a.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return d(this.octets,a.octets,8,u)},s.prototype.prefixLengthFromSubnetMask=function(){let a=0,u=!1,h={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 h){if(x=h[m],u&&x!==0)return null;x!==8&&(u=!0),a+=x}else return null;return 32-a},s.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){return this.octets.slice(0)},s.prototype.toIPv4MappedAddress=function(){return g.IPv6.parse(`::ffff:${this.toString()}`)},s.prototype.toNormalizedString=function(){return this.toString()},s.prototype.toString=function(){return this.octets.join(".")},s}(),g.IPv4.broadcastAddressFromCIDR=function(s){try{let a=this.parseCIDR(s),u=a[0].toByteArray(),h=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],m=0;for(;m<4;)p.push(parseInt(u[m],10)|parseInt(h[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(s){return this.parser(s)!==null},g.IPv4.isValid=function(s){try{return new this(this.parser(s)),!0}catch{return!1}},g.IPv4.isValidFourPartDecimal=function(s){return!!(g.IPv4.isValid(s)&&s.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},g.IPv4.networkAddressFromCIDR=function(s){let a,u,h,p,m;try{for(a=this.parseCIDR(s),h=a[0].toByteArray(),m=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],u=0;u<4;)p.push(parseInt(h[u],10)&parseInt(m[u],10)),u++;return new this(p)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.parse=function(s){let a=this.parser(s);if(a===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(a)},g.IPv4.parseCIDR=function(s){let a;if(a=s.match(/^(.+)\/(\d+)$/)){let u=parseInt(a[2]);if(u>=0&&u<=32){let h=[this.parse(a[1]),u];return Object.defineProperty(h,"toString",{value:function(){return this.join("/")}}),h}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},g.IPv4.parser=function(s){let a,u,h;if(a=s.match(e.fourOctet))return function(){let p=a.slice(1,6),m=[];for(let x=0;x<p.length;x++)u=p[x],m.push(b(u));return m}();if(a=s.match(e.longValue)){if(h=b(a[1]),h>4294967295||h<0)throw new Error("ipaddr: address outside defined range");return function(){let p=[],m;for(m=0;m<=24;m+=8)p.push(h>>m&255);return p}().reverse()}else return(a=s.match(e.twoOctet))?function(){let p=a.slice(1,4),m=[];if(h=b(p[1]),h>16777215||h<0)throw new Error("ipaddr: address outside defined range");return m.push(b(p[0])),m.push(h>>16&255),m.push(h>>8&255),m.push(h&255),m}():(a=s.match(e.threeOctet))?function(){let p=a.slice(1,5),m=[];if(h=b(p[2]),h>65535||h<0)throw new Error("ipaddr: address outside defined range");return m.push(b(p[0])),m.push(b(p[1])),m.push(h>>8&255),m.push(h&255),m}():null},g.IPv4.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>32)throw new Error("ipaddr: invalid IPv4 prefix length");let a=[0,0,0,0],u=0,h=Math.floor(s/8);for(;u<h;)a[u]=255,u++;return h<4&&(a[h]=Math.pow(2,s%8)-1<<8-s%8),new this(a)},g.IPv6=function(){function s(a,u){let h,p;if(a.length===16)for(this.parts=[],h=0;h<=14;h+=2)this.parts.push(a[h]<<8|a[h+1]);else if(a.length===8)this.parts=a;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(h=0;h<this.parts.length;h++)if(p=this.parts[h],!(0<=p&&p<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");u&&(this.zoneId=u)}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(a,u){let h;if(u===void 0&&(h=a,a=h[0],u=h[1]),a.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return d(this.parts,a.parts,16,u)},s.prototype.prefixLengthFromSubnetMask=function(){let a=0,u=!1,h={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 h){if(m=h[p],u&&m!==0)return null;m!==16&&(u=!0),a+=m}else return null;return 128-a},s.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){let a,u=[],h=this.parts;for(let p=0;p<h.length;p++)a=h[p],u.push(a>>8),u.push(a&255);return u},s.prototype.toFixedLengthString=function(){let a=function(){let h=[];for(let p=0;p<this.parts.length;p++)h.push(w(this.parts[p].toString(16),4));return h}.call(this).join(":"),u="";return this.zoneId&&(u=`%${this.zoneId}`),a+u},s.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let a=this.parts.slice(-2),u=a[0],h=a[1];return new g.IPv4([u>>8,u&255,h>>8,h&255])},s.prototype.toNormalizedString=function(){let a=function(){let h=[];for(let p=0;p<this.parts.length;p++)h.push(this.parts[p].toString(16));return h}.call(this).join(":"),u="";return this.zoneId&&(u=`%${this.zoneId}`),a+u},s.prototype.toRFC5952String=function(){let a=/((^|:)(0(:|$)){2,})/g,u=this.toNormalizedString(),h=0,p=-1,m;for(;m=a.exec(u);)m[0].length>p&&(h=m.index,p=m[0].length);return p<0?u:`${u.substring(0,h)}::${u.substring(h+p)}`},s.prototype.toString=function(){return this.toRFC5952String()},s}(),g.IPv6.broadcastAddressFromCIDR=function(s){try{let a=this.parseCIDR(s),u=a[0].toByteArray(),h=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],m=0;for(;m<16;)p.push(parseInt(u[m],10)|parseInt(h[m],10)^255),m++;return new this(p)}catch(a){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${a})`)}},g.IPv6.isIPv6=function(s){return this.parser(s)!==null},g.IPv6.isValid=function(s){if(typeof s=="string"&&s.indexOf(":")===-1)return!1;try{let a=this.parser(s);return new this(a.parts,a.zoneId),!0}catch{return!1}},g.IPv6.networkAddressFromCIDR=function(s){let a,u,h,p,m;try{for(a=this.parseCIDR(s),h=a[0].toByteArray(),m=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],u=0;u<16;)p.push(parseInt(h[u],10)&parseInt(m[u],10)),u++;return new this(p)}catch(x){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${x})`)}},g.IPv6.parse=function(s){let a=this.parser(s);if(a.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(a.parts,a.zoneId)},g.IPv6.parseCIDR=function(s){let a,u,h;if((u=s.match(/^(.+)\/(\d+)$/))&&(a=parseInt(u[2]),a>=0&&a<=128))return h=[this.parse(u[1]),a],Object.defineProperty(h,"toString",{value:function(){return this.join("/")}}),h;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},g.IPv6.parser=function(s){let a,u,h,p,m,x;if(h=s.match(f.deprecatedTransitional))return this.parser(`::ffff:${h[1]}`);if(f.native.test(s))return l(s,8);if((h=s.match(f.transitional))&&(x=h[6]||"",a=l(h[1].slice(0,-1)+x,6),a.parts)){for(m=[parseInt(h[2]),parseInt(h[3]),parseInt(h[4]),parseInt(h[5])],u=0;u<m.length;u++)if(p=m[u],!(0<=p&&p<=255))return null;return a.parts.push(m[0]<<8|m[1]),a.parts.push(m[2]<<8|m[3]),{parts:a.parts,zoneId:a.zoneId}}return null},g.IPv6.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>128)throw new Error("ipaddr: invalid IPv6 prefix length");let a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=0,h=Math.floor(s/8);for(;u<h;)a[u]=255,u++;return h<16&&(a[h]=Math.pow(2,s%8)-1<<8-s%8),new this(a)},g.fromByteArray=function(s){let a=s.length;if(a===4)return new g.IPv4(s);if(a===16)return new g.IPv6(s);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},g.isValid=function(s){return g.IPv6.isValid(s)||g.IPv4.isValid(s)},g.parse=function(s){if(g.IPv6.isValid(s))return g.IPv6.parse(s);if(g.IPv4.isValid(s))return g.IPv4.parse(s);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},g.parseCIDR=function(s){try{return g.IPv6.parseCIDR(s)}catch{try{return g.IPv4.parseCIDR(s)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},g.process=function(s){let a=this.parse(s);return a.kind()==="ipv6"&&a.isIPv4MappedAddress()?a.toIPv4Address():a},g.subnetMatch=function(s,a,u){let h,p,m,x;u==null&&(u="unicast");for(p in a)if(Object.prototype.hasOwnProperty.call(a,p)){for(m=a[p],m[0]&&!(m[0]instanceof Array)&&(m=[m]),h=0;h<m.length;h++)if(x=m[h],s.kind()===x[0].kind()&&s.match.apply(s,x))return p}return u},typeof fe<"u"&&fe.exports?fe.exports=g:r.ipaddr=g})(co)});var Os={};B(Os,{dcutr:()=>Bs,multicodec:()=>At});var Vs=Symbol.for("@libp2p/connection");var js=Symbol.for("@libp2p/content-routing");var qs=Symbol.for("@libp2p/peer-discovery");var Js=Symbol.for("@libp2p/peer-id");var Hs=Symbol.for("@libp2p/peer-routing");var Tr;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Tr||(Tr={}));var ta=Symbol.for("@libp2p/transport");var Cr;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Cr||(Cr={}));var V=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var it="ERR_INVALID_MESSAGE";var pe=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},na=globalThis.CustomEvent??pe;var xe={};B(xe,{base58btc:()=>k,base58flickr:()=>Po});var Ta=new Uint8Array(0);function kr(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 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")}function $r(r){return new TextEncoder().encode(r)}function Mr(r){return new TextDecoder().decode(r)}function Eo(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),c=i.charCodeAt(0);if(e[c]!==255)throw new TypeError(i+" is ambiguous");e[c]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function w(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,h=0,p=0,m=a.length;p!==m&&a[p]===0;)p++,u++;for(var x=(m-p)*b+1>>>0,I=new Uint8Array(x);p!==m;){for(var v=a[p],L=0,E=x-1;(v!==0||L<h)&&E!==-1;E--,L++)v+=256*I[E]>>>0,I[E]=v%f>>>0,v=v/f>>>0;if(v!==0)throw new Error("Non-zero carry");h=L,p++}for(var D=x-h;D!==x&&I[D]===0;)D++;for(var Q=l.repeat(u);D<x;++D)Q+=r.charAt(I[D]);return Q}function g(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var h=0,p=0;a[u]===l;)h++,u++;for(var m=(a.length-u)*d+1>>>0,x=new Uint8Array(m);a[u];){var I=e[a.charCodeAt(u)];if(I===255)return;for(var v=0,L=m-1;(I!==0||v<p)&&L!==-1;L--,v++)I+=f*x[L]>>>0,x[L]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");p=v,u++}if(a[u]!==" "){for(var E=m-p;E!==m&&x[E]===0;)E++;for(var D=new Uint8Array(h+(m-E)),Q=h;E!==m;)D[Q++]=x[E++];return D}}}function s(a){var u=g(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:g,decode:s}}var So=Eo,Lo=So,Or=Lo;var me=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")}},ge=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 _r(this,t)}},we=class{decoders;constructor(t){this.decoders=t}or(t){return _r(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 _r(r,t){return new we({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var be=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 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)}};function ht({name:r,prefix:t,encode:e,decode:n}){return new be(r,t,e,n)}function tt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Or(e,r);return ht({prefix:t,name:r,encode:n,decode:i=>H(o(i))})}function Uo(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 c=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let b=0;b<i;++b){let w=o[r[b]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|w,f+=e,f>=8&&(f-=8,c[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return c}function No(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",c=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],c+=8;c>e;)c-=e,i+=t[o&f>>c];if(c!==0&&(i+=t[o&f<<e-c]),n)for(;i.length*e&7;)i+="=";return i}function S({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ht({prefix:t,name:r,encode(o){return No(o,n,e)},decode(o){return Uo(o,n,e,r)}})}var k=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Po=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ye={};B(ye,{base32:()=>Z,base32hex:()=>To,base32hexpad:()=>ko,base32hexpadupper:()=>$o,base32hexupper:()=>Co,base32pad:()=>Fo,base32padupper:()=>Ro,base32upper:()=>Do,base32z:()=>Mo});var Z=S({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Do=S({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fo=S({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ro=S({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),To=S({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Co=S({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ko=S({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$o=S({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Mo=S({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bo=jr,Vr=128,Oo=127,_o=~Oo,Vo=Math.pow(2,31);function jr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Vo;)t[e++]=r&255|Vr,r/=128;for(;r&_o;)t[e++]=r&255|Vr,r>>>=7;return t[e]=r|0,jr.bytes=e-n+1,t}var zo=Ie,jo=128,zr=127;function Ie(r,n){var e=0,n=n||0,o=0,i=n,c,f=r.length;do{if(i>=f)throw Ie.bytes=0,new RangeError("Could not decode varint");c=r[i++],e+=o<28?(c&zr)<<o:(c&zr)*Math.pow(2,o),o+=7}while(c>=jo);return Ie.bytes=i-n,e}var Go=Math.pow(2,7),Wo=Math.pow(2,14),qo=Math.pow(2,21),Xo=Math.pow(2,28),Jo=Math.pow(2,35),Qo=Math.pow(2,42),Ho=Math.pow(2,49),Zo=Math.pow(2,56),Ko=Math.pow(2,63),Yo=function(r){return r<Go?1:r<Wo?2:r<qo?3:r<Xo?4:r<Jo?5:r<Qo?6:r<Ho?7:r<Zo?8:r<Ko?9:10},ti={encode:Bo,decode:zo,encodingLength:Yo},ei=ti,vt=ei;function Et(r,t=0){return[vt.decode(r,t),vt.decode.bytes]}function lt(r,t,e=0){return vt.encode(r,t,e),t}function dt(r){return vt.encodingLength(r)}function st(r,t){let e=t.byteLength,n=dt(r),o=n+dt(e),i=new Uint8Array(o+e);return lt(r,i,0),lt(e,i,n),i.set(t,o),new pt(r,e,t,i)}function zt(r){let t=H(r),[e,n]=Et(t),[o,i]=Et(t.subarray(n)),c=t.subarray(n+i);if(c.byteLength!==o)throw new Error("Incorrect length");return new pt(e,o,c,t)}function Gr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&kr(r.bytes,e.bytes)}}var pt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Wr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ni(e,Ae(r),t??k.encoder);default:return oi(e,Ae(r),t??Z.encoder)}}var qr=new WeakMap;function Ae(r){let t=qr.get(r);if(t==null){let e=new Map;return qr.set(r,e),e}return t}var et=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!==St)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ii)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=st(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Gr(t.multihash,n.multihash)}toString(t){return Wr(this,t)}toJSON(){return{"/":Wr(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:c}=e;return new r(n,o,i,c??Xr(n,o,i.bytes))}else if(e[si]===!0){let{version:n,multihash:o,code:i}=e,c=zt(o);return r.create(n,i,c)}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=Xr(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!==0)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),c=new pt(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,g]=Et(t.subarray(e));return e+=g,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 c=e,f=n(),l=n(),d=e+l,b=d-c;return{version:o,codec:i,multihashCode:f,digestSize:l,multihashSize:b,size:d}}static parse(t,e){let[n,o]=ri(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}};function ri(r,t){switch(r[0]){case"Q":{let e=t??k;return[k.prefix,e.decode(`${k.prefix}${r}`)]}case k.prefix:{let e=t??k;return[k.prefix,e.decode(r)]}case Z.prefix:{let e=t??Z;return[Z.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 ni(r,t,e){let{prefix:n}=e;if(n!==k.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 oi(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 St=112,ii=18;function Xr(r,t,e){let n=dt(r),o=n+dt(t),i=new Uint8Array(o+e.byteLength);return lt(r,i,0),lt(t,i,n),i.set(e,o),i}var si=Symbol.for("@ipld/js-cid/CID");function Jr(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 ve={};B(ve,{base10:()=>ai});var ai=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var Ee={};B(Ee,{base16:()=>ci,base16upper:()=>fi});var ci=S({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fi=S({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Se={};B(Se,{base2:()=>ui});var ui=S({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Le={};B(Le,{base256emoji:()=>mi});var Qr=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}"),hi=Qr.reduce((r,t,e)=>(r[e]=t,r),[]),li=Qr.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function di(r){return r.reduce((t,e)=>(t+=hi[e],t),"")}function pi(r){let t=[];for(let e of r){let n=li[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var mi=ht({prefix:"\u{1F680}",name:"base256emoji",encode:di,decode:pi});var Ue={};B(Ue,{base36:()=>gi,base36upper:()=>wi});var gi=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),wi=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ne={};B(Ne,{base64:()=>bi,base64pad:()=>xi,base64url:()=>yi,base64urlpad:()=>Ii});var bi=S({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xi=S({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),yi=S({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ii=S({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pe={};B(Pe,{base8:()=>Ai});var Ai=S({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var De={};B(De,{identity:()=>vi});var vi=ht({prefix:"\0",name:"identity",encode:r=>Mr(r),decode:r=>$r(r)});var oc=new TextEncoder,ic=new TextDecoder;var Fe={};B(Fe,{identity:()=>Ni});var Hr=0,Li="identity",Zr=H;function Ui(r){return st(Hr,Zr(r))}var Ni={code:Hr,name:Li,encode:Zr,digest:Ui};var Ce={};B(Ce,{sha256:()=>Pi,sha512:()=>Di});function Te({name:r,code:t,encode:e}){return new Re(r,t,e)}var Re=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?st(this.code,e):e.then(n=>st(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Yr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Pi=Te({name:"sha2-256",code:18,encode:Yr("SHA-256")}),Di=Te({name:"sha2-512",code:19,encode:Yr("SHA-512")});var Lt={...De,...Se,...Pe,...ve,...Ee,...ye,...Ue,...xe,...Ne,...Le},bc={...Ce,...Fe};function at(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function z(r=0){return globalThis.Buffer?.allocUnsafe!=null?at(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function en(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var tn=en("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ke=en("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}),Fi={utf8:tn,"utf-8":tn,hex:Lt.base16,latin1:ke,ascii:ke,binary:ke,...Lt},jt=Fi;function $(r,t="utf8"){let e=jt[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)}var Ri=Math.pow(2,7),Ti=Math.pow(2,14),Ci=Math.pow(2,21),$e=Math.pow(2,28),Me=Math.pow(2,35),Be=Math.pow(2,42),Oe=Math.pow(2,49),y=128,R=127;function T(r){if(r<Ri)return 1;if(r<Ti)return 2;if(r<Ci)return 3;if(r<$e)return 4;if(r<Me)return 5;if(r<Be)return 6;if(r<Oe)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ki(r,t,e=0){switch(T(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 $i(r,t,e=0){switch(T(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 Mi(r,t){let e=r[t],n=0;if(n+=e&R,e<y||(e=r[t+1],n+=(e&R)<<7,e<y)||(e=r[t+2],n+=(e&R)<<14,e<y)||(e=r[t+3],n+=(e&R)<<21,e<y)||(e=r[t+4],n+=(e&R)*$e,e<y)||(e=r[t+5],n+=(e&R)*Me,e<y)||(e=r[t+6],n+=(e&R)*Be,e<y)||(e=r[t+7],n+=(e&R)*Oe,e<y))return n;throw new RangeError("Could not decode varint")}function Bi(r,t){let e=r.get(t),n=0;if(n+=e&R,e<y||(e=r.get(t+1),n+=(e&R)<<7,e<y)||(e=r.get(t+2),n+=(e&R)<<14,e<y)||(e=r.get(t+3),n+=(e&R)<<21,e<y)||(e=r.get(t+4),n+=(e&R)*$e,e<y)||(e=r.get(t+5),n+=(e&R)*Me,e<y)||(e=r.get(t+6),n+=(e&R)*Be,e<y)||(e=r.get(t+7),n+=(e&R)*Oe,e<y))return n;throw new RangeError("Could not decode varint")}function rt(r,t,e=0){return t==null&&(t=z(T(r))),t instanceof Uint8Array?ki(r,t,e):$i(r,t,e)}function j(r,t=0){return r instanceof Uint8Array?Mi(r,t):Bi(r,t)}function K(r,t){if(globalThis.Buffer!=null)return at(globalThis.Buffer.concat(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 at(e)}var Gt=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,c=0,f=this.peekChar();if(f===void 0)return;let l=f==="0",d=2**(8*o)-1;for(;;){let b=this.readAtomically(()=>{let w=this.readChar();if(w===void 0)return;let g=Number.parseInt(w,t);if(!Number.isNaN(g))return g});if(b===void 0)break;if(i*=t,i+=b,i>d||(c+=1,e!==void 0&&c>e))return}if(c!==0)return!n&&l&&c>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 c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return e[o]=c[0],e[o+1]=c[1],e[o+2]=c[2],e[o+3]=c[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),c=16-(n+2),[f]=t(i.subarray(0,c));return e.set(i.subarray(0,f),16-f),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var rn=45,Oi=15,gt=new Gt;function _e(r){if(!(r.length>Oi))return gt.new(r).parseWith(()=>gt.readIPv4Addr())}function Ve(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>rn))return gt.new(r).parseWith(()=>gt.readIPv6Addr())}function Wt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>rn))return gt.new(r).parseWith(()=>gt.readIPAddr())}var Vc=parseInt("0xFFFF",16),zc=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Nt(r,t="utf8"){let e=jt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?at(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function qt(r){return!!_e(r)}function Xt(r){return!!Ve(r)}function wt(r){return!!Wt(r)}var sn=qt,Gi=Xt,ze=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(Gi(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=sn(e[n]),c;i&&(c=ze(e[n]),e[n]=$(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,$(c.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={},je={},qi=[[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"]];qi.forEach(r=>{let t=Xi(...r);je[t.code]=t,bt[t.name]=t});function Xi(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function A(r){if(typeof r=="number"){if(je[r]!=null)return je[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 Pf=A("ip4"),Df=A("ip6"),Ff=A("ipcidr");function We(r,t){switch(A(r).code){case 4:case 41:return Qi(t);case 42:return un(t);case 6:case 273:case 33:case 132:return ln(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return un(t);case 421:return Yi(t);case 444:return hn(t);case 445:return hn(t);case 466:return Ki(t);default:return $(t,"base16")}}function qe(r,t){switch(A(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 Xe(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fn(t);case 421:return Hi(t);case 444:return ts(t);case 445:return es(t);case 466:return Zi(t);default:return Nt(t,"base16")}}var Ge=Object.values(Lt).map(r=>r.decoder),Ji=function(){let r=Ge[0].or(Ge[1]);return Ge.slice(2).forEach(t=>r=r.or(t)),r}();function cn(r){if(!wt(r))throw new Error("invalid ip address");return ze(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 Xe(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function ln(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function fn(r){let t=Nt(r),e=Uint8Array.from(rt(t.length));return K([e,t],e.length+t.length)}function un(r){let t=j(r);if(r=r.slice(T(t)),r.length!==t)throw new Error("inconsistent lengths");return $(r)}function Hi(r){let t;r[0]==="Q"||r[0]==="1"?t=zt(k.decode(`z${r}`)).bytes:t=et.parse(r).multihash.bytes;let e=Uint8Array.from(rt(t.length));return K([e,t],e.length+t.length)}function Zi(r){let t=Ji.decode(r),e=Uint8Array.from(rt(t.length));return K([e,t],e.length+t.length)}function Ki(r){let t=j(r),e=r.slice(T(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+$(e,"base64url")}function Yi(r){let t=j(r),e=r.slice(T(t));if(e.length!==t)throw new Error("inconsistent lengths");return $(e,"base58btc")}function ts(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=Z.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=Xe(n);return K([e,o],e.length+o.length)}function es(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=Z.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=Xe(n);return K([e,o],e.length+o.length)}function hn(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=$(t,"base32"),o=ln(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 c=o[i],f=A(c);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,qe(f.code,n)]),e.push([f.code,n]);break}let l=qe(f.code,o[i]);t.push([f.code,l]),e.push([f.code,We(f.code,l)])}return{string:pn(e),bytes:He(t),tuples:t,stringTuples:e,path:n}}function Qe(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=j(r,o),c=T(i),f=A(i),l=rs(f,r.slice(o+c));if(l===0){t.push([i]),e.push([i]),o+=c;continue}let d=r.slice(o+c,o+c+l);if(o+=l+c,o>r.length)throw mn("Invalid address Uint8Array: "+$(r,"base16"));t.push([i,d]);let b=We(i,d);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=A(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Je(t.join("/"))}function He(r){return K(r.map(t=>{let e=A(t[0]),n=Uint8Array.from(rt(e.code));return t.length>1&&t[1]!=null&&(n=K([n,t[1]])),n}))}function rs(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=j(t instanceof Uint8Array?t:Uint8Array.from(t));return e+T(e)}}function Je(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function mn(r){return new Error("Error parsing address: "+r)}var ns=Symbol.for("nodejs.util.inspect.custom"),Ze=Symbol.for("@multiformats/js-multiaddr/multiaddr"),os=[A("dns").code,A("dns4").code,A("dns6").code,A("dnsaddr").code],Jt=class r{bytes;#e;#t;#r;#n;[Ze]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Qe(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=Qe(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="",c=A("tcp"),f=A("udp"),l=A("ip4"),d=A("ip6"),b=A("dns6"),w=A("ip6zone");for(let[s,a]of this.stringTuples())s===w.code&&(i=`%${a??""}`),os.includes(s)&&(e=c.name,o=443,n=`${a??""}${i}`,t=s===b.code?6:4),(s===c.code||s===f.code)&&(e=A(s).name,o=parseInt(a??"")),(s===l.code||s===d.code)&&(e=A(s).name,n=`${a??""}${i}`,t=s===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({},A(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>A(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(He(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"?$(k.decode(`z${n}`),"base58btc"):$(et.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Jr(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 V(`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)}[ns](){return`Multiaddr(${this.#e})`}};var gn=new Map;function wn(r){return!!r?.[Ze]}function Ke(r){return new Jt(r)}var bn=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},is=new WeakMap;function ss({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(bn());let i,c,f,l=r??clearTimeout,d=()=>{l(i),f(bn())},b=()=>{o&&o.removeEventListener("abort",d)},w=new Promise((g,s)=>{c=()=>{b(),g(n)},f=s,i=(t??setTimeout)(c,e)});return o&&o.addEventListener("abort",d,{once:!0}),is.set(w,()=>{l(i),i=null,c()}),w}}var as=ss(),xn=as;function Pt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Y(r=0){return globalThis.Buffer?.alloc!=null?Pt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Dt(r=0){return globalThis.Buffer?.allocUnsafe!=null?Pt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Ye(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Dt(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 Qt(r){return!!r?.[An]}var O=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(Qt(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(Qt(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(Qt(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 Ye(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Ye(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 c=this.bufs[i],f=o,l=f+c.byteLength;if(o=l,t>=l)continue;let d=t>=f&&t<l,b=e>f&&e<=l;if(d&&b){if(t===f&&e===l){n.push(c);break}let w=t-f;n.push(c.subarray(w,w+(e-t)));break}if(d){if(t===0){n.push(c);continue}n.push(c.subarray(t-f));continue}if(b){if(e===l){n.push(c);break}n.push(c.subarray(0,e-f));break}n.push(c)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Qt(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,c=new Int32Array(i);for(let w=0;w<i;w++)c[w]=-1;for(let w=0;w<o;w++)c[n[w]]=w;let f=c,l=this.byteLength-n.byteLength,d=n.byteLength-1,b;for(let w=e;w<=l;w+=b){b=0;for(let g=d;g>=0;g--){let s=this.get(w+g);if(n[g]!==s){b=Math.max(1,g-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=Dt(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=Y(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=Y(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=Y(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=Dt(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=Y(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=Y(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=Y(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=Y(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=Y(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 Ht=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 vn(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Ht(e?.errorMessage,e?.errorCode));let n,o=new Ht(e?.errorMessage,e?.errorCode);try{return await Promise.race([r,new Promise((i,c)=>{n=()=>{c(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var tr=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 vn(this.needNext.promise,e?.signal,e)}};function En(){return new tr}var Zt=class extends Error{code;constructor(t,e){super(t),this.code=e}},er=class extends Zt{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted"}};function Sn(r,t){let e=En();r.sink(e).catch(async c=>{await e.end(c)}),r.sink=async c=>{for await(let f of c)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 O;return{read:async(c,f)=>{f?.signal?.throwIfAborted();let l,d=new Promise((b,w)=>{l=()=>{w(new er("Read aborted"))},f?.signal?.addEventListener("abort",l)});try{if(c==null){let{done:w,value:g}=await Promise.race([n.next(),d]);return w===!0?new O:g}for(;o.byteLength<c;){let{value:w,done:g}=await Promise.race([n.next(),d]);if(g===!0)throw new Zt("unexpected end of input","ERR_UNEXPECTED_EOF");o.append(w)}let b=o.sublist(0,c);return o.consume(c),b}finally{l!=null&&f?.signal?.removeEventListener("abort",l)}},write:async(c,f)=>{f?.signal?.throwIfAborted(),c instanceof Uint8Array?await e.push(c,f):await e.push(c.subarray(),f)},unwrap:()=>{if(o.byteLength>0){let c=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*c}()}return r}}}function Ln(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Un(r=0){return globalThis.Buffer?.allocUnsafe!=null?Ln(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Kt(r){return r[Symbol.asyncIterator]!=null}var Yt=r=>{let t=T(r),e=Un(t);return rt(r,e),Yt.bytes=t,e};Yt.bytes=0;function Ft(r,t){t=t??{};let e=t.lengthEncoder??Yt;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)}()}Ft.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Yt;return new O(e(r.byteLength),r)};var yt=de(Dn(),1);var fs=8,us=1024*1024*4,ct;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(ct||(ct={}));var nr=r=>{let t=j(r);return nr.bytes=T(t),t};nr.bytes=0;function rr(r,t){let e=new O,n=ct.LENGTH,o=-1,i=t?.lengthDecoder??nr,c=t?.maxLengthLength??fs,f=t?.maxDataLength??us;function*l(){for(;e.byteLength>0;){if(n===ct.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 d=i.bytes;e.consume(d),t?.onLength!=null&&t.onLength(o),n=ct.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>c)throw(0,yt.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===ct.DATA){if(e.byteLength<o)break;let d=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(d),yield d,n=ct.LENGTH}}}return Kt(r)?async function*(){for await(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,yt.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,yt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}rr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:c}=await r.next(e);if(i===!0)return;c!=null&&(yield c)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return rr(n,{...t??{},onLength:i=>{e=i}})};var te=class extends Error{code;constructor(t,e){super(t),this.code=e}},Fn=r=>j(r);Fn.bytes=0;function Rn(r,t={}){let e=Sn(r,t);return t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=T(t.maxDataLength)),{read:async o=>{let i=-1,c=new O,f=t?.lengthDecoder??Fn;for(;;){c.append(await e.read(1,o));try{i=f(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new te("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(i>-1)break}if(t?.maxDataLength!=null&&i>t.maxDataLength)throw new te("message length too long","ERR_MSG_DATA_TOO_LONG");return e.read(i,o)},write:async(o,i)=>{await e.write(Ft.single(o,t),i)},writeV:async(o,i)=>{let c=new O(...o.map(f=>Ft.single(f,t)));await e.write(c,i)},unwrap:()=>e.unwrap()}}function or(r,t){let e=Rn(r,t),n={read:async(o,i)=>{let c=await e.read(i);return o.decode(c)},write:async(o,i,c)=>{await e.write(i.encode(o),c)},writeV:async(o,i,c)=>{await e.writeV(o.map(f=>i.encode(f)),c)},pb:o=>({read:async i=>n.read(o,i),write:async(i,c)=>n.write(i,o,c),writeV:async(i,c)=>n.writeV(i,o,c),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var ir=new Float32Array([-0]),nt=new Uint8Array(ir.buffer);function Tn(r,t,e){ir[0]=r,t[e]=nt[0],t[e+1]=nt[1],t[e+2]=nt[2],t[e+3]=nt[3]}function Cn(r,t){return nt[0]=r[t],nt[1]=r[t+1],nt[2]=r[t+2],nt[3]=r[t+3],ir[0]}var sr=new Float64Array([-0]),C=new Uint8Array(sr.buffer);function kn(r,t,e){sr[0]=r,t[e]=C[0],t[e+1]=C[1],t[e+2]=C[2],t[e+3]=C[3],t[e+4]=C[4],t[e+5]=C[5],t[e+6]=C[6],t[e+7]=C[7]}function $n(r,t){return C[0]=r[t],C[1]=r[t+1],C[2]=r[t+2],C[3]=r[t+3],C[4]=r[t+4],C[5]=r[t+5],C[6]=r[t+6],C[7]=r[t+7],sr[0]}var ls=BigInt(Number.MAX_SAFE_INTEGER),ds=BigInt(Number.MIN_SAFE_INTEGER),M=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 ft;if(t<ls&&t>ds)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>Mn&&(o=0n,++n>Mn&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ft;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):ft}},ft=new M(0,0);ft.toBigInt=function(){return 0n};ft.zzEncode=ft.zzDecode=function(){return this};ft.length=function(){return 1};var Mn=4294967296n;function Bn(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=[],c=0,f;for(;t<e;)f=r[t++],f<128?i[c++]=f:f>191&&f<224?i[c++]=(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[c++]=55296+(f>>10),i[c++]=56320+(f&1023)):i[c++]=(f&15)<<12|(r[t++]&63)<<6|r[t++]&63,c>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),c=0);return o!=null?(c>0&&o.push(String.fromCharCode.apply(String,i.slice(0,c))),o.join("")):String.fromCharCode.apply(String,i.slice(0,c))}function ar(r,t,e){let n=e,o,i;for(let c=0;c<r.length;++c)o=r.charCodeAt(c),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(c+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++c,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 G(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ee(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var cr=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,G(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 G(this,4);return ee(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw G(this,4);return ee(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw G(this,4);let t=Cn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw G(this,4);let t=$n(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 G(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 G(this,t);this.pos+=t}else do if(this.pos>=this.len)throw G(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 M(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 G(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 G(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 G(this,8);let t=ee(this.buf,this.pos+=4),e=ee(this.buf,this.pos+=4);return new M(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 fr(r){return new cr(r instanceof Uint8Array?r:r.subarray())}function ur(r,t){let e=fr(r);return t.decode(e)}function hr(r){let t=r??8192,e=t>>>1,n,o=t;return function(c){if(c<1||c>e)return z(c);o+c>t&&(n=z(t),o=0);let f=n.subarray(o,o+=c);return o&7&&(o=(o|7)+1),f}}var ut=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function lr(){}var pr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ps=hr();function ms(r){return globalThis.Buffer!=null?z(r):ps(r)}var Ct=class{len;head;tail;states;constructor(){this.len=0,this.head=new ut(lr,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ut(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new mr((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(Rt,10,M.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=M.fromBigInt(t);return this._push(Rt,e.length(),e)}uint64Number(t){let e=M.fromNumber(t);return this._push(Rt,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=M.fromBigInt(t).zzEncode();return this._push(Rt,e.length(),e)}sint64Number(t){let e=M.fromNumber(t).zzEncode();return this._push(Rt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(dr,1,t?1:0)}fixed32(t){return this._push(Tt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=M.fromBigInt(t);return this._push(Tt,4,e.lo)._push(Tt,4,e.hi)}fixed64Number(t){let e=M.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(Tn,4,t)}double(t){return this._push(kn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(dr,1,0):this.uint32(e)._push(ws,e,t)}string(t){let e=Bn(t);return e!==0?this.uint32(e)._push(ar,e,t):this._push(dr,1,0)}fork(){return this.states=new pr(this),this.head=this.tail=new ut(lr,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 ut(lr,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=ms(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function dr(r,t,e){t[e]=r&255}function gs(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var mr=class extends ut{next;constructor(t,e){super(gs,t,e),this.next=void 0}};function Rt(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 ws(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ct.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(bs,t,r),this},Ct.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(xs,t,r),this});function bs(r,t,e){t.set(r,e)}function xs(r,t,e){r.length<40?ar(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Nt(r),e)}function gr(){return new Ct}function wr(r,t){let e=gr();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 br(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)};return re("enum",It.VARINT,e,n)}function xr(r,t){return re("message",It.LENGTH_DELIMITED,r,t)}var W;(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=()=>br(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=xr((o,i,c={})=>{if(c.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);c.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let c={observedAddresses:[]},f=i==null?o.len:o.pos+i;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.observedAddresses.push(o.bytes());break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>wr(o,r.codec()),r.decode=o=>ur(o,r.codec())})(W||(W={}));function ys(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),c=i.charCodeAt(0);if(e[c]!==255)throw new TypeError(i+" is ambiguous");e[c]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function w(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,h=0,p=0,m=a.length;p!==m&&a[p]===0;)p++,u++;for(var x=(m-p)*b+1>>>0,I=new Uint8Array(x);p!==m;){for(var v=a[p],L=0,E=x-1;(v!==0||L<h)&&E!==-1;E--,L++)v+=256*I[E]>>>0,I[E]=v%f>>>0,v=v/f>>>0;if(v!==0)throw new Error("Non-zero carry");h=L,p++}for(var D=x-h;D!==x&&I[D]===0;)D++;for(var Q=l.repeat(u);D<x;++D)Q+=r.charAt(I[D]);return Q}function g(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var h=0,p=0;a[u]===l;)h++,u++;for(var m=(a.length-u)*d+1>>>0,x=new Uint8Array(m);a[u];){var I=e[a.charCodeAt(u)];if(I===255)return;for(var v=0,L=m-1;(I!==0||v<p)&&L!==-1;L--,v++)I+=f*x[L]>>>0,x[L]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");p=v,u++}if(a[u]!==" "){for(var E=m-p;E!==m&&x[E]===0;)E++;for(var D=new Uint8Array(h+(m-E)),Q=h;E!==m;)D[Q++]=x[E++];return D}}}function s(a){var u=g(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:g,decode:s}}var Is=ys,As=Is,Vn=As;var yh=new Uint8Array(0);var zn=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 yr=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")}},Ir=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 jn(this,t)}},Ar=class{constructor(t){this.decoders=t}or(t){return jn(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`)}},jn=(r,t)=>new Ar({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),vr=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new yr(t,e,n),this.decoder=new Ir(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Gn=({name:r,prefix:t,encode:e,decode:n})=>new vr(r,t,e,n),Er=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=Vn(e,t);return Gn({prefix:r,name:t,encode:n,decode:i=>zn(o(i))})},vs=(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 c=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let b=0;b<i;++b){let w=o[r[b]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|w,f+=e,f>=8&&(f-=8,c[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return c},Es=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",c=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],c+=8;c>e;)c-=e,i+=t[o&f>>c];if(c&&(i+=t[o&f<<e-c]),n)for(;i.length*e&7;)i+="=";return i},kt=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Gn({prefix:t,name:r,encode(o){return Es(o,n,e)},decode(o){return vs(o,n,e,r)}});var Wn=Er({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lh=Er({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ph=kt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Dh=kt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qn=kt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fh=kt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ss=r=>r.toString().split("/").slice(1),$t=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),U=r=>({match:t=>$t(e=>e===r).match(t),pattern:r}),ie=()=>({match:r=>$t(t=>typeof t=="string").match(r),pattern:"{string}"}),Xn=()=>({match:r=>$t(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),_=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{Wn.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{qn.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),X=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),J=(...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(", ")})`}),N=(...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=Ss(o);for(let c of r){let f=c.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 Lr=N(U("dns4"),ie()),Ur=N(U("dns6"),ie()),Nr=N(U("dnsaddr"),ie()),Jn=N(U("dns"),ie()),Mh=F(Lr),Bh=F(Ur),Oh=F(Nr),Qn=F(J(Jn,Nr,Lr,Ur)),Hn=N(U("ip4"),$t(qt)),Zn=N(U("ip6"),$t(Xt)),Kn=J(Hn,Zn),Mt=J(Kn,Jn,Lr,Ur,Nr),_h=F(Mt),Vh=F(Hn),zh=F(Zn),Yn=F(Kn),se=N(Mt,U("tcp"),Xn()),Bt=N(Mt,U("udp"),Xn()),Ls=J(se,Bt),jh=F(se),Gh=F(Bt),Pr=N(Bt,U("quic")),ae=N(Bt,U("quic-v1")),Us=J(Pr,ae),Wh=F(Pr),qh=F(ae),Sr=J(Mt,se,Bt,Pr,ae),to=J(N(Sr,U("ws"),X(_()))),Xh=F(to),eo=J(N(Sr,U("wss"),X(_())),N(Sr,U("tls"),U("ws"),X(_()))),Jh=F(eo),ro=N(Ls,U("webrtc-direct"),ne(),X(ne()),X(_())),Qh=F(ro),no=N(ae,U("webtransport"),ne(),ne(),X(_())),Hh=F(no),oe=J(to,eo,N(se,X(_())),N(Us,X(_())),N(Mt,X(_())),ro,no,_()),Zh=F(oe),Ns=N(oe,U("p2p-circuit"),_()),oo=F(Ns),Ps=J(N(oe,U("p2p-circuit"),U("webrtc"),_()),N(oe,U("webrtc"),X(_())),U("webrtc")),Kh=F(Ps);var ho=de(io(),1);var so="[a-fA-F\\d:]",ot=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${so})|(?<=${so})(?=\\s|$))`:"",q="(?: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}",P="[a-fA-F\\d]{1,4}",ce=`
2
+ "use strict";var Libp2PDcutr=(()=>{var ho=Object.create;var Bt=Object.defineProperty;var lo=Object.getOwnPropertyDescriptor;var po=Object.getOwnPropertyNames;var mo=Object.getPrototypeOf,go=Object.prototype.hasOwnProperty;var he=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),O=(r,t)=>{for(var e in t)Bt(r,e,{get:t[e],enumerable:!0})},Fr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of po(t))!go.call(r,o)&&o!==e&&Bt(r,o,{get:()=>t[o],enumerable:!(n=lo(t,o))||n.enumerable});return r};var le=(r,t,e)=>(e=r!=null?ho(mo(r)):{},Fr(t||!r||!r.__esModule?Bt(e,"default",{value:r,enumerable:!0}):e,r)),wo=r=>Fr(Bt({},"__esModule",{value:!0}),r);var En=he((mu,An)=>{"use strict";function vn(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function rs(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 vn(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),vn(new o,e)}}An.exports=rs});var Yn=he(Mt=>{(function(){var r,t,e,n,o,i,c,f;f=function(l){var d,b,w,g;return d=(l&255<<24)>>>24,b=(l&255<<16)>>>16,w=(l&65280)>>>8,g=l&255,[d,b,w,g].join(".")},c=function(l){var d,b,w,g,s,a;for(d=[],w=g=0;g<=3&&l.length!==0;w=++g){if(w>0){if(l[0]!==".")throw new Error("Invalid IP");l=l.substring(1)}a=t(l),s=a[0],b=a[1],l=l.substring(b),d.push(s)}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,b,w,g,s;for(g=0,d=10,b="9",w=0,l.length>1&&l[w]==="0"&&(l[w+1]==="x"||l[w+1]==="X"?(w+=2,d=16):"0"<=l[w+1]&&l[w+1]<="9"&&(w++,d=8,b="7")),s=w;w<l.length;){if("0"<=l[w]&&l[w]<=b)g=g*d+(e(l[w])-n)>>>0;else if(d===16)if("a"<=l[w]&&l[w]<="f")g=g*d+(10+e(l[w])-i)>>>0;else if("A"<=l[w]&&l[w]<="F")g=g*d+(10+e(l[w])-o)>>>0;else break;else break;if(g>4294967295)throw new Error("too large");w++}if(w===s)throw new Error("empty octet");return[g,w]},r=function(){function l(d,b){var w,g,s,a;if(typeof d!="string")throw new Error("Missing `net' parameter");if(b||(a=d.split("/",2),d=a[0],b=a[1]),b||(b=32),typeof b=="string"&&b.indexOf(".")>-1){try{this.maskLong=c(b)}catch(u){throw w=u,new Error("Invalid mask: "+b)}for(g=s=32;s>=0;g=--s)if(this.maskLong===4294967295<<32-g>>>0){this.bitmask=g;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=(c(d)&this.maskLong)>>>0}catch(u){throw w=u,new Error("Invalid net address: "+d)}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 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):(c(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 b,w,g;for(g=c(this.first),w=c(this.last),b=0;g<=w;)d(f(g),g,b),b++,g++},l.prototype.toString=function(){return this.base+"/"+this.bitmask},l}(),Mt.ip2long=c,Mt.long2ip=f,Mt.Netmask=r}).call(Mt)});var no=he((ro,ce)=>{(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,}",c="(?:[0-9a-f]+::?)+",f={zoneIndex:new RegExp(i,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${i})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${i})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${i})?$`,"i")};function l(s,a){if(s.indexOf("::")!==s.lastIndexOf("::"))return null;let u=0,h=-1,p=(s.match(f.zoneIndex)||[])[0],m,x;for(p&&(p=p.substring(1),s=s.replace(/%.+$/,""));(h=s.indexOf(":",h+1))>=0;)u++;if(s.substr(0,2)==="::"&&u--,s.substr(-2,2)==="::"&&u--,u>a)return null;for(x=a-u,m=":";x--;)m+="0:";return s=s.replace("::",m),s[0]===":"&&(s=s.slice(1)),s[s.length-1]===":"&&(s=s.slice(0,-1)),a=function(){let I=s.split(":"),A=[];for(let L=0;L<I.length;L++)A.push(parseInt(I[L],16));return A}(),{parts:a,zoneId:p}}function d(s,a,u,h){if(s.length!==a.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let p=0,m;for(;h>0;){if(m=u-h,m<0&&(m=0),s[p]>>m!==a[p]>>m)return!1;h-=u,p+=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,a){for(;s.length<a;)s=`0${s}`;return s}let g={};g.IPv4=function(){function s(a){if(a.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let u,h;for(u=0;u<a.length;u++)if(h=a[u],!(0<=h&&h<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=a}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(a,u){let h;if(u===void 0&&(h=a,a=h[0],u=h[1]),a.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return d(this.octets,a.octets,8,u)},s.prototype.prefixLengthFromSubnetMask=function(){let a=0,u=!1,h={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 h){if(x=h[m],u&&x!==0)return null;x!==8&&(u=!0),a+=x}else return null;return 32-a},s.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){return this.octets.slice(0)},s.prototype.toIPv4MappedAddress=function(){return g.IPv6.parse(`::ffff:${this.toString()}`)},s.prototype.toNormalizedString=function(){return this.toString()},s.prototype.toString=function(){return this.octets.join(".")},s}(),g.IPv4.broadcastAddressFromCIDR=function(s){try{let a=this.parseCIDR(s),u=a[0].toByteArray(),h=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],m=0;for(;m<4;)p.push(parseInt(u[m],10)|parseInt(h[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(s){return this.parser(s)!==null},g.IPv4.isValid=function(s){try{return new this(this.parser(s)),!0}catch{return!1}},g.IPv4.isValidFourPartDecimal=function(s){return!!(g.IPv4.isValid(s)&&s.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},g.IPv4.networkAddressFromCIDR=function(s){let a,u,h,p,m;try{for(a=this.parseCIDR(s),h=a[0].toByteArray(),m=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],u=0;u<4;)p.push(parseInt(h[u],10)&parseInt(m[u],10)),u++;return new this(p)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.parse=function(s){let a=this.parser(s);if(a===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(a)},g.IPv4.parseCIDR=function(s){let a;if(a=s.match(/^(.+)\/(\d+)$/)){let u=parseInt(a[2]);if(u>=0&&u<=32){let h=[this.parse(a[1]),u];return Object.defineProperty(h,"toString",{value:function(){return this.join("/")}}),h}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},g.IPv4.parser=function(s){let a,u,h;if(a=s.match(e.fourOctet))return function(){let p=a.slice(1,6),m=[];for(let x=0;x<p.length;x++)u=p[x],m.push(b(u));return m}();if(a=s.match(e.longValue)){if(h=b(a[1]),h>4294967295||h<0)throw new Error("ipaddr: address outside defined range");return function(){let p=[],m;for(m=0;m<=24;m+=8)p.push(h>>m&255);return p}().reverse()}else return(a=s.match(e.twoOctet))?function(){let p=a.slice(1,4),m=[];if(h=b(p[1]),h>16777215||h<0)throw new Error("ipaddr: address outside defined range");return m.push(b(p[0])),m.push(h>>16&255),m.push(h>>8&255),m.push(h&255),m}():(a=s.match(e.threeOctet))?function(){let p=a.slice(1,5),m=[];if(h=b(p[2]),h>65535||h<0)throw new Error("ipaddr: address outside defined range");return m.push(b(p[0])),m.push(b(p[1])),m.push(h>>8&255),m.push(h&255),m}():null},g.IPv4.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>32)throw new Error("ipaddr: invalid IPv4 prefix length");let a=[0,0,0,0],u=0,h=Math.floor(s/8);for(;u<h;)a[u]=255,u++;return h<4&&(a[h]=Math.pow(2,s%8)-1<<8-s%8),new this(a)},g.IPv6=function(){function s(a,u){let h,p;if(a.length===16)for(this.parts=[],h=0;h<=14;h+=2)this.parts.push(a[h]<<8|a[h+1]);else if(a.length===8)this.parts=a;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(h=0;h<this.parts.length;h++)if(p=this.parts[h],!(0<=p&&p<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");u&&(this.zoneId=u)}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(a,u){let h;if(u===void 0&&(h=a,a=h[0],u=h[1]),a.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return d(this.parts,a.parts,16,u)},s.prototype.prefixLengthFromSubnetMask=function(){let a=0,u=!1,h={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 h){if(m=h[p],u&&m!==0)return null;m!==16&&(u=!0),a+=m}else return null;return 128-a},s.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){let a,u=[],h=this.parts;for(let p=0;p<h.length;p++)a=h[p],u.push(a>>8),u.push(a&255);return u},s.prototype.toFixedLengthString=function(){let a=function(){let h=[];for(let p=0;p<this.parts.length;p++)h.push(w(this.parts[p].toString(16),4));return h}.call(this).join(":"),u="";return this.zoneId&&(u=`%${this.zoneId}`),a+u},s.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let a=this.parts.slice(-2),u=a[0],h=a[1];return new g.IPv4([u>>8,u&255,h>>8,h&255])},s.prototype.toNormalizedString=function(){let a=function(){let h=[];for(let p=0;p<this.parts.length;p++)h.push(this.parts[p].toString(16));return h}.call(this).join(":"),u="";return this.zoneId&&(u=`%${this.zoneId}`),a+u},s.prototype.toRFC5952String=function(){let a=/((^|:)(0(:|$)){2,})/g,u=this.toNormalizedString(),h=0,p=-1,m;for(;m=a.exec(u);)m[0].length>p&&(h=m.index,p=m[0].length);return p<0?u:`${u.substring(0,h)}::${u.substring(h+p)}`},s.prototype.toString=function(){return this.toRFC5952String()},s}(),g.IPv6.broadcastAddressFromCIDR=function(s){try{let a=this.parseCIDR(s),u=a[0].toByteArray(),h=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],m=0;for(;m<16;)p.push(parseInt(u[m],10)|parseInt(h[m],10)^255),m++;return new this(p)}catch(a){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${a})`)}},g.IPv6.isIPv6=function(s){return this.parser(s)!==null},g.IPv6.isValid=function(s){if(typeof s=="string"&&s.indexOf(":")===-1)return!1;try{let a=this.parser(s);return new this(a.parts,a.zoneId),!0}catch{return!1}},g.IPv6.networkAddressFromCIDR=function(s){let a,u,h,p,m;try{for(a=this.parseCIDR(s),h=a[0].toByteArray(),m=this.subnetMaskFromPrefixLength(a[1]).toByteArray(),p=[],u=0;u<16;)p.push(parseInt(h[u],10)&parseInt(m[u],10)),u++;return new this(p)}catch(x){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${x})`)}},g.IPv6.parse=function(s){let a=this.parser(s);if(a.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(a.parts,a.zoneId)},g.IPv6.parseCIDR=function(s){let a,u,h;if((u=s.match(/^(.+)\/(\d+)$/))&&(a=parseInt(u[2]),a>=0&&a<=128))return h=[this.parse(u[1]),a],Object.defineProperty(h,"toString",{value:function(){return this.join("/")}}),h;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},g.IPv6.parser=function(s){let a,u,h,p,m,x;if(h=s.match(f.deprecatedTransitional))return this.parser(`::ffff:${h[1]}`);if(f.native.test(s))return l(s,8);if((h=s.match(f.transitional))&&(x=h[6]||"",a=l(h[1].slice(0,-1)+x,6),a.parts)){for(m=[parseInt(h[2]),parseInt(h[3]),parseInt(h[4]),parseInt(h[5])],u=0;u<m.length;u++)if(p=m[u],!(0<=p&&p<=255))return null;return a.parts.push(m[0]<<8|m[1]),a.parts.push(m[2]<<8|m[3]),{parts:a.parts,zoneId:a.zoneId}}return null},g.IPv6.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>128)throw new Error("ipaddr: invalid IPv6 prefix length");let a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],u=0,h=Math.floor(s/8);for(;u<h;)a[u]=255,u++;return h<16&&(a[h]=Math.pow(2,s%8)-1<<8-s%8),new this(a)},g.fromByteArray=function(s){let a=s.length;if(a===4)return new g.IPv4(s);if(a===16)return new g.IPv6(s);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},g.isValid=function(s){return g.IPv6.isValid(s)||g.IPv4.isValid(s)},g.parse=function(s){if(g.IPv6.isValid(s))return g.IPv6.parse(s);if(g.IPv4.isValid(s))return g.IPv4.parse(s);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},g.parseCIDR=function(s){try{return g.IPv6.parseCIDR(s)}catch{try{return g.IPv4.parseCIDR(s)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},g.process=function(s){let a=this.parse(s);return a.kind()==="ipv6"&&a.isIPv4MappedAddress()?a.toIPv4Address():a},g.subnetMatch=function(s,a,u){let h,p,m,x;u==null&&(u="unicast");for(p in a)if(Object.prototype.hasOwnProperty.call(a,p)){for(m=a[p],m[0]&&!(m[0]instanceof Array)&&(m=[m]),h=0;h<m.length;h++)if(x=m[h],s.kind()===x[0].kind()&&s.match.apply(s,x))return p}return u},typeof ce<"u"&&ce.exports?ce.exports=g:r.ipaddr=g})(ro)});var Ts={};O(Ts,{dcutr:()=>Us,multicodec:()=>vt});var ks=Symbol.for("@libp2p/connection");var Ms=Symbol.for("@libp2p/content-routing");var _s=Symbol.for("@libp2p/peer-discovery");var zs=Symbol.for("@libp2p/peer-id");var Gs=Symbol.for("@libp2p/peer-routing");var Rr;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Rr||(Rr={}));var Js=Symbol.for("@libp2p/transport");var Ur;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Ur||(Ur={}));var j=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var st="ERR_INVALID_MESSAGE";var de=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},Zs=globalThis.CustomEvent??de;var be={};O(be,{base58btc:()=>$,base58flickr:()=>Ao});var Na=new Uint8Array(0);function Tr(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 Cr(r){return new TextEncoder().encode(r)}function kr(r){return new TextDecoder().decode(r)}function bo(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),c=i.charCodeAt(0);if(e[c]!==255)throw new TypeError(i+" is ambiguous");e[c]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function w(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,h=0,p=0,m=a.length;p!==m&&a[p]===0;)p++,u++;for(var x=(m-p)*b+1>>>0,I=new Uint8Array(x);p!==m;){for(var A=a[p],L=0,E=x-1;(A!==0||L<h)&&E!==-1;E--,L++)A+=256*I[E]>>>0,I[E]=A%f>>>0,A=A/f>>>0;if(A!==0)throw new Error("Non-zero carry");h=L,p++}for(var F=x-h;F!==x&&I[F]===0;)F++;for(var H=l.repeat(u);F<x;++F)H+=r.charAt(I[F]);return H}function g(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var h=0,p=0;a[u]===l;)h++,u++;for(var m=(a.length-u)*d+1>>>0,x=new Uint8Array(m);a[u];){var I=e[a.charCodeAt(u)];if(I===255)return;for(var A=0,L=m-1;(I!==0||A<p)&&L!==-1;L--,A++)I+=f*x[L]>>>0,x[L]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");p=A,u++}if(a[u]!==" "){for(var E=m-p;E!==m&&x[E]===0;)E++;for(var F=new Uint8Array(h+(m-E)),H=h;E!==m;)F[H++]=x[E++];return F}}}function s(a){var u=g(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:g,decode:s}}var xo=bo,yo=xo,Mr=yo;var pe=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")}},me=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 Br(this,t)}},ge=class{decoders;constructor(t){this.decoders=t}or(t){return Br(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 Br(r,t){return new ge({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var we=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 pe(t,e,n),this.decoder=new me(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ht({name:r,prefix:t,encode:e,decode:n}){return new we(r,t,e,n)}function tt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Mr(e,r);return ht({prefix:t,name:r,encode:n,decode:i=>Z(o(i))})}function Io(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 c=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let b=0;b<i;++b){let w=o[r[b]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|w,f+=e,f>=8&&(f-=8,c[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return c}function vo(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",c=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],c+=8;c>e;)c-=e,i+=t[o&f>>c];if(c!==0&&(i+=t[o&f<<e-c]),n)for(;i.length*e&7;)i+="=";return i}function S({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ht({prefix:t,name:r,encode(o){return vo(o,n,e)},decode(o){return Io(o,n,e,r)}})}var $=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ao=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xe={};O(xe,{base32:()=>K,base32hex:()=>No,base32hexpad:()=>Do,base32hexpadupper:()=>Fo,base32hexupper:()=>Po,base32pad:()=>So,base32padupper:()=>Lo,base32upper:()=>Eo,base32z:()=>Ro});var K=S({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Eo=S({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),So=S({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Lo=S({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),No=S({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Po=S({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Do=S({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Fo=S({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ro=S({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Uo=Vr,Or=128,To=127,Co=~To,ko=Math.pow(2,31);function Vr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ko;)t[e++]=r&255|Or,r/=128;for(;r&Co;)t[e++]=r&255|Or,r>>>=7;return t[e]=r|0,Vr.bytes=e-n+1,t}var $o=ye,Mo=128,_r=127;function ye(r,n){var e=0,n=n||0,o=0,i=n,c,f=r.length;do{if(i>=f)throw ye.bytes=0,new RangeError("Could not decode varint");c=r[i++],e+=o<28?(c&_r)<<o:(c&_r)*Math.pow(2,o),o+=7}while(c>=Mo);return ye.bytes=i-n,e}var Bo=Math.pow(2,7),Oo=Math.pow(2,14),_o=Math.pow(2,21),Vo=Math.pow(2,28),zo=Math.pow(2,35),jo=Math.pow(2,42),Go=Math.pow(2,49),Wo=Math.pow(2,56),qo=Math.pow(2,63),Xo=function(r){return r<Bo?1:r<Oo?2:r<_o?3:r<Vo?4:r<zo?5:r<jo?6:r<Go?7:r<Wo?8:r<qo?9:10},Jo={encode:Uo,decode:$o,encodingLength:Xo},Qo=Jo,At=Qo;function Et(r,t=0){return[At.decode(r,t),At.decode.bytes]}function lt(r,t,e=0){return At.encode(r,t,e),t}function dt(r){return At.encodingLength(r)}function at(r,t){let e=t.byteLength,n=dt(r),o=n+dt(e),i=new Uint8Array(o+e);return lt(r,i,0),lt(e,i,n),i.set(t,o),new pt(r,e,t,i)}function _t(r){let t=Z(r),[e,n]=Et(t),[o,i]=Et(t.subarray(n)),c=t.subarray(n+i);if(c.byteLength!==o)throw new Error("Incorrect length");return new pt(e,o,c,t)}function zr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Tr(r.bytes,e.bytes)}}var pt=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function jr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Zo(e,Ie(r),t??$.encoder);default:return Ko(e,Ie(r),t??K.encoder)}}var Gr=new WeakMap;function Ie(r){let t=Gr.get(r);if(t==null){let e=new Map;return Gr.set(r,e),e}return t}var et=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!==St)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Yo)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=at(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&&zr(t.multihash,n.multihash)}toString(t){return jr(this,t)}toJSON(){return{"/":jr(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:c}=e;return new r(n,o,i,c??Wr(n,o,i.bytes))}else if(e[ti]===!0){let{version:n,multihash:o,code:i}=e,c=_t(o);return r.create(n,i,c)}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!==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),c=new pt(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,g]=Et(t.subarray(e));return e+=g,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 c=e,f=n(),l=n(),d=e+l,b=d-c;return{version:o,codec:i,multihashCode:f,digestSize:l,multihashSize:b,size:d}}static parse(t,e){let[n,o]=Ho(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 Ie(i).set(n,t),i}};function Ho(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 K.prefix:{let e=t??K;return[K.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 Zo(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 Ko(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 St=112,Yo=18;function Wr(r,t,e){let n=dt(r),o=n+dt(t),i=new Uint8Array(o+e.byteLength);return lt(r,i,0),lt(t,i,n),i.set(e,o),i}var ti=Symbol.for("@ipld/js-cid/CID");function Vt(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 ve={};O(ve,{base10:()=>ei});var ei=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var Ae={};O(Ae,{base16:()=>ri,base16upper:()=>ni});var ri=S({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ni=S({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ee={};O(Ee,{base2:()=>oi});var oi=S({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Se={};O(Se,{base256emoji:()=>fi});var qr=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}"),ii=qr.reduce((r,t,e)=>(r[e]=t,r),[]),si=qr.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function ai(r){return r.reduce((t,e)=>(t+=ii[e],t),"")}function ci(r){let t=[];for(let e of r){let n=si[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var fi=ht({prefix:"\u{1F680}",name:"base256emoji",encode:ai,decode:ci});var Le={};O(Le,{base36:()=>ui,base36upper:()=>hi});var ui=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hi=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ne={};O(Ne,{base64:()=>li,base64pad:()=>di,base64url:()=>pi,base64urlpad:()=>mi});var li=S({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),di=S({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pi=S({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mi=S({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pe={};O(Pe,{base8:()=>gi});var gi=S({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var De={};O(De,{identity:()=>wi});var wi=ht({prefix:"\0",name:"identity",encode:r=>kr(r),decode:r=>Cr(r)});var Ka=new TextEncoder,Ya=new TextDecoder;var Fe={};O(Fe,{identity:()=>vi});var Xr=0,yi="identity",Jr=Z;function Ii(r){return at(Xr,Jr(r))}var vi={code:Xr,name:yi,encode:Jr,digest:Ii};var Te={};O(Te,{sha256:()=>Ai,sha512:()=>Ei});function Ue({name:r,code:t,encode:e}){return new Re(r,t,e)}var Re=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?at(this.code,e):e.then(n=>at(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Hr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ai=Ue({name:"sha2-256",code:18,encode:Hr("SHA-256")}),Ei=Ue({name:"sha2-512",code:19,encode:Hr("SHA-512")});var Lt={...De,...Ee,...Pe,...ve,...Ae,...xe,...Le,...be,...Ne,...Se},lc={...Te,...Fe};function rt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Y(r=0){return globalThis.Buffer?.alloc!=null?rt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function U(r=0){return globalThis.Buffer?.allocUnsafe!=null?rt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Kr(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Zr=Kr("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ce=Kr("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=U(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Si={utf8:Zr,"utf-8":Zr,hex:Lt.base16,latin1:Ce,ascii:Ce,binary:Ce,...Lt},zt=Si;function M(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)}var Li=Math.pow(2,7),Ni=Math.pow(2,14),Pi=Math.pow(2,21),ke=Math.pow(2,28),$e=Math.pow(2,35),Me=Math.pow(2,42),Be=Math.pow(2,49),y=128,T=127;function C(r){if(r<Li)return 1;if(r<Ni)return 2;if(r<Pi)return 3;if(r<ke)return 4;if(r<$e)return 5;if(r<Me)return 6;if(r<Be)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Di(r,t,e=0){switch(C(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 Fi(r,t,e=0){switch(C(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 Ri(r,t){let e=r[t],n=0;if(n+=e&T,e<y||(e=r[t+1],n+=(e&T)<<7,e<y)||(e=r[t+2],n+=(e&T)<<14,e<y)||(e=r[t+3],n+=(e&T)<<21,e<y)||(e=r[t+4],n+=(e&T)*ke,e<y)||(e=r[t+5],n+=(e&T)*$e,e<y)||(e=r[t+6],n+=(e&T)*Me,e<y)||(e=r[t+7],n+=(e&T)*Be,e<y))return n;throw new RangeError("Could not decode varint")}function Ui(r,t){let e=r.get(t),n=0;if(n+=e&T,e<y||(e=r.get(t+1),n+=(e&T)<<7,e<y)||(e=r.get(t+2),n+=(e&T)<<14,e<y)||(e=r.get(t+3),n+=(e&T)<<21,e<y)||(e=r.get(t+4),n+=(e&T)*ke,e<y)||(e=r.get(t+5),n+=(e&T)*$e,e<y)||(e=r.get(t+6),n+=(e&T)*Me,e<y)||(e=r.get(t+7),n+=(e&T)*Be,e<y))return n;throw new RangeError("Could not decode varint")}function nt(r,t,e=0){return t==null&&(t=U(C(r))),t instanceof Uint8Array?Di(r,t,e):Fi(r,t,e)}function G(r,t=0){return r instanceof Uint8Array?Ri(r,t):Ui(r,t)}function _(r,t){if(globalThis.Buffer!=null)return rt(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=U(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return rt(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,c=0,f=this.peekChar();if(f===void 0)return;let l=f==="0",d=2**(8*o)-1;for(;;){let b=this.readAtomically(()=>{let w=this.readChar();if(w===void 0)return;let g=Number.parseInt(w,t);if(!Number.isNaN(g))return g});if(b===void 0)break;if(i*=t,i+=b,i>d||(c+=1,e!==void 0&&c>e))return}if(c!==0)return!n&&l&&c>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 c=this.readSeparator(":",n,()=>this.readIPv4Addr());if(c!==void 0)return e[o]=c[0],e[o+1]=c[1],e[o+2]=c[2],e[o+3]=c[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),c=16-(n+2),[f]=t(i.subarray(0,c));return e.set(i.subarray(0,f),16-f),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Yr=45,Ti=15,gt=new jt;function Oe(r){if(!(r.length>Ti))return gt.new(r).parseWith(()=>gt.readIPv4Addr())}function _e(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Yr))return gt.new(r).parseWith(()=>gt.readIPv6Addr())}function Gt(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Yr))return gt.new(r).parseWith(()=>gt.readIPAddr())}var kc=parseInt("0xFFFF",16),$c=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Pt(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?rt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Wt(r){return!!Oe(r)}function qt(r){return!!_e(r)}function wt(r){return!!Gt(r)}var rn=Wt,Bi=qt,Ve=function(r){let t=0;if(r=r.toString().trim(),rn(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Bi(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=rn(e[n]),c;i&&(c=Ve(e[n]),e[n]=M(c.slice(0,2),"base16")),c!=null&&++n<8&&e.splice(n,0,M(c.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")},nn=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={},ze={},_i=[[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"]];_i.forEach(r=>{let t=Vi(...r);ze[t.code]=t,bt[t.name]=t});function Vi(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function v(r){if(typeof r=="number"){if(ze[r]!=null)return ze[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 Af=v("ip4"),Ef=v("ip6"),Sf=v("ipcidr");function Ge(r,t){switch(v(r).code){case 4:case 41:return ji(t);case 42:return an(t);case 6:case 273:case 33:case 132:return fn(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return an(t);case 421:return Xi(t);case 444:return cn(t);case 445:return cn(t);case 466:return qi(t);default:return M(t,"base16")}}function We(r,t){switch(v(r).code){case 4:return on(t);case 41:return on(t);case 42:return sn(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 sn(t);case 421:return Gi(t);case 444:return Ji(t);case 445:return Qi(t);case 466:return Wi(t);default:return Pt(t,"base16")}}var je=Object.values(Lt).map(r=>r.decoder),zi=function(){let r=je[0].or(je[1]);return je.slice(2).forEach(t=>r=r.or(t)),r}();function on(r){if(!wt(r))throw new Error("invalid ip address");return Ve(r)}function ji(r){let t=nn(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 fn(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function sn(r){let t=Pt(r),e=Uint8Array.from(nt(t.length));return _([e,t],e.length+t.length)}function an(r){let t=G(r);if(r=r.slice(C(t)),r.length!==t)throw new Error("inconsistent lengths");return M(r)}function Gi(r){let t;r[0]==="Q"||r[0]==="1"?t=_t($.decode(`z${r}`)).bytes:t=et.parse(r).multihash.bytes;let e=Uint8Array.from(nt(t.length));return _([e,t],e.length+t.length)}function Wi(r){let t=zi.decode(r),e=Uint8Array.from(nt(t.length));return _([e,t],e.length+t.length)}function qi(r){let t=G(r),e=r.slice(C(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+M(e,"base64url")}function Xi(r){let t=G(r),e=r.slice(C(t));if(e.length!==t)throw new Error("inconsistent lengths");return M(e,"base58btc")}function Ji(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=K.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 _([e,o],e.length+o.length)}function Qi(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=K.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 _([e,o],e.length+o.length)}function cn(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=M(t,"base32"),o=fn(e);return`${n}:${o}`}function un(r){r=Xe(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 c=o[i],f=v(c);if(f.size===0){t.push([f.code]),e.push([f.code]);continue}if(i++,i>=o.length)throw ln("invalid address: "+r);if(f.path===!0){n=Xe(o.slice(i).join("/")),t.push([f.code,We(f.code,n)]),e.push([f.code,n]);break}let l=We(f.code,o[i]);t.push([f.code,l]),e.push([f.code,Ge(f.code,l)])}return{string:hn(e),bytes:Qe(t),tuples:t,stringTuples:e,path:n}}function Je(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=G(r,o),c=C(i),f=v(i),l=Hi(f,r.slice(o+c));if(l===0){t.push([i]),e.push([i]),o+=c;continue}let d=r.slice(o+c,o+c+l);if(o+=l+c,o>r.length)throw ln("Invalid address Uint8Array: "+M(r,"base16"));t.push([i,d]);let b=Ge(i,d);if(e.push([i,b]),f.path===!0){n=b;break}}return{bytes:Uint8Array.from(r),string:hn(e),tuples:t,stringTuples:e,path:n}}function hn(r){let t=[];return r.map(e=>{let n=v(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Xe(t.join("/"))}function Qe(r){return _(r.map(t=>{let e=v(t[0]),n=Uint8Array.from(nt(e.code));return t.length>1&&t[1]!=null&&(n=_([n,t[1]])),n}))}function Hi(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=G(t instanceof Uint8Array?t:Uint8Array.from(t));return e+C(e)}}function Xe(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function ln(r){return new Error("Error parsing address: "+r)}var Zi=Symbol.for("nodejs.util.inspect.custom"),He=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ki=[v("dns").code,v("dns4").code,v("dns6").code,v("dnsaddr").code],Xt=class r{bytes;#e;#t;#r;#n;[He]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Je(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=un(t)}else if(pn(t))e=Je(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="",c=v("tcp"),f=v("udp"),l=v("ip4"),d=v("ip6"),b=v("dns6"),w=v("ip6zone");for(let[s,a]of this.stringTuples())s===w.code&&(i=`%${a??""}`),Ki.includes(s)&&(e=c.name,o=443,n=`${a??""}${i}`,t=s===b.code?6:4),(s===c.code||s===f.code)&&(e=v(s).name,o=parseInt(a??"")),(s===l.code||s===d.code)&&(e=v(s).name,n=`${a??""}${i}`,t=s===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({},v(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>v(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(Qe(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"?M($.decode(`z${n}`),"base58btc"):M(et.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Vt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=dn.get(e.name);if(n==null)throw new j(`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)}[Zi](){return`Multiaddr(${this.#e})`}};var dn=new Map;function pn(r){return!!r?.[He]}function Ze(r){return new Xt(r)}var mn=()=>{let r=new Error("Delay aborted");return r.name="AbortError",r},Yi=new WeakMap;function ts({clearTimeout:r,setTimeout:t}={}){return(e,{value:n,signal:o}={})=>{if(o?.aborted)return Promise.reject(mn());let i,c,f,l=r??clearTimeout,d=()=>{l(i),f(mn())},b=()=>{o&&o.removeEventListener("abort",d)},w=new Promise((g,s)=>{c=()=>{b(),g(n)},f=s,i=(t??setTimeout)(c,e)});return o&&o.addEventListener("abort",d,{once:!0}),Yi.set(w,()=>{l(i),i=null,c()}),w}}var es=ts(),gn=es;var bn=Symbol.for("@achingbrain/uint8arraylist");function wn(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 Jt(r){return!!r?.[bn]}var V=class r{bufs;length;[bn]=!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(Jt(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(Jt(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=wn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=wn(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(Jt(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 _(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:_(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 c=this.bufs[i],f=o,l=f+c.byteLength;if(o=l,t>=l)continue;let d=t>=f&&t<l,b=e>f&&e<=l;if(d&&b){if(t===f&&e===l){n.push(c);break}let w=t-f;n.push(c.subarray(w,w+(e-t)));break}if(d){if(t===0){n.push(c);continue}n.push(c.subarray(t-f));continue}if(b){if(e===l){n.push(c);break}n.push(c.subarray(0,e-f));break}n.push(c)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Jt(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,c=new Int32Array(i);for(let w=0;w<i;w++)c[w]=-1;for(let w=0;w<o;w++)c[n[w]]=w;let f=c,l=this.byteLength-n.byteLength,d=n.byteLength-1,b;for(let w=e;w<=l;w+=b){b=0;for(let g=d;g>=0;g--){let s=this.get(w+g);if(n[g]!==s){b=Math.max(1,g-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=U(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=Y(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=Y(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=Y(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=U(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=Y(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=Y(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=Y(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=Y(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=Y(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(!Vt(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 xn(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,c)=>{n=()=>{c(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var Ke=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 xn(this.needNext.promise,e?.signal,e)}};function yn(){return new Ke}var Ht=class extends Error{code;constructor(t,e){super(t),this.code=e}},Ye=class extends Ht{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted"}};function In(r,t){let e=yn();r.sink(e).catch(async c=>{await e.end(c)}),r.sink=async c=>{for await(let f of c)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 V;return{read:async(c,f)=>{f?.signal?.throwIfAborted();let l,d=new Promise((b,w)=>{l=()=>{w(new Ye("Read aborted"))},f?.signal?.addEventListener("abort",l)});try{if(c==null){let{done:w,value:g}=await Promise.race([n.next(),d]);return w===!0?new V:g}for(;o.byteLength<c;){let{value:w,done:g}=await Promise.race([n.next(),d]);if(g===!0)throw new Ht("unexpected end of input","ERR_UNEXPECTED_EOF");o.append(w)}let b=o.sublist(0,c);return o.consume(c),b}finally{l!=null&&f?.signal?.removeEventListener("abort",l)}},write:async(c,f)=>{f?.signal?.throwIfAborted(),c instanceof Uint8Array?await e.push(c,f):await e.push(c.subarray(),f)},unwrap:()=>{if(o.byteLength>0){let c=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*c}()}return r}}}function Zt(r){return r[Symbol.asyncIterator]!=null}var Kt=r=>{let t=C(r),e=U(t);return nt(r,e),Kt.bytes=t,e};Kt.bytes=0;function Dt(r,t){t=t??{};let e=t.lengthEncoder??Kt;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return Zt(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Dt.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Kt;return new V(e(r.byteLength),r)};var yt=le(En(),1);var ns=8,os=1024*1024*4,ct;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(ct||(ct={}));var er=r=>{let t=G(r);return er.bytes=C(t),t};er.bytes=0;function tr(r,t){let e=new V,n=ct.LENGTH,o=-1,i=t?.lengthDecoder??er,c=t?.maxLengthLength??ns,f=t?.maxDataLength??os;function*l(){for(;e.byteLength>0;){if(n===ct.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 d=i.bytes;e.consume(d),t?.onLength!=null&&t.onLength(o),n=ct.DATA}catch(d){if(d instanceof RangeError){if(e.byteLength>c)throw(0,yt.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===ct.DATA){if(e.byteLength<o)break;let d=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(d),yield d,n=ct.LENGTH}}}return Zt(r)?async function*(){for await(let d of r)e.append(d),yield*l();if(e.byteLength>0)throw(0,yt.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,yt.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}tr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:c}=await r.next(e);if(i===!0)return;c!=null&&(yield c)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return tr(n,{...t??{},onLength:i=>{e=i}})};var Yt=class extends Error{code;constructor(t,e){super(t),this.code=e}},Sn=r=>G(r);Sn.bytes=0;function Ln(r,t={}){let e=In(r,t);return t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=C(t.maxDataLength)),{read:async o=>{let i=-1,c=new V,f=t?.lengthDecoder??Sn;for(;;){c.append(await e.read(1,o));try{i=f(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(t?.maxLengthLength!=null&&c.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(Dt.single(o,t),i)},writeV:async(o,i)=>{let c=new V(...o.map(f=>Dt.single(f,t)));await e.write(c,i)},unwrap:()=>e.unwrap()}}function rr(r,t){let e=Ln(r,t),n={read:async(o,i)=>{let c=await e.read(i);return o.decode(c)},write:async(o,i,c)=>{await e.write(i.encode(o),c)},writeV:async(o,i,c)=>{await e.writeV(o.map(f=>i.encode(f)),c)},pb:o=>({read:async i=>n.read(o,i),write:async(i,c)=>n.write(i,o,c),writeV:async(i,c)=>n.writeV(i,o,c),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var nr=new Float32Array([-0]),ot=new Uint8Array(nr.buffer);function Nn(r,t,e){nr[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3]}function Pn(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],nr[0]}var or=new Float64Array([-0]),k=new Uint8Array(or.buffer);function Dn(r,t,e){or[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 Fn(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],or[0]}var ss=BigInt(Number.MAX_SAFE_INTEGER),as=BigInt(Number.MIN_SAFE_INTEGER),B=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 ft;if(t<ss&&t>as)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>Rn&&(o=0n,++n>Rn&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ft;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):ft}},ft=new B(0,0);ft.toBigInt=function(){return 0n};ft.zzEncode=ft.zzDecode=function(){return this};ft.length=function(){return 1};var Rn=4294967296n;function Un(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 Tn(r,t,e){if(e-t<1)return"";let o,i=[],c=0,f;for(;t<e;)f=r[t++],f<128?i[c++]=f:f>191&&f<224?i[c++]=(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[c++]=55296+(f>>10),i[c++]=56320+(f&1023)):i[c++]=(f&15)<<12|(r[t++]&63)<<6|r[t++]&63,c>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),c=0);return o!=null?(c>0&&o.push(String.fromCharCode.apply(String,i.slice(0,c))),o.join("")):String.fromCharCode.apply(String,i.slice(0,c))}function ir(r,t,e){let n=e,o,i;for(let c=0;c<r.length;++c)o=r.charCodeAt(c),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(c+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++c,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 te(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var sr=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 te(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw W(this,4);return te(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw W(this,4);let t=Pn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw W(this,4);let t=Fn(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 Tn(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 B(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=te(this.buf,this.pos+=4),e=te(this.buf,this.pos+=4);return new B(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 ar(r){return new sr(r instanceof Uint8Array?r:r.subarray())}function cr(r,t){let e=ar(r);return t.decode(e)}function fr(r){let t=r??8192,e=t>>>1,n,o=t;return function(c){if(c<1||c>e)return U(c);o+c>t&&(n=U(t),o=0);let f=n.subarray(o,o+=c);return o&7&&(o=(o|7)+1),f}}var ut=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function ur(){}var lr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},cs=fr();function fs(r){return globalThis.Buffer!=null?U(r):cs(r)}var Ut=class{len;head;tail;states;constructor(){this.len=0,this.head=new ut(ur,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ut(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new dr((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(Ft,10,B.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=B.fromBigInt(t);return this._push(Ft,e.length(),e)}uint64Number(t){let e=B.fromNumber(t);return this._push(Ft,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=B.fromBigInt(t).zzEncode();return this._push(Ft,e.length(),e)}sint64Number(t){let e=B.fromNumber(t).zzEncode();return this._push(Ft,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(hr,1,t?1:0)}fixed32(t){return this._push(Rt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=B.fromBigInt(t);return this._push(Rt,4,e.lo)._push(Rt,4,e.hi)}fixed64Number(t){let e=B.fromNumber(t);return this._push(Rt,4,e.lo)._push(Rt,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(Nn,4,t)}double(t){return this._push(Dn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(hr,1,0):this.uint32(e)._push(hs,e,t)}string(t){let e=Un(t);return e!==0?this.uint32(e)._push(ir,e,t):this._push(hr,1,0)}fork(){return this.states=new lr(this),this.head=this.tail=new ut(ur,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 ut(ur,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=fs(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function hr(r,t,e){t[e]=r&255}function us(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var dr=class extends ut{next;constructor(t,e){super(us,t,e),this.next=void 0}};function Ft(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 Rt(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 hs(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ut.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ls,t,r),this},Ut.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ds,t,r),this});function ls(r,t,e){t.set(r,e)}function ds(r,t,e){r.length<40?ir(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Pt(r),e)}function pr(){return new Ut}function mr(r,t){let e=pr();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 ee(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function gr(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)};return ee("enum",It.VARINT,e,n)}function wr(r,t){return ee("message",It.LENGTH_DELIMITED,r,t)}var q;(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=()=>gr(e)}(t=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=wr((o,i,c={})=>{if(c.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);c.lengthDelimited!==!1&&i.ldelim()},(o,i)=>{let c={observedAddresses:[]},f=i==null?o.len:o.pos+i;for(;o.pos<f;){let l=o.uint32();switch(l>>>3){case 1:c.type=r.Type.codec().decode(o);break;case 2:c.observedAddresses.push(o.bytes());break;default:o.skipType(l&7);break}}return c})),n),r.encode=o=>mr(o,r.codec()),r.decode=o=>cr(o,r.codec())})(q||(q={}));function ps(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),c=i.charCodeAt(0);if(e[c]!==255)throw new TypeError(i+" is ambiguous");e[c]=o}var f=r.length,l=r.charAt(0),d=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function w(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,h=0,p=0,m=a.length;p!==m&&a[p]===0;)p++,u++;for(var x=(m-p)*b+1>>>0,I=new Uint8Array(x);p!==m;){for(var A=a[p],L=0,E=x-1;(A!==0||L<h)&&E!==-1;E--,L++)A+=256*I[E]>>>0,I[E]=A%f>>>0,A=A/f>>>0;if(A!==0)throw new Error("Non-zero carry");h=L,p++}for(var F=x-h;F!==x&&I[F]===0;)F++;for(var H=l.repeat(u);F<x;++F)H+=r.charAt(I[F]);return H}function g(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var h=0,p=0;a[u]===l;)h++,u++;for(var m=(a.length-u)*d+1>>>0,x=new Uint8Array(m);a[u];){var I=e[a.charCodeAt(u)];if(I===255)return;for(var A=0,L=m-1;(I!==0||A<p)&&L!==-1;L--,A++)I+=f*x[L]>>>0,x[L]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");p=A,u++}if(a[u]!==" "){for(var E=m-p;E!==m&&x[E]===0;)E++;for(var F=new Uint8Array(h+(m-E)),H=h;E!==m;)F[H++]=x[E++];return F}}}function s(a){var u=g(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:g,decode:s}}var ms=ps,gs=ms,kn=gs;var oh=new Uint8Array(0);var $n=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 br=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")}},xr=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 Mn(this,t)}},yr=class{constructor(t){this.decoders=t}or(t){return Mn(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`)}},Mn=(r,t)=>new yr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Ir=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new br(t,e,n),this.decoder=new xr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Bn=({name:r,prefix:t,encode:e,decode:n})=>new Ir(r,t,e,n),vr=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=kn(e,t);return Bn({prefix:r,name:t,encode:n,decode:i=>$n(o(i))})},ws=(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 c=new Uint8Array(i*e/8|0),f=0,l=0,d=0;for(let b=0;b<i;++b){let w=o[r[b]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|w,f+=e,f>=8&&(f-=8,c[d++]=255&l>>f)}if(f>=e||255&l<<8-f)throw new SyntaxError("Unexpected end of data");return c},bs=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,i="",c=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],c+=8;c>e;)c-=e,i+=t[o&f>>c];if(c&&(i+=t[o&f<<e-c]),n)for(;i.length*e&7;)i+="=";return i},Tt=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Bn({prefix:t,name:r,encode(o){return bs(o,n,e)},decode(o){return ws(o,n,e,r)}});var On=vr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uh=vr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh=Tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ph=Tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_n=Tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mh=Tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xs=r=>r.toString().split("/").slice(1),Ct=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),N=r=>({match:t=>Ct(e=>e===r).match(t),pattern:r}),oe=()=>({match:r=>Ct(t=>typeof t=="string").match(r),pattern:"{string}"}),Vn=()=>({match:r=>Ct(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),z=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{On.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),re=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{_n.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),J=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(", ")})`}),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 R(...r){function t(o){let i=xs(o);for(let c of r){let f=c.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 Er=P(N("dns4"),oe()),Sr=P(N("dns6"),oe()),Lr=P(N("dnsaddr"),oe()),zn=P(N("dns"),oe()),Ih=R(Er),vh=R(Sr),Ah=R(Lr),jn=R(Q(zn,Lr,Er,Sr)),Gn=P(N("ip4"),Ct(Wt)),Wn=P(N("ip6"),Ct(qt)),qn=Q(Gn,Wn),kt=Q(qn,zn,Er,Sr,Lr),Eh=R(kt),Sh=R(Gn),Lh=R(Wn),Xn=R(qn),ie=P(kt,N("tcp"),Vn()),$t=P(kt,N("udp"),Vn()),ys=Q(ie,$t),Nh=R(ie),Ph=R($t),Nr=P($t,N("quic")),se=P($t,N("quic-v1")),Is=Q(Nr,se),Dh=R(Nr),Fh=R(se),Ar=Q(kt,ie,$t,Nr,se),Jn=Q(P(Ar,N("ws"),J(z()))),Rh=R(Jn),Qn=Q(P(Ar,N("wss"),J(z())),P(Ar,N("tls"),N("ws"),J(z()))),Uh=R(Qn),Hn=P(ys,N("webrtc-direct"),re(),J(re()),J(z())),Th=R(Hn),Zn=P(se,N("webtransport"),re(),re(),J(z())),Ch=R(Zn),ne=Q(Jn,Qn,P(ie,J(z())),P(Is,J(z())),P(kt,J(z())),Hn,Zn,z()),kh=R(ne),vs=P(ne,N("p2p-circuit"),z()),Kn=R(vs),As=Q(P(ne,N("p2p-circuit"),N("webrtc"),z()),P(ne,N("webrtc"),J(z())),N("webrtc")),$h=R(As);var io=le(Yn(),1);var to="[a-fA-F\\d:]",it=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${to})|(?<=${to})(?=\\s|$))`:"",X="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",D="[a-fA-F\\d]{1,4}",ae=`
3
3
  (?:
4
- (?:${P}:){7}(?:${P}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
- (?:${P}:){6}(?:${q}|:${P}|:)| // 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
- (?:${P}:){5}(?::${q}|(?::${P}){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
- (?:${P}:){4}(?:(?::${P}){0,1}:${q}|(?::${P}){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
- (?:${P}:){3}(?:(?::${P}){0,2}:${q}|(?::${P}){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
- (?:${P}:){2}(?:(?::${P}){0,3}:${q}|(?::${P}){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
- (?:${P}:){1}(?:(?::${P}){0,4}:${q}|(?::${P}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
- (?::(?:(?::${P}){0,5}:${q}|(?::${P}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
4
+ (?:${D}:){7}(?:${D}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
+ (?:${D}:){6}(?:${X}|:${D}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
6
+ (?:${D}:){5}(?::${X}|(?::${D}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
7
+ (?:${D}:){4}(?:(?::${D}){0,1}:${X}|(?::${D}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
8
+ (?:${D}:){3}(?:(?::${D}){0,2}:${X}|(?::${D}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
9
+ (?:${D}:){2}(?:(?::${D}){0,3}:${X}|(?::${D}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
10
+ (?:${D}:){1}(?:(?::${D}){0,4}:${X}|(?::${D}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
+ (?::(?:(?::${D}){0,5}:${X}|(?::${D}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
12
12
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
13
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Ds=new RegExp(`(?:^${q}$)|(?:^${ce}$)`),Fs=new RegExp(`^${q}$`),Rs=new RegExp(`^${ce}$`),Dr=r=>r&&r.exact?Ds:new RegExp(`(?:${ot(r)}${q}${ot(r)})|(?:${ot(r)}${ce}${ot(r)})`,"g");Dr.v4=r=>r&&r.exact?Fs:new RegExp(`${ot(r)}${q}${ot(r)}`,"g");Dr.v6=r=>r&&r.exact?Rs:new RegExp(`${ot(r)}${ce}${ot(r)}`,"g");var ao=Dr;var lo=de(fo(),1),{isValid:Ts,parse:Cs}=lo.default,ks=["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"],$s=ks.map(r=>new ho.Netmask(r));function Ms(r){for(let t of $s)if(t.contains(r))return!0;return!1}function uo(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 po=r=>{if(Ts(r)){let t=Cs(r);if(t.kind()==="ipv4")return Ms(t.toNormalizedString());if(t.kind()==="ipv6")return uo(r)}else if(wt(r)&&ao.v6().test(r))return uo(r)};var mo=po;function Fr(r,t){return oo.matches(r)||t.transportForMultiaddr(r)==null?!1:Qn.matches(r)?!0:Yn.matches(r)?mo(r.toOptions().host)===!1:!1}var go=1024*4,wo=100,ue={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},he=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=or(e,{maxDataLength:go}).pb(W);this.log("B sending connect to %p",t.remotePeer);let c=Date.now();await i.write({type:W.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!==W.Type.CONNECT)throw this.log("A sent wrong message type"),new V("DCUtR message type was incorrect",it);let l=this.getDialableMultiaddrs(f.observedAddresses);if(l.length===0)throw this.log("A did not have any dialable multiaddrs"),new V("DCUtR connect message had no multiaddrs",it);let d=Date.now()-c;this.log("A sending sync, rtt %dms",d),await i.write({type:W.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await xn(d/2),this.log("B dialing",l);let b=await this.connectionManager.openConnection(l,{signal:o.signal,priority:wo});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=>Fr(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=or(t,{maxDataLength:go}).pb(W);this.log("A receiving connect");let i=await o.read(n);if(i.type!==W.Type.CONNECT)throw this.log("B sent wrong message type"),new V("DCUtR message type was incorrect",it);if(i.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new V("DCUtR connect message had no multiaddrs",it);let c=this.getDialableMultiaddrs(i.observedAddresses);if(c.length===0)throw this.log("B had no dialable multiaddrs"),new V("DCUtR connect message had no dialable multiaddrs",it);if(this.log("A sending connect"),await o.write({type:W.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(d=>d.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==W.Type.SYNC)throw new V("DCUtR message type was incorrect",it);this.log("A dialing",c);let l=await this.connectionManager.openConnection(c,{signal:n.signal,priority:wo,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=Ke(n);if(!Fr(o,this.transportManager))continue;e.push(o)}catch{}return e}};var At="/libp2p/dcutr";function Bs(r={}){return t=>new he(t,r)}return vo(Os);})();
13
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Es=new RegExp(`(?:^${X}$)|(?:^${ae}$)`),Ss=new RegExp(`^${X}$`),Ls=new RegExp(`^${ae}$`),Pr=r=>r&&r.exact?Es:new RegExp(`(?:${it(r)}${X}${it(r)})|(?:${it(r)}${ae}${it(r)})`,"g");Pr.v4=r=>r&&r.exact?Ss:new RegExp(`${it(r)}${X}${it(r)}`,"g");Pr.v6=r=>r&&r.exact?Ls:new RegExp(`${it(r)}${ae}${it(r)}`,"g");var eo=Pr;var so=le(no(),1),{isValid:Ns,parse:Ps}=so.default,Ds=["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"],Fs=Ds.map(r=>new io.Netmask(r));function Rs(r){for(let t of Fs)if(t.contains(r))return!0;return!1}function oo(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 ao=r=>{if(Ns(r)){let t=Ps(r);if(t.kind()==="ipv4")return Rs(t.toNormalizedString());if(t.kind()==="ipv6")return oo(r)}else if(wt(r)&&eo.v6().test(r))return oo(r)};var co=ao;function Dr(r,t){return Kn.matches(r)||t.transportForMultiaddr(r)==null?!1:jn.matches(r)?!0:Xn.matches(r)?co(r.toOptions().host)===!1:!1}var fo=1024*4,uo=100,fe={timeout:5e3,retries:3,maxInboundStreams:1,maxOutboundStreams:1},ue=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??fe.timeout,this.retries=e.retries??fe.retries,this.maxInboundStreams=e.maxInboundStreams??fe.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??fe.maxOutboundStreams}isStarted(){return this.started}async start(){this.started||(this.topologyId=await this.registrar.register(vt,{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(vt,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(vt),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([vt],{signal:o.signal,runOnTransientConnection:!0});let i=rr(e,{maxDataLength:fo}).pb(q);this.log("B sending connect to %p",t.remotePeer);let c=Date.now();await i.write({type:q.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!==q.Type.CONNECT)throw this.log("A sent wrong message type"),new j("DCUtR message type was incorrect",st);let l=this.getDialableMultiaddrs(f.observedAddresses);if(l.length===0)throw this.log("A did not have any dialable multiaddrs"),new j("DCUtR connect message had no multiaddrs",st);let d=Date.now()-c;this.log("A sending sync, rtt %dms",d),await i.write({type:q.Type.SYNC,observedAddresses:[]},o),this.log("A waiting for half RTT"),await gn(d/2),this.log("B dialing",l);let b=await this.connectionManager.openConnection(l,{signal:o.signal,priority:uo});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=>Dr(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=rr(t,{maxDataLength:fo}).pb(q);this.log("A receiving connect");let i=await o.read(n);if(i.type!==q.Type.CONNECT)throw this.log("B sent wrong message type"),new j("DCUtR message type was incorrect",st);if(i.observedAddresses.length===0)throw this.log("B sent no multiaddrs"),new j("DCUtR connect message had no multiaddrs",st);let c=this.getDialableMultiaddrs(i.observedAddresses);if(c.length===0)throw this.log("B had no dialable multiaddrs"),new j("DCUtR connect message had no dialable multiaddrs",st);if(this.log("A sending connect"),await o.write({type:q.Type.CONNECT,observedAddresses:this.addressManager.getAddresses().map(d=>d.bytes)}),this.log("A receiving sync"),(await o.read(n)).type!==q.Type.SYNC)throw new j("DCUtR message type was incorrect",st);this.log("A dialing",c);let l=await this.connectionManager.openConnection(c,{signal:n.signal,priority:uo,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=Ze(n);if(!Dr(o,this.transportManager))continue;e.push(o)}catch{}return e}};var vt="/libp2p/dcutr";function Us(r={}){return t=>new ue(t,r)}return wo(Ts);})();
14
14
  return Libp2PDcutr}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/dcutr",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
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.1.0",
55
- "@libp2p/interface-internal": "^1.0.4",
54
+ "@libp2p/interface": "^1.1.1",
55
+ "@libp2p/interface-internal": "^1.0.5",
56
56
  "@multiformats/multiaddr": "^12.1.10",
57
57
  "@multiformats/multiaddr-matcher": "^1.1.0",
58
58
  "delay": "^6.0.0",
@@ -62,7 +62,7 @@
62
62
  "uint8arraylist": "^2.4.3"
63
63
  },
64
64
  "devDependencies": {
65
- "aegir": "^41.0.2",
65
+ "aegir": "^42.0.0",
66
66
  "protons": "^7.3.0",
67
67
  "sinon": "^17.0.0",
68
68
  "sinon-ts": "^2.0.0"