@libp2p/peer-collections 6.0.34 → 6.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,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 Dr=Object.defineProperty;var ti=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ri=Object.prototype.hasOwnProperty;var nt=(r,t)=>{for(var e in t)Dr(r,e,{get:t[e],enumerable:!0})},ni=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ei(t))!ri.call(r,o)&&o!==e&&Dr(r,o,{get:()=>t[o],enumerable:!(n=ti(t,o))||n.enumerable});return r};var oi=r=>ni(Dr({},"__esModule",{value:!0}),r);var Mc={};nt(Mc,{PeerFilter:()=>Ze,PeerList:()=>Mt,PeerMap:()=>Rt,PeerSet:()=>Nt,peerFilter:()=>Ws,peerList:()=>Gs,peerMap:()=>Vs,peerSet:()=>js,trackedPeerList:()=>Qs,trackedPeerMap:()=>Xs,trackedPeerSet:()=>Js});var Ur=Symbol.for("@libp2p/peer-id");var Et=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ye=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var $e=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var we=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Nr={};nt(Nr,{base58btc:()=>F,base58flickr:()=>hi});var qc=new Uint8Array(0);function $n(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 Wn(r){return new TextEncoder().encode(r)}function Xn(r){return new TextDecoder().decode(r)}function si(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,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function h(_){if(_ instanceof Uint8Array||(ArrayBuffer.isView(_)?_=new Uint8Array(_.buffer,_.byteOffset,_.byteLength):Array.isArray(_)&&(_=Uint8Array.from(_))),!(_ instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(_.length===0)return"";for(var E=0,m=0,S=0,C=_.length;S!==C&&_[S]===0;)S++,E++;for(var v=(C-S)*f+1>>>0,U=new Uint8Array(v);S!==C;){for(var p=_[S],D=0,T=v-1;(p!==0||D<m)&&T!==-1;T--,D++)p+=256*U[T]>>>0,U[T]=p%a>>>0,p=p/a>>>0;if(p!==0)throw new Error("Non-zero carry");m=D,S++}for(var B=v-m;B!==v&&U[B]===0;)B++;for(var u=c.repeat(E);B<v;++B)u+=r.charAt(U[B]);return u}function x(_){if(typeof _!="string")throw new TypeError("Expected String");if(_.length===0)return new Uint8Array;var E=0;if(_[E]!==" "){for(var m=0,S=0;_[E]===c;)m++,E++;for(var C=(_.length-E)*l+1>>>0,v=new Uint8Array(C);_[E];){var U=e[_.charCodeAt(E)];if(U===255)return;for(var p=0,D=C-1;(U!==0||p<S)&&D!==-1;D--,p++)U+=a*v[D]>>>0,v[D]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");S=p,E++}if(_[E]!==" "){for(var T=C-S;T!==C&&v[T]===0;)T++;for(var B=new Uint8Array(m+(C-T)),u=m;T!==C;)B[u++]=v[T++];return B}}}function b(_){var E=x(_);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:x,decode:b}}var ii=si,ai=ii,Qn=ai;var Pr=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")}},kr=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 to(this,t)}},Kr=class{decoders;constructor(t){this.decoders=t}or(t){return to(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 to(r,t){return new Kr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Rr=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 Pr(t,e,n),this.decoder=new kr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ee({name:r,prefix:t,encode:e,decode:n}){return new Rr(r,t,e,n)}function Lt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Qn(e,r);return ee({prefix:t,name:r,encode:n,decode:s=>_t(o(s))})}function ci(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let f=t[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function fi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],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)!==0;)s+="=";return s}function ui(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=ui(n);return ee({prefix:t,name:r,encode(s){return fi(s,n,e)},decode(s){return ci(s,o,e,r)}})}var F=Lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hi=Lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mr={};nt(Mr,{base32:()=>re,base32hex:()=>mi,base32hexpad:()=>bi,base32hexpadupper:()=>xi,base32hexupper:()=>yi,base32pad:()=>di,base32padupper:()=>pi,base32upper:()=>li,base32z:()=>gi});var re=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),li=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),di=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),pi=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mi=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yi=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bi=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xi=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gi=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Or={};nt(Or,{base36:()=>Ee,base36upper:()=>wi});var Ee=Lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),wi=Lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ei=no,eo=128,_i=127,Si=~_i,Ai=Math.pow(2,31);function no(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ai;)t[e++]=r&255|eo,r/=128;for(;r&Si;)t[e++]=r&255|eo,r>>>=7;return t[e]=r|0,no.bytes=e-n+1,t}var vi=Hr,Bi=128,ro=127;function Hr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Hr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&ro)<<o:(i&ro)*Math.pow(2,o),o+=7}while(i>=Bi);return Hr.bytes=s-n,e}var Ii=Math.pow(2,7),Li=Math.pow(2,14),Ci=Math.pow(2,21),Ti=Math.pow(2,28),Di=Math.pow(2,35),Ui=Math.pow(2,42),Pi=Math.pow(2,49),ki=Math.pow(2,56),Ki=Math.pow(2,63),Ri=function(r){return r<Ii?1:r<Li?2:r<Ci?3:r<Ti?4:r<Di?5:r<Ui?6:r<Pi?7:r<ki?8:r<Ki?9:10},Ni={encode:Ei,decode:vi,encodingLength:Ri},Mi=Ni,_e=Mi;function Se(r,t=0){return[_e.decode(r,t),_e.decode.bytes]}function ne(r,t,e=0){return _e.encode(r,t,e),t}function oe(r){return _e.encodingLength(r)}function Ht(r,t){let e=t.byteLength,n=oe(r),o=n+oe(e),s=new Uint8Array(o+e);return ne(r,s,0),ne(e,s,n),s.set(t,o),new se(r,e,t,s)}function Ae(r){let t=_t(r),[e,n]=Se(t),[o,s]=Se(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new se(e,o,i,t)}function oo(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&$n(r.bytes,e.bytes)}}var se=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function so(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Hi(e,zr(r),t??F.encoder);default:return zi(e,zr(r),t??re.encoder)}}var io=new WeakMap;function zr(r){let t=io.get(r);if(t==null){let e=new Map;return io.set(r,e),e}return t}var rt=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!==ve)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==qi)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=Ht(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&&oo(t.multihash,n.multihash)}toString(t){return so(this,t)}toJSON(){return{"/":so(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??ao(n,o,s.bytes))}else if(e[Fi]===!0){let{version:n,multihash:o,code:s}=e,i=Ae(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!==ve)throw new Error(`Version 0 CID must use dag-pb (code: ${ve}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ao(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ve,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),i=new se(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[h,x]=Se(t.subarray(e));return e+=x,h},o=n(),s=ve;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(),c=n(),l=e+c,f=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(t,e){let[n,o]=Oi(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 zr(s).set(n,t),s}};function Oi(r,t){switch(r[0]){case"Q":{let e=t??F;return[F.prefix,e.decode(`${F.prefix}${r}`)]}case F.prefix:{let e=t??F;return[F.prefix,e.decode(r)]}case re.prefix:{let e=t??re;return[re.prefix,e.decode(r)]}case Ee.prefix:{let e=t??Ee;return[Ee.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 Hi(r,t,e){let{prefix:n}=e;if(n!==F.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 zi(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 ve=112,qi=18;function ao(r,t,e){let n=oe(r),o=n+oe(t),s=new Uint8Array(o+e.byteLength);return ne(r,s,0),ne(t,s,n),s.set(e,o),s}var Fi=Symbol.for("@ipld/js-cid/CID");var qr={};nt(qr,{identity:()=>ht});var co=0,Vi="identity",fo=_t;function ji(r){return Ht(co,fo(r))}var ht={code:co,name:Vi,encode:fo,digest:ji};function ot(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 lt(r=0){return new Uint8Array(r)}function st(r=0){return new Uint8Array(r)}function Xe(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=st(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ho=Symbol.for("@achingbrain/uint8arraylist");function uo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Je(r){return!!r?.[ho]}var it=class r{bufs;length;[ho]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Je(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Je(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=uo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=uo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Je(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Xe(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Xe(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,f=e>a&&e<=c;if(l&&f){if(t===a&&e===c){n.push(i);break}let h=t-a;n.push(i.subarray(h,h+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Je(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let h=e;h<=c;h+=f){f=0;for(let x=l;x>=0;x--){let b=this.get(h+x);if(n[x]!==b){f=Math.max(1,x-a[b]);break}}if(f===0)return h}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=st(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=st(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ot(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Fr={};nt(Fr,{base10:()=>Gi});var Gi=Lt({prefix:"9",name:"base10",alphabet:"0123456789"});var Vr={};nt(Vr,{base16:()=>Zi,base16upper:()=>Yi});var Zi=z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yi=z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var jr={};nt(jr,{base2:()=>$i});var $i=z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gr={};nt(Gr,{base256emoji:()=>ta});var lo=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}"),Wi=lo.reduce((r,t,e)=>(r[e]=t,r),[]),Xi=lo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Ji(r){return r.reduce((t,e)=>(t+=Wi[e],t),"")}function Qi(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Xi[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ta=ee({prefix:"\u{1F680}",name:"base256emoji",encode:Ji,decode:Qi});var Zr={};nt(Zr,{base64:()=>ea,base64pad:()=>ra,base64url:()=>na,base64urlpad:()=>oa});var ea=z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ra=z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),na=z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),oa=z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yr={};nt(Yr,{base8:()=>sa});var sa=z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $r={};nt($r,{identity:()=>ia});var ia=ee({prefix:"\0",name:"identity",encode:r=>Xn(r),decode:r=>Wn(r)});var Bf=new TextEncoder,If=new TextDecoder;var Jr={};nt(Jr,{sha256:()=>Be,sha512:()=>fa});function Xr({name:r,code:t,encode:e}){return new Wr(r,t,e)}var Wr=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?Ht(this.code,e):e.then(n=>Ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};function mo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Be=Xr({name:"sha2-256",code:18,encode:mo("SHA-256")}),fa=Xr({name:"sha2-512",code:19,encode:mo("SHA-512")});var Qr={...$r,...jr,...Yr,...Fr,...Vr,...Mr,...Or,...Nr,...Zr,...Gr},Of={...Jr,...qr};function bo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var yo=bo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),tn=bo("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=st(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ua={utf8:yo,"utf-8":yo,hex:Qr.base16,latin1:tn,ascii:tn,binary:tn,...Qr},Qe=ua;function G(r,t="utf8"){let e=Qe[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function ut(r,t="utf8"){let e=Qe[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var ha=parseInt("11111",2),en=parseInt("10000000",2),la=parseInt("01111111",2),xo={0:Ie,1:Ie,2:da,3:ya,4:ba,5:ma,6:pa,16:Ie,22:Ie,48:Ie};function rn(r,t={offset:0}){let e=r[t.offset]&ha;if(t.offset++,xo[e]!=null)return xo[e](r,t);throw new Error("No decoder for tag "+e)}function Le(r,t){let e=0;if((r[t.offset]&en)===en){let n=r[t.offset]&la,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Ie(r,t){Le(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=rn(r,t);if(n===null)break;e.push(n)}return e}function da(r,t){let e=Le(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function pa(r,t){let e=Le(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let f=0;for(let h=0;h<c.length;h++)f+=c[h]<<h*7;a+=`.${f}`,c=[]}}return a}function ma(r,t){return t.offset++,null}function ya(r,t){let e=Le(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function ba(r,t){let e=Le(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function xa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new it;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function nn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=xa(r.byteLength);return new it(Uint8Array.from([t.byteLength|en]),t)}function go(r){let t=new it,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new it(Uint8Array.from([2]),nn(t),t)}function wo(r){let t=Uint8Array.from([0]),e=new it(t,r);return new it(Uint8Array.from([3]),nn(e),e)}function tr(r,t=48){let e=new it;for(let n of r)e.append(n);return new it(Uint8Array.from([t]),nn(e),e)}async function Eo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var ga=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),wa=Uint8Array.from([6,5,43,129,4,0,34]),Ea=Uint8Array.from([6,5,43,129,4,0,35]),_a={ext:!0,kty:"EC",crv:"P-256"},Sa={ext:!0,kty:"EC",crv:"P-384"},Aa={ext:!0,kty:"EC",crv:"P-521"},on=32,sn=48,an=66;function _o(r){let t=rn(r);return So(t)}function So(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===on*2+1)return n=ut(t.subarray(e,e+on),"base64url"),o=ut(t.subarray(e+on),"base64url"),new ie({..._a,key_ops:["verify"],x:n,y:o});if(t.byteLength===sn*2+1)return n=ut(t.subarray(e,e+sn),"base64url"),o=ut(t.subarray(e+sn),"base64url"),new ie({...Sa,key_ops:["verify"],x:n,y:o});if(t.byteLength===an*2+1)return n=ut(t.subarray(e,e+an),"base64url"),o=ut(t.subarray(e+an),"base64url"),new ie({...Aa,key_ops:["verify"],x:n,y:o});throw new Et(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ao(r){return tr([go(Uint8Array.from([1])),tr([va(r.crv)],160),tr([wo(new it(Uint8Array.from([4]),G(r.x??"","base64url"),G(r.y??"","base64url")))],161)]).subarray()}function va(r){if(r==="P-256")return ga;if(r==="P-384")return wa;if(r==="P-521")return Ea;throw new Et(`Invalid curve ${r}`)}var ie=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ao(this.jwk)),this._raw}toMultihash(){return ht.digest(ae(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}async verify(t,e,n){return Eo(this.jwk,e,t,n)}};var qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function fe(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ce(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function W(r,...t){if(!fe(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 Bo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ce(r.outputLen),Ce(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 Io(r,t){W(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function At(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function er(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function dt(r,t){return r<<32-t|r>>>t}var Lo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ba=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function bt(r){if(W(r),Lo)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Ba[r[e]];return t}var St={_0:48,_9:57,A:65,F:70,a:97,f:102};function vo(r){if(r>=St._0&&r<=St._9)return r-St._0;if(r>=St.A&&r<=St.F)return r-(St.A-10);if(r>=St.a&&r<=St.f)return r-(St.a-10)}function he(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Lo)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=vo(r.charCodeAt(s)),a=vo(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Co(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Te(r){return typeof r=="string"&&(r=Co(r)),W(r),r}function at(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];W(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 ce=class{};function cn(r){let t=n=>r().update(Te(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function De(r=32){if(qt&&typeof qt.getRandomValues=="function")return qt.getRandomValues(new Uint8Array(r));if(qt&&typeof qt.randomBytes=="function")return Uint8Array.from(qt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Ia(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),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}function To(r,t,e){return r&t^~r&e}function Do(r,t,e){return r&t^r&e^t&e}var Ue=class extends ce{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=er(this.buffer)}update(t){ue(this),t=Te(t),W(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=er(t);for(;o<=s-i;i+=o)this.process(c,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),Io(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,At(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)e[h]=0;Ia(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=er(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,f[h],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.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},vt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Y=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var rr=BigInt(4294967295),Uo=BigInt(32);function La(r,t=!1){return t?{h:Number(r&rr),l:Number(r>>Uo&rr)}:{h:Number(r>>Uo&rr)|0,l:Number(r&rr)|0}}function Po(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=La(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var fn=(r,t,e)=>r>>>e,un=(r,t,e)=>r<<32-e|t>>>e,Ft=(r,t,e)=>r>>>e|t<<32-e,Vt=(r,t,e)=>r<<32-e|t>>>e,Pe=(r,t,e)=>r<<64-e|t>>>e-32,ke=(r,t,e)=>r>>>e-32|t<<64-e;function xt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ko=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ko=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ro=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),No=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Mo=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Oo=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Ta=Uint32Array.from([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]),Ct=new Uint32Array(64),hn=class extends Ue{constructor(t=32){super(64,t,8,!1),this.A=vt[0]|0,this.B=vt[1]|0,this.C=vt[2]|0,this.D=vt[3]|0,this.E=vt[4]|0,this.F=vt[5]|0,this.G=vt[6]|0,this.H=vt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){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=c|0}process(t,e){for(let h=0;h<16;h++,e+=4)Ct[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let x=Ct[h-15],b=Ct[h-2],_=dt(x,7)^dt(x,18)^x>>>3,E=dt(b,17)^dt(b,19)^b>>>10;Ct[h]=E+Ct[h-7]+_+Ct[h-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:l,H:f}=this;for(let h=0;h<64;h++){let x=dt(a,6)^dt(a,11)^dt(a,25),b=f+x+To(a,c,l)+Ta[h]+Ct[h]|0,E=(dt(n,2)^dt(n,13)^dt(n,22))+Do(n,o,s)|0;f=l,l=c,c=a,a=i+b|0,i=s,s=o,o=n,n=b+E|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,c=c+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,l,f)}roundClean(){At(Ct)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}};var Ho=Po(["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))),Da=Ho[0],Ua=Ho[1],Tt=new Uint32Array(80),Dt=new Uint32Array(80),ln=class extends Ue{constructor(t=64){super(128,t,16,!1),this.Ah=Y[0]|0,this.Al=Y[1]|0,this.Bh=Y[2]|0,this.Bl=Y[3]|0,this.Ch=Y[4]|0,this.Cl=Y[5]|0,this.Dh=Y[6]|0,this.Dl=Y[7]|0,this.Eh=Y[8]|0,this.El=Y[9]|0,this.Fh=Y[10]|0,this.Fl=Y[11]|0,this.Gh=Y[12]|0,this.Gl=Y[13]|0,this.Hh=Y[14]|0,this.Hl=Y[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:l,El:f,Fh:h,Fl:x,Gh:b,Gl:_,Hh:E,Hl:m}=this;return[t,e,n,o,s,i,a,c,l,f,h,x,b,_,E,m]}set(t,e,n,o,s,i,a,c,l,f,h,x,b,_,E,m){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=c|0,this.Eh=l|0,this.El=f|0,this.Fh=h|0,this.Fl=x|0,this.Gh=b|0,this.Gl=_|0,this.Hh=E|0,this.Hl=m|0}process(t,e){for(let v=0;v<16;v++,e+=4)Tt[v]=t.getUint32(e),Dt[v]=t.getUint32(e+=4);for(let v=16;v<80;v++){let U=Tt[v-15]|0,p=Dt[v-15]|0,D=Ft(U,p,1)^Ft(U,p,8)^fn(U,p,7),T=Vt(U,p,1)^Vt(U,p,8)^un(U,p,7),B=Tt[v-2]|0,u=Dt[v-2]|0,g=Ft(B,u,19)^Pe(B,u,61)^fn(B,u,6),d=Vt(B,u,19)^ke(B,u,61)^un(B,u,6),y=Ro(T,d,Dt[v-7],Dt[v-16]),w=No(y,D,g,Tt[v-7],Tt[v-16]);Tt[v]=w|0,Dt[v]=y|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:l,Dl:f,Eh:h,El:x,Fh:b,Fl:_,Gh:E,Gl:m,Hh:S,Hl:C}=this;for(let v=0;v<80;v++){let U=Ft(h,x,14)^Ft(h,x,18)^Pe(h,x,41),p=Vt(h,x,14)^Vt(h,x,18)^ke(h,x,41),D=h&b^~h&E,T=x&_^~x&m,B=Mo(C,p,T,Ua[v],Dt[v]),u=Oo(B,S,U,D,Da[v],Tt[v]),g=B|0,d=Ft(n,o,28)^Pe(n,o,34)^Pe(n,o,39),y=Vt(n,o,28)^ke(n,o,34)^ke(n,o,39),w=n&s^n&a^s&a,I=o&i^o&c^i&c;S=E|0,C=m|0,E=b|0,m=_|0,b=h|0,_=x|0,{h,l:x}=xt(l|0,f|0,u|0,g|0),l=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let A=ko(g,y,I);n=Ko(A,u,d,w),o=A|0}({h:n,l:o}=xt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=xt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=xt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=xt(this.Dh|0,this.Dl|0,l|0,f|0),{h,l:x}=xt(this.Eh|0,this.El|0,h|0,x|0),{h:b,l:_}=xt(this.Fh|0,this.Fl|0,b|0,_|0),{h:E,l:m}=xt(this.Gh|0,this.Gl|0,E|0,m|0),{h:S,l:C}=xt(this.Hh|0,this.Hl|0,S|0,C|0),this.set(n,o,s,i,a,c,l,f,h,x,b,_,E,m,S,C)}roundClean(){At(Tt,Dt)}destroy(){At(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var zo=cn(()=>new hn);var qo=cn(()=>new ln);var mn=BigInt(0),pn=BigInt(1);function Bt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Ke(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Fo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?mn:BigInt("0x"+r)}function le(r){return Fo(bt(r))}function jt(r){return W(r),Fo(bt(Uint8Array.from(r).reverse()))}function nr(r,t){return he(r.toString(16).padStart(t*2,"0"))}function de(r,t){return nr(r,t).reverse()}function M(r,t,e){let n;if(typeof t=="string")try{n=he(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(fe(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}var dn=r=>typeof r=="bigint"&&mn<=r;function Vo(r,t,e){return dn(r)&&dn(t)&&dn(e)&&t<=r&&r<e}function Ut(r,t,e,n){if(!Vo(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function jo(r){let t;for(t=0;r>mn;r>>=pn,t+=1);return t}var Gt=r=>(pn<<BigInt(r))-pn;function Go(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=b=>new Uint8Array(b),o=b=>Uint8Array.of(b),s=n(r),i=n(r),a=0,c=()=>{s.fill(1),i.fill(0),a=0},l=(...b)=>e(i,s,...b),f=(b=n(0))=>{i=l(o(0),b),s=l(),b.length!==0&&(i=l(o(1),b),s=l())},h=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let b=0,_=[];for(;b<t;){s=l();let E=s.slice();_.push(E),b+=s.length}return at(..._)};return(b,_)=>{c(),f(b);let E;for(;!(E=_(h()));)f();return c(),E}}function Pt(r,t,e={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(o,s,i){let a=r[o];if(i&&a===void 0)return;let c=typeof a;if(c!==s||a===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${c}`)}Object.entries(t).forEach(([o,s])=>n(o,s,!1)),Object.entries(e).forEach(([o,s])=>n(o,s,!0))}function pe(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 Q=BigInt(0),Z=BigInt(1),Zt=BigInt(2),Pa=BigInt(3),$o=BigInt(4),Wo=BigInt(5),Xo=BigInt(8);function H(r,t){let e=r%t;return e>=Q?e:t+e}function O(r,t,e){let n=r;for(;t-- >Q;)n*=n,n%=e;return n}function Zo(r,t){if(r===Q)throw new Error("invert: expected non-zero number");if(t<=Q)throw new Error("invert: expected positive modulus, got "+t);let e=H(r,t),n=t,o=Q,s=Z,i=Z,a=Q;for(;e!==Q;){let l=n/e,f=n%e,h=o-i*l,x=s-a*l;n=e,e=f,o=i,s=a,i=h,a=x}if(n!==Z)throw new Error("invert: does not exist");return H(o,t)}function Jo(r,t){let e=(r.ORDER+Z)/$o,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function ka(r,t){let e=(r.ORDER-Wo)/Xo,n=r.mul(t,Zt),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,Zt),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function Ka(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-Z,e=0;for(;t%Zt===Q;)t/=Zt,e++;let n=Zt,o=pt(r);for(;Yo(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Jo;let s=o.pow(n,t),i=(t+Z)/Zt;return function(c,l){if(c.is0(l))return l;if(Yo(c,l)!==1)throw new Error("Cannot find square root");let f=e,h=c.mul(c.ONE,s),x=c.pow(l,t),b=c.pow(l,i);for(;!c.eql(x,c.ONE);){if(c.is0(x))return c.ZERO;let _=1,E=c.sqr(x);for(;!c.eql(E,c.ONE);)if(_++,E=c.sqr(E),_===f)throw new Error("Cannot find square root");let m=Z<<BigInt(f-_-1),S=c.pow(h,m);f=_,h=c.sqr(S),x=c.mul(x,h),b=c.mul(b,S)}return b}}function Ra(r){return r%$o===Pa?Jo:r%Xo===Wo?ka:Ka(r)}var Qo=(r,t)=>(H(r,t)&Z)===Z,Na=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function yn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=Na.reduce((n,o)=>(n[o]="function",n),t);return Pt(r,e),r}function Ma(r,t,e){if(e<Q)throw new Error("invalid exponent, negatives unsupported");if(e===Q)return r.ONE;if(e===Z)return t;let n=r.ONE,o=t;for(;e>Q;)e&Z&&(n=r.mul(n,o)),o=r.sqr(o),e>>=Z;return n}function Re(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function Yo(r,t){let e=(r.ORDER-Z)/Zt,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function ts(r,t){t!==void 0&&Ce(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<=Q)throw new Error("invalid field: expected ORDER > 0, got "+r);let o,s;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(e=f.isLE)}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:i,nByteLength:a}=ts(r,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,l=Object.freeze({ORDER:r,isLE:e,BITS:i,BYTES:a,MASK:Gt(i),ZERO:Q,ONE:Z,create:f=>H(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return Q<=f&&f<r},is0:f=>f===Q,isValidNot0:f=>!l.is0(f)&&l.isValid(f),isOdd:f=>(f&Z)===Z,neg:f=>H(-f,r),eql:(f,h)=>f===h,sqr:f=>H(f*f,r),add:(f,h)=>H(f+h,r),sub:(f,h)=>H(f-h,r),mul:(f,h)=>H(f*h,r),pow:(f,h)=>Ma(l,f,h),div:(f,h)=>H(f*Zo(h,r),r),sqrN:f=>f*f,addN:(f,h)=>f+h,subN:(f,h)=>f-h,mulN:(f,h)=>f*h,inv:f=>Zo(f,r),sqrt:s||(f=>(c||(c=Ra(r)),c(l,f))),toBytes:f=>e?de(f,a):nr(f,a),fromBytes:f=>{if(f.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);return e?jt(f):le(f)},invertBatch:f=>Re(l,f),cmov:(f,h,x)=>x?h:f});return Object.freeze(l)}function es(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 bn(r){let t=es(r);return t+Math.ceil(t/2)}function rs(r,t,e=!1){let n=r.length,o=es(t),s=bn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?jt(r):le(r),a=H(i,t-Z)+Z;return e?de(a,o):nr(a,o)}var ye=BigInt(0),Yt=BigInt(1);function me(r,t){let e=t.negate();return r?e:t}function or(r,t,e){let n=t==="pz"?i=>i.pz:i=>i.ez,o=Re(r.Fp,e.map(n));return e.map((i,a)=>i.toAffine(o[a])).map(r.fromAffine)}function is(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function xn(r,t){is(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Gt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ns(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Yt);let l=t*n,f=l+Math.abs(a)-1,h=a===0,x=a<0,b=t%2!==0;return{nextN:c,offset:f,isZero:h,isNeg:x,isNegF:b,offsetF:l}}function Oa(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 Ha(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 gn=new WeakMap,as=new WeakMap;function wn(r){return as.get(r)||1}function os(r){if(r!==ye)throw new Error("invalid wNAF")}function sr(r,t){return{constTimeNegate:me,hasPrecomputes(e){return wn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>ye;)n&Yt&&(o=o.add(s)),s=s.double(),n>>=Yt;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=xn(n,t),i=[],a=e,c=a;for(let l=0;l<o;l++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=xn(e,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:f,isZero:h,isNeg:x,isNegF:b,offsetF:_}=ns(o,c,a);o=l,h?i=i.add(me(b,n[_])):s=s.add(me(x,n[f]))}return os(o),{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=xn(e,t);for(let a=0;a<i.windows&&o!==ye;a++){let{nextN:c,offset:l,isZero:f,isNeg:h}=ns(o,a,i);if(o=c,!f){let x=n[l];s=s.add(h?x.negate():x)}}return os(o),s},getPrecomputes(e,n,o){let s=gn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&(typeof o=="function"&&(s=o(s)),gn.set(n,s))),s},wNAFCached(e,n,o){let s=wn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=wn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){is(n,t),as.set(e,n),gn.delete(e)}}}function cs(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>ye||n>ye;)e&Yt&&(s=s.add(o)),n&Yt&&(i=i.add(o)),o=o.double(),e>>=Yt,n>>=Yt;return{p1:s,p2:i}}function ir(r,t,e,n){Oa(e,r),Ha(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=jo(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=Gt(c),f=new Array(Number(l)+1).fill(i),h=Math.floor((t.BITS-1)/c)*c,x=i;for(let b=h;b>=0;b-=c){f.fill(i);for(let E=0;E<s;E++){let m=n[E],S=Number(m>>BigInt(b)&l);f[S]=f[S].add(e[E])}let _=i;for(let E=f.length-1,m=i;E>0;E--)m=m.add(f[E]),_=_.add(m);if(x=x.add(_),b!==0)for(let E=0;E<c;E++)x=x.double()}return x}function ss(r,t){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return yn(t),t}else return pt(r)}function ar(r,t,e={}){if(!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>ye))throw new Error(`CURVE.${a} must be positive bigint`)}let n=ss(t.p,e.Fp),o=ss(t.n,e.Fn),i=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let a of i)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var gt=BigInt(0),tt=BigInt(1),En=BigInt(2),za=BigInt(8),qa={zip215:!0};function Fa(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),a=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,a)}function Va(r,t={}){let{Fp:e,Fn:n}=ar("edwards",r,t),{h:o,n:s}=r;Pt(t,{},{uvRatio:"function"});let i=En<<BigInt(n.BYTES*8)-tt,a=E=>e.create(E),c=t.uvRatio||((E,m)=>{try{return{isValid:!0,value:e.sqrt(e.div(E,m))}}catch{return{isValid:!1,value:gt}}});if(!Fa(e,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function l(E,m,S=!1){let C=S?tt:gt;return Ut("coordinate "+E,m,C,i),m}function f(E){if(!(E instanceof b))throw new Error("ExtendedPoint expected")}let h=pe((E,m)=>{let{ex:S,ey:C,ez:v}=E,U=E.is0();m==null&&(m=U?za:e.inv(v));let p=a(S*m),D=a(C*m),T=a(v*m);if(U)return{x:gt,y:tt};if(T!==tt)throw new Error("invZ was invalid");return{x:p,y:D}}),x=pe(E=>{let{a:m,d:S}=r;if(E.is0())throw new Error("bad point: ZERO");let{ex:C,ey:v,ez:U,et:p}=E,D=a(C*C),T=a(v*v),B=a(U*U),u=a(B*B),g=a(D*m),d=a(B*a(g+T)),y=a(u+a(S*a(D*T)));if(d!==y)throw new Error("bad point: equation left != right (1)");let w=a(C*v),I=a(U*p);if(w!==I)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(m,S,C,v){this.ex=l("x",m),this.ey=l("y",S),this.ez=l("z",C,!0),this.et=l("t",v),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof b)throw new Error("extended point not allowed");let{x:S,y:C}=m||{};return l("x",S),l("y",C),new b(S,C,tt,a(S*C))}static normalizeZ(m){return or(b,"ez",m)}static msm(m,S){return ir(b,n,m,S)}_setWindowSize(m){this.precompute(m)}precompute(m=8,S=!0){return _.setWindowSize(this,m),S||this.multiply(En),this}assertValidity(){x(this)}equals(m){f(m);let{ex:S,ey:C,ez:v}=this,{ex:U,ey:p,ez:D}=m,T=a(S*D),B=a(U*v),u=a(C*D),g=a(p*v);return T===B&&u===g}is0(){return this.equals(b.ZERO)}negate(){return new b(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:m}=r,{ex:S,ey:C,ez:v}=this,U=a(S*S),p=a(C*C),D=a(En*a(v*v)),T=a(m*U),B=S+C,u=a(a(B*B)-U-p),g=T+p,d=g-D,y=T-p,w=a(u*d),I=a(g*y),A=a(u*y),L=a(d*g);return new b(w,I,L,A)}add(m){f(m);let{a:S,d:C}=r,{ex:v,ey:U,ez:p,et:D}=this,{ex:T,ey:B,ez:u,et:g}=m,d=a(v*T),y=a(U*B),w=a(D*C*g),I=a(p*u),A=a((v+U)*(T+B)-d-y),L=I-w,k=I+w,P=a(y-S*d),q=a(A*L),R=a(k*P),K=a(A*P),V=a(L*k);return new b(q,R,V,K)}subtract(m){return this.add(m.negate())}multiply(m){let S=m;Ut("scalar",S,tt,s);let{p:C,f:v}=_.wNAFCached(this,S,b.normalizeZ);return b.normalizeZ([C,v])[0]}multiplyUnsafe(m,S=b.ZERO){let C=m;return Ut("scalar",C,gt,s),C===gt?b.ZERO:this.is0()||C===tt?this:_.wNAFCachedUnsafe(this,C,b.normalizeZ,S)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return _.wNAFCachedUnsafe(this,s).is0()}toAffine(m){return h(this,m)}clearCofactor(){return o===tt?this:this.multiplyUnsafe(o)}static fromBytes(m,S=!1){return W(m),this.fromHex(m,S)}static fromHex(m,S=!1){let{d:C,a:v}=r,U=e.BYTES;m=M("pointHex",m,U),Bt("zip215",S);let p=m.slice(),D=m[U-1];p[U-1]=D&-129;let T=jt(p),B=S?i:e.ORDER;Ut("pointHex.y",T,gt,B);let u=a(T*T),g=a(u-tt),d=a(C*u-v),{isValid:y,value:w}=c(g,d);if(!y)throw new Error("Point.fromHex: invalid y coordinate");let I=(w&tt)===tt,A=(D&128)!==0;if(!S&&w===gt&&A)throw new Error("Point.fromHex: x=0 and x_0=1");return A!==I&&(w=a(-w)),b.fromAffine({x:w,y:T})}static fromPrivateScalar(m){return b.BASE.multiply(m)}toBytes(){let{x:m,y:S}=this.toAffine(),C=de(S,e.BYTES);return C[C.length-1]|=m&tt?128:0,C}toRawBytes(){return this.toBytes()}toHex(){return bt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}b.BASE=new b(r.Gx,r.Gy,tt,a(r.Gx*r.Gy)),b.ZERO=new b(gt,tt,tt,gt),b.Fp=e,b.Fn=n;let _=sr(b,n.BYTES*8);return b}function ja(r,t){Pt(t,{hash:"function"},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:e,hash:n}=t,{BASE:o,Fp:s,Fn:i}=r,a=i.ORDER,c=t.randomBytes||De,l=t.adjustScalarBytes||(p=>p),f=t.domain||((p,D,T)=>{if(Bt("phflag",T),D.length||T)throw new Error("Contexts/pre-hash are not supported");return p});function h(p){return i.create(p)}function x(p){return h(jt(p))}function b(p){let D=s.BYTES;p=M("private key",p,D);let T=M("hashed private key",n(p),2*D),B=l(T.slice(0,D)),u=T.slice(D,2*D),g=x(B);return{head:B,prefix:u,scalar:g}}function _(p){let{head:D,prefix:T,scalar:B}=b(p),u=o.multiply(B),g=u.toBytes();return{head:D,prefix:T,scalar:B,point:u,pointBytes:g}}function E(p){return _(p).pointBytes}function m(p=Uint8Array.of(),...D){let T=at(...D);return x(n(f(T,M("context",p),!!e)))}function S(p,D,T={}){p=M("message",p),e&&(p=e(p));let{prefix:B,scalar:u,pointBytes:g}=_(D),d=m(T.context,B,p),y=o.multiply(d).toBytes(),w=m(T.context,y,g,p),I=h(d+w*u);Ut("signature.s",I,gt,a);let A=s.BYTES,L=at(y,de(I,A));return M("result",L,A*2)}let C=qa;function v(p,D,T,B=C){let{context:u,zip215:g}=B,d=s.BYTES;p=M("signature",p,2*d),D=M("message",D),T=M("publicKey",T,d),g!==void 0&&Bt("zip215",g),e&&(D=e(D));let y=jt(p.slice(d,2*d)),w,I,A;try{w=r.fromHex(T,g),I=r.fromHex(p.slice(0,d),g),A=o.multiplyUnsafe(y)}catch{return!1}if(!g&&w.isSmallOrder())return!1;let L=m(u,I.toBytes(),w.toBytes(),D);return I.add(w.multiplyUnsafe(L)).subtract(A).clearCofactor().is0()}return o.precompute(8),{getPublicKey:E,sign:S,verify:v,utils:{getExtendedPublicKey:_,randomPrivateKey:()=>c(s.BYTES),precompute(p=8,D=r.BASE){return D.precompute(p,!1)}},Point:r}}function Ga(r){let t={a:r.a,d:r.d,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=pt(t.n,r.nBitLength,!0),o={Fp:e,Fn:n,uvRatio:r.uvRatio},s={hash:r.hash,randomBytes:r.randomBytes,adjustScalarBytes:r.adjustScalarBytes,domain:r.domain,prehash:r.prehash,mapToCurve:r.mapToCurve};return{CURVE:t,curveOpts:o,eddsaOpts:s}}function Za(r,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:r})}function fs(r){let{CURVE:t,curveOpts:e,eddsaOpts:n}=Ga(r),o=Va(t,e),s=ja(o,n);return Za(r,s)}var Vu=BigInt(0),Ya=BigInt(1),us=BigInt(2),ju=BigInt(3),$a=BigInt(5),Wa=BigInt(8),cr={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Wa,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Xa(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=cr.p,a=r*r%s*r%s,c=O(a,us,s)*a%s,l=O(c,Ya,s)*r%s,f=O(l,$a,s)*l%s,h=O(f,t,s)*f%s,x=O(h,e,s)*h%s,b=O(x,n,s)*x%s,_=O(b,o,s)*b%s,E=O(_,o,s)*b%s,m=O(E,t,s)*f%s;return{pow_p_5_8:O(m,us,s)*r%s,b2:a}}function Ja(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var hs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Qa(r,t){let e=cr.p,n=H(t*t*t,e),o=H(n*n*t,e),s=Xa(r*o).pow_p_5_8,i=H(r*n*s,e),a=H(t*i*i,e),c=i,l=H(i*hs,e),f=a===r,h=a===H(-r,e),x=a===H(-r*hs,e);return f&&(i=c),(h||x)&&(i=l),Qo(i,e)&&(i=H(-i,e)),{isValid:f||h,value:i}}var tc=pt(cr.p,void 0,!0),ec={...cr,Fp:tc,hash:qo,adjustScalarBytes:Ja,uvRatio:Qa},ls=fs(ec);var Ne=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},fr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ds={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new fr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var ur=ds;var hr=32;var _n,rc=(async()=>{try{return await ur.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function nc(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await ur.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await ur.get().subtle.verify({name:"Ed25519"},n,t,e instanceof Uint8Array?e:e.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function oc(r,t,e){return ls.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function ps(r,t,e){return _n==null&&(_n=await rc),_n?nc(r,t,e):oc(r,t,e)}function lr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var dr=class{type="Ed25519";raw;constructor(t){this.raw=Sn(t,hr)}toMultihash(){return ht.digest(ae(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=ps(this.raw,e,t);return lr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ys(r){return r=Sn(r,hr),new dr(r)}function Sn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Et(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var ic=Math.pow(2,7),ac=Math.pow(2,14),cc=Math.pow(2,21),bs=Math.pow(2,28),xs=Math.pow(2,35),gs=Math.pow(2,42),ws=Math.pow(2,49),et=128,kt=127;function Me(r){if(r<ic)return 1;if(r<ac)return 2;if(r<cc)return 3;if(r<bs)return 4;if(r<xs)return 5;if(r<gs)return 6;if(r<ws)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Es(r,t,e=0){switch(Me(r)){case 8:t[e++]=r&255|et,r/=128;case 7:t[e++]=r&255|et,r/=128;case 6:t[e++]=r&255|et,r/=128;case 5:t[e++]=r&255|et,r/=128;case 4:t[e++]=r&255|et,r>>>=7;case 3:t[e++]=r&255|et,r>>>=7;case 2:t[e++]=r&255|et,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function _s(r,t){let e=r[t],n=0;if(n+=e&kt,e<et||(e=r[t+1],n+=(e&kt)<<7,e<et)||(e=r[t+2],n+=(e&kt)<<14,e<et)||(e=r[t+3],n+=(e&kt)<<21,e<et)||(e=r[t+4],n+=(e&kt)*bs,e<et)||(e=r[t+5],n+=(e&kt)*xs,e<et)||(e=r[t+6],n+=(e&kt)*gs,e<et)||(e=r[t+7],n+=(e&kt)*ws,e<et))return n;throw new RangeError("Could not decode varint")}var An=new Float32Array([-0]),Kt=new Uint8Array(An.buffer);function Ss(r,t,e){An[0]=r,t[e]=Kt[0],t[e+1]=Kt[1],t[e+2]=Kt[2],t[e+3]=Kt[3]}function As(r,t){return Kt[0]=r[t],Kt[1]=r[t+1],Kt[2]=r[t+2],Kt[3]=r[t+3],An[0]}var vn=new Float64Array([-0]),X=new Uint8Array(vn.buffer);function vs(r,t,e){vn[0]=r,t[e]=X[0],t[e+1]=X[1],t[e+2]=X[2],t[e+3]=X[3],t[e+4]=X[4],t[e+5]=X[5],t[e+6]=X[6],t[e+7]=X[7]}function Bs(r,t){return X[0]=r[t],X[1]=r[t+1],X[2]=r[t+2],X[3]=r[t+3],X[4]=r[t+4],X[5]=r[t+5],X[6]=r[t+6],X[7]=r[t+7],vn[0]}var fc=BigInt(Number.MAX_SAFE_INTEGER),uc=BigInt(Number.MIN_SAFE_INTEGER),ct=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 $t;if(t<fc&&t>uc)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>Is&&(o=0n,++n>Is&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return $t;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):$t}},$t=new ct(0,0);$t.toBigInt=function(){return 0n};$t.zzEncode=$t.zzDecode=function(){return this};$t.length=function(){return 1};var Is=4294967296n;function Ls(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 Cs(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 Bn(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 mt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function pr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var In=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,mt(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 mt(this,4);return pr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw mt(this,4);return pr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw mt(this,4);let t=As(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw mt(this,4);let t=Bs(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 mt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Cs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw mt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw mt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ct(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 mt(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 mt(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 mt(this,8);let t=pr(this.buf,this.pos+=4),e=pr(this.buf,this.pos+=4);return new ct(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=_s(this.buf,this.pos);return this.pos+=Me(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 Ln(r){return new In(r instanceof Uint8Array?r:r.subarray())}function mr(r,t,e){let n=Ln(r);return t.decode(n,void 0,e)}function Cn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return st(i);o+i>t&&(n=st(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var Wt=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Tn(){}var Un=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},hc=Cn();function lc(r){return globalThis.Buffer!=null?st(r):hc(r)}var He=class{len;head;tail;states;constructor(){this.len=0,this.head=new Wt(Tn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Wt(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Pn((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(yr,10,ct.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ct.fromBigInt(t);return this._push(yr,e.length(),e)}uint64Number(t){return this._push(Es,Me(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=ct.fromBigInt(t).zzEncode();return this._push(yr,e.length(),e)}sint64Number(t){let e=ct.fromNumber(t).zzEncode();return this._push(yr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Dn,1,t?1:0)}fixed32(t){return this._push(Oe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ct.fromBigInt(t);return this._push(Oe,4,e.lo)._push(Oe,4,e.hi)}fixed64Number(t){let e=ct.fromNumber(t);return this._push(Oe,4,e.lo)._push(Oe,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(Ss,4,t)}double(t){return this._push(vs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Dn,1,0):this.uint32(e)._push(pc,e,t)}string(t){let e=Ls(t);return e!==0?this.uint32(e)._push(Bn,e,t):this._push(Dn,1,0)}fork(){return this.states=new Un(this),this.head=this.tail=new Wt(Tn,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 Wt(Tn,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=lc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Dn(r,t,e){t[e]=r&255}function dc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Pn=class extends Wt{next;constructor(t,e){super(dc,t,e),this.next=void 0}};function yr(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 Oe(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 pc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(He.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(mc,t,r),this},He.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(yc,t,r),this});function mc(r,t,e){t.set(r,e)}function yc(r,t,e){r.length<40?Bn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(G(r),e)}function kn(){return new He}function br(r,t){let e=kn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var be;(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"})(be||(be={}));function xr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Kn(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 xr("enum",be.VARINT,e,n)}function gr(r,t){return xr("message",be.LENGTH_DELIMITED,r,t)}var ft;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(ft||(ft={}));var Rn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Rn||(Rn={}));(function(r){r.codec=()=>Kn(Rn)})(ft||(ft={}));var ze;(function(r){let t;r.codec=()=>(t==null&&(t=gr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.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=ft.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>br(e,r.codec()),r.decode=(e,n)=>mr(e,r.codec(),n)})(ze||(ze={}));var Nn;(function(r){let t;r.codec=()=>(t==null&&(t=gr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.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=ft.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>br(e,r.codec()),r.decode=(e,n)=>mr(e,r.codec(),n)})(Nn||(Nn={}));var wr=class extends ce{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Bo(t);let n=Te(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),At(s)}update(t){return ue(this),this.iHash.update(t),this}digestInto(t){ue(this),W(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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Mn=(r,t,e)=>new wr(r,t).update(e).digest();Mn.create=(r,t)=>new wr(r,t);function Ds(r){r.lowS!==void 0&&Bt("lowS",r.lowS),r.prehash!==void 0&&Bt("prehash",r.prehash)}var On=class extends Error{constructor(t=""){super(t)}},It={Err:On,_tlv:{encode:(r,t)=>{let{Err:e}=It;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=Ke(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Ke(o.length/2|128):"";return Ke(r)+s+o+t},decode(r,t){let{Err:e}=It,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 c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of l)i=i<<8|f;if(n+=c,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}=It;if(r<qe)throw new t("integer: negative integers are not allowed");let e=Ke(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}=It;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 le(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=It,o=M("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:l,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=It,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},qe=BigInt(0),Fe=BigInt(1),xc=BigInt(2),Er=BigInt(3),gc=BigInt(4);function wc(r,t,e){function n(o){let s=r.sqr(o),i=r.mul(s,o);return r.add(r.add(i,r.mul(o,t)),e)}return n}function Us(r,t,e){let{BYTES:n}=r;function o(s){let i;if(typeof s=="bigint")i=s;else{let a=M("private key",s);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");let c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{i=r.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof s}`)}}if(e&&(i=r.create(i)),!r.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}return o}function Ec(r,t={}){let{Fp:e,Fn:n}=ar("weierstrass",r,t),{h:o,n:s}=r;Pt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:i}=t;if(i&&(!e.is0(r.a)||typeof i.beta!="bigint"||typeof i.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!e.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(B,u,g){let{x:d,y}=u.toAffine(),w=e.toBytes(d);if(Bt("isCompressed",g),g){a();let I=!e.isOdd(y);return at(Ps(I),w)}else return at(Uint8Array.of(4),w,e.toBytes(y))}function l(B){W(B);let u=e.BYTES,g=u+1,d=2*u+1,y=B.length,w=B[0],I=B.subarray(1);if(y===g&&(w===2||w===3)){let A=e.fromBytes(I);if(!e.isValid(A))throw new Error("bad point: is not on curve, wrong x");let L=x(A),k;try{k=e.sqrt(L)}catch(R){let K=R instanceof Error?": "+R.message:"";throw new Error("bad point: is not on curve, sqrt error"+K)}a();let P=e.isOdd(k);return(w&1)===1!==P&&(k=e.neg(k)),{x:A,y:k}}else if(y===d&&w===4){let A=e.fromBytes(I.subarray(u*0,u*1)),L=e.fromBytes(I.subarray(u*1,u*2));if(!b(A,L))throw new Error("bad point: is not on curve");return{x:A,y:L}}else throw new Error(`bad point: got length ${y}, expected compressed=${g} or uncompressed=${d}`)}let f=t.toBytes||c,h=t.fromBytes||l,x=wc(e,r.a,r.b);function b(B,u){let g=e.sqr(u),d=x(B);return e.eql(g,d)}if(!b(r.Gx,r.Gy))throw new Error("bad curve params: generator point");let _=e.mul(e.pow(r.a,Er),gc),E=e.mul(e.sqr(r.b),BigInt(27));if(e.is0(e.add(_,E)))throw new Error("bad curve params: a or b");function m(B,u,g=!1){if(!e.isValid(u)||g&&e.is0(u))throw new Error(`bad point coordinate ${B}`);return u}function S(B){if(!(B instanceof p))throw new Error("ProjectivePoint expected")}let C=pe((B,u)=>{let{px:g,py:d,pz:y}=B;if(e.eql(y,e.ONE))return{x:g,y:d};let w=B.is0();u==null&&(u=w?e.ONE:e.inv(y));let I=e.mul(g,u),A=e.mul(d,u),L=e.mul(y,u);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:I,y:A}}),v=pe(B=>{if(B.is0()){if(t.allowInfinityPoint&&!e.is0(B.py))return;throw new Error("bad point: ZERO")}let{x:u,y:g}=B.toAffine();if(!e.isValid(u)||!e.isValid(g))throw new Error("bad point: x or y not field elements");if(!b(u,g))throw new Error("bad point: equation left != right");if(!B.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function U(B,u,g,d,y){return g=new p(e.mul(g.px,B),g.py,g.pz),u=me(d,u),g=me(y,g),u.add(g)}class p{constructor(u,g,d){this.px=m("x",u),this.py=m("y",g,!0),this.pz=m("z",d),Object.freeze(this)}static fromAffine(u){let{x:g,y:d}=u||{};if(!u||!e.isValid(g)||!e.isValid(d))throw new Error("invalid affine point");if(u instanceof p)throw new Error("projective point not allowed");return e.is0(g)&&e.is0(d)?p.ZERO:new p(g,d,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){return or(p,"pz",u)}static fromBytes(u){return W(u),p.fromHex(u)}static fromHex(u){let g=p.fromAffine(h(M("pointHex",u)));return g.assertValidity(),g}static fromPrivateKey(u){let g=Us(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return p.BASE.multiply(g(u))}static msm(u,g){return ir(p,n,u,g)}precompute(u=8,g=!0){return T.setWindowSize(this,u),g||this.multiply(Er),this}_setWindowSize(u){this.precompute(u)}assertValidity(){v(this)}hasEvenY(){let{y:u}=this.toAffine();if(!e.isOdd)throw new Error("Field doesn't support isOdd");return!e.isOdd(u)}equals(u){S(u);let{px:g,py:d,pz:y}=this,{px:w,py:I,pz:A}=u,L=e.eql(e.mul(g,A),e.mul(w,y)),k=e.eql(e.mul(d,A),e.mul(I,y));return L&&k}negate(){return new p(this.px,e.neg(this.py),this.pz)}double(){let{a:u,b:g}=r,d=e.mul(g,Er),{px:y,py:w,pz:I}=this,A=e.ZERO,L=e.ZERO,k=e.ZERO,P=e.mul(y,y),q=e.mul(w,w),R=e.mul(I,I),K=e.mul(y,w);return K=e.add(K,K),k=e.mul(y,I),k=e.add(k,k),A=e.mul(u,k),L=e.mul(d,R),L=e.add(A,L),A=e.sub(q,L),L=e.add(q,L),L=e.mul(A,L),A=e.mul(K,A),k=e.mul(d,k),R=e.mul(u,R),K=e.sub(P,R),K=e.mul(u,K),K=e.add(K,k),k=e.add(P,P),P=e.add(k,P),P=e.add(P,R),P=e.mul(P,K),L=e.add(L,P),R=e.mul(w,I),R=e.add(R,R),P=e.mul(R,K),A=e.sub(A,P),k=e.mul(R,q),k=e.add(k,k),k=e.add(k,k),new p(A,L,k)}add(u){S(u);let{px:g,py:d,pz:y}=this,{px:w,py:I,pz:A}=u,L=e.ZERO,k=e.ZERO,P=e.ZERO,q=r.a,R=e.mul(r.b,Er),K=e.mul(g,w),V=e.mul(d,I),j=e.mul(y,A),$=e.add(g,d),N=e.add(w,I);$=e.mul($,N),N=e.add(K,V),$=e.sub($,N),N=e.add(g,y);let J=e.add(w,A);return N=e.mul(N,J),J=e.add(K,j),N=e.sub(N,J),J=e.add(d,y),L=e.add(I,A),J=e.mul(J,L),L=e.add(V,j),J=e.sub(J,L),P=e.mul(q,N),L=e.mul(R,j),P=e.add(L,P),L=e.sub(V,P),P=e.add(V,P),k=e.mul(L,P),V=e.add(K,K),V=e.add(V,K),j=e.mul(q,j),N=e.mul(R,N),V=e.add(V,j),j=e.sub(K,j),j=e.mul(q,j),N=e.add(N,j),K=e.mul(V,N),k=e.add(k,K),K=e.mul(J,N),L=e.mul($,L),L=e.sub(L,K),K=e.mul($,V),P=e.mul(J,P),P=e.add(P,K),new p(L,k,P)}subtract(u){return this.add(u.negate())}is0(){return this.equals(p.ZERO)}multiply(u){let{endo:g}=t;if(!n.isValidNot0(u))throw new Error("invalid scalar: out of range");let d,y,w=I=>T.wNAFCached(this,I,p.normalizeZ);if(g){let{k1neg:I,k1:A,k2neg:L,k2:k}=g.splitScalar(u),{p:P,f:q}=w(A),{p:R,f:K}=w(k);y=q.add(K),d=U(g.beta,P,R,I,L)}else{let{p:I,f:A}=w(u);d=I,y=A}return p.normalizeZ([d,y])[0]}multiplyUnsafe(u){let{endo:g}=t,d=this;if(!n.isValid(u))throw new Error("invalid scalar: out of range");if(u===qe||d.is0())return p.ZERO;if(u===Fe)return d;if(T.hasPrecomputes(this))return this.multiply(u);if(g){let{k1neg:y,k1:w,k2neg:I,k2:A}=g.splitScalar(u),{p1:L,p2:k}=cs(p,d,w,A);return U(g.beta,L,k,y,I)}else return T.wNAFCachedUnsafe(d,u)}multiplyAndAddUnsafe(u,g,d){let y=this.multiplyUnsafe(g).add(u.multiplyUnsafe(d));return y.is0()?void 0:y}toAffine(u){return C(this,u)}isTorsionFree(){let{isTorsionFree:u}=t;return o===Fe?!0:u?u(p,this):T.wNAFCachedUnsafe(this,s).is0()}clearCofactor(){let{clearCofactor:u}=t;return o===Fe?this:u?u(p,this):this.multiplyUnsafe(o)}toBytes(u=!0){return Bt("isCompressed",u),this.assertValidity(),f(p,this,u)}toRawBytes(u=!0){return this.toBytes(u)}toHex(u=!0){return bt(this.toBytes(u))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}p.BASE=new p(r.Gx,r.Gy,e.ONE),p.ZERO=new p(e.ZERO,e.ONE,e.ZERO),p.Fp=e,p.Fn=n;let D=n.BITS,T=sr(p,t.endo?Math.ceil(D/2):D);return p}function Ps(r){return Uint8Array.of(r?2:3)}function _c(r,t,e={}){Pt(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=t.randomBytes||De,o=t.hmac||((d,...y)=>Mn(t.hash,d,at(...y))),{Fp:s,Fn:i}=r,{ORDER:a,BITS:c}=i;function l(d){let y=a>>Fe;return d>y}function f(d){return l(d)?i.neg(d):d}function h(d,y){if(!i.isValidNot0(y))throw new Error(`invalid signature ${d}: out of range 1..CURVE.n`)}class x{constructor(y,w,I){h("r",y),h("s",w),this.r=y,this.s=w,I!=null&&(this.recovery=I),Object.freeze(this)}static fromCompact(y){let w=i.BYTES,I=M("compactSignature",y,w*2);return new x(i.fromBytes(I.subarray(0,w)),i.fromBytes(I.subarray(w,w*2)))}static fromDER(y){let{r:w,s:I}=It.toSig(M("DER",y));return new x(w,I)}assertValidity(){}addRecoveryBit(y){return new x(this.r,this.s,y)}recoverPublicKey(y){let w=s.ORDER,{r:I,s:A,recovery:L}=this;if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");if(a*xc<w&&L>1)throw new Error("recovery id is ambiguous for h>1 curve");let P=L===2||L===3?I+a:I;if(!s.isValid(P))throw new Error("recovery id 2 or 3 invalid");let q=s.toBytes(P),R=r.fromHex(at(Ps((L&1)===0),q)),K=i.inv(P),V=v(M("msgHash",y)),j=i.create(-V*K),$=i.create(A*K),N=r.BASE.multiplyUnsafe(j).add(R.multiplyUnsafe($));if(N.is0())throw new Error("point at infinify");return N.assertValidity(),N}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,i.neg(this.s),this.recovery):this}toBytes(y){if(y==="compact")return at(i.toBytes(this.r),i.toBytes(this.s));if(y==="der")return he(It.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bt(this.toBytes("compact"))}}let b=Us(i,e.allowedPrivateKeyLengths,e.wrapPrivateKey),_={isValidPrivateKey(d){try{return b(d),!0}catch{return!1}},normPrivateKeyToScalar:b,randomPrivateKey:()=>{let d=a;return rs(n(bn(d)),d)},precompute(d=8,y=r.BASE){return y.precompute(d,!1)}};function E(d,y=!0){return r.fromPrivateKey(d).toBytes(y)}function m(d){if(typeof d=="bigint")return!1;if(d instanceof r)return!0;let w=M("key",d).length,I=s.BYTES,A=I+1,L=2*I+1;if(!(e.allowedPrivateKeyLengths||i.BYTES===A))return w===A||w===L}function S(d,y,w=!0){if(m(d)===!0)throw new Error("first arg must be private key");if(m(y)===!1)throw new Error("second arg must be public key");return r.fromHex(y).multiply(b(d)).toBytes(w)}let C=t.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let y=le(d),w=d.length*8-c;return w>0?y>>BigInt(w):y},v=t.bits2int_modN||function(d){return i.create(C(d))},U=Gt(c);function p(d){return Ut("num < 2^"+c,d,qe,U),i.toBytes(d)}function D(d,y,w=T){if(["recovered","canonical"].some($=>$ in w))throw new Error("sign() legacy options not supported");let{hash:I}=t,{lowS:A,prehash:L,extraEntropy:k}=w;A==null&&(A=!0),d=M("msgHash",d),Ds(w),L&&(d=M("prehashed msgHash",I(d)));let P=v(d),q=b(y),R=[p(q),p(P)];if(k!=null&&k!==!1){let $=k===!0?n(s.BYTES):k;R.push(M("extraEntropy",$))}let K=at(...R),V=P;function j($){let N=C($);if(!i.isValidNot0(N))return;let J=i.inv(N),ge=r.BASE.multiply(N).toAffine(),Qt=i.create(ge.x);if(Qt===qe)return;let Ot=i.create(J*i.create(V+Qt*q));if(Ot===qe)return;let Tr=(ge.x===Qt?0:2)|Number(ge.y&Fe),te=Ot;return A&&l(Ot)&&(te=f(Ot),Tr^=1),new x(Qt,te,Tr)}return{seed:K,k2sig:j}}let T={lowS:t.lowS,prehash:!1},B={lowS:t.lowS,prehash:!1};function u(d,y,w=T){let{seed:I,k2sig:A}=D(d,y,w);return Go(t.hash.outputLen,i.BYTES,o)(I,A)}r.BASE.precompute(8);function g(d,y,w,I=B){let A=d;y=M("msgHash",y),w=M("publicKey",w),Ds(I);let{lowS:L,prehash:k,format:P}=I;if("strict"in I)throw new Error("options.strict was renamed to lowS");if(P!==void 0&&!["compact","der","js"].includes(P))throw new Error('format must be "compact", "der" or "js"');let q=typeof A=="string"||fe(A),R=!q&&!P&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!q&&!R)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,V;try{if(R)if(P===void 0||P==="js")K=new x(A.r,A.s);else throw new Error("invalid format");if(q){try{P!=="compact"&&(K=x.fromDER(A))}catch(te){if(!(te instanceof It.Err))throw te}!K&&P!=="der"&&(K=x.fromCompact(A))}V=r.fromHex(w)}catch{return!1}if(!K||L&&K.hasHighS())return!1;k&&(y=t.hash(y));let{r:j,s:$}=K,N=v(y),J=i.inv($),ge=i.create(N*J),Qt=i.create(j*J),Ot=r.BASE.multiplyUnsafe(ge).add(V.multiplyUnsafe(Qt));return Ot.is0()?!1:i.create(Ot.x)===j}return Object.freeze({getPublicKey:E,getSharedSecret:S,sign:u,verify:g,utils:_,Point:r,Signature:x})}function Sc(r){let t={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},e=r.Fp,n=pt(t.n,r.nBitLength),o={Fp:e,Fn:n,allowedPrivateKeyLengths:r.allowedPrivateKeyLengths,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,wrapPrivateKey:r.wrapPrivateKey,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:t,curveOpts:o}}function Ac(r){let{CURVE:t,curveOpts:e}=Sc(r),n={hash:r.hash,hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:t,curveOpts:e,ecdsaOpts:n}}function vc(r,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:r})}function ks(r){let{CURVE:t,curveOpts:e,ecdsaOpts:n}=Ac(r),o=Ec(t,e),s=_c(o,n,e);return vc(r,s)}function Ks(r,t){let e=n=>ks({...r,hash:n});return{...e(t),create:e}}var _r={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},hl=BigInt(0),Bc=BigInt(1),Hn=BigInt(2),Rs=(r,t)=>(r+t/Hn)/t;function Ic(r){let t=_r.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,f=l*l*r%t,h=O(f,e,t)*f%t,x=O(h,e,t)*f%t,b=O(x,Hn,t)*l%t,_=O(b,o,t)*b%t,E=O(_,s,t)*_%t,m=O(E,a,t)*E%t,S=O(m,c,t)*m%t,C=O(S,a,t)*E%t,v=O(C,e,t)*f%t,U=O(v,i,t)*_%t,p=O(U,n,t)*l%t,D=O(p,Hn,t);if(!zn.eql(zn.sqr(D),r))throw new Error("Cannot find square root");return D}var zn=pt(_r.p,void 0,void 0,{sqrt:Ic}),xe=Ks({..._r,Fp:zn,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=_r.n,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Bc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=Rs(s*r,t),c=Rs(-n*r,t),l=H(r-a*e-c*o,t),f=H(-a*n-c*s,t),h=l>i,x=f>i;if(h&&(l=t-l),x&&(f=t-f),l>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:h,k1:l,k2neg:x,k2:f}}}},zo);function Ns(r,t,e,n){let o=Be.digest(e instanceof Uint8Array?e:e.subarray());if(lr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),xe.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new Ne(String(s))});try{return n?.signal?.throwIfAborted(),xe.verify(t,o.digest,r)}catch(s){throw new Ne(String(s))}}var Sr=class{type="secp256k1";raw;_key;constructor(t){this._key=Os(t),this.raw=Ms(this._key)}toMultihash(){return ht.digest(ae(this))}toCID(){return rt.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}verify(t,e,n){return Ns(this._key,e,t,n)}};function Hs(r){return new Sr(r)}function Ms(r){return xe.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Os(r){try{return xe.ProjectivePoint.fromHex(r),r}catch(t){throw new Ye(String(t))}}function zs(r){let{Type:t,Data:e}=ze.decode(r.digest),n=e??new Uint8Array;switch(t){case ft.Ed25519:return ys(n);case ft.secp256k1:return Hs(n);case ft.ECDSA:return _o(n);default:throw new we}}function ae(r){return ze.encode({Type:ft[r.type],Data:r.raw})}var qs=Symbol.for("nodejs.util.inspect.custom"),Lc=114,Ve=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()})`}[Ur]=!0;toString(){return this.string==null&&(this.string=F.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return rt.createV1(Lc,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ot(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ot(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[qs](){return`PeerId(${this.toString()})`}},Ar=class extends Ve{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},vr=class extends Ve{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Br=class extends Ve{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Cc=2336,Ir=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ht.digest(G(this.url))}[qs](){return`PeerId(${this.url})`}[Ur]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return rt.createV1(Cc,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ut(t)),t.toString()===this.toString())}};function Fs(r){if(Dc(r))return new Ar({multihash:r});if(Tc(r))try{let t=zs(r);if(t.type==="Ed25519")return new vr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Br({multihash:r,publicKey:t})}catch{let e=ut(r.digest);return new Ir(new URL(e))}throw new $e("Supplied PeerID Multihash is invalid")}function Tc(r){return r.code===ht.code}function Dc(r){return r.code===Be.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 Lr(r){let t=Ae(F.decode(`z${r}`));return Fs(t)}var Rt=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 Vs(){return new Rt}var Nt=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=Lr(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=Lr(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return wt(this.set.values(),t=>Lr(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 js(){return new Nt}var Mt=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 Gs(){return new Mt}var qn={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Zs={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},Ys=new globalThis.TextEncoder;function Uc(r,t){let e=qn[t],n=Zs[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Pc(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=qn[t],o=Zs[t],s=r;for(;s.length>0;){let i=Ys.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 Fn(r,{size:t=32,utf8Buffer:e}={}){if(!qn[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 Pc(r,t,e);r=Ys.encode(r)}return Uc(r,t)}var je={hash:r=>Number(Fn(r,{size:32})),hashV:(r,t)=>kc(je.hash(r,t))};function kc(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),G(t,"base16")}var Vn=64,yt=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=lt(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?ot(this.fp,t.fp):!1}};function Xt(r,t){return Math.floor(Math.random()*(t-r))+r}var Jt=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof yt))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof yt))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 yt))throw new TypeError("Invalid Fingerprint");let e=Xt(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof yt))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var Kc=500,Ge=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??je,this.seed=t.seed??Xt(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=G(t));let e=new yt(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 Jt(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new Jt(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[Xt(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new Jt(this.bucketSize));for(let a=0;a<Kc;a++){let c=this.buckets[i].swap(e);if(c!=null&&(i=(i^c.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new Jt(this.bucketSize)),this.buckets[i].add(c)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=G(t));let e=new yt(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=G(t));let e=new yt(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}},Rc={1:.5,2:.84,4:.95,8:.98};function Nc(r=.001){return r>.002?2:r>1e-5?4:8}function $s(r,t=.001){let e=Nc(t),n=Rc[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 Cr=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??je,this.seed=t.seed??Xt(0,Math.pow(2,10)),this.filterSeries=[new Ge({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=G(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 Ge({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=G(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=G(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 jn(r,t=.001,e){return new Cr({...$s(r,t),...e??{}})}var Ze=class{filter;constructor(t,e){this.filter=jn(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 Ws(r,t=.001){return new Ze(r,t)}var Gn=class extends Rt{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 Xs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Gn({name:t,metrics:e}):n=new Rt,n}var Zn=class extends Nt{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 Js(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Zn({name:t,metrics:e}):n=new Nt,n}var Yn=class extends Mt{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 Qs(r){let{name:t,metrics:e}=r,n;return e!=null?n=new Yn({name:t,metrics:e}):n=new Mt,n}return oi(Mc);})();
2
+ "use strict";var Libp2PPeerCollections=(()=>{var qr=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var vi=Object.getOwnPropertyNames;var Ai=Object.prototype.hasOwnProperty;var at=(e,t)=>{for(var r in t)qr(e,r,{get:t[r],enumerable:!0})},Ii=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vi(t))!Ai.call(e,o)&&o!==r&&qr(e,o,{get:()=>t[o],enumerable:!(n=Bi(t,o))||n.enumerable});return e};var Li=e=>Ii(qr({},"__esModule",{value:!0}),e);var mf={};at(mf,{PeerFilter:()=>or,PeerList:()=>Jt,PeerMap:()=>$t,PeerSet:()=>Wt,peerFilter:()=>wi,peerList:()=>yi,peerMap:()=>pi,peerSet:()=>mi,trackedPeerList:()=>Si,trackedPeerMap:()=>Ei,trackedPeerSet:()=>_i});var Vr=Symbol.for("@libp2p/peer-id");var vt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ir=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var cr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ue=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Gr={};at(Gr,{base58btc:()=>Y,base58flickr:()=>ki});var xf=new Uint8Array(0);function wo(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function At(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Eo(e){return new TextEncoder().encode(e)}function _o(e){return new TextDecoder().decode(e)}function Ci(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,a=e.charAt(0),u=Math.log(c)/Math.log(256),y=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var E=0,S=0,g=0,B=h.length;g!==B&&h[g]===0;)g++,E++;for(var w=(B-g)*y+1>>>0,T=new Uint8Array(w);g!==B;){for(var K=h[g],M=0,P=w-1;(K!==0||M<S)&&P!==-1;P--,M++)K+=256*T[P]>>>0,T[P]=K%c>>>0,K=K/c>>>0;if(K!==0)throw new Error("Non-zero carry");S=M,g++}for(var R=w-S;R!==w&&T[R]===0;)R++;for(var x=a.repeat(E);R<w;++R)x+=e.charAt(T[R]);return x}function f(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var E=0;if(h[E]!==" "){for(var S=0,g=0;h[E]===a;)S++,E++;for(var B=(h.length-E)*u+1>>>0,w=new Uint8Array(B);h[E];){var T=r[h.charCodeAt(E)];if(T===255)return;for(var K=0,M=B-1;(T!==0||K<g)&&M!==-1;M--,K++)T+=c*w[M]>>>0,w[M]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");g=K,E++}if(h[E]!==" "){for(var P=B-g;P!==B&&w[P]===0;)P++;for(var R=new Uint8Array(S+(B-P)),x=S;P!==B;)R[x++]=w[P++];return R}}}function d(h){var E=f(h);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:f,decode:d}}var Ti=Ci,Ui=Ti,Bo=Ui;var zr=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Fr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return vo(this,t)}},jr=class{decoders;constructor(t){this.decoders=t}or(t){return vo(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function vo(e,t){return new jr({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Zr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new zr(t,r,n),this.decoder=new Fr(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ue({name:e,prefix:t,encode:r,decode:n}){return new Zr(e,t,r,n)}function Ht({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Bo(r,e);return ue({prefix:t,name:e,encode:n,decode:s=>At(o(s))})}function Di(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,c=0,a=0;for(let u=0;u<o;++u){let y=t[e[u]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|y,i+=r,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=r||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Ki(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Ri(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function Z({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Ri(n);return ue({prefix:t,name:e,encode(s){return Ki(s,n,r)},decode(s){return Di(s,o,r,e)}})}var Y=Ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ki=Ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Yr={};at(Yr,{base32:()=>he,base32hex:()=>Oi,base32hexpad:()=>qi,base32hexpadupper:()=>Vi,base32hexupper:()=>Hi,base32pad:()=>Pi,base32padupper:()=>Mi,base32upper:()=>Ni,base32z:()=>zi});var he=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ni=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Pi=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mi=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oi=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hi=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qi=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vi=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zi=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xr={};at(Xr,{base36:()=>De,base36upper:()=>Fi});var De=Ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Fi=Ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ji=Lo,Ao=128,Zi=127,Gi=~Zi,Yi=Math.pow(2,31);function Lo(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Yi;)t[r++]=e&255|Ao,e/=128;for(;e&Gi;)t[r++]=e&255|Ao,e>>>=7;return t[r]=e|0,Lo.bytes=r-n+1,t}var Xi=$r,$i=128,Io=127;function $r(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw $r.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Io)<<o:(i&Io)*Math.pow(2,o),o+=7}while(i>=$i);return $r.bytes=s-n,r}var Wi=Math.pow(2,7),Ji=Math.pow(2,14),Qi=Math.pow(2,21),tc=Math.pow(2,28),ec=Math.pow(2,35),rc=Math.pow(2,42),nc=Math.pow(2,49),oc=Math.pow(2,56),sc=Math.pow(2,63),ic=function(e){return e<Wi?1:e<Ji?2:e<Qi?3:e<tc?4:e<ec?5:e<rc?6:e<nc?7:e<oc?8:e<sc?9:10},cc={encode:ji,decode:Xi,encodingLength:ic},ac=cc,Ke=ac;function Re(e,t=0){return[Ke.decode(e,t),Ke.decode.bytes]}function le(e,t,r=0){return Ke.encode(e,t,r),t}function de(e){return Ke.encodingLength(e)}function me(e,t){let r=t.byteLength,n=de(e),o=n+de(r),s=new Uint8Array(o+r);return le(e,s,0),le(r,s,n),s.set(t,o),new pe(e,r,t,s)}function ke(e){let t=At(e),[r,n]=Re(t),[o,s]=Re(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new pe(r,o,i,t)}function Co(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&wo(e.bytes,r.bytes)}}var pe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function To(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return uc(r,Wr(e),t??Y.encoder);default:return hc(r,Wr(e),t??he.encoder)}}var Uo=new WeakMap;function Wr(e){let t=Uo.get(e);if(t==null){let r=new Map;return Uo.set(e,r),r}return t}var it=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==lc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=me(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Co(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??Do(n,o,s.bytes))}else if(r[dc]===!0){let{version:n,multihash:o,code:s}=r,i=ke(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Ne)throw new Error(`Version 0 CID must use dag-pb (code: ${Ne}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Do(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Ne,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=At(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new pe(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,f]=Re(t.subarray(r));return r+=f,l},o=n(),s=Ne;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),a=n(),u=r+a,y=u-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:y,size:u}}static parse(t,r){let[n,o]=fc(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wr(s).set(n,t),s}};function fc(e,t){switch(e[0]){case"Q":{let r=t??Y;return[Y.prefix,r.decode(`${Y.prefix}${e}`)]}case Y.prefix:{let r=t??Y;return[Y.prefix,r.decode(e)]}case he.prefix:{let r=t??he;return[he.prefix,r.decode(e)]}case De.prefix:{let r=t??De;return[De.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function uc(e,t,r){let{prefix:n}=r;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function hc(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var Ne=112,lc=18;function Do(e,t,r){let n=de(e),o=n+de(t),s=new Uint8Array(o+r.byteLength);return le(e,s,0),le(t,s,n),s.set(r,o),s}var dc=Symbol.for("@ipld/js-cid/CID");var Jr={};at(Jr,{identity:()=>gt});var Ko=0,pc="identity",Ro=At;function mc(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return me(Ko,Ro(e))}var gt={code:Ko,name:pc,encode:Ro,digest:mc};function ft(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function xt(e=0){return new Uint8Array(e)}function ut(e=0){return new Uint8Array(e)}function fr(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=ut(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var No=Symbol.for("@achingbrain/uint8arraylist");function ko(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function ur(e){return!!e?.[No]}var ht=class e{bufs;length;[No]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(ur(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(ur(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ko(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ko(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(ur(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return fr(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:fr(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=[...n],s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let u=t>=c&&t<a,y=r>c&&r<=a;if(u&&y){if(t===c&&r===a){n.push(i);break}let l=t-c;n.push(i.subarray(l,l+(r-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(y){if(r===a){n.push(i);break}n.push(i.subarray(0,r-c));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!ur(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let c=i,a=this.byteLength-n.byteLength,u=n.byteLength-1,y;for(let l=r;l<=a;l+=y){y=0;for(let f=u;f>=0;f--){let d=this.get(l+f);if(n[f]!==d){y=Math.max(1,f-c[d]);break}}if(y===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ft(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var Qr={};at(Qr,{base10:()=>yc});var yc=Ht({prefix:"9",name:"base10",alphabet:"0123456789"});var tn={};at(tn,{base16:()=>bc,base16upper:()=>gc});var bc=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gc=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var en={};at(en,{base2:()=>xc});var xc=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rn={};at(rn,{base256emoji:()=>Bc});var Po=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}"),wc=Po.reduce((e,t,r)=>(e[r]=t,e),[]),Ec=Po.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function _c(e){return e.reduce((t,r)=>(t+=wc[r],t),"")}function Sc(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Ec[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Bc=ue({prefix:"\u{1F680}",name:"base256emoji",encode:_c,decode:Sc});var nn={};at(nn,{base64:()=>vc,base64pad:()=>Ac,base64url:()=>Ic,base64urlpad:()=>Lc});var vc=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ac=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ic=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lc=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var on={};at(on,{base8:()=>Cc});var Cc=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var sn={};at(sn,{identity:()=>Tc});var Tc=ue({prefix:"\0",name:"identity",encode:e=>_o(e),decode:e=>Eo(e)});var ru=new TextEncoder,nu=new TextDecoder;var fn={};at(fn,{sha256:()=>Pe,sha512:()=>Rc});var Kc=20;function an({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new cn(e,t,r,n,o)}var cn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Kc,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Mo(n,this.code,r?.truncate):n.then(o=>Mo(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Mo(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return me(t,e)}function Ho(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Pe=an({name:"sha2-256",code:18,encode:Ho("SHA-256")}),Rc=an({name:"sha2-512",code:19,encode:Ho("SHA-512")});var un={...sn,...en,...on,...Qr,...tn,...Yr,...Xr,...Gr,...nn,...rn},mu={...fn,...Jr};function Vo(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var qo=Vo("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),hn=Vo("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=ut(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),kc={utf8:qo,"utf-8":qo,hex:un.base16,latin1:hn,ascii:hn,binary:hn,...un},hr=kc;function $(e,t="utf8"){let r=hr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function yt(e,t="utf8"){let r=hr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Nc=parseInt("11111",2),ln=parseInt("10000000",2),Pc=parseInt("01111111",2),zo={0:Me,1:Me,2:Mc,3:qc,4:Vc,5:Hc,6:Oc,16:Me,22:Me,48:Me};function dn(e,t={offset:0}){let r=e[t.offset]&Nc;if(t.offset++,zo[r]!=null)return zo[r](e,t);throw new Error("No decoder for tag "+r)}function Oe(e,t){let r=0;if((e[t.offset]&ln)===ln){let n=e[t.offset]&Pc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Me(e,t){Oe(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=dn(e,t);if(n===null)break;r.push(n)}return r}function Mc(e,t){let r=Oe(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Oc(e,t){let r=Oe(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let u=e[t.offset];if(t.offset++,a.push(u&127),u<128){a.reverse();let y=0;for(let l=0;l<a.length;l++)y+=a[l]<<l*7;c+=`.${y}`,a=[]}}return c}function Hc(e,t){return t.offset++,null}function qc(e,t){let r=Oe(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Vc(e,t){let r=Oe(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function zc(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new ht;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function pn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=zc(e.byteLength);return new ht(Uint8Array.from([t.byteLength|ln]),t)}function Fo(e){let t=new ht,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new ht(Uint8Array.from([2]),pn(t),t)}function jo(e){let t=Uint8Array.from([0]),r=new ht(t,e);return new ht(Uint8Array.from([3]),pn(r),r)}function lr(e,t=48){let r=new ht;for(let n of e)r.append(n);return new ht(Uint8Array.from([t]),pn(r),r)}async function Zo(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),s}var Fc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),jc=Uint8Array.from([6,5,43,129,4,0,34]),Zc=Uint8Array.from([6,5,43,129,4,0,35]),Gc={ext:!0,kty:"EC",crv:"P-256"},Yc={ext:!0,kty:"EC",crv:"P-384"},Xc={ext:!0,kty:"EC",crv:"P-521"},mn=32,yn=48,bn=66;function Go(e){let t=dn(e);return Yo(t)}function Yo(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===mn*2+1)return n=yt(t.subarray(r,r+mn),"base64url"),o=yt(t.subarray(r+mn),"base64url"),new ye({...Gc,key_ops:["verify"],x:n,y:o});if(t.byteLength===yn*2+1)return n=yt(t.subarray(r,r+yn),"base64url"),o=yt(t.subarray(r+yn),"base64url"),new ye({...Yc,key_ops:["verify"],x:n,y:o});if(t.byteLength===bn*2+1)return n=yt(t.subarray(r,r+bn),"base64url"),o=yt(t.subarray(r+bn),"base64url"),new ye({...Xc,key_ops:["verify"],x:n,y:o});throw new vt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Xo(e){return lr([Fo(Uint8Array.from([1])),lr([$c(e.crv)],160),lr([jo(new ht(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function $c(e){if(e==="P-256")return Fc;if(e==="P-384")return jc;if(e==="P-521")return Zc;throw new vt(`Invalid curve ${e}`)}var ye=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Xo(this.jwk)),this._raw}toMultihash(){return gt.digest(be(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}async verify(t,r,n){return Zo(this.jwk,r,t,n)}};var te=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Lt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function He(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ct(e,...t){if(!Lt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function dr(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");He(e.outputLen),He(e.blockLen)}function xe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Wo(e,t){ct(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ct(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function pr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function wt(e,t){return e<<32-t|e>>>t}var Jo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Wc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bt(e){if(ct(e),Jo)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Wc[e[r]];return t}var It={_0:48,_9:57,A:65,F:70,a:97,f:102};function $o(e){if(e>=It._0&&e<=It._9)return e-It._0;if(e>=It.A&&e<=It.F)return e-(It.A-10);if(e>=It.a&&e<=It.f)return e-(It.a-10)}function ee(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Jo)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=$o(e.charCodeAt(s)),c=$o(e.charCodeAt(s+1));if(i===void 0||c===void 0){let a=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function gn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function qe(e){return typeof e=="string"&&(e=gn(e)),ct(e),e}function rt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ct(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}var ge=class{};function xn(e){let t=n=>e().update(qe(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function we(e=32){if(te&&typeof te.getRandomValues=="function")return te.getRandomValues(new Uint8Array(e));if(te&&typeof te.randomBytes=="function")return Uint8Array.from(te.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function Jc(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),a=n?4:0,u=n?0:4;e.setUint32(t+a,i,n),e.setUint32(t+u,c,n)}function Qo(e,t,r){return e&t^~e&r}function ts(e,t,r){return e&t^e&r^t&r}var Ve=class extends ge{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=pr(this.buffer)}update(t){xe(this),t=qe(t),ct(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=pr(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xe(this),Wo(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ct(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)r[l]=0;Jc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=pr(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,y=this.get();if(u>y.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,y[l],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Tt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var mr=BigInt(4294967295),es=BigInt(32);function Qc(e,t=!1){return t?{h:Number(e&mr),l:Number(e>>es&mr)}:{h:Number(e>>es&mr)|0,l:Number(e&mr)|0}}function rs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:c}=Qc(e[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var wn=(e,t,r)=>e>>>r,En=(e,t,r)=>e<<32-r|t>>>r,re=(e,t,r)=>e>>>r|t<<32-r,ne=(e,t,r)=>e<<32-r|t>>>r,ze=(e,t,r)=>e<<64-r|t>>>r-32,Fe=(e,t,r)=>e>>>r-32|t<<64-r;function St(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ns=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),os=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ss=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),is=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,cs=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),as=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var ea=Uint32Array.from([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]),qt=new Uint32Array(64),_n=class extends Ve{constructor(t=32){super(64,t,8,!1),this.A=Tt[0]|0,this.B=Tt[1]|0,this.C=Tt[2]|0,this.D=Tt[3]|0,this.E=Tt[4]|0,this.F=Tt[5]|0,this.G=Tt[6]|0,this.H=Tt[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,r,n,o,s,i,c,a]}set(t,r,n,o,s,i,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,r){for(let l=0;l<16;l++,r+=4)qt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let f=qt[l-15],d=qt[l-2],h=wt(f,7)^wt(f,18)^f>>>3,E=wt(d,17)^wt(d,19)^d>>>10;qt[l]=E+qt[l-7]+h+qt[l-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:u,H:y}=this;for(let l=0;l<64;l++){let f=wt(c,6)^wt(c,11)^wt(c,25),d=y+f+Qo(c,a,u)+ea[l]+qt[l]|0,E=(wt(n,2)^wt(n,13)^wt(n,22))+ts(n,o,s)|0;y=u,u=a,a=c,c=i+d|0,i=s,s=o,o=n,n=d+E|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,y=y+this.H|0,this.set(n,o,s,i,c,a,u,y)}roundClean(){Ct(qt)}destroy(){this.set(0,0,0,0,0,0,0,0),Ct(this.buffer)}};var fs=rs(["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(e=>BigInt(e))),ra=fs[0],na=fs[1],Vt=new Uint32Array(80),zt=new Uint32Array(80),Sn=class extends Ve{constructor(t=64){super(128,t,16,!1),this.Ah=Q[0]|0,this.Al=Q[1]|0,this.Bh=Q[2]|0,this.Bl=Q[3]|0,this.Ch=Q[4]|0,this.Cl=Q[5]|0,this.Dh=Q[6]|0,this.Dl=Q[7]|0,this.Eh=Q[8]|0,this.El=Q[9]|0,this.Fh=Q[10]|0,this.Fl=Q[11]|0,this.Gh=Q[12]|0,this.Gl=Q[13]|0,this.Hh=Q[14]|0,this.Hl=Q[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:u,El:y,Fh:l,Fl:f,Gh:d,Gl:h,Hh:E,Hl:S}=this;return[t,r,n,o,s,i,c,a,u,y,l,f,d,h,E,S]}set(t,r,n,o,s,i,c,a,u,y,l,f,d,h,E,S){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=u|0,this.El=y|0,this.Fh=l|0,this.Fl=f|0,this.Gh=d|0,this.Gl=h|0,this.Hh=E|0,this.Hl=S|0}process(t,r){for(let w=0;w<16;w++,r+=4)Vt[w]=t.getUint32(r),zt[w]=t.getUint32(r+=4);for(let w=16;w<80;w++){let T=Vt[w-15]|0,K=zt[w-15]|0,M=re(T,K,1)^re(T,K,8)^wn(T,K,7),P=ne(T,K,1)^ne(T,K,8)^En(T,K,7),R=Vt[w-2]|0,x=zt[w-2]|0,L=re(R,x,19)^ze(R,x,61)^wn(R,x,6),k=ne(R,x,19)^Fe(R,x,61)^En(R,x,6),C=ss(P,k,zt[w-7],zt[w-16]),b=is(C,M,L,Vt[w-7],Vt[w-16]);Vt[w]=b|0,zt[w]=C|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:u,Dl:y,Eh:l,El:f,Fh:d,Fl:h,Gh:E,Gl:S,Hh:g,Hl:B}=this;for(let w=0;w<80;w++){let T=re(l,f,14)^re(l,f,18)^ze(l,f,41),K=ne(l,f,14)^ne(l,f,18)^Fe(l,f,41),M=l&d^~l&E,P=f&h^~f&S,R=cs(B,K,P,na[w],zt[w]),x=as(R,g,T,M,ra[w],Vt[w]),L=R|0,k=re(n,o,28)^ze(n,o,34)^ze(n,o,39),C=ne(n,o,28)^Fe(n,o,34)^Fe(n,o,39),b=n&s^n&c^s&c,p=o&i^o&a^i&a;g=E|0,B=S|0,E=d|0,S=h|0,d=l|0,h=f|0,{h:l,l:f}=St(u|0,y|0,x|0,L|0),u=c|0,y=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let m=ns(L,C,p);n=os(m,x,k,b),o=m|0}({h:n,l:o}=St(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=St(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=St(this.Ch|0,this.Cl|0,c|0,a|0),{h:u,l:y}=St(this.Dh|0,this.Dl|0,u|0,y|0),{h:l,l:f}=St(this.Eh|0,this.El|0,l|0,f|0),{h:d,l:h}=St(this.Fh|0,this.Fl|0,d|0,h|0),{h:E,l:S}=St(this.Gh|0,this.Gl|0,E|0,S|0),{h:g,l:B}=St(this.Hh|0,this.Hl|0,g|0,B|0),this.set(n,o,s,i,c,a,u,y,l,f,d,h,E,S,g,B)}roundClean(){Ct(Vt,zt)}destroy(){Ct(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var us=xn(()=>new _n);var hs=xn(()=>new Sn);var An=BigInt(0),vn=BigInt(1);function Ut(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}"`;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function lt(e,t,r=""){let n=Lt(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,c=s?` of length ${t}`:"",a=n?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return e}function je(e){let t=e.toString(16);return t.length&1?"0"+t:t}function ls(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?An:BigInt("0x"+e)}function Ee(e){return ls(bt(e))}function Dt(e){return ct(e),ls(bt(Uint8Array.from(e).reverse()))}function yr(e,t){return ee(e.toString(16).padStart(t*2,"0"))}function In(e,t){return yr(e,t).reverse()}function H(e,t,r){let n;if(typeof t=="string")try{n=ee(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(Lt(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function ds(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Ln(e){return Uint8Array.from(e)}var Bn=e=>typeof e=="bigint"&&An<=e;function ps(e,t,r){return Bn(e)&&Bn(t)&&Bn(r)&&t<=e&&e<r}function Ze(e,t,r,n){if(!ps(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function br(e){let t;for(t=0;e>An;e>>=vn,t+=1);return t}var Ft=e=>(vn<<BigInt(e))-vn;function ms(e,t,r){if(typeof e!="number"||e<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 r!="function")throw new Error("hmacFn must be a function");let n=d=>new Uint8Array(d),o=d=>Uint8Array.of(d),s=n(e),i=n(e),c=0,a=()=>{s.fill(1),i.fill(0),c=0},u=(...d)=>r(i,s,...d),y=(d=n(0))=>{i=u(o(0),d),s=u(),d.length!==0&&(i=u(o(1),d),s=u())},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,h=[];for(;d<t;){s=u();let E=s.slice();h.push(E),d+=s.length}return rt(...h)};return(d,h)=>{a(),y(d);let E;for(;!(E=h(l()));)y();return a(),E}}function jt(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,s,i){let c=e[o];if(i&&c===void 0)return;let a=typeof c;if(a!==s||c===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${a}`)}Object.entries(t).forEach(([o,s])=>n(o,s,!1)),Object.entries(r).forEach(([o,s])=>n(o,s,!0))}var Cn=()=>{throw new Error("not implemented")};function _e(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let s=e(r,...n);return t.set(r,s),s}}var nt=BigInt(0),W=BigInt(1),oe=BigInt(2),gs=BigInt(3),xs=BigInt(4),ws=BigInt(5),oa=BigInt(7),Es=BigInt(8),sa=BigInt(9),_s=BigInt(16);function G(e,t){let r=e%t;return r>=nt?r:t+r}function V(e,t,r){let n=e;for(;t-- >nt;)n*=n,n%=r;return n}function ys(e,t){if(e===nt)throw new Error("invert: expected non-zero number");if(t<=nt)throw new Error("invert: expected positive modulus, got "+t);let r=G(e,t),n=t,o=nt,s=W,i=W,c=nt;for(;r!==nt;){let u=n/r,y=n%r,l=o-i*u,f=s-c*u;n=r,r=y,o=i,s=c,i=l,c=f}if(n!==W)throw new Error("invert: does not exist");return G(o,t)}function Tn(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Ss(e,t){let r=(e.ORDER+W)/xs,n=e.pow(t,r);return Tn(e,n,t),n}function ia(e,t){let r=(e.ORDER-ws)/Es,n=e.mul(t,oe),o=e.pow(n,r),s=e.mul(t,o),i=e.mul(e.mul(s,oe),o),c=e.mul(s,e.sub(i,e.ONE));return Tn(e,c,t),c}function ca(e){let t=dt(e),r=Bs(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+oa)/_s;return(c,a)=>{let u=c.pow(a,i),y=c.mul(u,n),l=c.mul(u,o),f=c.mul(u,s),d=c.eql(c.sqr(y),a),h=c.eql(c.sqr(l),a);u=c.cmov(u,y,d),y=c.cmov(f,l,h);let E=c.eql(c.sqr(y),a),S=c.cmov(u,y,E);return Tn(c,S,a),S}}function Bs(e){if(e<gs)throw new Error("sqrt is not defined for small field");let t=e-W,r=0;for(;t%oe===nt;)t/=oe,r++;let n=oe,o=dt(e);for(;bs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ss;let s=o.pow(n,t),i=(t+W)/oe;return function(a,u){if(a.is0(u))return u;if(bs(a,u)!==1)throw new Error("Cannot find square root");let y=r,l=a.mul(a.ONE,s),f=a.pow(u,t),d=a.pow(u,i);for(;!a.eql(f,a.ONE);){if(a.is0(f))return a.ZERO;let h=1,E=a.sqr(f);for(;!a.eql(E,a.ONE);)if(h++,E=a.sqr(E),h===y)throw new Error("Cannot find square root");let S=W<<BigInt(y-h-1),g=a.pow(l,S);y=h,l=a.sqr(g),f=a.mul(f,l),d=a.mul(d,g)}return d}}function aa(e){return e%xs===gs?Ss:e%Es===ws?ia:e%_s===sa?ca(e):Bs(e)}var Kt=(e,t)=>(G(e,t)&W)===W,fa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Un(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=fa.reduce((n,o)=>(n[o]="function",n),t);return jt(e,r),e}function ua(e,t,r){if(r<nt)throw new Error("invalid exponent, negatives unsupported");if(r===nt)return e.ONE;if(r===W)return t;let n=e.ONE,o=t;for(;r>nt;)r&W&&(n=e.mul(n,o)),o=e.sqr(o),r>>=W;return n}function Ge(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((i,c,a)=>e.is0(c)?i:(n[a]=i,e.mul(i,c)),e.ONE),s=e.inv(o);return t.reduceRight((i,c,a)=>e.is0(c)?i:(n[a]=e.mul(i,n[a]),e.mul(i,c)),s),n}function bs(e,t){let r=(e.ORDER-W)/oe,n=e.pow(t,r),o=e.eql(n,e.ONE),s=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function gr(e,t){t!==void 0&&He(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function dt(e,t,r=!1,n={}){if(e<=nt)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,s,i=!1,c;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(r=f.isLE),typeof f.modFromBytes=="boolean"&&(i=f.modFromBytes),c=f.allowedLengths}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:a,nByteLength:u}=gr(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let y,l=Object.freeze({ORDER:e,isLE:r,BITS:a,BYTES:u,MASK:Ft(a),ZERO:nt,ONE:W,allowedLengths:c,create:f=>G(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return nt<=f&&f<e},is0:f=>f===nt,isValidNot0:f=>!l.is0(f)&&l.isValid(f),isOdd:f=>(f&W)===W,neg:f=>G(-f,e),eql:(f,d)=>f===d,sqr:f=>G(f*f,e),add:(f,d)=>G(f+d,e),sub:(f,d)=>G(f-d,e),mul:(f,d)=>G(f*d,e),pow:(f,d)=>ua(l,f,d),div:(f,d)=>G(f*ys(d,e),e),sqrN:f=>f*f,addN:(f,d)=>f+d,subN:(f,d)=>f-d,mulN:(f,d)=>f*d,inv:f=>ys(f,e),sqrt:s||(f=>(y||(y=aa(e)),y(l,f))),toBytes:f=>r?In(f,u):yr(f,u),fromBytes:(f,d=!0)=>{if(c){if(!c.includes(f.length)||f.length>u)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+f.length);let E=new Uint8Array(u);E.set(f,r?0:E.length-f.length),f=E}if(f.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+f.length);let h=r?Dt(f):Ee(f);if(i&&(h=G(h,e)),!d&&!l.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:f=>Ge(l,f),cmov:(f,d,h)=>h?d:f});return Object.freeze(l)}function vs(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Dn(e){let t=vs(e);return t+Math.ceil(t/2)}function Kn(e,t,r=!1){let n=e.length,o=vs(t),s=Dn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Dt(e):Ee(e),c=G(i,t-W)+W;return r?In(c,o):yr(c,o)}var Se=BigInt(0),se=BigInt(1);function Ye(e,t){let r=t.negate();return e?r:t}function Rt(e,t){let r=Ge(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Cs(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Rn(e,t){Cs(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=Ft(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function As(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,c=Number(e&o),a=e>>i;c>n&&(c-=s,a+=se);let u=t*n,y=u+Math.abs(c)-1,l=c===0,f=c<0,d=t%2!==0;return{nextN:a,offset:y,isZero:l,isNeg:f,isNegF:d,offsetF:u}}function ha(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function la(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var kn=new WeakMap,Ts=new WeakMap;function Nn(e){return Ts.get(e)||1}function Is(e){if(e!==Se)throw new Error("invalid wNAF")}var Be=class{constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Se;)r&se&&(n=n.add(o)),o=o.double(),r>>=se;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Rn(r,this.bits),s=[],i=t,c=i;for(let a=0;a<n;a++){c=i,s.push(c);for(let u=1;u<o;u++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=Rn(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:a,offset:u,isZero:y,isNeg:l,isNegF:f,offsetF:d}=As(n,c,i);n=a,y?s=s.add(Ye(f,r[d])):o=o.add(Ye(l,r[u]))}return Is(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=Rn(t,this.bits);for(let i=0;i<s.windows&&n!==Se;i++){let{nextN:c,offset:a,isZero:u,isNeg:y}=As(n,i,s);if(n=c,!u){let l=r[a];o=o.add(y?l.negate():l)}}return Is(n),o}getPrecomputes(t,r,n){let o=kn.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),kn.set(r,o))),o}cached(t,r,n){let o=Nn(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=Nn(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){Cs(r,this.bits),Ts.set(t,r),kn.delete(t)}hasCache(t){return Nn(t)!==1}};function Us(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>Se||n>Se;)r&se&&(s=s.add(o)),n&se&&(i=i.add(o)),o=o.double(),r>>=se,n>>=se;return{p1:s,p2:i}}function ve(e,t,r,n){ha(r,e),la(n,t);let o=r.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=e.ZERO,c=br(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let u=Ft(a),y=new Array(Number(u)+1).fill(i),l=Math.floor((t.BITS-1)/a)*a,f=i;for(let d=l;d>=0;d-=a){y.fill(i);for(let E=0;E<s;E++){let S=n[E],g=Number(S>>BigInt(d)&u);y[g]=y[g].add(r[E])}let h=i;for(let E=y.length-1,S=i;E>0;E--)S=S.add(y[E]),h=h.add(S);if(f=f.add(h),d!==0)for(let E=0;E<a;E++)f=f.double()}return f}function Ls(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Un(t),t}else return dt(e,{isLE:r})}function xr(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let a of["p","n","h"]){let u=t[a];if(!(typeof u=="bigint"&&u>Se))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Ls(t.p,r.Fp,n),s=Ls(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}var Zt=BigInt(0),J=BigInt(1),Pn=BigInt(2),da=BigInt(8);function pa(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),c=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,c)}function ma(e,t={}){let r=xr("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i}=s;jt(t,{},{uvRatio:"function"});let c=Pn<<BigInt(o.BYTES*8)-J,a=S=>n.create(S),u=t.uvRatio||((S,g)=>{try{return{isValid:!0,value:n.sqrt(n.div(S,g))}}catch{return{isValid:!1,value:Zt}}});if(!pa(n,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function y(S,g,B=!1){let w=B?J:Zt;return Ze("coordinate "+S,g,w,c),g}function l(S){if(!(S instanceof h))throw new Error("ExtendedPoint expected")}let f=_e((S,g)=>{let{X:B,Y:w,Z:T}=S,K=S.is0();g==null&&(g=K?da:n.inv(T));let M=a(B*g),P=a(w*g),R=n.mul(T,g);if(K)return{x:Zt,y:J};if(R!==J)throw new Error("invZ was invalid");return{x:M,y:P}}),d=_e(S=>{let{a:g,d:B}=s;if(S.is0())throw new Error("bad point: ZERO");let{X:w,Y:T,Z:K,T:M}=S,P=a(w*w),R=a(T*T),x=a(K*K),L=a(x*x),k=a(P*g),C=a(x*a(k+R)),b=a(L+a(B*a(P*R)));if(C!==b)throw new Error("bad point: equation left != right (1)");let p=a(w*T),m=a(K*M);if(p!==m)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(g,B,w,T){this.X=y("x",g),this.Y=y("y",B),this.Z=y("z",w,!0),this.T=y("t",T),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof h)throw new Error("extended point not allowed");let{x:B,y:w}=g||{};return y("x",B),y("y",w),new h(B,w,J,a(B*w))}static fromBytes(g,B=!1){let w=n.BYTES,{a:T,d:K}=s;g=Ln(lt(g,w,"point")),Ut(B,"zip215");let M=Ln(g),P=g[w-1];M[w-1]=P&-129;let R=Dt(M),x=B?c:n.ORDER;Ze("point.y",R,Zt,x);let L=a(R*R),k=a(L-J),C=a(K*L-T),{isValid:b,value:p}=u(k,C);if(!b)throw new Error("bad point: invalid y coordinate");let m=(p&J)===J,_=(P&128)!==0;if(!B&&p===Zt&&_)throw new Error("bad point: x=0 and x_0=1");return _!==m&&(p=a(-p)),h.fromAffine({x:p,y:R})}static fromHex(g,B=!1){return h.fromBytes(H("point",g),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,B=!0){return E.createCache(this,g),B||this.multiply(Pn),this}assertValidity(){d(this)}equals(g){l(g);let{X:B,Y:w,Z:T}=this,{X:K,Y:M,Z:P}=g,R=a(B*P),x=a(K*T),L=a(w*P),k=a(M*T);return R===x&&L===k}is0(){return this.equals(h.ZERO)}negate(){return new h(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:g}=s,{X:B,Y:w,Z:T}=this,K=a(B*B),M=a(w*w),P=a(Pn*a(T*T)),R=a(g*K),x=B+w,L=a(a(x*x)-K-M),k=R+M,C=k-P,b=R-M,p=a(L*C),m=a(k*b),_=a(L*b),v=a(C*k);return new h(p,m,v,_)}add(g){l(g);let{a:B,d:w}=s,{X:T,Y:K,Z:M,T:P}=this,{X:R,Y:x,Z:L,T:k}=g,C=a(T*R),b=a(K*x),p=a(P*w*k),m=a(M*L),_=a((T+K)*(R+x)-C-b),v=m-p,U=m+p,A=a(b-B*C),I=a(_*v),D=a(U*A),N=a(_*A),z=a(v*U);return new h(I,D,z,N)}subtract(g){return this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:w}=E.cached(this,g,T=>Rt(h,T));return Rt(h,[B,w])[0]}multiplyUnsafe(g,B=h.ZERO){if(!o.isValid(g))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return g===Zt?h.ZERO:this.is0()||g===J?this:E.unsafe(this,g,w=>Rt(h,w),B)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return E.unsafe(this,s.n).is0()}toAffine(g){return f(this,g)}clearCofactor(){return i===J?this:this.multiplyUnsafe(i)}toBytes(){let{x:g,y:B}=this.toAffine(),w=n.toBytes(B);return w[w.length-1]|=g&J?128:0,w}toHex(){return bt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(g){return Rt(h,g)}static msm(g,B){return ve(h,o,g,B)}_setWindowSize(g){this.precompute(g)}toRawBytes(){return this.toBytes()}}h.BASE=new h(s.Gx,s.Gy,J,a(s.Gx*s.Gy)),h.ZERO=new h(Zt,J,J,Zt),h.Fp=n,h.Fn=o;let E=new Be(h,o.BITS);return h.BASE.precompute(8),h}var wr=class{constructor(t){this.ep=t}static fromBytes(t){Cn()}static fromHex(t){Cn()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return bt(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.init(this.ep.precompute(t,r))}toRawBytes(){return this.toBytes()}};function ya(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');jt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:s,Fn:i}=e,c=r.randomBytes||we,a=r.adjustScalarBytes||(x=>x),u=r.domain||((x,L,k)=>{if(Ut(k,"phflag"),L.length||k)throw new Error("Contexts/pre-hash are not supported");return x});function y(x){return i.create(Dt(x))}function l(x){let L=w.secretKey;x=H("private key",x,L);let k=H("hashed private key",t(x),2*L),C=a(k.slice(0,L)),b=k.slice(L,2*L),p=y(C);return{head:C,prefix:b,scalar:p}}function f(x){let{head:L,prefix:k,scalar:C}=l(x),b=o.multiply(C),p=b.toBytes();return{head:L,prefix:k,scalar:C,point:b,pointBytes:p}}function d(x){return f(x).pointBytes}function h(x=Uint8Array.of(),...L){let k=rt(...L);return y(t(u(k,H("context",x),!!n)))}function E(x,L,k={}){x=H("message",x),n&&(x=n(x));let{prefix:C,scalar:b,pointBytes:p}=f(L),m=h(k.context,C,x),_=o.multiply(m).toBytes(),v=h(k.context,_,p,x),U=i.create(m+v*b);if(!i.isValid(U))throw new Error("sign failed: invalid s");let A=rt(_,i.toBytes(U));return lt(A,w.signature,"result")}let S={zip215:!0};function g(x,L,k,C=S){let{context:b,zip215:p}=C,m=w.signature;x=H("signature",x,m),L=H("message",L),k=H("publicKey",k,w.publicKey),p!==void 0&&Ut(p,"zip215"),n&&(L=n(L));let _=m/2,v=x.subarray(0,_),U=Dt(x.subarray(_,m)),A,I,D;try{A=e.fromBytes(k,p),I=e.fromBytes(v,p),D=o.multiplyUnsafe(U)}catch{return!1}if(!p&&A.isSmallOrder())return!1;let N=h(b,I.toBytes(),A.toBytes(),L);return I.add(A.multiplyUnsafe(N)).subtract(D).clearCofactor().is0()}let B=s.BYTES,w={secretKey:B,publicKey:B,signature:2*B,seed:B};function T(x=c(w.seed)){return lt(x,w.seed,"seed")}function K(x){let L=R.randomSecretKey(x);return{secretKey:L,publicKey:d(L)}}function M(x){return Lt(x)&&x.length===i.BYTES}function P(x,L){try{return!!e.fromBytes(x,L)}catch{return!1}}let R={getExtendedPublicKey:f,randomSecretKey:T,isValidSecretKey:M,isValidPublicKey:P,toMontgomery(x){let{y:L}=e.fromBytes(x),k=w.publicKey,C=k===32;if(!C&&k!==57)throw new Error("only defined for 25519 and 448");let b=C?s.div(J+L,J-L):s.div(L-J,L+J);return s.toBytes(b)},toMontgomerySecret(x){let L=w.secretKey;lt(x,L);let k=t(x.subarray(0,L));return a(k).subarray(0,L)},randomPrivateKey:T,precompute(x=8,L=e.BASE){return L.precompute(x,!1)}};return Object.freeze({keygen:K,getPublicKey:d,sign:E,verify:g,utils:R,Point:e,lengths:w})}function ba(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=dt(t.n,e.nBitLength,!0),o={Fp:r,Fn:n,uvRatio:e.uvRatio},s={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:s}}function ga(e,t){let r=t.Point;return Object.assign({},t,{ExtendedPoint:r,CURVE:e,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}function Ds(e){let{CURVE:t,curveOpts:r,hash:n,eddsaOpts:o}=ba(e),s=ma(t,r),i=ya(s,n,o);return ga(e,i)}var xa=BigInt(0),kt=BigInt(1),Ks=BigInt(2),Sh=BigInt(3),wa=BigInt(5),Ea=BigInt(8),Ae=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Xe={p:Ae,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Ea,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function _a(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ae,c=e*e%s*e%s,a=V(c,Ks,s)*c%s,u=V(a,kt,s)*e%s,y=V(u,wa,s)*u%s,l=V(y,t,s)*y%s,f=V(l,r,s)*l%s,d=V(f,n,s)*f%s,h=V(d,o,s)*d%s,E=V(h,o,s)*d%s,S=V(E,t,s)*y%s;return{pow_p_5_8:V(S,Ks,s)*e%s,b2:c}}function Sa(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Mn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function qn(e,t){let r=Ae,n=G(t*t*t,r),o=G(n*n*t,r),s=_a(e*o).pow_p_5_8,i=G(e*n*s,r),c=G(t*i*i,r),a=i,u=G(i*Mn,r),y=c===e,l=c===G(-e,r),f=c===G(-e*Mn,r);return y&&(i=a),(l||f)&&(i=u),Kt(i,r)&&(i=G(-i,r)),{isValid:y||l,value:i}}var Gt=dt(Xe.p,{isLE:!0}),Ba=dt(Xe.n,{isLE:!0}),va={...Xe,Fp:Gt,hash:hs,adjustScalarBytes:Sa,uvRatio:qn},Nt=Ds(va);var On=Mn,Aa=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Ia=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),La=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Ca=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Rs=e=>qn(kt,e),Ta=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Hn=e=>Nt.Point.Fp.create(Dt(e)&Ta);function ks(e){let{d:t}=Xe,r=Ae,n=g=>Gt.create(g),o=n(On*e*e),s=n((o+kt)*La),i=BigInt(-1),c=n((i-t*o)*n(o+t)),{isValid:a,value:u}=qn(s,c),y=n(u*e);Kt(y,r)||(y=n(-y)),a||(u=y),a||(i=o);let l=n(i*(o-kt)*Ca-c),f=u*u,d=n((u+u)*c),h=n(l*Aa),E=n(kt-f),S=n(kt+f);return new Nt.Point(n(d*S),n(E*h),n(h*S),n(d*E))}function Ua(e){ct(e,64);let t=Hn(e.subarray(0,32)),r=ks(t),n=Hn(e.subarray(32,64)),o=ks(n);return new Pt(r.add(o))}var Pt=class e extends wr{constructor(t){super(t)}static fromAffine(t){return new e(Nt.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static hashToCurve(t){return Ua(H("ristrettoHash",t,64))}static fromBytes(t){ct(t,32);let{a:r,d:n}=Xe,o=Ae,s=T=>Gt.create(T),i=Hn(t);if(!ds(Gt.toBytes(i),t)||Kt(i,o))throw new Error("invalid ristretto255 encoding 1");let c=s(i*i),a=s(kt+r*c),u=s(kt-r*c),y=s(a*a),l=s(u*u),f=s(r*n*y-l),{isValid:d,value:h}=Rs(s(f*l)),E=s(h*u),S=s(h*E*f),g=s((i+i)*E);Kt(g,o)&&(g=s(-g));let B=s(a*S),w=s(g*B);if(!d||Kt(w,o)||B===xa)throw new Error("invalid ristretto255 encoding 2");return new e(new Nt.Point(g,B,kt,w))}static fromHex(t){return e.fromBytes(H("ristrettoHex",t,32))}static msm(t,r){return ve(e,Nt.Point.Fn,t,r)}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=Ae,i=S=>Gt.create(S),c=i(i(n+r)*i(n-r)),a=i(t*r),u=i(a*a),{value:y}=Rs(i(c*u)),l=i(y*c),f=i(y*a),d=i(l*f*o),h;if(Kt(o*d,s)){let S=i(r*On),g=i(t*On);t=S,r=g,h=i(l*Ia)}else h=f;Kt(t*d,s)&&(r=i(-r));let E=i((n-r)*h);return Kt(E,s)&&(E=i(-E)),Gt.toBytes(E)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=u=>Gt.create(u),c=i(r*s)===i(n*o),a=i(n*s)===i(r*o);return c||a}is0(){return this.equals(e.ZERO)}};Pt.BASE=new Pt(Nt.Point.BASE);Pt.ZERO=new Pt(Nt.Point.ZERO);Pt.Fp=Gt;Pt.Fn=Ba;var $e=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Er=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Ns={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Er("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var _r=Ns;var Sr=32;var Vn,Da=(async()=>{try{return await _r.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Ka(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await _r.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await _r.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Ra(e,t,r){return Nt.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Ps(e,t,r){return Vn==null&&(Vn=await Da),Vn?Ka(e,t,r):Ra(e,t,r)}function Br(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var vr=class{type="Ed25519";raw;constructor(t){this.raw=zn(t,Sr)}toMultihash(){return gt.digest(be(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Ps(this.raw,r,t);return Br(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Os(e){return e=zn(e,Sr),new vr(e)}function zn(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new vt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Na=Math.pow(2,7),Pa=Math.pow(2,14),Ma=Math.pow(2,21),Hs=Math.pow(2,28),qs=Math.pow(2,35),Vs=Math.pow(2,42),zs=Math.pow(2,49),ot=128,Yt=127;function We(e){if(e<Na)return 1;if(e<Pa)return 2;if(e<Ma)return 3;if(e<Hs)return 4;if(e<qs)return 5;if(e<Vs)return 6;if(e<zs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Fs(e,t,r=0){switch(We(e)){case 8:t[r++]=e&255|ot,e/=128;case 7:t[r++]=e&255|ot,e/=128;case 6:t[r++]=e&255|ot,e/=128;case 5:t[r++]=e&255|ot,e/=128;case 4:t[r++]=e&255|ot,e>>>=7;case 3:t[r++]=e&255|ot,e>>>=7;case 2:t[r++]=e&255|ot,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function js(e,t){let r=e[t],n=0;if(n+=r&Yt,r<ot||(r=e[t+1],n+=(r&Yt)<<7,r<ot)||(r=e[t+2],n+=(r&Yt)<<14,r<ot)||(r=e[t+3],n+=(r&Yt)<<21,r<ot)||(r=e[t+4],n+=(r&Yt)*Hs,r<ot)||(r=e[t+5],n+=(r&Yt)*qs,r<ot)||(r=e[t+6],n+=(r&Yt)*Vs,r<ot)||(r=e[t+7],n+=(r&Yt)*zs,r<ot))return n;throw new RangeError("Could not decode varint")}var Fn=new Float32Array([-0]),Xt=new Uint8Array(Fn.buffer);function Zs(e,t,r){Fn[0]=e,t[r]=Xt[0],t[r+1]=Xt[1],t[r+2]=Xt[2],t[r+3]=Xt[3]}function Gs(e,t){return Xt[0]=e[t],Xt[1]=e[t+1],Xt[2]=e[t+2],Xt[3]=e[t+3],Fn[0]}var jn=new Float64Array([-0]),et=new Uint8Array(jn.buffer);function Ys(e,t,r){jn[0]=e,t[r]=et[0],t[r+1]=et[1],t[r+2]=et[2],t[r+3]=et[3],t[r+4]=et[4],t[r+5]=et[5],t[r+6]=et[6],t[r+7]=et[7]}function Xs(e,t){return et[0]=e[t],et[1]=e[t+1],et[2]=e[t+2],et[3]=e[t+3],et[4]=e[t+4],et[5]=e[t+5],et[6]=e[t+6],et[7]=e[t+7],jn[0]}var Oa=BigInt(Number.MAX_SAFE_INTEGER),Ha=BigInt(Number.MIN_SAFE_INTEGER),pt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+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 r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ie;if(t<Oa&&t>Ha)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>$s&&(o=0n,++n>$s&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ie;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):ie}},ie=new pt(0,0);ie.toBigInt=function(){return 0n};ie.zzEncode=ie.zzDecode=function(){return this};ie.length=function(){return 1};var $s=4294967296n;function Ws(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Js(e,t,r){if(r-t<1)return"";let o,s=[],i=0,c;for(;t<r;)c=e[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(e[t++]&63)<<6|e[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 Zn(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Et(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ar(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Gn=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,Et(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 Et(this,4);return Ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Et(this,4);return Ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Et(this,4);let t=Gs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Et(this,4);let t=Xs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Et(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Js(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Et(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Et(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new pt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Et(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Et(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Et(this,8);let t=Ar(this.buf,this.pos+=4),r=Ar(this.buf,this.pos+=4);return new pt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=js(this.buf,this.pos);return this.pos+=We(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 Yn(e){return new Gn(e instanceof Uint8Array?e:e.subarray())}function Ir(e,t,r){let n=Yn(e);return t.decode(n,void 0,r)}function Xn(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return ut(i);o+i>t&&(n=ut(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var ce=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function $n(){}var Jn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},qa=Xn();function Va(e){return globalThis.Buffer!=null?ut(e):qa(e)}var Qe=class{len;head;tail;states;constructor(){this.len=0,this.head=new ce($n,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new ce(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Qn((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(Lr,10,pt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=pt.fromBigInt(t);return this._push(Lr,r.length(),r)}uint64Number(t){return this._push(Fs,We(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 r=pt.fromBigInt(t).zzEncode();return this._push(Lr,r.length(),r)}sint64Number(t){let r=pt.fromNumber(t).zzEncode();return this._push(Lr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Wn,1,t?1:0)}fixed32(t){return this._push(Je,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=pt.fromBigInt(t);return this._push(Je,4,r.lo)._push(Je,4,r.hi)}fixed64Number(t){let r=pt.fromNumber(t);return this._push(Je,4,r.lo)._push(Je,4,r.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(Zs,4,t)}double(t){return this._push(Ys,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Wn,1,0):this.uint32(r)._push(Fa,r,t)}string(t){let r=Ws(t);return r!==0?this.uint32(r)._push(Zn,r,t):this._push(Wn,1,0)}fork(){return this.states=new Jn(this),this.head=this.tail=new ce($n,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 ce($n,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Va(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Wn(e,t,r){t[r]=e&255}function za(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Qn=class extends ce{next;constructor(t,r){super(za,t,r),this.next=void 0}};function Lr(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Je(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Fa(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Qe.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ja,t,e),this},Qe.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Za,t,e),this});function ja(e,t,r){t.set(e,r)}function Za(e,t,r){e.length<40?Zn(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set($(e),r)}function to(){return new Qe}function Cr(e,t){let r=to();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Ie;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(Ie||(Ie={}));function Tr(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function eo(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return Tr("enum",Ie.VARINT,r,n)}function Ur(e,t){return Tr("message",Ie.LENGTH_DELIMITED,e,t)}var mt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(mt||(mt={}));var ro;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(ro||(ro={}));(function(e){e.codec=()=>eo(ro)})(mt||(mt={}));var tr;(function(e){let t;e.codec=()=>(t==null&&(t=Ur((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),mt.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let c=r.uint32();switch(c>>>3){case 1:{s.Type=mt.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return s})),t),e.encode=r=>Cr(r,e.codec()),e.decode=(r,n)=>Ir(r,e.codec(),n)})(tr||(tr={}));var no;(function(e){let t;e.codec=()=>(t==null&&(t=Ur((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),mt.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let c=r.uint32();switch(c>>>3){case 1:{s.Type=mt.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return s})),t),e.encode=r=>Cr(r,e.codec()),e.decode=(r,n)=>Ir(r,e.codec(),n)})(no||(no={}));var Dr=class extends ge{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,dr(t);let n=qe(r);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),Ct(s)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),ct(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:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},oo=(e,t,r)=>new Dr(e,t).update(r).digest();oo.create=(e,t)=>new Dr(e,t);var ti=(e,t)=>(e+(e>=0?t:-t)/ei)/t;function Ya(e,t,r){let[[n,o],[s,i]]=t,c=ti(i*e,r),a=ti(-o*e,r),u=e-c*n-a*s,y=-c*o-a*i,l=u<Ot,f=y<Ot;l&&(u=-u),f&&(y=-y);let d=Ft(Math.ceil(br(r)/2))+Ce;if(u<Ot||u>=d||y<Ot||y>=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:y}}function io(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function so(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Ut(r.lowS,"lowS"),Ut(r.prehash,"prehash"),r.format!==void 0&&io(r.format),r}var co=class extends Error{constructor(t=""){super(t)}},Mt={Err:co,_tlv:{encode:(e,t)=>{let{Err:r}=Mt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=je(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?je(o.length/2|128):"";return je(e)+s+o+t},decode(e,t){let{Err:r}=Mt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let y of u)i=i<<8|y;if(n+=a,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=Mt;if(e<Ot)throw new t("integer: negative integers are not allowed");let r=je(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Mt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ee(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Mt,o=H("signature",e),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:u,l:y}=n.decode(2,a);if(y.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Mt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}},Ot=BigInt(0),Ce=BigInt(1),ei=BigInt(2),Kr=BigInt(3),Xa=BigInt(4);function Le(e,t){let{BYTES:r}=e,n;if(typeof t=="bigint")n=t;else{let o=H("private key",t);try{n=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof t}`)}}if(!e.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function $a(e,t={}){let r=xr("weierstrass",e,t),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i,n:c}=s;jt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:a}=t;if(a&&(!n.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=ni(n,o);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(C,b,p){let{x:m,y:_}=b.toAffine(),v=n.toBytes(m);if(Ut(p,"isCompressed"),p){y();let U=!n.isOdd(_);return rt(ri(U),v)}else return rt(Uint8Array.of(4),v,n.toBytes(_))}function f(C){lt(C,void 0,"Point");let{publicKey:b,publicKeyUncompressed:p}=u,m=C.length,_=C[0],v=C.subarray(1);if(m===b&&(_===2||_===3)){let U=n.fromBytes(v);if(!n.isValid(U))throw new Error("bad point: is not on curve, wrong x");let A=E(U),I;try{I=n.sqrt(A)}catch(z){let q=z instanceof Error?": "+z.message:"";throw new Error("bad point: is not on curve, sqrt error"+q)}y();let D=n.isOdd(I);return(_&1)===1!==D&&(I=n.neg(I)),{x:U,y:I}}else if(m===p&&_===4){let U=n.BYTES,A=n.fromBytes(v.subarray(0,U)),I=n.fromBytes(v.subarray(U,U*2));if(!S(A,I))throw new Error("bad point: is not on curve");return{x:A,y:I}}else throw new Error(`bad point: got length ${m}, expected compressed=${b} or uncompressed=${p}`)}let d=t.toBytes||l,h=t.fromBytes||f;function E(C){let b=n.sqr(C),p=n.mul(b,C);return n.add(n.add(p,n.mul(C,s.a)),s.b)}function S(C,b){let p=n.sqr(b),m=E(C);return n.eql(p,m)}if(!S(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let g=n.mul(n.pow(s.a,Kr),Xa),B=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(g,B)))throw new Error("bad curve params: a or b");function w(C,b,p=!1){if(!n.isValid(b)||p&&n.is0(b))throw new Error(`bad point coordinate ${C}`);return b}function T(C){if(!(C instanceof x))throw new Error("ProjectivePoint expected")}function K(C){if(!a||!a.basises)throw new Error("no endo");return Ya(C,a.basises,o.ORDER)}let M=_e((C,b)=>{let{X:p,Y:m,Z:_}=C;if(n.eql(_,n.ONE))return{x:p,y:m};let v=C.is0();b==null&&(b=v?n.ONE:n.inv(_));let U=n.mul(p,b),A=n.mul(m,b),I=n.mul(_,b);if(v)return{x:n.ZERO,y:n.ZERO};if(!n.eql(I,n.ONE))throw new Error("invZ was invalid");return{x:U,y:A}}),P=_e(C=>{if(C.is0()){if(t.allowInfinityPoint&&!n.is0(C.Y))return;throw new Error("bad point: ZERO")}let{x:b,y:p}=C.toAffine();if(!n.isValid(b)||!n.isValid(p))throw new Error("bad point: x or y not field elements");if(!S(b,p))throw new Error("bad point: equation left != right");if(!C.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function R(C,b,p,m,_){return p=new x(n.mul(p.X,C),p.Y,p.Z),b=Ye(m,b),p=Ye(_,p),b.add(p)}class x{constructor(b,p,m){this.X=w("x",b),this.Y=w("y",p,!0),this.Z=w("z",m),Object.freeze(this)}static CURVE(){return s}static fromAffine(b){let{x:p,y:m}=b||{};if(!b||!n.isValid(p)||!n.isValid(m))throw new Error("invalid affine point");if(b instanceof x)throw new Error("projective point not allowed");return n.is0(p)&&n.is0(m)?x.ZERO:new x(p,m,n.ONE)}static fromBytes(b){let p=x.fromAffine(h(lt(b,void 0,"point")));return p.assertValidity(),p}static fromHex(b){return x.fromBytes(H("pointHex",b))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(b=8,p=!0){return k.createCache(this,b),p||this.multiply(Kr),this}assertValidity(){P(this)}hasEvenY(){let{y:b}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(b)}equals(b){T(b);let{X:p,Y:m,Z:_}=this,{X:v,Y:U,Z:A}=b,I=n.eql(n.mul(p,A),n.mul(v,_)),D=n.eql(n.mul(m,A),n.mul(U,_));return I&&D}negate(){return new x(this.X,n.neg(this.Y),this.Z)}double(){let{a:b,b:p}=s,m=n.mul(p,Kr),{X:_,Y:v,Z:U}=this,A=n.ZERO,I=n.ZERO,D=n.ZERO,N=n.mul(_,_),z=n.mul(v,v),q=n.mul(U,U),O=n.mul(_,v);return O=n.add(O,O),D=n.mul(_,U),D=n.add(D,D),A=n.mul(b,D),I=n.mul(m,q),I=n.add(A,I),A=n.sub(z,I),I=n.add(z,I),I=n.mul(A,I),A=n.mul(O,A),D=n.mul(m,D),q=n.mul(b,q),O=n.sub(N,q),O=n.mul(b,O),O=n.add(O,D),D=n.add(N,N),N=n.add(D,N),N=n.add(N,q),N=n.mul(N,O),I=n.add(I,N),q=n.mul(v,U),q=n.add(q,q),N=n.mul(q,O),A=n.sub(A,N),D=n.mul(q,z),D=n.add(D,D),D=n.add(D,D),new x(A,I,D)}add(b){T(b);let{X:p,Y:m,Z:_}=this,{X:v,Y:U,Z:A}=b,I=n.ZERO,D=n.ZERO,N=n.ZERO,z=s.a,q=n.mul(s.b,Kr),O=n.mul(p,v),F=n.mul(m,U),X=n.mul(_,A),st=n.add(p,m),j=n.add(v,U);st=n.mul(st,j),j=n.add(O,F),st=n.sub(st,j),j=n.add(p,_);let tt=n.add(v,A);return j=n.mul(j,tt),tt=n.add(O,X),j=n.sub(j,tt),tt=n.add(m,_),I=n.add(U,A),tt=n.mul(tt,I),I=n.add(F,X),tt=n.sub(tt,I),N=n.mul(z,j),I=n.mul(q,X),N=n.add(I,N),I=n.sub(F,N),N=n.add(F,N),D=n.mul(I,N),F=n.add(O,O),F=n.add(F,O),X=n.mul(z,X),j=n.mul(q,j),F=n.add(F,X),X=n.sub(O,X),X=n.mul(z,X),j=n.add(j,X),O=n.mul(F,j),D=n.add(D,O),O=n.mul(tt,j),I=n.mul(st,I),I=n.sub(I,O),O=n.mul(st,F),N=n.mul(tt,N),N=n.add(N,O),new x(I,D,N)}subtract(b){return this.add(b.negate())}is0(){return this.equals(x.ZERO)}multiply(b){let{endo:p}=t;if(!o.isValidNot0(b))throw new Error("invalid scalar: out of range");let m,_,v=U=>k.cached(this,U,A=>Rt(x,A));if(p){let{k1neg:U,k1:A,k2neg:I,k2:D}=K(b),{p:N,f:z}=v(A),{p:q,f:O}=v(D);_=z.add(O),m=R(p.beta,N,q,U,I)}else{let{p:U,f:A}=v(b);m=U,_=A}return Rt(x,[m,_])[0]}multiplyUnsafe(b){let{endo:p}=t,m=this;if(!o.isValid(b))throw new Error("invalid scalar: out of range");if(b===Ot||m.is0())return x.ZERO;if(b===Ce)return m;if(k.hasCache(this))return this.multiply(b);if(p){let{k1neg:_,k1:v,k2neg:U,k2:A}=K(b),{p1:I,p2:D}=Us(x,m,v,A);return R(p.beta,I,D,_,U)}else return k.unsafe(m,b)}multiplyAndAddUnsafe(b,p,m){let _=this.multiplyUnsafe(p).add(b.multiplyUnsafe(m));return _.is0()?void 0:_}toAffine(b){return M(this,b)}isTorsionFree(){let{isTorsionFree:b}=t;return i===Ce?!0:b?b(x,this):k.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:b}=t;return i===Ce?this:b?b(x,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(b=!0){return Ut(b,"isCompressed"),this.assertValidity(),d(x,this,b)}toHex(b=!0){return bt(this.toBytes(b))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(b=!0){return this.toBytes(b)}_setWindowSize(b){this.precompute(b)}static normalizeZ(b){return Rt(x,b)}static msm(b,p){return ve(x,o,b,p)}static fromPrivateKey(b){return x.BASE.multiply(Le(o,b))}}x.BASE=new x(s.Gx,s.Gy,n.ONE),x.ZERO=new x(n.ZERO,n.ONE,n.ZERO),x.Fp=n,x.Fn=o;let L=o.BITS,k=new Be(x,t.endo?Math.ceil(L/2):L);return x.BASE.precompute(8),x}function ri(e){return Uint8Array.of(e?2:3)}function ni(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Wa(e,t={}){let{Fn:r}=e,n=t.randomBytes||we,o=Object.assign(ni(e.Fp,r),{seed:Dn(r.ORDER)});function s(d){try{return!!Le(r,d)}catch{return!1}}function i(d,h){let{publicKey:E,publicKeyUncompressed:S}=o;try{let g=d.length;return h===!0&&g!==E||h===!1&&g!==S?!1:!!e.fromBytes(d)}catch{return!1}}function c(d=n(o.seed)){return Kn(lt(d,o.seed,"seed"),r.ORDER)}function a(d,h=!0){return e.BASE.multiply(Le(r,d)).toBytes(h)}function u(d){let h=c(d);return{secretKey:h,publicKey:a(h)}}function y(d){if(typeof d=="bigint")return!1;if(d instanceof e)return!0;let{secretKey:h,publicKey:E,publicKeyUncompressed:S}=o;if(r.allowedLengths||h===E)return;let g=H("key",d).length;return g===E||g===S}function l(d,h,E=!0){if(y(d)===!0)throw new Error("first arg must be private key");if(y(h)===!1)throw new Error("second arg must be public key");let S=Le(r,d);return e.fromHex(h).multiply(S).toBytes(E)}return Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:u,Point:e,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:d=>Le(r,d),precompute(d=8,h=e.BASE){return h.precompute(d,!1)}},lengths:o})}function Ja(e,t,r={}){dr(t),jt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||we,o=r.hmac||((p,...m)=>oo(t,p,rt(...m))),{Fp:s,Fn:i}=e,{ORDER:c,BITS:a}=i,{keygen:u,getPublicKey:y,getSharedSecret:l,utils:f,lengths:d}=Wa(e,r),h={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},E="compact";function S(p){let m=c>>Ce;return p>m}function g(p,m){if(!i.isValidNot0(m))throw new Error(`invalid signature ${p}: out of range 1..Point.Fn.ORDER`);return m}function B(p,m){io(m);let _=d.signature,v=m==="compact"?_:m==="recovered"?_+1:void 0;return lt(p,v,`${m} signature`)}class w{constructor(m,_,v){this.r=g("r",m),this.s=g("s",_),v!=null&&(this.recovery=v),Object.freeze(this)}static fromBytes(m,_=E){B(m,_);let v;if(_==="der"){let{r:D,s:N}=Mt.toSig(lt(m));return new w(D,N)}_==="recovered"&&(v=m[0],_="compact",m=m.subarray(1));let U=i.BYTES,A=m.subarray(0,U),I=m.subarray(U,U*2);return new w(i.fromBytes(A),i.fromBytes(I),v)}static fromHex(m,_){return this.fromBytes(ee(m),_)}addRecoveryBit(m){return new w(this.r,this.s,m)}recoverPublicKey(m){let _=s.ORDER,{r:v,s:U,recovery:A}=this;if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");if(c*ei<_&&A>1)throw new Error("recovery id is ambiguous for h>1 curve");let D=A===2||A===3?v+c:v;if(!s.isValid(D))throw new Error("recovery id 2 or 3 invalid");let N=s.toBytes(D),z=e.fromBytes(rt(ri((A&1)===0),N)),q=i.inv(D),O=K(H("msgHash",m)),F=i.create(-O*q),X=i.create(U*q),st=e.BASE.multiplyUnsafe(F).add(z.multiplyUnsafe(X));if(st.is0())throw new Error("point at infinify");return st.assertValidity(),st}hasHighS(){return S(this.s)}toBytes(m=E){if(io(m),m==="der")return ee(Mt.hexFromSig(this));let _=i.toBytes(this.r),v=i.toBytes(this.s);if(m==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return rt(Uint8Array.of(this.recovery),_,v)}return rt(_,v)}toHex(m){return bt(this.toBytes(m))}assertValidity(){}static fromCompact(m){return w.fromBytes(H("sig",m),"compact")}static fromDER(m){return w.fromBytes(H("sig",m),"der")}normalizeS(){return this.hasHighS()?new w(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bt(this.toBytes("compact"))}}let T=r.bits2int||function(m){if(m.length>8192)throw new Error("input is too large");let _=Ee(m),v=m.length*8-a;return v>0?_>>BigInt(v):_},K=r.bits2int_modN||function(m){return i.create(T(m))},M=Ft(a);function P(p){return Ze("num < 2^"+a,p,Ot,M),i.toBytes(p)}function R(p,m){return lt(p,void 0,"message"),m?lt(t(p),void 0,"prehashed message"):p}function x(p,m,_){if(["recovered","canonical"].some(F=>F in _))throw new Error("sign() legacy options not supported");let{lowS:v,prehash:U,extraEntropy:A}=so(_,h);p=R(p,U);let I=K(p),D=Le(i,m),N=[P(D),P(I)];if(A!=null&&A!==!1){let F=A===!0?n(d.secretKey):A;N.push(H("extraEntropy",F))}let z=rt(...N),q=I;function O(F){let X=T(F);if(!i.isValidNot0(X))return;let st=i.inv(X),j=e.BASE.multiply(X).toAffine(),tt=i.create(j.x);if(tt===Ot)return;let sr=i.create(st*i.create(q+tt*D));if(sr===Ot)return;let go=(j.x===tt?0:2)|Number(j.y&Ce),xo=sr;return v&&S(sr)&&(xo=i.neg(sr),go^=1),new w(tt,xo,go)}return{seed:z,k2sig:O}}function L(p,m,_={}){p=H("message",p);let{seed:v,k2sig:U}=x(p,m,_);return ms(t.outputLen,i.BYTES,o)(v,U)}function k(p){let m,_=typeof p=="string"||Lt(p),v=!_&&p!==null&&typeof p=="object"&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!_&&!v)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(v)m=new w(p.r,p.s);else if(_){try{m=w.fromBytes(H("sig",p),"der")}catch(U){if(!(U instanceof Mt.Err))throw U}if(!m)try{m=w.fromBytes(H("sig",p),"compact")}catch{return!1}}return m||!1}function C(p,m,_,v={}){let{lowS:U,prehash:A,format:I}=so(v,h);if(_=H("publicKey",_),m=R(H("message",m),A),"strict"in v)throw new Error("options.strict was renamed to lowS");let D=I===void 0?k(p):w.fromBytes(H("sig",p),I);if(D===!1)return!1;try{let N=e.fromBytes(_);if(U&&D.hasHighS())return!1;let{r:z,s:q}=D,O=K(m),F=i.inv(q),X=i.create(O*F),st=i.create(z*F),j=e.BASE.multiplyUnsafe(X).add(N.multiplyUnsafe(st));return j.is0()?!1:i.create(j.x)===z}catch{return!1}}function b(p,m,_={}){let{prehash:v}=so(_,h);return m=R(m,v),w.fromBytes(p,"recovered").recoverPublicKey(m).toBytes()}return Object.freeze({keygen:u,getPublicKey:y,getSharedSecret:l,utils:f,lengths:d,Point:e,sign:L,verify:C,recoverPublicKey:b,Signature:w,hash:t})}function Qa(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0,o=dt(t.n,{BITS:e.nBitLength,allowedLengths:n,modFromBytes:e.wrapPrivateKey}),s={Fp:r,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:s}}function tf(e){let{CURVE:t,curveOpts:r}=Qa(e),n={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,hash:e.hash,ecdsaOpts:n}}function ef(e,t){let r=t.Point;return Object.assign({},t,{ProjectivePoint:r,CURVE:Object.assign({},e,gr(r.Fn.ORDER,r.Fn.BITS))})}function oi(e){let{CURVE:t,curveOpts:r,hash:n,ecdsaOpts:o}=tf(e),s=$a(t,r),i=Ja(s,n,o);return ef(e,i)}function si(e,t){let r=n=>oi({...e,hash:n});return{...r(t),create:r}}var fo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},rf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var ii=BigInt(2);function nf(e){let t=fo.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),u=e*e*e%t,y=u*u*e%t,l=V(y,r,t)*y%t,f=V(l,r,t)*y%t,d=V(f,ii,t)*u%t,h=V(d,o,t)*d%t,E=V(h,s,t)*h%t,S=V(E,c,t)*E%t,g=V(S,a,t)*S%t,B=V(g,c,t)*E%t,w=V(B,r,t)*y%t,T=V(w,i,t)*h%t,K=V(T,n,t)*u%t,M=V(K,ii,t);if(!ao.eql(ao.sqr(M),e))throw new Error("Cannot find square root");return M}var ao=dt(fo.p,{sqrt:nf}),Te=si({...fo,Fp:ao,lowS:!0,endo:rf},us);function ci(e,t,r,n){let o=Pe.digest(r instanceof Uint8Array?r:r.subarray());if(Br(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Te.verify(t,s,e))).catch(s=>{throw s.name==="AbortError"?s:new $e(String(s))});try{return n?.signal?.throwIfAborted(),Te.verify(t,o.digest,e)}catch(s){throw new $e(String(s))}}var Rr=class{type="secp256k1";raw;_key;constructor(t){this._key=fi(t),this.raw=ai(this._key)}toMultihash(){return gt.digest(be(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,r,n){return ci(this._key,r,t,n)}};function ui(e){return new Rr(e)}function ai(e){return Te.ProjectivePoint.fromHex(e).toRawBytes(!0)}function fi(e){try{return Te.ProjectivePoint.fromHex(e),e}catch(t){throw new ir(String(t))}}function hi(e){let{Type:t,Data:r}=tr.decode(e.digest),n=r??new Uint8Array;switch(t){case mt.Ed25519:return Os(n);case mt.secp256k1:return ui(n);case mt.ECDSA:return Go(n);default:throw new Ue}}function be(e){return tr.encode({Type:mt[e.type],Data:e.raw})}var li=Symbol.for("nodejs.util.inspect.custom"),of=114,er=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()})`}[Vr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return it.createV1(of,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ft(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ft(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[li](){return`PeerId(${this.toString()})`}},kr=class extends er{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Nr=class extends er{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Pr=class extends er{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},sf=2336,Mr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=gt.digest($(this.url))}[li](){return`PeerId(${this.url})`}[Vr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return it.createV1(sf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=yt(t)),t.toString()===this.toString())}};function di(e){if(af(e))return new kr({multihash:e});if(cf(e))try{let t=hi(e);if(t.type==="Ed25519")return new Nr({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Pr({multihash:e,publicKey:t})}catch{let r=yt(e.digest);return new Mr(new URL(r))}throw new cr("Supplied PeerID Multihash is invalid")}function cf(e){return e.code===gt.code}function af(e){return e.code===Pe.code}function Bt(e,t){let r={[Symbol.iterator]:()=>r,next:()=>{let n=e.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return r}function Or(e){let t=ke(Y.decode(`z${e}`));return di(t)}var $t=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[r,n]of t.entries())this.map.set(r.toString(),{key:r,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return Bt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((r,n)=>{t(r.value,r.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,r){this.map.set(t.toString(),{key:t,value:r})}keys(){return Bt(this.map.values(),t=>t.key)}values(){return Bt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function pi(){return new $t}var Wt=class e{set;constructor(t){if(this.set=new Set,t!=null)for(let r of t)this.set.add(r.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 Bt(this.set.entries(),t=>{let r=Or(t[0]);return[r,r]})}forEach(t){this.set.forEach(r=>{let n=Or(r);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return Bt(this.set.values(),t=>Or(t))}intersection(t){let r=new e;for(let n of t)this.has(n)&&r.add(n);return r}difference(t){let r=new e;for(let n of this)t.has(n)||r.add(n);return r}union(t){let r=new e;for(let n of t)r.add(n);for(let n of this)r.add(n);return r}};function mi(){return new Wt}var Jt=class e{list;constructor(t){if(this.list=[],t!=null)for(let r of t)this.list.push(r)}[Symbol.iterator](){return Bt(this.list.entries(),t=>t[1])}concat(t){let r=new e(this);for(let n of t)r.push(n);return r}entries(){return Bt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((r,n)=>t(r,n,this))}filter(t){let r=new e;return this.list.forEach((n,o)=>{t(n,o,this)&&r.push(n)}),r}find(t){let r=this.list.find((n,o)=>t(n,o,this));if(r!=null)return r}findIndex(t){return this.list.findIndex((r,n)=>t(r,n,this))}forEach(t){this.list.forEach((r,n)=>{t(r,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(r=>r.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let r of t)this.list.push(r)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let r=this.list.length;for(let n=t.length-1;n>-1;n--)r=this.list.unshift(t[n]);return r}clear(){this.list=[]}get length(){return this.list.length}};function yi(){return new Jt}var uo={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},bi={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},gi=new globalThis.TextEncoder;function ff(e,t){let r=uo[t],n=bi[t];for(let o=0;o<e.length;o++)n^=BigInt(e[o]),n=BigInt.asUintN(t,n*r);return n}function uf(e,t,r){if(r.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=uo[t],o=bi[t],s=e;for(;s.length>0;){let i=gi.encodeInto(s,r);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(r[c]),o=BigInt.asUintN(t,o*n)}return o}function ho(e,{size:t=32,utf8Buffer:r}={}){if(!uo[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof e=="string"){if(r)return uf(e,t,r);e=gi.encode(e)}return ff(e,t)}var rr={hash:e=>Number(ho(e,{size:32})),hashV:(e,t)=>hf(rr.hash(e,t))};function hf(e){let t=e.toString(16);return t.length%2===1&&(t=`0${t}`),$(t,"base16")}var lo=64,_t=class{fp;h;seed;constructor(t,r,n,o=2){if(o>lo)throw new TypeError("Invalid Fingerprint Size");let s=r.hashV(t,n),i=xt(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=r,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?ft(this.fp,t.fp):!1}};function ae(e,t){return Math.floor(Math.random()*(t-e))+e}var fe=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof _t))throw new TypeError("Invalid Fingerprint");return this.contents.some(r=>t.equals(r))}add(t){if(!(t instanceof _t))throw new TypeError("Invalid Fingerprint");for(let r=0;r<this.contents.length;r++)if(this.contents[r]==null)return this.contents[r]=t,!0;return!0}swap(t){if(!(t instanceof _t))throw new TypeError("Invalid Fingerprint");let r=ae(0,this.contents.length-1),n=this.contents[r];return this.contents[r]=t,n}remove(t){if(!(t instanceof _t))throw new TypeError("Invalid Fingerprint");let r=this.contents.findIndex(n=>t.equals(n));return r>-1?(this.contents[r]=null,!0):!1}};var lf=500,nr=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??rr,this.seed=t.seed??ae(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=$(t));let r=new _t(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^r.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new fe(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new fe(this.bucketSize)),this.buckets[n].add(r)||this.buckets[o].add(r))return this.count++,!0;let s=[n,o],i=s[ae(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new fe(this.bucketSize));for(let c=0;c<lf;c++){let a=this.buckets[i].swap(r);if(a!=null&&(i=(i^a.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new fe(this.bucketSize)),this.buckets[i].add(a)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=$(t));let r=new _t(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(r)??!1;if(o)return o;let s=(n^r.hash())%this.filterSize;return this.buckets[s]?.has(r)??!1}remove(t){typeof t=="string"&&(t=$(t));let r=new _t(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(r)??!1;if(o)return this.count--,o;let s=(n^r.hash())%this.filterSize,i=this.buckets[s]?.remove(r)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},df={1:.5,2:.84,4:.95,8:.98};function pf(e=.001){return e>.002?2:e>1e-5?4:8}function xi(e,t=.001){let r=pf(t),n=df[r],o=Math.round(e/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*r)),lo);return{filterSize:o,bucketSize:r,fingerprintSize:s}}var Hr=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??rr,this.seed=t.seed??ae(0,Math.pow(2,10)),this.filterSeries=[new nr({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=$(t)),this.has(t))return!0;let r=this.filterSeries.find(n=>n.reliable);if(r==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);r=new nr({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(r)}return r.add(t)}has(t){typeof t=="string"&&(t=$(t));for(let r=0;r<this.filterSeries.length;r++)if(this.filterSeries[r].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=$(t));for(let r=0;r<this.filterSeries.length;r++)if(this.filterSeries[r].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,r)=>t+r.count,0)}};function po(e,t=.001,r){return new Hr({...xi(e,t),...r??{}})}var or=class{filter;constructor(t,r){this.filter=po(t,r)}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 wi(e,t=.001){return new or(e,t)}var mo=class extends $t{metric;constructor(t){super();let{name:r,metrics:n}=t;this.metric=n.registerMetric(r),this.updateComponentMetric()}set(t,r){return super.set(t,r),this.updateComponentMetric(),this}delete(t){let r=super.delete(t);return this.updateComponentMetric(),r}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Ei(e){let{name:t,metrics:r}=e,n;return r!=null?n=new mo({name:t,metrics:r}):n=new $t,n}var yo=class extends Wt{metric;constructor(t){super();let{name:r,metrics:n}=t;this.metric=n.registerMetric(r),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 _i(e){let{name:t,metrics:r}=e,n;return r!=null?n=new yo({name:t,metrics:r}):n=new Wt,n}var bo=class extends Jt{metric;constructor(t){super();let{name:r,metrics:n}=t;this.metric=n.registerMetric(r),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 r=super.unshift(...t);return this.updateComponentMetric(),r}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function Si(e){let{name:t,metrics:r}=e,n;return r!=null?n=new bo({name:t,metrics:r}):n=new Jt,n}return Li(mf);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js: