@libp2p/peer-collections 6.0.12-4a85eb033 → 6.0.12-98b43045c
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.min.js +1 -1
- package/package.json +5 -5
package/dist/index.min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
2
|
-
"use strict";var Libp2PPeerCollections=(()=>{var Rs=Object.create;var ze=Object.defineProperty;var Ls=Object.getOwnPropertyDescriptor;var Cs=Object.getOwnPropertyNames;var Ns=Object.getPrototypeOf,Us=Object.prototype.hasOwnProperty;var zn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ct=(r,t)=>{for(var e in t)ze(r,e,{get:t[e],enumerable:!0})},Hn=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cs(t))!Us.call(r,o)&&o!==e&&ze(r,o,{get:()=>t[o],enumerable:!(n=Ls(t,o))||n.enumerable});return r};var ks=(r,t,e)=>(e=r!=null?Rs(Ns(r)):{},Hn(t||!r||!r.__esModule?ze(e,"default",{value:r,enumerable:!0}):e,r)),Ds=r=>Hn(ze({},"__esModule",{value:!0}),r);var hs=zn((De,gr)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(c){if(!Array.isArray(c)&&!ArrayBuffer.isView(c))return!1;for(var p=0;p<c.length;p++)if(!Number.isInteger(c[p])||c[p]<0||c[p]>255)return!1;return!0}function o(c,p){return(c&65535)*p+(((c>>>16)*p&65535)<<16)}function s(c,p){return c<<p|c>>>32-p}function i(c){return c^=c>>>16,c=o(c,2246822507),c^=c>>>13,c=o(c,3266489909),c^=c>>>16,c}function a(c,p){c=[c[0]>>>16,c[0]&65535,c[1]>>>16,c[1]&65535],p=[p[0]>>>16,p[0]&65535,p[1]>>>16,p[1]&65535];var l=[0,0,0,0];return l[3]+=c[3]+p[3],l[2]+=l[3]>>>16,l[3]&=65535,l[2]+=c[2]+p[2],l[1]+=l[2]>>>16,l[2]&=65535,l[1]+=c[1]+p[1],l[0]+=l[1]>>>16,l[1]&=65535,l[0]+=c[0]+p[0],l[0]&=65535,[l[0]<<16|l[1],l[2]<<16|l[3]]}function f(c,p){c=[c[0]>>>16,c[0]&65535,c[1]>>>16,c[1]&65535],p=[p[0]>>>16,p[0]&65535,p[1]>>>16,p[1]&65535];var l=[0,0,0,0];return l[3]+=c[3]*p[3],l[2]+=l[3]>>>16,l[3]&=65535,l[2]+=c[2]*p[3],l[1]+=l[2]>>>16,l[2]&=65535,l[2]+=c[3]*p[2],l[1]+=l[2]>>>16,l[2]&=65535,l[1]+=c[1]*p[3],l[0]+=l[1]>>>16,l[1]&=65535,l[1]+=c[2]*p[2],l[0]+=l[1]>>>16,l[1]&=65535,l[1]+=c[3]*p[1],l[0]+=l[1]>>>16,l[1]&=65535,l[0]+=c[0]*p[3]+c[1]*p[2]+c[2]*p[1]+c[3]*p[0],l[0]&=65535,[l[0]<<16|l[1],l[2]<<16|l[3]]}function b(c,p){return p%=64,p===32?[c[1],c[0]]:p<32?[c[0]<<p|c[1]>>>32-p,c[1]<<p|c[0]>>>32-p]:(p-=32,[c[1]<<p|c[0]>>>32-p,c[0]<<p|c[1]>>>32-p])}function u(c,p){return p%=64,p===0?c:p<32?[c[0]<<p|c[1]>>>32-p,c[1]<<p]:[c[1]<<p-32,0]}function m(c,p){return[c[0]^p[0],c[1]^p[1]]}function _(c){return c=m(c,[0,c[0]>>>1]),c=f(c,[4283543511,3981806797]),c=m(c,[0,c[0]>>>1]),c=f(c,[3301882366,444984403]),c=m(c,[0,c[0]>>>1]),c}e.x86.hash32=function(c,p){if(e.inputValidation&&!n(c))return t;p=p||0;for(var l=c.length%4,g=c.length-l,d=p,x=0,h=3432918353,y=461845907,B=0;B<g;B=B+4)x=c[B]|c[B+1]<<8|c[B+2]<<16|c[B+3]<<24,x=o(x,h),x=s(x,15),x=o(x,y),d^=x,d=s(d,13),d=o(d,5)+3864292196;switch(x=0,l){case 3:x^=c[B+2]<<16;case 2:x^=c[B+1]<<8;case 1:x^=c[B],x=o(x,h),x=s(x,15),x=o(x,y),d^=x}return d^=c.length,d=i(d),d>>>0},e.x86.hash128=function(c,p){if(e.inputValidation&&!n(c))return t;p=p||0;for(var l=c.length%16,g=c.length-l,d=p,x=p,h=p,y=p,B=0,I=0,w=0,v=0,R=597399067,V=2869860233,P=951274213,M=2716044179,N=0;N<g;N=N+16)B=c[N]|c[N+1]<<8|c[N+2]<<16|c[N+3]<<24,I=c[N+4]|c[N+5]<<8|c[N+6]<<16|c[N+7]<<24,w=c[N+8]|c[N+9]<<8|c[N+10]<<16|c[N+11]<<24,v=c[N+12]|c[N+13]<<8|c[N+14]<<16|c[N+15]<<24,B=o(B,R),B=s(B,15),B=o(B,V),d^=B,d=s(d,19),d+=x,d=o(d,5)+1444728091,I=o(I,V),I=s(I,16),I=o(I,P),x^=I,x=s(x,17),x+=h,x=o(x,5)+197830471,w=o(w,P),w=s(w,17),w=o(w,M),h^=w,h=s(h,15),h+=y,h=o(h,5)+2530024501,v=o(v,M),v=s(v,18),v=o(v,R),y^=v,y=s(y,13),y+=d,y=o(y,5)+850148119;switch(B=0,I=0,w=0,v=0,l){case 15:v^=c[N+14]<<16;case 14:v^=c[N+13]<<8;case 13:v^=c[N+12],v=o(v,M),v=s(v,18),v=o(v,R),y^=v;case 12:w^=c[N+11]<<24;case 11:w^=c[N+10]<<16;case 10:w^=c[N+9]<<8;case 9:w^=c[N+8],w=o(w,P),w=s(w,17),w=o(w,M),h^=w;case 8:I^=c[N+7]<<24;case 7:I^=c[N+6]<<16;case 6:I^=c[N+5]<<8;case 5:I^=c[N+4],I=o(I,V),I=s(I,16),I=o(I,P),x^=I;case 4:B^=c[N+3]<<24;case 3:B^=c[N+2]<<16;case 2:B^=c[N+1]<<8;case 1:B^=c[N],B=o(B,R),B=s(B,15),B=o(B,V),d^=B}return d^=c.length,x^=c.length,h^=c.length,y^=c.length,d+=x,d+=h,d+=y,x+=d,h+=d,y+=d,d=i(d),x=i(x),h=i(h),y=i(y),d+=x,d+=h,d+=y,x+=d,h+=d,y+=d,("00000000"+(d>>>0).toString(16)).slice(-8)+("00000000"+(x>>>0).toString(16)).slice(-8)+("00000000"+(h>>>0).toString(16)).slice(-8)+("00000000"+(y>>>0).toString(16)).slice(-8)},e.x64.hash128=function(c,p){if(e.inputValidation&&!n(c))return t;p=p||0;for(var l=c.length%16,g=c.length-l,d=[0,p],x=[0,p],h=[0,0],y=[0,0],B=[2277735313,289559509],I=[1291169091,658871167],w=0;w<g;w=w+16)h=[c[w+4]|c[w+5]<<8|c[w+6]<<16|c[w+7]<<24,c[w]|c[w+1]<<8|c[w+2]<<16|c[w+3]<<24],y=[c[w+12]|c[w+13]<<8|c[w+14]<<16|c[w+15]<<24,c[w+8]|c[w+9]<<8|c[w+10]<<16|c[w+11]<<24],h=f(h,B),h=b(h,31),h=f(h,I),d=m(d,h),d=b(d,27),d=a(d,x),d=a(f(d,[0,5]),[0,1390208809]),y=f(y,I),y=b(y,33),y=f(y,B),x=m(x,y),x=b(x,31),x=a(x,d),x=a(f(x,[0,5]),[0,944331445]);switch(h=[0,0],y=[0,0],l){case 15:y=m(y,u([0,c[w+14]],48));case 14:y=m(y,u([0,c[w+13]],40));case 13:y=m(y,u([0,c[w+12]],32));case 12:y=m(y,u([0,c[w+11]],24));case 11:y=m(y,u([0,c[w+10]],16));case 10:y=m(y,u([0,c[w+9]],8));case 9:y=m(y,[0,c[w+8]]),y=f(y,I),y=b(y,33),y=f(y,B),x=m(x,y);case 8:h=m(h,u([0,c[w+7]],56));case 7:h=m(h,u([0,c[w+6]],48));case 6:h=m(h,u([0,c[w+5]],40));case 5:h=m(h,u([0,c[w+4]],32));case 4:h=m(h,u([0,c[w+3]],24));case 3:h=m(h,u([0,c[w+2]],16));case 2:h=m(h,u([0,c[w+1]],8));case 1:h=m(h,[0,c[w]]),h=f(h,B),h=b(h,31),h=f(h,I),d=m(d,h)}return d=m(d,[0,c.length]),x=m(x,[0,c.length]),d=a(d,x),x=a(x,d),d=_(d),x=_(x),d=a(d,x),x=a(x,d),("00000000"+(d[0]>>>0).toString(16)).slice(-8)+("00000000"+(d[1]>>>0).toString(16)).slice(-8)+("00000000"+(x[0]>>>0).toString(16)).slice(-8)+("00000000"+(x[1]>>>0).toString(16)).slice(-8)},typeof De<"u"?(typeof gr<"u"&&gr.exports&&(De=gr.exports=e),De.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(De)});var ds=zn((k0,ls)=>{ls.exports=hs()});var Sa={};ct(Sa,{PeerFilter:()=>Oe,PeerList:()=>Vt,PeerMap:()=>qt,PeerSet:()=>Ft,peerFilter:()=>gs,peerList:()=>us,peerMap:()=>as,peerSet:()=>fs,trackedPeerList:()=>ys,trackedPeerMap:()=>bs,trackedPeerSet:()=>ws});var yr=Symbol.for("@libp2p/peer-id");var ge=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},He=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ke=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var be=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var vr={};ct(vr,{base58btc:()=>X,base58flickr:()=>Ks});var Aa=new Uint8Array(0);function Kn(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 Et(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 qn(r){return new TextEncoder().encode(r)}function Fn(r){return new TextDecoder().decode(r)}function Ms(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 a=r.length,f=r.charAt(0),b=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function m(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var l=0,g=0,d=0,x=p.length;d!==x&&p[d]===0;)d++,l++;for(var h=(x-d)*u+1>>>0,y=new Uint8Array(h);d!==x;){for(var B=p[d],I=0,w=h-1;(B!==0||I<g)&&w!==-1;w--,I++)B+=256*y[w]>>>0,y[w]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");g=I,d++}for(var v=h-g;v!==h&&y[v]===0;)v++;for(var R=f.repeat(l);v<h;++v)R+=r.charAt(y[v]);return R}function _(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var l=0;if(p[l]!==" "){for(var g=0,d=0;p[l]===f;)g++,l++;for(var x=(p.length-l)*b+1>>>0,h=new Uint8Array(x);p[l];){var y=e[p.charCodeAt(l)];if(y===255)return;for(var B=0,I=x-1;(y!==0||B<d)&&I!==-1;I--,B++)y+=a*h[I]>>>0,h[I]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");d=B,l++}if(p[l]!==" "){for(var w=x-d;w!==x&&h[w]===0;)w++;for(var v=new Uint8Array(g+(x-w)),R=g;w!==x;)v[R++]=h[w++];return v}}}function c(p){var l=_(p);if(l)return l;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:_,decode:c}}var Ps=Ms,Os=Ps,$n=Os;var Er=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")}},_r=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 Zn(this,t)}},Sr=class{decoders;constructor(t){this.decoders=t}or(t){return Zn(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 Zn(r,t){return new Sr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Br=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 Er(t,e,n),this.decoder=new _r(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function oe({name:r,prefix:t,encode:e,decode:n}){return new Br(r,t,e,n)}function Ct({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=$n(e,r);return oe({prefix:t,name:r,encode:n,decode:s=>Et(o(s))})}function zs(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),a=0,f=0,b=0;for(let u=0;u<s;++u){let m=o[r[u]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|m,a+=e,a>=8&&(a-=8,i[b++]=255&f>>a)}if(a>=e||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Hs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let f=0;f<r.length;++f)for(a=a<<8|r[f],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;s.length*e&7;)s+="=";return s}function G({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return oe({prefix:t,name:r,encode(o){return Hs(o,n,e)},decode(o){return zs(o,n,e,r)}})}var X=Ct({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ks=Ct({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ir={};ct(Ir,{base32:()=>se,base32hex:()=>$s,base32hexpad:()=>Gs,base32hexpadupper:()=>js,base32hexupper:()=>Zs,base32pad:()=>Fs,base32padupper:()=>Vs,base32upper:()=>qs,base32z:()=>Ys});var se=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qs=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fs=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vs=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$s=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Zs=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gs=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),js=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ys=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ar={};ct(Ar,{base36:()=>we,base36upper:()=>Xs});var we=Ct({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xs=Ct({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ws=Yn,Gn=128,Qs=127,Js=~Qs,ti=Math.pow(2,31);function Yn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ti;)t[e++]=r&255|Gn,r/=128;for(;r&Js;)t[e++]=r&255|Gn,r>>>=7;return t[e]=r|0,Yn.bytes=e-n+1,t}var ei=Tr,ri=128,jn=127;function Tr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Tr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&jn)<<o:(i&jn)*Math.pow(2,o),o+=7}while(i>=ri);return Tr.bytes=s-n,e}var ni=Math.pow(2,7),oi=Math.pow(2,14),si=Math.pow(2,21),ii=Math.pow(2,28),ci=Math.pow(2,35),ai=Math.pow(2,42),fi=Math.pow(2,49),ui=Math.pow(2,56),hi=Math.pow(2,63),li=function(r){return r<ni?1:r<oi?2:r<si?3:r<ii?4:r<ci?5:r<ai?6:r<fi?7:r<ui?8:r<hi?9:10},di={encode:Ws,decode:ei,encodingLength:li},pi=di,ye=pi;function Ee(r,t=0){return[ye.decode(r,t),ye.decode.bytes]}function ie(r,t,e=0){return ye.encode(r,t,e),t}function ce(r){return ye.encodingLength(r)}function $t(r,t){let e=t.byteLength,n=ce(r),o=n+ce(e),s=new Uint8Array(o+e);return ie(r,s,0),ie(e,s,n),s.set(t,o),new ae(r,e,t,s)}function _e(r){let t=Et(r),[e,n]=Ee(t),[o,s]=Ee(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ae(e,o,i,t)}function Xn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Kn(r.bytes,e.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Wn(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return xi(e,Rr(r),t??X.encoder);default:return gi(e,Rr(r),t??se.encoder)}}var Qn=new WeakMap;function Rr(r){let t=Qn.get(r);if(t==null){let e=new Map;return Qn.set(r,e),e}return t}var lt=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!==Se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==bi)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=$t(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&&Xn(t.multihash,n.multihash)}toString(t){return Wn(this,t)}toJSON(){return{"/":Wn(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??Jn(n,o,s.bytes))}else if(e[wi]===!0){let{version:n,multihash:o,code:s}=e,i=_e(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!==Se)throw new Error(`Version 0 CID must use dag-pb (code: ${Se}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Jn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Se,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=Et(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 ae(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[m,_]=Ee(t.subarray(e));return e+=_,m},o=n(),s=Se;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),f=n(),b=e+f,u=b-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:u,size:b}}static parse(t,e){let[n,o]=mi(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 Rr(s).set(n,t),s}};function mi(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 se.prefix:{let e=t??se;return[se.prefix,e.decode(r)]}case we.prefix:{let e=t??we;return[we.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 xi(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 gi(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 Se=112,bi=18;function Jn(r,t,e){let n=ce(r),o=n+ce(t),s=new Uint8Array(o+e.byteLength);return ie(r,s,0),ie(t,s,n),s.set(e,o),s}var wi=Symbol.for("@ipld/js-cid/CID");var Lr={};ct(Lr,{identity:()=>_t});var to=0,yi="identity",eo=Et;function Ei(r){return $t(to,eo(r))}var _t={code:to,name:yi,encode:eo,digest:Ei};function St(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 ro(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function _i(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function fe(r,...t){if(!_i(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function no(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ro(r.outputLen),ro(r.blockLen)}function ue(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 oo(r,t){fe(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Gt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Fe=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),dt=(r,t)=>r<<32-t|r>>>t;var Xa=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function so(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Be(r){return typeof r=="string"&&(r=so(r)),fe(r),r}function Cr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];fe(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()}},Wa={}.toString;function Ve(r){let t=n=>r().update(Be(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function $e(r=32){if(Gt&&typeof Gt.getRandomValues=="function")return Gt.getRandomValues(new Uint8Array(r));if(Gt&&typeof Gt.randomBytes=="function")return Gt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Si(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),a=Number(e&s),f=n?4:0,b=n?0:4;r.setUint32(t+f,i,n),r.setUint32(t+b,a,n)}var io=(r,t,e)=>r&t^~r&e,co=(r,t,e)=>r&t^r&e^t&e,le=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=Fe(this.buffer)}update(t){ue(this);let{view:e,buffer:n,blockLen:o}=this;t=Be(t);let s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let f=Fe(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ue(this),oo(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 m=i;m<o;m++)e[m]=0;Si(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=Fe(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let b=f/4,u=this.get();if(b>u.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<b;m++)a.setUint32(4*m,u[m],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:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Ze=BigInt(4294967295),Nr=BigInt(32);function ao(r,t=!1){return t?{h:Number(r&Ze),l:Number(r>>Nr&Ze)}:{h:Number(r>>Nr&Ze)|0,l:Number(r&Ze)|0}}function Bi(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}=ao(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var vi=(r,t)=>BigInt(r>>>0)<<Nr|BigInt(t>>>0),Ii=(r,t,e)=>r>>>e,Ai=(r,t,e)=>r<<32-e|t>>>e,Ti=(r,t,e)=>r>>>e|t<<32-e,Ri=(r,t,e)=>r<<32-e|t>>>e,Li=(r,t,e)=>r<<64-e|t>>>e-32,Ci=(r,t,e)=>r>>>e-32|t<<64-e,Ni=(r,t)=>t,Ui=(r,t)=>r,ki=(r,t,e)=>r<<e|t>>>32-e,Di=(r,t,e)=>t<<e|r>>>32-e,Mi=(r,t,e)=>t<<e-32|r>>>64-e,Pi=(r,t,e)=>r<<e-32|t>>>64-e;function Oi(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var zi=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Hi=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ki=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),qi=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Fi=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Vi=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var $i={fromBig:ao,split:Bi,toBig:vi,shrSH:Ii,shrSL:Ai,rotrSH:Ti,rotrSL:Ri,rotrBH:Li,rotrBL:Ci,rotr32H:Ni,rotr32L:Ui,rotlSH:ki,rotlSL:Di,rotlBH:Mi,rotlBL:Pi,add:Oi,add3L:zi,add3H:Hi,add4L:Ki,add4H:qi,add5H:Vi,add5L:Fi},D=$i;var[Zi,Gi]=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))),Nt=new Uint32Array(80),Ut=new Uint32Array(80),Ur=class extends le{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:a,Dl:f,Eh:b,El:u,Fh:m,Fl:_,Gh:c,Gl:p,Hh:l,Hl:g}=this;return[t,e,n,o,s,i,a,f,b,u,m,_,c,p,l,g]}set(t,e,n,o,s,i,a,f,b,u,m,_,c,p,l,g){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=a|0,this.Dl=f|0,this.Eh=b|0,this.El=u|0,this.Fh=m|0,this.Fl=_|0,this.Gh=c|0,this.Gl=p|0,this.Hh=l|0,this.Hl=g|0}process(t,e){for(let h=0;h<16;h++,e+=4)Nt[h]=t.getUint32(e),Ut[h]=t.getUint32(e+=4);for(let h=16;h<80;h++){let y=Nt[h-15]|0,B=Ut[h-15]|0,I=D.rotrSH(y,B,1)^D.rotrSH(y,B,8)^D.shrSH(y,B,7),w=D.rotrSL(y,B,1)^D.rotrSL(y,B,8)^D.shrSL(y,B,7),v=Nt[h-2]|0,R=Ut[h-2]|0,V=D.rotrSH(v,R,19)^D.rotrBH(v,R,61)^D.shrSH(v,R,6),P=D.rotrSL(v,R,19)^D.rotrBL(v,R,61)^D.shrSL(v,R,6),M=D.add4L(w,P,Ut[h-7],Ut[h-16]),N=D.add4H(M,I,V,Nt[h-7],Nt[h-16]);Nt[h]=N|0,Ut[h]=M|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:f,Dh:b,Dl:u,Eh:m,El:_,Fh:c,Fl:p,Gh:l,Gl:g,Hh:d,Hl:x}=this;for(let h=0;h<80;h++){let y=D.rotrSH(m,_,14)^D.rotrSH(m,_,18)^D.rotrBH(m,_,41),B=D.rotrSL(m,_,14)^D.rotrSL(m,_,18)^D.rotrBL(m,_,41),I=m&c^~m&l,w=_&p^~_&g,v=D.add5L(x,B,w,Gi[h],Ut[h]),R=D.add5H(v,d,y,I,Zi[h],Nt[h]),V=v|0,P=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),M=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),N=n&s^n&a^s&a,T=o&i^o&f^i&f;d=l|0,x=g|0,l=c|0,g=p|0,c=m|0,p=_|0,{h:m,l:_}=D.add(b|0,u|0,R|0,V|0),b=a|0,u=f|0,a=s|0,f=i|0,s=n|0,i=o|0;let L=D.add3L(V,M,T);n=D.add3H(L,R,P,N),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:a,l:f}=D.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:b,l:u}=D.add(this.Dh|0,this.Dl|0,b|0,u|0),{h:m,l:_}=D.add(this.Eh|0,this.El|0,m|0,_|0),{h:c,l:p}=D.add(this.Fh|0,this.Fl|0,c|0,p|0),{h:l,l:g}=D.add(this.Gh|0,this.Gl|0,l|0,g|0),{h:d,l:x}=D.add(this.Hh|0,this.Hl|0,d|0,x|0),this.set(n,o,s,i,a,f,b,u,m,_,c,p,l,g,d,x)}roundClean(){Nt.fill(0),Ut.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 fo=Ve(()=>new Ur);var je={};ct(je,{aInRange:()=>at,abool:()=>pt,abytes:()=>de,bitGet:()=>Ji,bitLen:()=>Or,bitMask:()=>Ie,bitSet:()=>tc,bytesToHex:()=>vt,bytesToNumberBE:()=>It,bytesToNumberLE:()=>Dt,concatBytes:()=>At,createHmacDrbg:()=>zr,ensureBytes:()=>j,equalBytes:()=>Wi,hexToBytes:()=>Yt,hexToNumber:()=>Pr,inRange:()=>ve,isBytes:()=>kt,memoized:()=>Wt,notImplemented:()=>rc,numberToBytesBE:()=>Mt,numberToBytesLE:()=>Xt,numberToHexUnpadded:()=>jt,numberToVarBytesBE:()=>Xi,utf8ToBytes:()=>Qi,validateObject:()=>bt});var Mr=BigInt(0),Ge=BigInt(1),ji=BigInt(2);function kt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function de(r){if(!kt(r))throw new Error("Uint8Array expected")}function pt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var Yi=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function vt(r){de(r);let t="";for(let e=0;e<r.length;e++)t+=Yi[r[e]];return t}function jt(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Pr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Bt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function uo(r){if(r>=Bt._0&&r<=Bt._9)return r-Bt._0;if(r>=Bt._A&&r<=Bt._F)return r-(Bt._A-10);if(r>=Bt._a&&r<=Bt._f)return r-(Bt._a-10)}function Yt(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("padded 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=uo(r.charCodeAt(s)),a=uo(r.charCodeAt(s+1));if(i===void 0||a===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+a}return n}function It(r){return Pr(vt(r))}function Dt(r){return de(r),Pr(vt(Uint8Array.from(r).reverse()))}function Mt(r,t){return Yt(r.toString(16).padStart(t*2,"0"))}function Xt(r,t){return Mt(r,t).reverse()}function Xi(r){return Yt(jt(r))}function j(r,t,e){let n;if(typeof t=="string")try{n=Yt(t)}catch(s){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${s}`)}else if(kt(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} expected ${e} bytes, got ${o}`);return n}function At(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];de(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 Wi(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 Qi(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var kr=r=>typeof r=="bigint"&&Mr<=r;function ve(r,t,e){return kr(r)&&kr(t)&&kr(e)&&t<=r&&r<e}function at(r,t,e,n){if(!ve(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function Or(r){let t;for(t=0;r>Mr;r>>=Ge,t+=1);return t}function Ji(r,t){return r>>BigInt(t)&Ge}function tc(r,t,e){return r|(e?Ge:Mr)<<BigInt(t)}var Ie=r=>(ji<<BigInt(r-1))-Ge,Dr=r=>new Uint8Array(r),ho=r=>Uint8Array.from(r);function zr(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=Dr(r),o=Dr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...m)=>e(o,n,...m),f=(m=Dr())=>{o=a(ho([0]),m),n=a(),m.length!==0&&(o=a(ho([1]),m),n=a())},b=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let m=0,_=[];for(;m<t;){n=a();let c=n.slice();_.push(c),m+=n.length}return At(..._)};return(m,_)=>{i(),f(m);let c;for(;!(c=_(b()));)f();return i(),c}}var ec={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"||kt(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 bt(r,t,e={}){let n=(o,s,i)=>{let a=ec[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let f=r[o];if(!(i&&f===void 0)&&!a(f,r))throw new Error(`Invalid param ${String(o)}=${f} (${typeof f}), expected ${s}`)};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 rc=()=>{throw new Error("not implemented")};function Wt(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 W=BigInt(0),$=BigInt(1),Qt=BigInt(2),nc=BigInt(3),Hr=BigInt(4),lo=BigInt(5),po=BigInt(8),oc=BigInt(9),sc=BigInt(16);function q(r,t){let e=r%t;return e>=W?e:t+e}function ic(r,t,e){if(e<=W||t<W)throw new Error("Expected power/modulo > 0");if(e===$)return W;let n=$;for(;t>W;)t&$&&(n=n*r%e),r=r*r%e,t>>=$;return n}function Z(r,t,e){let n=r;for(;t-- >W;)n*=n,n%=e;return n}function Ye(r,t){if(r===W||t<=W)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=q(r,t),n=t,o=W,s=$,i=$,a=W;for(;e!==W;){let b=n/e,u=n%e,m=o-i*b,_=s-a*b;n=e,e=u,o=i,s=a,i=m,a=_}if(n!==$)throw new Error("invert: does not exist");return q(o,t)}function cc(r){let t=(r-$)/Qt,e,n,o;for(e=r-$,n=0;e%Qt===W;e/=Qt,n++);for(o=Qt;o<r&&ic(o,t,r)!==r-$;o++);if(n===1){let i=(r+$)/Hr;return function(f,b){let u=f.pow(b,i);if(!f.eql(f.sqr(u),b))throw new Error("Cannot find square root");return u}}let s=(e+$)/Qt;return function(a,f){if(a.pow(f,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let b=n,u=a.pow(a.mul(a.ONE,o),e),m=a.pow(f,s),_=a.pow(f,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let c=1;for(let l=a.sqr(_);c<b&&!a.eql(l,a.ONE);c++)l=a.sqr(l);let p=a.pow(u,$<<BigInt(b-c-1));u=a.sqr(p),m=a.mul(m,p),_=a.mul(_,u),b=c}return m}}function ac(r){if(r%Hr===nc){let t=(r+$)/Hr;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%po===lo){let t=(r-lo)/po;return function(n,o){let s=n.mul(o,Qt),i=n.pow(s,t),a=n.mul(o,i),f=n.mul(n.mul(a,Qt),i),b=n.mul(a,n.sub(f,n.ONE));if(!n.eql(n.sqr(b),o))throw new Error("Cannot find square root");return b}}return r%sc,cc(r)}var mo=(r,t)=>(q(r,t)&$)===$,fc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Kr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=fc.reduce((n,o)=>(n[o]="function",n),t);return bt(r,e)}function uc(r,t,e){if(e<W)throw new Error("Expected power > 0");if(e===W)return r.ONE;if(e===$)return t;let n=r.ONE,o=t;for(;e>W;)e&$&&(n=r.mul(n,o)),o=r.sqr(o),e>>=$;return n}function hc(r,t){let e=new Array(t.length),n=t.reduce((s,i,a)=>r.is0(i)?s:(e[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,a)=>r.is0(i)?s:(e[a]=r.mul(s,e[a]),r.mul(s,i)),o),e}function qr(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Pt(r,t,e=!1,n={}){if(r<=W)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=qr(r,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=ac(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Ie(o),ZERO:W,ONE:$,create:f=>q(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return W<=f&&f<r},is0:f=>f===W,isOdd:f=>(f&$)===$,neg:f=>q(-f,r),eql:(f,b)=>f===b,sqr:f=>q(f*f,r),add:(f,b)=>q(f+b,r),sub:(f,b)=>q(f-b,r),mul:(f,b)=>q(f*b,r),pow:(f,b)=>uc(a,f,b),div:(f,b)=>q(f*Ye(b,r),r),sqrN:f=>f*f,addN:(f,b)=>f+b,subN:(f,b)=>f-b,mulN:(f,b)=>f*b,inv:f=>Ye(f,r),sqrt:n.sqrt||(f=>i(a,f)),invertBatch:f=>hc(a,f),cmov:(f,b,u)=>u?b:f,toBytes:f=>e?Xt(f,s):Mt(f,s),fromBytes:f=>{if(f.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${f.length}`);return e?Dt(f):It(f)}});return Object.freeze(a)}function xo(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 Fr(r){let t=xo(r);return t+Math.ceil(t/2)}function go(r,t,e=!1){let n=r.length,o=xo(t),s=Fr(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=e?It(r):Dt(r),a=q(i,t-$)+$;return e?Xt(a,o):Mt(a,o)}var dc=BigInt(0),Vr=BigInt(1),$r=new WeakMap,bo=new WeakMap;function Xe(r,t){let e=(s,i)=>{let a=i.negate();return s?a:i},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},o=s=>{n(s);let i=Math.ceil(t/s)+1,a=2**(s-1);return{windows:i,windowSize:a}};return{constTimeNegate:e,unsafeLadder(s,i){let a=r.ZERO,f=s;for(;i>dc;)i&Vr&&(a=a.add(f)),f=f.double(),i>>=Vr;return a},precomputeWindow(s,i){let{windows:a,windowSize:f}=o(i),b=[],u=s,m=u;for(let _=0;_<a;_++){m=u,b.push(m);for(let c=1;c<f;c++)m=m.add(u),b.push(m);u=m.double()}return b},wNAF(s,i,a){let{windows:f,windowSize:b}=o(s),u=r.ZERO,m=r.BASE,_=BigInt(2**s-1),c=2**s,p=BigInt(s);for(let l=0;l<f;l++){let g=l*b,d=Number(a&_);a>>=p,d>b&&(d-=c,a+=Vr);let x=g,h=g+Math.abs(d)-1,y=l%2!==0,B=d<0;d===0?m=m.add(e(y,i[x])):u=u.add(e(B,i[h]))}return{p:u,f:m}},wNAFCached(s,i,a){let f=bo.get(s)||1,b=$r.get(s);return b||(b=this.precomputeWindow(s,f),f!==1&&$r.set(s,a(b))),this.wNAF(f,b,i)},setWindowSize(s,i){n(i),bo.set(s,i),$r.delete(s)}}}function We(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,m)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${m}`)}),e.forEach((u,m)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${m}`)});let o=Or(BigInt(e.length)),s=o>12?o-3:o>4?o-2:o?2:1,i=(1<<s)-1,a=new Array(i+1).fill(r.ZERO),f=Math.floor((t.BITS-1)/s)*s,b=r.ZERO;for(let u=f;u>=0;u-=s){a.fill(r.ZERO);for(let _=0;_<n.length;_++){let c=n[_],p=Number(c>>BigInt(u)&BigInt(i));a[p]=a[p].add(e[_])}let m=r.ZERO;for(let _=a.length-1,c=r.ZERO;_>0;_--)c=c.add(a[_]),m=m.add(c);if(b=b.add(m),u!==0)for(let _=0;_<s;_++)b=b.double()}return b}function Ae(r){return Kr(r.Fp),bt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...qr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var mt=BigInt(0),ft=BigInt(1),Qe=BigInt(2),pc=BigInt(8),mc={zip215:!0};function xc(r){let t=Ae(r);return bt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function wo(r){let t=xc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:f}=t,b=Qe<<BigInt(a*8)-ft,u=e.create,m=Pt(t.n,t.nBitLength),_=t.uvRatio||((S,E)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(E))}}catch{return{isValid:!1,value:mt}}}),c=t.adjustScalarBytes||(S=>S),p=t.domain||((S,E,A)=>{if(pt("phflag",A),E.length||A)throw new Error("Contexts/pre-hash are not supported");return S});function l(S,E){at("coordinate "+S,E,mt,b)}function g(S){if(!(S instanceof h))throw new Error("ExtendedPoint expected")}let d=Wt((S,E)=>{let{ex:A,ey:C,ez:U}=S,k=S.is0();E==null&&(E=k?pc:e.inv(U));let O=u(A*E),H=u(C*E),z=u(U*E);if(k)return{x:mt,y:ft};if(z!==ft)throw new Error("invZ was invalid");return{x:O,y:H}}),x=Wt(S=>{let{a:E,d:A}=t;if(S.is0())throw new Error("bad point: ZERO");let{ex:C,ey:U,ez:k,et:O}=S,H=u(C*C),z=u(U*U),K=u(k*k),F=u(K*K),Q=u(H*E),J=u(K*u(Q+z)),et=u(F+u(A*u(H*z)));if(J!==et)throw new Error("bad point: equation left != right (1)");let nt=u(C*U),Y=u(k*O);if(nt!==Y)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(E,A,C,U){this.ex=E,this.ey=A,this.ez=C,this.et=U,l("x",E),l("y",A),l("z",C),l("t",U),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(E){if(E instanceof h)throw new Error("extended point not allowed");let{x:A,y:C}=E||{};return l("x",A),l("y",C),new h(A,C,ft,u(A*C))}static normalizeZ(E){let A=e.invertBatch(E.map(C=>C.ez));return E.map((C,U)=>C.toAffine(A[U])).map(h.fromAffine)}static msm(E,A){return We(h,m,E,A)}_setWindowSize(E){I.setWindowSize(this,E)}assertValidity(){x(this)}equals(E){g(E);let{ex:A,ey:C,ez:U}=this,{ex:k,ey:O,ez:H}=E,z=u(A*H),K=u(k*U),F=u(C*H),Q=u(O*U);return z===K&&F===Q}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:E}=t,{ex:A,ey:C,ez:U}=this,k=u(A*A),O=u(C*C),H=u(Qe*u(U*U)),z=u(E*k),K=A+C,F=u(u(K*K)-k-O),Q=z+O,J=Q-H,et=z-O,nt=u(F*J),Y=u(Q*et),it=u(F*et),yt=u(J*Q);return new h(nt,Y,yt,it)}add(E){g(E);let{a:A,d:C}=t,{ex:U,ey:k,ez:O,et:H}=this,{ex:z,ey:K,ez:F,et:Q}=E;if(A===BigInt(-1)){let Nn=u((k-U)*(K+z)),Un=u((k+U)*(K-z)),wr=u(Un-Nn);if(wr===mt)return this.double();let kn=u(O*Qe*Q),Dn=u(H*Qe*F),Mn=Dn+kn,Pn=Un+Nn,On=Dn-kn,vs=u(Mn*wr),Is=u(Pn*On),As=u(Mn*On),Ts=u(wr*Pn);return new h(vs,Is,Ts,As)}let J=u(U*z),et=u(k*K),nt=u(H*C*Q),Y=u(O*F),it=u((U+k)*(z+K)-J-et),yt=Y-nt,me=Y+nt,xe=u(et-A*J),Es=u(it*yt),_s=u(me*xe),Ss=u(it*xe),Bs=u(yt*me);return new h(Es,_s,Bs,Ss)}subtract(E){return this.add(E.negate())}wNAF(E){return I.wNAFCached(this,E,h.normalizeZ)}multiply(E){let A=E;at("scalar",A,ft,n);let{p:C,f:U}=this.wNAF(A);return h.normalizeZ([C,U])[0]}multiplyUnsafe(E){let A=E;return at("scalar",A,mt,n),A===mt?B:this.equals(B)||A===ft?this:this.equals(y)?this.wNAF(A).p:I.unsafeLadder(this,A)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return I.unsafeLadder(this,n).is0()}toAffine(E){return d(this,E)}clearCofactor(){let{h:E}=t;return E===ft?this:this.multiplyUnsafe(E)}static fromHex(E,A=!1){let{d:C,a:U}=t,k=e.BYTES;E=j("pointHex",E,k),pt("zip215",A);let O=E.slice(),H=E[k-1];O[k-1]=H&-129;let z=Dt(O),K=A?b:e.ORDER;at("pointHex.y",z,mt,K);let F=u(z*z),Q=u(F-ft),J=u(C*F-U),{isValid:et,value:nt}=_(Q,J);if(!et)throw new Error("Point.fromHex: invalid y coordinate");let Y=(nt&ft)===ft,it=(H&128)!==0;if(!A&&nt===mt&&it)throw new Error("Point.fromHex: x=0 and x_0=1");return it!==Y&&(nt=u(-nt)),h.fromAffine({x:nt,y:z})}static fromPrivateKey(E){return R(E).point}toRawBytes(){let{x:E,y:A}=this.toAffine(),C=Xt(A,e.BYTES);return C[C.length-1]|=E&ft?128:0,C}toHex(){return vt(this.toRawBytes())}}h.BASE=new h(t.Gx,t.Gy,ft,u(t.Gx*t.Gy)),h.ZERO=new h(mt,ft,ft,mt);let{BASE:y,ZERO:B}=h,I=Xe(h,a*8);function w(S){return q(S,n)}function v(S){return w(Dt(S))}function R(S){let E=a;S=j("private key",S,E);let A=j("hashed private key",s(S),2*E),C=c(A.slice(0,E)),U=A.slice(E,2*E),k=v(C),O=y.multiply(k),H=O.toRawBytes();return{head:C,prefix:U,scalar:k,point:O,pointBytes:H}}function V(S){return R(S).pointBytes}function P(S=new Uint8Array,...E){let A=At(...E);return v(s(p(A,j("context",S),!!o)))}function M(S,E,A={}){S=j("message",S),o&&(S=o(S));let{prefix:C,scalar:U,pointBytes:k}=R(E),O=P(A.context,C,S),H=y.multiply(O).toRawBytes(),z=P(A.context,H,k,S),K=w(O+z*U);at("signature.s",K,mt,n);let F=At(H,Xt(K,e.BYTES));return j("result",F,a*2)}let N=mc;function T(S,E,A,C=N){let{context:U,zip215:k}=C,O=e.BYTES;S=j("signature",S,2*O),E=j("message",E),k!==void 0&&pt("zip215",k),o&&(E=o(E));let H=Dt(S.slice(O,2*O)),z,K,F;try{z=h.fromHex(A,k),K=h.fromHex(S.slice(0,O),k),F=y.multiplyUnsafe(H)}catch{return!1}if(!k&&z.isSmallOrder())return!1;let Q=P(U,K.toRawBytes(),z.toRawBytes(),E);return K.add(z.multiplyUnsafe(Q)).subtract(F).clearCofactor().equals(h.ZERO)}return y._setWindowSize(8),{CURVE:t,getPublicKey:V,sign:M,verify:T,ExtendedPoint:h,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>i(e.BYTES),precompute(S=8,E=h.BASE){return E._setWindowSize(S),E.multiply(BigInt(3)),E}}}}var Zr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),yo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ef=BigInt(0),gc=BigInt(1),Eo=BigInt(2),_f=BigInt(3),bc=BigInt(5),wc=BigInt(8);function yc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Zr,a=r*r%s*r%s,f=Z(a,Eo,s)*a%s,b=Z(f,gc,s)*r%s,u=Z(b,bc,s)*b%s,m=Z(u,t,s)*u%s,_=Z(m,e,s)*m%s,c=Z(_,n,s)*_%s,p=Z(c,o,s)*c%s,l=Z(p,o,s)*c%s,g=Z(l,t,s)*u%s;return{pow_p_5_8:Z(g,Eo,s)*r%s,b2:a}}function Ec(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function _c(r,t){let e=Zr,n=q(t*t*t,e),o=q(n*n*t,e),s=yc(r*o).pow_p_5_8,i=q(r*n*s,e),a=q(t*i*i,e),f=i,b=q(i*yo,e),u=a===r,m=a===q(-r,e),_=a===q(-r*yo,e);return u&&(i=f),(m||_)&&(i=b),mo(i,e)&&(i=q(-i,e)),{isValid:u||m,value:i}}var Sc=Pt(Zr,void 0,!0),Bc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Sc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:wc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:fo,randomBytes:$e,adjustScalarBytes:Ec,uvRatio:_c},_o=wo(Bc);var Je=32;function So(r,t,e){return _o.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var tr=class{type="Ed25519";raw;constructor(t){this.raw=Gr(t,Je)}toMultihash(){return _t.digest(er(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:St(this.raw,t.raw)}verify(t,e){return So(this.raw,e,t)}};function vo(r){return r=Gr(r,Je),new tr(r)}function Gr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ge(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Io(r=0){return new Uint8Array(r)}function Tt(r=0){return new Uint8Array(r)}var Ic=Math.pow(2,7),Ac=Math.pow(2,14),Tc=Math.pow(2,21),Ao=Math.pow(2,28),To=Math.pow(2,35),Ro=Math.pow(2,42),Lo=Math.pow(2,49),ot=128,Ot=127;function Te(r){if(r<Ic)return 1;if(r<Ac)return 2;if(r<Tc)return 3;if(r<Ao)return 4;if(r<To)return 5;if(r<Ro)return 6;if(r<Lo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Co(r,t,e=0){switch(Te(r)){case 8:t[e++]=r&255|ot,r/=128;case 7:t[e++]=r&255|ot,r/=128;case 6:t[e++]=r&255|ot,r/=128;case 5:t[e++]=r&255|ot,r/=128;case 4:t[e++]=r&255|ot,r>>>=7;case 3:t[e++]=r&255|ot,r>>>=7;case 2:t[e++]=r&255|ot,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function No(r,t){let e=r[t],n=0;if(n+=e&Ot,e<ot||(e=r[t+1],n+=(e&Ot)<<7,e<ot)||(e=r[t+2],n+=(e&Ot)<<14,e<ot)||(e=r[t+3],n+=(e&Ot)<<21,e<ot)||(e=r[t+4],n+=(e&Ot)*Ao,e<ot)||(e=r[t+5],n+=(e&Ot)*To,e<ot)||(e=r[t+6],n+=(e&Ot)*Ro,e<ot)||(e=r[t+7],n+=(e&Ot)*Lo,e<ot))return n;throw new RangeError("Could not decode varint")}var jr=new Float32Array([-0]),zt=new Uint8Array(jr.buffer);function Uo(r,t,e){jr[0]=r,t[e]=zt[0],t[e+1]=zt[1],t[e+2]=zt[2],t[e+3]=zt[3]}function ko(r,t){return zt[0]=r[t],zt[1]=r[t+1],zt[2]=r[t+2],zt[3]=r[t+3],jr[0]}var Yr=new Float64Array([-0]),rt=new Uint8Array(Yr.buffer);function Do(r,t,e){Yr[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3],t[e+4]=rt[4],t[e+5]=rt[5],t[e+6]=rt[6],t[e+7]=rt[7]}function Mo(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],rt[4]=r[t+4],rt[5]=r[t+5],rt[6]=r[t+6],rt[7]=r[t+7],Yr[0]}var Rc=BigInt(Number.MAX_SAFE_INTEGER),Lc=BigInt(Number.MIN_SAFE_INTEGER),ut=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 Jt;if(t<Rc&&t>Lc)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>Po&&(o=0n,++n>Po&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Jt;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):Jt}},Jt=new ut(0,0);Jt.toBigInt=function(){return 0n};Jt.zzEncode=Jt.zzDecode=function(){return this};Jt.length=function(){return 1};var Po=4294967296n;function Oo(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 zo(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&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 Xr(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 xt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function rr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Wr=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,xt(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 xt(this,4);return rr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xt(this,4);return rr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw xt(this,4);let t=ko(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw xt(this,4);let t=Mo(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 xt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return zo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw xt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw xt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ut(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 xt(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 xt(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 xt(this,8);let t=rr(this.buf,this.pos+=4),e=rr(this.buf,this.pos+=4);return new ut(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=No(this.buf,this.pos);return this.pos+=Te(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 Qr(r){return new Wr(r instanceof Uint8Array?r:r.subarray())}function nr(r,t,e){let n=Qr(r);return t.decode(n,void 0,e)}var Jr={};ct(Jr,{base10:()=>Cc});var Cc=Ct({prefix:"9",name:"base10",alphabet:"0123456789"});var tn={};ct(tn,{base16:()=>Nc,base16upper:()=>Uc});var Nc=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Uc=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var en={};ct(en,{base2:()=>kc});var kc=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rn={};ct(rn,{base256emoji:()=>zc});var Ko=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}"),Dc=Ko.reduce((r,t,e)=>(r[e]=t,r),[]),Mc=Ko.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Pc(r){return r.reduce((t,e)=>(t+=Dc[e],t),"")}function Oc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Mc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var zc=oe({prefix:"\u{1F680}",name:"base256emoji",encode:Pc,decode:Oc});var nn={};ct(nn,{base64:()=>Hc,base64pad:()=>Kc,base64url:()=>qc,base64urlpad:()=>Fc});var Hc=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Kc=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qc=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fc=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var on={};ct(on,{base8:()=>Vc});var Vc=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var sn={};ct(sn,{identity:()=>$c});var $c=oe({prefix:"\0",name:"identity",encode:r=>Fn(r),decode:r=>qn(r)});var su=new TextEncoder,iu=new TextDecoder;var fn={};ct(fn,{sha256:()=>Re,sha512:()=>jc});function an({name:r,code:t,encode:e}){return new cn(r,t,e)}var cn=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?$t(this.code,e):e.then(n=>$t(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Fo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=an({name:"sha2-256",code:18,encode:Fo("SHA-256")}),jc=an({name:"sha2-512",code:19,encode:Fo("SHA-512")});var un={...sn,...en,...on,...Jr,...tn,...Ir,...Ar,...vr,...nn,...rn},bu={...fn,...Lr};function $o(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Vo=$o("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),hn=$o("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=Tt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Yc={utf8:Vo,"utf-8":Vo,hex:un.base16,latin1:hn,ascii:hn,binary:hn,...un},or=Yc;function st(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function ln(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return Tt(i);o+i>t&&(n=Tt(t),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var te=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function dn(){}var mn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Xc=ln();function Wc(r){return globalThis.Buffer!=null?Tt(r):Xc(r)}var Ce=class{len;head;tail;states;constructor(){this.len=0,this.head=new te(dn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new te(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new xn((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(sr,10,ut.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ut.fromBigInt(t);return this._push(sr,e.length(),e)}uint64Number(t){return this._push(Co,Te(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=ut.fromBigInt(t).zzEncode();return this._push(sr,e.length(),e)}sint64Number(t){let e=ut.fromNumber(t).zzEncode();return this._push(sr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(pn,1,t?1:0)}fixed32(t){return this._push(Le,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ut.fromBigInt(t);return this._push(Le,4,e.lo)._push(Le,4,e.hi)}fixed64Number(t){let e=ut.fromNumber(t);return this._push(Le,4,e.lo)._push(Le,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(Uo,4,t)}double(t){return this._push(Do,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(pn,1,0):this.uint32(e)._push(Jc,e,t)}string(t){let e=Oo(t);return e!==0?this.uint32(e)._push(Xr,e,t):this._push(pn,1,0)}fork(){return this.states=new mn(this),this.head=this.tail=new te(dn,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 te(dn,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=Wc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function pn(r,t,e){t[e]=r&255}function Qc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var xn=class extends te{next;constructor(t,e){super(Qc,t,e),this.next=void 0}};function sr(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 Le(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 Jc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ce.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ta,t,r),this},Ce.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ea,t,r),this});function ta(r,t,e){t.set(r,e)}function ea(r,t,e){r.length<40?Xr(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(st(r),e)}function gn(){return new Ce}function ir(r,t){let e=gn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var pe;(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"})(pe||(pe={}));function cr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function bn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return cr("enum",pe.VARINT,e,n)}function ar(r,t){return cr("message",pe.LENGTH_DELIMITED,r,t)}var ht;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ht||(ht={}));var wn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(wn||(wn={}));(function(r){r.codec=()=>bn(wn)})(ht||(ht={}));var Ne;(function(r){let t;r.codec=()=>(t==null&&(t=ar((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.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 a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ir(e,r.codec()),r.decode=(e,n)=>nr(e,r.codec(),n)})(Ne||(Ne={}));var yn;(function(r){let t;r.codec=()=>(t==null&&(t=ar((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.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 a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ir(e,r.codec()),r.decode=(e,n)=>nr(e,r.codec(),n)})(yn||(yn={}));var na=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]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=new Uint32Array(64),En=class extends le{constructor(){super(64,32,8,!1),this.A=Ht[0]|0,this.B=Ht[1]|0,this.C=Ht[2]|0,this.D=Ht[3]|0,this.E=Ht[4]|0,this.F=Ht[5]|0,this.G=Ht[6]|0,this.H=Ht[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:f}=this;return[t,e,n,o,s,i,a,f]}set(t,e,n,o,s,i,a,f){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=a|0,this.H=f|0}process(t,e){for(let m=0;m<16;m++,e+=4)Kt[m]=t.getUint32(e,!1);for(let m=16;m<64;m++){let _=Kt[m-15],c=Kt[m-2],p=dt(_,7)^dt(_,18)^_>>>3,l=dt(c,17)^dt(c,19)^c>>>10;Kt[m]=l+Kt[m-7]+p+Kt[m-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:f,G:b,H:u}=this;for(let m=0;m<64;m++){let _=dt(a,6)^dt(a,11)^dt(a,25),c=u+_+io(a,f,b)+na[m]+Kt[m]|0,l=(dt(n,2)^dt(n,13)^dt(n,22))+co(n,o,s)|0;u=b,b=f,f=a,a=i+c|0,i=s,s=o,o=n,n=c+l|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,f=f+this.F|0,b=b+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,f,b,u)}roundClean(){Kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Zo=Ve(()=>new En);function fr(r,t="utf8"){let e=or[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ue=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var ur=class extends he{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,no(t);let n=Be(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 ue(this),this.iHash.update(t),this}digestInto(t){ue(this),fe(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:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},_n=(r,t,e)=>new ur(r,t).update(e).digest();_n.create=(r,t)=>new ur(r,t);function Go(r){r.lowS!==void 0&&pt("lowS",r.lowS),r.prehash!==void 0&&pt("prehash",r.prehash)}function oa(r){let t=Ae(r);bt(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("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("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:sa,hexToBytes:ia}=je,Rt={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=Rt;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=jt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?jt(o.length/2|128):"";return`${jt(r)}${s}${o}${t}`},decode(r,t){let{Err:e}=Rt,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 f=o&127;if(!f)throw new e("tlv.decode(long): indefinite length not supported");if(f>4)throw new e("tlv.decode(long): byte length is too big");let b=t.subarray(n,n+f);if(b.length!==f)throw new e("tlv.decode: length bytes not complete");if(b[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of b)i=i<<8|u;if(n+=f,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Rt;if(r<Lt)throw new t("integer: negative integers are not allowed");let e=jt(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=Rt;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 sa(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Rt,o=typeof r=="string"?ia(r):r;de(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("Invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:b,l:u}=n.decode(2,f);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(b)}},hexFromSig(r){let{_tlv:t,_int:e}=Rt,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},Lt=BigInt(0),tt=BigInt(1),ch=BigInt(2),jo=BigInt(3),ah=BigInt(4);function ca(r){let t=oa(r),{Fp:e}=t,n=Pt(t.n,t.nBitLength),o=t.toBytes||((l,g,d)=>{let x=g.toAffine();return At(Uint8Array.from([4]),e.toBytes(x.x),e.toBytes(x.y))}),s=t.fromBytes||(l=>{let g=l.subarray(1),d=e.fromBytes(g.subarray(0,e.BYTES)),x=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:d,y:x}});function i(l){let{a:g,b:d}=t,x=e.sqr(l),h=e.mul(x,l);return e.add(e.add(h,e.mul(l,g)),d)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function a(l){return ve(l,tt,t.n)}function f(l){let{allowedPrivateKeyLengths:g,nByteLength:d,wrapPrivateKey:x,n:h}=t;if(g&&typeof l!="bigint"){if(kt(l)&&(l=vt(l)),typeof l!="string"||!g.includes(l.length))throw new Error("Invalid key");l=l.padStart(d*2,"0")}let y;try{y=typeof l=="bigint"?l:It(j("private key",l,d))}catch{throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof l}`)}return x&&(y=q(y,h)),at("private key",y,tt,h),y}function b(l){if(!(l instanceof _))throw new Error("ProjectivePoint expected")}let u=Wt((l,g)=>{let{px:d,py:x,pz:h}=l;if(e.eql(h,e.ONE))return{x:d,y:x};let y=l.is0();g==null&&(g=y?e.ONE:e.inv(h));let B=e.mul(d,g),I=e.mul(x,g),w=e.mul(h,g);if(y)return{x:e.ZERO,y:e.ZERO};if(!e.eql(w,e.ONE))throw new Error("invZ was invalid");return{x:B,y:I}}),m=Wt(l=>{if(l.is0()){if(t.allowInfinityPoint&&!e.is0(l.py))return;throw new Error("bad point: ZERO")}let{x:g,y:d}=l.toAffine();if(!e.isValid(g)||!e.isValid(d))throw new Error("bad point: x or y not FE");let x=e.sqr(d),h=i(g);if(!e.eql(x,h))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class _{constructor(g,d,x){if(this.px=g,this.py=d,this.pz=x,g==null||!e.isValid(g))throw new Error("x required");if(d==null||!e.isValid(d))throw new Error("y required");if(x==null||!e.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:d,y:x}=g||{};if(!g||!e.isValid(d)||!e.isValid(x))throw new Error("invalid affine point");if(g instanceof _)throw new Error("projective point not allowed");let h=y=>e.eql(y,e.ZERO);return h(d)&&h(x)?_.ZERO:new _(d,x,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let d=e.invertBatch(g.map(x=>x.pz));return g.map((x,h)=>x.toAffine(d[h])).map(_.fromAffine)}static fromHex(g){let d=_.fromAffine(s(j("pointHex",g)));return d.assertValidity(),d}static fromPrivateKey(g){return _.BASE.multiply(f(g))}static msm(g,d){return We(_,n,g,d)}_setWindowSize(g){p.setWindowSize(this,g)}assertValidity(){m(this)}hasEvenY(){let{y:g}=this.toAffine();if(e.isOdd)return!e.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){b(g);let{px:d,py:x,pz:h}=this,{px:y,py:B,pz:I}=g,w=e.eql(e.mul(d,I),e.mul(y,h)),v=e.eql(e.mul(x,I),e.mul(B,h));return w&&v}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){let{a:g,b:d}=t,x=e.mul(d,jo),{px:h,py:y,pz:B}=this,I=e.ZERO,w=e.ZERO,v=e.ZERO,R=e.mul(h,h),V=e.mul(y,y),P=e.mul(B,B),M=e.mul(h,y);return M=e.add(M,M),v=e.mul(h,B),v=e.add(v,v),I=e.mul(g,v),w=e.mul(x,P),w=e.add(I,w),I=e.sub(V,w),w=e.add(V,w),w=e.mul(I,w),I=e.mul(M,I),v=e.mul(x,v),P=e.mul(g,P),M=e.sub(R,P),M=e.mul(g,M),M=e.add(M,v),v=e.add(R,R),R=e.add(v,R),R=e.add(R,P),R=e.mul(R,M),w=e.add(w,R),P=e.mul(y,B),P=e.add(P,P),R=e.mul(P,M),I=e.sub(I,R),v=e.mul(P,V),v=e.add(v,v),v=e.add(v,v),new _(I,w,v)}add(g){b(g);let{px:d,py:x,pz:h}=this,{px:y,py:B,pz:I}=g,w=e.ZERO,v=e.ZERO,R=e.ZERO,V=t.a,P=e.mul(t.b,jo),M=e.mul(d,y),N=e.mul(x,B),T=e.mul(h,I),L=e.add(d,x),S=e.add(y,B);L=e.mul(L,S),S=e.add(M,N),L=e.sub(L,S),S=e.add(d,h);let E=e.add(y,I);return S=e.mul(S,E),E=e.add(M,T),S=e.sub(S,E),E=e.add(x,h),w=e.add(B,I),E=e.mul(E,w),w=e.add(N,T),E=e.sub(E,w),R=e.mul(V,S),w=e.mul(P,T),R=e.add(w,R),w=e.sub(N,R),R=e.add(N,R),v=e.mul(w,R),N=e.add(M,M),N=e.add(N,M),T=e.mul(V,T),S=e.mul(P,S),N=e.add(N,T),T=e.sub(M,T),T=e.mul(V,T),S=e.add(S,T),M=e.mul(N,S),v=e.add(v,M),M=e.mul(E,S),w=e.mul(L,w),w=e.sub(w,M),M=e.mul(L,N),R=e.mul(E,R),R=e.add(R,M),new _(w,v,R)}subtract(g){return this.add(g.negate())}is0(){return this.equals(_.ZERO)}wNAF(g){return p.wNAFCached(this,g,_.normalizeZ)}multiplyUnsafe(g){at("scalar",g,Lt,t.n);let d=_.ZERO;if(g===Lt)return d;if(g===tt)return this;let{endo:x}=t;if(!x)return p.unsafeLadder(this,g);let{k1neg:h,k1:y,k2neg:B,k2:I}=x.splitScalar(g),w=d,v=d,R=this;for(;y>Lt||I>Lt;)y&tt&&(w=w.add(R)),I&tt&&(v=v.add(R)),R=R.double(),y>>=tt,I>>=tt;return h&&(w=w.negate()),B&&(v=v.negate()),v=new _(e.mul(v.px,x.beta),v.py,v.pz),w.add(v)}multiply(g){let{endo:d,n:x}=t;at("scalar",g,tt,x);let h,y;if(d){let{k1neg:B,k1:I,k2neg:w,k2:v}=d.splitScalar(g),{p:R,f:V}=this.wNAF(I),{p:P,f:M}=this.wNAF(v);R=p.constTimeNegate(B,R),P=p.constTimeNegate(w,P),P=new _(e.mul(P.px,d.beta),P.py,P.pz),h=R.add(P),y=V.add(M)}else{let{p:B,f:I}=this.wNAF(g);h=B,y=I}return _.normalizeZ([h,y])[0]}multiplyAndAddUnsafe(g,d,x){let h=_.BASE,y=(I,w)=>w===Lt||w===tt||!I.equals(h)?I.multiplyUnsafe(w):I.multiply(w),B=y(this,d).add(y(g,x));return B.is0()?void 0:B}toAffine(g){return u(this,g)}isTorsionFree(){let{h:g,isTorsionFree:d}=t;if(g===tt)return!0;if(d)return d(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:d}=t;return g===tt?this:d?d(_,this):this.multiplyUnsafe(t.h)}toRawBytes(g=!0){return pt("isCompressed",g),this.assertValidity(),o(_,this,g)}toHex(g=!0){return pt("isCompressed",g),vt(this.toRawBytes(g))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);let c=t.nBitLength,p=Xe(_,t.endo?Math.ceil(c/2):c);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:a}}function aa(r){let t=Ae(r);return bt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Yo(r){let t=aa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(T){return q(T,n)}function a(T){return Ye(T,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:b,weierstrassEquation:u,isWithinCurveOrder:m}=ca({...t,toBytes(T,L,S){let E=L.toAffine(),A=e.toBytes(E.x),C=At;return pt("isCompressed",S),S?C(Uint8Array.from([L.hasEvenY()?2:3]),A):C(Uint8Array.from([4]),A,e.toBytes(E.y))},fromBytes(T){let L=T.length,S=T[0],E=T.subarray(1);if(L===o&&(S===2||S===3)){let A=It(E);if(!ve(A,tt,e.ORDER))throw new Error("Point is not on curve");let C=u(A),U;try{U=e.sqrt(C)}catch(H){let z=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+z)}let k=(U&tt)===tt;return(S&1)===1!==k&&(U=e.neg(U)),{x:A,y:U}}else if(L===s&&S===4){let A=e.fromBytes(E.subarray(0,e.BYTES)),C=e.fromBytes(E.subarray(e.BYTES,2*e.BYTES));return{x:A,y:C}}else throw new Error(`Point of length ${L} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),_=T=>vt(Mt(T,t.nByteLength));function c(T){let L=n>>tt;return T>L}function p(T){return c(T)?i(-T):T}let l=(T,L,S)=>It(T.slice(L,S));class g{constructor(L,S,E){this.r=L,this.s=S,this.recovery=E,this.assertValidity()}static fromCompact(L){let S=t.nByteLength;return L=j("compactSignature",L,S*2),new g(l(L,0,S),l(L,S,2*S))}static fromDER(L){let{r:S,s:E}=Rt.toSig(j("DER",L));return new g(S,E)}assertValidity(){at("r",this.r,tt,n),at("s",this.s,tt,n)}addRecoveryBit(L){return new g(this.r,this.s,L)}recoverPublicKey(L){let{r:S,s:E,recovery:A}=this,C=I(j("msgHash",L));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");let U=A===2||A===3?S+t.n:S;if(U>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let k=A&1?"03":"02",O=f.fromHex(k+_(U)),H=a(U),z=i(-C*H),K=i(E*H),F=f.BASE.multiplyAndAddUnsafe(O,z,K);if(!F)throw new Error("point at infinify");return F.assertValidity(),F}hasHighS(){return c(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Yt(this.toDERHex())}toDERHex(){return Rt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Yt(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}let d={isValidPrivateKey(T){try{return b(T),!0}catch{return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{let T=Fr(t.n);return go(t.randomBytes(T),t.n)},precompute(T=8,L=f.BASE){return L._setWindowSize(T),L.multiply(BigInt(3)),L}};function x(T,L=!0){return f.fromPrivateKey(T).toRawBytes(L)}function h(T){let L=kt(T),S=typeof T=="string",E=(L||S)&&T.length;return L?E===o||E===s:S?E===2*o||E===2*s:T instanceof f}function y(T,L,S=!0){if(h(T))throw new Error("first arg must be private key");if(!h(L))throw new Error("second arg must be public key");return f.fromHex(L).multiply(b(T)).toRawBytes(S)}let B=t.bits2int||function(T){let L=It(T),S=T.length*8-t.nBitLength;return S>0?L>>BigInt(S):L},I=t.bits2int_modN||function(T){return i(B(T))},w=Ie(t.nBitLength);function v(T){return at(`num < 2^${t.nBitLength}`,T,Lt,w),Mt(T,t.nByteLength)}function R(T,L,S=V){if(["recovered","canonical"].some(J=>J in S))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:A}=t,{lowS:C,prehash:U,extraEntropy:k}=S;C==null&&(C=!0),T=j("msgHash",T),Go(S),U&&(T=j("prehashed msgHash",E(T)));let O=I(T),H=b(L),z=[v(H),v(O)];if(k!=null&&k!==!1){let J=k===!0?A(e.BYTES):k;z.push(j("extraEntropy",J))}let K=At(...z),F=O;function Q(J){let et=B(J);if(!m(et))return;let nt=a(et),Y=f.BASE.multiply(et).toAffine(),it=i(Y.x);if(it===Lt)return;let yt=i(nt*i(F+it*H));if(yt===Lt)return;let me=(Y.x===it?0:2)|Number(Y.y&tt),xe=yt;return C&&c(yt)&&(xe=p(yt),me^=1),new g(it,xe,me)}return{seed:K,k2sig:Q}}let V={lowS:t.lowS,prehash:!1},P={lowS:t.lowS,prehash:!1};function M(T,L,S=V){let{seed:E,k2sig:A}=R(T,L,S),C=t;return zr(C.hash.outputLen,C.nByteLength,C.hmac)(E,A)}f.BASE._setWindowSize(8);function N(T,L,S,E=P){let A=T;if(L=j("msgHash",L),S=j("publicKey",S),"strict"in E)throw new Error("options.strict was renamed to lowS");Go(E);let{lowS:C,prehash:U}=E,k,O;try{if(typeof A=="string"||kt(A))try{k=g.fromDER(A)}catch(Y){if(!(Y instanceof Rt.Err))throw Y;k=g.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){let{r:Y,s:it}=A;k=new g(Y,it)}else throw new Error("PARSE");O=f.fromHex(S)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&k.hasHighS())return!1;U&&(L=t.hash(L));let{r:H,s:z}=k,K=I(L),F=a(z),Q=i(K*F),J=i(H*F),et=f.BASE.multiplyAndAddUnsafe(O,Q,J)?.toAffine();return et?i(et.x)===H:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:y,sign:M,verify:N,ProjectivePoint:f,Signature:g,utils:d}}function fa(r){return{hash:r,hmac:(t,...e)=>_n(r,t,Cr(...e)),randomBytes:$e}}function Xo(r,t){let e=n=>Yo({...r,...fa(n)});return Object.freeze({...e(t),create:e})}var Jo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Wo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ua=BigInt(1),Sn=BigInt(2),Qo=(r,t)=>(r+t/Sn)/t;function ha(r){let t=Jo,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),f=BigInt(88),b=r*r*r%t,u=b*b*r%t,m=Z(u,e,t)*u%t,_=Z(m,e,t)*u%t,c=Z(_,Sn,t)*b%t,p=Z(c,o,t)*c%t,l=Z(p,s,t)*p%t,g=Z(l,a,t)*l%t,d=Z(g,f,t)*g%t,x=Z(d,a,t)*l%t,h=Z(x,e,t)*u%t,y=Z(h,i,t)*p%t,B=Z(y,n,t)*b%t,I=Z(B,Sn,t);if(!Bn.eql(Bn.sqr(I),r))throw new Error("Cannot find square root");return I}var Bn=Pt(Jo,void 0,void 0,{sqrt:ha}),ee=Xo({a:BigInt(0),b:BigInt(7),Fp:Bn,n:Wo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Wo,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ua*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=Qo(s*r,t),f=Qo(-n*r,t),b=q(r-a*e-f*o,t),u=q(-a*n-f*s,t),m=b>i,_=u>i;if(m&&(b=t-b),_&&(u=t-u),b>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:b,k2neg:_,k2:u}}}},Zo),gh=BigInt(0);var bh=ee.ProjectivePoint;function ts(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function es(r,t,e){let n=Re.digest(e instanceof Uint8Array?e:e.subarray());if(ts(n))return n.then(({digest:o})=>ee.verify(t,o,r)).catch(o=>{throw new Ue(String(o))});try{return ee.verify(t,n.digest,r)}catch(o){throw new Ue(String(o))}}var hr=class{type="secp256k1";raw;_key;constructor(t){this._key=ns(t),this.raw=rs(this._key)}toMultihash(){return _t.digest(er(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:St(this.raw,t.raw)}verify(t,e){return es(this._key,e,t)}};function os(r){return new hr(r)}function rs(r){return ee.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ns(r){try{return ee.ProjectivePoint.fromHex(r),r}catch(t){throw new He(String(t))}}function ss(r){let{Type:t,Data:e}=Ne.decode(r.digest),n=e??new Uint8Array;switch(t){case ht.Ed25519:return vo(n);case ht.secp256k1:return os(n);default:throw new be}}function er(r){return Ne.encode({Type:ht[r.type],Data:r.raw})}var is=Symbol.for("nodejs.util.inspect.custom"),la=114,ke=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()})`}[yr]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(la,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return St(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return St(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[is](){return`PeerId(${this.toString()})`}},lr=class extends ke{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},dr=class extends ke{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},pr=class extends ke{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},da=2336,mr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=_t.digest(st(this.url))}[is](){return`PeerId(${this.url})`}[yr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(da,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=fr(t)),t.toString()===this.toString())}};function cs(r){if(ma(r))return new lr({multihash:r});if(pa(r))try{let t=ss(r);if(t.type==="Ed25519")return new dr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new pr({multihash:r,publicKey:t})}catch{let e=fr(r.digest);return new mr(new URL(e))}throw new Ke("Supplied PeerID Multihash is invalid")}function pa(r){return r.code===_t.code}function ma(r){return r.code===Re.code}function wt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function xr(r){let t=_e(X.decode(`z${r}`));return cs(t)}var qt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return wt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return wt(this.map.values(),t=>t.key)}values(){return wt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function as(){return new qt}var Ft=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return wt(this.set.entries(),t=>{let e=xr(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=xr(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return wt(this.set.values(),t=>xr(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function fs(){return new Ft}var Vt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return wt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return wt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function us(){return new Vt}var vn=64,gt=class{fp;h;seed;constructor(t,e,n,o=2){if(o>vn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=Io(o);for(let a=0;a<i.length;a++)i[a]=s[a];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?St(this.fp,t.fp):!1}};function re(r,t){return Math.floor(Math.random()*(t-r))+r}var ne=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=re(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var In={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ps={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},ms=new globalThis.TextEncoder;function xa(r,t){let e=In[t],n=ps[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function ga(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=In[t],o=ps[t],s=r;for(;s.length>0;){let i=ms.encodeInto(s,e);s=s.slice(i.read);for(let a=0;a<i.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function An(r,{size:t=32,utf8Buffer:e}={}){if(!In[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return ga(r,t,e);r=ms.encode(r)}return xa(r,t)}var ba=ks(ds(),1);var Me={hash:r=>Number(An(r,{size:32})),hashV:(r,t)=>wa(Me.hash(r,t))};function wa(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),st(t,"base16")}var ya=500,Pe=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??Me,this.seed=t.seed??re(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new ne(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new ne(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[re(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new ne(this.bucketSize));for(let a=0;a<ya;a++){let f=this.buckets[i].swap(e);if(f!=null&&(i=(i^f.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new ne(this.bucketSize)),this.buckets[i].add(f)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Ea={1:.5,2:.84,4:.95,8:.98};function _a(r=.001){return r>.002?2:r>1e-5?4:8}function xs(r,t=.001){let e=_a(t),n=Ea[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),vn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var br=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??Me,this.seed=t.seed??re(0,Math.pow(2,10)),this.filterSeries=[new Pe({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=st(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Pe({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Tn(r,t=.001,e){return new br({...xs(r,t),...e??{}})}var Oe=class{filter;constructor(t,e){this.filter=Tn(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function gs(r,t=.001){return new Oe(r,t)}var Rn=class extends qt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function bs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Rn({name:t,metrics:e}):n=new qt,n}var Ln=class extends Ft{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function ws(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Ln({name:t,metrics:e}):n=new Ft,n}var Cn=class extends Vt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function ys(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Cn({name:t,metrics:e}):n=new Vt,n}return Ds(Sa);})();
|
2
|
+
"use strict";var Libp2PPeerCollections=(()=>{var ks=Object.create;var ze=Object.defineProperty;var Ms=Object.getOwnPropertyDescriptor;var Ds=Object.getOwnPropertyNames;var Os=Object.getPrototypeOf,Ps=Object.prototype.hasOwnProperty;var qn=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ct=(r,t)=>{for(var e in t)ze(r,e,{get:t[e],enumerable:!0})},Fn=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ds(t))!Ps.call(r,o)&&o!==e&&ze(r,o,{get:()=>t[o],enumerable:!(n=Ms(t,o))||n.enumerable});return r};var zs=(r,t,e)=>(e=r!=null?ks(Os(r)):{},Fn(t||!r||!r.__esModule?ze(e,"default",{value:r,enumerable:!0}):e,r)),Hs=r=>Fn(ze({},"__esModule",{value:!0}),r);var xs=qn((Me,wr)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(i){if(!Array.isArray(i)&&!ArrayBuffer.isView(i))return!1;for(var l=0;l<i.length;l++)if(!Number.isInteger(i[l])||i[l]<0||i[l]>255)return!1;return!0}function o(i,l){return(i&65535)*l+(((i>>>16)*l&65535)<<16)}function s(i,l){return i<<l|i>>>32-l}function c(i){return i^=i>>>16,i=o(i,2246822507),i^=i>>>13,i=o(i,3266489909),i^=i>>>16,i}function a(i,l){i=[i[0]>>>16,i[0]&65535,i[1]>>>16,i[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var d=[0,0,0,0];return d[3]+=i[3]+l[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=i[2]+l[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=i[1]+l[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=i[0]+l[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function f(i,l){i=[i[0]>>>16,i[0]&65535,i[1]>>>16,i[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var d=[0,0,0,0];return d[3]+=i[3]*l[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=i[2]*l[3],d[1]+=d[2]>>>16,d[2]&=65535,d[2]+=i[3]*l[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=i[1]*l[3],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=i[2]*l[2],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=i[3]*l[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=i[0]*l[3]+i[1]*l[2]+i[2]*l[1]+i[3]*l[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function y(i,l){return l%=64,l===32?[i[1],i[0]]:l<32?[i[0]<<l|i[1]>>>32-l,i[1]<<l|i[0]>>>32-l]:(l-=32,[i[1]<<l|i[0]>>>32-l,i[0]<<l|i[1]>>>32-l])}function h(i,l){return l%=64,l===0?i:l<32?[i[0]<<l|i[1]>>>32-l,i[1]<<l]:[i[1]<<l-32,0]}function g(i,l){return[i[0]^l[0],i[1]^l[1]]}function _(i){return i=g(i,[0,i[0]>>>1]),i=f(i,[4283543511,3981806797]),i=g(i,[0,i[0]>>>1]),i=f(i,[3301882366,444984403]),i=g(i,[0,i[0]>>>1]),i}e.x86.hash32=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%4,x=i.length-d,p=l,m=0,u=3432918353,E=461845907,B=0;B<x;B=B+4)m=i[B]|i[B+1]<<8|i[B+2]<<16|i[B+3]<<24,m=o(m,u),m=s(m,15),m=o(m,E),p^=m,p=s(p,13),p=o(p,5)+3864292196;switch(m=0,d){case 3:m^=i[B+2]<<16;case 2:m^=i[B+1]<<8;case 1:m^=i[B],m=o(m,u),m=s(m,15),m=o(m,E),p^=m}return p^=i.length,p=c(p),p>>>0},e.x86.hash128=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%16,x=i.length-d,p=l,m=l,u=l,E=l,B=0,A=0,b=0,I=0,R=597399067,K=2869860233,P=951274213,O=2716044179,N=0;N<x;N=N+16)B=i[N]|i[N+1]<<8|i[N+2]<<16|i[N+3]<<24,A=i[N+4]|i[N+5]<<8|i[N+6]<<16|i[N+7]<<24,b=i[N+8]|i[N+9]<<8|i[N+10]<<16|i[N+11]<<24,I=i[N+12]|i[N+13]<<8|i[N+14]<<16|i[N+15]<<24,B=o(B,R),B=s(B,15),B=o(B,K),p^=B,p=s(p,19),p+=m,p=o(p,5)+1444728091,A=o(A,K),A=s(A,16),A=o(A,P),m^=A,m=s(m,17),m+=u,m=o(m,5)+197830471,b=o(b,P),b=s(b,17),b=o(b,O),u^=b,u=s(u,15),u+=E,u=o(u,5)+2530024501,I=o(I,O),I=s(I,18),I=o(I,R),E^=I,E=s(E,13),E+=p,E=o(E,5)+850148119;switch(B=0,A=0,b=0,I=0,d){case 15:I^=i[N+14]<<16;case 14:I^=i[N+13]<<8;case 13:I^=i[N+12],I=o(I,O),I=s(I,18),I=o(I,R),E^=I;case 12:b^=i[N+11]<<24;case 11:b^=i[N+10]<<16;case 10:b^=i[N+9]<<8;case 9:b^=i[N+8],b=o(b,P),b=s(b,17),b=o(b,O),u^=b;case 8:A^=i[N+7]<<24;case 7:A^=i[N+6]<<16;case 6:A^=i[N+5]<<8;case 5:A^=i[N+4],A=o(A,K),A=s(A,16),A=o(A,P),m^=A;case 4:B^=i[N+3]<<24;case 3:B^=i[N+2]<<16;case 2:B^=i[N+1]<<8;case 1:B^=i[N],B=o(B,R),B=s(B,15),B=o(B,K),p^=B}return p^=i.length,m^=i.length,u^=i.length,E^=i.length,p+=m,p+=u,p+=E,m+=p,u+=p,E+=p,p=c(p),m=c(m),u=c(u),E=c(E),p+=m,p+=u,p+=E,m+=p,u+=p,E+=p,("00000000"+(p>>>0).toString(16)).slice(-8)+("00000000"+(m>>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)},e.x64.hash128=function(i,l){if(e.inputValidation&&!n(i))return t;l=l||0;for(var d=i.length%16,x=i.length-d,p=[0,l],m=[0,l],u=[0,0],E=[0,0],B=[2277735313,289559509],A=[1291169091,658871167],b=0;b<x;b=b+16)u=[i[b+4]|i[b+5]<<8|i[b+6]<<16|i[b+7]<<24,i[b]|i[b+1]<<8|i[b+2]<<16|i[b+3]<<24],E=[i[b+12]|i[b+13]<<8|i[b+14]<<16|i[b+15]<<24,i[b+8]|i[b+9]<<8|i[b+10]<<16|i[b+11]<<24],u=f(u,B),u=y(u,31),u=f(u,A),p=g(p,u),p=y(p,27),p=a(p,m),p=a(f(p,[0,5]),[0,1390208809]),E=f(E,A),E=y(E,33),E=f(E,B),m=g(m,E),m=y(m,31),m=a(m,p),m=a(f(m,[0,5]),[0,944331445]);switch(u=[0,0],E=[0,0],d){case 15:E=g(E,h([0,i[b+14]],48));case 14:E=g(E,h([0,i[b+13]],40));case 13:E=g(E,h([0,i[b+12]],32));case 12:E=g(E,h([0,i[b+11]],24));case 11:E=g(E,h([0,i[b+10]],16));case 10:E=g(E,h([0,i[b+9]],8));case 9:E=g(E,[0,i[b+8]]),E=f(E,A),E=y(E,33),E=f(E,B),m=g(m,E);case 8:u=g(u,h([0,i[b+7]],56));case 7:u=g(u,h([0,i[b+6]],48));case 6:u=g(u,h([0,i[b+5]],40));case 5:u=g(u,h([0,i[b+4]],32));case 4:u=g(u,h([0,i[b+3]],24));case 3:u=g(u,h([0,i[b+2]],16));case 2:u=g(u,h([0,i[b+1]],8));case 1:u=g(u,[0,i[b]]),u=f(u,B),u=y(u,31),u=f(u,A),p=g(p,u)}return p=g(p,[0,i.length]),m=g(m,[0,i.length]),p=a(p,m),m=a(m,p),p=_(p),m=_(m),p=a(p,m),m=a(m,p),("00000000"+(p[0]>>>0).toString(16)).slice(-8)+("00000000"+(p[1]>>>0).toString(16)).slice(-8)+("00000000"+(m[0]>>>0).toString(16)).slice(-8)+("00000000"+(m[1]>>>0).toString(16)).slice(-8)},typeof Me<"u"?(typeof wr<"u"&&wr.exports&&(Me=wr.exports=e),Me.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(Me)});var bs=qn((P0,gs)=>{gs.exports=xs()});var Ra={};ct(Ra,{PeerFilter:()=>Pe,PeerList:()=>Zt,PeerMap:()=>Ft,PeerSet:()=>Vt,peerFilter:()=>_s,peerList:()=>ms,peerMap:()=>ds,peerSet:()=>ps,trackedPeerList:()=>vs,trackedPeerMap:()=>Ss,trackedPeerSet:()=>Bs});var _r=Symbol.for("@libp2p/peer-id");var ge=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},He=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ke=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var be=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ir={};ct(Ir,{base58btc:()=>X,base58flickr:()=>Gs});var Ua=new Uint8Array(0);function Vn(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 _t(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 Zn(r){return new TextEncoder().encode(r)}function Gn(r){return new TextDecoder().decode(r)}function Ks(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),c=s.charCodeAt(0);if(e[c]!==255)throw new TypeError(s+" is ambiguous");e[c]=o}var a=r.length,f=r.charAt(0),y=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function g(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var d=0,x=0,p=0,m=l.length;p!==m&&l[p]===0;)p++,d++;for(var u=(m-p)*h+1>>>0,E=new Uint8Array(u);p!==m;){for(var B=l[p],A=0,b=u-1;(B!==0||A<x)&&b!==-1;b--,A++)B+=256*E[b]>>>0,E[b]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");x=A,p++}for(var I=u-x;I!==u&&E[I]===0;)I++;for(var R=f.repeat(d);I<u;++I)R+=r.charAt(E[I]);return R}function _(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var d=0;if(l[d]!==" "){for(var x=0,p=0;l[d]===f;)x++,d++;for(var m=(l.length-d)*y+1>>>0,u=new Uint8Array(m);l[d];){var E=e[l.charCodeAt(d)];if(E===255)return;for(var B=0,A=m-1;(E!==0||B<p)&&A!==-1;A--,B++)E+=a*u[A]>>>0,u[A]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");p=B,d++}if(l[d]!==" "){for(var b=m-p;b!==m&&u[b]===0;)b++;for(var I=new Uint8Array(x+(m-b)),R=x;b!==m;)I[R++]=u[b++];return I}}}function i(l){var d=_(l);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:_,decode:i}}var qs=Ks,Fs=qs,Yn=Fs;var Sr=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")}},Br=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 Xn(this,t)}},vr=class{decoders;constructor(t){this.decoders=t}or(t){return Xn(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 Xn(r,t){return new vr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ar=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 Sr(t,e,n),this.decoder=new Br(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function se({name:r,prefix:t,encode:e,decode:n}){return new Ar(r,t,e,n)}function Nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Yn(e,r);return se({prefix:t,name:r,encode:n,decode:s=>_t(o(s))})}function Vs(r,t,e,n){let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let s=r.length;for(;r[s-1]==="=";)--s;let c=new Uint8Array(s*e/8|0),a=0,f=0,y=0;for(let h=0;h<s;++h){let g=o[r[h]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<e|g,a+=e,a>=8&&(a-=8,c[y++]=255&f>>a)}if(a>=e||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return c}function Zs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",c=0,a=0;for(let f=0;f<r.length;++f)for(a=a<<8|r[f],c+=8;c>e;)c-=e,s+=t[o&a>>c];if(c!==0&&(s+=t[o&a<<e-c]),n)for(;s.length*e&7;)s+="=";return s}function Y({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return se({prefix:t,name:r,encode(o){return Zs(o,n,e)},decode(o){return Vs(o,n,e,r)}})}var X=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Gs=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Tr={};ct(Tr,{base32:()=>ie,base32hex:()=>Ws,base32hexpad:()=>Qs,base32hexpadupper:()=>Js,base32hexupper:()=>$s,base32pad:()=>Ys,base32padupper:()=>Xs,base32upper:()=>js,base32z:()=>ti});var ie=Y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),js=Y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ys=Y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xs=Y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ws=Y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$s=Y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qs=Y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Js=Y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ti=Y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Rr={};ct(Rr,{base36:()=>we,base36upper:()=>ei});var we=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ei=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ri=Qn,Wn=128,ni=127,oi=~ni,si=Math.pow(2,31);function Qn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=si;)t[e++]=r&255|Wn,r/=128;for(;r&oi;)t[e++]=r&255|Wn,r>>>=7;return t[e]=r|0,Qn.bytes=e-n+1,t}var ii=Cr,ci=128,$n=127;function Cr(r,n){var e=0,n=n||0,o=0,s=n,c,a=r.length;do{if(s>=a)throw Cr.bytes=0,new RangeError("Could not decode varint");c=r[s++],e+=o<28?(c&$n)<<o:(c&$n)*Math.pow(2,o),o+=7}while(c>=ci);return Cr.bytes=s-n,e}var ai=Math.pow(2,7),fi=Math.pow(2,14),ui=Math.pow(2,21),hi=Math.pow(2,28),li=Math.pow(2,35),di=Math.pow(2,42),pi=Math.pow(2,49),mi=Math.pow(2,56),xi=Math.pow(2,63),gi=function(r){return r<ai?1:r<fi?2:r<ui?3:r<hi?4:r<li?5:r<di?6:r<pi?7:r<mi?8:r<xi?9:10},bi={encode:ri,decode:ii,encodingLength:gi},wi=bi,ye=wi;function Ee(r,t=0){return[ye.decode(r,t),ye.decode.bytes]}function ce(r,t,e=0){return ye.encode(r,t,e),t}function ae(r){return ye.encodingLength(r)}function Gt(r,t){let e=t.byteLength,n=ae(r),o=n+ae(e),s=new Uint8Array(o+e);return ce(r,s,0),ce(e,s,n),s.set(t,o),new fe(r,e,t,s)}function _e(r){let t=_t(r),[e,n]=Ee(t),[o,s]=Ee(t.subarray(n)),c=t.subarray(n+s);if(c.byteLength!==o)throw new Error("Incorrect length");return new fe(e,o,c,t)}function Jn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Vn(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 to(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ei(e,Lr(r),t??X.encoder);default:return _i(e,Lr(r),t??ie.encoder)}}var eo=new WeakMap;function Lr(r){let t=eo.get(r);if(t==null){let e=new Map;return eo.set(r,e),e}return t}var lt=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!==Se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Si)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=Gt(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&&Jn(t.multihash,n.multihash)}toString(t){return to(this,t)}toJSON(){return{"/":to(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:c}=e;return new r(n,o,s,c??ro(n,o,s.bytes))}else if(e[Bi]===!0){let{version:n,multihash:o,code:s}=e,c=_e(o);return r.create(n,s,c)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Se)throw new Error(`Version 0 CID must use dag-pb (code: ${Se}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ro(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Se,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=_t(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),c=new fe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(c):r.createV1(e.codec,c),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[g,_]=Ee(t.subarray(e));return e+=_,g},o=n(),s=Se;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let c=e,a=n(),f=n(),y=e+f,h=y-c;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:h,size:y}}static parse(t,e){let[n,o]=yi(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 Lr(s).set(n,t),s}};function yi(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 ie.prefix:{let e=t??ie;return[ie.prefix,e.decode(r)]}case we.prefix:{let e=t??we;return[we.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 Ei(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 _i(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 Se=112,Si=18;function ro(r,t,e){let n=ae(r),o=n+ae(t),s=new Uint8Array(o+e.byteLength);return ce(r,s,0),ce(t,s,n),s.set(e,o),s}var Bi=Symbol.for("@ipld/js-cid/CID");var Nr={};ct(Nr,{identity:()=>St});var no=0,vi="identity",oo=_t;function Ai(r){return Gt(no,oo(r))}var St={code:no,name:vi,encode:oo,digest:Ai};function Bt(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 so(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ii(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ue(r,...t){if(!Ii(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 io(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");so(r.outputLen),so(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 co(r,t){ue(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Fe=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),dt=(r,t)=>r<<32-t|r>>>t;function ao(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Be(r){return typeof r=="string"&&(r=ao(r)),ue(r),r}function Ur(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ue(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 le=class{clone(){return this._cloneInto()}};function Ve(r){let t=n=>r().update(Be(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ze(r=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(r));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Ti(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),c=Number(e>>o&s),a=Number(e&s),f=n?4:0,y=n?0:4;r.setUint32(t+f,c,n),r.setUint32(t+y,a,n)}var fo=(r,t,e)=>r&t^~r&e,uo=(r,t,e)=>r&t^r&e^t&e,de=class extends le{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=Fe(this.buffer)}update(t){he(this);let{view:e,buffer:n,blockLen:o}=this;t=Be(t);let s=t.length;for(let c=0;c<s;){let a=Math.min(o-this.pos,s-c);if(a===o){let f=Fe(t);for(;o<=s-c;c+=o)this.process(f,c);continue}n.set(t.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){he(this),co(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:c}=this;e[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(n,0),c=0);for(let g=c;g<o;g++)e[g]=0;Ti(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=Fe(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let y=f/4,h=this.get();if(y>h.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g<y;g++)a.setUint32(4*g,h[g],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:c,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=c,o%e&&t.buffer.set(n),t}};var Ge=BigInt(4294967295),kr=BigInt(32);function ho(r,t=!1){return t?{h:Number(r&Ge),l:Number(r>>kr&Ge)}:{h:Number(r>>kr&Ge)|0,l:Number(r&Ge)|0}}function Ri(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:c}=ho(r[o],t);[e[o],n[o]]=[s,c]}return[e,n]}var Ci=(r,t)=>BigInt(r>>>0)<<kr|BigInt(t>>>0),Li=(r,t,e)=>r>>>e,Ni=(r,t,e)=>r<<32-e|t>>>e,Ui=(r,t,e)=>r>>>e|t<<32-e,ki=(r,t,e)=>r<<32-e|t>>>e,Mi=(r,t,e)=>r<<64-e|t>>>e-32,Di=(r,t,e)=>r>>>e-32|t<<64-e,Oi=(r,t)=>t,Pi=(r,t)=>r,zi=(r,t,e)=>r<<e|t>>>32-e,Hi=(r,t,e)=>t<<e|r>>>32-e,Ki=(r,t,e)=>t<<e-32|r>>>64-e,qi=(r,t,e)=>r<<e-32|t>>>64-e;function Fi(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Vi=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Zi=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Gi=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ji=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Yi=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Xi=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Wi={fromBig:ho,split:Ri,toBig:Ci,shrSH:Li,shrSL:Ni,rotrSH:Ui,rotrSL:ki,rotrBH:Mi,rotrBL:Di,rotr32H:Oi,rotr32L:Pi,rotlSH:zi,rotlSL:Hi,rotlBH:Ki,rotlBL:qi,add:Fi,add3L:Vi,add3H:Zi,add4L:Gi,add4H:ji,add5H:Xi,add5L:Yi},D=Wi;var[$i,Qi]=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))),Ut=new Uint32Array(80),kt=new Uint32Array(80),Mr=class extends de{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:c,Dh:a,Dl:f,Eh:y,El:h,Fh:g,Fl:_,Gh:i,Gl:l,Hh:d,Hl:x}=this;return[t,e,n,o,s,c,a,f,y,h,g,_,i,l,d,x]}set(t,e,n,o,s,c,a,f,y,h,g,_,i,l,d,x){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=c|0,this.Dh=a|0,this.Dl=f|0,this.Eh=y|0,this.El=h|0,this.Fh=g|0,this.Fl=_|0,this.Gh=i|0,this.Gl=l|0,this.Hh=d|0,this.Hl=x|0}process(t,e){for(let u=0;u<16;u++,e+=4)Ut[u]=t.getUint32(e),kt[u]=t.getUint32(e+=4);for(let u=16;u<80;u++){let E=Ut[u-15]|0,B=kt[u-15]|0,A=D.rotrSH(E,B,1)^D.rotrSH(E,B,8)^D.shrSH(E,B,7),b=D.rotrSL(E,B,1)^D.rotrSL(E,B,8)^D.shrSL(E,B,7),I=Ut[u-2]|0,R=kt[u-2]|0,K=D.rotrSH(I,R,19)^D.rotrBH(I,R,61)^D.shrSH(I,R,6),P=D.rotrSL(I,R,19)^D.rotrBL(I,R,61)^D.shrSL(I,R,6),O=D.add4L(b,P,kt[u-7],kt[u-16]),N=D.add4H(O,A,K,Ut[u-7],Ut[u-16]);Ut[u]=N|0,kt[u]=O|0}let{Ah:n,Al:o,Bh:s,Bl:c,Ch:a,Cl:f,Dh:y,Dl:h,Eh:g,El:_,Fh:i,Fl:l,Gh:d,Gl:x,Hh:p,Hl:m}=this;for(let u=0;u<80;u++){let E=D.rotrSH(g,_,14)^D.rotrSH(g,_,18)^D.rotrBH(g,_,41),B=D.rotrSL(g,_,14)^D.rotrSL(g,_,18)^D.rotrBL(g,_,41),A=g&i^~g&d,b=_&l^~_&x,I=D.add5L(m,B,b,Qi[u],kt[u]),R=D.add5H(I,p,E,A,$i[u],Ut[u]),K=I|0,P=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),O=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),N=n&s^n&a^s&a,T=o&c^o&f^c&f;p=d|0,m=x|0,d=i|0,x=l|0,i=g|0,l=_|0,{h:g,l:_}=D.add(y|0,h|0,R|0,K|0),y=a|0,h=f|0,a=s|0,f=c|0,s=n|0,c=o|0;let L=D.add3L(K,O,T);n=D.add3H(L,R,P,N),o=L|0}({h:n,l:o}=D.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:c}=D.add(this.Bh|0,this.Bl|0,s|0,c|0),{h:a,l:f}=D.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:y,l:h}=D.add(this.Dh|0,this.Dl|0,y|0,h|0),{h:g,l:_}=D.add(this.Eh|0,this.El|0,g|0,_|0),{h:i,l}=D.add(this.Fh|0,this.Fl|0,i|0,l|0),{h:d,l:x}=D.add(this.Gh|0,this.Gl|0,d|0,x|0),{h:p,l:m}=D.add(this.Hh|0,this.Hl|0,p|0,m|0),this.set(n,o,s,c,a,f,y,h,g,_,i,l,d,x,p,m)}roundClean(){Ut.fill(0),kt.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=Ve(()=>new Mr);var Xe={};ct(Xe,{aInRange:()=>at,abool:()=>pt,abytes:()=>pe,bitGet:()=>oc,bitLen:()=>zr,bitMask:()=>Ae,bitSet:()=>sc,bytesToHex:()=>At,bytesToNumberBE:()=>It,bytesToNumberLE:()=>Dt,concatBytes:()=>Tt,createHmacDrbg:()=>Hr,ensureBytes:()=>j,equalBytes:()=>rc,hexToBytes:()=>Wt,hexToNumber:()=>Pr,inRange:()=>ve,isBytes:()=>Mt,memoized:()=>Qt,notImplemented:()=>cc,numberToBytesBE:()=>Ot,numberToBytesLE:()=>$t,numberToHexUnpadded:()=>Xt,numberToVarBytesBE:()=>ec,utf8ToBytes:()=>nc,validateObject:()=>wt});var je=BigInt(0),Ye=BigInt(1),Ji=BigInt(2);function Mt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pe(r){if(!Mt(r))throw new Error("Uint8Array expected")}function pt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var tc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function At(r){pe(r);let t="";for(let e=0;e<r.length;e++)t+=tc[r[e]];return t}function Xt(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Pr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?je:BigInt("0x"+r)}var vt={_0:48,_9:57,A:65,F:70,a:97,f:102};function po(r){if(r>=vt._0&&r<=vt._9)return r-vt._0;if(r>=vt.A&&r<=vt.F)return r-(vt.A-10);if(r>=vt.a&&r<=vt.f)return r-(vt.a-10)}function Wt(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 c=po(r.charCodeAt(s)),a=po(r.charCodeAt(s+1));if(c===void 0||a===void 0){let f=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=c*16+a}return n}function It(r){return Pr(At(r))}function Dt(r){return pe(r),Pr(At(Uint8Array.from(r).reverse()))}function Ot(r,t){return Wt(r.toString(16).padStart(t*2,"0"))}function $t(r,t){return Ot(r,t).reverse()}function ec(r){return Wt(Xt(r))}function j(r,t,e){let n;if(typeof t=="string")try{n=Wt(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Mt(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 Tt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pe(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 rc(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 nc(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Dr=r=>typeof r=="bigint"&&je<=r;function ve(r,t,e){return Dr(r)&&Dr(t)&&Dr(e)&&t<=r&&r<e}function at(r,t,e,n){if(!ve(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function zr(r){let t;for(t=0;r>je;r>>=Ye,t+=1);return t}function oc(r,t){return r>>BigInt(t)&Ye}function sc(r,t,e){return r|(e?Ye:je)<<BigInt(t)}var Ae=r=>(Ji<<BigInt(r-1))-Ye,Or=r=>new Uint8Array(r),mo=r=>Uint8Array.from(r);function Hr(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=Or(r),o=Or(r),s=0,c=()=>{n.fill(1),o.fill(0),s=0},a=(...g)=>e(o,n,...g),f=(g=Or())=>{o=a(mo([0]),g),n=a(),g.length!==0&&(o=a(mo([1]),g),n=a())},y=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0,_=[];for(;g<t;){n=a();let i=n.slice();_.push(i),g+=n.length}return Tt(..._)};return(g,_)=>{c(),f(g);let i;for(;!(i=_(y()));)f();return c(),i}}var ic={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"||Mt(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 wt(r,t,e={}){let n=(o,s,c)=>{let a=ic[s];if(typeof a!="function")throw new Error("invalid validator function");let f=r[o];if(!(c&&f===void 0)&&!a(f,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+f)};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 cc=()=>{throw new Error("not implemented")};function Qt(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 W=BigInt(0),Z=BigInt(1),Jt=BigInt(2),ac=BigInt(3),Kr=BigInt(4),xo=BigInt(5),go=BigInt(8),fc=BigInt(9),uc=BigInt(16);function F(r,t){let e=r%t;return e>=W?e:t+e}function hc(r,t,e){if(t<W)throw new Error("invalid exponent, negatives unsupported");if(e<=W)throw new Error("invalid modulus");if(e===Z)return W;let n=Z;for(;t>W;)t&Z&&(n=n*r%e),r=r*r%e,t>>=Z;return n}function G(r,t,e){let n=r;for(;t-- >W;)n*=n,n%=e;return n}function We(r,t){if(r===W)throw new Error("invert: expected non-zero number");if(t<=W)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=W,s=Z,c=Z,a=W;for(;e!==W;){let y=n/e,h=n%e,g=o-c*y,_=s-a*y;n=e,e=h,o=c,s=a,c=g,a=_}if(n!==Z)throw new Error("invert: does not exist");return F(o,t)}function lc(r){let t=(r-Z)/Jt,e,n,o;for(e=r-Z,n=0;e%Jt===W;e/=Jt,n++);for(o=Jt;o<r&&hc(o,t,r)!==r-Z;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let c=(r+Z)/Kr;return function(f,y){let h=f.pow(y,c);if(!f.eql(f.sqr(h),y))throw new Error("Cannot find square root");return h}}let s=(e+Z)/Jt;return function(a,f){if(a.pow(f,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let y=n,h=a.pow(a.mul(a.ONE,o),e),g=a.pow(f,s),_=a.pow(f,e);for(;!a.eql(_,a.ONE);){if(a.eql(_,a.ZERO))return a.ZERO;let i=1;for(let d=a.sqr(_);i<y&&!a.eql(d,a.ONE);i++)d=a.sqr(d);let l=a.pow(h,Z<<BigInt(y-i-1));h=a.sqr(l),g=a.mul(g,l),_=a.mul(_,h),y=i}return g}}function dc(r){if(r%Kr===ac){let t=(r+Z)/Kr;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%go===xo){let t=(r-xo)/go;return function(n,o){let s=n.mul(o,Jt),c=n.pow(s,t),a=n.mul(o,c),f=n.mul(n.mul(a,Jt),c),y=n.mul(a,n.sub(f,n.ONE));if(!n.eql(n.sqr(y),o))throw new Error("Cannot find square root");return y}}return r%uc,lc(r)}var bo=(r,t)=>(F(r,t)&Z)===Z,pc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qr(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=pc.reduce((n,o)=>(n[o]="function",n),t);return wt(r,e)}function mc(r,t,e){if(e<W)throw new Error("invalid exponent, negatives unsupported");if(e===W)return r.ONE;if(e===Z)return t;let n=r.ONE,o=t;for(;e>W;)e&Z&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Z;return n}function xc(r,t){let e=new Array(t.length),n=t.reduce((s,c,a)=>r.is0(c)?s:(e[a]=s,r.mul(s,c)),r.ONE),o=r.inv(n);return t.reduceRight((s,c,a)=>r.is0(c)?s:(e[a]=r.mul(s,e[a]),r.mul(s,c)),o),e}function Fr(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Pt(r,t,e=!1,n={}){if(r<=W)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Fr(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Ae(o),ZERO:W,ONE:Z,create:f=>F(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return W<=f&&f<r},is0:f=>f===W,isOdd:f=>(f&Z)===Z,neg:f=>F(-f,r),eql:(f,y)=>f===y,sqr:f=>F(f*f,r),add:(f,y)=>F(f+y,r),sub:(f,y)=>F(f-y,r),mul:(f,y)=>F(f*y,r),pow:(f,y)=>mc(a,f,y),div:(f,y)=>F(f*We(y,r),r),sqrN:f=>f*f,addN:(f,y)=>f+y,subN:(f,y)=>f-y,mulN:(f,y)=>f*y,inv:f=>We(f,r),sqrt:n.sqrt||(f=>(c||(c=dc(r)),c(a,f))),invertBatch:f=>xc(a,f),cmov:(f,y,h)=>h?y:f,toBytes:f=>e?$t(f,s):Ot(f,s),fromBytes:f=>{if(f.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+f.length);return e?Dt(f):It(f)}});return Object.freeze(a)}function wo(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 Vr(r){let t=wo(r);return t+Math.ceil(t/2)}function yo(r,t,e=!1){let n=r.length,o=wo(t),s=Vr(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let c=e?It(r):Dt(r),a=F(c,t-Z)+Z;return e?$t(a,o):Ot(a,o)}var Eo=BigInt(0),$e=BigInt(1);function Zr(r,t){let e=t.negate();return r?e:t}function _o(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Gr(r,t){_o(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function bc(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 wc(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 jr=new WeakMap,So=new WeakMap;function Yr(r){return So.get(r)||1}function Qe(r,t){return{constTimeNegate:Zr,hasPrecomputes(e){return Yr(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Eo;)n&$e&&(o=o.add(s)),s=s.double(),n>>=$e;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Gr(n,t),c=[],a=e,f=a;for(let y=0;y<o;y++){f=a,c.push(f);for(let h=1;h<s;h++)f=f.add(a),c.push(f);a=f.double()}return c},wNAF(e,n,o){let{windows:s,windowSize:c}=Gr(e,t),a=r.ZERO,f=r.BASE,y=BigInt(2**e-1),h=2**e,g=BigInt(e);for(let _=0;_<s;_++){let i=_*c,l=Number(o&y);o>>=g,l>c&&(l-=h,o+=$e);let d=i,x=i+Math.abs(l)-1,p=_%2!==0,m=l<0;l===0?f=f.add(Zr(p,n[d])):a=a.add(Zr(m,n[x]))}return{p:a,f}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:c,windowSize:a}=Gr(e,t),f=BigInt(2**e-1),y=2**e,h=BigInt(e);for(let g=0;g<c;g++){let _=g*a;if(o===Eo)break;let i=Number(o&f);if(o>>=h,i>a&&(i-=y,o+=$e),i===0)continue;let l=n[_+Math.abs(i)-1];i<0&&(l=l.negate()),s=s.add(l)}return s},getPrecomputes(e,n,o){let s=jr.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&jr.set(n,o(s))),s},wNAFCached(e,n,o){let s=Yr(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let c=Yr(e);return c===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(c,this.getPrecomputes(c,e,o),n,s)},setWindowSize(e,n){_o(n,t),So.set(e,n),jr.delete(e)}}}function Je(r,t,e,n){if(bc(e,r),wc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=zr(BigInt(e.length)),c=s>12?s-3:s>4?s-2:s?2:1,a=(1<<c)-1,f=new Array(a+1).fill(o),y=Math.floor((t.BITS-1)/c)*c,h=o;for(let g=y;g>=0;g-=c){f.fill(o);for(let i=0;i<n.length;i++){let l=n[i],d=Number(l>>BigInt(g)&BigInt(a));f[d]=f[d].add(e[i])}let _=o;for(let i=f.length-1,l=o;i>0;i--)l=l.add(f[i]),_=_.add(l);if(h=h.add(_),g!==0)for(let i=0;i<c;i++)h=h.double()}return h}function Ie(r){return qr(r.Fp),wt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Fr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var mt=BigInt(0),ft=BigInt(1),tr=BigInt(2),yc=BigInt(8),Ec={zip215:!0};function _c(r){let t=Ie(r);return wt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Bo(r){let t=_c(r),{Fp:e,n,prehash:o,hash:s,randomBytes:c,nByteLength:a,h:f}=t,y=tr<<BigInt(a*8)-ft,h=e.create,g=Pt(t.n,t.nBitLength),_=t.uvRatio||((S,w)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(w))}}catch{return{isValid:!1,value:mt}}}),i=t.adjustScalarBytes||(S=>S),l=t.domain||((S,w,v)=>{if(pt("phflag",v),w.length||v)throw new Error("Contexts/pre-hash are not supported");return S});function d(S,w){at("coordinate "+S,w,mt,y)}function x(S){if(!(S instanceof u))throw new Error("ExtendedPoint expected")}let p=Qt((S,w)=>{let{ex:v,ey:C,ez:U}=S,k=S.is0();w==null&&(w=k?yc:e.inv(U));let z=h(v*w),H=h(C*w),M=h(U*w);if(k)return{x:mt,y:ft};if(M!==ft)throw new Error("invZ was invalid");return{x:z,y:H}}),m=Qt(S=>{let{a:w,d:v}=t;if(S.is0())throw new Error("bad point: ZERO");let{ex:C,ey:U,ez:k,et:z}=S,H=h(C*C),M=h(U*U),q=h(k*k),V=h(q*q),$=h(H*w),Q=h(q*h($+M)),tt=h(V+h(v*h(H*M)));if(Q!==tt)throw new Error("bad point: equation left != right (1)");let et=h(C*U),it=h(k*z);if(et!==it)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(w,v,C,U){this.ex=w,this.ey=v,this.ez=C,this.et=U,d("x",w),d("y",v),d("z",C),d("t",U),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof u)throw new Error("extended point not allowed");let{x:v,y:C}=w||{};return d("x",v),d("y",C),new u(v,C,ft,h(v*C))}static normalizeZ(w){let v=e.invertBatch(w.map(C=>C.ez));return w.map((C,U)=>C.toAffine(v[U])).map(u.fromAffine)}static msm(w,v){return Je(u,g,w,v)}_setWindowSize(w){A.setWindowSize(this,w)}assertValidity(){m(this)}equals(w){x(w);let{ex:v,ey:C,ez:U}=this,{ex:k,ey:z,ez:H}=w,M=h(v*H),q=h(k*U),V=h(C*H),$=h(z*U);return M===q&&V===$}is0(){return this.equals(u.ZERO)}negate(){return new u(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:w}=t,{ex:v,ey:C,ez:U}=this,k=h(v*v),z=h(C*C),H=h(tr*h(U*U)),M=h(w*k),q=v+C,V=h(h(q*q)-k-z),$=M+z,Q=$-H,tt=M-z,et=h(V*Q),it=h($*tt),nt=h(V*tt),bt=h(Q*$);return new u(et,it,bt,nt)}add(w){x(w);let{a:v,d:C}=t,{ex:U,ey:k,ez:z,et:H}=this,{ex:M,ey:q,ez:V,et:$}=w;if(v===BigInt(-1)){let Mn=h((k-U)*(q+M)),Dn=h((k+U)*(q-M)),Er=h(Dn-Mn);if(Er===mt)return this.double();let On=h(z*tr*$),Pn=h(H*tr*V),zn=Pn+On,Hn=Dn+Mn,Kn=Pn-On,Cs=h(zn*Er),Ls=h(Hn*Kn),Ns=h(zn*Kn),Us=h(Er*Hn);return new u(Cs,Ls,Us,Ns)}let Q=h(U*M),tt=h(k*q),et=h(H*C*$),it=h(z*V),nt=h((U+k)*(M+q)-Q-tt),bt=it-et,Et=it+et,xe=h(tt-v*Q),As=h(nt*bt),Is=h(Et*xe),Ts=h(nt*xe),Rs=h(bt*Et);return new u(As,Is,Rs,Ts)}subtract(w){return this.add(w.negate())}wNAF(w){return A.wNAFCached(this,w,u.normalizeZ)}multiply(w){let v=w;at("scalar",v,ft,n);let{p:C,f:U}=this.wNAF(v);return u.normalizeZ([C,U])[0]}multiplyUnsafe(w,v=u.ZERO){let C=w;return at("scalar",C,mt,n),C===mt?B:this.is0()||C===ft?this:A.wNAFCachedUnsafe(this,C,u.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return A.unsafeLadder(this,n).is0()}toAffine(w){return p(this,w)}clearCofactor(){let{h:w}=t;return w===ft?this:this.multiplyUnsafe(w)}static fromHex(w,v=!1){let{d:C,a:U}=t,k=e.BYTES;w=j("pointHex",w,k),pt("zip215",v);let z=w.slice(),H=w[k-1];z[k-1]=H&-129;let M=Dt(z),q=v?y:e.ORDER;at("pointHex.y",M,mt,q);let V=h(M*M),$=h(V-ft),Q=h(C*V-U),{isValid:tt,value:et}=_($,Q);if(!tt)throw new Error("Point.fromHex: invalid y coordinate");let it=(et&ft)===ft,nt=(H&128)!==0;if(!v&&et===mt&&nt)throw new Error("Point.fromHex: x=0 and x_0=1");return nt!==it&&(et=h(-et)),u.fromAffine({x:et,y:M})}static fromPrivateKey(w){return R(w).point}toRawBytes(){let{x:w,y:v}=this.toAffine(),C=$t(v,e.BYTES);return C[C.length-1]|=w&ft?128:0,C}toHex(){return At(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,ft,h(t.Gx*t.Gy)),u.ZERO=new u(mt,ft,ft,mt);let{BASE:E,ZERO:B}=u,A=Qe(u,a*8);function b(S){return F(S,n)}function I(S){return b(Dt(S))}function R(S){let w=e.BYTES;S=j("private key",S,w);let v=j("hashed private key",s(S),2*w),C=i(v.slice(0,w)),U=v.slice(w,2*w),k=I(C),z=E.multiply(k),H=z.toRawBytes();return{head:C,prefix:U,scalar:k,point:z,pointBytes:H}}function K(S){return R(S).pointBytes}function P(S=new Uint8Array,...w){let v=Tt(...w);return I(s(l(v,j("context",S),!!o)))}function O(S,w,v={}){S=j("message",S),o&&(S=o(S));let{prefix:C,scalar:U,pointBytes:k}=R(w),z=P(v.context,C,S),H=E.multiply(z).toRawBytes(),M=P(v.context,H,k,S),q=b(z+M*U);at("signature.s",q,mt,n);let V=Tt(H,$t(q,e.BYTES));return j("result",V,e.BYTES*2)}let N=Ec;function T(S,w,v,C=N){let{context:U,zip215:k}=C,z=e.BYTES;S=j("signature",S,2*z),w=j("message",w),v=j("publicKey",v,z),k!==void 0&&pt("zip215",k),o&&(w=o(w));let H=Dt(S.slice(z,2*z)),M,q,V;try{M=u.fromHex(v,k),q=u.fromHex(S.slice(0,z),k),V=E.multiplyUnsafe(H)}catch{return!1}if(!k&&M.isSmallOrder())return!1;let $=P(U,q.toRawBytes(),M.toRawBytes(),w);return q.add(M.multiplyUnsafe($)).subtract(V).clearCofactor().equals(u.ZERO)}return E._setWindowSize(8),{CURVE:t,getPublicKey:K,sign:O,verify:T,ExtendedPoint:u,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>c(e.BYTES),precompute(S=8,w=u.BASE){return w._setWindowSize(S),w.multiply(BigInt(3)),w}}}}var Xr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),vo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),vf=BigInt(0),Sc=BigInt(1),Ao=BigInt(2),Af=BigInt(3),Bc=BigInt(5),vc=BigInt(8);function Ac(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Xr,a=r*r%s*r%s,f=G(a,Ao,s)*a%s,y=G(f,Sc,s)*r%s,h=G(y,Bc,s)*y%s,g=G(h,t,s)*h%s,_=G(g,e,s)*g%s,i=G(_,n,s)*_%s,l=G(i,o,s)*i%s,d=G(l,o,s)*i%s,x=G(d,t,s)*h%s;return{pow_p_5_8:G(x,Ao,s)*r%s,b2:a}}function Ic(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Tc(r,t){let e=Xr,n=F(t*t*t,e),o=F(n*n*t,e),s=Ac(r*o).pow_p_5_8,c=F(r*n*s,e),a=F(t*c*c,e),f=c,y=F(c*vo,e),h=a===r,g=a===F(-r,e),_=a===F(-r*vo,e);return h&&(c=f),(g||_)&&(c=y),bo(c,e)&&(c=F(-c,e)),{isValid:h||g,value:c}}var Rc=Pt(Xr,void 0,!0),Cc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Rc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:vc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:lo,randomBytes:Ze,adjustScalarBytes:Ic,uvRatio:Tc},Io=Bo(Cc);var er=32;function To(r,t,e){return Io.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var rr=class{type="Ed25519";raw;constructor(t){this.raw=Wr(t,er)}toMultihash(){return St.digest(nr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,e){return To(this.raw,e,t)}};function Co(r){return r=Wr(r,er),new rr(r)}function Wr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ge(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Lo(r=0){return new Uint8Array(r)}function Rt(r=0){return new Uint8Array(r)}var Nc=Math.pow(2,7),Uc=Math.pow(2,14),kc=Math.pow(2,21),No=Math.pow(2,28),Uo=Math.pow(2,35),ko=Math.pow(2,42),Mo=Math.pow(2,49),ot=128,zt=127;function Te(r){if(r<Nc)return 1;if(r<Uc)return 2;if(r<kc)return 3;if(r<No)return 4;if(r<Uo)return 5;if(r<ko)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 Do(r,t,e=0){switch(Te(r)){case 8:t[e++]=r&255|ot,r/=128;case 7:t[e++]=r&255|ot,r/=128;case 6:t[e++]=r&255|ot,r/=128;case 5:t[e++]=r&255|ot,r/=128;case 4:t[e++]=r&255|ot,r>>>=7;case 3:t[e++]=r&255|ot,r>>>=7;case 2:t[e++]=r&255|ot,r>>>=7;case 1:{t[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&zt,e<ot||(e=r[t+1],n+=(e&zt)<<7,e<ot)||(e=r[t+2],n+=(e&zt)<<14,e<ot)||(e=r[t+3],n+=(e&zt)<<21,e<ot)||(e=r[t+4],n+=(e&zt)*No,e<ot)||(e=r[t+5],n+=(e&zt)*Uo,e<ot)||(e=r[t+6],n+=(e&zt)*ko,e<ot)||(e=r[t+7],n+=(e&zt)*Mo,e<ot))return n;throw new RangeError("Could not decode varint")}var $r=new Float32Array([-0]),Ht=new Uint8Array($r.buffer);function Po(r,t,e){$r[0]=r,t[e]=Ht[0],t[e+1]=Ht[1],t[e+2]=Ht[2],t[e+3]=Ht[3]}function zo(r,t){return Ht[0]=r[t],Ht[1]=r[t+1],Ht[2]=r[t+2],Ht[3]=r[t+3],$r[0]}var Qr=new Float64Array([-0]),rt=new Uint8Array(Qr.buffer);function Ho(r,t,e){Qr[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3],t[e+4]=rt[4],t[e+5]=rt[5],t[e+6]=rt[6],t[e+7]=rt[7]}function Ko(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],rt[4]=r[t+4],rt[5]=r[t+5],rt[6]=r[t+6],rt[7]=r[t+7],Qr[0]}var Mc=BigInt(Number.MAX_SAFE_INTEGER),Dc=BigInt(Number.MIN_SAFE_INTEGER),ut=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 te;if(t<Mc&&t>Dc)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>qo&&(o=0n,++n>qo&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return te;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):te}},te=new ut(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var qo=4294967296n;function Fo(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 Vo(r,t,e){if(e-t<1)return"";let o,s=[],c=0,a;for(;t<e;)a=r[t++],a<128?s[c++]=a:a>191&&a<224?s[c++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[c++]=55296+(a>>10),s[c++]=56320+(a&1023)):s[c++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,c>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),c=0);return o!=null?(c>0&&o.push(String.fromCharCode.apply(String,s.slice(0,c))),o.join("")):String.fromCharCode.apply(String,s.slice(0,c))}function Jr(r,t,e){let n=e,o,s;for(let c=0;c<r.length;++c)o=r.charCodeAt(c),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(c+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++c,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function xt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function or(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var tn=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,xt(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 xt(this,4);return or(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xt(this,4);return or(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw xt(this,4);let t=zo(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw xt(this,4);let t=Ko(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 xt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Vo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw xt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw xt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ut(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 xt(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 xt(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 xt(this,8);let t=or(this.buf,this.pos+=4),e=or(this.buf,this.pos+=4);return new ut(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+=Te(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 en(r){return new tn(r instanceof Uint8Array?r:r.subarray())}function sr(r,t,e){let n=en(r);return t.decode(n,void 0,e)}var rn={};ct(rn,{base10:()=>Oc});var Oc=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var nn={};ct(nn,{base16:()=>Pc,base16upper:()=>zc});var Pc=Y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zc=Y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var on={};ct(on,{base2:()=>Hc});var Hc=Y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sn={};ct(sn,{base256emoji:()=>Zc});var Go=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}"),Kc=Go.reduce((r,t,e)=>(r[e]=t,r),[]),qc=Go.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Fc(r){return r.reduce((t,e)=>(t+=Kc[e],t),"")}function Vc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=qc[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Zc=se({prefix:"\u{1F680}",name:"base256emoji",encode:Fc,decode:Vc});var cn={};ct(cn,{base64:()=>Gc,base64pad:()=>jc,base64url:()=>Yc,base64urlpad:()=>Xc});var Gc=Y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jc=Y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Yc=Y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xc=Y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var an={};ct(an,{base8:()=>Wc});var Wc=Y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fn={};ct(fn,{identity:()=>$c});var $c=se({prefix:"\0",name:"identity",encode:r=>Gn(r),decode:r=>Zn(r)});var fu=new TextEncoder,uu=new TextDecoder;var ln={};ct(ln,{sha256:()=>Re,sha512:()=>ta});function hn({name:r,code:t,encode:e}){return new un(r,t,e)}var un=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?Gt(this.code,e):e.then(n=>Gt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Yo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=hn({name:"sha2-256",code:18,encode:Yo("SHA-256")}),ta=hn({name:"sha2-512",code:19,encode:Yo("SHA-512")});var dn={...fn,...on,...an,...rn,...nn,...Tr,...Rr,...Ir,...cn,...sn},_u={...ln,...Nr};function Wo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Xo=Wo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),pn=Wo("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=Rt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ea={utf8:Xo,"utf-8":Xo,hex:dn.base16,latin1:pn,ascii:pn,binary:pn,...dn},ir=ea;function st(r,t="utf8"){let e=ir[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function mn(r){let t=r??8192,e=t>>>1,n,o=t;return function(c){if(c<1||c>e)return Rt(c);o+c>t&&(n=Rt(t),o=0);let a=n.subarray(o,o+=c);return o&7&&(o=(o|7)+1),a}}var ee=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function xn(){}var bn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ra=mn();function na(r){return globalThis.Buffer!=null?Rt(r):ra(r)}var Le=class{len;head;tail;states;constructor(){this.len=0,this.head=new ee(xn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ee(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new wn((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(cr,10,ut.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ut.fromBigInt(t);return this._push(cr,e.length(),e)}uint64Number(t){return this._push(Do,Te(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=ut.fromBigInt(t).zzEncode();return this._push(cr,e.length(),e)}sint64Number(t){let e=ut.fromNumber(t).zzEncode();return this._push(cr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(gn,1,t?1:0)}fixed32(t){return this._push(Ce,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ut.fromBigInt(t);return this._push(Ce,4,e.lo)._push(Ce,4,e.hi)}fixed64Number(t){let e=ut.fromNumber(t);return this._push(Ce,4,e.lo)._push(Ce,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(Po,4,t)}double(t){return this._push(Ho,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(gn,1,0):this.uint32(e)._push(sa,e,t)}string(t){let e=Fo(t);return e!==0?this.uint32(e)._push(Jr,e,t):this._push(gn,1,0)}fork(){return this.states=new bn(this),this.head=this.tail=new ee(xn,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 ee(xn,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=na(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function gn(r,t,e){t[e]=r&255}function oa(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var wn=class extends ee{next;constructor(t,e){super(oa,t,e),this.next=void 0}};function cr(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 Ce(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 sa(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Le.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ia,t,r),this},Le.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ca,t,r),this});function ia(r,t,e){t.set(r,e)}function ca(r,t,e){r.length<40?Jr(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(st(r),e)}function yn(){return new Le}function ar(r,t){let e=yn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var me;(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"})(me||(me={}));function fr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function En(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,c){let a=t(s);c.int32(a)},n=function(s){let c=s.int32();return t(c)};return fr("enum",me.VARINT,e,n)}function ur(r,t){return fr("message",me.LENGTH_DELIMITED,r,t)}var ht;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ht||(ht={}));var _n;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(_n||(_n={}));(function(r){r.codec=()=>En(_n)})(ht||(ht={}));var Ne;(function(r){let t;r.codec=()=>(t==null&&(t=ur((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.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={},c=n==null?e.len:e.pos+n;for(;e.pos<c;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ar(e,r.codec()),r.decode=(e,n)=>sr(e,r.codec(),n)})(Ne||(Ne={}));var Sn;(function(r){let t;r.codec=()=>(t==null&&(t=ur((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ht.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={},c=n==null?e.len:e.pos+n;for(;e.pos<c;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=ht.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ar(e,r.codec()),r.decode=(e,n)=>sr(e,r.codec(),n)})(Sn||(Sn={}));function hr(r,t="utf8"){let e=ir[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ue=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var fa=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]),Kt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qt=new Uint32Array(64),Bn=class extends de{constructor(){super(64,32,8,!1),this.A=Kt[0]|0,this.B=Kt[1]|0,this.C=Kt[2]|0,this.D=Kt[3]|0,this.E=Kt[4]|0,this.F=Kt[5]|0,this.G=Kt[6]|0,this.H=Kt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:c,G:a,H:f}=this;return[t,e,n,o,s,c,a,f]}set(t,e,n,o,s,c,a,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=c|0,this.G=a|0,this.H=f|0}process(t,e){for(let g=0;g<16;g++,e+=4)qt[g]=t.getUint32(e,!1);for(let g=16;g<64;g++){let _=qt[g-15],i=qt[g-2],l=dt(_,7)^dt(_,18)^_>>>3,d=dt(i,17)^dt(i,19)^i>>>10;qt[g]=d+qt[g-7]+l+qt[g-16]|0}let{A:n,B:o,C:s,D:c,E:a,F:f,G:y,H:h}=this;for(let g=0;g<64;g++){let _=dt(a,6)^dt(a,11)^dt(a,25),i=h+_+fo(a,f,y)+fa[g]+qt[g]|0,d=(dt(n,2)^dt(n,13)^dt(n,22))+uo(n,o,s)|0;h=y,y=f,f=a,a=c+i|0,c=s,s=o,o=n,n=i+d|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,c=c+this.D|0,a=a+this.E|0,f=f+this.F|0,y=y+this.G|0,h=h+this.H|0,this.set(n,o,s,c,a,f,y,h)}roundClean(){qt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var $o=Ve(()=>new Bn);var lr=class extends le{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,io(t);let n=Be(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 c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=t.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),s.fill(0)}update(t){return he(this),this.iHash.update(t),this}digestInto(t){he(this),ue(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:c,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=c,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},vn=(r,t,e)=>new lr(r,t).update(e).digest();vn.create=(r,t)=>new lr(r,t);function Qo(r){r.lowS!==void 0&&pt("lowS",r.lowS),r.prehash!==void 0&&pt("prehash",r.prehash)}function ua(r){let t=Ie(r);wt(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:ha,hexToBytes:la}=Xe,Ct={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=Ct;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=Xt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Xt(o.length/2|128):"";return Xt(r)+s+o+t},decode(r,t){let{Err:e}=Ct,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),c=0;if(!s)c=o;else{let f=o&127;if(!f)throw new e("tlv.decode(long): indefinite length not supported");if(f>4)throw new e("tlv.decode(long): byte length is too big");let y=t.subarray(n,n+f);if(y.length!==f)throw new e("tlv.decode: length bytes not complete");if(y[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let h of y)c=c<<8|h;if(n+=f,c<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+c);if(a.length!==c)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+c)}}},_int:{encode(r){let{Err:t}=Ct;if(r<Lt)throw new t("integer: negative integers are not allowed");let e=Xt(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}=Ct;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 ha(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ct,o=typeof r=="string"?la(r):r;pe(o);let{v:s,l:c}=n.decode(48,o);if(c.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:y,l:h}=n.decode(2,f);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(y)}},hexFromSig(r){let{_tlv:t,_int:e}=Ct,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Lt=BigInt(0),J=BigInt(1),hh=BigInt(2),Jo=BigInt(3),lh=BigInt(4);function da(r){let t=ua(r),{Fp:e}=t,n=Pt(t.n,t.nBitLength),o=t.toBytes||((d,x,p)=>{let m=x.toAffine();return Tt(Uint8Array.from([4]),e.toBytes(m.x),e.toBytes(m.y))}),s=t.fromBytes||(d=>{let x=d.subarray(1),p=e.fromBytes(x.subarray(0,e.BYTES)),m=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:p,y:m}});function c(d){let{a:x,b:p}=t,m=e.sqr(d),u=e.mul(m,d);return e.add(e.add(u,e.mul(d,x)),p)}if(!e.eql(e.sqr(t.Gy),c(t.Gx)))throw new Error("bad generator point: equation left != right");function a(d){return ve(d,J,t.n)}function f(d){let{allowedPrivateKeyLengths:x,nByteLength:p,wrapPrivateKey:m,n:u}=t;if(x&&typeof d!="bigint"){if(Mt(d)&&(d=At(d)),typeof d!="string"||!x.includes(d.length))throw new Error("invalid private key");d=d.padStart(p*2,"0")}let E;try{E=typeof d=="bigint"?d:It(j("private key",d,p))}catch{throw new Error("invalid private key, expected hex or "+p+" bytes, got "+typeof d)}return m&&(E=F(E,u)),at("private key",E,J,u),E}function y(d){if(!(d instanceof _))throw new Error("ProjectivePoint expected")}let h=Qt((d,x)=>{let{px:p,py:m,pz:u}=d;if(e.eql(u,e.ONE))return{x:p,y:m};let E=d.is0();x==null&&(x=E?e.ONE:e.inv(u));let B=e.mul(p,x),A=e.mul(m,x),b=e.mul(u,x);if(E)return{x:e.ZERO,y:e.ZERO};if(!e.eql(b,e.ONE))throw new Error("invZ was invalid");return{x:B,y:A}}),g=Qt(d=>{if(d.is0()){if(t.allowInfinityPoint&&!e.is0(d.py))return;throw new Error("bad point: ZERO")}let{x,y:p}=d.toAffine();if(!e.isValid(x)||!e.isValid(p))throw new Error("bad point: x or y not FE");let m=e.sqr(p),u=c(x);if(!e.eql(m,u))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class _{constructor(x,p,m){if(this.px=x,this.py=p,this.pz=m,x==null||!e.isValid(x))throw new Error("x required");if(p==null||!e.isValid(p))throw new Error("y required");if(m==null||!e.isValid(m))throw new Error("z required");Object.freeze(this)}static fromAffine(x){let{x:p,y:m}=x||{};if(!x||!e.isValid(p)||!e.isValid(m))throw new Error("invalid affine point");if(x instanceof _)throw new Error("projective point not allowed");let u=E=>e.eql(E,e.ZERO);return u(p)&&u(m)?_.ZERO:new _(p,m,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let p=e.invertBatch(x.map(m=>m.pz));return x.map((m,u)=>m.toAffine(p[u])).map(_.fromAffine)}static fromHex(x){let p=_.fromAffine(s(j("pointHex",x)));return p.assertValidity(),p}static fromPrivateKey(x){return _.BASE.multiply(f(x))}static msm(x,p){return Je(_,n,x,p)}_setWindowSize(x){l.setWindowSize(this,x)}assertValidity(){g(this)}hasEvenY(){let{y:x}=this.toAffine();if(e.isOdd)return!e.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){y(x);let{px:p,py:m,pz:u}=this,{px:E,py:B,pz:A}=x,b=e.eql(e.mul(p,A),e.mul(E,u)),I=e.eql(e.mul(m,A),e.mul(B,u));return b&&I}negate(){return new _(this.px,e.neg(this.py),this.pz)}double(){let{a:x,b:p}=t,m=e.mul(p,Jo),{px:u,py:E,pz:B}=this,A=e.ZERO,b=e.ZERO,I=e.ZERO,R=e.mul(u,u),K=e.mul(E,E),P=e.mul(B,B),O=e.mul(u,E);return O=e.add(O,O),I=e.mul(u,B),I=e.add(I,I),A=e.mul(x,I),b=e.mul(m,P),b=e.add(A,b),A=e.sub(K,b),b=e.add(K,b),b=e.mul(A,b),A=e.mul(O,A),I=e.mul(m,I),P=e.mul(x,P),O=e.sub(R,P),O=e.mul(x,O),O=e.add(O,I),I=e.add(R,R),R=e.add(I,R),R=e.add(R,P),R=e.mul(R,O),b=e.add(b,R),P=e.mul(E,B),P=e.add(P,P),R=e.mul(P,O),A=e.sub(A,R),I=e.mul(P,K),I=e.add(I,I),I=e.add(I,I),new _(A,b,I)}add(x){y(x);let{px:p,py:m,pz:u}=this,{px:E,py:B,pz:A}=x,b=e.ZERO,I=e.ZERO,R=e.ZERO,K=t.a,P=e.mul(t.b,Jo),O=e.mul(p,E),N=e.mul(m,B),T=e.mul(u,A),L=e.add(p,m),S=e.add(E,B);L=e.mul(L,S),S=e.add(O,N),L=e.sub(L,S),S=e.add(p,u);let w=e.add(E,A);return S=e.mul(S,w),w=e.add(O,T),S=e.sub(S,w),w=e.add(m,u),b=e.add(B,A),w=e.mul(w,b),b=e.add(N,T),w=e.sub(w,b),R=e.mul(K,S),b=e.mul(P,T),R=e.add(b,R),b=e.sub(N,R),R=e.add(N,R),I=e.mul(b,R),N=e.add(O,O),N=e.add(N,O),T=e.mul(K,T),S=e.mul(P,S),N=e.add(N,T),T=e.sub(O,T),T=e.mul(K,T),S=e.add(S,T),O=e.mul(N,S),I=e.add(I,O),O=e.mul(w,S),b=e.mul(L,b),b=e.sub(b,O),O=e.mul(L,N),R=e.mul(w,R),R=e.add(R,O),new _(b,I,R)}subtract(x){return this.add(x.negate())}is0(){return this.equals(_.ZERO)}wNAF(x){return l.wNAFCached(this,x,_.normalizeZ)}multiplyUnsafe(x){let{endo:p,n:m}=t;at("scalar",x,Lt,m);let u=_.ZERO;if(x===Lt)return u;if(this.is0()||x===J)return this;if(!p||l.hasPrecomputes(this))return l.wNAFCachedUnsafe(this,x,_.normalizeZ);let{k1neg:E,k1:B,k2neg:A,k2:b}=p.splitScalar(x),I=u,R=u,K=this;for(;B>Lt||b>Lt;)B&J&&(I=I.add(K)),b&J&&(R=R.add(K)),K=K.double(),B>>=J,b>>=J;return E&&(I=I.negate()),A&&(R=R.negate()),R=new _(e.mul(R.px,p.beta),R.py,R.pz),I.add(R)}multiply(x){let{endo:p,n:m}=t;at("scalar",x,J,m);let u,E;if(p){let{k1neg:B,k1:A,k2neg:b,k2:I}=p.splitScalar(x),{p:R,f:K}=this.wNAF(A),{p:P,f:O}=this.wNAF(I);R=l.constTimeNegate(B,R),P=l.constTimeNegate(b,P),P=new _(e.mul(P.px,p.beta),P.py,P.pz),u=R.add(P),E=K.add(O)}else{let{p:B,f:A}=this.wNAF(x);u=B,E=A}return _.normalizeZ([u,E])[0]}multiplyAndAddUnsafe(x,p,m){let u=_.BASE,E=(A,b)=>b===Lt||b===J||!A.equals(u)?A.multiplyUnsafe(b):A.multiply(b),B=E(this,p).add(E(x,m));return B.is0()?void 0:B}toAffine(x){return h(this,x)}isTorsionFree(){let{h:x,isTorsionFree:p}=t;if(x===J)return!0;if(p)return p(_,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:p}=t;return x===J?this:p?p(_,this):this.multiplyUnsafe(t.h)}toRawBytes(x=!0){return pt("isCompressed",x),this.assertValidity(),o(_,this,x)}toHex(x=!0){return pt("isCompressed",x),At(this.toRawBytes(x))}}_.BASE=new _(t.Gx,t.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO);let i=t.nBitLength,l=Qe(_,t.endo?Math.ceil(i/2):i);return{CURVE:t,ProjectivePoint:_,normPrivateKeyToScalar:f,weierstrassEquation:c,isWithinCurveOrder:a}}function pa(r){let t=Ie(r);return wt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ts(r){let t=pa(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function c(T){return F(T,n)}function a(T){return We(T,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:y,weierstrassEquation:h,isWithinCurveOrder:g}=da({...t,toBytes(T,L,S){let w=L.toAffine(),v=e.toBytes(w.x),C=Tt;return pt("isCompressed",S),S?C(Uint8Array.from([L.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,e.toBytes(w.y))},fromBytes(T){let L=T.length,S=T[0],w=T.subarray(1);if(L===o&&(S===2||S===3)){let v=It(w);if(!ve(v,J,e.ORDER))throw new Error("Point is not on curve");let C=h(v),U;try{U=e.sqrt(C)}catch(H){let M=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+M)}let k=(U&J)===J;return(S&1)===1!==k&&(U=e.neg(U)),{x:v,y:U}}else if(L===s&&S===4){let v=e.fromBytes(w.subarray(0,e.BYTES)),C=e.fromBytes(w.subarray(e.BYTES,2*e.BYTES));return{x:v,y:C}}else{let v=o,C=s;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+C+", got "+L)}}}),_=T=>At(Ot(T,t.nByteLength));function i(T){let L=n>>J;return T>L}function l(T){return i(T)?c(-T):T}let d=(T,L,S)=>It(T.slice(L,S));class x{constructor(L,S,w){this.r=L,this.s=S,this.recovery=w,this.assertValidity()}static fromCompact(L){let S=t.nByteLength;return L=j("compactSignature",L,S*2),new x(d(L,0,S),d(L,S,2*S))}static fromDER(L){let{r:S,s:w}=Ct.toSig(j("DER",L));return new x(S,w)}assertValidity(){at("r",this.r,J,n),at("s",this.s,J,n)}addRecoveryBit(L){return new x(this.r,this.s,L)}recoverPublicKey(L){let{r:S,s:w,recovery:v}=this,C=A(j("msgHash",L));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let U=v===2||v===3?S+t.n:S;if(U>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let k=v&1?"03":"02",z=f.fromHex(k+_(U)),H=a(U),M=c(-C*H),q=c(w*H),V=f.BASE.multiplyAndAddUnsafe(z,M,q);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return i(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Wt(this.toDERHex())}toDERHex(){return Ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Wt(this.toCompactHex())}toCompactHex(){return _(this.r)+_(this.s)}}let p={isValidPrivateKey(T){try{return y(T),!0}catch{return!1}},normPrivateKeyToScalar:y,randomPrivateKey:()=>{let T=Vr(t.n);return yo(t.randomBytes(T),t.n)},precompute(T=8,L=f.BASE){return L._setWindowSize(T),L.multiply(BigInt(3)),L}};function m(T,L=!0){return f.fromPrivateKey(T).toRawBytes(L)}function u(T){let L=Mt(T),S=typeof T=="string",w=(L||S)&&T.length;return L?w===o||w===s:S?w===2*o||w===2*s:T instanceof f}function E(T,L,S=!0){if(u(T))throw new Error("first arg must be private key");if(!u(L))throw new Error("second arg must be public key");return f.fromHex(L).multiply(y(T)).toRawBytes(S)}let B=t.bits2int||function(T){if(T.length>8192)throw new Error("input is too large");let L=It(T),S=T.length*8-t.nBitLength;return S>0?L>>BigInt(S):L},A=t.bits2int_modN||function(T){return c(B(T))},b=Ae(t.nBitLength);function I(T){return at("num < 2^"+t.nBitLength,T,Lt,b),Ot(T,t.nByteLength)}function R(T,L,S=K){if(["recovered","canonical"].some(Q=>Q in S))throw new Error("sign() legacy options not supported");let{hash:w,randomBytes:v}=t,{lowS:C,prehash:U,extraEntropy:k}=S;C==null&&(C=!0),T=j("msgHash",T),Qo(S),U&&(T=j("prehashed msgHash",w(T)));let z=A(T),H=y(L),M=[I(H),I(z)];if(k!=null&&k!==!1){let Q=k===!0?v(e.BYTES):k;M.push(j("extraEntropy",Q))}let q=Tt(...M),V=z;function $(Q){let tt=B(Q);if(!g(tt))return;let et=a(tt),it=f.BASE.multiply(tt).toAffine(),nt=c(it.x);if(nt===Lt)return;let bt=c(et*c(V+nt*H));if(bt===Lt)return;let Et=(it.x===nt?0:2)|Number(it.y&J),xe=bt;return C&&i(bt)&&(xe=l(bt),Et^=1),new x(nt,xe,Et)}return{seed:q,k2sig:$}}let K={lowS:t.lowS,prehash:!1},P={lowS:t.lowS,prehash:!1};function O(T,L,S=K){let{seed:w,k2sig:v}=R(T,L,S),C=t;return Hr(C.hash.outputLen,C.nByteLength,C.hmac)(w,v)}f.BASE._setWindowSize(8);function N(T,L,S,w=P){let v=T;L=j("msgHash",L),S=j("publicKey",S);let{lowS:C,prehash:U,format:k}=w;if(Qo(w),"strict"in w)throw new Error("options.strict was renamed to lowS");if(k!==void 0&&k!=="compact"&&k!=="der")throw new Error("format must be compact or der");let z=typeof v=="string"||Mt(v),H=!z&&!k&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!z&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,q;try{if(H&&(M=new x(v.r,v.s)),z){try{k!=="compact"&&(M=x.fromDER(v))}catch(Et){if(!(Et instanceof Ct.Err))throw Et}!M&&k!=="der"&&(M=x.fromCompact(v))}q=f.fromHex(S)}catch{return!1}if(!M||C&&M.hasHighS())return!1;U&&(L=t.hash(L));let{r:V,s:$}=M,Q=A(L),tt=a($),et=c(Q*tt),it=c(V*tt),nt=f.BASE.multiplyAndAddUnsafe(q,et,it)?.toAffine();return nt?c(nt.x)===V:!1}return{CURVE:t,getPublicKey:m,getSharedSecret:E,sign:O,verify:N,ProjectivePoint:f,Signature:x,utils:p}}function ma(r){return{hash:r,hmac:(t,...e)=>vn(r,t,Ur(...e)),randomBytes:Ze}}function es(r,t){let e=n=>ts({...r,...ma(n)});return Object.freeze({...e(t),create:e})}var os=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xa=BigInt(1),An=BigInt(2),ns=(r,t)=>(r+t/An)/t;function ga(r){let t=os,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),c=BigInt(23),a=BigInt(44),f=BigInt(88),y=r*r*r%t,h=y*y*r%t,g=G(h,e,t)*h%t,_=G(g,e,t)*h%t,i=G(_,An,t)*y%t,l=G(i,o,t)*i%t,d=G(l,s,t)*l%t,x=G(d,a,t)*d%t,p=G(x,f,t)*x%t,m=G(p,a,t)*d%t,u=G(m,e,t)*h%t,E=G(u,c,t)*l%t,B=G(E,n,t)*y%t,A=G(B,An,t);if(!In.eql(In.sqr(A),r))throw new Error("Cannot find square root");return A}var In=Pt(os,void 0,void 0,{sqrt:ga}),re=es({a:BigInt(0),b:BigInt(7),Fp:In,n:rs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=rs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,c=BigInt("0x100000000000000000000000000000000"),a=ns(s*r,t),f=ns(-n*r,t),y=F(r-a*e-f*o,t),h=F(-a*n-f*s,t),g=y>c,_=h>c;if(g&&(y=t-y),_&&(h=t-h),y>c||h>c)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:g,k1:y,k2neg:_,k2:h}}}},$o),Eh=BigInt(0);var _h=re.ProjectivePoint;function ss(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function is(r,t,e){let n=Re.digest(e instanceof Uint8Array?e:e.subarray());if(ss(n))return n.then(({digest:o})=>re.verify(t,o,r)).catch(o=>{throw new Ue(String(o))});try{return re.verify(t,n.digest,r)}catch(o){throw new Ue(String(o))}}var dr=class{type="secp256k1";raw;_key;constructor(t){this._key=as(t),this.raw=cs(this._key)}toMultihash(){return St.digest(nr(this))}toCID(){return lt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Bt(this.raw,t.raw)}verify(t,e){return is(this._key,e,t)}};function fs(r){return new dr(r)}function cs(r){return re.ProjectivePoint.fromHex(r).toRawBytes(!0)}function as(r){try{return re.ProjectivePoint.fromHex(r),r}catch(t){throw new He(String(t))}}function us(r){let{Type:t,Data:e}=Ne.decode(r.digest),n=e??new Uint8Array;switch(t){case ht.Ed25519:return Co(n);case ht.secp256k1:return fs(n);default:throw new be}}function nr(r){return Ne.encode({Type:ht[r.type],Data:r.raw})}var hs=Symbol.for("nodejs.util.inspect.custom"),ba=114,ke=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()})`}[_r]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return lt.createV1(ba,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[hs](){return`PeerId(${this.toString()})`}},pr=class extends ke{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},mr=class extends ke{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},xr=class extends ke{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},wa=2336,gr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=St.digest(st(this.url))}[hs](){return`PeerId(${this.url})`}[_r]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return lt.createV1(wa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=hr(t)),t.toString()===this.toString())}};function ls(r){if(Ea(r))return new pr({multihash:r});if(ya(r))try{let t=us(r);if(t.type==="Ed25519")return new mr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new xr({multihash:r,publicKey:t})}catch{let e=hr(r.digest);return new gr(new URL(e))}throw new Ke("Supplied PeerID Multihash is invalid")}function ya(r){return r.code===St.code}function Ea(r){return r.code===Re.code}function yt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function br(r){let t=_e(X.decode(`z${r}`));return ls(t)}var Ft=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return yt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return yt(this.map.values(),t=>t.key)}values(){return yt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function ds(){return new Ft}var Vt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return yt(this.set.entries(),t=>{let e=br(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=br(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return yt(this.set.values(),t=>br(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function ps(){return new Vt}var Zt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return yt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return yt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function ms(){return new Zt}var Tn=64,gt=class{fp;h;seed;constructor(t,e,n,o=2){if(o>Tn)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),c=Lo(o);for(let a=0;a<c.length;a++)c[a]=s[a];c.length===0&&(c[0]=7),this.fp=c,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?Bt(this.fp,t.fp):!1}};function ne(r,t){return Math.floor(Math.random()*(t-r))+r}var oe=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=ne(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof gt))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Rn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},ws={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},ys=new globalThis.TextEncoder;function _a(r,t){let e=Rn[t],n=ws[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Sa(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=Rn[t],o=ws[t],s=r;for(;s.length>0;){let c=ys.encodeInto(s,e);s=s.slice(c.read);for(let a=0;a<c.written;a++)o^=BigInt(e[a]),o=BigInt.asUintN(t,o*n)}return o}function Cn(r,{size:t=32,utf8Buffer:e}={}){if(!Rn[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Sa(r,t,e);r=ys.encode(r)}return _a(r,t)}var Ba=zs(bs(),1);var De={hash:r=>Number(Cn(r,{size:32})),hashV:(r,t)=>va(De.hash(r,t))};function va(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),st(t,"base16")}var Aa=500,Oe=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??De,this.seed=t.seed??ne(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new oe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new oe(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],c=s[ne(0,s.length-1)];this.buckets[c]==null&&(this.buckets[c]=new oe(this.bucketSize));for(let a=0;a<Aa;a++){let f=this.buckets[c].swap(e);if(f!=null&&(c=(c^f.hash())%this.filterSize,this.buckets[c]==null&&(this.buckets[c]=new oe(this.bucketSize)),this.buckets[c].add(f)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=st(t));let e=new gt(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,c=this.buckets[s]?.remove(e)??!1;return c&&this.count--,c}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Ia={1:.5,2:.84,4:.95,8:.98};function Ta(r=.001){return r>.002?2:r>1e-5?4:8}function Es(r,t=.001){let e=Ta(t),n=Ia[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),Tn);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var yr=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??De,this.seed=t.seed??ne(0,Math.pow(2,10)),this.filterSeries=[new Oe({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=st(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new Oe({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=st(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function Ln(r,t=.001,e){return new yr({...Es(r,t),...e??{}})}var Pe=class{filter;constructor(t,e){this.filter=Ln(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function _s(r,t=.001){return new Pe(r,t)}var Nn=class extends Ft{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Ss(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Nn({name:t,metrics:e}):n=new Ft,n}var Un=class extends Vt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Bs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Un({name:t,metrics:e}):n=new Vt,n}var kn=class extends Zt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function vs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new kn({name:t,metrics:e}):n=new Zt,n}return Hs(Ra);})();
|
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/peer-collections",
|
3
|
-
"version": "6.0.12-
|
3
|
+
"version": "6.0.12-98b43045c",
|
4
4
|
"description": "Stores values against a peer id",
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme",
|
@@ -54,13 +54,13 @@
|
|
54
54
|
"test:electron-main": "aegir test -t electron-main"
|
55
55
|
},
|
56
56
|
"dependencies": {
|
57
|
-
"@libp2p/interface": "2.2.1-
|
58
|
-
"@libp2p/peer-id": "5.0.8-
|
59
|
-
"@libp2p/utils": "6.2.1-
|
57
|
+
"@libp2p/interface": "2.2.1-98b43045c",
|
58
|
+
"@libp2p/peer-id": "5.0.8-98b43045c",
|
59
|
+
"@libp2p/utils": "6.2.1-98b43045c",
|
60
60
|
"multiformats": "^13.2.2"
|
61
61
|
},
|
62
62
|
"devDependencies": {
|
63
|
-
"@libp2p/crypto": "5.0.7-
|
63
|
+
"@libp2p/crypto": "5.0.7-98b43045c",
|
64
64
|
"@types/sinon": "^17.0.3",
|
65
65
|
"aegir": "^44.0.1",
|
66
66
|
"sinon": "^18.0.0",
|