@libp2p/identify 3.0.27 → 3.0.28-3833353bd
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 +1 -1
- package/package.json +9 -9
- package/dist/typedoc-urls.json +0 -18
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PIdentify = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PIdentify=(()=>{var lc=Object.create;var Nr=Object.defineProperty;var dc=Object.getOwnPropertyDescriptor;var hc=Object.getOwnPropertyNames;var pc=Object.getPrototypeOf,mc=Object.prototype.hasOwnProperty;var gc=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Et=(r,t)=>{for(var e in t)Nr(r,e,{get:t[e],enumerable:!0})},Os=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of hc(t))!mc.call(r,o)&&o!==e&&Nr(r,o,{get:()=>t[o],enumerable:!(n=dc(t,o))||n.enumerable});return r};var yc=(r,t,e)=>(e=r!=null?lc(pc(r)):{},Os(t||!r||!r.__esModule?Nr(e,"default",{value:r,enumerable:!0}):e,r)),bc=r=>Os(Nr({},"__esModule",{value:!0}),r);var za=gc(Pr=>{(function(){var r,t,e,n,o,s,i,c;c=function(a){var f,u,l,d;return f=(a&255<<24)>>>24,u=(a&255<<16)>>>16,l=(a&65280)>>>8,d=a&255,[f,u,l,d].join(".")},i=function(a){var f,u,l,d,y,m;for(f=[],l=d=0;d<=3&&a.length!==0;l=++d){if(l>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}m=t(a),y=m[0],u=m[1],a=a.substring(u),f.push(y)}if(a.length!==0)throw new Error("Invalid IP");switch(f.length){case 1:if(f[0]>4294967295)throw new Error("Invalid IP");return f[0]>>>0;case 2:if(f[0]>255||f[1]>16777215)throw new Error("Invalid IP");return(f[0]<<24|f[1])>>>0;case 3:if(f[0]>255||f[1]>255||f[2]>65535)throw new Error("Invalid IP");return(f[0]<<24|f[1]<<16|f[2])>>>0;case 4:if(f[0]>255||f[1]>255||f[2]>255||f[3]>255)throw new Error("Invalid IP");return(f[0]<<24|f[1]<<16|f[2]<<8|f[3])>>>0;default:throw new Error("Invalid IP")}},e=function(a){return a.charCodeAt(0)},n=e("0"),s=e("a"),o=e("A"),t=function(a){var f,u,l,d,y;for(d=0,f=10,u="9",l=0,a.length>1&&a[l]==="0"&&(a[l+1]==="x"||a[l+1]==="X"?(l+=2,f=16):"0"<=a[l+1]&&a[l+1]<="9"&&(l++,f=8,u="7")),y=l;l<a.length;){if("0"<=a[l]&&a[l]<=u)d=d*f+(e(a[l])-n)>>>0;else if(f===16)if("a"<=a[l]&&a[l]<="f")d=d*f+(10+e(a[l])-s)>>>0;else if("A"<=a[l]&&a[l]<="F")d=d*f+(10+e(a[l])-o)>>>0;else break;else break;if(d>4294967295)throw new Error("too large");l++}if(l===y)throw new Error("empty octet");return[d,l]},r=function(){function a(f,u){var l,d,y,m;if(typeof f!="string")throw new Error("Missing `net' parameter");if(u||(m=f.split("/",2),f=m[0],u=m[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=i(u)}catch(b){throw l=b,new Error("Invalid mask: "+u)}for(d=y=32;y>=0;d=--y)if(this.maskLong===4294967295<<32-d>>>0){this.bitmask=d;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(f)&this.maskLong)>>>0}catch(b){throw l=b,new Error("Invalid net address: "+f)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return a.prototype.contains=function(f){return typeof f=="string"&&(f.indexOf("/")>0||f.split(".").length!==4)&&(f=new a(f)),f instanceof a?this.contains(f.base)&&this.contains(f.broadcast||f.last):(i(f)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(f){return f==null&&(f=1),new a(c(this.netLong+this.size*f),this.mask)},a.prototype.forEach=function(f){var u,l,d;for(d=i(this.first),l=i(this.last),u=0;d<=l;)f(c(d),d,u),u++,d++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),Pr.ip2long=i,Pr.long2ip=c,Pr.Netmask=r}).call(Pr)});var Jl={};Et(Jl,{identify:()=>Xl,identifyPush:()=>Ql});var Dn=Symbol.for("@libp2p/peer-id");var vt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Oe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ur=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Dr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}},Or=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},_t=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var we=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var kr=Symbol.for("@libp2p/service-capabilities"),nd=Symbol.for("@libp2p/service-dependencies");var Fn={};Et(Fn,{base58btc:()=>X,base58flickr:()=>Ic});var Bd=new Uint8Array(0);function ks(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Yt(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 Ms(r){return new TextEncoder().encode(r)}function Ks(r){return new TextDecoder().decode(r)}function xc(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,h=0,E=0,S=m.length;E!==S&&m[E]===0;)E++,b++;for(var g=(S-E)*u+1>>>0,A=new Uint8Array(g);E!==S;){for(var R=m[E],C=0,B=g-1;(R!==0||C<h)&&B!==-1;B--,C++)R+=256*A[B]>>>0,A[B]=R%c>>>0,R=R/c>>>0;if(R!==0)throw new Error("Non-zero carry");h=C,E++}for(var P=g-h;P!==g&&A[P]===0;)P++;for(var T=a.repeat(b);P<g;++P)T+=r.charAt(A[P]);return T}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var h=0,E=0;m[b]===a;)h++,b++;for(var S=(m.length-b)*f+1>>>0,g=new Uint8Array(S);m[b];){var A=e[m.charCodeAt(b)];if(A===255)return;for(var R=0,C=S-1;(A!==0||R<E)&&C!==-1;C--,R++)A+=c*g[C]>>>0,g[C]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");E=R,b++}if(m[b]!==" "){for(var B=S-E;B!==S&&g[B]===0;)B++;for(var P=new Uint8Array(h+(S-B)),T=h;B!==S;)P[T++]=g[B++];return P}}}function y(m){var b=d(m);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:y}}var wc=xc,Ec=wc,Vs=Ec;var On=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},kn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return qs(this,t)}},Mn=class{decoders;constructor(t){this.decoders=t}or(t){return qs(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function qs(r,t){return new Mn({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Kn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new On(t,e,n),this.decoder=new kn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ke({name:r,prefix:t,encode:e,decode:n}){return new Kn(r,t,e,n)}function ie({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Vs(e,r);return ke({prefix:t,name:r,encode:n,decode:s=>Yt(o(s))})}function vc(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,f=0;for(let u=0;u<s;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,i[f++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function Sc(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function nt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ke({prefix:t,name:r,encode(o){return Sc(o,n,e)},decode(o){return vc(o,n,e,r)}})}var X=ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ic=ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vn={};Et(Vn,{base32:()=>jt,base32hex:()=>Lc,base32hexpad:()=>Cc,base32hexpadupper:()=>Rc,base32hexupper:()=>Pc,base32pad:()=>Bc,base32padupper:()=>Tc,base32upper:()=>Ac,base32z:()=>_c});var jt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ac=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bc=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tc=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lc=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pc=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cc=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rc=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_c=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var qn={};Et(qn,{base36:()=>sr,base36upper:()=>Nc});var sr=ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Nc=ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Uc=Gs,Hs=128,Dc=127,Oc=~Dc,kc=Math.pow(2,31);function Gs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=kc;)t[e++]=r&255|Hs,r/=128;for(;r&Oc;)t[e++]=r&255|Hs,r>>>=7;return t[e]=r|0,Gs.bytes=e-n+1,t}var Mc=Hn,Kc=128,zs=127;function Hn(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Hn.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&zs)<<o:(i&zs)*Math.pow(2,o),o+=7}while(i>=Kc);return Hn.bytes=s-n,e}var Fc=Math.pow(2,7),Vc=Math.pow(2,14),qc=Math.pow(2,21),Hc=Math.pow(2,28),zc=Math.pow(2,35),Gc=Math.pow(2,42),$c=Math.pow(2,49),Zc=Math.pow(2,56),Wc=Math.pow(2,63),Yc=function(r){return r<Fc?1:r<Vc?2:r<qc?3:r<Hc?4:r<zc?5:r<Gc?6:r<$c?7:r<Zc?8:r<Wc?9:10},jc={encode:Uc,decode:Mc,encodingLength:Yc},Xc=jc,ir=Xc;function ar(r,t=0){return[ir.decode(r,t),ir.decode.bytes]}function Me(r,t,e=0){return ir.encode(r,t,e),t}function Ke(r){return ir.encodingLength(r)}function Nt(r,t){let e=t.byteLength,n=Ke(r),o=n+Ke(e),s=new Uint8Array(o+e);return Me(r,s,0),Me(e,s,n),s.set(t,o),new Fe(r,e,t,s)}function Ee(r){let t=Yt(r),[e,n]=ar(t),[o,s]=ar(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Fe(e,o,i,t)}function $s(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ks(r.bytes,e.bytes)}}var Fe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Zs(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Jc(e,zn(r),t??X.encoder);default:return tu(e,zn(r),t??jt.encoder)}}var Ws=new WeakMap;function zn(r){let t=Ws.get(r);if(t==null){let e=new Map;return Ws.set(r,e),e}return t}var ft=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==cr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==eu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Nt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&$s(t.multihash,n.multihash)}toString(t){return Zs(this,t)}toJSON(){return{"/":Zs(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Ys(n,o,s.bytes))}else if(e[ru]===!0){let{version:n,multihash:o,code:s}=e,i=Ee(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==cr)throw new Error(`Version 0 CID must use dag-pb (code: ${cr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Ys(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,cr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Yt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Fe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,d]=ar(t.subarray(e));return e+=d,l},o=n(),s=cr;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Qc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return zn(s).set(n,t),s}};function Qc(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case jt.prefix:{let e=t??jt;return[jt.prefix,e.decode(r)]}case sr.prefix:{let e=t??sr;return[sr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Jc(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function tu(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var cr=112,eu=18;function Ys(r,t,e){let n=Ke(r),o=n+Ke(t),s=new Uint8Array(o+e.byteLength);return Me(r,s,0),Me(t,s,n),s.set(e,o),s}var ru=Symbol.for("@ipld/js-cid/CID");var Gn={};Et(Gn,{identity:()=>Xt});var js=0,nu="identity",Xs=Yt;function ou(r){return Nt(js,Xs(r))}var Xt={code:js,name:nu,encode:Xs,digest:ou};function mt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Qs(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function su(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ve(r,...t){if(!su(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Js(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Qs(r.outputLen),Qs(r.blockLen)}function qe(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ti(r,t){Ve(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var ve=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Kr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ut(r,t){return r<<32-t|r>>>t}function ei(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function ur(r){return typeof r=="string"&&(r=ei(r)),Ve(r),r}function $n(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ve(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var He=class{clone(){return this._cloneInto()}};function Fr(r){let t=n=>r().update(ur(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Vr(r=32){if(ve&&typeof ve.getRandomValues=="function")return ve.getRandomValues(new Uint8Array(r));if(ve&&typeof ve.randomBytes=="function")return ve.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function iu(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,f=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+f,c,n)}function ri(r,t,e){return r&t^~r&e}function ni(r,t,e){return r&t^r&e^t&e}var ze=class extends He{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Kr(this.buffer)}update(t){qe(this);let{view:e,buffer:n,blockLen:o}=this;t=ur(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Kr(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){qe(this),ti(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;iu(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Kr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var qr=BigInt(4294967295),Zn=BigInt(32);function oi(r,t=!1){return t?{h:Number(r&qr),l:Number(r>>Zn&qr)}:{h:Number(r>>Zn&qr)|0,l:Number(r&qr)|0}}function au(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=oi(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var cu=(r,t)=>BigInt(r>>>0)<<Zn|BigInt(t>>>0),uu=(r,t,e)=>r>>>e,fu=(r,t,e)=>r<<32-e|t>>>e,lu=(r,t,e)=>r>>>e|t<<32-e,du=(r,t,e)=>r<<32-e|t>>>e,hu=(r,t,e)=>r<<64-e|t>>>e-32,pu=(r,t,e)=>r>>>e-32|t<<64-e,mu=(r,t)=>t,gu=(r,t)=>r,yu=(r,t,e)=>r<<e|t>>>32-e,bu=(r,t,e)=>t<<e|r>>>32-e,xu=(r,t,e)=>t<<e-32|r>>>64-e,wu=(r,t,e)=>r<<e-32|t>>>64-e;function Eu(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var vu=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Su=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Iu=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Au=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Bu=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Tu=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Lu={fromBig:oi,split:au,toBig:cu,shrSH:uu,shrSL:fu,rotrSH:lu,rotrSL:du,rotrBH:hu,rotrBL:pu,rotr32H:mu,rotr32L:gu,rotlSH:yu,rotlSL:bu,rotlBH:xu,rotlBL:wu,add:Eu,add3L:vu,add3H:Su,add4L:Iu,add4H:Au,add5H:Tu,add5L:Bu},D=Lu;var[Pu,Cu]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),ce=new Uint32Array(80),ue=new Uint32Array(80),Wn=class extends ze{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:d,Gh:y,Gl:m,Hh:b,Hl:h}=this;return[t,e,n,o,s,i,c,a,f,u,l,d,y,m,b,h]}set(t,e,n,o,s,i,c,a,f,u,l,d,y,m,b,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=y|0,this.Gl=m|0,this.Hh=b|0,this.Hl=h|0}process(t,e){for(let g=0;g<16;g++,e+=4)ce[g]=t.getUint32(e),ue[g]=t.getUint32(e+=4);for(let g=16;g<80;g++){let A=ce[g-15]|0,R=ue[g-15]|0,C=D.rotrSH(A,R,1)^D.rotrSH(A,R,8)^D.shrSH(A,R,7),B=D.rotrSL(A,R,1)^D.rotrSL(A,R,8)^D.shrSL(A,R,7),P=ce[g-2]|0,T=ue[g-2]|0,Q=D.rotrSH(P,T,19)^D.rotrBH(P,T,61)^D.shrSH(P,T,6),q=D.rotrSL(P,T,19)^D.rotrBL(P,T,61)^D.shrSL(P,T,6),k=D.add4L(B,q,ue[g-7],ue[g-16]),st=D.add4H(k,C,Q,ce[g-7],ce[g-16]);ce[g]=st|0,ue[g]=k|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:d,Fh:y,Fl:m,Gh:b,Gl:h,Hh:E,Hl:S}=this;for(let g=0;g<80;g++){let A=D.rotrSH(l,d,14)^D.rotrSH(l,d,18)^D.rotrBH(l,d,41),R=D.rotrSL(l,d,14)^D.rotrSL(l,d,18)^D.rotrBL(l,d,41),C=l&y^~l&b,B=d&m^~d&h,P=D.add5L(S,R,B,Cu[g],ue[g]),T=D.add5H(P,E,A,C,Pu[g],ce[g]),Q=P|0,q=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),k=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),st=n&s^n&c^s&c,v=o&i^o&a^i&a;E=b|0,S=h|0,b=y|0,h=m|0,y=l|0,m=d|0,{h:l,l:d}=D.add(f|0,u|0,T|0,Q|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let L=D.add3L(Q,k,v);n=D.add3H(L,T,q,st),o=L|0}({h:n,l:o}=D.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=D.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=D.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=D.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=D.add(this.Eh|0,this.El|0,l|0,d|0),{h:y,l:m}=D.add(this.Fh|0,this.Fl|0,y|0,m|0),{h:b,l:h}=D.add(this.Gh|0,this.Gl|0,b|0,h|0),{h:E,l:S}=D.add(this.Hh|0,this.Hl|0,E|0,S|0),this.set(n,o,s,i,c,a,f,u,l,d,y,m,b,h,E,S)}roundClean(){ce.fill(0),ue.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var si=Fr(()=>new Wn);var Gr={};Et(Gr,{aInRange:()=>It,abool:()=>Dt,abytes:()=>Ge,bitGet:()=>Ou,bitLen:()=>Qn,bitMask:()=>lr,bitSet:()=>ku,bytesToHex:()=>Jt,bytesToNumberBE:()=>te,bytesToNumberLE:()=>le,concatBytes:()=>ee,createHmacDrbg:()=>Jn,ensureBytes:()=>et,equalBytes:()=>Uu,hexToBytes:()=>Ie,hexToNumber:()=>Xn,inRange:()=>fr,isBytes:()=>fe,memoized:()=>Be,notImplemented:()=>Ku,numberToBytesBE:()=>de,numberToBytesLE:()=>Ae,numberToHexUnpadded:()=>Se,numberToVarBytesBE:()=>Nu,utf8ToBytes:()=>Du,validateObject:()=>zt});var Hr=BigInt(0),zr=BigInt(1),Ru=BigInt(2);function fe(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ge(r){if(!fe(r))throw new Error("Uint8Array expected")}function Dt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var _u=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Jt(r){Ge(r);let t="";for(let e=0;e<r.length;e++)t+=_u[r[e]];return t}function Se(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Xn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Hr:BigInt("0x"+r)}var Qt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ii(r){if(r>=Qt._0&&r<=Qt._9)return r-Qt._0;if(r>=Qt.A&&r<=Qt.F)return r-(Qt.A-10);if(r>=Qt.a&&r<=Qt.f)return r-(Qt.a-10)}function Ie(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=ii(r.charCodeAt(s)),c=ii(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function te(r){return Xn(Jt(r))}function le(r){return Ge(r),Xn(Jt(Uint8Array.from(r).reverse()))}function de(r,t){return Ie(r.toString(16).padStart(t*2,"0"))}function Ae(r,t){return de(r,t).reverse()}function Nu(r){return Ie(Se(r))}function et(r,t,e){let n;if(typeof t=="string")try{n=Ie(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(fe(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function ee(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ge(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Uu(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Du(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Yn=r=>typeof r=="bigint"&&Hr<=r;function fr(r,t,e){return Yn(r)&&Yn(t)&&Yn(e)&&t<=r&&r<e}function It(r,t,e,n){if(!fr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Qn(r){let t;for(t=0;r>Hr;r>>=zr,t+=1);return t}function Ou(r,t){return r>>BigInt(t)&zr}function ku(r,t,e){return r|(e?zr:Hr)<<BigInt(t)}var lr=r=>(Ru<<BigInt(r-1))-zr,jn=r=>new Uint8Array(r),ai=r=>Uint8Array.from(r);function Jn(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=jn(r),o=jn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=jn())=>{o=c(ai([0]),l),n=c(),l.length!==0&&(o=c(ai([1]),l),n=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<t;){n=c();let y=n.slice();d.push(y),l+=n.length}return ee(...d)};return(l,d)=>{i(),a(l);let y;for(;!(y=d(f()));)a();return i(),y}}var Mu={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||fe(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function zt(r,t,e={}){let n=(o,s,i)=>{let c=Mu[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}var Ku=()=>{throw new Error("not implemented")};function Be(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var it=BigInt(0),J=BigInt(1),Te=BigInt(2),Fu=BigInt(3),to=BigInt(4),ci=BigInt(5),ui=BigInt(8),Vu=BigInt(9),qu=BigInt(16);function W(r,t){let e=r%t;return e>=it?e:t+e}function Hu(r,t,e){if(t<it)throw new Error("invalid exponent, negatives unsupported");if(e<=it)throw new Error("invalid modulus");if(e===J)return it;let n=J;for(;t>it;)t&J&&(n=n*r%e),r=r*r%e,t>>=J;return n}function tt(r,t,e){let n=r;for(;t-- >it;)n*=n,n%=e;return n}function $r(r,t){if(r===it)throw new Error("invert: expected non-zero number");if(t<=it)throw new Error("invert: expected positive modulus, got "+t);let e=W(r,t),n=t,o=it,s=J,i=J,c=it;for(;e!==it;){let f=n/e,u=n%e,l=o-i*f,d=s-c*f;n=e,e=u,o=i,s=c,i=l,c=d}if(n!==J)throw new Error("invert: does not exist");return W(o,t)}function zu(r){let t=(r-J)/Te,e,n,o;for(e=r-J,n=0;e%Te===it;e/=Te,n++);for(o=Te;o<r&&Hu(o,t,r)!==r-J;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+J)/to;return function(a,f){let u=a.pow(f,i);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+J)/Te;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,s),d=c.pow(a,e);for(;!c.eql(d,c.ONE);){if(c.eql(d,c.ZERO))return c.ZERO;let y=1;for(let b=c.sqr(d);y<f&&!c.eql(b,c.ONE);y++)b=c.sqr(b);let m=c.pow(u,J<<BigInt(f-y-1));u=c.sqr(m),l=c.mul(l,m),d=c.mul(d,u),f=y}return l}}function Gu(r){if(r%to===Fu){let t=(r+J)/to;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%ui===ci){let t=(r-ci)/ui;return function(n,o){let s=n.mul(o,Te),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,Te),i),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%qu,zu(r)}var fi=(r,t)=>(W(r,t)&J)===J,$u=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function eo(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=$u.reduce((n,o)=>(n[o]="function",n),t);return zt(r,e)}function Zu(r,t,e){if(e<it)throw new Error("invalid exponent, negatives unsupported");if(e===it)return r.ONE;if(e===J)return t;let n=r.ONE,o=t;for(;e>it;)e&J&&(n=r.mul(n,o)),o=r.sqr(o),e>>=J;return n}function Wu(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function ro(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function he(r,t,e=!1,n={}){if(r<=it)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=ro(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:lr(o),ZERO:it,ONE:J,create:a=>W(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return it<=a&&a<r},is0:a=>a===it,isOdd:a=>(a&J)===J,neg:a=>W(-a,r),eql:(a,f)=>a===f,sqr:a=>W(a*a,r),add:(a,f)=>W(a+f,r),sub:(a,f)=>W(a-f,r),mul:(a,f)=>W(a*f,r),pow:(a,f)=>Zu(c,a,f),div:(a,f)=>W(a*$r(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>$r(a,r),sqrt:n.sqrt||(a=>(i||(i=Gu(r)),i(c,a))),invertBatch:a=>Wu(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?Ae(a,s):de(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?le(a):te(a)}});return Object.freeze(c)}function li(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function no(r){let t=li(r);return t+Math.ceil(t/2)}function di(r,t,e=!1){let n=r.length,o=li(t),s=no(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?le(r):te(r),c=W(i,t-J)+J;return e?Ae(c,o):de(c,o)}var hi=BigInt(0),Zr=BigInt(1);function oo(r,t){let e=t.negate();return r?e:t}function pi(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function so(r,t){pi(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Yu(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function ju(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var io=new WeakMap,mi=new WeakMap;function ao(r){return mi.get(r)||1}function Wr(r,t){return{constTimeNegate:oo,hasPrecomputes(e){return ao(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>hi;)n&Zr&&(o=o.add(s)),s=s.double(),n>>=Zr;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=so(n,t),i=[],c=e,a=c;for(let f=0;f<o;f++){a=c,i.push(a);for(let u=1;u<s;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=so(e,t),c=r.ZERO,a=r.BASE,f=BigInt(2**e-1),u=2**e,l=BigInt(e);for(let d=0;d<s;d++){let y=d*i,m=Number(o&f);o>>=l,m>i&&(m-=u,o+=Zr);let b=y,h=y+Math.abs(m)-1,E=d%2!==0,S=m<0;m===0?a=a.add(oo(E,n[b])):c=c.add(oo(S,n[h]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:c}=so(e,t),a=BigInt(2**e-1),f=2**e,u=BigInt(e);for(let l=0;l<i;l++){let d=l*c;if(o===hi)break;let y=Number(o&a);if(o>>=u,y>c&&(y-=f,o+=Zr),y===0)continue;let m=n[d+Math.abs(y)-1];y<0&&(m=m.negate()),s=s.add(m)}return s},getPrecomputes(e,n,o){let s=io.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&io.set(n,o(s))),s},wNAFCached(e,n,o){let s=ao(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=ao(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){pi(n,t),mi.set(e,n),io.delete(e)}}}function Yr(r,t,e,n){if(Yu(e,r),ju(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Qn(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,a=new Array(c+1).fill(o),f=Math.floor((t.BITS-1)/i)*i,u=o;for(let l=f;l>=0;l-=i){a.fill(o);for(let y=0;y<n.length;y++){let m=n[y],b=Number(m>>BigInt(l)&BigInt(c));a[b]=a[b].add(e[y])}let d=o;for(let y=a.length-1,m=o;y>0;y--)m=m.add(a[y]),d=d.add(m);if(u=u.add(d),l!==0)for(let y=0;y<i;y++)u=u.double()}return u}function dr(r){return eo(r.Fp),zt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ro(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ot=BigInt(0),At=BigInt(1),jr=BigInt(2),Xu=BigInt(8),Qu={zip215:!0};function Ju(r){let t=dr(r);return zt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function gi(r){let t=Ju(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,f=jr<<BigInt(c*8)-At,u=e.create,l=he(t.n,t.nBitLength),d=t.uvRatio||((x,p)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(p))}}catch{return{isValid:!1,value:Ot}}}),y=t.adjustScalarBytes||(x=>x),m=t.domain||((x,p,w)=>{if(Dt("phflag",w),p.length||w)throw new Error("Contexts/pre-hash are not supported");return x});function b(x,p){It("coordinate "+x,p,Ot,f)}function h(x){if(!(x instanceof g))throw new Error("ExtendedPoint expected")}let E=Be((x,p)=>{let{ex:w,ey:I,ez:_}=x,N=x.is0();p==null&&(p=N?Xu:e.inv(_));let O=u(w*p),M=u(I*p),U=u(_*p);if(N)return{x:Ot,y:At};if(U!==At)throw new Error("invZ was invalid");return{x:O,y:M}}),S=Be(x=>{let{a:p,d:w}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:I,ey:_,ez:N,et:O}=x,M=u(I*I),U=u(_*_),Z=u(N*N),j=u(Z*Z),ct=u(M*p),ut=u(Z*u(ct+U)),dt=u(j+u(w*u(M*U)));if(ut!==dt)throw new Error("bad point: equation left != right (1)");let pt=u(I*_),St=u(N*O);if(pt!==St)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(p,w,I,_){this.ex=p,this.ey=w,this.ez=I,this.et=_,b("x",p),b("y",w),b("z",I),b("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof g)throw new Error("extended point not allowed");let{x:w,y:I}=p||{};return b("x",w),b("y",I),new g(w,I,At,u(w*I))}static normalizeZ(p){let w=e.invertBatch(p.map(I=>I.ez));return p.map((I,_)=>I.toAffine(w[_])).map(g.fromAffine)}static msm(p,w){return Yr(g,l,p,w)}_setWindowSize(p){C.setWindowSize(this,p)}assertValidity(){S(this)}equals(p){h(p);let{ex:w,ey:I,ez:_}=this,{ex:N,ey:O,ez:M}=p,U=u(w*M),Z=u(N*_),j=u(I*M),ct=u(O*_);return U===Z&&j===ct}is0(){return this.equals(g.ZERO)}negate(){return new g(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:w,ey:I,ez:_}=this,N=u(w*w),O=u(I*I),M=u(jr*u(_*_)),U=u(p*N),Z=w+I,j=u(u(Z*Z)-N-O),ct=U+O,ut=ct-M,dt=U-O,pt=u(j*ut),St=u(ct*dt),wt=u(j*dt),Ht=u(ut*ct);return new g(pt,St,Ht,wt)}add(p){h(p);let{a:w,d:I}=t,{ex:_,ey:N,ez:O,et:M}=this,{ex:U,ey:Z,ez:j,et:ct}=p;if(w===BigInt(-1)){let Ps=u((N-_)*(Z+U)),Cs=u((N+_)*(Z-U)),Un=u(Cs-Ps);if(Un===Ot)return this.double();let Rs=u(O*jr*ct),_s=u(M*jr*j),Ns=_s+Rs,Us=Cs+Ps,Ds=_s-Rs,ac=u(Ns*Un),cc=u(Us*Ds),uc=u(Ns*Ds),fc=u(Un*Us);return new g(ac,cc,fc,uc)}let ut=u(_*U),dt=u(N*Z),pt=u(M*I*ct),St=u(O*j),wt=u((_+N)*(U+Z)-ut-dt),Ht=St-pt,Wt=St+pt,or=u(dt-w*ut),nc=u(wt*Ht),oc=u(Wt*or),sc=u(wt*or),ic=u(Ht*Wt);return new g(nc,oc,ic,sc)}subtract(p){return this.add(p.negate())}wNAF(p){return C.wNAFCached(this,p,g.normalizeZ)}multiply(p){let w=p;It("scalar",w,At,n);let{p:I,f:_}=this.wNAF(w);return g.normalizeZ([I,_])[0]}multiplyUnsafe(p,w=g.ZERO){let I=p;return It("scalar",I,Ot,n),I===Ot?R:this.is0()||I===At?this:C.wNAFCachedUnsafe(this,I,g.normalizeZ,w)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return C.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=t;return p===At?this:this.multiplyUnsafe(p)}static fromHex(p,w=!1){let{d:I,a:_}=t,N=e.BYTES;p=et("pointHex",p,N),Dt("zip215",w);let O=p.slice(),M=p[N-1];O[N-1]=M&-129;let U=le(O),Z=w?f:e.ORDER;It("pointHex.y",U,Ot,Z);let j=u(U*U),ct=u(j-At),ut=u(I*j-_),{isValid:dt,value:pt}=d(ct,ut);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let St=(pt&At)===At,wt=(M&128)!==0;if(!w&&pt===Ot&&wt)throw new Error("Point.fromHex: x=0 and x_0=1");return wt!==St&&(pt=u(-pt)),g.fromAffine({x:pt,y:U})}static fromPrivateKey(p){return T(p).point}toRawBytes(){let{x:p,y:w}=this.toAffine(),I=Ae(w,e.BYTES);return I[I.length-1]|=p&At?128:0,I}toHex(){return Jt(this.toRawBytes())}}g.BASE=new g(t.Gx,t.Gy,At,u(t.Gx*t.Gy)),g.ZERO=new g(Ot,At,At,Ot);let{BASE:A,ZERO:R}=g,C=Wr(g,c*8);function B(x){return W(x,n)}function P(x){return B(le(x))}function T(x){let p=e.BYTES;x=et("private key",x,p);let w=et("hashed private key",s(x),2*p),I=y(w.slice(0,p)),_=w.slice(p,2*p),N=P(I),O=A.multiply(N),M=O.toRawBytes();return{head:I,prefix:_,scalar:N,point:O,pointBytes:M}}function Q(x){return T(x).pointBytes}function q(x=new Uint8Array,...p){let w=ee(...p);return P(s(m(w,et("context",x),!!o)))}function k(x,p,w={}){x=et("message",x),o&&(x=o(x));let{prefix:I,scalar:_,pointBytes:N}=T(p),O=q(w.context,I,x),M=A.multiply(O).toRawBytes(),U=q(w.context,M,N,x),Z=B(O+U*_);It("signature.s",Z,Ot,n);let j=ee(M,Ae(Z,e.BYTES));return et("result",j,e.BYTES*2)}let st=Qu;function v(x,p,w,I=st){let{context:_,zip215:N}=I,O=e.BYTES;x=et("signature",x,2*O),p=et("message",p),w=et("publicKey",w,O),N!==void 0&&Dt("zip215",N),o&&(p=o(p));let M=le(x.slice(O,2*O)),U,Z,j;try{U=g.fromHex(w,N),Z=g.fromHex(x.slice(0,O),N),j=A.multiplyUnsafe(M)}catch{return!1}if(!N&&U.isSmallOrder())return!1;let ct=q(_,Z.toRawBytes(),U.toRawBytes(),p);return Z.add(U.multiplyUnsafe(ct)).subtract(j).clearCofactor().equals(g.ZERO)}return A._setWindowSize(8),{CURVE:t,getPublicKey:Q,sign:k,verify:v,ExtendedPoint:g,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,p=g.BASE){return p._setWindowSize(x),p.multiply(BigInt(3)),p}}}}var co=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),yi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),bh=BigInt(0),tf=BigInt(1),bi=BigInt(2),xh=BigInt(3),ef=BigInt(5),rf=BigInt(8);function nf(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=co,c=r*r%s*r%s,a=tt(c,bi,s)*c%s,f=tt(a,tf,s)*r%s,u=tt(f,ef,s)*f%s,l=tt(u,t,s)*u%s,d=tt(l,e,s)*l%s,y=tt(d,n,s)*d%s,m=tt(y,o,s)*y%s,b=tt(m,o,s)*y%s,h=tt(b,t,s)*u%s;return{pow_p_5_8:tt(h,bi,s)*r%s,b2:c}}function of(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function sf(r,t){let e=co,n=W(t*t*t,e),o=W(n*n*t,e),s=nf(r*o).pow_p_5_8,i=W(r*n*s,e),c=W(t*i*i,e),a=i,f=W(i*yi,e),u=c===r,l=c===W(-r,e),d=c===W(-r*yi,e);return u&&(i=a),(l||d)&&(i=f),fi(i,e)&&(i=W(-i,e)),{isValid:u||l,value:i}}var af=he(co,void 0,!0),cf={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:af,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:rf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:si,randomBytes:Vr,adjustScalarBytes:of,uvRatio:sf},xi=gi(cf);var Xr=32;function wi(r,t,e){return xi.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Qr=class{type="Ed25519";raw;constructor(t){this.raw=uo(t,Xr)}toMultihash(){return Xt.digest(pe(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:mt(this.raw,t.raw)}verify(t,e){return wi(this.raw,e,t)}};function fo(r){return r=uo(r,Xr),new Qr(r)}function uo(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new vt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function ht(r=0){return new Uint8Array(r)}function Bt(r=0){return new Uint8Array(r)}var ff=Math.pow(2,7),lf=Math.pow(2,14),df=Math.pow(2,21),lo=Math.pow(2,28),ho=Math.pow(2,35),po=Math.pow(2,42),mo=Math.pow(2,49),$=128,gt=127;function yt(r){if(r<ff)return 1;if(r<lf)return 2;if(r<df)return 3;if(r<lo)return 4;if(r<ho)return 5;if(r<po)return 6;if(r<mo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function go(r,t,e=0){switch(yt(r)){case 8:t[e++]=r&255|$,r/=128;case 7:t[e++]=r&255|$,r/=128;case 6:t[e++]=r&255|$,r/=128;case 5:t[e++]=r&255|$,r/=128;case 4:t[e++]=r&255|$,r>>>=7;case 3:t[e++]=r&255|$,r>>>=7;case 2:t[e++]=r&255|$,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function hf(r,t,e=0){switch(yt(r)){case 8:t.set(e++,r&255|$),r/=128;case 7:t.set(e++,r&255|$),r/=128;case 6:t.set(e++,r&255|$),r/=128;case 5:t.set(e++,r&255|$),r/=128;case 4:t.set(e++,r&255|$),r>>>=7;case 3:t.set(e++,r&255|$),r>>>=7;case 2:t.set(e++,r&255|$),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function yo(r,t){let e=r[t],n=0;if(n+=e>,e<$||(e=r[t+1],n+=(e>)<<7,e<$)||(e=r[t+2],n+=(e>)<<14,e<$)||(e=r[t+3],n+=(e>)<<21,e<$)||(e=r[t+4],n+=(e>)*lo,e<$)||(e=r[t+5],n+=(e>)*ho,e<$)||(e=r[t+6],n+=(e>)*po,e<$)||(e=r[t+7],n+=(e>)*mo,e<$))return n;throw new RangeError("Could not decode varint")}function pf(r,t){let e=r.get(t),n=0;if(n+=e>,e<$||(e=r.get(t+1),n+=(e>)<<7,e<$)||(e=r.get(t+2),n+=(e>)<<14,e<$)||(e=r.get(t+3),n+=(e>)<<21,e<$)||(e=r.get(t+4),n+=(e>)*lo,e<$)||(e=r.get(t+5),n+=(e>)*ho,e<$)||(e=r.get(t+6),n+=(e>)*po,e<$)||(e=r.get(t+7),n+=(e>)*mo,e<$))return n;throw new RangeError("Could not decode varint")}function Ct(r,t,e=0){return t==null&&(t=Bt(yt(r))),t instanceof Uint8Array?go(r,t,e):hf(r,t,e)}function re(r,t=0){return r instanceof Uint8Array?yo(r,t):pf(r,t)}var bo=new Float32Array([-0]),me=new Uint8Array(bo.buffer);function vi(r,t,e){bo[0]=r,t[e]=me[0],t[e+1]=me[1],t[e+2]=me[2],t[e+3]=me[3]}function Si(r,t){return me[0]=r[t],me[1]=r[t+1],me[2]=r[t+2],me[3]=r[t+3],bo[0]}var xo=new Float64Array([-0]),bt=new Uint8Array(xo.buffer);function Ii(r,t,e){xo[0]=r,t[e]=bt[0],t[e+1]=bt[1],t[e+2]=bt[2],t[e+3]=bt[3],t[e+4]=bt[4],t[e+5]=bt[5],t[e+6]=bt[6],t[e+7]=bt[7]}function Ai(r,t){return bt[0]=r[t],bt[1]=r[t+1],bt[2]=r[t+2],bt[3]=r[t+3],bt[4]=r[t+4],bt[5]=r[t+5],bt[6]=r[t+6],bt[7]=r[t+7],xo[0]}var mf=BigInt(Number.MAX_SAFE_INTEGER),gf=BigInt(Number.MIN_SAFE_INTEGER),Lt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Le;if(t<mf&&t>gf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Bi&&(o=0n,++n>Bi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Le;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Le}},Le=new Lt(0,0);Le.toBigInt=function(){return 0n};Le.zzEncode=Le.zzDecode=function(){return this};Le.length=function(){return 1};var Bi=4294967296n;function Ti(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Li(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function wo(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function kt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function tn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Eo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,kt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw kt(this,4);return tn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw kt(this,4);return tn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw kt(this,4);let t=Si(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw kt(this,4);let t=Ai(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw kt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Li(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw kt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw kt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Lt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw kt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw kt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw kt(this,8);let t=tn(this.buf,this.pos+=4),e=tn(this.buf,this.pos+=4);return new Lt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=yo(this.buf,this.pos);return this.pos+=yt(t),t}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 vo(r){return new Eo(r instanceof Uint8Array?r:r.subarray())}function Mt(r,t,e){let n=vo(r);return t.decode(n,void 0,e)}var So={};Et(So,{base10:()=>yf});var yf=ie({prefix:"9",name:"base10",alphabet:"0123456789"});var Io={};Et(Io,{base16:()=>bf,base16upper:()=>xf});var bf=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xf=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ao={};Et(Ao,{base2:()=>wf});var wf=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bo={};Et(Bo,{base256emoji:()=>Af});var Ci=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}"),Ef=Ci.reduce((r,t,e)=>(r[e]=t,r),[]),vf=Ci.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Sf(r){return r.reduce((t,e)=>(t+=Ef[e],t),"")}function If(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=vf[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Af=ke({prefix:"\u{1F680}",name:"base256emoji",encode:Sf,decode:If});var Lo={};Et(Lo,{base64:()=>Bf,base64pad:()=>Tf,base64url:()=>To,base64urlpad:()=>Lf});var Bf=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tf=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),To=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lf=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Po={};Et(Po,{base8:()=>Pf});var Pf=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Co={};Et(Co,{identity:()=>Cf});var Cf=ke({prefix:"\0",name:"identity",encode:r=>Ks(r),decode:r=>Ms(r)});var ep=new TextEncoder,rp=new TextDecoder;var No={};Et(No,{sha256:()=>hr,sha512:()=>Nf});function _o({name:r,code:t,encode:e}){return new Ro(r,t,e)}var Ro=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Nt(this.code,e):e.then(n=>Nt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function _i(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var hr=_o({name:"sha2-256",code:18,encode:_i("SHA-256")}),Nf=_o({name:"sha2-512",code:19,encode:_i("SHA-512")});var pr={...Co,...Ao,...Po,...So,...Io,...Vn,...qn,...Fn,...Lo,...Bo},pp={...No,...Gn};function Ui(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ni=Ui("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Uo=Ui("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Bt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Uf={utf8:Ni,"utf-8":Ni,hex:pr.base16,latin1:Uo,ascii:Uo,binary:Uo,...pr},en=Uf;function H(r,t="utf8"){let e=en[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Do(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return Bt(i);o+i>t&&(n=Bt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var Pe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Oo(){}var Mo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Df=Do();function Of(r){return globalThis.Buffer!=null?Bt(r):Df(r)}var gr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Pe(Oo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Pe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ko((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(rn,10,Lt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Lt.fromBigInt(t);return this._push(rn,e.length(),e)}uint64Number(t){return this._push(go,yt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Lt.fromBigInt(t).zzEncode();return this._push(rn,e.length(),e)}sint64Number(t){let e=Lt.fromNumber(t).zzEncode();return this._push(rn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ko,1,t?1:0)}fixed32(t){return this._push(mr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Lt.fromBigInt(t);return this._push(mr,4,e.lo)._push(mr,4,e.hi)}fixed64Number(t){let e=Lt.fromNumber(t);return this._push(mr,4,e.lo)._push(mr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(vi,4,t)}double(t){return this._push(Ii,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ko,1,0):this.uint32(e)._push(Mf,e,t)}string(t){let e=Ti(t);return e!==0?this.uint32(e)._push(wo,e,t):this._push(ko,1,0)}fork(){return this.states=new Mo(this),this.head=this.tail=new Pe(Oo,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 Pe(Oo,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Of(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ko(r,t,e){t[e]=r&255}function kf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Ko=class extends Pe{next;constructor(t,e){super(kf,t,e),this.next=void 0}};function rn(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function mr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Mf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(gr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Kf,t,r),this},gr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Ff,t,r),this});function Kf(r,t,e){t.set(r,e)}function Ff(r,t,e){r.length<40?wo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(H(r),e)}function Fo(){return new gr}function Kt(r,t){let e=Fo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var $e;(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"})($e||($e={}));function nn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Vo(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return nn("enum",$e.VARINT,e,n)}function Ft(r,t){return nn("message",$e.LENGTH_DELIMITED,r,t)}var Ce=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var at;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(at||(at={}));var qo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(qo||(qo={}));(function(r){r.codec=()=>Vo(qo)})(at||(at={}));var Gt;(function(r){let t;r.codec=()=>(t==null&&(t=Ft((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),at.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=at.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Kt(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(Gt||(Gt={}));var Ho;(function(r){let t;r.codec=()=>(t==null&&(t=Ft((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),at.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=at.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Kt(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(Ho||(Ho={}));var xr={};Et(xr,{MAX_RSA_KEY_SIZE:()=>Wo,generateRSAKeyPair:()=>Yi,jwkToJWKKeyPair:()=>ji,jwkToPkcs1:()=>Qf,jwkToPkix:()=>jo,jwkToRSAPrivateKey:()=>Wi,pkcs1ToJwk:()=>Gi,pkcs1ToRSAPrivateKey:()=>Zi,pkixToJwk:()=>$i,pkixToRSAPublicKey:()=>Xo});var Vf=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ge=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ye=new Uint32Array(64),zo=class extends ze{constructor(){super(64,32,8,!1),this.A=ge[0]|0,this.B=ge[1]|0,this.C=ge[2]|0,this.D=ge[3]|0,this.E=ge[4]|0,this.F=ge[5]|0,this.G=ge[6]|0,this.H=ge[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)ye[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let d=ye[l-15],y=ye[l-2],m=Ut(d,7)^Ut(d,18)^d>>>3,b=Ut(y,17)^Ut(y,19)^y>>>10;ye[l]=b+ye[l-7]+m+ye[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Ut(c,6)^Ut(c,11)^Ut(c,25),y=u+d+ri(c,a,f)+Vf[l]+ye[l]|0,b=(Ut(n,2)^Ut(n,13)^Ut(n,22))+ni(n,o,s)|0;u=f,f=a,a=c,c=i+y|0,i=s,s=o,o=n,n=y+b|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){ye.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ze=Fr(()=>new zo);function K(r,t="utf8"){let e=en[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}function Pt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=Bt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ki=Symbol.for("@achingbrain/uint8arraylist");function Oi(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function on(r){return!!r?.[ki]}var ot=class r{bufs;length;[ki]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(on(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(on(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Oi(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Oi(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(on(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Pt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Pt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!on(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let d=f;d>=0;d--){let y=this.get(l+d);if(n[d]!==y){u=Math.max(1,d-c[y]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=ht(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=ht(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=ht(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=ht(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=ht(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=ht(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=ht(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=ht(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!mt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var qf=parseInt("11111",2),$o=parseInt("10000000",2),Hf=parseInt("01111111",2),Mi={2:zf,3:Zf,5:$f,6:Gf,16:Go,22:Go,48:Go};function yr(r,t={offset:0}){let e=r[t.offset]&qf;if(t.offset++,Mi[e]!=null)return Mi[e](r,t);throw new Error("No decoder for tag "+e)}function sn(r,t){let e=0;if((r[t.offset]&$o)===$o){let n=r[t.offset]&Hf,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Go(r,t){sn(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=yr(r,t);if(n===null)break;e.push(n)}return e}function zf(r,t){let e=sn(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Gf(r,t){let e=sn(r,t);return t.offset+=e,["oid-unimplemented"]}function $f(r,t){return t.offset++,null}function Zf(r,t){let e=sn(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return yr(o,{offset:0})}function Wf(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new ot;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Zo(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Wf(r.byteLength);return new ot(Uint8Array.from([t.byteLength|$o]),t)}function Rt(r){let t=new ot,e=parseInt("10000000",2);return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new ot(Uint8Array.from([2]),Zo(t),t)}function Ki(r){let t=Uint8Array.from([0]),e=new ot(t,r);return new ot(Uint8Array.from([3]),Zo(e),e)}function an(r){let t=new ot;for(let e of r)t.append(e);return new ot(Uint8Array.from([48]),Zo(t),t)}var br=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},cn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Fi={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new cn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var be=Fi;async function Vi(r){let t=await be.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Yf(t);return{privateKey:e[0],publicKey:e[1]}}async function qi(r,t){let e=await be.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await be.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Hi(r,t,e){let n=await be.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return be.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Yf(r){if(r.privateKey==null||r.publicKey==null)throw new vt("Private and public key are required");return Promise.all([be.get().subtle.exportKey("jwk",r.privateKey),be.get().subtle.exportKey("jwk",r.publicKey)])}function zi(r){if(r.kty!=="RSA")throw new vt("invalid key type");if(r.n==null)throw new vt("invalid key modulus");return H(r.n,"base64url").length*8}var We=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=xr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return ft.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:mt(this.raw,t.raw)}verify(t,e){return Hi(this._key,e,t)}},wr=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=xr.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:mt(this.raw,t.raw)}sign(t){return qi(this._key,t)}};var Wo=8192,Yo=18,jf=1062,Xf=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Gi(r){let t=yr(r);return{n:K(t[1],"base64url"),e:K(t[2],"base64url"),d:K(t[3],"base64url"),p:K(t[4],"base64url"),q:K(t[5],"base64url"),dp:K(t[6],"base64url"),dq:K(t[7],"base64url"),qi:K(t[8],"base64url"),kty:"RSA"}}function Qf(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new vt("JWK was missing components");return an([Rt(Uint8Array.from([0])),Rt(H(r.n,"base64url")),Rt(H(r.e,"base64url")),Rt(H(r.d,"base64url")),Rt(H(r.p,"base64url")),Rt(H(r.q,"base64url")),Rt(H(r.dp,"base64url")),Rt(H(r.dq,"base64url")),Rt(H(r.qi,"base64url"))]).subarray()}function $i(r){let t=yr(r,{offset:0});return{kty:"RSA",n:K(t[1][0],"base64url"),e:K(t[1][1],"base64url")}}function jo(r){if(r.n==null||r.e==null)throw new vt("JWK was missing components");return an([Xf,Ki(an([Rt(H(r.n,"base64url")),Rt(H(r.e,"base64url"))]))]).subarray()}function Zi(r){let t=Gi(r);return Wi(t)}function Xo(r,t){if(r.byteLength>=jf)throw new Oe("Key size is too large");let e=$i(r);if(t==null){let n=Ze(Gt.encode({Type:at.RSA,Data:r}));t=Nt(Yo,n)}return new We(e,t)}function Wi(r){if(zi(r)>Wo)throw new vt("Key size is too large");let t=ji(r),e=Ze(Gt.encode({Type:at.RSA,Data:jo(t.publicKey)})),n=Nt(Yo,e);return new wr(t.privateKey,new We(t.publicKey,n))}async function Yi(r){if(r>Wo)throw new vt("Key size is too large");let t=await Vi(r),e=Ze(Gt.encode({Type:at.RSA,Data:jo(t.publicKey)})),n=Nt(Yo,e);return new wr(t.privateKey,new We(t.publicKey,n))}function ji(r){if(r==null)throw new vt("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var un=class extends He{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Js(t);let n=ur(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return qe(this),this.iHash.update(t),this}digestInto(t){qe(this),Ve(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Qo=(r,t,e)=>new un(r,t).update(e).digest();Qo.create=(r,t)=>new un(r,t);function Xi(r){r.lowS!==void 0&&Dt("lowS",r.lowS),r.prehash!==void 0&&Dt("prehash",r.prehash)}function Jf(r){let t=dr(r);zt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:tl,hexToBytes:el}=Gr,Jo=class extends Error{constructor(t=""){super(t)}},ne={Err:Jo,_tlv:{encode:(r,t)=>{let{Err:e}=ne;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Se(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Se(o.length/2|128):"";return Se(r)+s+o+t},decode(r,t){let{Err:e}=ne,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=ne;if(r<oe)throw new t("integer: negative integers are not allowed");let e=Se(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=ne;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return tl(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=ne,o=typeof r=="string"?el(r):r;Ge(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=ne,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},oe=BigInt(0),lt=BigInt(1),O0=BigInt(2),Qi=BigInt(3),k0=BigInt(4);function rl(r){let t=Jf(r),{Fp:e}=t,n=he(t.n,t.nBitLength),o=t.toBytes||((b,h,E)=>{let S=h.toAffine();return ee(Uint8Array.from([4]),e.toBytes(S.x),e.toBytes(S.y))}),s=t.fromBytes||(b=>{let h=b.subarray(1),E=e.fromBytes(h.subarray(0,e.BYTES)),S=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:E,y:S}});function i(b){let{a:h,b:E}=t,S=e.sqr(b),g=e.mul(S,b);return e.add(e.add(g,e.mul(b,h)),E)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(b){return fr(b,lt,t.n)}function a(b){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:S,n:g}=t;if(h&&typeof b!="bigint"){if(fe(b)&&(b=Jt(b)),typeof b!="string"||!h.includes(b.length))throw new Error("invalid private key");b=b.padStart(E*2,"0")}let A;try{A=typeof b=="bigint"?b:te(et("private key",b,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof b)}return S&&(A=W(A,g)),It("private key",A,lt,g),A}function f(b){if(!(b instanceof d))throw new Error("ProjectivePoint expected")}let u=Be((b,h)=>{let{px:E,py:S,pz:g}=b;if(e.eql(g,e.ONE))return{x:E,y:S};let A=b.is0();h==null&&(h=A?e.ONE:e.inv(g));let R=e.mul(E,h),C=e.mul(S,h),B=e.mul(g,h);if(A)return{x:e.ZERO,y:e.ZERO};if(!e.eql(B,e.ONE))throw new Error("invZ was invalid");return{x:R,y:C}}),l=Be(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=b.toAffine();if(!e.isValid(h)||!e.isValid(E))throw new Error("bad point: x or y not FE");let S=e.sqr(E),g=i(h);if(!e.eql(S,g))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,E,S){if(this.px=h,this.py=E,this.pz=S,h==null||!e.isValid(h))throw new Error("x required");if(E==null||!e.isValid(E))throw new Error("y required");if(S==null||!e.isValid(S))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:E,y:S}=h||{};if(!h||!e.isValid(E)||!e.isValid(S))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let g=A=>e.eql(A,e.ZERO);return g(E)&&g(S)?d.ZERO:new d(E,S,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=e.invertBatch(h.map(S=>S.pz));return h.map((S,g)=>S.toAffine(E[g])).map(d.fromAffine)}static fromHex(h){let E=d.fromAffine(s(et("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return d.BASE.multiply(a(h))}static msm(h,E){return Yr(d,n,h,E)}_setWindowSize(h){m.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:E,py:S,pz:g}=this,{px:A,py:R,pz:C}=h,B=e.eql(e.mul(E,C),e.mul(A,g)),P=e.eql(e.mul(S,C),e.mul(R,g));return B&&P}negate(){return new d(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:E}=t,S=e.mul(E,Qi),{px:g,py:A,pz:R}=this,C=e.ZERO,B=e.ZERO,P=e.ZERO,T=e.mul(g,g),Q=e.mul(A,A),q=e.mul(R,R),k=e.mul(g,A);return k=e.add(k,k),P=e.mul(g,R),P=e.add(P,P),C=e.mul(h,P),B=e.mul(S,q),B=e.add(C,B),C=e.sub(Q,B),B=e.add(Q,B),B=e.mul(C,B),C=e.mul(k,C),P=e.mul(S,P),q=e.mul(h,q),k=e.sub(T,q),k=e.mul(h,k),k=e.add(k,P),P=e.add(T,T),T=e.add(P,T),T=e.add(T,q),T=e.mul(T,k),B=e.add(B,T),q=e.mul(A,R),q=e.add(q,q),T=e.mul(q,k),C=e.sub(C,T),P=e.mul(q,Q),P=e.add(P,P),P=e.add(P,P),new d(C,B,P)}add(h){f(h);let{px:E,py:S,pz:g}=this,{px:A,py:R,pz:C}=h,B=e.ZERO,P=e.ZERO,T=e.ZERO,Q=t.a,q=e.mul(t.b,Qi),k=e.mul(E,A),st=e.mul(S,R),v=e.mul(g,C),L=e.add(E,S),x=e.add(A,R);L=e.mul(L,x),x=e.add(k,st),L=e.sub(L,x),x=e.add(E,g);let p=e.add(A,C);return x=e.mul(x,p),p=e.add(k,v),x=e.sub(x,p),p=e.add(S,g),B=e.add(R,C),p=e.mul(p,B),B=e.add(st,v),p=e.sub(p,B),T=e.mul(Q,x),B=e.mul(q,v),T=e.add(B,T),B=e.sub(st,T),T=e.add(st,T),P=e.mul(B,T),st=e.add(k,k),st=e.add(st,k),v=e.mul(Q,v),x=e.mul(q,x),st=e.add(st,v),v=e.sub(k,v),v=e.mul(Q,v),x=e.add(x,v),k=e.mul(st,x),P=e.add(P,k),k=e.mul(p,x),B=e.mul(L,B),B=e.sub(B,k),k=e.mul(L,st),T=e.mul(p,T),T=e.add(T,k),new d(B,P,T)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return m.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:E,n:S}=t;It("scalar",h,oe,S);let g=d.ZERO;if(h===oe)return g;if(this.is0()||h===lt)return this;if(!E||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:A,k1:R,k2neg:C,k2:B}=E.splitScalar(h),P=g,T=g,Q=this;for(;R>oe||B>oe;)R<&&(P=P.add(Q)),B<&&(T=T.add(Q)),Q=Q.double(),R>>=lt,B>>=lt;return A&&(P=P.negate()),C&&(T=T.negate()),T=new d(e.mul(T.px,E.beta),T.py,T.pz),P.add(T)}multiply(h){let{endo:E,n:S}=t;It("scalar",h,lt,S);let g,A;if(E){let{k1neg:R,k1:C,k2neg:B,k2:P}=E.splitScalar(h),{p:T,f:Q}=this.wNAF(C),{p:q,f:k}=this.wNAF(P);T=m.constTimeNegate(R,T),q=m.constTimeNegate(B,q),q=new d(e.mul(q.px,E.beta),q.py,q.pz),g=T.add(q),A=Q.add(k)}else{let{p:R,f:C}=this.wNAF(h);g=R,A=C}return d.normalizeZ([g,A])[0]}multiplyAndAddUnsafe(h,E,S){let g=d.BASE,A=(C,B)=>B===oe||B===lt||!C.equals(g)?C.multiplyUnsafe(B):C.multiply(B),R=A(this,E).add(A(h,S));return R.is0()?void 0:R}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=t;if(h===lt)return!0;if(E)return E(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=t;return h===lt?this:E?E(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Dt("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Dt("isCompressed",h),Jt(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,e.ONE),d.ZERO=new d(e.ZERO,e.ONE,e.ZERO);let y=t.nBitLength,m=Wr(d,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function nl(r){let t=dr(r);return zt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ji(r){let t=nl(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(v){return W(v,n)}function c(v){return $r(v,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=rl({...t,toBytes(v,L,x){let p=L.toAffine(),w=e.toBytes(p.x),I=ee;return Dt("isCompressed",x),x?I(Uint8Array.from([L.hasEvenY()?2:3]),w):I(Uint8Array.from([4]),w,e.toBytes(p.y))},fromBytes(v){let L=v.length,x=v[0],p=v.subarray(1);if(L===o&&(x===2||x===3)){let w=te(p);if(!fr(w,lt,e.ORDER))throw new Error("Point is not on curve");let I=u(w),_;try{_=e.sqrt(I)}catch(M){let U=M instanceof Error?": "+M.message:"";throw new Error("Point is not on curve"+U)}let N=(_<)===lt;return(x&1)===1!==N&&(_=e.neg(_)),{x:w,y:_}}else if(L===s&&x===4){let w=e.fromBytes(p.subarray(0,e.BYTES)),I=e.fromBytes(p.subarray(e.BYTES,2*e.BYTES));return{x:w,y:I}}else{let w=o,I=s;throw new Error("invalid Point, expected length of "+w+", or uncompressed "+I+", got "+L)}}}),d=v=>Jt(de(v,t.nByteLength));function y(v){let L=n>>lt;return v>L}function m(v){return y(v)?i(-v):v}let b=(v,L,x)=>te(v.slice(L,x));class h{constructor(L,x,p){this.r=L,this.s=x,this.recovery=p,this.assertValidity()}static fromCompact(L){let x=t.nByteLength;return L=et("compactSignature",L,x*2),new h(b(L,0,x),b(L,x,2*x))}static fromDER(L){let{r:x,s:p}=ne.toSig(et("DER",L));return new h(x,p)}assertValidity(){It("r",this.r,lt,n),It("s",this.s,lt,n)}addRecoveryBit(L){return new h(this.r,this.s,L)}recoverPublicKey(L){let{r:x,s:p,recovery:w}=this,I=C(et("msgHash",L));if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");let _=w===2||w===3?x+t.n:x;if(_>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let N=(w&1)===0?"02":"03",O=a.fromHex(N+d(_)),M=c(_),U=i(-I*M),Z=i(p*M),j=a.BASE.multiplyAndAddUnsafe(O,U,Z);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Ie(this.toDERHex())}toDERHex(){return ne.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ie(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let E={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let v=no(t.n);return di(t.randomBytes(v),t.n)},precompute(v=8,L=a.BASE){return L._setWindowSize(v),L.multiply(BigInt(3)),L}};function S(v,L=!0){return a.fromPrivateKey(v).toRawBytes(L)}function g(v){let L=fe(v),x=typeof v=="string",p=(L||x)&&v.length;return L?p===o||p===s:x?p===2*o||p===2*s:v instanceof a}function A(v,L,x=!0){if(g(v))throw new Error("first arg must be private key");if(!g(L))throw new Error("second arg must be public key");return a.fromHex(L).multiply(f(v)).toRawBytes(x)}let R=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let L=te(v),x=v.length*8-t.nBitLength;return x>0?L>>BigInt(x):L},C=t.bits2int_modN||function(v){return i(R(v))},B=lr(t.nBitLength);function P(v){return It("num < 2^"+t.nBitLength,v,oe,B),de(v,t.nByteLength)}function T(v,L,x=Q){if(["recovered","canonical"].some(ut=>ut in x))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:w}=t,{lowS:I,prehash:_,extraEntropy:N}=x;I==null&&(I=!0),v=et("msgHash",v),Xi(x),_&&(v=et("prehashed msgHash",p(v)));let O=C(v),M=f(L),U=[P(M),P(O)];if(N!=null&&N!==!1){let ut=N===!0?w(e.BYTES):N;U.push(et("extraEntropy",ut))}let Z=ee(...U),j=O;function ct(ut){let dt=R(ut);if(!l(dt))return;let pt=c(dt),St=a.BASE.multiply(dt).toAffine(),wt=i(St.x);if(wt===oe)return;let Ht=i(pt*i(j+wt*M));if(Ht===oe)return;let Wt=(St.x===wt?0:2)|Number(St.y<),or=Ht;return I&&y(Ht)&&(or=m(Ht),Wt^=1),new h(wt,or,Wt)}return{seed:Z,k2sig:ct}}let Q={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function k(v,L,x=Q){let{seed:p,k2sig:w}=T(v,L,x),I=t;return Jn(I.hash.outputLen,I.nByteLength,I.hmac)(p,w)}a.BASE._setWindowSize(8);function st(v,L,x,p=q){let w=v;L=et("msgHash",L),x=et("publicKey",x);let{lowS:I,prehash:_,format:N}=p;if(Xi(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(N!==void 0&&N!=="compact"&&N!=="der")throw new Error("format must be compact or der");let O=typeof w=="string"||fe(w),M=!O&&!N&&typeof w=="object"&&w!==null&&typeof w.r=="bigint"&&typeof w.s=="bigint";if(!O&&!M)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let U,Z;try{if(M&&(U=new h(w.r,w.s)),O){try{N!=="compact"&&(U=h.fromDER(w))}catch(Wt){if(!(Wt instanceof ne.Err))throw Wt}!U&&N!=="der"&&(U=h.fromCompact(w))}Z=a.fromHex(x)}catch{return!1}if(!U||I&&U.hasHighS())return!1;_&&(L=t.hash(L));let{r:j,s:ct}=U,ut=C(L),dt=c(ct),pt=i(ut*dt),St=i(j*dt),wt=a.BASE.multiplyAndAddUnsafe(Z,pt,St)?.toAffine();return wt?i(wt.x)===j:!1}return{CURVE:t,getPublicKey:S,getSharedSecret:A,sign:k,verify:st,ProjectivePoint:a,Signature:h,utils:E}}function ol(r){return{hash:r,hmac:(t,...e)=>Qo(r,t,$n(...e)),randomBytes:Vr}}function ta(r,t){let e=n=>Ji({...r,...ol(n)});return{...e(t),create:e}}var na=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ea=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),sl=BigInt(1),ts=BigInt(2),ra=(r,t)=>(r+t/ts)/t;function il(r){let t=na,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=tt(u,e,t)*u%t,d=tt(l,e,t)*u%t,y=tt(d,ts,t)*f%t,m=tt(y,o,t)*y%t,b=tt(m,s,t)*m%t,h=tt(b,c,t)*b%t,E=tt(h,a,t)*h%t,S=tt(E,c,t)*b%t,g=tt(S,e,t)*u%t,A=tt(g,i,t)*m%t,R=tt(A,n,t)*f%t,C=tt(R,ts,t);if(!es.eql(es.sqr(C),r))throw new Error("Cannot find square root");return C}var es=he(na,void 0,void 0,{sqrt:il}),Re=ta({a:BigInt(0),b:BigInt(7),Fp:es,n:ea,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ea,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-sl*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=ra(s*r,t),a=ra(-n*r,t),f=W(r-c*e-a*o,t),u=W(-c*n-a*s,t),l=f>i,d=u>i;if(l&&(f=t-f),d&&(u=t-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},Ze),$0=BigInt(0);var Z0=Re.ProjectivePoint;function oa(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function sa(r,t,e){let n=hr.digest(e instanceof Uint8Array?e:e.subarray());if(oa(n))return n.then(({digest:o})=>Re.verify(t,o,r)).catch(o=>{throw new br(String(o))});try{return Re.verify(t,n.digest,r)}catch(o){throw new br(String(o))}}var fn=class{type="secp256k1";raw;_key;constructor(t){this._key=aa(t),this.raw=ia(this._key)}toMultihash(){return Xt.digest(pe(this))}toCID(){return ft.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:mt(this.raw,t.raw)}verify(t,e){return sa(this._key,e,t)}};function rs(r){return new fn(r)}function ia(r){return Re.ProjectivePoint.fromHex(r).toRawBytes(!0)}function aa(r){try{return Re.ProjectivePoint.fromHex(r),r}catch(t){throw new Oe(String(t))}}function Ye(r,t){let{Type:e,Data:n}=Gt.decode(r),o=n??new Uint8Array;switch(e){case at.RSA:return Xo(o,t);case at.Ed25519:return fo(o);case at.secp256k1:return rs(o);default:throw new we}}function ca(r){let{Type:t,Data:e}=Gt.decode(r.digest),n=e??new Uint8Array;switch(t){case at.Ed25519:return fo(n);case at.secp256k1:return rs(n);default:throw new we}}function pe(r){return Gt.encode({Type:at[r.type],Data:r.raw})}var Er;(function(r){let t;r.codec=()=>(t==null&&(t=Ft((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.publicKey!=null&&e.publicKey.byteLength>0&&(n.uint32(10),n.bytes(e.publicKey)),e.payloadType!=null&&e.payloadType.byteLength>0&&(n.uint32(18),n.bytes(e.payloadType)),e.payload!=null&&e.payload.byteLength>0&&(n.uint32(26),n.bytes(e.payload)),e.signature!=null&&e.signature.byteLength>0&&(n.uint32(42),n.bytes(e.signature)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={publicKey:ht(0),payloadType:ht(0),payload:ht(0),signature:ht(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.publicKey=e.bytes();break}case 2:{s.payloadType=e.bytes();break}case 3:{s.payload=e.bytes();break}case 5:{s.signature=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Kt(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(Er||(Er={}));var ln=class extends Error{constructor(t="Invalid signature"){super(t),this.name="InvalidSignatureError"}};var $t=class r{static createFromProtobuf=async t=>{let e=Er.decode(t),n=Ye(e.publicKey);return new r({publicKey:n,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};static seal=async(t,e)=>{if(e==null)throw new Error("Missing private key");let n=t.domain,o=t.codec,s=t.marshal(),i=ua(n,o,s),c=await e.sign(i.subarray());return new r({publicKey:e.publicKey,payloadType:o,payload:s,signature:c})};static openAndCertify=async(t,e)=>{let n=await r.createFromProtobuf(t);if(!await n.validate(e))throw new ln("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(t){let{publicKey:e,payloadType:n,payload:o,signature:s}=t;this.publicKey=e,this.payloadType=n,this.payload=o,this.signature=s}marshal(){return this.marshaled==null&&(this.marshaled=Er.encode({publicKey:pe(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return mt(this.marshal(),t.marshal())}async validate(t){let e=ua(t,this.payloadType,this.payload);return this.publicKey.verify(e.subarray(),this.signature)}},ua=(r,t,e)=>{let n=H(r),o=Ct(n.byteLength),s=Ct(t.length),i=Ct(e.length);return new ot(o,n,s,t,i,e)};var fa=Symbol.for("nodejs.util.inspect.custom"),al=114,vr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Dn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ft.createV1(al,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return mt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return mt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[fa](){return`PeerId(${this.toString()})`}},Sr=class extends vr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ir=class extends vr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ar=class extends vr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},cl=2336,Br=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Xt.digest(H(this.url))}[fa](){return`PeerId(${this.url})`}[Dn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ft.createV1(cl,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=K(t)),t.toString()===this.toString())}};var ul=114,la=2336;function da(r){if(r.type==="Ed25519")return new Ir({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Ar({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Sr({multihash:r.toCID().multihash,publicKey:r});throw new we}function ns(r){if(ll(r))return new Sr({multihash:r});if(fl(r))try{let t=ca(r);if(t.type==="Ed25519")return new Ir({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ar({multihash:r,publicKey:t})}catch{let e=K(r.digest);return new Br(new URL(e))}throw new Dr("Supplied PeerID Multihash is invalid")}function dn(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==ul&&r.code!==la)throw new Ur("Supplied PeerID CID is invalid");if(r.code===la){let t=K(r.multihash.digest);return new Br(new URL(t))}return ns(r.multihash)}function fl(r){return r.code===Xt.code}function ll(r){return r.code===hr.code}function ha(r,t){let e=(n,o)=>n.toString().localeCompare(o.toString());return r.length!==t.length?!1:(t.sort(e),r.sort(e).every((n,o)=>t[o].equals(n)))}var hn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(s*=t,s+=u,s>f||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var pa=45,dl=15,je=new hn;function pn(r){if(!(r.length>dl))return je.new(r).parseWith(()=>je.readIPv4Addr())}function mn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>pa))return je.new(r).parseWith(()=>je.readIPv6Addr())}function _e(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>pa)return;let e=je.new(r).parseWith(()=>je.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function ma(r,t,e){let n=0;for(let o of r)if(!(n<t)){if(n>e)break;if(o!==255)return!1;n++}return!0}function ga(r,t,e,n){let o=0;for(let s of r)if(!(o<e)){if(o>n)break;if(s!==t[o])return!1;o++}return!0}function os(r){switch(r.length){case Ne:return r.join(".");case Ue:{let t=[];for(let e=0;e<r.length;e++)e%2===0&&t.push(r[e].toString(16).padStart(2,"0")+r[e+1].toString(16).padStart(2,"0"));return t.join(":")}default:throw new Error("Invalid ip length")}}function ya(r){let t=0;for(let[e,n]of r.entries()){if(n===255){t+=8;continue}for(;(n&128)!=0;)t++,n=n<<1;if((n&128)!=0)return-1;for(let o=e+1;o<r.length;o++)if(r[o]!=0)return-1;break}return t}function ba(r){let t="0x";for(let e of r)t+=(e>>4).toString(16)+(e&15).toString(16);return t}var Ne=4,Ue=16,hg=parseInt("0xFFFF",16),hl=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Tr(r,t){t.length===Ue&&r.length===Ne&&ma(t,0,11)&&(t=t.slice(12)),t.length===Ne&&r.length===Ue&&ga(r,hl,0,11)&&(r=r.slice(12));let e=r.length;if(e!=t.length)throw new Error("Failed to mask ip");let n=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=r[o]&t[o];return n}function xa(r,t){if(typeof t=="string"&&(t=_e(t)),t==null)throw new Error("Invalid ip");if(t.length!==r.network.length)return!1;for(let e=0;e<t.length;e++)if((r.network[e]&r.mask[e])!==(t[e]&r.mask[e]))return!1;return!0}function ss(r){let[t,e]=r.split("/");if(!t||!e)throw new Error("Failed to parse given CIDR: "+r);let n=Ne,o=pn(t);if(o==null&&(n=Ue,o=mn(t),o==null))throw new Error("Failed to parse given CIDR: "+r);let s=parseInt(e,10);if(Number.isNaN(s)||String(s).length!==e.length||s<0||s>n*8)throw new Error("Failed to parse given CIDR: "+r);let i=is(s,8*n);return{network:Tr(o,i),mask:i}}function is(r,t){if(t!==8*Ne&&t!==8*Ue)throw new Error("Invalid CIDR mask");if(r<0||r>t)throw new Error("Invalid CIDR mask");let e=t/8,n=new Uint8Array(e);for(let o=0;o<e;o++){if(r>=8){n[o]=255,r-=8;continue}n[o]=255-(255>>r),r=0}return n}var Xe=class{constructor(t,e){if(e==null)({network:this.network,mask:this.mask}=ss(t));else{let n=_e(t);if(n==null)throw new Error("Failed to parse network");e=String(e);let o=parseInt(e,10);if(Number.isNaN(o)||String(o).length!==e.length||o<0||o>n.length*8){let s=_e(e);if(s==null)throw new Error("Failed to parse mask");this.mask=s}else this.mask=is(o,8*n.length);this.network=Tr(n,this.mask)}}contains(t){return xa({network:this.network,mask:this.mask},t)}toString(){let t=ya(this.mask),e=t!==-1?String(t):ba(this.mask);return os(this.network)+"/"+e}};function wa(r,t){return new Xe(r).contains(t)}function Qe(r){return!!pn(r)}function Je(r){return!!mn(r)}function gn(r){return!!_e(r)}var Ea=Qe,pl=Je,as=function(r){let t=0;if(r=r.toString().trim(),Ea(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(pl(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ea(e[n]),i;s&&(i=as(e[n]),e[n]=K(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,K(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},va=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var tr={},cs={},gl=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];gl.forEach(r=>{let t=yl(...r);cs[t.code]=t,tr[t.name]=t});function yl(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function z(r){if(typeof r=="number"){if(cs[r]!=null)return cs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(tr[r]!=null)return tr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var $g=z("ip4"),Zg=z("ip6"),Wg=z("ipcidr");function ds(r,t){switch(z(r).code){case 4:case 41:return xl(t);case 42:return ls(t);case 43:return K(t,"base10");case 6:case 273:case 33:case 132:return Aa(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ls(t);case 421:return Sl(t);case 444:return Ia(t);case 445:return Ia(t);case 466:return vl(t);case 481:return globalThis.encodeURIComponent(ls(t));default:return K(t,"base16")}}function hs(r,t){switch(z(r).code){case 4:return Sa(t);case 41:return Sa(t);case 42:return fs(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return ps(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fs(t);case 421:return wl(t);case 444:return Il(t);case 445:return Al(t);case 466:return El(t);case 481:return fs(globalThis.decodeURIComponent(t));default:return H(t,"base16")}}var us=Object.values(pr).map(r=>r.decoder),bl=function(){let r=us[0].or(us[1]);return us.slice(2).forEach(t=>r=r.or(t)),r}();function Sa(r){if(!gn(r))throw new Error("invalid ip address");return as(r)}function xl(r){let t=va(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!gn(t))throw new Error("invalid ip address");return t}function ps(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Aa(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function fs(r){let t=H(r),e=Uint8Array.from(Ct(t.length));return Pt([e,t],e.length+t.length)}function ls(r){let t=re(r);if(r=r.slice(yt(t)),r.length!==t)throw new Error("inconsistent lengths");return K(r)}function wl(r){let t;r[0]==="Q"||r[0]==="1"?t=Ee(X.decode(`z${r}`)).bytes:t=ft.parse(r).multihash.bytes;let e=Uint8Array.from(Ct(t.length));return Pt([e,t],e.length+t.length)}function El(r){let t=bl.decode(r),e=Uint8Array.from(Ct(t.length));return Pt([e,t],e.length+t.length)}function vl(r){let t=re(r),e=r.slice(yt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+K(e,"base64url")}function Sl(r){let t=re(r),e=r.slice(yt(t));if(e.length!==t)throw new Error("inconsistent lengths");return K(e,"base58btc")}function Il(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=jt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ps(n);return Pt([e,o],e.length+o.length)}function Al(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=jt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ps(n);return Pt([e,o],e.length+o.length)}function Ia(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=K(t,"base32"),o=Aa(e);return`${n}:${o}`}function Ba(r){r=ms(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=z(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw new yn("invalid address: "+r);if(c.path===!0){n=ms(o.slice(s).join("/")),t.push([c.code,hs(c.code,n)]),e.push([c.code,n]);break}let a=hs(c.code,o[s]);t.push([c.code,a]),e.push([c.code,ds(c.code,a)])}return{string:Ta(e),bytes:bn(t),tuples:t,stringTuples:e,path:n}}function gs(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=re(r,o),i=yt(s),c=z(s),a=Bl(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw new yn("Invalid address Uint8Array: "+K(r,"base16"));t.push([s,f]);let u=ds(s,f);if(e.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Ta(e),tuples:t,stringTuples:e,path:n}}function Ta(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ms(t.join("/"))}function bn(r){return Pt(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(Ct(e.code));return t.length>1&&t[1]!=null&&(n=Pt([n,t[1]])),n}))}function Bl(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=re(t instanceof Uint8Array?t:Uint8Array.from(t));return e+yt(e)}}function ms(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var yn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Tl=Symbol.for("nodejs.util.inspect.custom"),bs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ll=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],ys=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},xn=class r{bytes;#e;#t;#r;#n;[bs]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=gs(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ba(t)}else if(Pa(t))e=gs(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=z("tcp"),c=z("udp"),a=z("ip4"),f=z("ip6"),u=z("dns6"),l=z("ip6zone");for(let[y,m]of this.stringTuples())y===l.code&&(s=`%${m??""}`),Ll.includes(y)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${m??""}${s}`,t=y===u.code?6:4),(y===i.code||y===c.code)&&(e=z(y).name==="tcp"?"tcp":"udp",o=parseInt(m??"")),(y===a.code||y===f.code)&&(e=z(y).name==="tcp"?"tcp":"udp",n=`${m??""}${s}`,t=y===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},z(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>z(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(bn(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===tr.p2p.code&&t.push([n,o]),n===tr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?K(X.decode(`z${n}`),"base58btc"):K(ft.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return mt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=La.get(e.name);if(n==null)throw new ys(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Zt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Tl](){return`Multiaddr(${this.#e})`}};var La=new Map;function Pa(r){return!!r?.[bs]}function Zt(r){return new xn(r)}var Ca="libp2p-peer-record",Ra=Uint8Array.from([3,1]);var Lr;(function(r){let t;(function(n){let o;n.codec=()=>(o==null&&(o=Ft((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.multiaddr!=null&&s.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(s.multiaddr)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let a={multiaddr:ht(0)},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{a.multiaddr=s.bytes();break}default:{s.skipType(u&7);break}}}return a})),o),n.encode=s=>Kt(s,n.codec()),n.decode=(s,i)=>Mt(s,n.codec(),i)})(t=r.AddressInfo||(r.AddressInfo={}));let e;r.codec=()=>(e==null&&(e=Ft((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.peerId!=null&&n.peerId.byteLength>0&&(o.uint32(10),o.bytes(n.peerId)),n.seq!=null&&n.seq!==0n&&(o.uint32(16),o.uint64(n.seq)),n.addresses!=null)for(let i of n.addresses)o.uint32(26),r.AddressInfo.codec().encode(i,o);s.lengthDelimited!==!1&&o.ldelim()},(n,o,s={})=>{let i={peerId:ht(0),seq:0n,addresses:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:{i.peerId=n.bytes();break}case 2:{i.seq=n.uint64();break}case 3:{if(s.limits?.addresses!=null&&i.addresses.length===s.limits.addresses)throw new Ce('Decode error - map field "addresses" had too many elements');i.addresses.push(r.AddressInfo.codec().decode(n,n.uint32(),{limits:s.limits?.addresses$}));break}default:{n.skipType(a&7);break}}}return i})),e),r.encode=n=>Kt(n,r.codec()),r.decode=(n,o)=>Mt(n,r.codec(),o)})(Lr||(Lr={}));var Vt=class r{static createFromProtobuf=t=>{let e=Lr.decode(t),n=ns(Ee(e.peerId)),o=(e.addresses??[]).map(i=>Zt(i.multiaddr)),s=e.seq;return new r({peerId:n,multiaddrs:o,seqNumber:s})};static DOMAIN=Ca;static CODEC=Ra;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(t){let{peerId:e,multiaddrs:n,seqNumber:o}=t;this.peerId=e,this.multiaddrs=n??[],this.seqNumber=o??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=Lr.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof r)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!ha(this.multiaddrs,t.multiaddrs))}};function Pl(r){return r[Symbol.asyncIterator]!=null}function Cl(r){if(Pl(r))return(async()=>{for await(let t of r);})();for(let t of r);}var _a=Cl;function qt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var wn=globalThis.CustomEvent??Event;async function*xs(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered??!1,o=new EventTarget,s=[],i=qt(),c=qt(),a=!1,f,u=!1;o.addEventListener("task-complete",()=>{c.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(s.length===e&&(i=qt(),await i.promise),u)break;let b={done:!1};s.push(b),m().then(h=>{b.done=!0,b.ok=!0,b.value=h,o.dispatchEvent(new wn("task-complete"))},h=>{b.done=!0,b.err=h,o.dispatchEvent(new wn("task-complete"))})}a=!0,o.dispatchEvent(new wn("task-complete"))}catch(m){f=m,o.dispatchEvent(new wn("task-complete"))}});function l(){return n?s[0]?.done:!!s.find(m=>m.done)}function*d(){for(;s.length>0&&s[0].done;){let m=s[0];if(s.shift(),m.ok)yield m.value;else throw u=!0,i.resolve(),m.err;i.resolve()}}function*y(){for(;l();)for(let m=0;m<s.length;m++)if(s[m].done){let b=s[m];if(s.splice(m,1),m--,b.ok)yield b.value;else throw u=!0,i.resolve(),b.err;i.resolve()}}for(;;){if(l()||(c=qt(),await c.promise),f!=null)throw f;if(n?yield*d():yield*y(),a&&s.length===0)break}}var En=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Na(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new En(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new En(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var ws=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=qt(),this.haveNext=qt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=qt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=qt(),await Na(this.readNext.promise,e?.signal,e)}};function Ua(){return new ws}var vn=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Es=class extends Error{code;constructor(t,e){super(t),this.code=e}},vs=class extends Es{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Da(r,t){let e=Ua();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let c of i)await e.push(c);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new ot;return{read:async(i,c)=>{c?.signal?.throwIfAborted();let a,f=new Promise((u,l)=>{a=()=>{l(new vs("Read aborted"))},c?.signal?.addEventListener("abort",a)});try{if(i==null){let{done:l,value:d}=await Promise.race([n.next(),f]);return l===!0?new ot:d}for(;o.byteLength<i;){let{value:l,done:d}=await Promise.race([n.next(),f]);if(d===!0)throw new vn("unexpected end of input");o.append(l)}let u=o.sublist(0,i);return o.consume(i),u}finally{a!=null&&c?.signal?.removeEventListener("abort",a)}},write:async(i,c)=>{c?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,c):await e.push(i.subarray(),c)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var Sn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},In=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},An=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Oa(r,t={}){let e=Da(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=yt(t.maxDataLength));let n=t?.lengthDecoder??re,o=t?.lengthEncoder??Ct;return{read:async i=>{let c=-1,a=new ot;for(;;){a.append(await e.read(1,i));try{c=n(a)}catch(f){if(f instanceof RangeError)continue;throw f}if(c<0)throw new Sn("Invalid message length");if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new An("message length length too long");if(c>-1)break}if(t?.maxDataLength!=null&&c>t.maxDataLength)throw new In("message length too long");return e.read(c,i)},write:async(i,c)=>{await e.write(new ot(o(i.byteLength),i),c)},writeV:async(i,c)=>{let a=new ot(...i.flatMap(f=>[o(f.byteLength),f]));await e.write(a,c)},unwrap:()=>e.unwrap()}}function er(r,t){let e=Oa(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(c=>s.encode(c)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var ka="0.1.0",Ma="id",Ka="id/push",Fa="1.0.0",Va="1.0.0";var xe;(function(r){let t;r.codec=()=>(t==null&&(t=Ft((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.protocolVersion!=null&&(n.uint32(42),n.string(e.protocolVersion)),e.agentVersion!=null&&(n.uint32(50),n.string(e.agentVersion)),e.publicKey!=null&&(n.uint32(10),n.bytes(e.publicKey)),e.listenAddrs!=null)for(let s of e.listenAddrs)n.uint32(18),n.bytes(s);if(e.observedAddr!=null&&(n.uint32(34),n.bytes(e.observedAddr)),e.protocols!=null)for(let s of e.protocols)n.uint32(26),n.string(s);e.signedPeerRecord!=null&&(n.uint32(66),n.bytes(e.signedPeerRecord)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={listenAddrs:[],protocols:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 5:{s.protocolVersion=e.string();break}case 6:{s.agentVersion=e.string();break}case 1:{s.publicKey=e.bytes();break}case 2:{if(o.limits?.listenAddrs!=null&&s.listenAddrs.length===o.limits.listenAddrs)throw new Ce('Decode error - map field "listenAddrs" had too many elements');s.listenAddrs.push(e.bytes());break}case 4:{s.observedAddr=e.bytes();break}case 3:{if(o.limits?.protocols!=null&&s.protocols.length===o.limits.protocols)throw new Ce('Decode error - map field "protocols" had too many elements');s.protocols.push(e.string());break}case 8:{s.signedPeerRecord=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Kt(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(xe||(xe={}));var Tt={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function qa(r){if(r!=null&&r.length>0)try{return Zt(r)}catch{}}function Nl(r,t){return t??r.userAgent}async function Bn(r,t,e,n,o){if(e("received identify from %p",n.remotePeer),o==null)throw new _t("message was null or undefined");let s={};if(o.listenAddrs.length>0&&(s.addresses=o.listenAddrs.map(a=>({isCertified:!1,multiaddr:Zt(a)}))),o.protocols.length>0&&(s.protocols=o.protocols),o.publicKey!=null){let a=Ye(o.publicKey);if(!da(a).equals(n.remotePeer))throw new _t("public key did not match remote PeerId");s.publicKey=a}let i;if(o.signedPeerRecord!=null){e.trace("received signedPeerRecord from %p",n.remotePeer);let a=o.signedPeerRecord,f=await $t.openAndCertify(a,Vt.DOMAIN),u=Vt.createFromProtobuf(f.payload),l=dn(f.publicKey.toCID());if(!u.peerId.equals(l))throw new _t("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(u.peerId))throw new _t("signing key does not match remote PeerId");let d;try{d=await r.get(u.peerId)}catch(y){if(y.name!=="NotFoundError")throw y}if(d!=null&&(s.metadata=d.metadata,d.peerRecordEnvelope!=null)){let y=await $t.createFromProtobuf(d.peerRecordEnvelope),m=Vt.createFromProtobuf(y.payload);m.seqNumber>=u.seqNumber&&(e("sequence number was lower or equal to existing sequence number - stored: %d received: %d",m.seqNumber,u.seqNumber),u=m,a=d.peerRecordEnvelope)}s.peerRecordEnvelope=a,s.addresses=u.multiaddrs.map(y=>({isCertified:!0,multiaddr:y})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else e("%p did not send a signed peer record",n.remotePeer);if(e.trace("patching %p with",n.remotePeer,s),await r.patch(n.remotePeer,s),o.agentVersion!=null||o.protocolVersion!=null){let a={};o.agentVersion!=null&&(a.AgentVersion=H(o.agentVersion)),o.protocolVersion!=null&&(a.ProtocolVersion=H(o.protocolVersion)),e.trace("merging %p metadata",n.remotePeer,a),await r.merge(n.remotePeer,{metadata:a})}let c={peerId:n.remotePeer,protocolVersion:o.protocolVersion,agentVersion:o.agentVersion,publicKey:o.publicKey,listenAddrs:o.listenAddrs.map(a=>Zt(a)),observedAddr:o.observedAddr==null?void 0:Zt(o.observedAddr),protocols:o.protocols,signedPeerRecord:i,connection:n};return t.safeDispatchEvent("peer:identify",{detail:c}),c}var rr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(t,e){this.protocol=e.protocol,this.started=!1,this.peerId=t.peerId,this.privateKey=t.privateKey,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.events=t.events,this.log=e.log,this.timeout=e.timeout??Tt.timeout,this.maxInboundStreams=e.maxInboundStreams??Tt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Tt.maxOutboundStreams,this.maxMessageSize=e.maxMessageSize??Tt.maxMessageSize,this.maxObservedAddresses=e.maxObservedAddresses??Tt.maxObservedAddresses,this.runOnLimitedConnection=e.runOnLimitedConnection??Tt.runOnLimitedConnection,this.host={protocolVersion:`${e.protocolPrefix??Tt.protocolPrefix}/${ka}`,agentVersion:Nl(t.nodeInfo,e.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:H(this.host.agentVersion),ProtocolVersion:H(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,t=>{this.handleProtocol(t).catch(e=>{this.log.error(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Tn=class extends rr{connectionManager;concurrency;constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Tt.protocolPrefix}/${Ka}/${Va}`,log:t.logger.forComponent("libp2p:identify-push")}),this.connectionManager=t.connectionManager,this.concurrency=e.concurrency??Tt.concurrency,(e.runOnSelfUpdate??Tt.runOnSelfUpdate)&&t.events.addEventListener("self:peer:update",n=>{this.push().catch(o=>{this.log.error(o)})})}[kr]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let t=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),e=new Vt({peerId:this.peerId,multiaddrs:t}),n=await $t.seal(e,this.privateKey),o=this.registrar.getProtocols(),s=await this.peerStore.get(this.peerId),i=K(s.metadata.get("AgentVersion")??H(this.host.agentVersion)),c=K(s.metadata.get("ProtocolVersion")??H(this.host.protocolVersion)),a=this;async function*f(){for(let u of a.connectionManager.getConnections())(await a.peerStore.get(u.remotePeer)).protocols.includes(a.protocol)&&(yield async()=>{let d,y=AbortSignal.timeout(a.timeout);try{d=await u.newStream(a.protocol,{signal:y,runOnLimitedConnection:a.runOnLimitedConnection}),await er(d,{maxDataLength:a.maxMessageSize}).pb(xe).write({listenAddrs:t.map(b=>b.bytes),signedPeerRecord:n.marshal(),protocols:o,agentVersion:i,protocolVersion:c},{signal:y}),await d.close({signal:y})}catch(m){a.log.error("could not push identify update to peer",m),d?.abort(m)}})}await _a(xs(f(),{concurrency:this.concurrency}))}async handleProtocol(t){let{connection:e,stream:n}=t;try{if(this.peerId.equals(e.remotePeer))throw new Error("received push from ourselves?");let o={signal:AbortSignal.timeout(this.timeout)},i=await er(n,{maxDataLength:this.maxMessageSize}).pb(xe).read(o);await n.close(o),await Bn(this.peerStore,this.events,this.log,e,i)}catch(o){this.log.error("received invalid message",o),n.abort(o);return}this.log.trace("handled push from %p",e.remotePeer)}};var Dl=41;function Ha(r){try{let[[t,e]]=r.stringTuples();if(e==null)return!1;if(t===Dl)return wa("2000::/3",e)}catch{}return!1}var Ga=yc(za(),1),Ol=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],kl=Ol.map(r=>new Ga.Netmask(r));function Ss(r){for(let t of kl)if(t.contains(r))return!0;return!1}function Ml(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Kl(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Ss(o)}function Fl(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Vl(r){let t=r.split(":"),e=t[t.length-1];return Ss(e)}function ql(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function $a(r){return Qe(r)?Ss(r):Ml(r)?Kl(r):Fl(r)?Vl(r):Je(r)?ql(r):void 0}function Za(r){try{let[[t]]=r.stringTuples();return t===4||t===41}catch{}return!1}function Wa(r){try{if(!Za(r))return!1;let[[,t]]=r.stringTuples();return t==null?!1:$a(t)??!1}catch{}return!0}var Hl=r=>r.toString().split("/").slice(1),nr=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),F=r=>({match:t=>nr(e=>e===r).match(t),pattern:r}),De=()=>({match:r=>nr(t=>typeof t=="string").match(r),pattern:"{string}"}),Cr=()=>({match:r=>nr(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),Y=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{X.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Rr=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{To.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),G=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),xt=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),V=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function rt(...r){function t(o){let s=Hl(o);for(let i of r){let c=i.match(s);if(c===!1)return!1;s=c}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var Pn=V(F("dns4"),De()),Cn=V(F("dns6"),De()),Rn=V(F("dnsaddr"),De()),As=V(F("dns"),De()),Ob=rt(Pn,G(Y())),kb=rt(Cn,G(Y())),Mb=rt(Rn,G(Y())),Kb=rt(xt(As,Rn,Pn,Cn),G(Y())),Ya=V(F("ip4"),nr(Qe)),ja=V(F("ip6"),nr(Je)),Bs=xt(Ya,ja),se=xt(Bs,As,Pn,Cn,Rn),Xa=rt(xt(Bs,V(xt(As,Rn,Pn,Cn),G(Y())))),Fb=rt(Ya),Vb=rt(ja),qb=rt(Bs),Ts=V(se,F("tcp"),Cr()),_r=V(se,F("udp"),Cr()),Qa=rt(V(Ts,G(Y()))),Hb=rt(_r),Ls=V(_r,F("quic"),G(Y())),_n=V(_r,F("quic-v1"),G(Y())),zl=xt(Ls,_n),zb=rt(Ls),Gb=rt(_n),Is=xt(se,Ts,_r,Ls,_n),Ja=xt(V(Is,F("ws"),G(Y()))),$b=rt(Ja),tc=xt(V(Is,F("wss"),G(Y())),V(Is,F("tls"),G(V(F("sni"),De())),F("ws"),G(Y()))),Zb=rt(tc),ec=V(_r,F("webrtc-direct"),G(Rr()),G(Rr()),G(Y())),Wb=rt(ec),rc=V(_n,F("webtransport"),G(Rr()),G(Rr()),G(Y())),Yb=rt(rc),Ln=xt(Ja,tc,V(Ts,G(Y())),V(zl,G(Y())),V(se,G(Y())),ec,rc,Y()),jb=rt(Ln),Gl=V(Ln,F("p2p-circuit"),Y()),Xb=rt(Gl),$l=xt(V(Ln,F("p2p-circuit"),F("webrtc"),G(Y())),V(Ln,F("webrtc"),G(Y())),V(F("webrtc"),G(Y()))),Qb=rt($l),Zl=xt(V(se,F("tcp"),Cr(),F("http"),G(Y())),V(se,F("http"),G(Y()))),Jb=rt(Zl),Wl=xt(V(se,F("tcp"),xt(V(F("443"),F("http")),V(Cr(),F("https"))),G(Y())),V(se,F("tls"),F("http"),G(Y())),V(se,F("https"),G(Y()))),tx=rt(Wl),Yl=xt(V(F("memory"),De(),G(Y()))),ex=rt(Yl);var jl=41,Nn=class extends rr{constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Tt.protocolPrefix}/${Ma}/${Fa}`,log:t.logger.forComponent("libp2p:identify")}),(e.runOnConnectionOpen??Tt.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{let o=n.detail;this.identify(o).catch(s=>{s.name!==Or.name&&this.log.error("error during identify trigged by connection:open",s)})})}[kr]=["@libp2p/identify"];async _identify(t,e={}){let n;if(e.signal==null){let o=AbortSignal.timeout(this.timeout);e={...e,signal:o}}try{n=await t.newStream(this.protocol,{...e,runOnLimitedConnection:this.runOnLimitedConnection});let s=await er(n,{maxDataLength:this.maxMessageSize}).pb(xe).read(e);return await n.close(e),s}catch(o){throw n?.abort(o),o}}async identify(t,e={}){let n=await this._identify(t,e),{publicKey:o,protocols:s,observedAddr:i}=n;if(o==null)throw new _t("public key was missing from identify message");let c=Ye(o),a=dn(c.toCID());if(!t.remotePeer.equals(a))throw new _t("identified peer does not match the expected peer");if(this.peerId.equals(a))throw new _t("identified peer is our own peer id?");return this.maybeAddObservedAddress(i),this.log("identify completed for peer %p and protocols %o",a,s),Bn(this.peerStore,this.events,this.log,t,n)}maybeAddObservedAddress(t){let e=qa(t);if(e==null)return;if(this.log.trace("our observed address was %a",e),Wa(e)){this.log.trace("our observed address was private");return}if(e.stringTuples()[0][0]===jl&&!Ha(e)){this.log.trace("our observed address was IPv6 but not a global unicast address");return}Qa.exactMatch(e)||(this.log.trace("storing the observed address"),this.addressManager.addObservedAddr(e))}async handleProtocol(t){let{connection:e,stream:n}=t,o=AbortSignal.timeout(this.timeout);try{let s=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),c=s.peerRecordEnvelope;if(i.length>0&&c==null){let u=new Vt({peerId:this.peerId,multiaddrs:i});c=(await $t.seal(u,this.privateKey)).marshal().subarray()}let a=e.remoteAddr.bytes;Xa.matches(e.remoteAddr)||(a=void 0),await er(n).pb(xe).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:pe(this.privateKey.publicKey),listenAddrs:i.map(u=>u.bytes),signedPeerRecord:c,observedAddr:a,protocols:s.protocols},{signal:o}),await n.close({signal:o})}catch(s){this.log.error("could not respond to identify request",s),n.abort(s)}}};function Xl(r={}){return t=>new Nn(t,r)}function Ql(r={}){return t=>new Tn(t,r)}return bc(Jl);})();
|
|
2
|
+
"use strict";var Libp2PIdentify=(()=>{var fc=Object.create;var Nr=Object.defineProperty;var lc=Object.getOwnPropertyDescriptor;var dc=Object.getOwnPropertyNames;var hc=Object.getPrototypeOf,pc=Object.prototype.hasOwnProperty;var mc=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),St=(r,t)=>{for(var e in t)Nr(r,e,{get:t[e],enumerable:!0})},Os=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dc(t))!pc.call(r,o)&&o!==e&&Nr(r,o,{get:()=>t[o],enumerable:!(n=lc(t,o))||n.enumerable});return r};var yc=(r,t,e)=>(e=r!=null?fc(hc(r)):{},Os(t||!r||!r.__esModule?Nr(e,"default",{value:r,enumerable:!0}):e,r)),gc=r=>Os(Nr({},"__esModule",{value:!0}),r);var Za=mc(Dr=>{(function(){var r,t,e,n,o,s,i,c;c=function(a){var f,u,l,d;return f=(a&255<<24)>>>24,u=(a&255<<16)>>>16,l=(a&65280)>>>8,d=a&255,[f,u,l,d].join(".")},i=function(a){var f,u,l,d,b,m;for(f=[],l=d=0;d<=3&&a.length!==0;l=++d){if(l>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}m=t(a),b=m[0],u=m[1],a=a.substring(u),f.push(b)}if(a.length!==0)throw new Error("Invalid IP");switch(f.length){case 1:if(f[0]>4294967295)throw new Error("Invalid IP");return f[0]>>>0;case 2:if(f[0]>255||f[1]>16777215)throw new Error("Invalid IP");return(f[0]<<24|f[1])>>>0;case 3:if(f[0]>255||f[1]>255||f[2]>65535)throw new Error("Invalid IP");return(f[0]<<24|f[1]<<16|f[2])>>>0;case 4:if(f[0]>255||f[1]>255||f[2]>255||f[3]>255)throw new Error("Invalid IP");return(f[0]<<24|f[1]<<16|f[2]<<8|f[3])>>>0;default:throw new Error("Invalid IP")}},e=function(a){return a.charCodeAt(0)},n=e("0"),s=e("a"),o=e("A"),t=function(a){var f,u,l,d,b;for(d=0,f=10,u="9",l=0,a.length>1&&a[l]==="0"&&(a[l+1]==="x"||a[l+1]==="X"?(l+=2,f=16):"0"<=a[l+1]&&a[l+1]<="9"&&(l++,f=8,u="7")),b=l;l<a.length;){if("0"<=a[l]&&a[l]<=u)d=d*f+(e(a[l])-n)>>>0;else if(f===16)if("a"<=a[l]&&a[l]<="f")d=d*f+(10+e(a[l])-s)>>>0;else if("A"<=a[l]&&a[l]<="F")d=d*f+(10+e(a[l])-o)>>>0;else break;else break;if(d>4294967295)throw new Error("too large");l++}if(l===b)throw new Error("empty octet");return[d,l]},r=function(){function a(f,u){var l,d,b,m;if(typeof f!="string")throw new Error("Missing `net' parameter");if(u||(m=f.split("/",2),f=m[0],u=m[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=i(u)}catch(g){throw l=g,new Error("Invalid mask: "+u)}for(d=b=32;b>=0;d=--b)if(this.maskLong===4294967295<<32-d>>>0){this.bitmask=d;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(f)&this.maskLong)>>>0}catch(g){throw l=g,new Error("Invalid net address: "+f)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return a.prototype.contains=function(f){return typeof f=="string"&&(f.indexOf("/")>0||f.split(".").length!==4)&&(f=new a(f)),f instanceof a?this.contains(f.base)&&this.contains(f.broadcast||f.last):(i(f)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(f){return f==null&&(f=1),new a(c(this.netLong+this.size*f),this.mask)},a.prototype.forEach=function(f){var u,l,d;for(d=i(this.first),l=i(this.last),u=0;d<=l;)f(c(d),d,u),u++,d++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),Dr.ip2long=i,Dr.long2ip=c,Dr.Netmask=r}).call(Dr)});var Ql={};St(Ql,{identify:()=>Xl,identifyPush:()=>Jl});var Dn=Symbol.for("@libp2p/peer-id");var ft=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ne=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Kr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},kr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}},Mr=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},Ut=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var xe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Fr=Symbol.for("@libp2p/service-capabilities"),nd=Symbol.for("@libp2p/service-dependencies");var Kn={};St(Kn,{base58btc:()=>X,base58flickr:()=>Ac});var Bd=new Uint8Array(0);function Ns(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Yt(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 Ks(r){return new TextEncoder().encode(r)}function ks(r){return new TextDecoder().decode(r)}function bc(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var g=0,h=0,w=0,S=m.length;w!==S&&m[w]===0;)w++,g++;for(var y=(S-w)*u+1>>>0,I=new Uint8Array(y);w!==S;){for(var D=m[w],_=0,P=y-1;(D!==0||_<h)&&P!==-1;P--,_++)D+=256*I[P]>>>0,I[P]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");h=_,w++}for(var C=y-h;C!==y&&I[C]===0;)C++;for(var L=a.repeat(g);C<y;++C)L+=r.charAt(I[C]);return L}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var g=0;if(m[g]!==" "){for(var h=0,w=0;m[g]===a;)h++,g++;for(var S=(m.length-g)*f+1>>>0,y=new Uint8Array(S);m[g];){var I=e[m.charCodeAt(g)];if(I===255)return;for(var D=0,_=S-1;(I!==0||D<w)&&_!==-1;_--,D++)I+=c*y[_]>>>0,y[_]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");w=D,g++}if(m[g]!==" "){for(var P=S-w;P!==S&&y[P]===0;)P++;for(var C=new Uint8Array(h+(S-P)),L=h;P!==S;)C[L++]=y[P++];return C}}}function b(m){var g=d(m);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:b}}var xc=bc,wc=xc,Fs=wc;var Rn=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Un=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Vs(this,t)}},On=class{decoders;constructor(t){this.decoders=t}or(t){return Vs(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Vs(r,t){return new On({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Nn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Rn(t,e,n),this.decoder=new Un(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ke({name:r,prefix:t,encode:e,decode:n}){return new Nn(r,t,e,n)}function ie({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Fs(e,r);return Ke({prefix:t,name:r,encode:n,decode:s=>Yt(o(s))})}function Ec(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),c=0,a=0,f=0;for(let u=0;u<s;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,i[f++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function vc(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function nt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ke({prefix:t,name:r,encode(o){return vc(o,n,e)},decode(o){return Ec(o,n,e,r)}})}var X=ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ac=ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kn={};St(kn,{base32:()=>Xt,base32hex:()=>Pc,base32hexpad:()=>Lc,base32hexpadupper:()=>Tc,base32hexupper:()=>Cc,base32pad:()=>Ic,base32padupper:()=>Bc,base32upper:()=>Sc,base32z:()=>_c});var Xt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sc=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ic=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bc=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Pc=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Cc=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lc=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tc=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_c=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mn={};St(Mn,{base36:()=>ir,base36upper:()=>Dc});var ir=ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Dc=ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Rc=zs,qs=128,Uc=127,Oc=~Uc,Nc=Math.pow(2,31);function zs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Nc;)t[e++]=r&255|qs,r/=128;for(;r&Oc;)t[e++]=r&255|qs,r>>>=7;return t[e]=r|0,zs.bytes=e-n+1,t}var Kc=Fn,kc=128,Hs=127;function Fn(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Fn.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Hs)<<o:(i&Hs)*Math.pow(2,o),o+=7}while(i>=kc);return Fn.bytes=s-n,e}var Mc=Math.pow(2,7),Fc=Math.pow(2,14),Vc=Math.pow(2,21),qc=Math.pow(2,28),Hc=Math.pow(2,35),zc=Math.pow(2,42),Gc=Math.pow(2,49),$c=Math.pow(2,56),Zc=Math.pow(2,63),jc=function(r){return r<Mc?1:r<Fc?2:r<Vc?3:r<qc?4:r<Hc?5:r<zc?6:r<Gc?7:r<$c?8:r<Zc?9:10},Wc={encode:Rc,decode:Kc,encodingLength:jc},Yc=Wc,ar=Yc;function cr(r,t=0){return[ar.decode(r,t),ar.decode.bytes]}function ke(r,t,e=0){return ar.encode(r,t,e),t}function Me(r){return ar.encodingLength(r)}function Ot(r,t){let e=t.byteLength,n=Me(r),o=n+Me(e),s=new Uint8Array(o+e);return ke(r,s,0),ke(e,s,n),s.set(t,o),new Fe(r,e,t,s)}function we(r){let t=Yt(r),[e,n]=cr(t),[o,s]=cr(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Fe(e,o,i,t)}function Gs(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ns(r.bytes,e.bytes)}}var Fe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function $s(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Jc(e,Vn(r),t??X.encoder);default:return Qc(e,Vn(r),t??Xt.encoder)}}var Zs=new WeakMap;function Vn(r){let t=Zs.get(r);if(t==null){let e=new Map;return Zs.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ur)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==tu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Ot(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Gs(t.multihash,n.multihash)}toString(t){return $s(this,t)}toJSON(){return{"/":$s(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??js(n,o,s.bytes))}else if(e[eu]===!0){let{version:n,multihash:o,code:s}=e,i=we(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ur)throw new Error(`Version 0 CID must use dag-pb (code: ${ur}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=js(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ur,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Yt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Fe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,d]=cr(t.subarray(e));return e+=d,l},o=n(),s=ur;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),f=e+a,u=f-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Xc(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vn(s).set(n,t),s}};function Xc(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case Xt.prefix:{let e=t??Xt;return[Xt.prefix,e.decode(r)]}case ir.prefix:{let e=t??ir;return[ir.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Jc(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Qc(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ur=112,tu=18;function js(r,t,e){let n=Me(r),o=n+Me(t),s=new Uint8Array(o+e.byteLength);return ke(r,s,0),ke(t,s,n),s.set(e,o),s}var eu=Symbol.for("@ipld/js-cid/CID");var qn={};St(qn,{identity:()=>Nt});var Ws=0,ru="identity",Ys=Yt;function nu(r){return Ot(Ws,Ys(r))}var Nt={code:Ws,name:ru,encode:Ys,digest:nu};function ht(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function yt(r=0){return new Uint8Array(r)}function It(r=0){return new Uint8Array(r)}function Lt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=It(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Js=Symbol.for("@achingbrain/uint8arraylist");function Xs(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function qr(r){return!!r?.[Js]}var st=class r{bufs;length;[Js]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(qr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(qr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Xs(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Xs(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(qr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Lt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Lt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!qr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let d=f;d>=0;d--){let b=this.get(l+d);if(n[d]!==b){u=Math.max(1,d-c[b]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=It(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=yt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=yt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=yt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=It(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=yt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=yt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=yt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=yt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=yt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ht(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Hn={};St(Hn,{base10:()=>ou});var ou=ie({prefix:"9",name:"base10",alphabet:"0123456789"});var zn={};St(zn,{base16:()=>su,base16upper:()=>iu});var su=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),iu=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Gn={};St(Gn,{base2:()=>au});var au=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $n={};St($n,{base256emoji:()=>du});var Qs=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}"),cu=Qs.reduce((r,t,e)=>(r[e]=t,r),[]),uu=Qs.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function fu(r){return r.reduce((t,e)=>(t+=cu[e],t),"")}function lu(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=uu[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var du=Ke({prefix:"\u{1F680}",name:"base256emoji",encode:fu,decode:lu});var jn={};St(jn,{base64:()=>hu,base64pad:()=>pu,base64url:()=>Zn,base64urlpad:()=>mu});var hu=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pu=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zn=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mu=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Wn={};St(Wn,{base8:()=>yu});var yu=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Yn={};St(Yn,{identity:()=>gu});var gu=Ke({prefix:"\0",name:"identity",encode:r=>ks(r),decode:r=>Ks(r)});var uh=new TextEncoder,fh=new TextDecoder;var Qn={};St(Qn,{sha256:()=>fr,sha512:()=>wu});function Jn({name:r,code:t,encode:e}){return new Xn(r,t,e)}var Xn=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Ot(this.code,e):e.then(n=>Ot(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ei(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var fr=Jn({name:"sha2-256",code:18,encode:ei("SHA-256")}),wu=Jn({name:"sha2-512",code:19,encode:ei("SHA-512")});var lr={...Yn,...Gn,...Wn,...Hn,...zn,...kn,...Mn,...Kn,...jn,...$n},vh={...Qn,...qn};function ni(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ri=ni("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),to=ni("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=It(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Eu={utf8:ri,"utf-8":ri,hex:lr.base16,latin1:to,ascii:to,binary:to,...lr},Hr=Eu;function M(r,t="utf8"){let e=Hr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function U(r,t="utf8"){let e=Hr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var vu=parseInt("11111",2),eo=parseInt("10000000",2),Au=parseInt("01111111",2),oi={0:dr,1:dr,2:Su,3:Pu,4:Cu,5:Bu,6:Iu,16:dr,22:dr,48:dr};function Jt(r,t={offset:0}){let e=r[t.offset]&vu;if(t.offset++,oi[e]!=null)return oi[e](r,t);throw new Error("No decoder for tag "+e)}function hr(r,t){let e=0;if((r[t.offset]&eo)===eo){let n=r[t.offset]&Au,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function dr(r,t){hr(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Jt(r,t);if(n===null)break;e.push(n)}return e}function Su(r,t){let e=hr(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Iu(r,t){let e=hr(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let f=r[t.offset];if(t.offset++,a.push(f&127),f<128){a.reverse();let u=0;for(let l=0;l<a.length;l++)u+=a[l]<<l*7;c+=`.${u}`,a=[]}}return c}function Bu(r,t){return t.offset++,null}function Pu(r,t){let e=hr(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Cu(r,t){let e=hr(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Lu(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new st;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function ro(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Lu(r.byteLength);return new st(Uint8Array.from([t.byteLength|eo]),t)}function Bt(r){let t=new st,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new st(Uint8Array.from([2]),ro(t),t)}function zr(r){let t=Uint8Array.from([0]),e=new st(t,r);return new st(Uint8Array.from([3]),ro(e),e)}function ce(r,t=48){let e=new st;for(let n of r)e.append(n);return new st(Uint8Array.from([t]),ro(e),e)}async function si(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Tu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),_u=Uint8Array.from([6,5,43,129,4,0,34]),Du=Uint8Array.from([6,5,43,129,4,0,35]),Ru={ext:!0,kty:"EC",crv:"P-256"},Uu={ext:!0,kty:"EC",crv:"P-384"},Ou={ext:!0,kty:"EC",crv:"P-521"},no=32,oo=48,so=66;function io(r){let t=Jt(r);return ii(t)}function ii(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===no*2+1)return n=U(t.subarray(e,e+no),"base64url"),o=U(t.subarray(e+no),"base64url"),new Ve({...Ru,key_ops:["verify"],x:n,y:o});if(t.byteLength===oo*2+1)return n=U(t.subarray(e,e+oo),"base64url"),o=U(t.subarray(e+oo),"base64url"),new Ve({...Uu,key_ops:["verify"],x:n,y:o});if(t.byteLength===so*2+1)return n=U(t.subarray(e,e+so),"base64url"),o=U(t.subarray(e+so),"base64url"),new Ve({...Ou,key_ops:["verify"],x:n,y:o});throw new ft(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ai(r){return ce([Bt(Uint8Array.from([1])),ce([Nu(r.crv)],160),ce([zr(new st(Uint8Array.from([4]),M(r.x??"","base64url"),M(r.y??"","base64url")))],161)]).subarray()}function Nu(r){if(r==="P-256")return Tu;if(r==="P-384")return _u;if(r==="P-521")return Du;throw new ft(`Invalid curve ${r}`)}var Ve=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ai(this.jwk)),this._raw}toMultihash(){return Nt.digest(zt(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}async verify(t,e){return si(this.jwk,e,t)}};function ci(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ku(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function qe(r,...t){if(!Ku(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function ui(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ci(r.outputLen),ci(r.blockLen)}function He(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function fi(r,t){qe(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Ee=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Gr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Kt(r,t){return r<<32-t|r>>>t}var np=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function li(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function pr(r){return typeof r=="string"&&(r=li(r)),qe(r),r}function ao(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];qe(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var ze=class{clone(){return this._cloneInto()}};function $r(r){let t=n=>r().update(pr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Zr(r=32){if(Ee&&typeof Ee.getRandomValues=="function")return Ee.getRandomValues(new Uint8Array(r));if(Ee&&typeof Ee.randomBytes=="function")return Uint8Array.from(Ee.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function ku(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),c=Number(e&s),a=n?4:0,f=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+f,c,n)}function di(r,t,e){return r&t^~r&e}function hi(r,t,e){return r&t^r&e^t&e}var Ge=class extends ze{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Gr(this.buffer)}update(t){He(this);let{view:e,buffer:n,blockLen:o}=this;t=pr(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Gr(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){He(this),fi(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;ku(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Gr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Mu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ue=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=new Uint32Array(64),co=class extends Ge{constructor(t=32){super(64,t,8,!1),this.A=ue[0]|0,this.B=ue[1]|0,this.C=ue[2]|0,this.D=ue[3]|0,this.E=ue[4]|0,this.F=ue[5]|0,this.G=ue[6]|0,this.H=ue[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let l=0;l<16;l++,e+=4)fe[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let d=fe[l-15],b=fe[l-2],m=Kt(d,7)^Kt(d,18)^d>>>3,g=Kt(b,17)^Kt(b,19)^b>>>10;fe[l]=g+fe[l-7]+m+fe[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Kt(c,6)^Kt(c,11)^Kt(c,25),b=u+d+di(c,a,f)+Mu[l]+fe[l]|0,g=(Kt(n,2)^Kt(n,13)^Kt(n,22))+hi(n,o,s)|0;u=f,f=a,a=c,c=i+b|0,i=s,s=o,o=n,n=b+g|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,a,f,u)}roundClean(){fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ve=$r(()=>new co);var jr=BigInt(4294967295),uo=BigInt(32);function pi(r,t=!1){return t?{h:Number(r&jr),l:Number(r>>uo&jr)}:{h:Number(r>>uo&jr)|0,l:Number(r&jr)|0}}function Fu(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=pi(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var Vu=(r,t)=>BigInt(r>>>0)<<uo|BigInt(t>>>0),qu=(r,t,e)=>r>>>e,Hu=(r,t,e)=>r<<32-e|t>>>e,zu=(r,t,e)=>r>>>e|t<<32-e,Gu=(r,t,e)=>r<<32-e|t>>>e,$u=(r,t,e)=>r<<64-e|t>>>e-32,Zu=(r,t,e)=>r>>>e-32|t<<64-e,ju=(r,t)=>t,Wu=(r,t)=>r,Yu=(r,t,e)=>r<<e|t>>>32-e,Xu=(r,t,e)=>t<<e|r>>>32-e,Ju=(r,t,e)=>t<<e-32|r>>>64-e,Qu=(r,t,e)=>r<<e-32|t>>>64-e;function tf(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ef=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),rf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,nf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),of=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,sf=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),af=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var cf={fromBig:pi,split:Fu,toBig:Vu,shrSH:qu,shrSL:Hu,rotrSH:zu,rotrSL:Gu,rotrBH:$u,rotrBL:Zu,rotr32H:ju,rotr32L:Wu,rotlSH:Yu,rotlSL:Xu,rotlBH:Ju,rotlBL:Qu,add:tf,add3L:ef,add3H:rf,add4L:nf,add4H:of,add5H:af,add5L:sf},O=cf;var[uf,ff]=O.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),le=new Uint32Array(80),de=new Uint32Array(80),fo=class extends Ge{constructor(t=64){super(128,t,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:d,Gh:b,Gl:m,Hh:g,Hl:h}=this;return[t,e,n,o,s,i,c,a,f,u,l,d,b,m,g,h]}set(t,e,n,o,s,i,c,a,f,u,l,d,b,m,g,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=b|0,this.Gl=m|0,this.Hh=g|0,this.Hl=h|0}process(t,e){for(let y=0;y<16;y++,e+=4)le[y]=t.getUint32(e),de[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let I=le[y-15]|0,D=de[y-15]|0,_=O.rotrSH(I,D,1)^O.rotrSH(I,D,8)^O.shrSH(I,D,7),P=O.rotrSL(I,D,1)^O.rotrSL(I,D,8)^O.shrSL(I,D,7),C=le[y-2]|0,L=de[y-2]|0,J=O.rotrSH(C,L,19)^O.rotrBH(C,L,61)^O.shrSH(C,L,6),$=O.rotrSL(C,L,19)^O.rotrBL(C,L,61)^O.shrSL(C,L,6),K=O.add4L(P,$,de[y-7],de[y-16]),ut=O.add4H(K,_,J,le[y-7],le[y-16]);le[y]=ut|0,de[y]=K|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:d,Fh:b,Fl:m,Gh:g,Gl:h,Hh:w,Hl:S}=this;for(let y=0;y<80;y++){let I=O.rotrSH(l,d,14)^O.rotrSH(l,d,18)^O.rotrBH(l,d,41),D=O.rotrSL(l,d,14)^O.rotrSL(l,d,18)^O.rotrBL(l,d,41),_=l&b^~l&g,P=d&m^~d&h,C=O.add5L(S,D,P,ff[y],de[y]),L=O.add5H(C,w,I,_,uf[y],le[y]),J=C|0,$=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),K=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),ut=n&s^n&c^s&c,v=o&i^o&a^i&a;w=g|0,S=h|0,g=b|0,h=m|0,b=l|0,m=d|0,{h:l,l:d}=O.add(f|0,u|0,L|0,J|0),f=c|0,u=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let B=O.add3L(J,K,v);n=O.add3H(B,L,$,ut),o=B|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=O.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=O.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=O.add(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:m}=O.add(this.Fh|0,this.Fl|0,b|0,m|0),{h:g,l:h}=O.add(this.Gh|0,this.Gl|0,g|0,h|0),{h:w,l:S}=O.add(this.Hh|0,this.Hl|0,w|0,S|0),this.set(n,o,s,i,c,a,f,u,l,d,b,m,g,h,w,S)}roundClean(){le.fill(0),de.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var lo=$r(()=>new fo);var yo=BigInt(0),mo=BigInt(1);function Ae(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function go(r){if(!Ae(r))throw new Error("Uint8Array expected")}function Gt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function mr(r){let t=r.toString(16);return t.length&1?"0"+t:t}function gi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?yo:BigInt("0x"+r)}var bi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",lf=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function he(r){if(go(r),bi)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=lf[r[e]];return t}var Qt={_0:48,_9:57,A:65,F:70,a:97,f:102};function mi(r){if(r>=Qt._0&&r<=Qt._9)return r-Qt._0;if(r>=Qt.A&&r<=Qt.F)return r-(Qt.A-10);if(r>=Qt.a&&r<=Qt.f)return r-(Qt.a-10)}function yr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(bi)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=mi(r.charCodeAt(s)),c=mi(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function te(r){return gi(he(r))}function Se(r){return go(r),gi(he(Uint8Array.from(r).reverse()))}function Ie(r,t){return yr(r.toString(16).padStart(t*2,"0"))}function $e(r,t){return Ie(r,t).reverse()}function rt(r,t,e){let n;if(typeof t=="string")try{n=yr(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Ae(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function pe(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];go(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var ho=r=>typeof r=="bigint"&&yo<=r;function Wr(r,t,e){return ho(r)&&ho(t)&&ho(e)&&t<=r&&r<e}function Tt(r,t,e,n){if(!Wr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function xi(r){let t;for(t=0;r>yo;r>>=mo,t+=1);return t}var Be=r=>(mo<<BigInt(r))-mo,po=r=>new Uint8Array(r),yi=r=>Uint8Array.from(r);function wi(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=po(r),o=po(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...l)=>e(o,n,...l),a=(l=po(0))=>{o=c(yi([0]),l),n=c(),l.length!==0&&(o=c(yi([1]),l),n=c())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<t;){n=c();let b=n.slice();d.push(b),l+=n.length}return pe(...d)};return(l,d)=>{i(),a(l);let b;for(;!(b=d(f()));)a();return i(),b}}var df={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Ae(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ee(r,t,e={}){let n=(o,s,i)=>{let c=df[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Ze(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var lt=BigInt(0),Q=BigInt(1),Pe=BigInt(2),hf=BigInt(3),bo=BigInt(4),Ei=BigInt(5),vi=BigInt(8),pf=BigInt(9),mf=BigInt(16);function Y(r,t){let e=r%t;return e>=lt?e:t+e}function yf(r,t,e){if(t<lt)throw new Error("invalid exponent, negatives unsupported");if(e<=lt)throw new Error("invalid modulus");if(e===Q)return lt;let n=Q;for(;t>lt;)t&Q&&(n=n*r%e),r=r*r%e,t>>=Q;return n}function tt(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function Yr(r,t){if(r===lt)throw new Error("invert: expected non-zero number");if(t<=lt)throw new Error("invert: expected positive modulus, got "+t);let e=Y(r,t),n=t,o=lt,s=Q,i=Q,c=lt;for(;e!==lt;){let f=n/e,u=n%e,l=o-i*f,d=s-c*f;n=e,e=u,o=i,s=c,i=l,c=d}if(n!==Q)throw new Error("invert: does not exist");return Y(o,t)}function gf(r){let t=(r-Q)/Pe,e,n,o;for(e=r-Q,n=0;e%Pe===lt;e/=Pe,n++);for(o=Pe;o<r&&yf(o,t,r)!==r-Q;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+Q)/bo;return function(a,f){let u=a.pow(f,i);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(e+Q)/Pe;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,s),d=c.pow(a,e);for(;!c.eql(d,c.ONE);){if(c.eql(d,c.ZERO))return c.ZERO;let b=1;for(let g=c.sqr(d);b<f&&!c.eql(g,c.ONE);b++)g=c.sqr(g);let m=c.pow(u,Q<<BigInt(f-b-1));u=c.sqr(m),l=c.mul(l,m),d=c.mul(d,u),f=b}return l}}function bf(r){if(r%bo===hf){let t=(r+Q)/bo;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%vi===Ei){let t=(r-Ei)/vi;return function(n,o){let s=n.mul(o,Pe),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,Pe),i),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%mf,gf(r)}var Ai=(r,t)=>(Y(r,t)&Q)===Q,xf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xo(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=xf.reduce((n,o)=>(n[o]="function",n),t);return ee(r,e)}function wf(r,t,e){if(e<lt)throw new Error("invalid exponent, negatives unsupported");if(e===lt)return r.ONE;if(e===Q)return t;let n=r.ONE,o=t;for(;e>lt;)e&Q&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Q;return n}function Ef(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function wo(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function me(r,t,e=!1,n={}){if(r<=lt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=wo(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Be(o),ZERO:lt,ONE:Q,create:a=>Y(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return lt<=a&&a<r},is0:a=>a===lt,isOdd:a=>(a&Q)===Q,neg:a=>Y(-a,r),eql:(a,f)=>a===f,sqr:a=>Y(a*a,r),add:(a,f)=>Y(a+f,r),sub:(a,f)=>Y(a-f,r),mul:(a,f)=>Y(a*f,r),pow:(a,f)=>wf(c,a,f),div:(a,f)=>Y(a*Yr(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>Yr(a,r),sqrt:n.sqrt||(a=>(i||(i=bf(r)),i(c,a))),invertBatch:a=>Ef(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?$e(a,s):Ie(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?Se(a):te(a)}});return Object.freeze(c)}function Si(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Eo(r){let t=Si(r);return t+Math.ceil(t/2)}function Ii(r,t,e=!1){let n=r.length,o=Si(t),s=Eo(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Se(r):te(r),c=Y(i,t-Q)+Q;return e?$e(c,o):Ie(c,o)}var Bi=BigInt(0),Bo=BigInt(1);function vo(r,t){let e=t.negate();return r?e:t}function Ci(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Ao(r,t){Ci(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Be(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Pi(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=Bo);let f=t*n,u=f+Math.abs(c)-1,l=c===0,d=c<0,b=t%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:d,isNegF:b,offsetF:f}}function vf(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Af(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var So=new WeakMap,Li=new WeakMap;function Io(r){return Li.get(r)||1}function Xr(r,t){return{constTimeNegate:vo,hasPrecomputes(e){return Io(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Bi;)n&Bo&&(o=o.add(s)),s=s.double(),n>>=Bo;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Ao(n,t),i=[],c=e,a=c;for(let f=0;f<o;f++){a=c,i.push(a);for(let u=1;u<s;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=Ao(e,t);for(let a=0;a<c.windows;a++){let{nextN:f,offset:u,isZero:l,isNeg:d,isNegF:b,offsetF:m}=Pi(o,a,c);o=f,l?i=i.add(vo(b,n[m])):s=s.add(vo(d,n[u]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Ao(e,t);for(let c=0;c<i.windows&&o!==Bi;c++){let{nextN:a,offset:f,isZero:u,isNeg:l}=Pi(o,c,i);if(o=a,!u){let d=n[f];s=s.add(l?d.negate():d)}}return s},getPrecomputes(e,n,o){let s=So.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&So.set(n,o(s))),s},wNAFCached(e,n,o){let s=Io(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Io(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Ci(n,t),Li.set(e,n),So.delete(e)}}}function Jr(r,t,e,n){if(vf(e,r),Af(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=xi(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=Be(i),a=new Array(Number(c)+1).fill(o),f=Math.floor((t.BITS-1)/i)*i,u=o;for(let l=f;l>=0;l-=i){a.fill(o);for(let b=0;b<n.length;b++){let m=n[b],g=Number(m>>BigInt(l)&c);a[g]=a[g].add(e[b])}let d=o;for(let b=a.length-1,m=o;b>0;b--)m=m.add(a[b]),d=d.add(m);if(u=u.add(d),l!==0)for(let b=0;b<i;b++)u=u.double()}return u}function gr(r){return xo(r.Fp),ee(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var $t=BigInt(0),vt=BigInt(1),Ti=BigInt(2),Sf=BigInt(8),If={zip215:!0};function Bf(r){let t=gr(r);return ee(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function _i(r){let t=Bf(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,f=Ti<<BigInt(c*8)-vt,u=e.create,l=me(t.n,t.nBitLength),d=t.uvRatio||((x,p)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(p))}}catch{return{isValid:!1,value:$t}}}),b=t.adjustScalarBytes||(x=>x),m=t.domain||((x,p,E)=>{if(Gt("phflag",E),p.length||E)throw new Error("Contexts/pre-hash are not supported");return x});function g(x,p,E=!1){let A=E?vt:$t;Tt("coordinate "+x,p,A,f)}function h(x){if(!(x instanceof y))throw new Error("ExtendedPoint expected")}let w=Ze((x,p)=>{let{ex:E,ey:A,ez:R}=x,N=x.is0();p==null&&(p=N?Sf:e.inv(R));let k=u(E*p),F=u(A*p),H=u(R*p);if(N)return{x:$t,y:vt};if(H!==vt)throw new Error("invZ was invalid");return{x:k,y:F}}),S=Ze(x=>{let{a:p,d:E}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:A,ey:R,ez:N,et:k}=x,F=u(A*A),H=u(R*R),j=u(N*N),at=u(j*j),ot=u(F*p),mt=u(j*u(ot+H)),At=u(at+u(E*u(F*H)));if(mt!==At)throw new Error("bad point: equation left != right (1)");let dt=u(A*R),gt=u(N*k);if(dt!==gt)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,E,A,R){g("x",p),g("y",E),g("z",A,!0),g("t",R),this.ex=p,this.ey=E,this.ez=A,this.et=R,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:E,y:A}=p||{};return g("x",E),g("y",A),new y(E,A,vt,u(E*A))}static normalizeZ(p){let E=e.invertBatch(p.map(A=>A.ez));return p.map((A,R)=>A.toAffine(E[R])).map(y.fromAffine)}static msm(p,E){return Jr(y,l,p,E)}_setWindowSize(p){_.setWindowSize(this,p)}assertValidity(){S(this)}equals(p){h(p);let{ex:E,ey:A,ez:R}=this,{ex:N,ey:k,ez:F}=p,H=u(E*F),j=u(N*R),at=u(A*F),ot=u(k*R);return H===j&&at===ot}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:E,ey:A,ez:R}=this,N=u(E*E),k=u(A*A),F=u(Ti*u(R*R)),H=u(p*N),j=E+A,at=u(u(j*j)-N-k),ot=H+k,mt=ot-F,At=H-k,dt=u(at*mt),gt=u(ot*At),Ct=u(at*At),Rt=u(mt*ot);return new y(dt,gt,Rt,Ct)}add(p){h(p);let{a:E,d:A}=t,{ex:R,ey:N,ez:k,et:F}=this,{ex:H,ey:j,ez:at,et:ot}=p,mt=u(R*H),At=u(N*j),dt=u(F*A*ot),gt=u(k*at),Ct=u((R+N)*(H+j)-mt-At),Rt=gt-dt,sr=gt+dt,Us=u(At-E*mt),ic=u(Ct*Rt),ac=u(sr*Us),cc=u(Ct*Us),uc=u(Rt*sr);return new y(ic,ac,uc,cc)}subtract(p){return this.add(p.negate())}wNAF(p){return _.wNAFCached(this,p,y.normalizeZ)}multiply(p){let E=p;Tt("scalar",E,vt,n);let{p:A,f:R}=this.wNAF(E);return y.normalizeZ([A,R])[0]}multiplyUnsafe(p,E=y.ZERO){let A=p;return Tt("scalar",A,$t,n),A===$t?D:this.is0()||A===vt?this:_.wNAFCachedUnsafe(this,A,y.normalizeZ,E)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return _.unsafeLadder(this,n).is0()}toAffine(p){return w(this,p)}clearCofactor(){let{h:p}=t;return p===vt?this:this.multiplyUnsafe(p)}static fromHex(p,E=!1){let{d:A,a:R}=t,N=e.BYTES;p=rt("pointHex",p,N),Gt("zip215",E);let k=p.slice(),F=p[N-1];k[N-1]=F&-129;let H=Se(k),j=E?f:e.ORDER;Tt("pointHex.y",H,$t,j);let at=u(H*H),ot=u(at-vt),mt=u(A*at-R),{isValid:At,value:dt}=d(ot,mt);if(!At)throw new Error("Point.fromHex: invalid y coordinate");let gt=(dt&vt)===vt,Ct=(F&128)!==0;if(!E&&dt===$t&&Ct)throw new Error("Point.fromHex: x=0 and x_0=1");return Ct!==gt&&(dt=u(-dt)),y.fromAffine({x:dt,y:H})}static fromPrivateKey(p){let{scalar:E}=L(p);return I.multiply(E)}toRawBytes(){let{x:p,y:E}=this.toAffine(),A=$e(E,e.BYTES);return A[A.length-1]|=p&vt?128:0,A}toHex(){return he(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,vt,u(t.Gx*t.Gy)),y.ZERO=new y($t,vt,vt,$t);let{BASE:I,ZERO:D}=y,_=Xr(y,c*8);function P(x){return Y(x,n)}function C(x){return P(Se(x))}function L(x){let p=e.BYTES;x=rt("private key",x,p);let E=rt("hashed private key",s(x),2*p),A=b(E.slice(0,p)),R=E.slice(p,2*p),N=C(A);return{head:A,prefix:R,scalar:N}}function J(x){let{head:p,prefix:E,scalar:A}=L(x),R=I.multiply(A),N=R.toRawBytes();return{head:p,prefix:E,scalar:A,point:R,pointBytes:N}}function $(x){return J(x).pointBytes}function K(x=new Uint8Array,...p){let E=pe(...p);return C(s(m(E,rt("context",x),!!o)))}function ut(x,p,E={}){x=rt("message",x),o&&(x=o(x));let{prefix:A,scalar:R,pointBytes:N}=J(p),k=K(E.context,A,x),F=I.multiply(k).toRawBytes(),H=K(E.context,F,N,x),j=P(k+H*R);Tt("signature.s",j,$t,n);let at=pe(F,$e(j,e.BYTES));return rt("result",at,e.BYTES*2)}let v=If;function B(x,p,E,A=v){let{context:R,zip215:N}=A,k=e.BYTES;x=rt("signature",x,2*k),p=rt("message",p),E=rt("publicKey",E,k),N!==void 0&&Gt("zip215",N),o&&(p=o(p));let F=Se(x.slice(k,2*k)),H,j,at;try{H=y.fromHex(E,N),j=y.fromHex(x.slice(0,k),N),at=I.multiplyUnsafe(F)}catch{return!1}if(!N&&H.isSmallOrder())return!1;let ot=K(R,j.toRawBytes(),H.toRawBytes(),p);return j.add(H.multiplyUnsafe(ot)).subtract(at).clearCofactor().equals(y.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:$,sign:ut,verify:B,ExtendedPoint:y,utils:{getExtendedPublicKey:J,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,p=y.BASE){return p._setWindowSize(x),p.multiply(BigInt(3)),p}}}}var Po=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Di=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),kp=BigInt(0),Pf=BigInt(1),Ri=BigInt(2),Mp=BigInt(3),Cf=BigInt(5),Lf=BigInt(8);function Tf(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Po,c=r*r%s*r%s,a=tt(c,Ri,s)*c%s,f=tt(a,Pf,s)*r%s,u=tt(f,Cf,s)*f%s,l=tt(u,t,s)*u%s,d=tt(l,e,s)*l%s,b=tt(d,n,s)*d%s,m=tt(b,o,s)*b%s,g=tt(m,o,s)*b%s,h=tt(g,t,s)*u%s;return{pow_p_5_8:tt(h,Ri,s)*r%s,b2:c}}function _f(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Df(r,t){let e=Po,n=Y(t*t*t,e),o=Y(n*n*t,e),s=Tf(r*o).pow_p_5_8,i=Y(r*n*s,e),c=Y(t*i*i,e),a=i,f=Y(i*Di,e),u=c===r,l=c===Y(-r,e),d=c===Y(-r*Di,e);return u&&(i=a),(l||d)&&(i=f),Ai(i,e)&&(i=Y(-i,e)),{isValid:u||l,value:i}}var Ui=me(Po,void 0,!0),Rf={a:Ui.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ui,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Lf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:lo,randomBytes:Zr,adjustScalarBytes:_f,uvRatio:Df},Oi=_i(Rf);var Qr=32;function Ni(r,t,e){return Oi.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var tn=class{type="Ed25519";raw;constructor(t){this.raw=Co(t,Qr)}toMultihash(){return Nt.digest(zt(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return Ni(this.raw,e,t)}};function Lo(r){return r=Co(r,Qr),new tn(r)}function Co(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ft(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Of=Math.pow(2,7),Nf=Math.pow(2,14),Kf=Math.pow(2,21),To=Math.pow(2,28),_o=Math.pow(2,35),Do=Math.pow(2,42),Ro=Math.pow(2,49),Z=128,bt=127;function xt(r){if(r<Of)return 1;if(r<Nf)return 2;if(r<Kf)return 3;if(r<To)return 4;if(r<_o)return 5;if(r<Do)return 6;if(r<Ro)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Uo(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|Z,r/=128;case 7:t[e++]=r&255|Z,r/=128;case 6:t[e++]=r&255|Z,r/=128;case 5:t[e++]=r&255|Z,r/=128;case 4:t[e++]=r&255|Z,r>>>=7;case 3:t[e++]=r&255|Z,r>>>=7;case 2:t[e++]=r&255|Z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function kf(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|Z),r/=128;case 7:t.set(e++,r&255|Z),r/=128;case 6:t.set(e++,r&255|Z),r/=128;case 5:t.set(e++,r&255|Z),r/=128;case 4:t.set(e++,r&255|Z),r>>>=7;case 3:t.set(e++,r&255|Z),r>>>=7;case 2:t.set(e++,r&255|Z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Oo(r,t){let e=r[t],n=0;if(n+=e&bt,e<Z||(e=r[t+1],n+=(e&bt)<<7,e<Z)||(e=r[t+2],n+=(e&bt)<<14,e<Z)||(e=r[t+3],n+=(e&bt)<<21,e<Z)||(e=r[t+4],n+=(e&bt)*To,e<Z)||(e=r[t+5],n+=(e&bt)*_o,e<Z)||(e=r[t+6],n+=(e&bt)*Do,e<Z)||(e=r[t+7],n+=(e&bt)*Ro,e<Z))return n;throw new RangeError("Could not decode varint")}function Mf(r,t){let e=r.get(t),n=0;if(n+=e&bt,e<Z||(e=r.get(t+1),n+=(e&bt)<<7,e<Z)||(e=r.get(t+2),n+=(e&bt)<<14,e<Z)||(e=r.get(t+3),n+=(e&bt)<<21,e<Z)||(e=r.get(t+4),n+=(e&bt)*To,e<Z)||(e=r.get(t+5),n+=(e&bt)*_o,e<Z)||(e=r.get(t+6),n+=(e&bt)*Do,e<Z)||(e=r.get(t+7),n+=(e&bt)*Ro,e<Z))return n;throw new RangeError("Could not decode varint")}function Dt(r,t,e=0){return t==null&&(t=It(xt(r))),t instanceof Uint8Array?Uo(r,t,e):kf(r,t,e)}function re(r,t=0){return r instanceof Uint8Array?Oo(r,t):Mf(r,t)}var No=new Float32Array([-0]),ye=new Uint8Array(No.buffer);function ki(r,t,e){No[0]=r,t[e]=ye[0],t[e+1]=ye[1],t[e+2]=ye[2],t[e+3]=ye[3]}function Mi(r,t){return ye[0]=r[t],ye[1]=r[t+1],ye[2]=r[t+2],ye[3]=r[t+3],No[0]}var Ko=new Float64Array([-0]),wt=new Uint8Array(Ko.buffer);function Fi(r,t,e){Ko[0]=r,t[e]=wt[0],t[e+1]=wt[1],t[e+2]=wt[2],t[e+3]=wt[3],t[e+4]=wt[4],t[e+5]=wt[5],t[e+6]=wt[6],t[e+7]=wt[7]}function Vi(r,t){return wt[0]=r[t],wt[1]=r[t+1],wt[2]=r[t+2],wt[3]=r[t+3],wt[4]=r[t+4],wt[5]=r[t+5],wt[6]=r[t+6],wt[7]=r[t+7],Ko[0]}var Ff=BigInt(Number.MAX_SAFE_INTEGER),Vf=BigInt(Number.MIN_SAFE_INTEGER),_t=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ce;if(t<Ff&&t>Vf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>qi&&(o=0n,++n>qi&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ce;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Ce}},Ce=new _t(0,0);Ce.toBigInt=function(){return 0n};Ce.zzEncode=Ce.zzDecode=function(){return this};Ce.length=function(){return 1};var qi=4294967296n;function Hi(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function zi(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function ko(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function kt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function rn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Mo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,kt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw kt(this,4);return rn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw kt(this,4);return rn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw kt(this,4);let t=Mi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw kt(this,4);let t=Vi(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw kt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return zi(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw kt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw kt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new _t(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw kt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw kt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw kt(this,8);let t=rn(this.buf,this.pos+=4),e=rn(this.buf,this.pos+=4);return new _t(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Oo(this.buf,this.pos);return this.pos+=xt(t),t}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 Fo(r){return new Mo(r instanceof Uint8Array?r:r.subarray())}function Mt(r,t,e){let n=Fo(r);return t.decode(n,void 0,e)}function Vo(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return It(i);o+i>t&&(n=It(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var Le=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function qo(){}var zo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},qf=Vo();function Hf(r){return globalThis.Buffer!=null?It(r):qf(r)}var xr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Le(qo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Le(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Go((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(nn,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(nn,e.length(),e)}uint64Number(t){return this._push(Uo,xt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=_t.fromBigInt(t).zzEncode();return this._push(nn,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(nn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ho,1,t?1:0)}fixed32(t){return this._push(br,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(br,4,e.lo)._push(br,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(br,4,e.lo)._push(br,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ki,4,t)}double(t){return this._push(Fi,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Ho,1,0):this.uint32(e)._push(Gf,e,t)}string(t){let e=Hi(t);return e!==0?this.uint32(e)._push(ko,e,t):this._push(Ho,1,0)}fork(){return this.states=new zo(this),this.head=this.tail=new Le(qo,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 Le(qo,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Hf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Ho(r,t,e){t[e]=r&255}function zf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Go=class extends Le{next;constructor(t,e){super(zf,t,e),this.next=void 0}};function nn(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function br(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Gf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(xr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push($f,t,r),this},xr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Zf,t,r),this});function $f(r,t,e){t.set(r,e)}function Zf(r,t,e){r.length<40?ko(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(M(r),e)}function $o(){return new xr}function Ft(r,t){let e=$o();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var je;(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"})(je||(je={}));function on(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Zo(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return on("enum",je.VARINT,e,n)}function Vt(r,t){return on("message",je.LENGTH_DELIMITED,r,t)}var Te=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var it;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(it||(it={}));var jo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(jo||(jo={}));(function(r){r.codec=()=>Zo(jo)})(it||(it={}));var Zt;(function(r){let t;r.codec=()=>(t==null&&(t=Vt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),it.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=it.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Ft(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(Zt||(Zt={}));var Wo;(function(r){let t;r.codec=()=>(t==null&&(t=Vt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),it.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.Type=it.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Ft(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(Wo||(Wo={}));var wr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},sn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Zi={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new sn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var ge=Zi;var vr={};St(vr,{MAX_RSA_KEY_SIZE:()=>Yo,generateRSAKeyPair:()=>Xi,jwkToJWKKeyPair:()=>Ji,jwkToPkcs1:()=>Xf,jwkToPkix:()=>ts,jwkToRSAPrivateKey:()=>os,pkcs1MessageToJwk:()=>Jo,pkcs1MessageToRSAPrivateKey:()=>es,pkcs1ToJwk:()=>Yf,pkcs1ToRSAPrivateKey:()=>Yi,pkixMessageToJwk:()=>Qo,pkixMessageToRSAPublicKey:()=>ns,pkixToJwk:()=>Jf,pkixToRSAPublicKey:()=>rs});var We=class{type="RSA";jwk;_raw;_multihash;constructor(t,e){this.jwk=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=vr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ct.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return Wi(this.jwk,e,t)}},Er=class{type="RSA";jwk;_raw;publicKey;constructor(t,e){this.jwk=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=vr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}sign(t){return ji(this.jwk,t)}};var Yo=8192,Xo=18,jf=1062,Wf=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Yf(r){let t=Jt(r);return Jo(t)}function Jo(r){return{n:U(r[1],"base64url"),e:U(r[2],"base64url"),d:U(r[3],"base64url"),p:U(r[4],"base64url"),q:U(r[5],"base64url"),dp:U(r[6],"base64url"),dq:U(r[7],"base64url"),qi:U(r[8],"base64url"),kty:"RSA"}}function Xf(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new ft("JWK was missing components");return ce([Bt(Uint8Array.from([0])),Bt(M(r.n,"base64url")),Bt(M(r.e,"base64url")),Bt(M(r.d,"base64url")),Bt(M(r.p,"base64url")),Bt(M(r.q,"base64url")),Bt(M(r.dp,"base64url")),Bt(M(r.dq,"base64url")),Bt(M(r.qi,"base64url"))]).subarray()}function Jf(r){let t=Jt(r,{offset:0});return Qo(t)}function Qo(r){let t=Jt(r[1],{offset:0});return{kty:"RSA",n:U(t[0],"base64url"),e:U(t[1],"base64url")}}function ts(r){if(r.n==null||r.e==null)throw new ft("JWK was missing components");return ce([Wf,zr(ce([Bt(M(r.n,"base64url")),Bt(M(r.e,"base64url"))]))]).subarray()}function Yi(r){let t=Jt(r);return es(t)}function es(r){let t=Jo(r);return os(t)}function rs(r,t){if(r.byteLength>=jf)throw new Ne("Key size is too large");let e=Jt(r,{offset:0});return ns(e,r,t)}function ns(r,t,e){let n=Qo(r);if(e==null){let o=ve(Zt.encode({Type:it.RSA,Data:t}));e=Ot(Xo,o)}return new We(n,e)}function os(r){if(ta(r)>Yo)throw new ft("Key size is too large");let t=Ji(r),e=ve(Zt.encode({Type:it.RSA,Data:ts(t.publicKey)})),n=Ot(Xo,e);return new Er(t.privateKey,new We(t.publicKey,n))}async function Xi(r){if(r>Yo)throw new ft("Key size is too large");let t=await Qi(r),e=ve(Zt.encode({Type:it.RSA,Data:ts(t.publicKey)})),n=Ot(Xo,e);return new Er(t.privateKey,new We(t.publicKey,n))}function Ji(r){if(r==null)throw new ft("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}async function Qi(r){let t=await ge.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Qf(t);return{privateKey:e[0],publicKey:e[1]}}async function ji(r,t){let e=await ge.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ge.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Wi(r,t,e){let n=await ge.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ge.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Qf(r){if(r.privateKey==null||r.publicKey==null)throw new ft("Private and public key are required");return Promise.all([ge.get().subtle.exportKey("jwk",r.privateKey),ge.get().subtle.exportKey("jwk",r.publicKey)])}function ta(r){if(r.kty!=="RSA")throw new ft("invalid key type");if(r.n==null)throw new ft("invalid key modulus");return M(r.n,"base64url").length*8}var an=class extends ze{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,ui(t);let n=pr(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return He(this),this.iHash.update(t),this}digestInto(t){He(this),qe(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ss=(r,t,e)=>new an(r,t).update(e).digest();ss.create=(r,t)=>new an(r,t);function ea(r){r.lowS!==void 0&&Gt("lowS",r.lowS),r.prehash!==void 0&&Gt("prehash",r.prehash)}function tl(r){let t=gr(r);ee(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var is=class extends Error{constructor(t=""){super(t)}},ne={Err:is,_tlv:{encode:(r,t)=>{let{Err:e}=ne;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=mr(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?mr(o.length/2|128):"";return mr(r)+s+o+t},decode(r,t){let{Err:e}=ne,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=ne;if(r<oe)throw new t("integer: negative integers are not allowed");let e=mr(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=ne;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return te(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=ne,o=rt("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=ne,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},oe=BigInt(0),pt=BigInt(1),lm=BigInt(2),ra=BigInt(3),dm=BigInt(4);function el(r){let t=tl(r),{Fp:e}=t,n=me(t.n,t.nBitLength),o=t.toBytes||((g,h,w)=>{let S=h.toAffine();return pe(Uint8Array.from([4]),e.toBytes(S.x),e.toBytes(S.y))}),s=t.fromBytes||(g=>{let h=g.subarray(1),w=e.fromBytes(h.subarray(0,e.BYTES)),S=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:w,y:S}});function i(g){let{a:h,b:w}=t,S=e.sqr(g),y=e.mul(S,g);return e.add(e.add(y,e.mul(g,h)),w)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return Wr(g,pt,t.n)}function a(g){let{allowedPrivateKeyLengths:h,nByteLength:w,wrapPrivateKey:S,n:y}=t;if(h&&typeof g!="bigint"){if(Ae(g)&&(g=he(g)),typeof g!="string"||!h.includes(g.length))throw new Error("invalid private key");g=g.padStart(w*2,"0")}let I;try{I=typeof g=="bigint"?g:te(rt("private key",g,w))}catch{throw new Error("invalid private key, expected hex or "+w+" bytes, got "+typeof g)}return S&&(I=Y(I,y)),Tt("private key",I,pt,y),I}function f(g){if(!(g instanceof d))throw new Error("ProjectivePoint expected")}let u=Ze((g,h)=>{let{px:w,py:S,pz:y}=g;if(e.eql(y,e.ONE))return{x:w,y:S};let I=g.is0();h==null&&(h=I?e.ONE:e.inv(y));let D=e.mul(w,h),_=e.mul(S,h),P=e.mul(y,h);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(P,e.ONE))throw new Error("invZ was invalid");return{x:D,y:_}}),l=Ze(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:h,y:w}=g.toAffine();if(!e.isValid(h)||!e.isValid(w))throw new Error("bad point: x or y not FE");let S=e.sqr(w),y=i(h);if(!e.eql(S,y))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,w,S){if(h==null||!e.isValid(h))throw new Error("x required");if(w==null||!e.isValid(w))throw new Error("y required");if(S==null||!e.isValid(S))throw new Error("z required");this.px=h,this.py=w,this.pz=S,Object.freeze(this)}static fromAffine(h){let{x:w,y:S}=h||{};if(!h||!e.isValid(w)||!e.isValid(S))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let y=I=>e.eql(I,e.ZERO);return y(w)&&y(S)?d.ZERO:new d(w,S,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let w=e.invertBatch(h.map(S=>S.pz));return h.map((S,y)=>S.toAffine(w[y])).map(d.fromAffine)}static fromHex(h){let w=d.fromAffine(s(rt("pointHex",h)));return w.assertValidity(),w}static fromPrivateKey(h){return d.BASE.multiply(a(h))}static msm(h,w){return Jr(d,n,h,w)}_setWindowSize(h){m.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:w,py:S,pz:y}=this,{px:I,py:D,pz:_}=h,P=e.eql(e.mul(w,_),e.mul(I,y)),C=e.eql(e.mul(S,_),e.mul(D,y));return P&&C}negate(){return new d(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:w}=t,S=e.mul(w,ra),{px:y,py:I,pz:D}=this,_=e.ZERO,P=e.ZERO,C=e.ZERO,L=e.mul(y,y),J=e.mul(I,I),$=e.mul(D,D),K=e.mul(y,I);return K=e.add(K,K),C=e.mul(y,D),C=e.add(C,C),_=e.mul(h,C),P=e.mul(S,$),P=e.add(_,P),_=e.sub(J,P),P=e.add(J,P),P=e.mul(_,P),_=e.mul(K,_),C=e.mul(S,C),$=e.mul(h,$),K=e.sub(L,$),K=e.mul(h,K),K=e.add(K,C),C=e.add(L,L),L=e.add(C,L),L=e.add(L,$),L=e.mul(L,K),P=e.add(P,L),$=e.mul(I,D),$=e.add($,$),L=e.mul($,K),_=e.sub(_,L),C=e.mul($,J),C=e.add(C,C),C=e.add(C,C),new d(_,P,C)}add(h){f(h);let{px:w,py:S,pz:y}=this,{px:I,py:D,pz:_}=h,P=e.ZERO,C=e.ZERO,L=e.ZERO,J=t.a,$=e.mul(t.b,ra),K=e.mul(w,I),ut=e.mul(S,D),v=e.mul(y,_),B=e.add(w,S),T=e.add(I,D);B=e.mul(B,T),T=e.add(K,ut),B=e.sub(B,T),T=e.add(w,y);let x=e.add(I,_);return T=e.mul(T,x),x=e.add(K,v),T=e.sub(T,x),x=e.add(S,y),P=e.add(D,_),x=e.mul(x,P),P=e.add(ut,v),x=e.sub(x,P),L=e.mul(J,T),P=e.mul($,v),L=e.add(P,L),P=e.sub(ut,L),L=e.add(ut,L),C=e.mul(P,L),ut=e.add(K,K),ut=e.add(ut,K),v=e.mul(J,v),T=e.mul($,T),ut=e.add(ut,v),v=e.sub(K,v),v=e.mul(J,v),T=e.add(T,v),K=e.mul(ut,T),C=e.add(C,K),K=e.mul(x,T),P=e.mul(B,P),P=e.sub(P,K),K=e.mul(B,ut),L=e.mul(x,L),L=e.add(L,K),new d(P,C,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return m.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:w,n:S}=t;Tt("scalar",h,oe,S);let y=d.ZERO;if(h===oe)return y;if(this.is0()||h===pt)return this;if(!w||m.hasPrecomputes(this))return m.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:I,k1:D,k2neg:_,k2:P}=w.splitScalar(h),C=y,L=y,J=this;for(;D>oe||P>oe;)D&pt&&(C=C.add(J)),P&pt&&(L=L.add(J)),J=J.double(),D>>=pt,P>>=pt;return I&&(C=C.negate()),_&&(L=L.negate()),L=new d(e.mul(L.px,w.beta),L.py,L.pz),C.add(L)}multiply(h){let{endo:w,n:S}=t;Tt("scalar",h,pt,S);let y,I;if(w){let{k1neg:D,k1:_,k2neg:P,k2:C}=w.splitScalar(h),{p:L,f:J}=this.wNAF(_),{p:$,f:K}=this.wNAF(C);L=m.constTimeNegate(D,L),$=m.constTimeNegate(P,$),$=new d(e.mul($.px,w.beta),$.py,$.pz),y=L.add($),I=J.add(K)}else{let{p:D,f:_}=this.wNAF(h);y=D,I=_}return d.normalizeZ([y,I])[0]}multiplyAndAddUnsafe(h,w,S){let y=d.BASE,I=(_,P)=>P===oe||P===pt||!_.equals(y)?_.multiplyUnsafe(P):_.multiply(P),D=I(this,w).add(I(h,S));return D.is0()?void 0:D}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:w}=t;if(h===pt)return!0;if(w)return w(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:w}=t;return h===pt?this:w?w(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Gt("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Gt("isCompressed",h),he(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,e.ONE),d.ZERO=new d(e.ZERO,e.ONE,e.ZERO);let b=t.nBitLength,m=Xr(d,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function rl(r){let t=gr(r);return ee(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function na(r){let t=rl(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(v){return Y(v,n)}function c(v){return Yr(v,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=el({...t,toBytes(v,B,T){let x=B.toAffine(),p=e.toBytes(x.x),E=pe;return Gt("isCompressed",T),T?E(Uint8Array.from([B.hasEvenY()?2:3]),p):E(Uint8Array.from([4]),p,e.toBytes(x.y))},fromBytes(v){let B=v.length,T=v[0],x=v.subarray(1);if(B===o&&(T===2||T===3)){let p=te(x);if(!Wr(p,pt,e.ORDER))throw new Error("Point is not on curve");let E=u(p),A;try{A=e.sqrt(E)}catch(k){let F=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+F)}let R=(A&pt)===pt;return(T&1)===1!==R&&(A=e.neg(A)),{x:p,y:A}}else if(B===s&&T===4){let p=e.fromBytes(x.subarray(0,e.BYTES)),E=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:p,y:E}}else{let p=o,E=s;throw new Error("invalid Point, expected length of "+p+", or uncompressed "+E+", got "+B)}}}),d=v=>he(Ie(v,t.nByteLength));function b(v){let B=n>>pt;return v>B}function m(v){return b(v)?i(-v):v}let g=(v,B,T)=>te(v.slice(B,T));class h{constructor(B,T,x){Tt("r",B,pt,n),Tt("s",T,pt,n),this.r=B,this.s=T,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(B){let T=t.nByteLength;return B=rt("compactSignature",B,T*2),new h(g(B,0,T),g(B,T,2*T))}static fromDER(B){let{r:T,s:x}=ne.toSig(rt("DER",B));return new h(T,x)}assertValidity(){}addRecoveryBit(B){return new h(this.r,this.s,B)}recoverPublicKey(B){let{r:T,s:x,recovery:p}=this,E=_(rt("msgHash",B));if(p==null||![0,1,2,3].includes(p))throw new Error("recovery id invalid");let A=p===2||p===3?T+t.n:T;if(A>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(p&1)===0?"02":"03",N=a.fromHex(R+d(A)),k=c(A),F=i(-E*k),H=i(x*k),j=a.BASE.multiplyAndAddUnsafe(N,F,H);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return yr(this.toDERHex())}toDERHex(){return ne.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return yr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let w={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let v=Eo(t.n);return Ii(t.randomBytes(v),t.n)},precompute(v=8,B=a.BASE){return B._setWindowSize(v),B.multiply(BigInt(3)),B}};function S(v,B=!0){return a.fromPrivateKey(v).toRawBytes(B)}function y(v){let B=Ae(v),T=typeof v=="string",x=(B||T)&&v.length;return B?x===o||x===s:T?x===2*o||x===2*s:v instanceof a}function I(v,B,T=!0){if(y(v))throw new Error("first arg must be private key");if(!y(B))throw new Error("second arg must be public key");return a.fromHex(B).multiply(f(v)).toRawBytes(T)}let D=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let B=te(v),T=v.length*8-t.nBitLength;return T>0?B>>BigInt(T):B},_=t.bits2int_modN||function(v){return i(D(v))},P=Be(t.nBitLength);function C(v){return Tt("num < 2^"+t.nBitLength,v,oe,P),Ie(v,t.nByteLength)}function L(v,B,T=J){if(["recovered","canonical"].some(ot=>ot in T))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:p}=t,{lowS:E,prehash:A,extraEntropy:R}=T;E==null&&(E=!0),v=rt("msgHash",v),ea(T),A&&(v=rt("prehashed msgHash",x(v)));let N=_(v),k=f(B),F=[C(k),C(N)];if(R!=null&&R!==!1){let ot=R===!0?p(e.BYTES):R;F.push(rt("extraEntropy",ot))}let H=pe(...F),j=N;function at(ot){let mt=D(ot);if(!l(mt))return;let At=c(mt),dt=a.BASE.multiply(mt).toAffine(),gt=i(dt.x);if(gt===oe)return;let Ct=i(At*i(j+gt*k));if(Ct===oe)return;let Rt=(dt.x===gt?0:2)|Number(dt.y&pt),sr=Ct;return E&&b(Ct)&&(sr=m(Ct),Rt^=1),new h(gt,sr,Rt)}return{seed:H,k2sig:at}}let J={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};function K(v,B,T=J){let{seed:x,k2sig:p}=L(v,B,T),E=t;return wi(E.hash.outputLen,E.nByteLength,E.hmac)(x,p)}a.BASE._setWindowSize(8);function ut(v,B,T,x=$){let p=v;B=rt("msgHash",B),T=rt("publicKey",T);let{lowS:E,prehash:A,format:R}=x;if(ea(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let N=typeof p=="string"||Ae(p),k=!N&&!R&&typeof p=="object"&&p!==null&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!N&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,H;try{if(k&&(F=new h(p.r,p.s)),N){try{R!=="compact"&&(F=h.fromDER(p))}catch(Rt){if(!(Rt instanceof ne.Err))throw Rt}!F&&R!=="der"&&(F=h.fromCompact(p))}H=a.fromHex(T)}catch{return!1}if(!F||E&&F.hasHighS())return!1;A&&(B=t.hash(B));let{r:j,s:at}=F,ot=_(B),mt=c(at),At=i(ot*mt),dt=i(j*mt),gt=a.BASE.multiplyAndAddUnsafe(H,At,dt)?.toAffine();return gt?i(gt.x)===j:!1}return{CURVE:t,getPublicKey:S,getSharedSecret:I,sign:K,verify:ut,ProjectivePoint:a,Signature:h,utils:w}}function nl(r){return{hash:r,hmac:(t,...e)=>ss(r,t,ao(...e)),randomBytes:Zr}}function oa(r,t){let e=n=>na({...r,...nl(n)});return{...e(t),create:e}}var aa=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),sa=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ol=BigInt(1),as=BigInt(2),ia=(r,t)=>(r+t/as)/t;function sl(r){let t=aa,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=tt(u,e,t)*u%t,d=tt(l,e,t)*u%t,b=tt(d,as,t)*f%t,m=tt(b,o,t)*b%t,g=tt(m,s,t)*m%t,h=tt(g,c,t)*g%t,w=tt(h,a,t)*h%t,S=tt(w,c,t)*g%t,y=tt(S,e,t)*u%t,I=tt(y,i,t)*m%t,D=tt(I,n,t)*f%t,_=tt(D,as,t);if(!cs.eql(cs.sqr(_),r))throw new Error("Cannot find square root");return _}var cs=me(aa,void 0,void 0,{sqrt:sl}),_e=oa({a:BigInt(0),b:BigInt(7),Fp:cs,n:sa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=sa,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ol*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=ia(s*r,t),a=ia(-n*r,t),f=Y(r-c*e-a*o,t),u=Y(-c*n-a*s,t),l=f>i,d=u>i;if(l&&(f=t-f),d&&(u=t-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},ve),Em=BigInt(0);var vm=_e.ProjectivePoint;function ca(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ua(r,t,e){let n=fr.digest(e instanceof Uint8Array?e:e.subarray());if(ca(n))return n.then(({digest:o})=>_e.verify(t,o,r)).catch(o=>{throw new wr(String(o))});try{return _e.verify(t,n.digest,r)}catch(o){throw new wr(String(o))}}var cn=class{type="secp256k1";raw;_key;constructor(t){this._key=la(t),this.raw=fa(this._key)}toMultihash(){return Nt.digest(zt(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,e){return ua(this._key,e,t)}};function us(r){return new cn(r)}function fa(r){return _e.ProjectivePoint.fromHex(r).toRawBytes(!0)}function la(r){try{return _e.ProjectivePoint.fromHex(r),r}catch(t){throw new Ne(String(t))}}function Ye(r,t){let{Type:e,Data:n}=Zt.decode(r),o=n??new Uint8Array;switch(e){case it.RSA:return rs(o,t);case it.Ed25519:return Lo(o);case it.secp256k1:return us(o);case it.ECDSA:return io(o);default:throw new xe}}function da(r){let{Type:t,Data:e}=Zt.decode(r.digest),n=e??new Uint8Array;switch(t){case it.Ed25519:return Lo(n);case it.secp256k1:return us(n);case it.ECDSA:return io(n);default:throw new xe}}function zt(r){return Zt.encode({Type:it[r.type],Data:r.raw})}var Ar;(function(r){let t;r.codec=()=>(t==null&&(t=Vt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.publicKey!=null&&e.publicKey.byteLength>0&&(n.uint32(10),n.bytes(e.publicKey)),e.payloadType!=null&&e.payloadType.byteLength>0&&(n.uint32(18),n.bytes(e.payloadType)),e.payload!=null&&e.payload.byteLength>0&&(n.uint32(26),n.bytes(e.payload)),e.signature!=null&&e.signature.byteLength>0&&(n.uint32(42),n.bytes(e.signature)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={publicKey:yt(0),payloadType:yt(0),payload:yt(0),signature:yt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{s.publicKey=e.bytes();break}case 2:{s.payloadType=e.bytes();break}case 3:{s.payload=e.bytes();break}case 5:{s.signature=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Ft(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(Ar||(Ar={}));var un=class extends Error{constructor(t="Invalid signature"){super(t),this.name="InvalidSignatureError"}};var jt=class r{static createFromProtobuf=async t=>{let e=Ar.decode(t),n=Ye(e.publicKey);return new r({publicKey:n,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};static seal=async(t,e)=>{if(e==null)throw new Error("Missing private key");let n=t.domain,o=t.codec,s=t.marshal(),i=ha(n,o,s),c=await e.sign(i.subarray());return new r({publicKey:e.publicKey,payloadType:o,payload:s,signature:c})};static openAndCertify=async(t,e)=>{let n=await r.createFromProtobuf(t);if(!await n.validate(e))throw new un("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(t){let{publicKey:e,payloadType:n,payload:o,signature:s}=t;this.publicKey=e,this.payloadType=n,this.payload=o,this.signature=s}marshal(){return this.marshaled==null&&(this.marshaled=Ar.encode({publicKey:zt(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return ht(this.marshal(),t.marshal())}async validate(t){let e=ha(t,this.payloadType,this.payload);return this.publicKey.verify(e.subarray(),this.signature)}},ha=(r,t,e)=>{let n=M(r),o=Dt(n.byteLength),s=Dt(t.length),i=Dt(e.length);return new st(o,n,s,t,i,e)};var pa=Symbol.for("nodejs.util.inspect.custom"),il=114,Sr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Dn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(il,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[pa](){return`PeerId(${this.toString()})`}},Ir=class extends Sr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Br=class extends Sr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Pr=class extends Sr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},al=2336,Cr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Nt.digest(M(this.url))}[pa](){return`PeerId(${this.url})`}[Dn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(al,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=U(t)),t.toString()===this.toString())}};var cl=114,ma=2336;function ya(r){if(r.type==="Ed25519")return new Br({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Pr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Ir({multihash:r.toCID().multihash,publicKey:r});throw new xe}function fs(r){if(fl(r))return new Ir({multihash:r});if(ul(r))try{let t=da(r);if(t.type==="Ed25519")return new Br({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Pr({multihash:r,publicKey:t})}catch{let e=U(r.digest);return new Cr(new URL(e))}throw new kr("Supplied PeerID Multihash is invalid")}function fn(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==cl&&r.code!==ma)throw new Kr("Supplied PeerID CID is invalid");if(r.code===ma){let t=U(r.multihash.digest);return new Cr(new URL(t))}return fs(r.multihash)}function ul(r){return r.code===Nt.code}function fl(r){return r.code===fr.code}function ga(r,t){let e=(n,o)=>n.toString().localeCompare(o.toString());return r.length!==t.length?!1:(t.sort(e),r.sort(e).every((n,o)=>t[o].equals(n)))}var ln=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(s*=t,s+=u,s>f||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[c]=t(s.subarray(0,i));return e.set(s.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ba=45,ll=15,Xe=new ln;function dn(r){if(!(r.length>ll))return Xe.new(r).parseWith(()=>Xe.readIPv4Addr())}function hn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ba))return Xe.new(r).parseWith(()=>Xe.readIPv6Addr())}function De(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>ba)return;let e=Xe.new(r).parseWith(()=>Xe.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function xa(r,t,e){let n=0;for(let o of r)if(!(n<t)){if(n>e)break;if(o!==255)return!1;n++}return!0}function wa(r,t,e,n){let o=0;for(let s of r)if(!(o<e)){if(o>n)break;if(s!==t[o])return!1;o++}return!0}function ls(r){switch(r.length){case Re:return r.join(".");case Ue:{let t=[];for(let e=0;e<r.length;e++)e%2===0&&t.push(r[e].toString(16).padStart(2,"0")+r[e+1].toString(16).padStart(2,"0"));return t.join(":")}default:throw new Error("Invalid ip length")}}function Ea(r){let t=0;for(let[e,n]of r.entries()){if(n===255){t+=8;continue}for(;(n&128)!=0;)t++,n=n<<1;if((n&128)!=0)return-1;for(let o=e+1;o<r.length;o++)if(r[o]!=0)return-1;break}return t}function va(r){let t="0x";for(let e of r)t+=(e>>4).toString(16)+(e&15).toString(16);return t}var Re=4,Ue=16,$y=parseInt("0xFFFF",16),dl=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Lr(r,t){t.length===Ue&&r.length===Re&&xa(t,0,11)&&(t=t.slice(12)),t.length===Re&&r.length===Ue&&wa(r,dl,0,11)&&(r=r.slice(12));let e=r.length;if(e!=t.length)throw new Error("Failed to mask ip");let n=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=r[o]&t[o];return n}function Aa(r,t){if(typeof t=="string"&&(t=De(t)),t==null)throw new Error("Invalid ip");if(t.length!==r.network.length)return!1;for(let e=0;e<t.length;e++)if((r.network[e]&r.mask[e])!==(t[e]&r.mask[e]))return!1;return!0}function ds(r){let[t,e]=r.split("/");if(!t||!e)throw new Error("Failed to parse given CIDR: "+r);let n=Re,o=dn(t);if(o==null&&(n=Ue,o=hn(t),o==null))throw new Error("Failed to parse given CIDR: "+r);let s=parseInt(e,10);if(Number.isNaN(s)||String(s).length!==e.length||s<0||s>n*8)throw new Error("Failed to parse given CIDR: "+r);let i=hs(s,8*n);return{network:Lr(o,i),mask:i}}function hs(r,t){if(t!==8*Re&&t!==8*Ue)throw new Error("Invalid CIDR mask");if(r<0||r>t)throw new Error("Invalid CIDR mask");let e=t/8,n=new Uint8Array(e);for(let o=0;o<e;o++){if(r>=8){n[o]=255,r-=8;continue}n[o]=255-(255>>r),r=0}return n}var Je=class{constructor(t,e){if(e==null)({network:this.network,mask:this.mask}=ds(t));else{let n=De(t);if(n==null)throw new Error("Failed to parse network");e=String(e);let o=parseInt(e,10);if(Number.isNaN(o)||String(o).length!==e.length||o<0||o>n.length*8){let s=De(e);if(s==null)throw new Error("Failed to parse mask");this.mask=s}else this.mask=hs(o,8*n.length);this.network=Lr(n,this.mask)}}contains(t){return Aa({network:this.network,mask:this.mask},t)}toString(){let t=Ea(this.mask),e=t!==-1?String(t):va(this.mask);return ls(this.network)+"/"+e}};function Sa(r,t){return new Je(r).contains(t)}function Qe(r){return!!dn(r)}function tr(r){return!!hn(r)}function pn(r){return!!De(r)}var Ia=Qe,hl=tr,ps=function(r){let t=0;if(r=r.toString().trim(),Ia(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(hl(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=Ia(e[n]),i;s&&(i=ps(e[n]),e[n]=U(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,U(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let s=parseInt(e[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Ba=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let s=0;s<e;s++)o.push(r[t+s]);return o.join(".")}if(e===16){let o=[];for(let s=0;s<e;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var er={},ms={},ml=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];ml.forEach(r=>{let t=yl(...r);ms[t.code]=t,er[t.name]=t});function yl(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function z(r){if(typeof r=="number"){if(ms[r]!=null)return ms[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(er[r]!=null)return er[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ig=z("ip4"),Bg=z("ip6"),Pg=z("ipcidr");function xs(r,t){switch(z(r).code){case 4:case 41:return bl(t);case 42:return bs(t);case 43:return U(t,"base10");case 6:case 273:case 33:case 132:return La(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bs(t);case 421:return vl(t);case 444:return Ca(t);case 445:return Ca(t);case 466:return El(t);case 481:return globalThis.encodeURIComponent(bs(t));default:return U(t,"base16")}}function ws(r,t){switch(z(r).code){case 4:return Pa(t);case 41:return Pa(t);case 42:return gs(t);case 43:return M(t,"base10");case 6:case 273:case 33:case 132:return Es(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return gs(t);case 421:return xl(t);case 444:return Al(t);case 445:return Sl(t);case 466:return wl(t);case 481:return gs(globalThis.decodeURIComponent(t));default:return M(t,"base16")}}var ys=Object.values(lr).map(r=>r.decoder),gl=function(){let r=ys[0].or(ys[1]);return ys.slice(2).forEach(t=>r=r.or(t)),r}();function Pa(r){if(!pn(r))throw new Error("invalid ip address");return ps(r)}function bl(r){let t=Ba(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!pn(t))throw new Error("invalid ip address");return t}function Es(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function La(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function gs(r){let t=M(r),e=Uint8Array.from(Dt(t.length));return Lt([e,t],e.length+t.length)}function bs(r){let t=re(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return U(r)}function xl(r){let t;r[0]==="Q"||r[0]==="1"?t=we(X.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(Dt(t.length));return Lt([e,t],e.length+t.length)}function wl(r){let t=gl.decode(r),e=Uint8Array.from(Dt(t.length));return Lt([e,t],e.length+t.length)}function El(r){let t=re(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+U(e,"base64url")}function vl(r){let t=re(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return U(e,"base58btc")}function Al(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Xt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Es(n);return Lt([e,o],e.length+o.length)}function Sl(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Xt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Es(n);return Lt([e,o],e.length+o.length)}function Ca(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=U(t,"base32"),o=La(e);return`${n}:${o}`}function Ta(r){r=vs(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],c=z(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(s++,s>=o.length)throw new mn("invalid address: "+r);if(c.path===!0){n=vs(o.slice(s).join("/")),t.push([c.code,ws(c.code,n)]),e.push([c.code,n]);break}let a=ws(c.code,o[s]);t.push([c.code,a]),e.push([c.code,xs(c.code,a)])}return{string:_a(e),bytes:yn(t),tuples:t,stringTuples:e,path:n}}function As(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let s=re(r,o),i=xt(s),c=z(s),a=Il(c,r.slice(o+i));if(a===0){t.push([s]),e.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+a);if(o+=a+i,o>r.length)throw new mn("Invalid address Uint8Array: "+U(r,"base16"));t.push([s,f]);let u=xs(s,f);if(e.push([s,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:_a(e),tuples:t,stringTuples:e,path:n}}function _a(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),vs(t.join("/"))}function yn(r){return Lt(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(Dt(e.code));return t.length>1&&t[1]!=null&&(n=Lt([n,t[1]])),n}))}function Il(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=re(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function vs(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var mn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Bl=Symbol.for("nodejs.util.inspect.custom"),Is=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Pl=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],Ss=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},gn=class r{bytes;#e;#t;#r;#n;[Is]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=As(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ta(t)}else if(Ra(t))e=As(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="",i=z("tcp"),c=z("udp"),a=z("ip4"),f=z("ip6"),u=z("dns6"),l=z("ip6zone");for(let[b,m]of this.stringTuples())b===l.code&&(s=`%${m??""}`),Pl.includes(b)&&(e=i.name==="tcp"?"tcp":"udp",o=443,n=`${m??""}${s}`,t=b===u.code?6:4),(b===i.code||b===c.code)&&(e=z(b).name==="tcp"?"tcp":"udp",o=parseInt(m??"")),(b===a.code||b===f.code)&&(e=z(b).name==="tcp"?"tcp":"udp",n=`${m??""}${s}`,t=b===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},z(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>z(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(yn(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===er.p2p.code&&t.push([n,o]),n===er["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?U(X.decode(`z${n}`),"base58btc"):U(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return ht(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=Da.get(e.name);if(n==null)throw new Ss(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>Wt(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Bl](){return`Multiaddr(${this.#e})`}};var Da=new Map;function Ra(r){return!!r?.[Is]}function Wt(r){return new gn(r)}var Ua="libp2p-peer-record",Oa=Uint8Array.from([3,1]);var Tr;(function(r){let t;(function(n){let o;n.codec=()=>(o==null&&(o=Vt((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.multiaddr!=null&&s.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(s.multiaddr)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let a={multiaddr:yt(0)},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{a.multiaddr=s.bytes();break}default:{s.skipType(u&7);break}}}return a})),o),n.encode=s=>Ft(s,n.codec()),n.decode=(s,i)=>Mt(s,n.codec(),i)})(t=r.AddressInfo||(r.AddressInfo={}));let e;r.codec=()=>(e==null&&(e=Vt((n,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),n.peerId!=null&&n.peerId.byteLength>0&&(o.uint32(10),o.bytes(n.peerId)),n.seq!=null&&n.seq!==0n&&(o.uint32(16),o.uint64(n.seq)),n.addresses!=null)for(let i of n.addresses)o.uint32(26),r.AddressInfo.codec().encode(i,o);s.lengthDelimited!==!1&&o.ldelim()},(n,o,s={})=>{let i={peerId:yt(0),seq:0n,addresses:[]},c=o==null?n.len:n.pos+o;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:{i.peerId=n.bytes();break}case 2:{i.seq=n.uint64();break}case 3:{if(s.limits?.addresses!=null&&i.addresses.length===s.limits.addresses)throw new Te('Decode error - map field "addresses" had too many elements');i.addresses.push(r.AddressInfo.codec().decode(n,n.uint32(),{limits:s.limits?.addresses$}));break}default:{n.skipType(a&7);break}}}return i})),e),r.encode=n=>Ft(n,r.codec()),r.decode=(n,o)=>Mt(n,r.codec(),o)})(Tr||(Tr={}));var qt=class r{static createFromProtobuf=t=>{let e=Tr.decode(t),n=fs(we(e.peerId)),o=(e.addresses??[]).map(i=>Wt(i.multiaddr)),s=e.seq;return new r({peerId:n,multiaddrs:o,seqNumber:s})};static DOMAIN=Ua;static CODEC=Oa;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(t){let{peerId:e,multiaddrs:n,seqNumber:o}=t;this.peerId=e,this.multiaddrs=n??[],this.seqNumber=o??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=Tr.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof r)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!ga(this.multiaddrs,t.multiaddrs))}};function Cl(r){return r[Symbol.asyncIterator]!=null}function Ll(r){if(Cl(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Na=Ll;function Ht(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var bn=globalThis.CustomEvent??Event;async function*Bs(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered??!1,o=new EventTarget,s=[],i=Ht(),c=Ht(),a=!1,f,u=!1;o.addEventListener("task-complete",()=>{c.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(s.length===e&&(i=Ht(),await i.promise),u)break;let g={done:!1};s.push(g),m().then(h=>{g.done=!0,g.ok=!0,g.value=h,o.dispatchEvent(new bn("task-complete"))},h=>{g.done=!0,g.err=h,o.dispatchEvent(new bn("task-complete"))})}a=!0,o.dispatchEvent(new bn("task-complete"))}catch(m){f=m,o.dispatchEvent(new bn("task-complete"))}});function l(){return n?s[0]?.done:!!s.find(m=>m.done)}function*d(){for(;s.length>0&&s[0].done;){let m=s[0];if(s.shift(),m.ok)yield m.value;else throw u=!0,i.resolve(),m.err;i.resolve()}}function*b(){for(;l();)for(let m=0;m<s.length;m++)if(s[m].done){let g=s[m];if(s.splice(m,1),m--,g.ok)yield g.value;else throw u=!0,i.resolve(),g.err;i.resolve()}}for(;;){if(l()||(c=Ht(),await c.promise),f!=null)throw f;if(n?yield*d():yield*b(),a&&s.length===0)break}}var xn=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function _r(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new xn(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new xn(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var Ps=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=Ht(),this.haveNext=Ht()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Ht(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Ht(),await _r(this.readNext.promise,e?.signal,e)}};function Ka(){return new Ps}var wn=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function ka(r,t){let e=Ka();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let c of i)await e.push(c);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new st;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:a,value:f}=await _r(n.next(),i?.signal);return a===!0?null:f}for(;o.byteLength<i.bytes;){let{value:a,done:f}=await _r(n.next(),i?.signal);if(f===!0)throw new wn("unexpected end of input");o.append(a)}let c=o.sublist(0,i.bytes);return o.consume(i.bytes),c},write:async(i,c)=>{c?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,c):await e.push(i.subarray(),c)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var En=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},vn=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},An=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Ma(r,t={}){let e=ka(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=xt(t.maxDataLength));let n=t?.lengthDecoder??re,o=t?.lengthEncoder??Dt;return{read:async i=>{let c=-1,a=new st;for(;;){a.append(await e.read({...i,bytes:1}));try{c=n(a)}catch(f){if(f instanceof RangeError)continue;throw f}if(c<0)throw new En("Invalid message length");if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new An("message length length too long");if(c>-1)break}if(t?.maxDataLength!=null&&c>t.maxDataLength)throw new vn("message length too long");return e.read({...i,bytes:c})},write:async(i,c)=>{await e.write(new st(o(i.byteLength),i),c)},writeV:async(i,c)=>{let a=new st(...i.flatMap(f=>[o(f.byteLength),f]));await e.write(a,c)},unwrap:()=>e.unwrap()}}function rr(r,t){let e=Ma(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(c=>s.encode(c)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Fa="0.1.0",Va="id",qa="id/push",Ha="1.0.0",za="1.0.0";var be;(function(r){let t;r.codec=()=>(t==null&&(t=Vt((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.protocolVersion!=null&&(n.uint32(42),n.string(e.protocolVersion)),e.agentVersion!=null&&(n.uint32(50),n.string(e.agentVersion)),e.publicKey!=null&&(n.uint32(10),n.bytes(e.publicKey)),e.listenAddrs!=null)for(let s of e.listenAddrs)n.uint32(18),n.bytes(s);if(e.observedAddr!=null&&(n.uint32(34),n.bytes(e.observedAddr)),e.protocols!=null)for(let s of e.protocols)n.uint32(26),n.string(s);e.signedPeerRecord!=null&&(n.uint32(66),n.bytes(e.signedPeerRecord)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={listenAddrs:[],protocols:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 5:{s.protocolVersion=e.string();break}case 6:{s.agentVersion=e.string();break}case 1:{s.publicKey=e.bytes();break}case 2:{if(o.limits?.listenAddrs!=null&&s.listenAddrs.length===o.limits.listenAddrs)throw new Te('Decode error - map field "listenAddrs" had too many elements');s.listenAddrs.push(e.bytes());break}case 4:{s.observedAddr=e.bytes();break}case 3:{if(o.limits?.protocols!=null&&s.protocols.length===o.limits.protocols)throw new Te('Decode error - map field "protocols" had too many elements');s.protocols.push(e.string());break}case 8:{s.signedPeerRecord=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>Ft(e,r.codec()),r.decode=(e,n)=>Mt(e,r.codec(),n)})(be||(be={}));var Pt={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function Ga(r){if(r!=null&&r.length>0)try{return Wt(r)}catch{}}function Dl(r,t){return t??r.userAgent}async function Sn(r,t,e,n,o){if(e("received identify from %p",n.remotePeer),o==null)throw new Ut("message was null or undefined");let s={};if(o.listenAddrs.length>0&&(s.addresses=o.listenAddrs.map(a=>({isCertified:!1,multiaddr:Wt(a)}))),o.protocols.length>0&&(s.protocols=o.protocols),o.publicKey!=null){let a=Ye(o.publicKey);if(!ya(a).equals(n.remotePeer))throw new Ut("public key did not match remote PeerId");s.publicKey=a}let i;if(o.signedPeerRecord!=null){e.trace("received signedPeerRecord from %p",n.remotePeer);let a=o.signedPeerRecord,f=await jt.openAndCertify(a,qt.DOMAIN),u=qt.createFromProtobuf(f.payload),l=fn(f.publicKey.toCID());if(!u.peerId.equals(l))throw new Ut("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(u.peerId))throw new Ut("signing key does not match remote PeerId");let d;try{d=await r.get(u.peerId)}catch(b){if(b.name!=="NotFoundError")throw b}if(d!=null&&(s.metadata=d.metadata,d.peerRecordEnvelope!=null)){let b=await jt.createFromProtobuf(d.peerRecordEnvelope),m=qt.createFromProtobuf(b.payload);m.seqNumber>=u.seqNumber&&(e("sequence number was lower or equal to existing sequence number - stored: %d received: %d",m.seqNumber,u.seqNumber),u=m,a=d.peerRecordEnvelope)}s.peerRecordEnvelope=a,s.addresses=u.multiaddrs.map(b=>({isCertified:!0,multiaddr:b})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else e("%p did not send a signed peer record",n.remotePeer);if(e.trace("patching %p with",n.remotePeer,s),await r.patch(n.remotePeer,s),o.agentVersion!=null||o.protocolVersion!=null){let a={};o.agentVersion!=null&&(a.AgentVersion=M(o.agentVersion)),o.protocolVersion!=null&&(a.ProtocolVersion=M(o.protocolVersion)),e.trace("merging %p metadata",n.remotePeer,a),await r.merge(n.remotePeer,{metadata:a})}let c={peerId:n.remotePeer,protocolVersion:o.protocolVersion,agentVersion:o.agentVersion,publicKey:o.publicKey,listenAddrs:o.listenAddrs.map(a=>Wt(a)),observedAddr:o.observedAddr==null?void 0:Wt(o.observedAddr),protocols:o.protocols,signedPeerRecord:i,connection:n};return t.safeDispatchEvent("peer:identify",{detail:c}),c}var nr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(t,e){this.protocol=e.protocol,this.started=!1,this.peerId=t.peerId,this.privateKey=t.privateKey,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.events=t.events,this.log=e.log,this.timeout=e.timeout??Pt.timeout,this.maxInboundStreams=e.maxInboundStreams??Pt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Pt.maxOutboundStreams,this.maxMessageSize=e.maxMessageSize??Pt.maxMessageSize,this.maxObservedAddresses=e.maxObservedAddresses??Pt.maxObservedAddresses,this.runOnLimitedConnection=e.runOnLimitedConnection??Pt.runOnLimitedConnection,this.host={protocolVersion:`${e.protocolPrefix??Pt.protocolPrefix}/${Fa}`,agentVersion:Dl(t.nodeInfo,e.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:M(this.host.agentVersion),ProtocolVersion:M(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,t=>{this.handleProtocol(t).catch(e=>{this.log.error(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var In=class extends nr{connectionManager;concurrency;constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Pt.protocolPrefix}/${qa}/${za}`,log:t.logger.forComponent("libp2p:identify-push")}),this.connectionManager=t.connectionManager,this.concurrency=e.concurrency??Pt.concurrency,(e.runOnSelfUpdate??Pt.runOnSelfUpdate)&&t.events.addEventListener("self:peer:update",n=>{this.push().catch(o=>{this.log.error(o)})})}[Fr]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let t=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),e=new qt({peerId:this.peerId,multiaddrs:t}),n=await jt.seal(e,this.privateKey),o=this.registrar.getProtocols(),s=await this.peerStore.get(this.peerId),i=U(s.metadata.get("AgentVersion")??M(this.host.agentVersion)),c=U(s.metadata.get("ProtocolVersion")??M(this.host.protocolVersion)),a=this;async function*f(){for(let u of a.connectionManager.getConnections())(await a.peerStore.get(u.remotePeer)).protocols.includes(a.protocol)&&(yield async()=>{let d,b=AbortSignal.timeout(a.timeout);try{d=await u.newStream(a.protocol,{signal:b,runOnLimitedConnection:a.runOnLimitedConnection}),await rr(d,{maxDataLength:a.maxMessageSize}).pb(be).write({listenAddrs:t.map(g=>g.bytes),signedPeerRecord:n.marshal(),protocols:o,agentVersion:i,protocolVersion:c},{signal:b}),await d.close({signal:b})}catch(m){a.log.error("could not push identify update to peer",m),d?.abort(m)}})}await Na(Bs(f(),{concurrency:this.concurrency}))}async handleProtocol(t){let{connection:e,stream:n}=t;try{if(this.peerId.equals(e.remotePeer))throw new Error("received push from ourselves?");let o={signal:AbortSignal.timeout(this.timeout)},i=await rr(n,{maxDataLength:this.maxMessageSize}).pb(be).read(o);await n.close(o),await Sn(this.peerStore,this.events,this.log,e,i)}catch(o){this.log.error("received invalid message",o),n.abort(o);return}this.log.trace("handled push from %p",e.remotePeer)}};var Ul=41;function $a(r){try{let[[t,e]]=r.stringTuples();if(e==null)return!1;if(t===Ul)return Sa("2000::/3",e)}catch{}return!1}var ja=yc(Za(),1),Ol=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Nl=Ol.map(r=>new ja.Netmask(r));function Cs(r){for(let t of Nl)if(t.contains(r))return!0;return!1}function Kl(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function kl(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Cs(o)}function Ml(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Fl(r){let t=r.split(":"),e=t[t.length-1];return Cs(e)}function Vl(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Wa(r){return Qe(r)?Cs(r):Kl(r)?kl(r):Ml(r)?Fl(r):tr(r)?Vl(r):void 0}function Ya(r){try{let[[t]]=r.stringTuples();return t===4||t===41}catch{}return!1}function Xa(r){try{if(!Ya(r))return!1;let[[,t]]=r.stringTuples();return t==null?!1:Wa(t)??!1}catch{}return!0}var ql=r=>r.toString().split("/").slice(1),or=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),V=r=>({match:t=>or(e=>e===r).match(t),pattern:r}),Oe=()=>({match:r=>or(t=>typeof t=="string").match(r),pattern:"{string}"}),Rr=()=>({match:r=>or(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),W=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{X.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Ur=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Zn.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),G=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),Et=(...r)=>({match:t=>{let e;for(let n of r){let o=n.match(t);o!==!1&&(e==null||o.length<e.length)&&(e=o)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),q=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function et(...r){function t(o){let s=ql(o);for(let i of r){let c=i.match(s);if(c===!1)return!1;s=c}return s}function e(o){return t(o)!==!1}function n(o){let s=t(o);return s===!1?!1:s.length===0}return{matchers:r,matches:e,exactMatch:n}}var Hl=W(),yx=et(Hl),Pn=q(V("dns4"),Oe()),Cn=q(V("dns6"),Oe()),Ln=q(V("dnsaddr"),Oe()),Ts=q(V("dns"),Oe()),gx=et(Pn,G(W())),bx=et(Cn,G(W())),xx=et(Ln,G(W())),wx=et(Et(Ts,Ln,Pn,Cn),G(W())),Ja=q(V("ip4"),or(Qe)),Qa=q(V("ip6"),or(tr)),_s=Et(Ja,Qa),se=Et(_s,Ts,Pn,Cn,Ln),tc=et(Et(_s,q(Et(Ts,Ln,Pn,Cn),G(W())))),Ex=et(Ja),vx=et(Qa),Ax=et(_s),Ds=q(se,V("tcp"),Rr()),Or=q(se,V("udp"),Rr()),ec=et(q(Ds,G(W()))),Sx=et(Or),Rs=q(Or,V("quic"),G(W())),Tn=q(Or,V("quic-v1"),G(W())),zl=Et(Rs,Tn),Ix=et(Rs),Bx=et(Tn),Ls=Et(se,Ds,Or,Rs,Tn),rc=Et(q(Ls,V("ws"),G(W()))),Px=et(rc),nc=Et(q(Ls,V("wss"),G(W())),q(Ls,V("tls"),G(q(V("sni"),Oe())),V("ws"),G(W()))),Cx=et(nc),oc=q(Or,V("webrtc-direct"),G(Ur()),G(Ur()),G(W())),Lx=et(oc),sc=q(Tn,V("webtransport"),G(Ur()),G(Ur()),G(W())),Tx=et(sc),Bn=Et(rc,nc,q(Ds,G(W())),q(zl,G(W())),q(se,G(W())),oc,sc,W()),_x=et(Bn),Gl=q(Bn,V("p2p-circuit"),W()),Dx=et(Gl),$l=Et(q(Bn,V("p2p-circuit"),V("webrtc"),G(W())),q(Bn,V("webrtc"),G(W())),q(V("webrtc"),G(W()))),Rx=et($l),Zl=Et(q(se,V("tcp"),Rr(),V("http"),G(W())),q(se,V("http"),G(W()))),Ux=et(Zl),jl=Et(q(se,V("tcp"),Et(q(V("443"),V("http")),q(Rr(),V("https"))),G(W())),q(se,V("tls"),V("http"),G(W())),q(se,V("https"),G(W()))),Ox=et(jl),Wl=Et(q(V("memory"),Oe(),G(W()))),Nx=et(Wl);var Yl=41,_n=class extends nr{constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Pt.protocolPrefix}/${Va}/${Ha}`,log:t.logger.forComponent("libp2p:identify")}),(e.runOnConnectionOpen??Pt.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{let o=n.detail;this.identify(o).catch(s=>{s.name!==Mr.name&&this.log.error("error during identify trigged by connection:open",s)})})}[Fr]=["@libp2p/identify"];async _identify(t,e={}){let n;if(e.signal==null){let o=AbortSignal.timeout(this.timeout);e={...e,signal:o}}try{n=await t.newStream(this.protocol,{...e,runOnLimitedConnection:this.runOnLimitedConnection});let s=await rr(n,{maxDataLength:this.maxMessageSize}).pb(be).read(e);return await n.close(e),s}catch(o){throw n?.abort(o),o}}async identify(t,e={}){let n=await this._identify(t,e),{publicKey:o,protocols:s,observedAddr:i}=n;if(o==null)throw new Ut("public key was missing from identify message");let c=Ye(o),a=fn(c.toCID());if(!t.remotePeer.equals(a))throw new Ut("identified peer does not match the expected peer");if(this.peerId.equals(a))throw new Ut("identified peer is our own peer id?");return this.maybeAddObservedAddress(i),this.log("identify completed for peer %p and protocols %o",a,s),Sn(this.peerStore,this.events,this.log,t,n)}maybeAddObservedAddress(t){let e=Ga(t);if(e==null)return;if(this.log.trace("our observed address was %a",e),Xa(e)){this.log.trace("our observed address was private");return}if(e.stringTuples()[0][0]===Yl&&!$a(e)){this.log.trace("our observed address was IPv6 but not a global unicast address");return}ec.exactMatch(e)||(this.log.trace("storing the observed address"),this.addressManager.addObservedAddr(e))}async handleProtocol(t){let{connection:e,stream:n}=t,o=AbortSignal.timeout(this.timeout);try{let s=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),c=s.peerRecordEnvelope;if(i.length>0&&c==null){let u=new qt({peerId:this.peerId,multiaddrs:i});c=(await jt.seal(u,this.privateKey)).marshal().subarray()}let a=e.remoteAddr.bytes;tc.matches(e.remoteAddr)||(a=void 0),await rr(n).pb(be).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:zt(this.privateKey.publicKey),listenAddrs:i.map(u=>u.bytes),signedPeerRecord:c,observedAddr:a,protocols:s.protocols},{signal:o}),await n.close({signal:o})}catch(s){this.log.error("could not respond to identify request",s),n.abort(s)}}};function Xl(r={}){return t=>new _n(t,r)}function Jl(r={}){return t=>new In(t,r)}return gc(Ql);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/identify",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.28-3833353bd",
|
|
4
4
|
"description": "Implementation of the Identify Protocol",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-identify#readme",
|
|
@@ -52,23 +52,23 @@
|
|
|
52
52
|
"doc-check": "aegir doc-check"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@libp2p/crypto": "
|
|
56
|
-
"@libp2p/interface": "
|
|
57
|
-
"@libp2p/interface-internal": "
|
|
58
|
-
"@libp2p/peer-id": "
|
|
59
|
-
"@libp2p/peer-record": "
|
|
60
|
-
"@libp2p/utils": "
|
|
55
|
+
"@libp2p/crypto": "5.1.0-3833353bd",
|
|
56
|
+
"@libp2p/interface": "2.8.0-3833353bd",
|
|
57
|
+
"@libp2p/interface-internal": "2.3.10-3833353bd",
|
|
58
|
+
"@libp2p/peer-id": "5.1.1-3833353bd",
|
|
59
|
+
"@libp2p/peer-record": "8.0.26-3833353bd",
|
|
60
|
+
"@libp2p/utils": "6.6.1-3833353bd",
|
|
61
61
|
"@multiformats/multiaddr": "^12.3.3",
|
|
62
62
|
"@multiformats/multiaddr-matcher": "^1.6.0",
|
|
63
63
|
"it-drain": "^3.0.7",
|
|
64
64
|
"it-parallel": "^3.0.8",
|
|
65
|
-
"it-protobuf-stream": "^
|
|
65
|
+
"it-protobuf-stream": "^2.0.1",
|
|
66
66
|
"protons-runtime": "^5.5.0",
|
|
67
67
|
"uint8arraylist": "^2.4.8",
|
|
68
68
|
"uint8arrays": "^5.1.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@libp2p/logger": "
|
|
71
|
+
"@libp2p/logger": "5.1.14-3833353bd",
|
|
72
72
|
"aegir": "^45.1.1",
|
|
73
73
|
"delay": "^6.0.0",
|
|
74
74
|
"it-length-prefixed": "^10.0.1",
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
|
|
3
|
-
".:Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
|
|
4
|
-
"IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
|
|
5
|
-
".:IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
|
|
6
|
-
"IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
|
|
7
|
-
".:IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
|
|
8
|
-
"IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
|
|
9
|
-
".:IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
|
|
10
|
-
"IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
|
|
11
|
-
".:IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
|
|
12
|
-
"IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
|
|
13
|
-
".:IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
|
|
14
|
-
"identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
|
|
15
|
-
".:identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
|
|
16
|
-
"identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush-1.html",
|
|
17
|
-
".:identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush-1.html"
|
|
18
|
-
}
|