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