kubo-rpc-client
Version:
A client library for the Kubo RPC API
2 lines • 234 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 Cm=Object.create;var Hn=Object.defineProperty;var Im=Object.getOwnPropertyDescriptor;var Bm=Object.getOwnPropertyNames;var Pm=Object.getPrototypeOf,Tm=Object.prototype.hasOwnProperty;var $t=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ue=(e,t)=>{for(var r in t)Hn(e,r,{get:t[r],enumerable:!0})},kc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bm(t))!Tm.call(e,o)&&o!==r&&Hn(e,o,{get:()=>t[o],enumerable:!(n=Im(t,o))||n.enumerable});return e};var Mt=(e,t,r)=>(r=e!=null?Cm(Pm(e)):{},kc(t||!e||!e.__esModule?Hn(r,"default",{value:e,enumerable:!0}):r,e)),_m=e=>kc(Hn({},"__esModule",{value:!0}),e);var ll=$t((N6,ul)=>{function Fw(){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)}ul.exports=Fw});var bn=$t(($6,gl)=>{"use strict";function yl(e,t){for(let r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function Vw(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 yl(e,r)}catch{r.message=e.message,r.stack=e.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),yl(new o,r)}}gl.exports=Vw});var Hh=$t((wB,Vh)=>{"use strict";Vh.exports=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}});var Zh=$t((Gh,Wh)=>{"use strict";var ss=Hh(),{hasOwnProperty:qh}=Object.prototype,{propertyIsEnumerable:Vx}=Object,qr=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),Hx=Gh,jh={concatArrays:!1,ignoreUndefined:!1},is=e=>{let t=[];for(let r in e)qh.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(e);for(let n of r)Vx.call(e,n)&&t.push(n)}return t};function zr(e){return Array.isArray(e)?jx(e):ss(e)?qx(e):e}function jx(e){let t=e.slice(0,0);return is(e).forEach(r=>{qr(t,r,zr(e[r]))}),t}function qx(e){let t=Object.getPrototypeOf(e)===null?Object.create(null):{};return is(e).forEach(r=>{qr(t,r,zr(e[r]))}),t}var zh=(e,t,r,n)=>(r.forEach(o=>{typeof t[o]>"u"&&n.ignoreUndefined||(o in e&&e[o]!==Object.getPrototypeOf(e)?qr(e,o,yc(e[o],t[o],n)):qr(e,o,zr(t[o])))}),e),zx=(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++)qh.call(s,a)&&(i.push(String(a)),s===e?qr(n,o++,s[a]):qr(n,o++,zr(s[a])));n=zh(n,s,is(s).filter(a=>!i.includes(a)),r)}),n};function yc(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?zx(e,t,r):!ss(t)||!ss(e)?zr(t):zh(e,t,is(t),r)}Wh.exports=function(...e){let t=yc(zr(jh),this!==Hx&&this||{},jh),r={_:{}};for(let n of e)if(n!==void 0){if(!ss(n))throw new TypeError("`"+n+"` is not an Option Object");r=yc(r,{_:n},t)}return r._}});var bc=$t((vB,np)=>{"use strict";var Wx=typeof navigator<"u"&&navigator.product==="ReactNative";function Zx(){return Wx?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var Mn=self.URL,rp=Zx(),wc=class{constructor(t="",r=rp){this.super=new Mn(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 Mn.createObjectURL(t)}static revokeObjectURL(t){Mn.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Yx(e){if(typeof e=="string")return new Mn(e).toString();if(!(e instanceof Mn)){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||"",u=e.pathname||"",f=e.path||u+a;return`${o}${t||r}${s||i+n}${f}${c}`}}np.exports={URLWithLegacySupport:wc,URLSearchParams:self.URLSearchParams,defaultBase:rp,format:Yx}});var ip=$t((CB,sp)=>{"use strict";var{URLWithLegacySupport:op,format:Xx}=bc();sp.exports=(e,t={},r={},n)=>{let o=t.protocol?t.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new op(e)}catch{s={}}let i=Object.assign({},t,{protocol:o||s.protocol,host:t.host||s.host});return new op(e,Xx(i)).toString()}});var cp=$t((IB,ap)=>{"use strict";var{URLWithLegacySupport:Jx,format:Qx,URLSearchParams:e1,defaultBase:t1}=bc(),r1=ip();ap.exports={URL:Jx,URLSearchParams:e1,format:Qx,relative:r1,defaultBase:t1}});var L1={};ue(L1,{CID:()=>I,RoutingEventTypes:()=>cc,RoutingMessageType:()=>fc,StrictNoSign:()=>R1,StrictSign:()=>D1,create:()=>N1,createBitswap:()=>tc,createBlock:()=>rc,createBootstrap:()=>nc,createConfig:()=>oc,createDAG:()=>ac,createDHT:()=>uc,createDiag:()=>lc,createFiles:()=>hc,createKey:()=>pc,createKuboRPCClient:()=>N1,createLog:()=>Sc,createName:()=>Ac,createObject:()=>vc,createPin:()=>Cc,createPubsub:()=>Ic,createRefs:()=>Bc,createRepo:()=>Pc,createRouting:()=>Tc,createStats:()=>_c,createSwarm:()=>Uc,multiaddr:()=>Q,readURLContent:()=>vm,urlSource:()=>k1});function Se(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 ct(e=0){return new Uint8Array(e)}function De(e=0){return new Uint8Array(e)}var Um=Math.pow(2,7),Dm=Math.pow(2,14),Rm=Math.pow(2,21),Ss=Math.pow(2,28),As=Math.pow(2,35),vs=Math.pow(2,42),Cs=Math.pow(2,49),ne=128,Ae=127;function tt(e){if(e<Um)return 1;if(e<Dm)return 2;if(e<Rm)return 3;if(e<Ss)return 4;if(e<As)return 5;if(e<vs)return 6;if(e<Cs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Jr(e,t,r=0){switch(tt(e)){case 8:t[r++]=e&255|ne,e/=128;case 7:t[r++]=e&255|ne,e/=128;case 6:t[r++]=e&255|ne,e/=128;case 5:t[r++]=e&255|ne,e/=128;case 4:t[r++]=e&255|ne,e>>>=7;case 3:t[r++]=e&255|ne,e>>>=7;case 2:t[r++]=e&255|ne,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Is(e,t){let r=e[t],n=0;if(n+=r&Ae,r<ne||(r=e[t+1],n+=(r&Ae)<<7,r<ne)||(r=e[t+2],n+=(r&Ae)<<14,r<ne)||(r=e[t+3],n+=(r&Ae)<<21,r<ne)||(r=e[t+4],n+=(r&Ae)*Ss,r<ne)||(r=e[t+5],n+=(r&Ae)*As,r<ne)||(r=e[t+6],n+=(r&Ae)*vs,r<ne)||(r=e[t+7],n+=(r&Ae)*Cs,r<ne))return n;throw new RangeError("Could not decode varint")}function Nm(e,t){let r=e.get(t),n=0;if(n+=r&Ae,r<ne||(r=e.get(t+1),n+=(r&Ae)<<7,r<ne)||(r=e.get(t+2),n+=(r&Ae)<<14,r<ne)||(r=e.get(t+3),n+=(r&Ae)<<21,r<ne)||(r=e.get(t+4),n+=(r&Ae)*Ss,r<ne)||(r=e.get(t+5),n+=(r&Ae)*As,r<ne)||(r=e.get(t+6),n+=(r&Ae)*vs,r<ne)||(r=e.get(t+7),n+=(r&Ae)*Cs,r<ne))return n;throw new RangeError("Could not decode varint")}function Bs(e,t=0){return e instanceof Uint8Array?Is(e,t):Nm(e,t)}function ft(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=De(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Ds={};ue(Ds,{base10:()=>Vm});var z1=new Uint8Array(0);function Lc(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 qe(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Oc(e){return new TextEncoder().encode(e)}function Kc(e){return new TextDecoder().decode(e)}function Lm(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),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var v=0,S=0,m=0,P=p.length;m!==P&&p[m]===0;)m++,v++;for(var b=(P-m)*f+1>>>0,T=new Uint8Array(b);m!==P;){for(var N=p[m],$=0,M=b-1;(N!==0||$<S)&&M!==-1;M--,$++)N+=256*T[M]>>>0,T[M]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");S=$,m++}for(var A=b-S;A!==b&&T[A]===0;)A++;for(var C=c.repeat(v);A<b;++A)C+=e.charAt(T[A]);return C}function y(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var v=0;if(p[v]!==" "){for(var S=0,m=0;p[v]===c;)S++,v++;for(var P=(p.length-v)*u+1>>>0,b=new Uint8Array(P);p[v];){var T=r[p.charCodeAt(v)];if(T===255)return;for(var N=0,$=P-1;(T!==0||N<m)&&$!==-1;$--,N++)T+=a*b[$]>>>0,b[$]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");m=N,v++}if(p[v]!==" "){for(var M=P-m;M!==P&&b[M]===0;)M++;for(var A=new Uint8Array(S+(P-M)),C=S;M!==P;)A[C++]=b[M++];return A}}}function B(p){var v=y(p);if(v)return v;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:y,decode:B}}var Om=Lm,Km=Om,Mc=Km;var Ps=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")}},Ts=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 Fc(this,t)}},_s=class{decoders;constructor(t){this.decoders=t}or(t){return Fc(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 Fc(e,t){return new _s({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Us=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 Ps(t,r,n),this.decoder=new Ts(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ir({name:e,prefix:t,encode:r,decode:n}){return new Us(e,t,r,n)}function Ct({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Mc(r,e);return ir({prefix:t,name:e,encode:n,decode:s=>qe(o(s))})}function $m(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 u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,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 Mm(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 Fm(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function ae({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Fm(n);return ir({prefix:t,name:e,encode(s){return Mm(s,n,r)},decode(s){return $m(s,o,r,e)}})}var Vm=Ct({prefix:"9",name:"base10",alphabet:"0123456789"});var Rs={};ue(Rs,{base16:()=>Hm,base16upper:()=>jm});var Hm=ae({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),jm=ae({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ns={};ue(Ns,{base2:()=>qm});var qm=ae({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ks={};ue(ks,{base256emoji:()=>Ym});var Vc=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}"),zm=Vc.reduce((e,t,r)=>(e[r]=t,e),[]),Gm=Vc.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Wm(e){return e.reduce((t,r)=>(t+=zm[r],t),"")}function Zm(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Gm[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Ym=ir({prefix:"\u{1F680}",name:"base256emoji",encode:Wm,decode:Zm});var Ls={};ue(Ls,{base32:()=>rt,base32hex:()=>e0,base32hexpad:()=>r0,base32hexpadupper:()=>n0,base32hexupper:()=>t0,base32pad:()=>Jm,base32padupper:()=>Qm,base32upper:()=>Xm,base32z:()=>o0});var rt=ae({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xm=ae({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jm=ae({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qm=ae({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e0=ae({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t0=ae({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r0=ae({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),n0=ae({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),o0=ae({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Os={};ue(Os,{base36:()=>Qr,base36upper:()=>s0});var Qr=Ct({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),s0=Ct({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ks={};ue(Ks,{base58btc:()=>te,base58flickr:()=>i0});var te=Ct({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),i0=Ct({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $s={};ue($s,{base64:()=>ar,base64pad:()=>a0,base64url:()=>Ft,base64urlpad:()=>c0});var ar=ae({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),a0=ae({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ft=ae({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),c0=ae({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ms={};ue(Ms,{base8:()=>f0});var f0=ae({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fs={};ue(Fs,{identity:()=>u0});var u0=ir({prefix:"\0",name:"identity",encode:e=>Kc(e),decode:e=>Oc(e)});var Vs={};ue(Vs,{code:()=>p0,decode:()=>y0,encode:()=>m0,name:()=>h0});var l0=new TextEncoder,d0=new TextDecoder,h0="json",p0=512;function m0(e){return l0.encode(JSON.stringify(e))}function y0(e){return JSON.parse(d0.decode(e))}var Hs={};ue(Hs,{code:()=>w0,decode:()=>x0,encode:()=>b0,name:()=>g0});var g0="raw",w0=85;function b0(e){return qe(e)}function x0(e){return qe(e)}var qs={};ue(qs,{identity:()=>Pe});var E0=qc,Hc=128,S0=127,A0=~S0,v0=Math.pow(2,31);function qc(e,t,r){t=t||[],r=r||0;for(var n=r;e>=v0;)t[r++]=e&255|Hc,e/=128;for(;e&A0;)t[r++]=e&255|Hc,e>>>=7;return t[r]=e|0,qc.bytes=r-n+1,t}var C0=js,I0=128,jc=127;function js(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw js.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&jc)<<o:(i&jc)*Math.pow(2,o),o+=7}while(i>=I0);return js.bytes=s-n,r}var B0=Math.pow(2,7),P0=Math.pow(2,14),T0=Math.pow(2,21),_0=Math.pow(2,28),U0=Math.pow(2,35),D0=Math.pow(2,42),R0=Math.pow(2,49),N0=Math.pow(2,56),k0=Math.pow(2,63),L0=function(e){return e<B0?1:e<P0?2:e<T0?3:e<_0?4:e<U0?5:e<D0?6:e<R0?7:e<N0?8:e<k0?9:10},O0={encode:E0,decode:C0,encodingLength:L0},K0=O0,en=K0;function tn(e,t=0){return[en.decode(e,t),en.decode.bytes]}function cr(e,t,r=0){return en.encode(e,t,r),t}function fr(e){return en.encodingLength(e)}function nt(e,t){let r=t.byteLength,n=fr(e),o=n+fr(r),s=new Uint8Array(o+r);return cr(e,s,0),cr(r,s,n),s.set(t,o),new ur(e,r,t,s)}function rn(e){let t=qe(e),[r,n]=tn(t),[o,s]=tn(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ur(r,o,i,t)}function zc(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Lc(e.bytes,r.bytes)}}var ur=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var Gc=0,$0="identity",Wc=qe;function M0(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 nt(Gc,Wc(e))}var Pe={code:Gc,name:$0,encode:Wc,digest:M0};var Ws={};ue(Ws,{sha256:()=>nn,sha512:()=>V0});var F0=20;function Gs({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new zs(e,t,r,n,o)}var zs=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??F0,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?Zc(n,this.code,r?.truncate):n.then(o=>Zc(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Zc(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 nt(t,e)}function Xc(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var nn=Gs({name:"sha2-256",code:18,encode:Xc("SHA-256")}),V0=Gs({name:"sha2-512",code:19,encode:Xc("SHA-512")});function Jc(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return j0(r,Zs(e),t??te.encoder);default:return q0(r,Zs(e),t??rt.encoder)}}var Qc=new WeakMap;function Zs(e){let t=Qc.get(e);if(t==null){let r=new Map;return Qc.set(e,r),r}return t}var I=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==on)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==z0)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=nt(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&&zc(t.multihash,n.multihash)}toString(t){return Jc(this,t)}toJSON(){return{"/":Jc(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??ef(n,o,s.bytes))}else if(r[G0]===!0){let{version:n,multihash:o,code:s}=r,i=rn(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!==on)throw new Error(`Version 0 CID must use dag-pb (code: ${on}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ef(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,on,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=qe(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 ur(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,y]=tn(t.subarray(r));return r+=y,l},o=n(),s=on;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(),u=r+c,f=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=H0(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 Zs(s).set(n,t),s}};function H0(e,t){switch(e[0]){case"Q":{let r=t??te;return[te.prefix,r.decode(`${te.prefix}${e}`)]}case te.prefix:{let r=t??te;return[te.prefix,r.decode(e)]}case rt.prefix:{let r=t??rt;return[rt.prefix,r.decode(e)]}case Qr.prefix:{let r=t??Qr;return[Qr.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 j0(e,t,r){let{prefix:n}=r;if(n!==te.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 q0(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 on=112,z0=18;function ef(e,t,r){let n=fr(e),o=n+fr(t),s=new Uint8Array(o+r.byteLength);return cr(e,s,0),cr(t,s,n),s.set(r,o),s}var G0=Symbol.for("@ipld/js-cid/CID");var Vt={...Fs,...Ns,...Ms,...Ds,...Rs,...Ls,...Os,...Ks,...$s,...ks},tf={...Ws,...qs},rf={raw:Hs,json:Vs};function of(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var nf=of("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Ys=of("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=De(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),W0={utf8:nf,"utf-8":nf,hex:Vt.base16,latin1:Ys,ascii:Ys,binary:Ys,...Vt},qn=W0;function Y(e,t="utf8"){let r=qn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=qn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var we=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ut=class extends Error{static name="ValidationError";name="ValidationError"},zn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Gn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Wn=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",u=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let y=Number.parseInt(l,t);if(!Number.isNaN(y))return y});if(f===void 0)break;if(s*=t,s+=f,s>u||(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 Z0=45,Y0=15,Zn=new Wn;function sf(e){if(!(e.length>Y0))return Zn.new(e).parseWith(()=>Zn.readIPv4Addr())}function af(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Z0))return Zn.new(e).parseWith(()=>Zn.readIPv6Addr())}function Yn(e){return!!sf(e)}function cf(e){return!!af(e)}function Js(e){return t=>q(t,e)}function Qs(e){return t=>Y(t,e)}function dr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Ht(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function ff(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=Y(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=Ht(n);return ft([r,o],r.length+o.length)}function uf(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=rt.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=Ht(n);return ft([r,o],r.length+o.length)}function ei(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=q(t,"base32"),o=dr(r);return`${n}:${o}`}var ti=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 we("Invalid byte value in IP address");t[n]=o}),t},lf=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=Yn(r[n]),i;s&&(i=ti(r[n]),r[n]=q(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,q(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 we("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},df=function(e){if(e.byteLength!==4)throw new we("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},hf=function(e){if(e.byteLength!==16)throw new we("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 we(`Invalid IPv6 address "${r}"`)}};function pf(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new we(`Invalid IPv6 address "${e}"`)}}var Xs=Object.values(Vt).map(e=>e.decoder),X0=(function(){let e=Xs[0].or(Xs[1]);return Xs.slice(2).forEach(t=>e=e.or(t)),e})();function mf(e){return X0.decode(e)}function yf(e){return t=>e.encoder.encode(t)}function J0(e){if(parseInt(e).toString()!==e)throw new ut("Value must be an integer")}function Q0(e){if(e<0)throw new ut("Value must be a positive integer, or zero")}function ey(e){return t=>{if(t>e)throw new ut(`Value must be smaller than or equal to ${e}`)}}function ty(...e){return t=>{for(let r of e)r(t)}}var sn=ty(J0,Q0,ey(65535));var de=-1,ri=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 Gn(`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)}))}},lt=new ri,ky=[{code:4,name:"ip4",size:32,valueToBytes:ti,bytesToValue:df,validate:e=>{if(!Yn(e))throw new ut(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ht,bytesToValue:dr,validate:sn},{code:273,name:"udp",size:16,valueToBytes:Ht,bytesToValue:dr,validate:sn},{code:33,name:"dccp",size:16,valueToBytes:Ht,bytesToValue:dr,validate:sn},{code:41,name:"ip6",size:128,valueToBytes:lf,bytesToValue:hf,stringToValue:pf,validate:e=>{if(!cf(e))throw new ut(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:de},{code:43,name:"ipcidr",size:8,bytesToValue:Js("base10"),valueToBytes:Qs("base10")},{code:53,name:"dns",size:de},{code:54,name:"dns4",size:de},{code:55,name:"dns6",size:de},{code:56,name:"dnsaddr",size:de},{code:132,name:"sctp",size:16,valueToBytes:Ht,bytesToValue:dr,validate:sn},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:de,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:de,bytesToValue:Js("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?Qs("base58btc")(e):I.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:ei,valueToBytes:ff},{code:445,name:"onion3",size:296,bytesToValue:ei,valueToBytes:uf},{code:446,name:"garlic64",size:de},{code:447,name:"garlic32",size:de},{code:448,name:"tls"},{code:449,name:"sni",size:de},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:de,bytesToValue:yf(Ft),valueToBytes:mf},{code:480,name:"http"},{code:481,name:"http-path",size:de,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:de}];ky.forEach(e=>{lt.addProtocol(e)});function gf(e){let t=[],r=0;for(;r<e.length;){let n=Bs(e,r),o=lt.getProtocol(n),s=tt(n),i=Ly(o,e,r+s),a=0;i>0&&o.size===de&&(a=tt(i));let c=s+a+i,u={code:n,name:o.name,bytes:e.subarray(r,r+c)};if(i>0){let f=r+s+a,l=e.subarray(f,f+i);u.value=o.bytesToValue?.(l)??q(l)}t.push(u),r+=c}return t}function wf(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=lt.getProtocol(n.code),s=tt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??Y(n.value),a=i.byteLength,o.size===de&&(c=tt(a)));let u=new Uint8Array(s+c+a),f=0;Jr(n.code,u,f),f+=s,i!=null&&(o.size===de&&(Jr(a,u,f),f+=c),u.set(i,f)),n.bytes=u}r.push(n.bytes),t+=n.bytes.byteLength}return ft(r,t)}function bf(e){if(e.charAt(0)!=="/")throw new we('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=lt.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 we(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new we(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}t.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new we("Incomplete multiaddr");return t}function xf(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=lt.getProtocol(t.code);if(r==null)throw new we(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Ly(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Bs(t,r)}var Oy=Symbol.for("nodejs.util.inspect.custom"),ui=Symbol.for("@multiformats/multiaddr");function Ky(e){if(e==null&&(e="/"),jt(e))return e.getComponents();if(e instanceof Uint8Array)return gf(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),bf(e);if(Array.isArray(e))return e;throw new we("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Xn=class e{[ui]=!0;#e;#t;#r;constructor(t="/",r={}){this.#e=Ky(t),r.validate!==!1&&$y(this)}get bytes(){return this.#r==null&&(this.#r=wf(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=xf(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 zn(`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 Se(this.bytes,t.bytes)}[Oy](){return`Multiaddr(${this.toString()})`}};function $y(e){e.getComponents().forEach(t=>{let r=lt.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function jt(e){return!!e?.[ui]}function Q(e){return new Xn(e)}var ho={};ue(ho,{code:()=>Sg,decode:()=>Si,decodeOptions:()=>xg,encode:()=>Ei,encodeOptions:()=>wg,name:()=>Eg,toByteView:()=>Cu});var My=["string","number","bigint","symbol"],Fy=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Ef(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(My.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Vy(e))return"Buffer";let r=Hy(e);return r||"Object"}function Vy(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Hy(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Fy.includes(t))return t}var d=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}};d.uint=new d(0,"uint",!0);d.negint=new d(1,"negint",!0);d.bytes=new d(2,"bytes",!0);d.string=new d(3,"string",!0);d.array=new d(4,"array",!1);d.map=new d(5,"map",!1);d.tag=new d(6,"tag",!1);d.float=new d(7,"float",!0);d.false=new d(7,"false",!0);d.true=new d(7,"true",!0);d.null=new d(7,"null",!0);d.undefined=new d(7,"undefined",!0);d.break=new d(7,"break",!0);var E=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 hr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",jy=new TextDecoder,qy=new TextEncoder;function Jn(e){return hr&&globalThis.Buffer.isBuffer(e)}function an(e){return e instanceof Uint8Array?Jn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Cf=hr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Af(e,t,r):(e,t,r)=>r-t>64?jy.decode(e.subarray(t,r)):Af(e,t,r),Qn=hr?e=>e.length>64?globalThis.Buffer.from(e):Sf(e):e=>e.length>64?qy.encode(e):Sf(e),ot=e=>Uint8Array.from(e),pr=hr?(e,t,r)=>Jn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),If=hr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),an(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},Bf=hr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Pf(e,t){if(Jn(e)&&Jn(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 Sf(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):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Af(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,i=o>239?4:o>223?3:o>191?2:1;if(t+i<=r){let a,c,u,f;switch(i){case 1:o<128&&(s=o);break;case 2:a=e[t+1],(a&192)===128&&(f=(o&31)<<6|a&63,f>127&&(s=f));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(f=(o&15)<<12|(a&63)<<6|c&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:a=e[t+1],c=e[t+2],u=e[t+3],(a&192)===128&&(c&192)===128&&(u&192)===128&&(f=(o&15)<<18|(a&63)<<12|(c&63)<<6|u&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=i}return li(n)}var vf=4096;function li(e){let t=e.length;if(t<=vf)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=vf));return r}var zy=256,cn=class{constructor(t=zy){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=Bf(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=pr(n,0,this.cursor)}else r=If(this.chunks,this.cursor);return t&&this.reset(),r}};var D="CBOR decode error:",dt="CBOR encode error:",fn=[];fn[23]=1;fn[24]=2;fn[25]=3;fn[26]=5;fn[27]=9;function ht(e,t,r){if(e.length-t<r)throw new Error(`${D} not enough data for type`)}var he=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Re(e,t,r){ht(e,t,1);let n=e[t];if(r.strict===!0&&n<he[0])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return n}function Ne(e,t,r){ht(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<he[1])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return n}function ke(e,t,r){ht(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<he[2])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(e,t,r){ht(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<he[3])throw new Error(`${D} 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(`${D} integers outside of the safe integer range are not supported`)}function Tf(e,t,r,n){return new E(d.uint,Re(e,t+1,n),2)}function _f(e,t,r,n){return new E(d.uint,Ne(e,t+1,n),3)}function Uf(e,t,r,n){return new E(d.uint,ke(e,t+1,n),5)}function Df(e,t,r,n){return new E(d.uint,Le(e,t+1,n),9)}function $e(e,t){return be(e,0,t.value)}function be(e,t,r){if(r<he[0]){let n=Number(r);e.push([t|n])}else if(r<he[1]){let n=Number(r);e.push([t|24,n])}else if(r<he[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<he[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<he[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(`${D} encountered BigInt larger than allowable range`)}}$e.encodedSize=function(t){return be.encodedSize(t.value)};be.encodedSize=function(t){return t<he[0]?1:t<he[1]?2:t<he[2]?3:t<he[3]?5:9};$e.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Rf(e,t,r,n){return new E(d.negint,-1-Re(e,t+1,n),2)}function Nf(e,t,r,n){return new E(d.negint,-1-Ne(e,t+1,n),3)}function kf(e,t,r,n){return new E(d.negint,-1-ke(e,t+1,n),5)}var di=BigInt(-1),Lf=BigInt(1);function Of(e,t,r,n){let o=Le(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new E(d.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${D} integers outside of the safe integer range are not supported`);return new E(d.negint,di-BigInt(o),9)}function eo(e,t){let r=t.value,n=typeof r=="bigint"?r*di-Lf:r*-1-1;be(e,t.type.majorEncoded,n)}eo.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*di-Lf:r*-1-1;return n<he[0]?1:n<he[1]?2:n<he[2]?3:n<he[3]?5:9};eo.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function un(e,t,r,n){ht(e,t,r+n);let o=pr(e,t+r,t+r+n);return new E(d.bytes,o,r+n)}function Kf(e,t,r,n){return un(e,t,1,r)}function $f(e,t,r,n){return un(e,t,2,Re(e,t+1,n))}function Mf(e,t,r,n){return un(e,t,3,Ne(e,t+1,n))}function Ff(e,t,r,n){return un(e,t,5,ke(e,t+1,n))}function Vf(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer bytes lengths not supported`);return un(e,t,9,o)}function to(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===d.string?Qn(e.value):e.value),e.encodedBytes}function mr(e,t){let r=to(t);be(e,t.type.majorEncoded,r.length),e.push(r)}mr.encodedSize=function(t){let r=to(t);return be.encodedSize(r.length)+r.length};mr.compareTokens=function(t,r){return Wy(to(t),to(r))};function Wy(e,t){return e.length<t.length?-1:e.length>t.length?1:Pf(e,t)}function ln(e,t,r,n,o){let s=r+n;ht(e,t,s);let i=new E(d.string,Cf(e,t+r,t+s),s);return o.retainStringBytes===!0&&(i.byteValue=pr(e,t+r,t+s)),i}function Hf(e,t,r,n){return ln(e,t,1,r,n)}function jf(e,t,r,n){return ln(e,t,2,Re(e,t+1,n),n)}function qf(e,t,r,n){return ln(e,t,3,Ne(e,t+1,n),n)}function zf(e,t,r,n){return ln(e,t,5,ke(e,t+1,n),n)}function Gf(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer string lengths not supported`);return ln(e,t,9,o,n)}var Wf=mr;function yr(e,t,r,n){return new E(d.array,n,r)}function Zf(e,t,r,n){return yr(e,t,1,r)}function Yf(e,t,r,n){return yr(e,t,2,Re(e,t+1,n))}function Xf(e,t,r,n){return yr(e,t,3,Ne(e,t+1,n))}function Jf(e,t,r,n){return yr(e,t,5,ke(e,t+1,n))}function Qf(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer array lengths not supported`);return yr(e,t,9,o)}function eu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${D} indefinite length items not allowed`);return yr(e,t,1,1/0)}function ro(e,t){be(e,d.array.majorEncoded,t.value)}ro.compareTokens=$e.compareTokens;ro.encodedSize=function(t){return be.encodedSize(t.value)};function gr(e,t,r,n){return new E(d.map,n,r)}function tu(e,t,r,n){return gr(e,t,1,r)}function ru(e,t,r,n){return gr(e,t,2,Re(e,t+1,n))}function nu(e,t,r,n){return gr(e,t,3,Ne(e,t+1,n))}function ou(e,t,r,n){return gr(e,t,5,ke(e,t+1,n))}function su(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer map lengths not supported`);return gr(e,t,9,o)}function iu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${D} indefinite length items not allowed`);return gr(e,t,1,1/0)}function no(e,t){be(e,d.map.majorEncoded,t.value)}no.compareTokens=$e.compareTokens;no.encodedSize=function(t){return be.encodedSize(t.value)};function au(e,t,r,n){return new E(d.tag,r,1)}function cu(e,t,r,n){return new E(d.tag,Re(e,t+1,n),2)}function fu(e,t,r,n){return new E(d.tag,Ne(e,t+1,n),3)}function uu(e,t,r,n){return new E(d.tag,ke(e,t+1,n),5)}function lu(e,t,r,n){return new E(d.tag,Le(e,t+1,n),9)}function oo(e,t){be(e,d.tag.majorEncoded,t.value)}oo.compareTokens=$e.compareTokens;oo.encodedSize=function(t){return be.encodedSize(t.value)};var eg=20,tg=21,rg=22,ng=23;function du(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${D} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new E(d.null,null,1):new E(d.undefined,void 0,1)}function hu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${D} indefinite length items not allowed`);return new E(d.break,void 0,1)}function hi(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${D} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e==