kubo-rpc-client
Version:
A client library for the Kubo RPC API
2 lines • 309 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.KuboRpcClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var KuboRpcClient=(()=>{var Tw=Object.create;var us=Object.defineProperty;var Dw=Object.getOwnPropertyDescriptor;var Uw=Object.getOwnPropertyNames;var Pw=Object.getPrototypeOf,_w=Object.prototype.hasOwnProperty;var fr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),z=(e,t)=>{for(var r in t)us(e,r,{get:t[r],enumerable:!0})},Xd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Uw(t))!_w.call(e,o)&&o!==r&&us(e,o,{get:()=>t[o],enumerable:!(n=Dw(t,o))||n.enumerable});return e};var ur=(e,t,r)=>(r=e!=null?Tw(Pw(e)):{},Xd(t||!e||!e.__esModule?us(r,"default",{value:e,enumerable:!0}):r,e)),Ow=e=>Xd(us({},"__esModule",{value:!0}),e);var Oh=fr((mT,_h)=>{function lS(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}_h.exports=lS});var go=fr((xT,Mh)=>{"use strict";function Fh(e,t){for(let r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function pS(e,t,r){if(!e||typeof e=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof t=="object"&&(r=t,t=""),t&&(r.code=t);try{return Fh(e,r)}catch{r.message=e.message,r.stack=e.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),Fh(new o,r)}}Mh.exports=pS});var qg=fr((_9,Vg)=>{"use strict";Vg.exports=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}});var Yg=fr((Zg,Xg)=>{"use strict";var $i=qg(),{hasOwnProperty:Gg}=Object.prototype,{propertyIsEnumerable:Y5}=Object,jn=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),J5=Zg,Hg={concatArrays:!1,ignoreUndefined:!1},zi=e=>{let t=[];for(let r in e)Gg.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(e);for(let n of r)Y5.call(e,n)&&t.push(n)}return t};function Kn(e){return Array.isArray(e)?Q5(e):$i(e)?e3(e):e}function Q5(e){let t=e.slice(0,0);return zi(e).forEach(r=>{jn(t,r,Kn(e[r]))}),t}function e3(e){let t=Object.getPrototypeOf(e)===null?Object.create(null):{};return zi(e).forEach(r=>{jn(t,r,Kn(e[r]))}),t}var Wg=(e,t,r,n)=>(r.forEach(o=>{typeof t[o]>"u"&&n.ignoreUndefined||(o in e&&e[o]!==Object.getPrototypeOf(e)?jn(e,o,Ud(e[o],t[o],n)):jn(e,o,Kn(t[o])))}),e),t3=(e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)Gg.call(s,a)&&(i.push(String(a)),s===e?jn(n,o++,s[a]):jn(n,o++,Kn(s[a])));n=Wg(n,s,zi(s).filter(a=>!i.includes(a)),r)}),n};function Ud(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?t3(e,t,r):!$i(t)||!$i(e)?Kn(t):Wg(e,t,zi(t),r)}Xg.exports=function(...e){let t=Ud(Kn(Hg),this!==J5&&this||{},Hg),r={_:{}};for(let n of e)if(n!==void 0){if(!$i(n))throw new TypeError("`"+n+"` is not an Option Object");r=Ud(r,{_:n},t)}return r._}});var Od=fr((F9,sb)=>{"use strict";var n3=typeof navigator<"u"&&navigator.product==="ReactNative";function o3(){return n3?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var as=self.URL,ob=o3(),_d=class{constructor(t="",r=ob){this.super=new as(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set username(t){this.super.username=t}static createObjectURL(t){return as.createObjectURL(t)}static revokeObjectURL(t){as.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function s3(e){if(typeof e=="string")return new as(e).toString();if(!(e instanceof as)){let t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",o=e.protocol?e.protocol+"//":"",s=e.host||"",i=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",f=e.pathname||"",u=e.path||f+a;return`${o}${t||r}${s||i+n}${u}${c}`}}sb.exports={URLWithLegacySupport:_d,URLSearchParams:self.URLSearchParams,defaultBase:ob,format:s3}});var cb=fr((M9,ab)=>{"use strict";var{URLWithLegacySupport:ib,format:i3}=Od();ab.exports=(e,t={},r={},n)=>{let o=t.protocol?t.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new ib(e)}catch{s={}}let i=Object.assign({},t,{protocol:o||s.protocol,host:t.host||s.host});return new ib(e,i3(i)).toString()}});var ub=fr(($9,fb)=>{"use strict";var{URLWithLegacySupport:a3,format:c3,URLSearchParams:f3,defaultBase:u3}=Od(),d3=cb();fb.exports={URL:a3,URLSearchParams:f3,format:c3,relative:d3,defaultBase:u3}});var q3={};z(q3,{CID:()=>_,RoutingEventTypes:()=>gd,RoutingMessageType:()=>bd,StrictNoSign:()=>j3,StrictSign:()=>z3,create:()=>K3,createBitswap:()=>ud,createBlock:()=>dd,createBootstrap:()=>ld,createConfig:()=>pd,createDAG:()=>yd,createDHT:()=>wd,createDiag:()=>xd,createFiles:()=>Sd,createKey:()=>vd,createKuboRPCClient:()=>K3,createLog:()=>Rd,createName:()=>kd,createObject:()=>Fd,createPin:()=>Md,createProvide:()=>$d,createPubsub:()=>zd,createRefs:()=>jd,createRepo:()=>Kd,createRouting:()=>Vd,createStats:()=>qd,createSwarm:()=>Hd,multiaddr:()=>Q,readURLContent:()=>Bw,urlSource:()=>V3});function na(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function dr(e=0){return new Uint8Array(e)}var Lw=Math.pow(2,7),Nw=Math.pow(2,14),Rw=Math.pow(2,21),oa=Math.pow(2,28),sa=Math.pow(2,35),ia=Math.pow(2,42),aa=Math.pow(2,49),re=128,Ie=127;function kr(e){if(e<Lw)return 1;if(e<Nw)return 2;if(e<Rw)return 3;if(e<oa)return 4;if(e<sa)return 5;if(e<ia)return 6;if(e<aa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ca(e,t,r=0){switch(kr(e)){case 8:t[r++]=e&255|re,e/=128;case 7:t[r++]=e&255|re,e/=128;case 6:t[r++]=e&255|re,e/=128;case 5:t[r++]=e&255|re,e/=128;case 4:t[r++]=e&255|re,e>>>=7;case 3:t[r++]=e&255|re,e>>>=7;case 2:t[r++]=e&255|re,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function kw(e,t){let r=e[t],n=0;if(n+=r&Ie,r<re||(r=e[t+1],n+=(r&Ie)<<7,r<re)||(r=e[t+2],n+=(r&Ie)<<14,r<re)||(r=e[t+3],n+=(r&Ie)<<21,r<re)||(r=e[t+4],n+=(r&Ie)*oa,r<re)||(r=e[t+5],n+=(r&Ie)*sa,r<re)||(r=e[t+6],n+=(r&Ie)*ia,r<re)||(r=e[t+7],n+=(r&Ie)*aa,r<re))return n;throw new RangeError("Could not decode varint")}function Fw(e,t){let r=e.get(t),n=0;if(n+=r&Ie,r<re||(r=e.get(t+1),n+=(r&Ie)<<7,r<re)||(r=e.get(t+2),n+=(r&Ie)<<14,r<re)||(r=e.get(t+3),n+=(r&Ie)<<21,r<re)||(r=e.get(t+4),n+=(r&Ie)*oa,r<re)||(r=e.get(t+5),n+=(r&Ie)*sa,r<re)||(r=e.get(t+6),n+=(r&Ie)*ia,r<re)||(r=e.get(t+7),n+=(r&Ie)*aa,r<re))return n;throw new RangeError("Could not decode varint")}function fa(e,t=0){return e instanceof Uint8Array?kw(e,t):Fw(e,t)}function $w(e){return e.buffer instanceof ArrayBuffer}function ua(e){return $w(e)?e:e.slice()}function zw(e){return e?.buffer instanceof ArrayBuffer}function da(e){if(zw(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Fr(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=dr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return da(r)}var ya={};z(ya,{base10:()=>Zw});var i4=new Uint8Array(0);function Yd(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Je(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return lr(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return lr(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Jd(e){return new TextEncoder().encode(e)}function Qd(e){return new TextDecoder().decode(e)}function jw(e){return e?.buffer instanceof ArrayBuffer}function lr(e){return jw(e)?e:e.slice()}function Kw(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=e.length,c=e.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var g=0,y=0,m=0,b=d.length;m!==b&&d[m]===0;)m++,g++;for(var E=(b-m)*u+1>>>0,v=new Uint8Array(E);m!==b;){for(var C=d[m],P=0,I=E-1;(C!==0||P<y)&&I!==-1;I--,P++)C+=256*v[I]>>>0,v[I]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");y=P,m++}for(var A=E-y;A!==E&&v[A]===0;)A++;for(var k=c.repeat(g);A<E;++A)k+=e.charAt(v[A]);return k}function w(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var g=0;if(d[g]!==" "){for(var y=0,m=0;d[g]===c;)y++,g++;for(var b=(d.length-g)*f+1>>>0,E=new Uint8Array(b);d[g];){var v=r[d.charCodeAt(g)];if(v===255)return;for(var C=0,P=b-1;(v!==0||C<m)&&P!==-1;P--,C++)v+=a*E[P]>>>0,E[P]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");m=C,g++}if(d[g]!==" "){for(var I=b-m;I!==b&&E[I]===0;)I++;for(var A=new Uint8Array(y+(b-I)),k=y;I!==b;)A[k++]=E[I++];return A}}}function x(d){var g=w(d);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:w,decode:x}}var Vw=Kw,qw=Vw,tl=qw;var la=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},pa=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return rl(this,t)}},ha=class{decoders;constructor(t){this.decoders=t}or(t){return rl(this,t)}decode(t){let r=t[0],n=this.decoders[r];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 rl(e,t){return new ha({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ma=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new la(t,r,n),this.decoder=new pa(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Mr({name:e,prefix:t,encode:r,decode:n}){return new ma(e,t,r,n)}function $t({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=tl(r,e);return Mr({prefix:t,name:e,encode:n,decode:s=>Je(o(s))})}function Hw(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let f=0;f<o;++f){let u=t[e[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Gw(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Ww(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function oe({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Ww(n);return Mr({prefix:t,name:e,encode(s){return Gw(s,n,r)},decode(s){return Hw(s,o,r,e)}})}var Zw=$t({prefix:"9",name:"base10",alphabet:"0123456789"});var ga={};z(ga,{base16:()=>Xw,base16upper:()=>Yw});var Xw=oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yw=oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ba={};z(ba,{base2:()=>Jw});var Jw=oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wa={};z(wa,{base256emoji:()=>nx});var nl=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}"),Qw=nl.reduce((e,t,r)=>(e[r]=t,e),[]),ex=nl.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function tx(e){return e.reduce((t,r)=>(t+=Qw[r],t),"")}function rx(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=ex[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var nx=Mr({prefix:"\u{1F680}",name:"base256emoji",encode:tx,decode:rx});var xa={};z(xa,{base32:()=>zt,base32hex:()=>ax,base32hexpad:()=>fx,base32hexpadupper:()=>ux,base32hexupper:()=>cx,base32pad:()=>sx,base32padupper:()=>ix,base32upper:()=>ox,base32z:()=>dx});var zt=oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ox=oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),sx=oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ix=oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ax=oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cx=oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),fx=oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ux=oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dx=oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ea={};z(Ea,{base36:()=>Xn,base36upper:()=>lx});var Xn=$t({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lx=$t({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Sa={};z(Sa,{base58btc:()=>dt,base58flickr:()=>px});var dt=$t({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),px=$t({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var va={};z(va,{base64:()=>ds,base64pad:()=>hx,base64url:()=>pr,base64urlpad:()=>mx});var ds=oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hx=oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),pr=oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mx=oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Aa={};z(Aa,{base8:()=>yx});var yx=oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ca={};z(Ca,{identity:()=>gx});var gx=Mr({prefix:"\0",name:"identity",encode:e=>Qd(e),decode:e=>Jd(e)});var Ia={};z(Ia,{code:()=>Ex,decode:()=>vx,encode:()=>Sx,name:()=>xx});var bx=new TextEncoder,wx=new TextDecoder,xx="json",Ex=512;function Sx(e){return bx.encode(JSON.stringify(e))}function vx(e){return JSON.parse(wx.decode(e))}var Ba={};z(Ba,{code:()=>Cx,decode:()=>Bx,encode:()=>Ix,name:()=>Ax});var Ax="raw",Cx=85;function Ix(e){return Je(e)}function Bx(e){return Je(e)}var Da={};z(Da,{identity:()=>ps});var Tx=il,ol=128,Dx=127,Ux=~Dx,Px=Math.pow(2,31);function il(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Px;)t[r++]=e&255|ol,e/=128;for(;e&Ux;)t[r++]=e&255|ol,e>>>=7;return t[r]=e|0,il.bytes=r-n+1,t}var _x=Ta,Ox=128,sl=127;function Ta(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw Ta.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&sl)<<o:(i&sl)*Math.pow(2,o),o+=7}while(i>=Ox);return Ta.bytes=s-n,r}var Lx=Math.pow(2,7),Nx=Math.pow(2,14),Rx=Math.pow(2,21),kx=Math.pow(2,28),Fx=Math.pow(2,35),Mx=Math.pow(2,42),$x=Math.pow(2,49),zx=Math.pow(2,56),jx=Math.pow(2,63),Kx=function(e){return e<Lx?1:e<Nx?2:e<Rx?3:e<kx?4:e<Fx?5:e<Mx?6:e<$x?7:e<zx?8:e<jx?9:10},Vx={encode:Tx,decode:_x,encodingLength:Kx},qx=Vx,Yn=qx;function Jn(e,t=0){return[Yn.decode(e,t),Yn.decode.bytes]}function $r(e,t,r=0){return Yn.encode(e,t,r),t}function zr(e){return Yn.encodingLength(e)}function Kr(e,t){let r=t.byteLength,n=zr(e),o=n+zr(r),s=new Uint8Array(o+r);return $r(e,s,0),$r(r,s,n),s.set(t,o),new jr(e,r,t,s)}function al(e){let t=Je(e),[r,n]=Jn(t),[o,s]=Jn(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new jr(r,o,i,t)}function cl(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Yd(e.bytes,r.bytes)}}var jr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=lr(n),this.bytes=lr(o)}};var fl=0,Hx="identity",ul=Je;function Gx(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Kr(fl,ul(e))}var ps={code:fl,name:Hx,encode:ul,digest:Gx};var _a={};z(_a,{sha256:()=>Zx,sha512:()=>Xx});var Wx=20;function Pa({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ua(e,t,r,n,o)}var Ua=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Wx,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?dl(n,this.code,r?.truncate):n.then(o=>dl(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function dl(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Kr(t,e)}function pl(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Zx=Pa({name:"sha2-256",code:18,encode:pl("SHA-256")}),Xx=Pa({name:"sha2-512",code:19,encode:pl("SHA-512")});function hl(e,t){let{bytes:r,version:n}=e;return n===0?Jx(r,Oa(e),t??dt.encoder):Qx(r,Oa(e),t??zt.encoder)}var ml=new WeakMap;function Oa(e){let t=ml.get(e);if(t==null){let r=new Map;return ml.set(e,r),r}return t}var _=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=lr(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==eo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==e1)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}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:r}=this.multihash,n=Kr(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&cl(t.multihash,n.multihash)}toString(t){return hl(this,t)}toJSON(){return{"/":hl(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??yl(n,o,s.bytes))}else if(r[t1]===!0){let{version:n,multihash:o,code:s}=r,i=al(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="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(r!==eo)throw new Error(`Version 0 CID must use dag-pb (code: ${eo}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=yl(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,eo,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Je(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new jr(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,w]=Jn(t.subarray(r));return r+=w,l},o=n(),s=eo;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),f=r+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=Yx(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oa(s).set(n,t),s}};function Yx(e,t){switch(e[0]){case"Q":{let r=t??dt;return[dt.prefix,r.decode(`${dt.prefix}${e}`)]}case dt.prefix:{let r=t??dt;return[dt.prefix,r.decode(e)]}case zt.prefix:{let r=t??zt;return[zt.prefix,r.decode(e)]}case Xn.prefix:{let r=t??Xn;return[Xn.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Jx(e,t,r){let{prefix:n}=r;if(n!==dt.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Qx(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var eo=112,e1=18;function yl(e,t,r){let n=zr(e),o=n+zr(t),s=new Uint8Array(o+r.byteLength);return $r(e,s,0),$r(t,s,n),s.set(r,o),s}var t1=Symbol.for("@ipld/js-cid/CID");var hr={...Ca,...ba,...Aa,...ya,...ga,...xa,...Ea,...Sa,...va,...wa},gl={..._a,...Da},bl={raw:Ba,json:Ia};function xl(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var wl=xl("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),La=xl("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=dr(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),r1={utf8:wl,"utf-8":wl,hex:hr.base16,latin1:La,ascii:La,binary:La,...hr},hs=r1;function Ve(e,t="utf8"){let r=hs[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function De(e,t="utf8"){let r=hs[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Se=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},Et=class extends Error{static name="ValidationError";name="ValidationError"},ms=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},ys=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var gs=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let w=Number.parseInt(l,t);if(!Number.isNaN(w))return w});if(u===void 0)break;if(s*=t,s+=u,s>f||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var n1=45,o1=15,bs=new gs;function El(e){if(!(e.length>o1))return bs.new(e).parseWith(()=>bs.readIPv4Addr())}function Sl(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>n1))return bs.new(e).parseWith(()=>bs.readIPv6Addr())}function ws(e){return!!El(e)}function vl(e){return!!Sl(e)}function Ra(e){return t=>De(t,e)}function ka(e){return t=>Ve(t,e)}function Vr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function mr(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Al(e){let t=e.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 r=Ve(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=mr(n);return Fr([r,o],r.length+o.length)}function Cl(e){let t=e.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 r=zt.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=mr(n);return Fr([r,o],r.length+o.length)}function Fa(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=De(t,"base32"),o=Vr(r);return`${n}:${o}`}var Ma=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new Se("Invalid byte value in IP address");t[n]=o}),t},Il=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=ws(r[n]),i;s&&(i=Ma(r[n]),r[n]=De(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,De(i.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let s=parseInt(r[n],16);if(isNaN(s)||s<0||s>65535)throw new Se("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Bl=function(e){if(e.byteLength!==4)throw new Se("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Tl=function(e){if(e.byteLength!==16)throw new Se("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],s=e[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new Se(`Invalid IPv6 address "${r}"`)}};function Dl(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new Se(`Invalid IPv6 address "${e}"`)}}var Na=Object.values(hr).map(e=>e.decoder),s1=(function(){let e=Na[0].or(Na[1]);return Na.slice(2).forEach(t=>e=e.or(t)),e})();function Ul(e){return s1.decode(e)}function Pl(e){return t=>e.encoder.encode(t)}function i1(e){if(parseInt(e).toString()!==e)throw new Et("Value must be an integer")}function a1(e){if(e<0)throw new Et("Value must be a positive integer, or zero")}function c1(e){return t=>{if(t>e)throw new Et(`Value must be smaller than or equal to ${e}`)}}function f1(...e){return t=>{for(let r of e)r(t)}}var to=f1(i1,a1,c1(65535));var ge=-1,$a=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new ys(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},St=new $a,K1=[{code:4,name:"ip4",size:32,valueToBytes:Ma,bytesToValue:Bl,validate:e=>{if(!ws(e))throw new Et(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:mr,bytesToValue:Vr,validate:to},{code:273,name:"udp",size:16,valueToBytes:mr,bytesToValue:Vr,validate:to},{code:33,name:"dccp",size:16,valueToBytes:mr,bytesToValue:Vr,validate:to},{code:41,name:"ip6",size:128,valueToBytes:Il,bytesToValue:Tl,stringToValue:Dl,validate:e=>{if(!vl(e))throw new Et(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ge},{code:43,name:"ipcidr",size:8,bytesToValue:Ra("base10"),valueToBytes:ka("base10")},{code:53,name:"dns",size:ge},{code:54,name:"dns4",size:ge},{code:55,name:"dns6",size:ge},{code:56,name:"dnsaddr",size:ge},{code:132,name:"sctp",size:16,valueToBytes:mr,bytesToValue:Vr,validate:to},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ge,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ge,bytesToValue:Ra("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?ka("base58btc")(e):_.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Fa,valueToBytes:Al},{code:445,name:"onion3",size:296,bytesToValue:Fa,valueToBytes:Cl},{code:446,name:"garlic64",size:ge},{code:447,name:"garlic32",size:ge},{code:448,name:"tls"},{code:449,name:"sni",size:ge},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ge,bytesToValue:Pl(pr),valueToBytes:Ul},{code:480,name:"http"},{code:481,name:"http-path",size:ge,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ge}];K1.forEach(e=>{St.addProtocol(e)});function _l(e){let t=[],r=0;for(;r<e.length;){let n=fa(e,r),o=St.getProtocol(n),s=kr(n),i=V1(o,e,r+s),a=0;i>0&&o.size===ge&&(a=kr(i));let c=s+a+i,f={code:n,name:o.name,bytes:ua(e.subarray(r,r+c))};if(i>0){let u=r+s+a,l=e.subarray(u,u+i);f.value=o.bytesToValue?.(l)??De(l)}t.push(f),r+=c}return t}function Ol(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=St.getProtocol(n.code),s=kr(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??Ve(n.value),a=i.byteLength,o.size===ge&&(c=kr(a)));let f=new Uint8Array(s+c+a),u=0;ca(n.code,f,u),u+=s,i!=null&&(o.size===ge&&(ca(a,f,u),u+=c),f.set(i,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Fr(r,t)}function Ll(e){if(e.charAt(0)!=="/")throw new Se('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let s=1;s<e.length;s++){let i=e.charAt(s);i!=="/"&&(r==="protocol"?o+=e.charAt(s):n+=e.charAt(s));let a=s===e.length-1;if(i==="/"||a){let c=St.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new Se(`Component ${o} was missing value`);r="value"}else if(r==="value"){let f={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new Se(`Component ${o} was missing value`);f.value=c.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new Se("Incomplete multiaddr");return t}function Nl(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=St.getProtocol(t.code);if(r==null)throw new Se(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function V1(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:fa(t,r)}var q1=Symbol.for("nodejs.util.inspect.custom"),Wa=Symbol.for("@multiformats/multiaddr");function H1(e){if(e==null&&(e="/"),yr(e))return e.getComponents();if(e instanceof Uint8Array)return _l(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Ll(e);if(Array.isArray(e))return e;throw new Se("Must be a string, Uint8Array, Component[], or another Multiaddr")}var xs=class e{[Wa]=!0;#e;#t;#r;constructor(t="/",r={}){this.#e=H1(t),r.validate!==!1&&G1(this)}get bytes(){return this.#r==null&&(this.#r=Ol(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Nl(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(t=>({...t}))]}encapsulate(t){let r=new e(t);return new e([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new ms(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===t){r=n;break}return new e(this.#e.slice(0,r),{validate:!1})}equals(t){return na(this.bytes,t.bytes)}[q1](){return`Multiaddr(${this.toString()})`}};function G1(e){e.getComponents().forEach(t=>{let r=St.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function yr(e){return!!e?.[Wa]}function Q(e){return new xs(e)}var cc={};z(cc,{code:()=>F2,decode:()=>$2,decodeOptions:()=>R2,encode:()=>M2,encodeOptions:()=>L2,name:()=>k2,toByteView:()=>Kp});var W1=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function Za(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=Z1(e);return r||"Object"}function Z1(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(W1.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var B=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ro=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",X1=new TextEncoder;function Es(e){return ro&&globalThis.Buffer.isBuffer(e)}function gr(e){return e instanceof Uint8Array?Es(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Y1=24,J1=200,qr=ro?e=>e.length>=Y1?globalThis.Buffer.from(e):Rl(e):e=>e.length>=J1?X1.encode(e):Rl(e),lt=e=>Uint8Array.from(e),Fl=ro?(e,t,r)=>Es(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Ml=ro?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),gr(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},$l=ro?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ss(e,t){if(Es(e)&&Es(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Rl(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var kl=4096;function zl(e){let t=e.length;if(t<=kl)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=kl));return r}var Q1=256,no=class{constructor(t=Q1){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=$l(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Fl(n,0,this.cursor)}else r=Ml(this.chunks,this.cursor);return t&&this.reset(),r}},vs=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var R="CBOR decode error:",pt="CBOR encode error:",oo=[];oo[23]=1;oo[24]=2;oo[25]=3;oo[26]=5;oo[27]=9;function vt(e,t,r){if(e.length-t<r)throw new Error(`${R} not enough data for type`)}var be=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ke(e,t,r){vt(e,t,1);let n=e[t];if(r.strict===!0&&n<be[0])throw new Error(`${R} integer encoded in more bytes than necessary (strict decode)`);return n}function Fe(e,t,r){vt(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<be[1])throw new Error(`${R} integer encoded in more bytes than necessary (strict decode)`);return n}function Me(e,t,r){vt(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<be[2])throw new Error(`${R} integer encoded in more bytes than necessary (strict decode)`);return n}function $e(e,t,r){vt(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<be[3])throw new Error(`${R} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${R} integers outside of the safe integer range are not supported`)}function jl(e,t,r,n){return new B(p.uint,ke(e,t+1,n),2)}function Kl(e,t,r,n){return new B(p.uint,Fe(e,t+1,n),3)}function Vl(e,t,r,n){return new B(p.uint,Me(e,t+1,n),5)}function ql(e,t,r,n){return new B(p.uint,$e(e,t+1,n),9)}function qe(e,t){return ee(e,0,t.value)}function ee(e,t,r){if(r<be[0]){let n=Number(r);e.push([t|n])}else if(r<be[1]){let n=Number(r);e.push([t|24,n])}else if(r<be[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<be[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<be[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),i=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=i&255,i=i>>8,o[3]=i&255,i=i>>8,o[2]=i&255,i=i>>8,o[1]=i&255,e.push(o)}else throw new Error(`${R} encountered BigInt larger than allowable range`)}}qe.encodedSize=function(t){return ee.encodedSize(t.value)};ee.encodedSize=function(t){return t<be[0]?1:t<be[1]?2:t<be[2]?3:t<be[3]?5:9};qe.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Hl(e,t,r,n){return new B(p.negint,-1-ke(e,t+1,n),2)}function Gl(e,t,r,n){return new B(p.negint,-1-Fe(e,t+1,n),3)}function Wl(e,t,r,n){return new B(p.negint,-1-Me(e,t+1,n),5)}var Xa=BigInt(-1),Zl=BigInt(1);function Xl(e,t,r,n){let o=$e(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new B(p.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${R} integers outside of the safe integer range are not supported`);return new B(p.negint,Xa-BigInt(o),9)}function As(e,t){let r=t.value,n=typeof r=="bigint"?r*Xa-Zl:r*-1-1;ee(e,t.type.majorEncoded,n)}As.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Xa-Zl:r*-1-1;return n<be[0]?1:n<be[1]?2:n<be[2]?3:n<be[3]?5:9};As.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function so(e,t,r,n){vt(e,t,r+n);let o=e.slice(t+r,t+r+n);return new B(p.bytes,o,r+n)}function Yl(e,t,r,n){return so(e,t,1,r)}function Jl(e,t,r,n){return so(e,t,2,ke(e,t+1,n))}function Ql(e,t,r,n){return so(e,t,3,Fe(e,t+1,n))}function ep(e,t,r,n){return so(e,t,5,Me(e,t+1,n))}function tp(e,t,r,n){let o=$e(e,t+1,n);if(typeof o=="bigint")throw new Error(`${R} 64-bit integer bytes lengths not supported`);return so(e,t,9,o)}function Cs(e){return e.encodedBytes===void 0&&(e.encodedBytes=p.equals(e.type,p.string)?qr(e.value):e.value),e.encodedBytes}function Hr(e,t){let r=Cs(t);ee(e,t.type.majorEncoded,r.length),e.push(r)}Hr.encodedSize=function(t){let r=Cs(t);return ee.encodedSize(r.length)+r.length};Hr.compareTokens=function(t,r){return t2(Cs(t),Cs(r))};function t2(e,t){return e.length<t.length?-1:e.length>t.length?1:Ss(e,t)}var rp=new TextDecoder,n2=32;function o2(e,t,r){if(r-t<n2){let o="";for(let s=t;s<r;s++){let i=e[s];if(i&128)return rp.decode(e.subarray(t,r));o+=String.fromCharCode(i)}return o}return rp.decode(e.subarray(t,r))}function io(e,t,r,n,o){let s=r+n;vt(e,t,s);let i=new B(p.string,o2(e,t+r,t+s),s);return o.retainStringBytes===!0&&(i.byteValue=e.slice(t+r,t+s)),i}function np(e,t,r,n){return io(e,t,1,r,n)}function op(e,t,r,n){return io(e,t,2,ke(e,t+1,n),n)}function sp(e,t,r,n){return io(e,t,3,Fe(e,t+1,n),n)}function ip(e,t,r,n){return io(e,t,5,Me(e,t+1,n),n)}function ap(e,t,r,n){let o=$e(e,t+1,n);if(typeof o=="bigint")throw new Error(`${R} 64-bit integer string lengths not supported`);return io(e,t,9,o,n)}var cp=Hr;function Gr(e,t,r,n){return new B(p.array,n,r)}function fp(e,t,r,n){return Gr(e,t,1,r)}function up(e,t,r,n){return Gr(e,t,2,ke(e,t+1,n))}function dp(e,t,r,n){return Gr(e,t,3,Fe(e,t+1,n))}function lp(e,t,r,n){return Gr(e,t,5,Me(e,t+1,n))}function pp(e,t,r,n){let o=$e(e,t+1,n);if(typeof o=="bigint")throw new Error(`${R} 64-bit integer array lengths not supported`);return Gr(e,t,9,o)}function hp(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${R} indefinite length items not allowed`);return Gr(e,t,1,1/0)}function Is(e,t){ee(e,p.array.majorEncoded,t.value)}Is.compareTokens=qe.compareTokens;Is.encodedSize=function(t){return ee.encodedSize(t.value)};function Wr(e,t,r,n){return new B(p.map,n,r)}function mp(e,t,r,n){return Wr(e,t,1,r)}function yp(e,t,r,n){return Wr(e,t,2,ke(e,t+1,n))}function gp(e,t,r,n){return Wr(e,t,3,Fe(e,t+1,n))}function bp(e,t,r,n){return Wr(e,t,5,Me(e,t+1,n))}function wp(e,t,r,n){let o=$e(e,t+1,n);if(typeof o=="bigint")throw new Error(`${R} 64-bit integer map lengths not supported`);return Wr(e,t,9,o)}function xp(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${R} indefinite length items not allowed`);return Wr(e,t,1,1/0)}function Bs(e,t){ee(e,p.map.majorEncoded,t.value)}Bs.compareTokens=qe.compareTokens;Bs.encodedSize=function(t){return ee.encodedSize(t.value)};function Ep(e,t,r,n){return new B(p.tag,r,1)}function Sp(e,t,r,n){return new B(p.tag,ke(e,t+1,n),2)}function vp(e,t,r,n){return new B(p.tag,Fe(e,t+1,n),3)}function Ap(e,t,r,n){return new B(p.tag,Me(e,t+1,n),5)}function Cp(e,t,r,n){return new B(p.tag,$e(e,t+1,n),9)}function Ts(e,t){ee(e,p.tag.majorEncoded,t.value)}Ts.compareTokens=qe.compareTokens;Ts.encodedSize=function(t){return ee.encodedSize(t.value)};var Ya=20,Ja=21,Qa=22,ec=23;function Ip(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${R} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new B(p.null,null,1):new B(p.undefined,void 0,1)}function Bp(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${R} indefinite length items not allowed`);return new B(p.break,void 0,1)}function tc(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${R