@libp2p/daemon-protocol 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDaemonProtocol = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PDaemonProtocol=(()=>{var kt=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var E=(i,e)=>{for(var t in e)kt(i,t,{get:e[t],enumerable:!0})},Qe=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Je(e))!We.call(i,n)&&n!==t&&kt(i,n,{get:()=>e[n],enumerable:!(r=Ke(e,n))||r.enumerable});return i};var Ve=i=>Qe(kt({},"__esModule",{value:!0}),i);var mi={};E(mi,{ConnManagerRequest:()=>dt,ConnectRequest:()=>it,DHTRequest:()=>ht,DHTResponse:()=>lt,DisconnectRequest:()=>at,ErrorResponse:()=>st,IdentifyResponse:()=>nt,PSMessage:()=>oe,PSRequest:()=>ut,PSResponse:()=>ft,PeerInfo:()=>F,PeerstoreRequest:()=>pt,PeerstoreResponse:()=>mt,Request:()=>ie,Response:()=>re,StreamHandlerRequest:()=>ot,StreamInfo:()=>ct,StreamOpenRequest:()=>rt});function B(i=0){return new Uint8Array(i)}var He=Math.pow(2,7),Ze=Math.pow(2,14),Ye=Math.pow(2,21),se=Math.pow(2,28),ce=Math.pow(2,35),he=Math.pow(2,42),le=Math.pow(2,49),m=128,O=127;function H(i){if(i<He)return 1;if(i<Ze)return 2;if(i<Ye)return 3;if(i<se)return 4;if(i<ce)return 5;if(i<he)return 6;if(i<le)return 7;if(Number.MAX_SAFE_INTEGER!=null&&i>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function de(i,e,t=0){switch(H(i)){case 8:e[t++]=i&255|m,i/=128;case 7:e[t++]=i&255|m,i/=128;case 6:e[t++]=i&255|m,i/=128;case 5:e[t++]=i&255|m,i/=128;case 4:e[t++]=i&255|m,i>>>=7;case 3:e[t++]=i&255|m,i>>>=7;case 2:e[t++]=i&255|m,i>>>=7;case 1:{e[t++]=i&255,i>>>=7;break}default:throw new Error("unreachable")}return e}function ae(i,e){let t=i[e],r=0;if(r+=t&O,t<m||(t=i[e+1],r+=(t&O)<<7,t<m)||(t=i[e+2],r+=(t&O)<<14,t<m)||(t=i[e+3],r+=(t&O)<<21,t<m)||(t=i[e+4],r+=(t&O)*se,t<m)||(t=i[e+5],r+=(t&O)*ce,t<m)||(t=i[e+6],r+=(t&O)*he,t<m)||(t=i[e+7],r+=(t&O)*le,t<m))return r;throw new RangeError("Could not decode varint")}var St=new Float32Array([-0]),P=new Uint8Array(St.buffer);function ue(i,e,t){St[0]=i,e[t]=P[0],e[t+1]=P[1],e[t+2]=P[2],e[t+3]=P[3]}function fe(i,e){return P[0]=i[e],P[1]=i[e+1],P[2]=i[e+2],P[3]=i[e+3],St[0]}var At=new Float64Array([-0]),p=new Uint8Array(At.buffer);function pe(i,e,t){At[0]=i,e[t]=p[0],e[t+1]=p[1],e[t+2]=p[2],e[t+3]=p[3],e[t+4]=p[4],e[t+5]=p[5],e[t+6]=p[6],e[t+7]=p[7]}function me(i,e){return p[0]=i[e],p[1]=i[e+1],p[2]=i[e+2],p[3]=i[e+3],p[4]=i[e+4],p[5]=i[e+5],p[6]=i[e+6],p[7]=i[e+7],At[0]}var qe=BigInt(Number.MAX_SAFE_INTEGER),je=BigInt(Number.MIN_SAFE_INTEGER),g=class i{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,r=~this.hi>>>0;return t===0&&(r=r+1>>>0),-(t+r*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,r=~this.hi>>>0;return t===0&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return r===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(e===0n)return G;if(e<qe&&e>je)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=~r|0n,n=~n|0n,++n>xe&&(n=0n,++r>xe&&(r=0n))),new i(Number(n),Number(r))}static fromNumber(e){if(e===0)return G;let t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)}static from(e){return typeof e=="number"?i.fromNumber(e):typeof e=="bigint"?i.fromBigInt(e):typeof e=="string"?i.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new i(e.low>>>0,e.high>>>0):G}},G=new g(0,0);G.toBigInt=function(){return 0n};G.zzEncode=G.zzDecode=function(){return this};G.length=function(){return 1};var xe=4294967296n;function Ee(i){let e=0,t=0;for(let r=0;r<i.length;++r)t=i.charCodeAt(r),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(i.charCodeAt(r+1)&64512)===56320?(++r,e+=4):e+=3;return e}function ge(i,e,t){if(t-e<1)return"";let n,o=[],s=0,c;for(;e<t;)c=i[e++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|i[e++]&63:c>239&&c<365?(c=((c&7)<<18|(i[e++]&63)<<12|(i[e++]&63)<<6|i[e++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(i[e++]&63)<<6|i[e++]&63,s>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,o)),s=0);return n!=null?(s>0&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Dt(i,e,t){let r=t,n,o;for(let s=0;s<i.length;++s)n=i.charCodeAt(s),n<128?e[t++]=n:n<2048?(e[t++]=n>>6|192,e[t++]=n&63|128):(n&64512)===55296&&((o=i.charCodeAt(s+1))&64512)===56320?(n=65536+((n&1023)<<10)+(o&1023),++s,e[t++]=n>>18|240,e[t++]=n>>12&63|128,e[t++]=n>>6&63|128,e[t++]=n&63|128):(e[t++]=n>>12|224,e[t++]=n>>6&63|128,e[t++]=n&63|128);return t-r}function k(i,e){return RangeError(`index out of range: ${i.pos} + ${e??1} > ${i.len}`)}function gt(i,e){return(i[e-4]|i[e-3]<<8|i[e-2]<<16|i[e-1]<<24)>>>0}var Ut=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,k(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw k(this,4);return gt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw k(this,4);return gt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw k(this,4);let e=fe(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw k(this,4);let e=me(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw k(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){let e=this.bytes();return ge(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw k(this,e);this.pos+=e}else do if(this.pos>=this.len)throw k(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new g(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw k(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw k(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw k(this,8);let e=gt(this.buf,this.pos+=4),t=gt(this.buf,this.pos+=4);return new g(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ae(this.buf,this.pos);return this.pos+=H(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function wt(i){return new Ut(i instanceof Uint8Array?i:i.subarray())}function a(i,e,t){let r=wt(i);return e.decode(r,void 0,t)}var Bt={};E(Bt,{base10:()=>sn});var wi=new Uint8Array(0);function ye(i,e){if(i===e)return!0;if(i.byteLength!==e.byteLength)return!1;for(let t=0;t<i.byteLength;t++)if(i[t]!==e[t])return!1;return!0}function T(i){if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")}function Ne(i){return new TextEncoder().encode(i)}function Ie(i){return new TextDecoder().decode(i)}function tn(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<i.length;n++){var o=i.charAt(n),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=n}var c=i.length,h=i.charAt(0),_=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function $(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,R=0,N=0,S=l.length;N!==S&&l[N]===0;)N++,x++;for(var A=(S-N)*b+1>>>0,y=new Uint8Array(A);N!==S;){for(var D=l[N],L=0,I=A-1;(D!==0||L<R)&&I!==-1;I--,L++)D+=256*y[I]>>>0,y[I]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");R=L,N++}for(var w=A-R;w!==A&&y[w]===0;)w++;for(var Et=h.repeat(x);w<A;++w)Et+=i.charAt(y[w]);return Et}function xt(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var R=0,N=0;l[x]===h;)R++,x++;for(var S=(l.length-x)*_+1>>>0,A=new Uint8Array(S);l[x];){var y=t[l.charCodeAt(x)];if(y===255)return;for(var D=0,L=S-1;(y!==0||D<N)&&L!==-1;L--,D++)y+=c*A[L]>>>0,A[L]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");N=D,x++}if(l[x]!==" "){for(var I=S-N;I!==S&&A[I]===0;)I++;for(var w=new Uint8Array(R+(S-I)),Et=R;I!==S;)w[Et++]=A[I++];return w}}}function Xe(l){var x=xt(l);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:$,decodeUnsafe:xt,decode:Xe}}var en=tn,nn=en,Se=nn;var Tt=class{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ct=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ae(this,e)}},Ft=class{decoders;constructor(e){this.decoders=e}or(e){return Ae(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r!=null)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ae(i,e){return new Ft({...i.decoders??{[i.prefix]:i},...e.decoders??{[e.prefix]:e}})}var Lt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Tt(e,t,r),this.decoder=new Ct(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function X({name:i,prefix:e,encode:t,decode:r}){return new Lt(i,e,t,r)}function M({name:i,prefix:e,alphabet:t}){let{encode:r,decode:n}=Se(t,i);return X({prefix:e,name:i,encode:r,decode:o=>T(n(o))})}function rn(i,e,t,r){let n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let o=i.length;for(;i[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,h=0,_=0;for(let b=0;b<o;++b){let $=n[i[b]];if($===void 0)throw new SyntaxError(`Non-${r} character`);h=h<<t|$,c+=t,c>=8&&(c-=8,s[_++]=255&h>>c)}if(c>=t||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return s}function on(i,e,t){let r=e[e.length-1]==="=",n=(1<<t)-1,o="",s=0,c=0;for(let h=0;h<i.length;++h)for(c=c<<8|i[h],s+=8;s>t;)s-=t,o+=e[n&c>>s];if(s!==0&&(o+=e[n&c<<t-s]),r)for(;o.length*t&7;)o+="=";return o}function d({name:i,prefix:e,bitsPerChar:t,alphabet:r}){return X({prefix:e,name:i,encode(n){return on(n,r,t)},decode(n){return rn(n,r,t,i)}})}var sn=M({prefix:"9",name:"base10",alphabet:"0123456789"});var Ot={};E(Ot,{base16:()=>cn,base16upper:()=>hn});var cn=d({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hn=d({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Pt={};E(Pt,{base2:()=>ln});var ln=d({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mt={};E(Mt,{base256emoji:()=>pn});var De=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}"),dn=De.reduce((i,e,t)=>(i[t]=e,i),[]),an=De.reduce((i,e,t)=>(i[e.codePointAt(0)]=t,i),[]);function un(i){return i.reduce((e,t)=>(e+=dn[t],e),"")}function fn(i){let e=[];for(let t of i){let r=an[t.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}var pn=X({prefix:"\u{1F680}",name:"base256emoji",encode:un,decode:fn});var Rt={};E(Rt,{base32:()=>K,base32hex:()=>gn,base32hexpad:()=>yn,base32hexpadupper:()=>Nn,base32hexupper:()=>bn,base32pad:()=>xn,base32padupper:()=>En,base32upper:()=>mn,base32z:()=>In});var K=d({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mn=d({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xn=d({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),En=d({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gn=d({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bn=d({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yn=d({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nn=d({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),In=d({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gt={};E(Gt,{base36:()=>kn,base36upper:()=>Sn});var kn=M({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sn=M({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var vt={};E(vt,{base58btc:()=>U,base58flickr:()=>An});var U=M({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),An=M({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var zt={};E(zt,{base64:()=>Dn,base64pad:()=>Un,base64url:()=>wn,base64urlpad:()=>Tn});var Dn=d({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Un=d({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wn=d({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Tn=d({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var _t={};E(_t,{base8:()=>Cn});var Cn=d({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $t={};E($t,{identity:()=>Fn});var Fn=X({prefix:"\0",name:"identity",encode:i=>Ie(i),decode:i=>Ne(i)});var Ki=new TextEncoder,Ji=new TextDecoder;var Kt={};E(Kt,{identity:()=>ti});var On=Te,Ue=128,Pn=127,Mn=~Pn,Rn=Math.pow(2,31);function Te(i,e,t){e=e||[],t=t||0;for(var r=t;i>=Rn;)e[t++]=i&255|Ue,i/=128;for(;i&Mn;)e[t++]=i&255|Ue,i>>>=7;return e[t]=i|0,Te.bytes=t-r+1,e}var Gn=Xt,vn=128,we=127;function Xt(i,r){var t=0,r=r||0,n=0,o=r,s,c=i.length;do{if(o>=c)throw Xt.bytes=0,new RangeError("Could not decode varint");s=i[o++],t+=n<28?(s&we)<<n:(s&we)*Math.pow(2,n),n+=7}while(s>=vn);return Xt.bytes=o-r,t}var zn=Math.pow(2,7),_n=Math.pow(2,14),$n=Math.pow(2,21),Xn=Math.pow(2,28),Kn=Math.pow(2,35),Jn=Math.pow(2,42),Wn=Math.pow(2,49),Qn=Math.pow(2,56),Vn=Math.pow(2,63),Hn=function(i){return i<zn?1:i<_n?2:i<$n?3:i<Xn?4:i<Kn?5:i<Jn?6:i<Wn?7:i<Qn?8:i<Vn?9:10},Zn={encode:On,decode:Gn,encodingLength:Hn},Yn=Zn,Z=Yn;function Y(i,e=0){return[Z.decode(i,e),Z.decode.bytes]}function J(i,e,t=0){return Z.encode(i,e,t),e}function W(i){return Z.encodingLength(i)}function v(i,e){let t=e.byteLength,r=W(i),n=r+W(t),o=new Uint8Array(n+t);return J(i,o,0),J(t,o,r),o.set(e,n),new Q(i,t,e,o)}function Ce(i){let e=T(i),[t,r]=Y(e),[n,o]=Y(e.subarray(r)),s=e.subarray(r+o);if(s.byteLength!==n)throw new Error("Incorrect length");return new Q(t,n,s,e)}function Fe(i,e){if(i===e)return!0;{let t=e;return i.code===t.code&&i.size===t.size&&t.bytes instanceof Uint8Array&&ye(i.bytes,t.bytes)}}var Q=class{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}};var Le=0,qn="identity",Be=T;function jn(i){return v(Le,Be(i))}var ti={code:Le,name:qn,encode:Be,digest:jn};var Qt={};E(Qt,{sha256:()=>ei,sha512:()=>ni});function Wt({name:i,code:e,encode:t}){return new Jt(i,e,t)}var Jt=class{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?v(this.code,t):t.then(r=>v(this.code,r))}else throw Error("Unknown type, must be binary type")}};function Pe(i){return async e=>new Uint8Array(await crypto.subtle.digest(i,e))}var ei=Wt({name:"sha2-256",code:18,encode:Pe("SHA-256")}),ni=Wt({name:"sha2-512",code:19,encode:Pe("SHA-512")});function Me(i,e){let{bytes:t,version:r}=i;switch(r){case 0:return ri(t,Vt(i),e??U.encoder);default:return oi(t,Vt(i),e??K.encoder)}}var Re=new WeakMap;function Vt(i){let e=Re.get(i);if(e==null){let t=new Map;return Re.set(i,t),t}return e}var yt=class i{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==j)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==si)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return i.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,r=v(e,t);return i.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return i.equals(this,e)}static equals(e,t){let r=t;return r!=null&&e.code===r.code&&e.version===r.version&&Fe(e.multihash,r.multihash)}toString(e){return Me(this,e)}toJSON(){return{"/":Me(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof i)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:r,code:n,multihash:o,bytes:s}=t;return new i(r,n,o,s??Ge(r,n,o.bytes))}else if(t[ci]===!0){let{version:r,multihash:n,code:o}=t,s=Ce(n);return i.create(r,o,s)}else return null}static create(e,t,r){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==j)throw new Error(`Version 0 CID must use dag-pb (code: ${j}) block encoding`);return new i(e,t,r,r.bytes)}case 1:{let n=Ge(e,t,r.bytes);return new i(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return i.create(0,j,e)}static createV1(e,t){return i.create(1,e,t)}static decode(e){let[t,r]=i.decodeFirst(e);if(r.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=i.inspectBytes(e),r=t.size-t.multihashSize,n=T(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=n.subarray(t.multihashSize-t.digestSize),s=new Q(t.multihashCode,t.digestSize,o,n);return[t.version===0?i.createV0(s):i.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,r=()=>{let[$,xt]=Y(e.subarray(t));return t+=xt,$},n=r(),o=j;if(n===18?(n=0,t=0):o=r(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let s=t,c=r(),h=r(),_=t+h,b=_-s;return{version:n,codec:o,multihashCode:c,digestSize:h,multihashSize:b,size:_}}static parse(e,t){let[r,n]=ii(e,t),o=i.decode(n);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vt(o).set(r,e),o}};function ii(i,e){switch(i[0]){case"Q":{let t=e??U;return[U.prefix,t.decode(`${U.prefix}${i}`)]}case U.prefix:{let t=e??U;return[U.prefix,t.decode(i)]}case K.prefix:{let t=e??K;return[K.prefix,t.decode(i)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[i[0],e.decode(i)]}}}function ri(i,e,t){let{prefix:r}=t;if(r!==U.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(r);if(n==null){let o=t.encode(i).slice(1);return e.set(r,o),o}else return n}function oi(i,e,t){let{prefix:r}=t,n=e.get(r);if(n==null){let o=t.encode(i);return e.set(r,o),o}else return n}var j=112,si=18;function Ge(i,e,t){let r=W(i),n=r+W(e),o=new Uint8Array(n+t.byteLength);return J(i,o,0),J(e,o,r),o.set(t,n),o}var ci=Symbol.for("@ipld/js-cid/CID");var Ht={...$t,...Pt,..._t,...Bt,...Ot,...Rt,...Gt,...vt,...zt,...Mt},ur={...Qt,...Kt};function ze(i,e,t,r){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:t},decoder:{decode:r}}}var ve=ze("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),Zt=ze("ascii","a",i=>{let e="a";for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return e},i=>{i=i.substring(1);let e=B(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e}),hi={utf8:ve,"utf-8":ve,hex:Ht.base16,latin1:Zt,ascii:Zt,binary:Zt,...Ht},_e=hi;function $e(i,e="utf8"){let t=_e[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${i}`)}function Yt(i){let e=i??8192,t=e>>>1,r,n=e;return function(s){if(s<1||s>t)return B(s);n+s>e&&(r=B(e),n=0);let c=r.subarray(n,n+=s);return n&7&&(n=(n|7)+1),c}}var z=class{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}};function qt(){}var te=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},li=Yt();function di(i){return globalThis.Buffer!=null?B(i):li(i)}var et=class{len;head;tail;states;constructor(){this.len=0,this.head=new z(qt,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new z(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ee((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Nt,10,g.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=g.fromBigInt(e);return this._push(Nt,t.length(),t)}uint64Number(e){return this._push(de,H(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=g.fromBigInt(e).zzEncode();return this._push(Nt,t.length(),t)}sint64Number(e){let t=g.fromNumber(e).zzEncode();return this._push(Nt,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(jt,1,e?1:0)}fixed32(e){return this._push(tt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=g.fromBigInt(e);return this._push(tt,4,t.lo)._push(tt,4,t.hi)}fixed64Number(e){let t=g.fromNumber(e);return this._push(tt,4,t.lo)._push(tt,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(ue,4,e)}double(e){return this._push(pe,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(jt,1,0):this.uint32(t)._push(ui,t,e)}string(e){let t=Ee(e);return t!==0?this.uint32(t)._push(Dt,t,e):this._push(jt,1,0)}fork(){return this.states=new te(this),this.head=this.tail=new z(qt,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new z(qt,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r!==0&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next,t=di(this.len),r=0;for(;e!=null;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t}};function jt(i,e,t){e[t]=i&255}function ai(i,e,t){for(;i>127;)e[t++]=i&127|128,i>>>=7;e[t]=i}var ee=class extends z{next;constructor(e,t){super(ai,e,t),this.next=void 0}};function Nt(i,e,t){for(;i.hi!==0;)e[t++]=i.lo&127|128,i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)e[t++]=i.lo&127|128,i.lo=i.lo>>>7;e[t++]=i.lo}function tt(i,e,t){e[t]=i&255,e[t+1]=i>>>8&255,e[t+2]=i>>>16&255,e[t+3]=i>>>24}function ui(i,e,t){e.set(i,t)}globalThis.Buffer!=null&&(et.prototype.bytes=function(i){let e=i.length>>>0;return this.uint32(e),e>0&&this._push(fi,e,i),this},et.prototype.string=function(i){let e=globalThis.Buffer.byteLength(i);return this.uint32(e),e>0&&this._push(pi,e,i),this});function fi(i,e,t){e.set(i,t)}function pi(i,e,t){i.length<40?Dt(i,e,t):e.utf8Write!=null?e.utf8Write(i,t):e.set($e(i),t)}function ne(){return new et}function u(i,e){let t=ne();return e.encode(i,t,{lengthDelimited:!1}),t.finish()}var V;(function(i){i[i.VARINT=0]="VARINT",i[i.BIT64=1]="BIT64",i[i.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",i[i.START_GROUP=3]="START_GROUP",i[i.END_GROUP=4]="END_GROUP",i[i.BIT32=5]="BIT32"})(V||(V={}));function It(i,e,t,r){return{name:i,type:e,encode:t,decode:r}}function C(i){function e(n){if(i[n.toString()]==null)throw new Error("Invalid enum value");return i[n]}let t=function(o,s){let c=e(o);s.int32(c)},r=function(o){let s=o.int32();return e(s)};return It("enum",V.VARINT,t,r)}function f(i,e){return It("message",V.LENGTH_DELIMITED,i,e)}var ie;(function(i){let e;(function(n){n.IDENTIFY="IDENTIFY",n.CONNECT="CONNECT",n.STREAM_OPEN="STREAM_OPEN",n.STREAM_HANDLER="STREAM_HANDLER",n.DHT="DHT",n.LIST_PEERS="LIST_PEERS",n.CONNMANAGER="CONNMANAGER",n.DISCONNECT="DISCONNECT",n.PUBSUB="PUBSUB",n.PEERSTORE="PEERSTORE"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.IDENTIFY=0]="IDENTIFY",n[n.CONNECT=1]="CONNECT",n[n.STREAM_OPEN=2]="STREAM_OPEN",n[n.STREAM_HANDLER=3]="STREAM_HANDLER",n[n.DHT=4]="DHT",n[n.LIST_PEERS=5]="LIST_PEERS",n[n.CONNMANAGER=6]="CONNMANAGER",n[n.DISCONNECT=7]="DISCONNECT",n[n.PUBSUB=8]="PUBSUB",n[n.PEERSTORE=9]="PEERSTORE"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.connect!=null&&(o.uint32(18),it.codec().encode(n.connect,o)),n.streamOpen!=null&&(o.uint32(26),rt.codec().encode(n.streamOpen,o)),n.streamHandler!=null&&(o.uint32(34),ot.codec().encode(n.streamHandler,o)),n.dht!=null&&(o.uint32(42),ht.codec().encode(n.dht,o)),n.connManager!=null&&(o.uint32(50),dt.codec().encode(n.connManager,o)),n.disconnect!=null&&(o.uint32(58),at.codec().encode(n.disconnect,o)),n.pubsub!=null&&(o.uint32(66),ut.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(74),pt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.connect=it.codec().decode(n,n.uint32());break;case 3:s.streamOpen=rt.codec().decode(n,n.uint32());break;case 4:s.streamHandler=ot.codec().decode(n,n.uint32());break;case 5:s.dht=ht.codec().decode(n,n.uint32());break;case 6:s.connManager=dt.codec().decode(n,n.uint32());break;case 7:s.disconnect=at.codec().decode(n,n.uint32());break;case 8:s.pubsub=ut.codec().decode(n,n.uint32());break;case 9:s.peerStore=pt.codec().decode(n,n.uint32());break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(ie||(ie={}));var re;(function(i){let e;(function(n){n.OK="OK",n.ERROR="ERROR"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.OK=0]="OK",n[n.ERROR=1]="ERROR"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.error!=null&&(o.uint32(18),st.codec().encode(n.error,o)),n.streamInfo!=null&&(o.uint32(26),ct.codec().encode(n.streamInfo,o)),n.identify!=null&&(o.uint32(34),nt.codec().encode(n.identify,o)),n.dht!=null&&(o.uint32(42),lt.codec().encode(n.dht,o)),n.peers!=null)for(let c of n.peers)o.uint32(50),F.codec().encode(c,o);n.pubsub!=null&&(o.uint32(58),ft.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(66),mt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={peers:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.error=st.codec().decode(n,n.uint32());break;case 3:s.streamInfo=ct.codec().decode(n,n.uint32());break;case 4:s.identify=nt.codec().decode(n,n.uint32());break;case 5:s.dht=lt.codec().decode(n,n.uint32());break;case 6:s.peers.push(F.codec().decode(n,n.uint32()));break;case 7:s.pubsub=ft.codec().decode(n,n.uint32());break;case 8:s.peerStore=mt.codec().decode(n,n.uint32());break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(re||(re={}));var nt;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.id!=null&&t.id.byteLength>0&&(r.uint32(10),r.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)r.uint32(18),r.bytes(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={id:new Uint8Array(0),addrs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(nt||(nt={}));var it;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),t.addrs!=null)for(let o of t.addrs)r.uint32(18),r.bytes(o);t.timeout!=null&&(r.uint32(24),r.int64(t.timeout)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0),addrs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addrs.push(t.bytes());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(it||(it={}));var rt;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),t.proto!=null)for(let o of t.proto)r.uint32(18),r.string(o);t.timeout!=null&&(r.uint32(24),r.int64(t.timeout)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0),proto:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.proto.push(t.string());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(rt||(rt={}));var ot;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.addr!=null&&t.addr.byteLength>0&&(r.uint32(10),r.bytes(t.addr)),t.proto!=null)for(let o of t.proto)r.uint32(18),r.string(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={addr:new Uint8Array(0),proto:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.addr=t.bytes();break;case 2:n.proto.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(ot||(ot={}));var st;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{n.lengthDelimited!==!1&&r.fork(),t.msg!=null&&t.msg!==""&&(r.uint32(10),r.string(t.msg)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={msg:""},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.msg=t.string();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(st||(st={}));var ct;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),t.addr!=null&&t.addr.byteLength>0&&(r.uint32(18),r.bytes(t.addr)),t.proto!=null&&t.proto!==""&&(r.uint32(26),r.string(t.proto)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addr=t.bytes();break;case 3:n.proto=t.string();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(ct||(ct={}));var ht;(function(i){let e;(function(n){n.FIND_PEER="FIND_PEER",n.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",n.FIND_PROVIDERS="FIND_PROVIDERS",n.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",n.GET_PUBLIC_KEY="GET_PUBLIC_KEY",n.GET_VALUE="GET_VALUE",n.SEARCH_VALUE="SEARCH_VALUE",n.PUT_VALUE="PUT_VALUE",n.PROVIDE="PROVIDE"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.FIND_PEER=0]="FIND_PEER",n[n.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",n[n.FIND_PROVIDERS=2]="FIND_PROVIDERS",n[n.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",n[n.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",n[n.GET_VALUE=5]="GET_VALUE",n[n.SEARCH_VALUE=6]="SEARCH_VALUE",n[n.PUT_VALUE=7]="PUT_VALUE",n[n.PROVIDE=8]="PROVIDE"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.cid!=null&&(o.uint32(26),o.bytes(n.cid)),n.key!=null&&(o.uint32(34),o.bytes(n.key)),n.value!=null&&(o.uint32(42),o.bytes(n.value)),n.count!=null&&(o.uint32(48),o.int32(n.count)),n.timeout!=null&&(o.uint32(56),o.int64(n.timeout)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.cid=n.bytes();break;case 4:s.key=n.bytes();break;case 5:s.value=n.bytes();break;case 6:s.count=n.int32();break;case 7:s.timeout=n.int64();break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(ht||(ht={}));var lt;(function(i){let e;(function(n){n.BEGIN="BEGIN",n.VALUE="VALUE",n.END="END"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.BEGIN=0]="BEGIN",n[n.VALUE=1]="VALUE",n[n.END=2]="END"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),F.codec().encode(n.peer,o)),n.value!=null&&(o.uint32(26),o.bytes(n.value)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.peer=F.codec().decode(n,n.uint32());break;case 3:s.value=n.bytes();break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(lt||(lt={}));var F;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.id!=null&&t.id.byteLength>0&&(r.uint32(10),r.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)r.uint32(18),r.bytes(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={id:new Uint8Array(0),addrs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(F||(F={}));var dt;(function(i){let e;(function(n){n.TAG_PEER="TAG_PEER",n.UNTAG_PEER="UNTAG_PEER",n.TRIM="TRIM"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.TAG_PEER=0]="TAG_PEER",n[n.UNTAG_PEER=1]="UNTAG_PEER",n[n.TRIM=2]="TRIM"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.tag!=null&&(o.uint32(26),o.string(n.tag)),n.weight!=null&&(o.uint32(32),o.int64(n.weight)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.tag=n.string();break;case 4:s.weight=n.int64();break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(dt||(dt={}));var at;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&t.peer.byteLength>0&&(r.uint32(10),r.bytes(t.peer)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={peer:new Uint8Array(0)},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(at||(at={}));var ut;(function(i){let e;(function(n){n.GET_TOPICS="GET_TOPICS",n.LIST_PEERS="LIST_PEERS",n.PUBLISH="PUBLISH",n.SUBSCRIBE="SUBSCRIBE"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.GET_TOPICS=0]="GET_TOPICS",n[n.LIST_PEERS=1]="LIST_PEERS",n[n.PUBLISH=2]="PUBLISH",n[n.SUBSCRIBE=3]="SUBSCRIBE"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.topic!=null&&(o.uint32(18),o.string(n.topic)),n.data!=null&&(o.uint32(26),o.bytes(n.data)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.topic=n.string();break;case 3:s.data=n.bytes();break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(ut||(ut={}));var oe;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.from!=null&&(r.uint32(10),r.bytes(t.from)),t.data!=null&&(r.uint32(18),r.bytes(t.data)),t.seqno!=null&&(r.uint32(26),r.bytes(t.seqno)),t.topicIDs!=null)for(let o of t.topicIDs)r.uint32(34),r.string(o);t.signature!=null&&(r.uint32(42),r.bytes(t.signature)),t.key!=null&&(r.uint32(50),r.bytes(t.key)),n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={topicIDs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.from=t.bytes();break;case 2:n.data=t.bytes();break;case 3:n.seqno=t.bytes();break;case 4:n.topicIDs.push(t.string());break;case 5:n.signature=t.bytes();break;case 6:n.key=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(oe||(oe={}));var ft;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.topics!=null)for(let o of t.topics)r.uint32(10),r.string(o);if(t.peerIDs!=null)for(let o of t.peerIDs)r.uint32(18),r.bytes(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={topics:[],peerIDs:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.topics.push(t.string());break;case 2:n.peerIDs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(ft||(ft={}));var pt;(function(i){let e;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.GET_PROTOCOLS="GET_PROTOCOLS",n.GET_PEER_INFO="GET_PEER_INFO"})(e=i.Type||(i.Type={}));let t;(function(n){n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.GET_PROTOCOLS=1]="GET_PROTOCOLS",n[n.GET_PEER_INFO=2]="GET_PEER_INFO"})(t||(t={})),function(n){n.codec=()=>C(t)}(e=i.Type||(i.Type={}));let r;i.codec=()=>(r==null&&(r=f((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),i.Type.codec().encode(n.type,o)),n.id!=null&&(o.uint32(18),o.bytes(n.id)),n.protos!=null)for(let c of n.protos)o.uint32(26),o.string(c);s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={protos:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=i.Type.codec().decode(n);break;case 2:s.id=n.bytes();break;case 3:s.protos.push(n.string());break;default:n.skipType(h&7);break}}return s})),r),i.encode=n=>u(n,i.codec()),i.decode=n=>a(n,i.codec())})(pt||(pt={}));var mt;(function(i){let e;i.codec=()=>(e==null&&(e=f((t,r,n={})=>{if(n.lengthDelimited!==!1&&r.fork(),t.peer!=null&&(r.uint32(10),F.codec().encode(t.peer,r)),t.protos!=null)for(let o of t.protos)r.uint32(18),r.string(o);n.lengthDelimited!==!1&&r.ldelim()},(t,r)=>{let n={protos:[]},o=r==null?t.len:t.pos+r;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=F.codec().decode(t,t.uint32());break;case 2:n.protos.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),i.encode=t=>u(t,i.codec()),i.decode=t=>a(t,i.codec())})(mt||(mt={}));return Ve(mi);})();
2
+ "use strict";var Libp2PDaemonProtocol=(()=>{var St=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var E=(r,e)=>{for(var t in e)St(r,t,{get:e[t],enumerable:!0})},Ve=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of We(e))!Qe.call(r,n)&&n!==t&&St(r,n,{get:()=>e[n],enumerable:!(i=Je(e,n))||i.enumerable});return r};var He=r=>Ve(St({},"__esModule",{value:!0}),r);var mr={};E(mr,{ConnManagerRequest:()=>at,ConnectRequest:()=>it,DHTRequest:()=>lt,DHTResponse:()=>dt,DisconnectRequest:()=>ut,ErrorResponse:()=>ct,IdentifyResponse:()=>rt,PSMessage:()=>se,PSRequest:()=>ft,PSResponse:()=>pt,PeerInfo:()=>F,PeerstoreRequest:()=>mt,PeerstoreResponse:()=>xt,Request:()=>ie,Response:()=>oe,StreamHandlerRequest:()=>st,StreamInfo:()=>ht,StreamOpenRequest:()=>ot});function B(r=0){return new Uint8Array(r)}var Ze=Math.pow(2,7),Ye=Math.pow(2,14),qe=Math.pow(2,21),ce=Math.pow(2,28),he=Math.pow(2,35),le=Math.pow(2,42),de=Math.pow(2,49),m=128,O=127;function H(r){if(r<Ze)return 1;if(r<Ye)return 2;if(r<qe)return 3;if(r<ce)return 4;if(r<he)return 5;if(r<le)return 6;if(r<de)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ae(r,e,t=0){switch(H(r)){case 8:e[t++]=r&255|m,r/=128;case 7:e[t++]=r&255|m,r/=128;case 6:e[t++]=r&255|m,r/=128;case 5:e[t++]=r&255|m,r/=128;case 4:e[t++]=r&255|m,r>>>=7;case 3:e[t++]=r&255|m,r>>>=7;case 2:e[t++]=r&255|m,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function ue(r,e){let t=r[e],i=0;if(i+=t&O,t<m||(t=r[e+1],i+=(t&O)<<7,t<m)||(t=r[e+2],i+=(t&O)<<14,t<m)||(t=r[e+3],i+=(t&O)<<21,t<m)||(t=r[e+4],i+=(t&O)*ce,t<m)||(t=r[e+5],i+=(t&O)*he,t<m)||(t=r[e+6],i+=(t&O)*le,t<m)||(t=r[e+7],i+=(t&O)*de,t<m))return i;throw new RangeError("Could not decode varint")}var At=new Float32Array([-0]),P=new Uint8Array(At.buffer);function fe(r,e,t){At[0]=r,e[t]=P[0],e[t+1]=P[1],e[t+2]=P[2],e[t+3]=P[3]}function pe(r,e){return P[0]=r[e],P[1]=r[e+1],P[2]=r[e+2],P[3]=r[e+3],At[0]}var Dt=new Float64Array([-0]),p=new Uint8Array(Dt.buffer);function me(r,e,t){Dt[0]=r,e[t]=p[0],e[t+1]=p[1],e[t+2]=p[2],e[t+3]=p[3],e[t+4]=p[4],e[t+5]=p[5],e[t+6]=p[6],e[t+7]=p[7]}function xe(r,e){return p[0]=r[e],p[1]=r[e+1],p[2]=r[e+2],p[3]=r[e+3],p[4]=r[e+4],p[5]=r[e+5],p[6]=r[e+6],p[7]=r[e+7],Dt[0]}var je=BigInt(Number.MAX_SAFE_INTEGER),tn=BigInt(Number.MIN_SAFE_INTEGER),g=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,i=~this.hi>>>0;return t===0&&(i=i+1>>>0),-(t+i*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,i=~this.hi>>>0;return t===0&&(i=i+1>>>0),-(BigInt(t)+(BigInt(i)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return i===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10}static fromBigInt(e){if(e===0n)return G;if(e<je&&e>tn)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let i=e>>32n,n=e-(i<<32n);return t&&(i=~i|0n,n=~n|0n,++n>Ee&&(n=0n,++i>Ee&&(i=0n))),new r(Number(n),Number(i))}static fromNumber(e){if(e===0)return G;let t=e<0;t&&(e=-e);let i=e>>>0,n=(e-i)/4294967296>>>0;return t&&(n=~n>>>0,i=~i>>>0,++i>4294967295&&(i=0,++n>4294967295&&(n=0))),new r(i,n)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):G}},G=new g(0,0);G.toBigInt=function(){return 0n};G.zzEncode=G.zzDecode=function(){return this};G.length=function(){return 1};var Ee=4294967296n;function ge(r){let e=0,t=0;for(let i=0;i<r.length;++i)t=r.charCodeAt(i),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e}function be(r,e,t){if(t-e<1)return"";let n,o=[],s=0,c;for(;e<t;)c=r[e++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|r[e++]&63:c>239&&c<365?(c=((c&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,o)),s=0);return n!=null?(s>0&&n.push(String.fromCharCode.apply(String,o.slice(0,s))),n.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Ut(r,e,t){let i=t,n,o;for(let s=0;s<r.length;++s)n=r.charCodeAt(s),n<128?e[t++]=n:n<2048?(e[t++]=n>>6|192,e[t++]=n&63|128):(n&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(n=65536+((n&1023)<<10)+(o&1023),++s,e[t++]=n>>18|240,e[t++]=n>>12&63|128,e[t++]=n>>6&63|128,e[t++]=n&63|128):(e[t++]=n>>12|224,e[t++]=n>>6&63|128,e[t++]=n&63|128);return t-i}function k(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function bt(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var wt=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,k(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw k(this,4);return bt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw k(this,4);return bt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw k(this,4);let e=pe(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw k(this,4);let e=xe(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw k(this,e);return this.pos+=e,t===i?new Uint8Array(0):this.buf.subarray(t,i)}string(){let e=this.bytes();return be(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw k(this,e);this.pos+=e}else do if(this.pos>=this.len)throw k(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new g(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw k(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw k(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw k(this,8);let e=bt(this.buf,this.pos+=4),t=bt(this.buf,this.pos+=4);return new g(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ue(this.buf,this.pos);return this.pos+=H(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ct(r){return new wt(r instanceof Uint8Array?r:r.subarray())}function a(r,e,t){let i=Ct(r);return e.decode(i,void 0,t)}var Ot={};E(Ot,{base10:()=>cn});var wr=new Uint8Array(0);function Ne(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function C(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ie(r){return new TextEncoder().encode(r)}function ke(r){return new TextDecoder().decode(r)}function en(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var n=0;n<r.length;n++){var o=r.charAt(n),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=n}var c=r.length,h=r.charAt(0),_=Math.log(c)/Math.log(256),b=Math.log(256)/Math.log(c);function $(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var x=0,R=0,N=0,S=l.length;N!==S&&l[N]===0;)N++,x++;for(var A=(S-N)*b+1>>>0,y=new Uint8Array(A);N!==S;){for(var D=l[N],L=0,I=A-1;(D!==0||L<R)&&I!==-1;I--,L++)D+=256*y[I]>>>0,y[I]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");R=L,N++}for(var w=A-R;w!==A&&y[w]===0;)w++;for(var gt=h.repeat(x);w<A;++w)gt+=r.charAt(y[w]);return gt}function Et(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var x=0;if(l[x]!==" "){for(var R=0,N=0;l[x]===h;)R++,x++;for(var S=(l.length-x)*_+1>>>0,A=new Uint8Array(S);l[x];){var y=t[l.charCodeAt(x)];if(y===255)return;for(var D=0,L=S-1;(y!==0||D<N)&&L!==-1;L--,D++)y+=c*A[L]>>>0,A[L]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");N=D,x++}if(l[x]!==" "){for(var I=S-N;I!==S&&A[I]===0;)I++;for(var w=new Uint8Array(R+(S-I)),gt=R;I!==S;)w[gt++]=A[I++];return w}}}function Ke(l){var x=Et(l);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:$,decodeUnsafe:Et,decode:Ke}}var nn=en,rn=nn,Ae=rn;var Tt=class{name;prefix;baseEncode;constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ft=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,i){this.name=e,this.prefix=t;let n=t.codePointAt(0);if(n===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return De(this,e)}},Lt=class{decoders;constructor(e){this.decoders=e}or(e){return De(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i!=null)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function De(r,e){return new Lt({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Bt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Tt(e,t,i),this.decoder=new Ft(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function X({name:r,prefix:e,encode:t,decode:i}){return new Bt(r,e,t,i)}function M({name:r,prefix:e,alphabet:t}){let{encode:i,decode:n}=Ae(t,r);return X({prefix:e,name:r,encode:i,decode:o=>C(n(o))})}function on(r,e,t,i){let n={};for(let b=0;b<e.length;++b)n[e[b]]=b;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,h=0,_=0;for(let b=0;b<o;++b){let $=n[r[b]];if($===void 0)throw new SyntaxError(`Non-${i} character`);h=h<<t|$,c+=t,c>=8&&(c-=8,s[_++]=255&h>>c)}if(c>=t||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return s}function sn(r,e,t){let i=e[e.length-1]==="=",n=(1<<t)-1,o="",s=0,c=0;for(let h=0;h<r.length;++h)for(c=c<<8|r[h],s+=8;s>t;)s-=t,o+=e[n&c>>s];if(s!==0&&(o+=e[n&c<<t-s]),i)for(;o.length*t&7;)o+="=";return o}function d({name:r,prefix:e,bitsPerChar:t,alphabet:i}){return X({prefix:e,name:r,encode(n){return sn(n,i,t)},decode(n){return on(n,i,t,r)}})}var cn=M({prefix:"9",name:"base10",alphabet:"0123456789"});var Pt={};E(Pt,{base16:()=>hn,base16upper:()=>ln});var hn=d({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ln=d({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mt={};E(Mt,{base2:()=>dn});var dn=d({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rt={};E(Rt,{base256emoji:()=>mn});var Ue=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}"),an=Ue.reduce((r,e,t)=>(r[t]=e,r),[]),un=Ue.reduce((r,e,t)=>{let i=e.codePointAt(0);if(i==null)throw new Error(`Invalid character: ${e}`);return r[i]=t,r},[]);function fn(r){return r.reduce((e,t)=>(e+=an[t],e),"")}function pn(r){let e=[];for(let t of r){let i=t.codePointAt(0);if(i==null)throw new Error(`Invalid character: ${t}`);let n=un[i];if(n==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var mn=X({prefix:"\u{1F680}",name:"base256emoji",encode:fn,decode:pn});var Gt={};E(Gt,{base32:()=>K,base32hex:()=>bn,base32hexpad:()=>Nn,base32hexpadupper:()=>In,base32hexupper:()=>yn,base32pad:()=>En,base32padupper:()=>gn,base32upper:()=>xn,base32z:()=>kn});var K=d({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xn=d({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),En=d({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gn=d({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bn=d({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yn=d({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Nn=d({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),In=d({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kn=d({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vt={};E(vt,{base36:()=>Z,base36upper:()=>Sn});var Z=M({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sn=M({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var zt={};E(zt,{base58btc:()=>U,base58flickr:()=>An});var U=M({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),An=M({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _t={};E(_t,{base64:()=>Dn,base64pad:()=>Un,base64url:()=>wn,base64urlpad:()=>Cn});var Dn=d({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Un=d({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),wn=d({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Cn=d({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $t={};E($t,{base8:()=>Tn});var Tn=d({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xt={};E(Xt,{identity:()=>Fn});var Fn=X({prefix:"\0",name:"identity",encode:r=>ke(r),decode:r=>Ie(r)});var Kr=new TextEncoder,Jr=new TextDecoder;var Jt={};E(Jt,{identity:()=>tr});var On=Te,we=128,Pn=127,Mn=~Pn,Rn=Math.pow(2,31);function Te(r,e,t){e=e||[],t=t||0;for(var i=t;r>=Rn;)e[t++]=r&255|we,r/=128;for(;r&Mn;)e[t++]=r&255|we,r>>>=7;return e[t]=r|0,Te.bytes=t-i+1,e}var Gn=Kt,vn=128,Ce=127;function Kt(r,i){var t=0,i=i||0,n=0,o=i,s,c=r.length;do{if(o>=c)throw Kt.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=n<28?(s&Ce)<<n:(s&Ce)*Math.pow(2,n),n+=7}while(s>=vn);return Kt.bytes=o-i,t}var zn=Math.pow(2,7),_n=Math.pow(2,14),$n=Math.pow(2,21),Xn=Math.pow(2,28),Kn=Math.pow(2,35),Jn=Math.pow(2,42),Wn=Math.pow(2,49),Qn=Math.pow(2,56),Vn=Math.pow(2,63),Hn=function(r){return r<zn?1:r<_n?2:r<$n?3:r<Xn?4:r<Kn?5:r<Jn?6:r<Wn?7:r<Qn?8:r<Vn?9:10},Zn={encode:On,decode:Gn,encodingLength:Hn},Yn=Zn,Y=Yn;function q(r,e=0){return[Y.decode(r,e),Y.decode.bytes]}function J(r,e,t=0){return Y.encode(r,e,t),e}function W(r){return Y.encodingLength(r)}function v(r,e){let t=e.byteLength,i=W(r),n=i+W(t),o=new Uint8Array(n+t);return J(r,o,0),J(t,o,i),o.set(e,n),new Q(r,t,e,o)}function Fe(r){let e=C(r),[t,i]=q(e),[n,o]=q(e.subarray(i)),s=e.subarray(i+o);if(s.byteLength!==n)throw new Error("Incorrect length");return new Q(t,n,s,e)}function Le(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ne(r.bytes,t.bytes)}}var Q=class{code;size;digest;bytes;constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var Be=0,qn="identity",Oe=C;function jn(r){return v(Be,Oe(r))}var tr={code:Be,name:qn,encode:Oe,digest:jn};var Vt={};E(Vt,{sha256:()=>er,sha512:()=>nr});function Qt({name:r,code:e,encode:t}){return new Wt(r,e,t)}var Wt=class{name;code;encode;constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?v(this.code,t):t.then(i=>v(this.code,i))}else throw Error("Unknown type, must be binary type")}};function Me(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var er=Qt({name:"sha2-256",code:18,encode:Me("SHA-256")}),nr=Qt({name:"sha2-512",code:19,encode:Me("SHA-512")});function Re(r,e){let{bytes:t,version:i}=r;switch(i){case 0:return ir(t,Ht(r),e??U.encoder);default:return or(t,Ht(r),e??K.encoder)}}var Ge=new WeakMap;function Ht(r){let e=Ge.get(r);if(e==null){let t=new Map;return Ge.set(r,t),t}return e}var Nt=class r{code;version;multihash;bytes;"/";constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==tt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==sr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=v(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let i=t;return i!=null&&e.code===i.code&&e.version===i.version&&Le(e.multihash,i.multihash)}toString(e){return Re(this,e)}toJSON(){return{"/":Re(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:i,code:n,multihash:o,bytes:s}=t;return new r(i,n,o,s??ve(i,n,o.bytes))}else if(t[cr]===!0){let{version:i,multihash:n,code:o}=t,s=Fe(n);return r.create(i,o,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(i.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==tt)throw new Error(`Version 0 CID must use dag-pb (code: ${tt}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=ve(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,tt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=C(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=n.subarray(t.multihashSize-t.digestSize),s=new Q(t.multihashCode,t.digestSize,o,n);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[$,Et]=q(e.subarray(t));return t+=Et,$},n=i(),o=tt;if(n===18?(n=0,t=0):o=i(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let s=t,c=i(),h=i(),_=t+h,b=_-s;return{version:n,codec:o,multihashCode:c,digestSize:h,multihashSize:b,size:_}}static parse(e,t){let[i,n]=rr(e,t),o=r.decode(n);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ht(o).set(i,e),o}};function rr(r,e){switch(r[0]){case"Q":{let t=e??U;return[U.prefix,t.decode(`${U.prefix}${r}`)]}case U.prefix:{let t=e??U;return[U.prefix,t.decode(r)]}case K.prefix:{let t=e??K;return[K.prefix,t.decode(r)]}case Z.prefix:{let t=e??Z;return[Z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function ir(r,e,t){let{prefix:i}=t;if(i!==U.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let o=t.encode(r).slice(1);return e.set(i,o),o}else return n}function or(r,e,t){let{prefix:i}=t,n=e.get(i);if(n==null){let o=t.encode(r);return e.set(i,o),o}else return n}var tt=112,sr=18;function ve(r,e,t){let i=W(r),n=i+W(e),o=new Uint8Array(n+t.byteLength);return J(r,o,0),J(e,o,i),o.set(t,n),o}var cr=Symbol.for("@ipld/js-cid/CID");var Zt={...Xt,...Mt,...$t,...Ot,...Pt,...Gt,...vt,...zt,..._t,...Rt},fi={...Vt,...Jt};function _e(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var ze=_e("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yt=_e("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=B(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),hr={utf8:ze,"utf-8":ze,hex:Zt.base16,latin1:Yt,ascii:Yt,binary:Yt,...Zt},$e=hr;function Xe(r,e="utf8"){let t=$e[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function qt(r){let e=r??8192,t=e>>>1,i,n=e;return function(s){if(s<1||s>t)return B(s);n+s>e&&(i=B(e),n=0);let c=i.subarray(n,n+=s);return n&7&&(n=(n|7)+1),c}}var z=class{fn;len;next;val;constructor(e,t,i){this.fn=e,this.len=t,this.next=void 0,this.val=i}};function jt(){}var ee=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},lr=qt();function dr(r){return globalThis.Buffer!=null?B(r):lr(r)}var nt=class{len;head;tail;states;constructor(){this.len=0,this.head=new z(jt,0,0),this.tail=this.head,this.states=null}_push(e,t,i){return this.tail=this.tail.next=new z(e,t,i),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ne((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(It,10,g.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=g.fromBigInt(e);return this._push(It,t.length(),t)}uint64Number(e){return this._push(ae,H(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=g.fromBigInt(e).zzEncode();return this._push(It,t.length(),t)}sint64Number(e){let t=g.fromNumber(e).zzEncode();return this._push(It,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(te,1,e?1:0)}fixed32(e){return this._push(et,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=g.fromBigInt(e);return this._push(et,4,t.lo)._push(et,4,t.hi)}fixed64Number(e){let t=g.fromNumber(e);return this._push(et,4,t.lo)._push(et,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(fe,4,e)}double(e){return this._push(me,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(te,1,0):this.uint32(t)._push(ur,t,e)}string(e){let t=ge(e);return t!==0?this.uint32(t)._push(Ut,t,e):this._push(te,1,0)}fork(){return this.states=new ee(this),this.head=this.tail=new z(jt,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new z(jt,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,i=this.len;return this.reset().uint32(i),i!==0&&(this.tail.next=e.next,this.tail=t,this.len+=i),this}finish(){let e=this.head.next,t=dr(this.len),i=0;for(;e!=null;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t}};function te(r,e,t){e[t]=r&255}function ar(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ne=class extends z{next;constructor(e,t){super(ar,e,t),this.next=void 0}};function It(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function et(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function ur(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(nt.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(fr,e,r),this},nt.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(pr,e,r),this});function fr(r,e,t){e.set(r,t)}function pr(r,e,t){r.length<40?Ut(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Xe(r),t)}function re(){return new nt}function u(r,e){let t=re();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var V;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(V||(V={}));function kt(r,e,t,i){return{name:r,type:e,encode:t,decode:i}}function T(r){function e(n){if(r[n.toString()]==null)throw new Error("Invalid enum value");return r[n]}let t=function(o,s){let c=e(o);s.int32(c)},i=function(o){let s=o.int32();return e(s)};return kt("enum",V.VARINT,t,i)}function f(r,e){return kt("message",V.LENGTH_DELIMITED,r,e)}var ie;(function(r){let e;(function(n){n.IDENTIFY="IDENTIFY",n.CONNECT="CONNECT",n.STREAM_OPEN="STREAM_OPEN",n.STREAM_HANDLER="STREAM_HANDLER",n.DHT="DHT",n.LIST_PEERS="LIST_PEERS",n.CONNMANAGER="CONNMANAGER",n.DISCONNECT="DISCONNECT",n.PUBSUB="PUBSUB",n.PEERSTORE="PEERSTORE"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.IDENTIFY=0]="IDENTIFY",n[n.CONNECT=1]="CONNECT",n[n.STREAM_OPEN=2]="STREAM_OPEN",n[n.STREAM_HANDLER=3]="STREAM_HANDLER",n[n.DHT=4]="DHT",n[n.LIST_PEERS=5]="LIST_PEERS",n[n.CONNMANAGER=6]="CONNMANAGER",n[n.DISCONNECT=7]="DISCONNECT",n[n.PUBSUB=8]="PUBSUB",n[n.PEERSTORE=9]="PEERSTORE"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.connect!=null&&(o.uint32(18),it.codec().encode(n.connect,o)),n.streamOpen!=null&&(o.uint32(26),ot.codec().encode(n.streamOpen,o)),n.streamHandler!=null&&(o.uint32(34),st.codec().encode(n.streamHandler,o)),n.dht!=null&&(o.uint32(42),lt.codec().encode(n.dht,o)),n.connManager!=null&&(o.uint32(50),at.codec().encode(n.connManager,o)),n.disconnect!=null&&(o.uint32(58),ut.codec().encode(n.disconnect,o)),n.pubsub!=null&&(o.uint32(66),ft.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(74),mt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.connect=it.codec().decode(n,n.uint32());break;case 3:s.streamOpen=ot.codec().decode(n,n.uint32());break;case 4:s.streamHandler=st.codec().decode(n,n.uint32());break;case 5:s.dht=lt.codec().decode(n,n.uint32());break;case 6:s.connManager=at.codec().decode(n,n.uint32());break;case 7:s.disconnect=ut.codec().decode(n,n.uint32());break;case 8:s.pubsub=ft.codec().decode(n,n.uint32());break;case 9:s.peerStore=mt.codec().decode(n,n.uint32());break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(ie||(ie={}));var oe;(function(r){let e;(function(n){n.OK="OK",n.ERROR="ERROR"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.OK=0]="OK",n[n.ERROR=1]="ERROR"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.error!=null&&(o.uint32(18),ct.codec().encode(n.error,o)),n.streamInfo!=null&&(o.uint32(26),ht.codec().encode(n.streamInfo,o)),n.identify!=null&&(o.uint32(34),rt.codec().encode(n.identify,o)),n.dht!=null&&(o.uint32(42),dt.codec().encode(n.dht,o)),n.peers!=null)for(let c of n.peers)o.uint32(50),F.codec().encode(c,o);n.pubsub!=null&&(o.uint32(58),pt.codec().encode(n.pubsub,o)),n.peerStore!=null&&(o.uint32(66),xt.codec().encode(n.peerStore,o)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={peers:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.error=ct.codec().decode(n,n.uint32());break;case 3:s.streamInfo=ht.codec().decode(n,n.uint32());break;case 4:s.identify=rt.codec().decode(n,n.uint32());break;case 5:s.dht=dt.codec().decode(n,n.uint32());break;case 6:s.peers.push(F.codec().decode(n,n.uint32()));break;case 7:s.pubsub=pt.codec().decode(n,n.uint32());break;case 8:s.peerStore=xt.codec().decode(n,n.uint32());break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(oe||(oe={}));var rt;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.id!=null&&t.id.byteLength>0&&(i.uint32(10),i.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={id:new Uint8Array(0),addrs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(rt||(rt={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),t.addrs!=null)for(let o of t.addrs)i.uint32(18),i.bytes(o);t.timeout!=null&&(i.uint32(24),i.int64(t.timeout)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0),addrs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addrs.push(t.bytes());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(it||(it={}));var ot;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),t.proto!=null)for(let o of t.proto)i.uint32(18),i.string(o);t.timeout!=null&&(i.uint32(24),i.int64(t.timeout)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0),proto:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.proto.push(t.string());break;case 3:n.timeout=t.int64();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(ot||(ot={}));var st;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.addr!=null&&t.addr.byteLength>0&&(i.uint32(10),i.bytes(t.addr)),t.proto!=null)for(let o of t.proto)i.uint32(18),i.string(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={addr:new Uint8Array(0),proto:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.addr=t.bytes();break;case 2:n.proto.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(st||(st={}));var ct;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),t.msg!=null&&t.msg!==""&&(i.uint32(10),i.string(t.msg)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={msg:""},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.msg=t.string();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(ct||(ct={}));var ht;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),t.addr!=null&&t.addr.byteLength>0&&(i.uint32(18),i.bytes(t.addr)),t.proto!=null&&t.proto!==""&&(i.uint32(26),i.string(t.proto)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0),addr:new Uint8Array(0),proto:""},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;case 2:n.addr=t.bytes();break;case 3:n.proto=t.string();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(ht||(ht={}));var lt;(function(r){let e;(function(n){n.FIND_PEER="FIND_PEER",n.FIND_PEERS_CONNECTED_TO_PEER="FIND_PEERS_CONNECTED_TO_PEER",n.FIND_PROVIDERS="FIND_PROVIDERS",n.GET_CLOSEST_PEERS="GET_CLOSEST_PEERS",n.GET_PUBLIC_KEY="GET_PUBLIC_KEY",n.GET_VALUE="GET_VALUE",n.SEARCH_VALUE="SEARCH_VALUE",n.PUT_VALUE="PUT_VALUE",n.PROVIDE="PROVIDE"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.FIND_PEER=0]="FIND_PEER",n[n.FIND_PEERS_CONNECTED_TO_PEER=1]="FIND_PEERS_CONNECTED_TO_PEER",n[n.FIND_PROVIDERS=2]="FIND_PROVIDERS",n[n.GET_CLOSEST_PEERS=3]="GET_CLOSEST_PEERS",n[n.GET_PUBLIC_KEY=4]="GET_PUBLIC_KEY",n[n.GET_VALUE=5]="GET_VALUE",n[n.SEARCH_VALUE=6]="SEARCH_VALUE",n[n.PUT_VALUE=7]="PUT_VALUE",n[n.PROVIDE=8]="PROVIDE"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.cid!=null&&(o.uint32(26),o.bytes(n.cid)),n.key!=null&&(o.uint32(34),o.bytes(n.key)),n.value!=null&&(o.uint32(42),o.bytes(n.value)),n.count!=null&&(o.uint32(48),o.int32(n.count)),n.timeout!=null&&(o.uint32(56),o.int64(n.timeout)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.cid=n.bytes();break;case 4:s.key=n.bytes();break;case 5:s.value=n.bytes();break;case 6:s.count=n.int32();break;case 7:s.timeout=n.int64();break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(lt||(lt={}));var dt;(function(r){let e;(function(n){n.BEGIN="BEGIN",n.VALUE="VALUE",n.END="END"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.BEGIN=0]="BEGIN",n[n.VALUE=1]="VALUE",n[n.END=2]="END"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),F.codec().encode(n.peer,o)),n.value!=null&&(o.uint32(26),o.bytes(n.value)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=F.codec().decode(n,n.uint32());break;case 3:s.value=n.bytes();break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(dt||(dt={}));var F;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.id!=null&&t.id.byteLength>0&&(i.uint32(10),i.bytes(t.id)),t.addrs!=null)for(let o of t.addrs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={id:new Uint8Array(0),addrs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.id=t.bytes();break;case 2:n.addrs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(F||(F={}));var at;(function(r){let e;(function(n){n.TAG_PEER="TAG_PEER",n.UNTAG_PEER="UNTAG_PEER",n.TRIM="TRIM"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.TAG_PEER=0]="TAG_PEER",n[n.UNTAG_PEER=1]="UNTAG_PEER",n[n.TRIM=2]="TRIM"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.peer!=null&&(o.uint32(18),o.bytes(n.peer)),n.tag!=null&&(o.uint32(26),o.string(n.tag)),n.weight!=null&&(o.uint32(32),o.int64(n.weight)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.peer=n.bytes();break;case 3:s.tag=n.string();break;case 4:s.weight=n.int64();break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(at||(at={}));var ut;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&t.peer.byteLength>0&&(i.uint32(10),i.bytes(t.peer)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={peer:new Uint8Array(0)},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(ut||(ut={}));var ft;(function(r){let e;(function(n){n.GET_TOPICS="GET_TOPICS",n.LIST_PEERS="LIST_PEERS",n.PUBLISH="PUBLISH",n.SUBSCRIBE="SUBSCRIBE"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.GET_TOPICS=0]="GET_TOPICS",n[n.LIST_PEERS=1]="LIST_PEERS",n[n.PUBLISH=2]="PUBLISH",n[n.SUBSCRIBE=3]="SUBSCRIBE"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.topic!=null&&(o.uint32(18),o.string(n.topic)),n.data!=null&&(o.uint32(26),o.bytes(n.data)),s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.topic=n.string();break;case 3:s.data=n.bytes();break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(ft||(ft={}));var se;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.from!=null&&(i.uint32(10),i.bytes(t.from)),t.data!=null&&(i.uint32(18),i.bytes(t.data)),t.seqno!=null&&(i.uint32(26),i.bytes(t.seqno)),t.topicIDs!=null)for(let o of t.topicIDs)i.uint32(34),i.string(o);t.signature!=null&&(i.uint32(42),i.bytes(t.signature)),t.key!=null&&(i.uint32(50),i.bytes(t.key)),n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={topicIDs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.from=t.bytes();break;case 2:n.data=t.bytes();break;case 3:n.seqno=t.bytes();break;case 4:n.topicIDs.push(t.string());break;case 5:n.signature=t.bytes();break;case 6:n.key=t.bytes();break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(se||(se={}));var pt;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.topics!=null)for(let o of t.topics)i.uint32(10),i.string(o);if(t.peerIDs!=null)for(let o of t.peerIDs)i.uint32(18),i.bytes(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={topics:[],peerIDs:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.topics.push(t.string());break;case 2:n.peerIDs.push(t.bytes());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(pt||(pt={}));var mt;(function(r){let e;(function(n){n.UNSPECIFIED="UNSPECIFIED",n.GET_PROTOCOLS="GET_PROTOCOLS",n.GET_PEER_INFO="GET_PEER_INFO"})(e=r.Type||(r.Type={}));let t;(function(n){n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.GET_PROTOCOLS=1]="GET_PROTOCOLS",n[n.GET_PEER_INFO=2]="GET_PEER_INFO"})(t||(t={})),function(n){n.codec=()=>T(t)}(e=r.Type||(r.Type={}));let i;r.codec=()=>(i==null&&(i=f((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.type!=null&&(o.uint32(8),r.Type.codec().encode(n.type,o)),n.id!=null&&(o.uint32(18),o.bytes(n.id)),n.protos!=null)for(let c of n.protos)o.uint32(26),o.string(c);s.lengthDelimited!==!1&&o.ldelim()},(n,o)=>{let s={protos:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let h=n.uint32();switch(h>>>3){case 1:s.type=r.Type.codec().decode(n);break;case 2:s.id=n.bytes();break;case 3:s.protos.push(n.string());break;default:n.skipType(h&7);break}}return s})),i),r.encode=n=>u(n,r.codec()),r.decode=n=>a(n,r.codec())})(mt||(mt={}));var xt;(function(r){let e;r.codec=()=>(e==null&&(e=f((t,i,n={})=>{if(n.lengthDelimited!==!1&&i.fork(),t.peer!=null&&(i.uint32(10),F.codec().encode(t.peer,i)),t.protos!=null)for(let o of t.protos)i.uint32(18),i.string(o);n.lengthDelimited!==!1&&i.ldelim()},(t,i)=>{let n={protos:[]},o=i==null?t.len:t.pos+i;for(;t.pos<o;){let s=t.uint32();switch(s>>>3){case 1:n.peer=F.codec().decode(t,t.uint32());break;case 2:n.protos.push(t.string());break;default:t.skipType(s&7);break}}return n})),e),r.encode=t=>u(t,r.codec()),r.decode=t=>a(t,r.codec())})(xt||(xt={}));return He(mr);})();
3
3
  return Libp2PDaemonProtocol}));
@@ -1,3 +1,11 @@
1
- import type { Upgrader } from '@libp2p/interface';
2
- export declare const passThroughUpgrader: Upgrader;
1
+ import type { Connection, MultiaddrConnection, Upgrader } from '@libp2p/interface';
2
+ export interface OnConnection {
3
+ (conn: MultiaddrConnection): void;
4
+ }
5
+ export declare class PassThroughUpgrader implements Upgrader {
6
+ private readonly onConnection?;
7
+ constructor(handler?: OnConnection);
8
+ upgradeInbound(maConn: MultiaddrConnection): Promise<Connection>;
9
+ upgradeOutbound(maConn: MultiaddrConnection): Promise<Connection>;
10
+ }
3
11
  //# sourceMappingURL=upgrader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgrader.d.ts","sourceRoot":"","sources":["../../src/upgrader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,eAAO,MAAM,mBAAmB,EAAE,QAKjC,CAAA"}
1
+ {"version":3,"file":"upgrader.d.ts","sourceRoot":"","sources":["../../src/upgrader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAElF,MAAM,WAAW,YAAY;IAC3B,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAClC;AAED,qBAAa,mBAAoB,YAAW,QAAQ;IAClD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAc;gBAE/B,OAAO,CAAC,EAAE,YAAY;IAI7B,cAAc,CAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAMjE,eAAe,CAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;CAIzE"}
@@ -1,7 +1,16 @@
1
- export const passThroughUpgrader = {
2
- // @ts-expect-error should return a connection
3
- upgradeInbound: async (maConn) => maConn,
4
- // @ts-expect-error should return a connection
5
- upgradeOutbound: async (maConn) => maConn
6
- };
1
+ export class PassThroughUpgrader {
2
+ onConnection;
3
+ constructor(handler) {
4
+ this.onConnection = handler;
5
+ }
6
+ async upgradeInbound(maConn) {
7
+ this.onConnection?.(maConn);
8
+ // @ts-expect-error should return a connection
9
+ return maConn;
10
+ }
11
+ async upgradeOutbound(maConn) {
12
+ // @ts-expect-error should return a connection
13
+ return maConn;
14
+ }
15
+ }
7
16
  //# sourceMappingURL=upgrader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../src/upgrader.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAa;IAC3C,8CAA8C;IAC9C,cAAc,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE,CAAC,MAAM;IACtC,8CAA8C;IAC9C,eAAe,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE,CAAC,MAAM;CACxC,CAAA"}
1
+ {"version":3,"file":"upgrader.js","sourceRoot":"","sources":["../../src/upgrader.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,mBAAmB;IACb,YAAY,CAAe;IAE5C,YAAa,OAAsB;QACjC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,cAAc,CAAE,MAA2B;QAC/C,IAAI,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,CAAA;QAC3B,8CAA8C;QAC9C,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,eAAe,CAAE,MAA2B;QAChD,8CAA8C;QAC9C,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
@@ -47,6 +47,8 @@
47
47
  "./stream-handler:StreamHandler": "https://libp2p.github.io/js-libp2p-daemon/classes/_libp2p_daemon_protocol.stream_handler.StreamHandler.html",
48
48
  "StreamHandlerOptions": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_protocol.stream_handler.StreamHandlerOptions.html",
49
49
  "./stream-handler:StreamHandlerOptions": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_protocol.stream_handler.StreamHandlerOptions.html",
50
- "passThroughUpgrader": "https://libp2p.github.io/js-libp2p-daemon/variables/_libp2p_daemon_protocol.upgrader.passThroughUpgrader.html",
51
- "./upgrader:passThroughUpgrader": "https://libp2p.github.io/js-libp2p-daemon/variables/_libp2p_daemon_protocol.upgrader.passThroughUpgrader.html"
50
+ "PassThroughUpgrader": "https://libp2p.github.io/js-libp2p-daemon/classes/_libp2p_daemon_protocol.upgrader.PassThroughUpgrader.html",
51
+ "./upgrader:PassThroughUpgrader": "https://libp2p.github.io/js-libp2p-daemon/classes/_libp2p_daemon_protocol.upgrader.PassThroughUpgrader.html",
52
+ "OnConnection": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_protocol.upgrader.OnConnection.html",
53
+ "./upgrader:OnConnection": "https://libp2p.github.io/js-libp2p-daemon/interfaces/_libp2p_daemon_protocol.upgrader.OnConnection.html"
52
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/daemon-protocol",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Communication protocol between libp2p daemons and clients",
5
5
  "author": "",
6
6
  "license": "Apache-2.0 OR MIT",
@@ -77,7 +77,7 @@
77
77
  "uint8arraylist": "^2.4.8"
78
78
  },
79
79
  "devDependencies": {
80
- "aegir": "^44.1.0",
80
+ "aegir": "^45.0.1",
81
81
  "protons": "^7.5.0"
82
82
  }
83
83
  }
package/src/upgrader.ts CHANGED
@@ -1,8 +1,24 @@
1
- import type { Upgrader } from '@libp2p/interface'
1
+ import type { Connection, MultiaddrConnection, Upgrader } from '@libp2p/interface'
2
2
 
3
- export const passThroughUpgrader: Upgrader = {
4
- // @ts-expect-error should return a connection
5
- upgradeInbound: async maConn => maConn,
6
- // @ts-expect-error should return a connection
7
- upgradeOutbound: async maConn => maConn
3
+ export interface OnConnection {
4
+ (conn: MultiaddrConnection): void
5
+ }
6
+
7
+ export class PassThroughUpgrader implements Upgrader {
8
+ private readonly onConnection?: OnConnection
9
+
10
+ constructor (handler?: OnConnection) {
11
+ this.onConnection = handler
12
+ }
13
+
14
+ async upgradeInbound (maConn: MultiaddrConnection): Promise<Connection> {
15
+ this.onConnection?.(maConn)
16
+ // @ts-expect-error should return a connection
17
+ return maConn
18
+ }
19
+
20
+ async upgradeOutbound (maConn: MultiaddrConnection): Promise<Connection> {
21
+ // @ts-expect-error should return a connection
22
+ return maConn
23
+ }
8
24
  }