@libp2p/bootstrap 11.0.46-cb1c14e62 → 11.0.46-cf9aab5c8
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 +6 -6
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PBootstrap = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PBootstrap=(()=>{var ln=Object.defineProperty;var Aa=Object.getOwnPropertyDescriptor;var Ba=Object.getOwnPropertyNames;var Ia=Object.prototype.hasOwnProperty;var dt=(r,t)=>{for(var e in t)ln(r,e,{get:t[e],enumerable:!0})},_a=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ba(t))!Ia.call(r,o)&&o!==e&&ln(r,o,{get:()=>t[o],enumerable:!(n=Aa(t,o))||n.enumerable});return r};var Ca=r=>_a(ln({},"__esModule",{value:!0}),r);var dl={};dt(dl,{bootstrap:()=>hl});var os=Symbol.for("@libp2p/peer-discovery");var hn=Symbol.for("@libp2p/peer-id");var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},gr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var wr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Er=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ze=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Sr=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let e=this.#t.get(t);return e==null?0:e.length}addEventListener(t,e,n){super.addEventListener(t,e,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:e,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,e,n){super.removeEventListener(t.toString(),e??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==e),this.#t.set(t,o))}dispatchEvent(t){let e=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),e}safeDispatchEvent(t,e={}){return this.dispatchEvent(new CustomEvent(t,e))}};var ss=Symbol.for("@libp2p/service-capabilities"),gl=Symbol.for("@libp2p/service-dependencies");var bn={};dt(bn,{base58btc:()=>W,base58flickr:()=>Na});var Vl=new Uint8Array(0);function is(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 Dt(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 as(r){return new TextEncoder().encode(r)}function cs(r){return new TextDecoder().decode(r)}function Ta(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),h=Math.log(256)/Math.log(a);function l(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,x=0,S=0,C=b.length;S!==C&&b[S]===0;)S++,w++;for(var B=(C-S)*h+1>>>0,D=new Uint8Array(B);S!==C;){for(var R=b[S],_=0,k=B-1;(R!==0||_<x)&&k!==-1;k--,_++)R+=256*D[k]>>>0,D[k]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");x=_,S++}for(var M=B-x;M!==B&&D[M]===0;)M++;for(var P=c.repeat(w);M<B;++M)P+=r.charAt(D[M]);return P}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 x=0,S=0;b[w]===c;)x++,w++;for(var C=(b.length-w)*u+1>>>0,B=new Uint8Array(C);b[w];){var D=e[b.charCodeAt(w)];if(D===255)return;for(var R=0,_=C-1;(D!==0||R<S)&&_!==-1;_--,R++)D+=a*B[_]>>>0,B[_]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");S=R,w++}if(b[w]!==" "){for(var k=C-S;k!==C&&B[k]===0;)k++;for(var M=new Uint8Array(x+(C-k)),P=x;k!==C;)M[P++]=B[k++];return M}}}function d(b){var w=f(b);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:f,decode:d}}var Da=Ta,Pa=Da,us=Pa;var dn=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")}},pn=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 ls(this,t)}},mn=class{decoders;constructor(t){this.decoders=t}or(t){return ls(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 ls(r,t){return new mn({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var yn=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 dn(t,e,n),this.decoder=new pn(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 yn(r,t,e,n)}function Zt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=us(e,r);return Ee({prefix:t,name:r,encode:n,decode:s=>Dt(o(s))})}function La(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 h=t[r[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|h,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 Oa(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 Ua(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function $({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Ua(n);return Ee({prefix:t,name:r,encode(s){return Oa(s,n,e)},decode(s){return La(s,o,e,r)}})}var W=Zt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Na=Zt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xn={};dt(xn,{base32:()=>$t,base32hex:()=>Ma,base32hexpad:()=>Va,base32hexpadupper:()=>qa,base32hexupper:()=>Ha,base32pad:()=>Ka,base32padupper:()=>ka,base32upper:()=>Ra,base32z:()=>za});var $t=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ra=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ka=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ka=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ma=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ha=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Va=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),qa=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),za=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var gn={};dt(gn,{base36:()=>Fe,base36upper:()=>Fa});var Fe=Zt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Fa=Zt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ja=ps,hs=128,Ga=127,Za=~Ga,$a=Math.pow(2,31);function ps(r,t,e){t=t||[],e=e||0;for(var n=e;r>=$a;)t[e++]=r&255|hs,r/=128;for(;r&Za;)t[e++]=r&255|hs,r>>>=7;return t[e]=r|0,ps.bytes=e-n+1,t}var Wa=wn,Ya=128,ds=127;function wn(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw wn.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&ds)<<o:(i&ds)*Math.pow(2,o),o+=7}while(i>=Ya);return wn.bytes=s-n,e}var Xa=Math.pow(2,7),Qa=Math.pow(2,14),Ja=Math.pow(2,21),tc=Math.pow(2,28),ec=Math.pow(2,35),rc=Math.pow(2,42),nc=Math.pow(2,49),oc=Math.pow(2,56),sc=Math.pow(2,63),ic=function(r){return r<Xa?1:r<Qa?2:r<Ja?3:r<tc?4:r<ec?5:r<rc?6:r<nc?7:r<oc?8:r<sc?9:10},ac={encode:ja,decode:Wa,encodingLength:ic},cc=ac,je=cc;function Ge(r,t=0){return[je.decode(r,t),je.decode.bytes]}function Se(r,t,e=0){return je.encode(r,t,e),t}function ve(r){return je.encodingLength(r)}function ie(r,t){let e=t.byteLength,n=ve(r),o=n+ve(e),s=new Uint8Array(o+e);return Se(r,s,0),Se(e,s,n),s.set(t,o),new Ae(r,e,t,s)}function Ze(r){let t=Dt(r),[e,n]=Ge(t),[o,s]=Ge(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ae(e,o,i,t)}function ms(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&is(r.bytes,e.bytes)}}var Ae=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function ys(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return uc(e,En(r),t??W.encoder);default:return lc(e,En(r),t??$t.encoder)}}var bs=new WeakMap;function En(r){let t=bs.get(r);if(t==null){let e=new Map;return bs.set(r,e),e}return t}var tt=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!==$e)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==hc)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=ie(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&&ms(t.multihash,n.multihash)}toString(t){return ys(this,t)}toJSON(){return{"/":ys(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??xs(n,o,s.bytes))}else if(e[dc]===!0){let{version:n,multihash:o,code:s}=e,i=Ze(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!==$e)throw new Error(`Version 0 CID must use dag-pb (code: ${$e}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=xs(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,$e,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=Dt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Ae(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,f]=Ge(t.subarray(e));return e+=f,l},o=n(),s=$e;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,h=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:h,size:u}}static parse(t,e){let[n,o]=fc(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 En(s).set(n,t),s}};function fc(r,t){switch(r[0]){case"Q":{let e=t??W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t??W;return[W.prefix,e.decode(r)]}case $t.prefix:{let e=t??$t;return[$t.prefix,e.decode(r)]}case Fe.prefix:{let e=t??Fe;return[Fe.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 uc(r,t,e){let{prefix:n}=e;if(n!==W.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 lc(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 $e=112,hc=18;function xs(r,t,e){let n=ve(r),o=n+ve(t),s=new Uint8Array(o+e.byteLength);return Se(r,s,0),Se(t,s,n),s.set(e,o),s}var dc=Symbol.for("@ipld/js-cid/CID");var Sn={};dt(Sn,{identity:()=>vt});var gs=0,pc="identity",ws=Dt;function mc(r){return ie(gs,ws(r))}var vt={code:gs,name:pc,encode:ws,digest:mc};function pt(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 Pt(r=0){return new Uint8Array(r)}function mt(r=0){return new Uint8Array(r)}function Lt(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=mt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Ss=Symbol.for("@achingbrain/uint8arraylist");function Es(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 Ar(r){return!!r?.[Ss]}var yt=class r{bufs;length;[Ss]=!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(Ar(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(Ar(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=Es(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Es(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(Ar(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Lt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Lt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,h=e>a&&e<=c;if(u&&h){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(h){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(!Ar(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,u=n.byteLength-1,h;for(let l=e;l<=c;l+=h){h=0;for(let f=u;f>=0;f--){let d=this.get(l+f);if(n[f]!==d){h=Math.max(1,f-a[d]);break}}if(h===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=mt(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=Pt(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=Pt(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=Pt(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=mt(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=Pt(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=Pt(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=Pt(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=Pt(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=Pt(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(!pt(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 vn={};dt(vn,{base10:()=>yc});var yc=Zt({prefix:"9",name:"base10",alphabet:"0123456789"});var An={};dt(An,{base16:()=>bc,base16upper:()=>xc});var bc=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xc=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bn={};dt(Bn,{base2:()=>gc});var gc=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var In={};dt(In,{base256emoji:()=>Ac});var vs=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),wc=vs.reduce((r,t,e)=>(r[e]=t,r),[]),Ec=vs.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Sc(r){return r.reduce((t,e)=>(t+=wc[e],t),"")}function vc(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ec[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ac=Ee({prefix:"\u{1F680}",name:"base256emoji",encode:Sc,decode:vc});var Cn={};dt(Cn,{base64:()=>Bc,base64pad:()=>Ic,base64url:()=>_n,base64urlpad:()=>_c});var Bc=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ic=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_n=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_c=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Tn={};dt(Tn,{base8:()=>Cc});var Cc=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Dn={};dt(Dn,{identity:()=>Tc});var Tc=Ee({prefix:"\0",name:"identity",encode:r=>cs(r),decode:r=>as(r)});var Ah=new TextEncoder,Bh=new TextDecoder;var On={};dt(On,{sha256:()=>We,sha512:()=>Lc});function Ln({name:r,code:t,encode:e}){return new Pn(r,t,e)}var Pn=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?ie(this.code,e):e.then(n=>ie(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Bs(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var We=Ln({name:"sha2-256",code:18,encode:Bs("SHA-256")}),Lc=Ln({name:"sha2-512",code:19,encode:Bs("SHA-512")});var Ye={...Dn,...Bn,...Tn,...vn,...An,...xn,...gn,...bn,...Cn,...In},Kh={...On,...Sn};function _s(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Is=_s("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Un=_s("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=mt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Oc={utf8:Is,"utf-8":Is,hex:Ye.base16,latin1:Un,ascii:Un,binary:Un,...Ye},Br=Oc;function it(r,t="utf8"){let e=Br[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function j(r,t="utf8"){let e=Br[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Uc=parseInt("11111",2),Nn=parseInt("10000000",2),Nc=parseInt("01111111",2),Cs={0:Xe,1:Xe,2:Rc,3:Mc,4:Hc,5:kc,6:Kc,16:Xe,22:Xe,48:Xe};function Rn(r,t={offset:0}){let e=r[t.offset]&Uc;if(t.offset++,Cs[e]!=null)return Cs[e](r,t);throw new Error("No decoder for tag "+e)}function Qe(r,t){let e=0;if((r[t.offset]&Nn)===Nn){let n=r[t.offset]&Nc,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 Xe(r,t){Qe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Rn(r,t);if(n===null)break;e.push(n)}return e}function Rc(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 Kc(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 h=0;for(let l=0;l<c.length;l++)h+=c[l]<<l*7;a+=`.${h}`,c=[]}}return a}function kc(r,t){return t.offset++,null}function Mc(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 Hc(r,t){let e=Qe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Vc(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new yt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Kn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Vc(r.byteLength);return new yt(Uint8Array.from([t.byteLength|Nn]),t)}function Ts(r){let t=new yt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new yt(Uint8Array.from([2]),Kn(t),t)}function Ds(r){let t=Uint8Array.from([0]),e=new yt(t,r);return new yt(Uint8Array.from([3]),Kn(e),e)}function Ir(r,t=48){let e=new yt;for(let n of r)e.append(n);return new yt(Uint8Array.from([t]),Kn(e),e)}async function Ps(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 qc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),zc=Uint8Array.from([6,5,43,129,4,0,34]),Fc=Uint8Array.from([6,5,43,129,4,0,35]),jc={ext:!0,kty:"EC",crv:"P-256"},Gc={ext:!0,kty:"EC",crv:"P-384"},Zc={ext:!0,kty:"EC",crv:"P-521"},kn=32,Mn=48,Hn=66;function Ls(r){let t=Rn(r);return Os(t)}function Os(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===kn*2+1)return n=j(t.subarray(e,e+kn),"base64url"),o=j(t.subarray(e+kn),"base64url"),new Ie({...jc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Mn*2+1)return n=j(t.subarray(e,e+Mn),"base64url"),o=j(t.subarray(e+Mn),"base64url"),new Ie({...Gc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Hn*2+1)return n=j(t.subarray(e,e+Hn),"base64url"),o=j(t.subarray(e+Hn),"base64url"),new Ie({...Zc,key_ops:["verify"],x:n,y:o});throw new It(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Us(r){return Ir([Ts(Uint8Array.from([1])),Ir([$c(r.crv)],160),Ir([Ds(new yt(Uint8Array.from([4]),it(r.x??"","base64url"),it(r.y??"","base64url")))],161)]).subarray()}function $c(r){if(r==="P-256")return qc;if(r==="P-384")return zc;if(r==="P-521")return Fc;throw new It(`Invalid curve ${r}`)}var Ie=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Us(this.jwk)),this._raw}toMultihash(){return vt.digest(_e(this))}toCID(){return tt.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:pt(this.raw,t.raw)}async verify(t,e,n){return Ps(this.jwk,e,t,n)}};var ae=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ce(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Je(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Y(r,...t){if(!ce(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 _r(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Je(r.outputLen),Je(r.blockLen)}function Te(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 Rs(r,t){Y(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Ut(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Cr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function At(r,t){return r<<32-t|r>>>t}var Ks=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Wc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function St(r){if(Y(r),Ks)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Wc[r[e]];return t}var Ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ns(r){if(r>=Ot._0&&r<=Ot._9)return r-Ot._0;if(r>=Ot.A&&r<=Ot.F)return r-(Ot.A-10);if(r>=Ot.a&&r<=Ot.f)return r-(Ot.a-10)}function fe(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Ks)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=Ns(r.charCodeAt(s)),a=Ns(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 Vn(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function tr(r){return typeof r=="string"&&(r=Vn(r)),Y(r),r}function ut(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Y(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 qn(r){let t=n=>r().update(tr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function er(r=32){if(ae&&typeof ae.getRandomValues=="function")return ae.getRandomValues(new Uint8Array(r));if(ae&&typeof ae.randomBytes=="function")return Uint8Array.from(ae.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Yc(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 ks(r,t,e){return r&t^~r&e}function Ms(r,t,e){return r&t^r&e^t&e}var rr=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=Cr(this.buffer)}update(t){Te(this),t=tr(t),Y(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=Cr(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){Te(this),Rs(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Ut(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Yc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=Cr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,h[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos: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()}},Nt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ot=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Tr=BigInt(4294967295),Hs=BigInt(32);function Xc(r,t=!1){return t?{h:Number(r&Tr),l:Number(r>>Hs&Tr)}:{h:Number(r>>Hs&Tr)|0,l:Number(r&Tr)|0}}function Vs(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}=Xc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var zn=(r,t,e)=>r>>>e,Fn=(r,t,e)=>r<<32-e|t>>>e,ue=(r,t,e)=>r>>>e|t<<32-e,le=(r,t,e)=>r<<32-e|t>>>e,nr=(r,t,e)=>r<<64-e|t>>>e-32,or=(r,t,e)=>r>>>e-32|t<<64-e;function _t(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var qs=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),zs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Fs=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),js=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,Gs=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Zs=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Jc=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]),Wt=new Uint32Array(64),jn=class extends rr{constructor(t=32){super(64,t,8,!1),this.A=Nt[0]|0,this.B=Nt[1]|0,this.C=Nt[2]|0,this.D=Nt[3]|0,this.E=Nt[4]|0,this.F=Nt[5]|0,this.G=Nt[6]|0,this.H=Nt[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 l=0;l<16;l++,e+=4)Wt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let f=Wt[l-15],d=Wt[l-2],b=At(f,7)^At(f,18)^f>>>3,w=At(d,17)^At(d,19)^d>>>10;Wt[l]=w+Wt[l-7]+b+Wt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:h}=this;for(let l=0;l<64;l++){let f=At(a,6)^At(a,11)^At(a,25),d=h+f+ks(a,c,u)+Jc[l]+Wt[l]|0,w=(At(n,2)^At(n,13)^At(n,22))+Ms(n,o,s)|0;h=u,u=c,c=a,a=i+d|0,i=s,s=o,o=n,n=d+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,h=h+this.H|0,this.set(n,o,s,i,a,c,u,h)}roundClean(){Ut(Wt)}destroy(){this.set(0,0,0,0,0,0,0,0),Ut(this.buffer)}};var $s=Vs(["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))),tf=$s[0],ef=$s[1],Yt=new Uint32Array(80),Xt=new Uint32Array(80),Gn=class extends rr{constructor(t=64){super(128,t,16,!1),this.Ah=ot[0]|0,this.Al=ot[1]|0,this.Bh=ot[2]|0,this.Bl=ot[3]|0,this.Ch=ot[4]|0,this.Cl=ot[5]|0,this.Dh=ot[6]|0,this.Dl=ot[7]|0,this.Eh=ot[8]|0,this.El=ot[9]|0,this.Fh=ot[10]|0,this.Fl=ot[11]|0,this.Gh=ot[12]|0,this.Gl=ot[13]|0,this.Hh=ot[14]|0,this.Hl=ot[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:h,Fh:l,Fl:f,Gh:d,Gl:b,Hh:w,Hl:x}=this;return[t,e,n,o,s,i,a,c,u,h,l,f,d,b,w,x]}set(t,e,n,o,s,i,a,c,u,h,l,f,d,b,w,x){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=h|0,this.Fh=l|0,this.Fl=f|0,this.Gh=d|0,this.Gl=b|0,this.Hh=w|0,this.Hl=x|0}process(t,e){for(let B=0;B<16;B++,e+=4)Yt[B]=t.getUint32(e),Xt[B]=t.getUint32(e+=4);for(let B=16;B<80;B++){let D=Yt[B-15]|0,R=Xt[B-15]|0,_=ue(D,R,1)^ue(D,R,8)^zn(D,R,7),k=le(D,R,1)^le(D,R,8)^Fn(D,R,7),M=Yt[B-2]|0,P=Xt[B-2]|0,m=ue(M,P,19)^nr(M,P,61)^zn(M,P,6),p=le(M,P,19)^or(M,P,61)^Fn(M,P,6),E=Fs(k,p,Xt[B-7],Xt[B-16]),v=js(E,_,m,Yt[B-7],Yt[B-16]);Yt[B]=v|0,Xt[B]=E|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:h,Eh:l,El:f,Fh:d,Fl:b,Gh:w,Gl:x,Hh:S,Hl:C}=this;for(let B=0;B<80;B++){let D=ue(l,f,14)^ue(l,f,18)^nr(l,f,41),R=le(l,f,14)^le(l,f,18)^or(l,f,41),_=l&d^~l&w,k=f&b^~f&x,M=Gs(C,R,k,ef[B],Xt[B]),P=Zs(M,S,D,_,tf[B],Yt[B]),m=M|0,p=ue(n,o,28)^nr(n,o,34)^nr(n,o,39),E=le(n,o,28)^or(n,o,34)^or(n,o,39),v=n&s^n&a^s&a,L=o&i^o&c^i&c;S=w|0,C=x|0,w=d|0,x=b|0,d=l|0,b=f|0,{h:l,l:f}=_t(u|0,h|0,P|0,m|0),u=a|0,h=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let U=qs(m,E,L);n=zs(U,P,p,v),o=U|0}({h:n,l:o}=_t(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=_t(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=_t(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:h}=_t(this.Dh|0,this.Dl|0,u|0,h|0),{h:l,l:f}=_t(this.Eh|0,this.El|0,l|0,f|0),{h:d,l:b}=_t(this.Fh|0,this.Fl|0,d|0,b|0),{h:w,l:x}=_t(this.Gh|0,this.Gl|0,w|0,x|0),{h:S,l:C}=_t(this.Hh|0,this.Hl|0,S|0,C|0),this.set(n,o,s,i,a,c,u,h,l,f,d,b,w,x,S,C)}roundClean(){Ut(Yt,Xt)}destroy(){Ut(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Ws=qn(()=>new jn);var Ys=qn(()=>new Gn);var Wn=BigInt(0),$n=BigInt(1);function Rt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function sr(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Xs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Wn:BigInt("0x"+r)}function De(r){return Xs(St(r))}function Kt(r){return Y(r),Xs(St(Uint8Array.from(r).reverse()))}function Dr(r,t){return fe(r.toString(16).padStart(t*2,"0"))}function kt(r,t){return Dr(r,t).reverse()}function q(r,t,e){let n;if(typeof t=="string")try{n=fe(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ce(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 Qs(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 Zn=r=>typeof r=="bigint"&&Wn<=r;function Js(r,t,e){return Zn(r)&&Zn(t)&&Zn(e)&&t<=r&&r<e}function Qt(r,t,e,n){if(!Js(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Pr(r){let t;for(t=0;r>Wn;r>>=$n,t+=1);return t}var Jt=r=>($n<<BigInt(r))-$n;function ti(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=d=>new Uint8Array(d),o=d=>Uint8Array.of(d),s=n(r),i=n(r),a=0,c=()=>{s.fill(1),i.fill(0),a=0},u=(...d)=>e(i,s,...d),h=(d=n(0))=>{i=u(o(0),d),s=u(),d.length!==0&&(i=u(o(1),d),s=u())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,b=[];for(;d<t;){s=u();let w=s.slice();b.push(w),d+=s.length}return ut(...b)};return(d,b)=>{c(),h(d);let w;for(;!(w=b(l()));)h();return c(),w}}function te(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 ft=BigInt(0),rt=BigInt(1),he=BigInt(2),ni=BigInt(3),oi=BigInt(4),si=BigInt(5),rf=BigInt(7),ii=BigInt(8),nf=BigInt(9),ai=BigInt(16);function X(r,t){let e=r%t;return e>=ft?e:t+e}function G(r,t,e){let n=r;for(;t-- >ft;)n*=n,n%=e;return n}function ei(r,t){if(r===ft)throw new Error("invert: expected non-zero number");if(t<=ft)throw new Error("invert: expected positive modulus, got "+t);let e=X(r,t),n=t,o=ft,s=rt,i=rt,a=ft;for(;e!==ft;){let u=n/e,h=n%e,l=o-i*u,f=s-a*u;n=e,e=h,o=i,s=a,i=l,a=f}if(n!==rt)throw new Error("invert: does not exist");return X(o,t)}function Yn(r,t,e){if(!r.eql(r.sqr(t),e))throw new Error("Cannot find square root")}function ci(r,t){let e=(r.ORDER+rt)/oi,n=r.pow(t,e);return Yn(r,n,t),n}function of(r,t){let e=(r.ORDER-si)/ii,n=r.mul(t,he),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,he),o),a=r.mul(s,r.sub(i,r.ONE));return Yn(r,a,t),a}function sf(r){let t=bt(r),e=fi(r),n=e(t,t.neg(t.ONE)),o=e(t,n),s=e(t,t.neg(n)),i=(r+rf)/ai;return(a,c)=>{let u=a.pow(c,i),h=a.mul(u,n),l=a.mul(u,o),f=a.mul(u,s),d=a.eql(a.sqr(h),c),b=a.eql(a.sqr(l),c);u=a.cmov(u,h,d),h=a.cmov(f,l,b);let w=a.eql(a.sqr(h),c),x=a.cmov(u,h,w);return Yn(a,x,c),x}}function fi(r){if(r<ni)throw new Error("sqrt is not defined for small field");let t=r-rt,e=0;for(;t%he===ft;)t/=he,e++;let n=he,o=bt(r);for(;ri(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return ci;let s=o.pow(n,t),i=(t+rt)/he;return function(c,u){if(c.is0(u))return u;if(ri(c,u)!==1)throw new Error("Cannot find square root");let h=e,l=c.mul(c.ONE,s),f=c.pow(u,t),d=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===h)throw new Error("Cannot find square root");let x=rt<<BigInt(h-b-1),S=c.pow(l,x);h=b,l=c.sqr(S),f=c.mul(f,l),d=c.mul(d,S)}return d}}function af(r){return r%oi===ni?ci:r%ii===si?of:r%ai===nf?sf(r):fi(r)}var Mt=(r,t)=>(X(r,t)&rt)===rt,cf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=cf.reduce((n,o)=>(n[o]="function",n),t);return te(r,e),r}function ff(r,t,e){if(e<ft)throw new Error("invalid exponent, negatives unsupported");if(e===ft)return r.ONE;if(e===rt)return t;let n=r.ONE,o=t;for(;e>ft;)e&rt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=rt;return n}function ir(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 ri(r,t){let e=(r.ORDER-rt)/he,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 ui(r,t){t!==void 0&&Je(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function bt(r,t,e=!1,n={}){if(r<=ft)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}=ui(r,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let h,l=Object.freeze({ORDER:r,isLE:e,BITS:c,BYTES:u,MASK:Jt(c),ZERO:ft,ONE:rt,allowedLengths:a,create:f=>X(f,r),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return ft<=f&&f<r},is0:f=>f===ft,isValidNot0:f=>!l.is0(f)&&l.isValid(f),isOdd:f=>(f&rt)===rt,neg:f=>X(-f,r),eql:(f,d)=>f===d,sqr:f=>X(f*f,r),add:(f,d)=>X(f+d,r),sub:(f,d)=>X(f-d,r),mul:(f,d)=>X(f*d,r),pow:(f,d)=>ff(l,f,d),div:(f,d)=>X(f*ei(d,r),r),sqrN:f=>f*f,addN:(f,d)=>f+d,subN:(f,d)=>f-d,mulN:(f,d)=>f*d,inv:f=>ei(f,r),sqrt:s||(f=>(h||(h=af(r)),h(l,f))),toBytes:f=>e?kt(f,u):Dr(f,u),fromBytes:(f,d=!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?Kt(f):De(f);if(i&&(b=X(b,r)),!d&&!l.isValid(b))throw new Error("invalid field element: outside of range 0..ORDER");return b},invertBatch:f=>ir(l,f),cmov:(f,d,b)=>b?d:f});return Object.freeze(l)}function li(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Qn(r){let t=li(r);return t+Math.ceil(t/2)}function Jn(r,t,e=!1){let n=r.length,o=li(t),s=Qn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Kt(r):De(r),a=X(i,t-rt)+rt;return e?kt(a,o):Dr(a,o)}var Le=BigInt(0),de=BigInt(1);function ar(r,t){let e=t.negate();return r?e:t}function Ht(r,t){let e=ir(r.Fp,t.map(n=>n.Z));return t.map((n,o)=>r.fromAffine(n.toAffine(e[o])))}function mi(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function to(r,t){mi(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Jt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function hi(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+=de);let u=t*n,h=u+Math.abs(a)-1,l=a===0,f=a<0,d=t%2!==0;return{nextN:c,offset:h,isZero:l,isNeg:f,isNegF:d,offsetF:u}}function uf(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 lf(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 eo=new WeakMap,yi=new WeakMap;function ro(r){return yi.get(r)||1}function di(r){if(r!==Le)throw new Error("invalid wNAF")}var Oe=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>Le;)e&de&&(n=n.add(o)),o=o.double(),e>>=de;return n}precomputeWindow(t,e){let{windows:n,windowSize:o}=to(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=to(t,this.bits);for(let a=0;a<i.windows;a++){let{nextN:c,offset:u,isZero:h,isNeg:l,isNegF:f,offsetF:d}=hi(n,a,i);n=c,h?s=s.add(ar(f,e[d])):o=o.add(ar(l,e[u]))}return di(n),{p:o,f:s}}wNAFUnsafe(t,e,n,o=this.ZERO){let s=to(t,this.bits);for(let i=0;i<s.windows&&n!==Le;i++){let{nextN:a,offset:c,isZero:u,isNeg:h}=hi(n,i,s);if(n=a,!u){let l=e[c];o=o.add(h?l.negate():l)}}return di(n),o}getPrecomputes(t,e,n){let o=eo.get(e);return o||(o=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(o=n(o)),eo.set(e,o))),o}cached(t,e,n){let o=ro(t);return this.wNAF(o,this.getPrecomputes(o,t,n),e)}unsafe(t,e,n,o){let s=ro(t);return s===1?this._unsafeLadder(t,e,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),e,o)}createCache(t,e){mi(e,this.bits),yi.set(t,e),eo.delete(t)}hasCache(t){return ro(t)!==1}};function bi(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>Le||n>Le;)e&de&&(s=s.add(o)),n&de&&(i=i.add(o)),o=o.double(),e>>=de,n>>=de;return{p1:s,p2:i}}function Ue(r,t,e,n){uf(e,r),lf(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=Pr(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let u=Jt(c),h=new Array(Number(u)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c,f=i;for(let d=l;d>=0;d-=c){h.fill(i);for(let w=0;w<s;w++){let x=n[w],S=Number(x>>BigInt(d)&u);h[S]=h[S].add(e[w])}let b=i;for(let w=h.length-1,x=i;w>0;w--)x=x.add(h[w]),b=b.add(x);if(f=f.add(b),d!==0)for(let w=0;w<c;w++)f=f.double()}return f}function pi(r,t){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Xn(t),t}else return bt(r)}function Lr(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>Le))throw new Error(`CURVE.${a} must be positive bigint`)}let n=pi(t.p,e.Fp),o=pi(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 Ct=BigInt(0),et=BigInt(1),no=BigInt(2),hf=BigInt(8);function df(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 pf(r,t={}){let{Fp:e,Fn:n}=Lr("edwards",r,t),{h:o,n:s}=r;te(t,{},{uvRatio:"function"});let i=no<<BigInt(n.BYTES*8)-et,a=w=>e.create(w),c=t.uvRatio||((w,x)=>{try{return{isValid:!0,value:e.sqrt(e.div(w,x))}}catch{return{isValid:!1,value:Ct}}});if(!df(e,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function u(w,x,S=!1){let C=S?et:Ct;return Qt("coordinate "+w,x,C,i),x}function h(w){if(!(w instanceof d))throw new Error("ExtendedPoint expected")}let l=Pe((w,x)=>{let{X:S,Y:C,Z:B}=w,D=w.is0();x==null&&(x=D?hf:e.inv(B));let R=a(S*x),_=a(C*x),k=e.mul(B,x);if(D)return{x:Ct,y:et};if(k!==et)throw new Error("invZ was invalid");return{x:R,y:_}}),f=Pe(w=>{let{a:x,d:S}=r;if(w.is0())throw new Error("bad point: ZERO");let{X:C,Y:B,Z:D,T:R}=w,_=a(C*C),k=a(B*B),M=a(D*D),P=a(M*M),m=a(_*x),p=a(M*a(m+k)),E=a(P+a(S*a(_*k)));if(p!==E)throw new Error("bad point: equation left != right (1)");let v=a(C*B),L=a(D*R);if(v!==L)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(x,S,C,B){this.X=u("x",x),this.Y=u("y",S),this.Z=u("z",C,!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(x){return Ht(d,x)}static msm(x,S){return Ue(d,n,x,S)}_setWindowSize(x){this.precompute(x)}static fromAffine(x){if(x instanceof d)throw new Error("extended point not allowed");let{x:S,y:C}=x||{};return u("x",S),u("y",C),new d(S,C,et,a(S*C))}precompute(x=8,S=!0){return b.createCache(this,x),S||this.multiply(no),this}assertValidity(){f(this)}equals(x){h(x);let{X:S,Y:C,Z:B}=this,{X:D,Y:R,Z:_}=x,k=a(S*_),M=a(D*B),P=a(C*_),m=a(R*B);return k===M&&P===m}is0(){return this.equals(d.ZERO)}negate(){return new d(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:x}=r,{X:S,Y:C,Z:B}=this,D=a(S*S),R=a(C*C),_=a(no*a(B*B)),k=a(x*D),M=S+C,P=a(a(M*M)-D-R),m=k+R,p=m-_,E=k-R,v=a(P*p),L=a(m*E),U=a(P*E),g=a(p*m);return new d(v,L,g,U)}add(x){h(x);let{a:S,d:C}=r,{X:B,Y:D,Z:R,T:_}=this,{X:k,Y:M,Z:P,T:m}=x,p=a(B*k),E=a(D*M),v=a(_*C*m),L=a(R*P),U=a((B+D)*(k+M)-p-E),g=L-v,y=L+v,A=a(E-S*p),T=a(U*g),N=a(y*A),K=a(U*A),H=a(g*y);return new d(T,N,H,K)}subtract(x){return this.add(x.negate())}multiply(x){let S=x;Qt("scalar",S,et,s);let{p:C,f:B}=b.cached(this,S,D=>Ht(d,D));return Ht(d,[C,B])[0]}multiplyUnsafe(x,S=d.ZERO){let C=x;return Qt("scalar",C,Ct,s),C===Ct?d.ZERO:this.is0()||C===et?this:b.unsafe(this,C,B=>Ht(d,B),S)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return b.unsafe(this,s).is0()}toAffine(x){return l(this,x)}clearCofactor(){return o===et?this:this.multiplyUnsafe(o)}static fromBytes(x,S=!1){return Y(x),d.fromHex(x,S)}static fromHex(x,S=!1){let{d:C,a:B}=r,D=e.BYTES;x=q("pointHex",x,D),Rt("zip215",S);let R=x.slice(),_=x[D-1];R[D-1]=_&-129;let k=Kt(R),M=S?i:e.ORDER;Qt("pointHex.y",k,Ct,M);let P=a(k*k),m=a(P-et),p=a(C*P-B),{isValid:E,value:v}=c(m,p);if(!E)throw new Error("Point.fromHex: invalid y coordinate");let L=(v&et)===et,U=(_&128)!==0;if(!S&&v===Ct&&U)throw new Error("Point.fromHex: x=0 and x_0=1");return U!==L&&(v=a(-v)),d.fromAffine({x:v,y:k})}toBytes(){let{x,y:S}=this.toAffine(),C=kt(S,e.BYTES);return C[C.length-1]|=x&et?128:0,C}toRawBytes(){return this.toBytes()}toHex(){return St(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}d.BASE=new d(r.Gx,r.Gy,et,a(r.Gx*r.Gy)),d.ZERO=new d(Ct,et,et,Ct),d.Fp=e,d.Fn=n;let b=new Oe(d,n.BYTES*8);return d}var Or=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 St(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 mf(r,t,e){if(typeof t!="function")throw new Error('"hash" function param is required');te(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||er,u=e.adjustScalarBytes||(p=>p),h=e.domain||((p,E,v)=>{if(Rt("phflag",v),E.length||v)throw new Error("Contexts/pre-hash are not supported");return p});function l(p){return i.create(p)}function f(p){return l(Kt(p))}function d(p){let E=s.BYTES;p=q("private key",p,E);let v=q("hashed private key",t(p),2*E),L=u(v.slice(0,E)),U=v.slice(E,2*E),g=f(L);return{head:L,prefix:U,scalar:g}}function b(p){let{head:E,prefix:v,scalar:L}=d(p),U=o.multiply(L),g=U.toBytes();return{head:E,prefix:v,scalar:L,point:U,pointBytes:g}}function w(p){return b(p).pointBytes}function x(p=Uint8Array.of(),...E){let v=ut(...E);return f(t(h(v,q("context",p),!!n)))}function S(p,E,v={}){p=q("message",p),n&&(p=n(p));let{prefix:L,scalar:U,pointBytes:g}=b(E),y=x(v.context,L,p),A=o.multiply(y).toBytes(),T=x(v.context,A,g,p),N=l(y+T*U);Qt("signature.s",N,Ct,a);let K=s.BYTES,H=ut(A,kt(N,K));return q("result",H,K*2)}let C={zip215:!0};function B(p,E,v,L=C){let{context:U,zip215:g}=L,y=s.BYTES;p=q("signature",p,2*y),E=q("message",E),v=q("publicKey",v,y),g!==void 0&&Rt("zip215",g),n&&(E=n(E));let A=Kt(p.slice(y,2*y)),T,N,K;try{T=r.fromHex(v,g),N=r.fromHex(p.slice(0,y),g),K=o.multiplyUnsafe(A)}catch{return!1}if(!g&&T.isSmallOrder())return!1;let H=x(U,N.toBytes(),T.toBytes(),E);return N.add(T.multiplyUnsafe(H)).subtract(K).clearCofactor().is0()}o.precompute(8);let D=s.BYTES,R={secret:D,public:D,signature:2*D,seed:D};function _(p=c(R.seed)){return p}let k={getExtendedPublicKey:b,randomSecretKey:_,isValidSecretKey:P,isValidPublicKey:m,randomPrivateKey:_,toMontgomery(p){let{y:E}=r.fromBytes(p),v=D===32;if(!v&&D!==57)throw new Error("only defined for 25519 and 448");let L=v?s.div(et+E,et-E):s.div(E-et,E+et);return s.toBytes(L)},toMontgomeryPriv(p){Y(p,D);let E=t(p.subarray(0,D));return u(E).subarray(0,D)},precompute(p=8,E=r.BASE){return E.precompute(p,!1)}};function M(p){let E=k.randomSecretKey(p);return{secretKey:E,publicKey:w(E)}}function P(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:M,getPublicKey:w,sign:S,verify:B,utils:k,Point:r,info:{type:"edwards",lengths:R}})}function yf(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=bt(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 bf(r,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:r})}function xi(r){let{CURVE:t,curveOpts:e,hash:n,eddsaOpts:o}=yf(r),s=pf(t,e),i=mf(s,n,o);return bf(r,i)}var xf=BigInt(0),Vt=BigInt(1),gi=BigInt(2),jd=BigInt(3),gf=BigInt(5),wf=BigInt(8),cr={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:wf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ef(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=cr.p,a=r*r%s*r%s,c=G(a,gi,s)*a%s,u=G(c,Vt,s)*r%s,h=G(u,gf,s)*u%s,l=G(h,t,s)*h%s,f=G(l,e,s)*l%s,d=G(f,n,s)*f%s,b=G(d,o,s)*d%s,w=G(b,o,s)*d%s,x=G(w,t,s)*h%s;return{pow_p_5_8:G(x,gi,s)*r%s,b2:a}}function Sf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var oo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ao(r,t){let e=cr.p,n=X(t*t*t,e),o=X(n*n*t,e),s=Ef(r*o).pow_p_5_8,i=X(r*n*s,e),a=X(t*i*i,e),c=i,u=X(i*oo,e),h=a===r,l=a===X(-r,e),f=a===X(-r*oo,e);return h&&(i=c),(l||f)&&(i=u),Mt(i,e)&&(i=X(-i,e)),{isValid:h||l,value:i}}var pe=bt(cr.p,{isLE:!0}),vf=bt(cr.n,{isLE:!0}),Af={...cr,Fp:pe,hash:Ys,adjustScalarBytes:Sf,uvRatio:ao},xt=xi(Af);var so=oo,Bf=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),If=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),_f=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Cf=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),wi=r=>ao(Vt,r),Tf=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),io=r=>xt.CURVE.Fp.create(Kt(r)&Tf);function Ei(r){let{d:t}=xt.CURVE,e=xt.CURVE.Fp.ORDER,n=xt.CURVE.Fp.create,o=n(so*r*r),s=n((o+Vt)*_f),i=BigInt(-1),a=n((i-t*o)*n(o+t)),{isValid:c,value:u}=ao(s,a),h=n(u*r);Mt(h,e)||(h=n(-h)),c||(u=h),c||(i=o);let l=n(i*(o-Vt)*Cf-a),f=u*u,d=n((u+u)*a),b=n(l*Bf),w=n(Vt-f),x=n(Vt+f);return new xt.Point(n(d*x),n(w*b),n(b*x),n(d*w))}function Df(r){Y(r,64);let t=io(r.subarray(0,32)),e=Ei(t),n=io(r.subarray(32,64)),o=Ei(n);return new qt(e.add(o))}var qt=class r extends Or{constructor(t){super(t)}static fromAffine(t){return new r(xt.Point.fromAffine(t))}assertSame(t){if(!(t instanceof r))throw new Error("RistrettoPoint expected")}init(t){return new r(t)}static hashToCurve(t){return Df(q("ristrettoHash",t,64))}static fromBytes(t){Y(t,32);let{a:e,d:n}=xt.CURVE,o=pe.ORDER,s=pe.create,i=io(t);if(!Qs(kt(i,32),t)||Mt(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),c=s(Vt+e*a),u=s(Vt-e*a),h=s(c*c),l=s(u*u),f=s(e*n*h-l),{isValid:d,value:b}=wi(s(f*l)),w=s(b*u),x=s(b*w*f),S=s((i+i)*w);Mt(S,o)&&(S=s(-S));let C=s(c*x),B=s(S*C);if(!d||Mt(B,o)||C===xf)throw new Error("invalid ristretto255 encoding 2");return new r(new xt.Point(S,C,Vt,B))}static fromHex(t){return r.fromBytes(q("ristrettoHex",t,32))}static msm(t,e){return Ue(r,xt.Point.Fn,t,e)}toBytes(){let{X:t,Y:e,Z:n,T:o}=this.ep,s=pe.ORDER,i=pe.create,a=i(i(n+e)*i(n-e)),c=i(t*e),u=i(c*c),{value:h}=wi(i(a*u)),l=i(h*a),f=i(h*c),d=i(l*f*o),b;if(Mt(o*d,s)){let x=i(e*so),S=i(t*so);t=x,e=S,b=i(l*If)}else b=f;Mt(t*d,s)&&(e=i(-e));let w=i((n-e)*b);return Mt(w,s)&&(w=i(-w)),kt(w,32)}equals(t){this.assertSame(t);let{X:e,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=pe.create,a=i(e*s)===i(n*o),c=i(n*s)===i(e*o);return a||c}is0(){return this.equals(r.ZERO)}};qt.BASE=new qt(xt.Point.BASE);qt.ZERO=new qt(xt.Point.ZERO);qt.Fp=pe;qt.Fn=vf;var fr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Ur=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Si={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Ur("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 Nr=Si;var Rr=32;var co,Pf=(async()=>{try{return await Nr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Lf(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await Nr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Nr.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 Of(r,t,e){return xt.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function vi(r,t,e){return co==null&&(co=await Pf),co?Lf(r,t,e):Of(r,t,e)}function Kr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var kr=class{type="Ed25519";raw;constructor(t){this.raw=fo(t,Rr)}toMultihash(){return vt.digest(_e(this))}toCID(){return tt.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:pt(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=vi(this.raw,e,t);return Kr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Bi(r){return r=fo(r,Rr),new kr(r)}function fo(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Nf=Math.pow(2,7),Rf=Math.pow(2,14),Kf=Math.pow(2,21),uo=Math.pow(2,28),lo=Math.pow(2,35),ho=Math.pow(2,42),po=Math.pow(2,49),Z=128,at=127;function Tt(r){if(r<Nf)return 1;if(r<Rf)return 2;if(r<Kf)return 3;if(r<uo)return 4;if(r<lo)return 5;if(r<ho)return 6;if(r<po)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ur(r,t,e=0){switch(Tt(r)){case 8:t[e++]=r&255|Z,r/=128;case 7:t[e++]=r&255|Z,r/=128;case 6:t[e++]=r&255|Z,r/=128;case 5:t[e++]=r&255|Z,r/=128;case 4:t[e++]=r&255|Z,r>>>=7;case 3:t[e++]=r&255|Z,r>>>=7;case 2:t[e++]=r&255|Z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function mo(r,t){let e=r[t],n=0;if(n+=e&at,e<Z||(e=r[t+1],n+=(e&at)<<7,e<Z)||(e=r[t+2],n+=(e&at)<<14,e<Z)||(e=r[t+3],n+=(e&at)<<21,e<Z)||(e=r[t+4],n+=(e&at)*uo,e<Z)||(e=r[t+5],n+=(e&at)*lo,e<Z)||(e=r[t+6],n+=(e&at)*ho,e<Z)||(e=r[t+7],n+=(e&at)*po,e<Z))return n;throw new RangeError("Could not decode varint")}function kf(r,t){let e=r.get(t),n=0;if(n+=e&at,e<Z||(e=r.get(t+1),n+=(e&at)<<7,e<Z)||(e=r.get(t+2),n+=(e&at)<<14,e<Z)||(e=r.get(t+3),n+=(e&at)<<21,e<Z)||(e=r.get(t+4),n+=(e&at)*uo,e<Z)||(e=r.get(t+5),n+=(e&at)*lo,e<Z)||(e=r.get(t+6),n+=(e&at)*ho,e<Z)||(e=r.get(t+7),n+=(e&at)*po,e<Z))return n;throw new RangeError("Could not decode varint")}function yo(r,t=0){return r instanceof Uint8Array?mo(r,t):kf(r,t)}var bo=new Float32Array([-0]),ee=new Uint8Array(bo.buffer);function Ii(r,t,e){bo[0]=r,t[e]=ee[0],t[e+1]=ee[1],t[e+2]=ee[2],t[e+3]=ee[3]}function _i(r,t){return ee[0]=r[t],ee[1]=r[t+1],ee[2]=r[t+2],ee[3]=r[t+3],bo[0]}var xo=new Float64Array([-0]),ct=new Uint8Array(xo.buffer);function Ci(r,t,e){xo[0]=r,t[e]=ct[0],t[e+1]=ct[1],t[e+2]=ct[2],t[e+3]=ct[3],t[e+4]=ct[4],t[e+5]=ct[5],t[e+6]=ct[6],t[e+7]=ct[7]}function Ti(r,t){return ct[0]=r[t],ct[1]=r[t+1],ct[2]=r[t+2],ct[3]=r[t+3],ct[4]=r[t+4],ct[5]=r[t+5],ct[6]=r[t+6],ct[7]=r[t+7],xo[0]}var Hf=BigInt(Number.MAX_SAFE_INTEGER),Vf=BigInt(Number.MIN_SAFE_INTEGER),gt=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 me;if(t<Hf&&t>Vf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Di&&(o=0n,++n>Di&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return me;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):me}},me=new gt(0,0);me.toBigInt=function(){return 0n};me.zzEncode=me.zzDecode=function(){return this};me.length=function(){return 1};var Di=4294967296n;function Pi(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Li(r,t,e){if(e-t<1)return"";let o,s=[],i=0,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 go(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 Bt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Mr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var wo=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,Bt(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 Bt(this,4);return Mr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Bt(this,4);return Mr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Bt(this,4);let t=_i(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Bt(this,4);let t=Ti(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 Bt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Li(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Bt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Bt(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 gt(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 Bt(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 Bt(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 Bt(this,8);let t=Mr(this.buf,this.pos+=4),e=Mr(this.buf,this.pos+=4);return new gt(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=mo(this.buf,this.pos);return this.pos+=Tt(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 Eo(r){return new wo(r instanceof Uint8Array?r:r.subarray())}function Hr(r,t,e){let n=Eo(r);return t.decode(n,void 0,e)}function So(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return mt(i);o+i>t&&(n=mt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var ye=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function vo(){}var Bo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},qf=So();function zf(r){return globalThis.Buffer!=null?mt(r):qf(r)}var hr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ye(vo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ye(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Io((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(Vr,10,gt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=gt.fromBigInt(t);return this._push(Vr,e.length(),e)}uint64Number(t){return this._push(ur,Tt(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=gt.fromBigInt(t).zzEncode();return this._push(Vr,e.length(),e)}sint64Number(t){let e=gt.fromNumber(t).zzEncode();return this._push(Vr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ao,1,t?1:0)}fixed32(t){return this._push(lr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=gt.fromBigInt(t);return this._push(lr,4,e.lo)._push(lr,4,e.hi)}fixed64Number(t){let e=gt.fromNumber(t);return this._push(lr,4,e.lo)._push(lr,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(Ii,4,t)}double(t){return this._push(Ci,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Ao,1,0):this.uint32(e)._push(jf,e,t)}string(t){let e=Pi(t);return e!==0?this.uint32(e)._push(go,e,t):this._push(Ao,1,0)}fork(){return this.states=new Bo(this),this.head=this.tail=new ye(vo,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 ye(vo,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=zf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Ao(r,t,e){t[e]=r&255}function Ff(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Io=class extends ye{next;constructor(t,e){super(Ff,t,e),this.next=void 0}};function Vr(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 lr(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 jf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(hr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Gf,t,r),this},hr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Zf,t,r),this});function Gf(r,t,e){t.set(r,e)}function Zf(r,t,e){r.length<40?go(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(it(r),e)}function _o(){return new hr}function qr(r,t){let e=_o();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ne;(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"})(Ne||(Ne={}));function zr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Co(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 zr("enum",Ne.VARINT,e,n)}function Fr(r,t){return zr("message",Ne.LENGTH_DELIMITED,r,t)}var wt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(wt||(wt={}));var To;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(To||(To={}));(function(r){r.codec=()=>Co(To)})(wt||(wt={}));var dr;(function(r){let t;r.codec=()=>(t==null&&(t=Fr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),wt.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=wt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>qr(e,r.codec()),r.decode=(e,n)=>Hr(e,r.codec(),n)})(dr||(dr={}));var Do;(function(r){let t;r.codec=()=>(t==null&&(t=Fr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),wt.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=wt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>qr(e,r.codec()),r.decode=(e,n)=>Hr(e,r.codec(),n)})(Do||(Do={}));var jr=class extends Ce{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,_r(t);let n=tr(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),Ut(s)}update(t){return Te(this),this.iHash.update(t),this}digestInto(t){Te(this),Y(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()}},Po=(r,t,e)=>new jr(r,t).update(e).digest();Po.create=(r,t)=>new jr(r,t);var Ui=(r,t)=>(r+(r>=0?t:-t)/Ri)/t;function Wf(r,t,e){let[[n,o],[s,i]]=t,a=Ui(i*r,e),c=Ui(-o*r,e),u=r-a*n-c*s,h=-a*o-c*i,l=u<Ft,f=h<Ft;l&&(u=-u),f&&(h=-h);let d=Jt(Math.ceil(Pr(e)/2))+Ke;if(u<Ft||u>=d||h<Ft||h>=d)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:l,k1:u,k2neg:f,k2:h}}function Ni(r){r.lowS!==void 0&&Rt("lowS",r.lowS),r.prehash!==void 0&&Rt("prehash",r.prehash)}var Lo=class extends Error{constructor(t=""){super(t)}},zt={Err:Lo,_tlv:{encode:(r,t)=>{let{Err:e}=zt;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=sr(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?sr(o.length/2|128):"";return sr(r)+s+o+t},decode(r,t){let{Err:e}=zt,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 h of u)i=i<<8|h;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}=zt;if(r<Ft)throw new t("integer: negative integers are not allowed");let e=sr(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}=zt;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 De(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=zt,o=q("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:h}=n.decode(2,c);if(h.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}=zt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Ft=BigInt(0),Ke=BigInt(1),Ri=BigInt(2),Gr=BigInt(3),Yf=BigInt(4);function Xf(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 Re(r,t){let{BYTES:e}=r,n;if(typeof t=="bigint")n=t;else{let o=q("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 Qf(r,t={}){let{Fp:e,Fn:n}=Lr("weierstrass",r,t),{h:o,n:s}=r;te(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(P,m,p){let{x:E,y:v}=m.toAffine(),L=e.toBytes(E);if(Rt("isCompressed",p),p){a();let U=!e.isOdd(v);return ut(Ki(U),L)}else return ut(Uint8Array.of(4),L,e.toBytes(v))}function u(P){Y(P);let m=e.BYTES,p=m+1,E=2*m+1,v=P.length,L=P[0],U=P.subarray(1);if(v===p&&(L===2||L===3)){let g=e.fromBytes(U);if(!e.isValid(g))throw new Error("bad point: is not on curve, wrong x");let y=f(g),A;try{A=e.sqrt(y)}catch(K){let H=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+H)}a();let T=e.isOdd(A);return(L&1)===1!==T&&(A=e.neg(A)),{x:g,y:A}}else if(v===E&&L===4){let g=e.fromBytes(U.subarray(m*0,m*1)),y=e.fromBytes(U.subarray(m*1,m*2));if(!d(g,y))throw new Error("bad point: is not on curve");return{x:g,y}}else throw new Error(`bad point: got length ${v}, expected compressed=${p} or uncompressed=${E}`)}let h=t.toBytes||c,l=t.fromBytes||u,f=Xf(e,r.a,r.b);function d(P,m){let p=e.sqr(m),E=f(P);return e.eql(p,E)}if(!d(r.Gx,r.Gy))throw new Error("bad curve params: generator point");let b=e.mul(e.pow(r.a,Gr),Yf),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 x(P,m,p=!1){if(!e.isValid(m)||p&&e.is0(m))throw new Error(`bad point coordinate ${P}`);return m}function S(P){if(!(P instanceof _))throw new Error("ProjectivePoint expected")}function C(P){if(!i||!i.basises)throw new Error("no endo");return Wf(P,i.basises,n.ORDER)}let B=Pe((P,m)=>{let{X:p,Y:E,Z:v}=P;if(e.eql(v,e.ONE))return{x:p,y:E};let L=P.is0();m==null&&(m=L?e.ONE:e.inv(v));let U=e.mul(p,m),g=e.mul(E,m),y=e.mul(v,m);if(L)return{x:e.ZERO,y:e.ZERO};if(!e.eql(y,e.ONE))throw new Error("invZ was invalid");return{x:U,y:g}}),D=Pe(P=>{if(P.is0()){if(t.allowInfinityPoint&&!e.is0(P.Y))return;throw new Error("bad point: ZERO")}let{x:m,y:p}=P.toAffine();if(!e.isValid(m)||!e.isValid(p))throw new Error("bad point: x or y not field elements");if(!d(m,p))throw new Error("bad point: equation left != right");if(!P.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function R(P,m,p,E,v){return p=new _(e.mul(p.X,P),p.Y,p.Z),m=ar(E,m),p=ar(v,p),m.add(p)}class _{constructor(m,p,E){this.X=x("x",m),this.Y=x("y",p,!0),this.Z=x("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 _)throw new Error("projective point not allowed");return e.is0(p)&&e.is0(E)?_.ZERO:new _(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 Ht(_,m)}static fromBytes(m){return Y(m),_.fromHex(m)}static fromHex(m){let p=_.fromAffine(l(q("pointHex",m)));return p.assertValidity(),p}static fromPrivateKey(m){return _.BASE.multiply(Re(n,m))}static msm(m,p){return Ue(_,n,m,p)}_setWindowSize(m){this.precompute(m)}precompute(m=8,p=!0){return M.createCache(this,m),p||this.multiply(Gr),this}assertValidity(){D(this)}hasEvenY(){let{y:m}=this.toAffine();if(!e.isOdd)throw new Error("Field doesn't support isOdd");return!e.isOdd(m)}equals(m){S(m);let{X:p,Y:E,Z:v}=this,{X:L,Y:U,Z:g}=m,y=e.eql(e.mul(p,g),e.mul(L,v)),A=e.eql(e.mul(E,g),e.mul(U,v));return y&&A}negate(){return new _(this.X,e.neg(this.Y),this.Z)}double(){let{a:m,b:p}=r,E=e.mul(p,Gr),{X:v,Y:L,Z:U}=this,g=e.ZERO,y=e.ZERO,A=e.ZERO,T=e.mul(v,v),N=e.mul(L,L),K=e.mul(U,U),H=e.mul(v,L);return H=e.add(H,H),A=e.mul(v,U),A=e.add(A,A),g=e.mul(m,A),y=e.mul(E,K),y=e.add(g,y),g=e.sub(N,y),y=e.add(N,y),y=e.mul(g,y),g=e.mul(H,g),A=e.mul(E,A),K=e.mul(m,K),H=e.sub(T,K),H=e.mul(m,H),H=e.add(H,A),A=e.add(T,T),T=e.add(A,T),T=e.add(T,K),T=e.mul(T,H),y=e.add(y,T),K=e.mul(L,U),K=e.add(K,K),T=e.mul(K,H),g=e.sub(g,T),A=e.mul(K,N),A=e.add(A,A),A=e.add(A,A),new _(g,y,A)}add(m){S(m);let{X:p,Y:E,Z:v}=this,{X:L,Y:U,Z:g}=m,y=e.ZERO,A=e.ZERO,T=e.ZERO,N=r.a,K=e.mul(r.b,Gr),H=e.mul(p,L),F=e.mul(E,U),z=e.mul(v,g),lt=e.add(p,E),V=e.add(L,U);lt=e.mul(lt,V),V=e.add(H,F),lt=e.sub(lt,V),V=e.add(p,v);let J=e.add(L,g);return V=e.mul(V,J),J=e.add(H,z),V=e.sub(V,J),J=e.add(E,v),y=e.add(U,g),J=e.mul(J,y),y=e.add(F,z),J=e.sub(J,y),T=e.mul(N,V),y=e.mul(K,z),T=e.add(y,T),y=e.sub(F,T),T=e.add(F,T),A=e.mul(y,T),F=e.add(H,H),F=e.add(F,H),z=e.mul(N,z),V=e.mul(K,V),F=e.add(F,z),z=e.sub(H,z),z=e.mul(N,z),V=e.add(V,z),H=e.mul(F,V),A=e.add(A,H),H=e.mul(J,V),y=e.mul(lt,y),y=e.sub(y,H),H=e.mul(lt,F),T=e.mul(J,T),T=e.add(T,H),new _(y,A,T)}subtract(m){return this.add(m.negate())}is0(){return this.equals(_.ZERO)}multiply(m){let{endo:p}=t;if(!n.isValidNot0(m))throw new Error("invalid scalar: out of range");let E,v,L=U=>M.cached(this,U,g=>Ht(_,g));if(p){let{k1neg:U,k1:g,k2neg:y,k2:A}=C(m),{p:T,f:N}=L(g),{p:K,f:H}=L(A);v=N.add(H),E=R(p.beta,T,K,U,y)}else{let{p:U,f:g}=L(m);E=U,v=g}return Ht(_,[E,v])[0]}multiplyUnsafe(m){let{endo:p}=t,E=this;if(!n.isValid(m))throw new Error("invalid scalar: out of range");if(m===Ft||E.is0())return _.ZERO;if(m===Ke)return E;if(M.hasCache(this))return this.multiply(m);if(p){let{k1neg:v,k1:L,k2neg:U,k2:g}=C(m),{p1:y,p2:A}=bi(_,E,L,g);return R(p.beta,y,A,v,U)}else return M.unsafe(E,m)}multiplyAndAddUnsafe(m,p,E){let v=this.multiplyUnsafe(p).add(m.multiplyUnsafe(E));return v.is0()?void 0:v}toAffine(m){return B(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return o===Ke?!0:m?m(_,this):M.unsafe(this,s).is0()}clearCofactor(){let{clearCofactor:m}=t;return o===Ke?this:m?m(_,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(m=!0){return Rt("isCompressed",m),this.assertValidity(),h(_,this,m)}toRawBytes(m=!0){return this.toBytes(m)}toHex(m=!0){return St(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}_.BASE=new _(r.Gx,r.Gy,e.ONE),_.ZERO=new _(e.ZERO,e.ONE,e.ZERO),_.Fp=e,_.Fn=n;let k=n.BITS,M=new Oe(_,t.endo?Math.ceil(k/2):k);return _}function Ki(r){return Uint8Array.of(r?2:3)}function Jf(r,t,e={}){_r(t),te(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=e.randomBytes||er,o=e.hmac||((g,...y)=>Po(t,g,ut(...y))),{Fp:s,Fn:i}=r,{ORDER:a,BITS:c}=i,u=Qn(a),h={secret:i.BYTES,public:1+s.BYTES,publicUncompressed:1+2*s.BYTES,signature:2*i.BYTES,seed:u};function l(g){let y=a>>Ke;return g>y}function f(g){return l(g)?i.neg(g):g}function d(g,y){if(!i.isValidNot0(y))throw new Error(`invalid signature ${g}: out of range 1..CURVE.n`)}class b{constructor(y,A,T){d("r",y),d("s",A),this.r=y,this.s=A,T!=null&&(this.recovery=T),Object.freeze(this)}static fromBytes(y,A="compact"){if(A==="compact"){let T=i.BYTES;Y(y,T*2);let N=y.subarray(0,T),K=y.subarray(T,T*2);return new b(i.fromBytes(N),i.fromBytes(K))}if(A==="der"){Y(y);let{r:T,s:N}=zt.toSig(y);return new b(T,N)}throw new Error("invalid format")}static fromHex(y,A){return this.fromBytes(fe(y),A)}addRecoveryBit(y){return new b(this.r,this.s,y)}recoverPublicKey(y){let A=s.ORDER,{r:T,s:N,recovery:K}=this;if(K==null||![0,1,2,3].includes(K))throw new Error("recovery id invalid");if(a*Ri<A&&K>1)throw new Error("recovery id is ambiguous for h>1 curve");let F=K===2||K===3?T+a:T;if(!s.isValid(F))throw new Error("recovery id 2 or 3 invalid");let z=s.toBytes(F),lt=r.fromHex(ut(Ki((K&1)===0),z)),V=i.inv(F),J=k(q("msgHash",y)),ht=i.create(-J*V),Gt=i.create(N*V),oe=r.BASE.multiplyUnsafe(ht).add(lt.multiplyUnsafe(Gt));if(oe.is0())throw new Error("point at infinify");return oe.assertValidity(),oe}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,i.neg(this.s),this.recovery):this}toBytes(y="compact"){if(y==="compact")return ut(i.toBytes(this.r),i.toBytes(this.s));if(y==="der")return fe(zt.hexFromSig(this));throw new Error("invalid format")}toHex(y){return St(this.toBytes(y))}assertValidity(){}static fromCompact(y){return b.fromBytes(q("sig",y),"compact")}static fromDER(y){return b.fromBytes(q("sig",y),"der")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return St(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return St(this.toBytes("compact"))}}function w(g){try{return!!Re(i,g)}catch{return!1}}function x(g,y){try{let A=g.length;return y===!0&&A!==h.public||y===!1&&A!==h.publicUncompressed?!1:!!r.fromBytes(g)}catch{return!1}}function S(g=n(u)){return Jn(g,a)}let C={isValidSecretKey:w,isValidPublicKey:x,randomSecretKey:S,isValidPrivateKey:w,randomPrivateKey:S,normPrivateKeyToScalar:g=>Re(i,g),precompute(g=8,y=r.BASE){return y.precompute(g,!1)}};function B(g,y=!0){return r.BASE.multiply(Re(i,g)).toBytes(y)}function D(g){if(typeof g=="bigint")return!1;if(g instanceof r)return!0;if(i.allowedLengths||h.secret===h.public)return;let y=q("key",g).length;return y===h.public||y===h.publicUncompressed}function R(g,y,A=!0){if(D(g)===!0)throw new Error("first arg must be private key");if(D(y)===!1)throw new Error("second arg must be public key");let T=Re(i,g);return r.fromHex(y).multiply(T).toBytes(A)}let _=e.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let y=De(g),A=g.length*8-c;return A>0?y>>BigInt(A):y},k=e.bits2int_modN||function(g){return i.create(_(g))},M=Jt(c);function P(g){return Qt("num < 2^"+c,g,Ft,M),i.toBytes(g)}function m(g,y,A=p){if(["recovered","canonical"].some(ht=>ht in A))throw new Error("sign() legacy options not supported");let{lowS:T,prehash:N,extraEntropy:K}=A;T==null&&(T=!0),g=q("msgHash",g),Ni(A),N&&(g=q("prehashed msgHash",t(g)));let H=k(g),F=Re(i,y),z=[P(F),P(H)];if(K!=null&&K!==!1){let ht=K===!0?n(h.secret):K;z.push(q("extraEntropy",ht))}let lt=ut(...z),V=H;function J(ht){let Gt=_(ht);if(!i.isValidNot0(Gt))return;let oe=i.inv(Gt),Ve=r.BASE.multiply(Gt).toAffine(),se=i.create(Ve.x);if(se===Ft)return;let qe=i.create(oe*i.create(V+se*F));if(qe===Ft)return;let rs=(Ve.x===se?0:2)|Number(Ve.y&Ke),ns=qe;return T&&l(qe)&&(ns=f(qe),rs^=1),new b(se,ns,rs)}return{seed:lt,k2sig:J}}let p={lowS:e.lowS,prehash:!1},E={lowS:e.lowS,prehash:!1};function v(g,y,A=p){let{seed:T,k2sig:N}=m(g,y,A);return ti(t.outputLen,i.BYTES,o)(T,N)}r.BASE.precompute(8);function L(g,y,A,T=E){let N=g;y=q("msgHash",y),A=q("publicKey",A),Ni(T);let{lowS:K,prehash:H,format:F}=T;if("strict"in T)throw new Error("options.strict was renamed to lowS");let z,lt;if(F===void 0){let V=typeof N=="string"||ce(N),J=!V&&N!==null&&typeof N=="object"&&typeof N.r=="bigint"&&typeof N.s=="bigint";if(!V&&!J)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(J)z=new b(N.r,N.s);else if(V){try{z=b.fromDER(N)}catch(ht){if(!(ht instanceof zt.Err))throw ht}if(!z)try{z=b.fromCompact(N)}catch{return!1}}}else if(F==="compact"||F==="der"){if(typeof N!="string"&&!ce(N))throw new Error('"der" / "compact" format expects Uint8Array signature');z=b.fromBytes(q("sig",N),F)}else if(F==="js"){if(!(N instanceof b))throw new Error('"js" format expects Signature instance');z=N}else throw new Error('format must be "compact", "der" or "js"');if(!z)return!1;try{if(lt=r.fromHex(A),K&&z.hasHighS())return!1;H&&(y=t(y));let{r:V,s:J}=z,ht=k(y),Gt=i.inv(J),oe=i.create(ht*Gt),Ve=i.create(V*Gt),se=r.BASE.multiplyUnsafe(oe).add(lt.multiplyUnsafe(Ve));return se.is0()?!1:i.create(se.x)===V}catch{return!1}}function U(g){let y=C.randomSecretKey(g);return{secretKey:y,publicKey:B(y)}}return Object.freeze({keygen:U,getPublicKey:B,sign:v,verify:L,getSharedSecret:R,utils:C,Point:r,Signature:b,info:{type:"weierstrass",lengths:h,publicKeyHasPrefix:!0}})}function tu(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=bt(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 eu(r){let{CURVE:t,curveOpts:e}=tu(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 ru(r,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:r})}function ki(r){let{CURVE:t,curveOpts:e,hash:n,ecdsaOpts:o}=eu(r),s=Qf(t,e),i=Jf(s,n,o);return ru(r,i)}function Mi(r,t){let e=n=>ki({...r,hash:n});return{...e(t),create:e}}var Uo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},nu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Hi=BigInt(2);function ou(r){let t=Uo.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,h=u*u*r%t,l=G(h,e,t)*h%t,f=G(l,e,t)*h%t,d=G(f,Hi,t)*u%t,b=G(d,o,t)*d%t,w=G(b,s,t)*b%t,x=G(w,a,t)*w%t,S=G(x,c,t)*x%t,C=G(S,a,t)*w%t,B=G(C,e,t)*h%t,D=G(B,i,t)*b%t,R=G(D,n,t)*u%t,_=G(R,Hi,t);if(!Oo.eql(Oo.sqr(_),r))throw new Error("Cannot find square root");return _}var Oo=bt(Uo.p,void 0,void 0,{sqrt:ou}),ke=Mi({...Uo,Fp:Oo,lowS:!0,endo:nu},Ws);function Vi(r,t,e,n){let o=We.digest(e instanceof Uint8Array?e:e.subarray());if(Kr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),ke.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new fr(String(s))});try{return n?.signal?.throwIfAborted(),ke.verify(t,o.digest,r)}catch(s){throw new fr(String(s))}}var Zr=class{type="secp256k1";raw;_key;constructor(t){this._key=zi(t),this.raw=qi(this._key)}toMultihash(){return vt.digest(_e(this))}toCID(){return tt.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:pt(this.raw,t.raw)}verify(t,e,n){return Vi(this._key,e,t,n)}};function Fi(r){return new Zr(r)}function qi(r){return ke.ProjectivePoint.fromHex(r).toRawBytes(!0)}function zi(r){try{return ke.ProjectivePoint.fromHex(r),r}catch(t){throw new gr(String(t))}}function ji(r){let{Type:t,Data:e}=dr.decode(r.digest),n=e??new Uint8Array;switch(t){case wt.Ed25519:return Bi(n);case wt.secp256k1:return Fi(n);case wt.ECDSA:return Ls(n);default:throw new ze}}function _e(r){return dr.encode({Type:wt[r.type],Data:r.raw})}var Gi=Symbol.for("nodejs.util.inspect.custom"),su=114,pr=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()})`}[hn]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return tt.createV1(su,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return pt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return pt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Gi](){return`PeerId(${this.toString()})`}},$r=class extends pr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Wr=class extends pr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Yr=class extends pr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},iu=2336,mr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=vt.digest(it(this.url))}[Gi](){return`PeerId(${this.url})`}[hn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return tt.createV1(iu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=j(t)),t.toString()===this.toString())}};var au=114,Zi=2336;function $i(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Ze(W.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return cu(tt.parse(r));if(t==null)throw new It('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Ze(t.decode(r))}return Wi(e)}function Wi(r){if(uu(r))return new $r({multihash:r});if(fu(r))try{let t=ji(r);if(t.type==="Ed25519")return new Wr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Yr({multihash:r,publicKey:t})}catch{let e=j(r.digest);return new mr(new URL(e))}throw new Er("Supplied PeerID Multihash is invalid")}function cu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==au&&r.code!==Zi)throw new wr("Supplied PeerID CID is invalid");if(r.code===Zi){let t=j(r.multihash.digest);return new mr(new URL(t))}return Wi(r.multihash)}function fu(r){return r.code===vt.code}function uu(r){return r.code===We.code}var st=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},jt=class extends Error{static name="ValidationError";name="ValidationError"},yr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Xr=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Qr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*o)-1;for(;;){let h=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let f=Number.parseInt(l,t);if(!Number.isNaN(f))return f});if(h===void 0)break;if(s*=t,s+=h,s>u||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[o]=i[0],e[o+1]=i[1],e[o+2]=i[2],e[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];e[o]=s>>8,e[o+1]=s&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return e.set(s.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var lu=45,hu=15,Jr=new Qr;function No(r){if(!(r.length>hu))return Jr.new(r).parseWith(()=>Jr.readIPv4Addr())}function Ro(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>lu))return Jr.new(r).parseWith(()=>Jr.readIPv6Addr())}function tn(r){return!!No(r)}function Xi(r){return!!Ro(r)}function ko(r){return t=>j(t,r)}function Mo(r){return t=>it(t,r)}function Me(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function be(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(t)}function Qi(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=it(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=be(n);return Lt([e,o],e.length+o.length)}function Ji(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=$t.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=be(n);return Lt([e,o],e.length+o.length)}function Ho(r){let t=r.subarray(0,r.length-2),e=r.subarray(r.length-2),n=j(t,"base32"),o=Me(e);return`${n}:${o}`}var Vo=function(r){r=r.toString().trim();let t=new Uint8Array(4);return r.split(/\./g).forEach((e,n)=>{let o=parseInt(e,10);if(isNaN(o)||o<0||o>255)throw new st("Invalid byte value in IP address");t[n]=o}),t},ta=function(r){let t=0;r=r.toString().trim();let e=r.split(":",8),n;for(n=0;n<e.length;n++){let s=tn(e[n]),i;s&&(i=Vo(e[n]),e[n]=j(i.subarray(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,j(i.subarray(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let s=[n,1];for(n=9-e.length;n>0;n--)s.push("0");e.splice.apply(e,s)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){e[n]===""&&(e[n]="0");let s=parseInt(e[n],16);if(isNaN(s)||s<0||s>65535)throw new st("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},ea=function(r){if(r.byteLength!==4)throw new st("IPv4 address was incorrect length");let t=[];for(let e=0;e<r.byteLength;e++)t.push(r[e]);return t.join(".")},ra=function(r){if(r.byteLength!==16)throw new st("IPv6 address was incorrect length");let t=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],s=r[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let e=t.join(":");try{let n=new URL(`http://[${e}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new st(`Invalid IPv6 address "${e}"`)}};function na(r){try{let t=new URL(`http://[${r}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new st(`Invalid IPv6 address "${r}"`)}}var Ko=Object.values(Ye).map(r=>r.decoder),du=function(){let r=Ko[0].or(Ko[1]);return Ko.slice(2).forEach(t=>r=r.or(t)),r}();function oa(r){return du.decode(r)}function sa(r){return t=>r.encoder.encode(t)}function pu(r){if(parseInt(r).toString()!==r)throw new jt("Value must be an integer")}function mu(r){if(r<0)throw new jt("Value must be a positive integer, or zero")}function yu(r){return t=>{if(t>r)throw new jt(`Value must be smaller than or equal to ${r}`)}}function bu(...r){return t=>{for(let e of r)e(t)}}var br=bu(pu,mu,yu(65535));var nt=-1,qo=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let e;if(typeof t=="string"?e=this.protocolsByName.get(t):e=this.protocolsByCode.get(t),e==null)throw new Xr(`Protocol ${t} was unknown`);return e}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(e=>{this.protocolsByName.set(e,t)})}removeProtocol(t){let e=this.protocolsByCode.get(t);e!=null&&(this.protocolsByCode.delete(e.code),this.protocolsByName.delete(e.name),e.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},Et=new qo,Zu=[{code:4,name:"ip4",size:32,valueToBytes:Vo,bytesToValue:ea,validate:r=>{if(!tn(r))throw new jt(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:be,bytesToValue:Me,validate:br},{code:273,name:"udp",size:16,valueToBytes:be,bytesToValue:Me,validate:br},{code:33,name:"dccp",size:16,valueToBytes:be,bytesToValue:Me,validate:br},{code:41,name:"ip6",size:128,valueToBytes:ta,bytesToValue:ra,stringToValue:na,validate:r=>{if(!Xi(r))throw new jt(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:nt},{code:43,name:"ipcidr",size:8,bytesToValue:ko("base10"),valueToBytes:Mo("base10")},{code:53,name:"dns",size:nt,resolvable:!0},{code:54,name:"dns4",size:nt,resolvable:!0},{code:55,name:"dns6",size:nt,resolvable:!0},{code:56,name:"dnsaddr",size:nt,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:be,bytesToValue:Me,validate:br},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:nt,path:!0,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:nt,bytesToValue:ko("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Mo("base58btc")(r):tt.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Ho,valueToBytes:Qi},{code:445,name:"onion3",size:296,bytesToValue:Ho,valueToBytes:Ji},{code:446,name:"garlic64",size:nt},{code:447,name:"garlic32",size:nt},{code:448,name:"tls"},{code:449,name:"sni",size:nt},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:nt,bytesToValue:sa(_n),valueToBytes:oa},{code:480,name:"http"},{code:481,name:"http-path",size:nt,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:nt}];Zu.forEach(r=>{Et.addProtocol(r)});function ia(r){let t=[],e=0;for(;e<r.length;){let n=yo(r,e),o=Et.getProtocol(n),s=Tt(n),i=$u(o,r,e+s),a=0;i>0&&o.size===nt&&(a=Tt(i));let c=s+a+i,u={code:n,name:o.name,bytes:r.subarray(e,e+c)};if(i>0){let h=e+s+a,l=r.subarray(h,h+i);u.value=o.bytesToValue?.(l)??j(l)}t.push(u),e+=c}return t}function aa(r){let t=0,e=[];for(let n of r){if(n.bytes==null){let o=Et.getProtocol(n.code),s=Tt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??it(n.value),a=i.byteLength,o.size===nt&&(c=Tt(a)));let u=new Uint8Array(s+c+a),h=0;ur(n.code,u,h),h+=s,i!=null&&(o.size===nt&&(ur(a,u,h),h+=c),u.set(i,h)),n.bytes=u}e.push(n.bytes),t+=n.bytes.byteLength}return Lt(e,t)}function ca(r){if(r.charAt(0)!=="/")throw new st('String multiaddr must start with "/"');let t=[],e="protocol",n="",o="";for(let s=1;s<r.length;s++){let i=r.charAt(s);i!=="/"&&(e==="protocol"?o+=r.charAt(s):n+=r.charAt(s));let a=s===r.length-1;if(i==="/"||a){let c=Et.getProtocol(o);if(e==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",e="protocol";continue}else if(a)throw new st(`Component ${o} was missing value`);e="value"}else if(e==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new st(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}t.push(u),n="",o="",e="protocol"}}}if(o!==""&&n!=="")throw new st("Incomplete multiaddr");return t}function fa(r){return`/${r.flatMap(t=>{if(t.value==null)return t.name;let e=Et.getProtocol(t.code);if(e==null)throw new st(`Unknown protocol code ${t.code}`);return[t.name,e.valueToString?.(t.value)??t.value]}).join("/")}`}function $u(r,t,e){return r.size==null||r.size===0?0:r.size>0?r.size/8:yo(t,e)}var Wu=Symbol.for("nodejs.util.inspect.custom"),Yo=Symbol.for("@multiformats/multiaddr"),Yu=[53,54,55,56],Wo=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}};function Xu(r){if(r==null&&(r="/"),la(r))return r.getComponents();if(r instanceof Uint8Array)return ia(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),ca(r);if(Array.isArray(r))return r;throw new st("Must be a string, Uint8Array, Component[], or another Multiaddr")}var sn=class r{[Yo]=!0;#t;#e;#r;constructor(t="/",e={}){this.#t=Xu(t),e.validate!==!1&&Qu(this)}get bytes(){return this.#r==null&&(this.#r=aa(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=fa(this.#t)),this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,s="";for(let{code:a,name:c,value:u}of this.#t)a===42&&(s=`%${u??""}`),Yu.includes(a)&&(e="tcp",o=443,n=`${u??""}${s}`,t=a===55?6:4),(a===6||a===273)&&(e=c==="tcp"?"tcp":"udp",o=parseInt(u??"")),(a===4||a===41)&&(e="tcp",n=`${u??""}${s}`,t=a===41?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}getComponents(){return[...this.#t]}protos(){return this.#t.map(({code:t,value:e})=>{let n=Et.getProtocol(t);return{code:t,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#t.map(({code:t})=>t)}protoNames(){return this.#t.map(({name:t})=>t)}tuples(){return this.#t.map(({code:t,value:e})=>{if(e==null)return[t];let n=Et.getProtocol(t),o=[t];return e!=null&&o.push(n.valueToBytes?.(e)??it(e)),o})}stringTuples(){return this.#t.map(({code:t,value:e})=>e==null?[t]:[t,e])}encapsulate(t){let e=new r(t);return new r([...this.#t,...e.getComponents()],{validate:!1})}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new yr(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(t){let e;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){e=n;break}return new r(this.#t.slice(0,e),{validate:!1})}getPeerId(){try{let t=[];this.#t.forEach(({code:n,value:o})=>{n===421&&t.push([n,o]),n===290&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?j(W.decode(`z${n}`),"base58btc"):j(tt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let t of this.#t)if(Et.getProtocol(t.code).path)return t.value??null;return null}equals(t){return pt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(s=>s.resolvable);if(e==null)return[this];let n=ua.get(e.name);if(n==null)throw new Wo(`no available resolver for ${e.name}`);return(await n(this,t)).map(s=>re(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(){return!(this.#t.length!==2||this.#t[0].code!==4&&this.#t[0].code!==41||this.#t[1].code!==6&&this.#t[1].code!==273)}[Wu](){return`Multiaddr(${this.toString()})`}};function Qu(r){r.getComponents().forEach(t=>{let e=Et.getProtocol(t.code);t.value!=null&&e.validate?.(t.value)})}var sy=parseInt("0xFFFF",16),iy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var ua=new Map;function la(r){return!!r?.[Yo]}function re(r){return new sn(r)}var nl=I("dns4"),ol=I("dns6"),sl=I("dnsaddr"),ge=Q(I("dns"),sl,nl,ol),fn=Q(I("ip4"),I("ip6")),He=Q(O(fn,I("tcp")),O(ge,I("tcp"))),un=O(fn,I("udp")),il=O(un,I("utp")),al=O(un,I("quic")),cl=O(un,I("quic-v1")),Xo=Q(O(He,I("ws")),O(ge,I("ws"))),an=Q(O(Xo,I("p2p")),Xo),Qo=Q(O(He,I("wss")),O(ge,I("wss")),O(He,I("tls"),I("ws")),O(ge,I("tls"),I("ws"))),cn=Q(O(Qo,I("p2p")),Qo),Jo=Q(O(He,I("http")),O(fn,I("http")),O(ge,I("http"))),ts=Q(O(He,I("https")),O(fn,I("https")),O(ge,I("https"))),pa=O(un,I("webrtc-direct"),I("certhash")),ba=Q(O(pa,I("p2p")),pa),ma=O(cl,I("webtransport"),I("certhash"),I("certhash")),xa=Q(O(ma,I("p2p")),ma),ga=Q(O(an,I("p2p-webrtc-star"),I("p2p")),O(cn,I("p2p-webrtc-star"),I("p2p")),O(an,I("p2p-webrtc-star")),O(cn,I("p2p-webrtc-star"))),Gy=Q(O(an,I("p2p-websocket-star"),I("p2p")),O(cn,I("p2p-websocket-star"),I("p2p")),O(an,I("p2p-websocket-star")),O(cn,I("p2p-websocket-star"))),wa=Q(O(Jo,I("p2p-webrtc-direct"),I("p2p")),O(ts,I("p2p-webrtc-direct"),I("p2p")),O(Jo,I("p2p-webrtc-direct")),O(ts,I("p2p-webrtc-direct"))),we=Q(Xo,Qo,Jo,ts,ga,wa,He,il,al,ge,ba,xa),Zy=Q(O(we,I("p2p-stardust"),I("p2p")),O(we,I("p2p-stardust"))),ne=Q(O(we,I("p2p")),ga,wa,ba,xa,I("p2p")),ya=Q(O(ne,I("p2p-circuit"),ne),O(ne,I("p2p-circuit")),O(I("p2p-circuit"),ne),O(we,I("p2p-circuit")),O(I("p2p-circuit"),we),I("p2p-circuit")),Ea=()=>Q(O(ya,Ea),ya),xe=Ea(),Sa=Q(O(xe,ne,xe),O(ne,xe),O(xe,ne),xe,ne);var $y=Q(O(xe,I("webrtc"),I("p2p")),O(xe,I("webrtc")),O(we,I("webrtc"),I("p2p")),O(we,I("webrtc")),I("webrtc"));function va(r){function t(e){let n;try{n=re(e)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function O(...r){function t(e){if(e.length<r.length)return null;let n=e;return r.some(o=>(n=typeof o=="function"?o().partialMatch(e):o.partialMatch(e),Array.isArray(n)&&(e=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:va(t),partialMatch:t}}function Q(...r){function t(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:va(t),partialMatch:t}}function I(r){let t=r;function e(o){let s;try{s=re(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:e,partialMatch:n}}var fl="bootstrap",ul=50,ll=1e3,es=class extends Sr{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,e={list:[]}){if(e.list==null||e.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=e.timeout??ll,this.list=[];for(let n of e.list){if(!Sa.matches(n)){this.log.error("Invalid multiaddr");continue}let o=re(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:$i(s),multiaddrs:[o]};this.list.push(i)}this._init=e}[os]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[ss]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??fl]:{value:this._init.tagValue??ul,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(e=>{this.log.error("could not dial bootstrap peer %p",t.id,e)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function hl(r){return t=>new es(t,r)}return Ca(dl);})();
|
|
2
|
+
"use strict";var Libp2PBootstrap=(()=>{var ln=Object.defineProperty;var Ca=Object.getOwnPropertyDescriptor;var Ta=Object.getOwnPropertyNames;var Da=Object.prototype.hasOwnProperty;var mt=(e,t)=>{for(var r in t)ln(e,r,{get:t[r],enumerable:!0})},Pa=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ta(t))!Da.call(e,o)&&o!==r&&ln(e,o,{get:()=>t[o],enumerable:!(n=Ca(t,o))||n.enumerable});return e};var La=e=>Pa(ln({},"__esModule",{value:!0}),e);var bl={};mt(bl,{bootstrap:()=>yl});var fs=Symbol.for("@libp2p/peer-discovery");var hn=Symbol.for("@libp2p/peer-id");var Ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},gr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var xr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},wr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var He=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Er=class extends EventTarget{#t=new Map;constructor(){super()}listenerCount(t){let r=this.#t.get(t);return r==null?0:r.length}addEventListener(t,r,n){super.addEventListener(t,r,n);let o=this.#t.get(t);o==null&&(o=[],this.#t.set(t,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(t,r,n){super.removeEventListener(t.toString(),r??null,n);let o=this.#t.get(t);o!=null&&(o=o.filter(({callback:s})=>s!==r),this.#t.set(t,o))}dispatchEvent(t){let r=super.dispatchEvent(t),n=this.#t.get(t.type);return n==null||(n=n.filter(({once:o})=>!o),this.#t.set(t.type,n)),r}safeDispatchEvent(t,r={}){return this.dispatchEvent(new CustomEvent(t,r))}};var us=Symbol.for("@libp2p/service-capabilities"),vl=Symbol.for("@libp2p/service-dependencies");var bn={};mt(bn,{base58btc:()=>X,base58flickr:()=>Ma});var jl=new Uint8Array(0);function ls(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Pt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function hs(e){return new TextEncoder().encode(e)}function ds(e){return new TextDecoder().decode(e)}function Ua(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var E=0,v=0,g=0,B=h.length;g!==B&&h[g]===0;)g++,E++;for(var w=(B-g)*d+1>>>0,P=new Uint8Array(w);g!==B;){for(var R=h[g],V=0,M=w-1;(R!==0||V<v)&&M!==-1;M--,V++)R+=256*P[M]>>>0,P[M]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");v=V,g++}for(var N=w-v;N!==w&&P[N]===0;)N++;for(var x=c.repeat(E);N<w;++N)x+=e.charAt(P[N]);return x}function f(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var E=0;if(h[E]!==" "){for(var v=0,g=0;h[E]===c;)v++,E++;for(var B=(h.length-E)*u+1>>>0,w=new Uint8Array(B);h[E];){var P=r[h.charCodeAt(E)];if(P===255)return;for(var R=0,V=B-1;(P!==0||R<g)&&V!==-1;V--,R++)P+=a*w[V]>>>0,w[V]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");g=R,E++}if(h[E]!==" "){for(var M=B-g;M!==B&&w[M]===0;)M++;for(var N=new Uint8Array(v+(B-M)),x=v;M!==B;)N[x++]=w[M++];return N}}}function p(h){var E=f(h);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:f,decode:p}}var Oa=Ua,Ra=Oa,ms=Ra;var dn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},pn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ys(this,t)}},mn=class{decoders;constructor(t){this.decoders=t}or(t){return ys(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ys(e,t){return new mn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var yn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new dn(t,r,n),this.decoder=new pn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function xe({name:e,prefix:t,encode:r,decode:n}){return new yn(e,t,r,n)}function $t({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ms(r,e);return xe({prefix:t,name:e,encode:n,decode:s=>Pt(o(s))})}function Na(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let u=0;u<o;++u){let d=t[e[u]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|d,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Ka(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function ka(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function Y({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=ka(n);return xe({prefix:t,name:e,encode(s){return Ka(s,n,r)},decode(s){return Na(s,o,r,e)}})}var X=$t({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ma=$t({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var gn={};mt(gn,{base32:()=>Wt,base32hex:()=>za,base32hexpad:()=>ja,base32hexpadupper:()=>Ga,base32hexupper:()=>Fa,base32pad:()=>Ha,base32padupper:()=>qa,base32upper:()=>Va,base32z:()=>Za});var Wt=Y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Va=Y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ha=Y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qa=Y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),za=Y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fa=Y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ja=Y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ga=Y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Za=Y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xn={};mt(xn,{base36:()=>qe,base36upper:()=>$a});var qe=$t({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$a=$t({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Wa=xs,bs=128,Ya=127,Xa=~Ya,Qa=Math.pow(2,31);function xs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Qa;)t[r++]=e&255|bs,e/=128;for(;e&Xa;)t[r++]=e&255|bs,e>>>=7;return t[r]=e|0,xs.bytes=r-n+1,t}var Ja=wn,tc=128,gs=127;function wn(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw wn.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&gs)<<o:(i&gs)*Math.pow(2,o),o+=7}while(i>=tc);return wn.bytes=s-n,r}var ec=Math.pow(2,7),rc=Math.pow(2,14),nc=Math.pow(2,21),oc=Math.pow(2,28),sc=Math.pow(2,35),ic=Math.pow(2,42),ac=Math.pow(2,49),cc=Math.pow(2,56),fc=Math.pow(2,63),uc=function(e){return e<ec?1:e<rc?2:e<nc?3:e<oc?4:e<sc?5:e<ic?6:e<ac?7:e<cc?8:e<fc?9:10},lc={encode:Wa,decode:Ja,encodingLength:uc},hc=lc,ze=hc;function Fe(e,t=0){return[ze.decode(e,t),ze.decode.bytes]}function we(e,t,r=0){return ze.encode(e,t,r),t}function Ee(e){return ze.encodingLength(e)}function ie(e,t){let r=t.byteLength,n=Ee(e),o=n+Ee(r),s=new Uint8Array(o+r);return we(e,s,0),we(r,s,n),s.set(t,o),new Se(e,r,t,s)}function je(e){let t=Pt(e),[r,n]=Fe(t),[o,s]=Fe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Se(r,o,i,t)}function ws(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ls(e.bytes,r.bytes)}}var Se=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Es(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return pc(r,En(e),t??X.encoder);default:return mc(r,En(e),t??Wt.encoder)}}var Ss=new WeakMap;function En(e){let t=Ss.get(e);if(t==null){let r=new Map;return Ss.set(e,r),r}return t}var et=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==yc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=ie(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ws(t.multihash,n.multihash)}toString(t){return Es(this,t)}toJSON(){return{"/":Es(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??vs(n,o,s.bytes))}else if(r[bc]===!0){let{version:n,multihash:o,code:s}=r,i=je(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Ge)throw new Error(`Version 0 CID must use dag-pb (code: ${Ge}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=vs(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Ge,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Pt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Se(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,f]=Fe(t.subarray(r));return r+=f,l},o=n(),s=Ge;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),u=r+c,d=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:d,size:u}}static parse(t,r){let[n,o]=dc(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return En(s).set(n,t),s}};function dc(e,t){switch(e[0]){case"Q":{let r=t??X;return[X.prefix,r.decode(`${X.prefix}${e}`)]}case X.prefix:{let r=t??X;return[X.prefix,r.decode(e)]}case Wt.prefix:{let r=t??Wt;return[Wt.prefix,r.decode(e)]}case qe.prefix:{let r=t??qe;return[qe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function pc(e,t,r){let{prefix:n}=r;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function mc(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var Ge=112,yc=18;function vs(e,t,r){let n=Ee(e),o=n+Ee(t),s=new Uint8Array(o+r.byteLength);return we(e,s,0),we(t,s,n),s.set(r,o),s}var bc=Symbol.for("@ipld/js-cid/CID");var Sn={};mt(Sn,{identity:()=>Bt});var As=0,gc="identity",Bs=Pt;function xc(e){return ie(As,Bs(e))}var Bt={code:As,name:gc,encode:Bs,digest:xc};function yt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Lt(e=0){return new Uint8Array(e)}function bt(e=0){return new Uint8Array(e)}function Ut(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=bt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var _s=Symbol.for("@achingbrain/uint8arraylist");function Is(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function vr(e){return!!e?.[_s]}var gt=class e{bufs;length;[_s]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(vr(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(vr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=Is(this.bufs,t);return r.buf[r.index]}set(t,r){let n=Is(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(vr(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return Ut(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ut(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=[...n],s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,d=r>a&&r<=c;if(u&&d){if(t===a&&r===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(r-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(d){if(r===c){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!vr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,u=n.byteLength-1,d;for(let l=r;l<=c;l+=d){d=0;for(let f=u;f>=0;f--){let p=this.get(l+f);if(n[f]!==p){d=Math.max(1,f-a[p]);break}}if(d===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!yt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var vn={};mt(vn,{base10:()=>wc});var wc=$t({prefix:"9",name:"base10",alphabet:"0123456789"});var An={};mt(An,{base16:()=>Ec,base16upper:()=>Sc});var Ec=Y({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sc=Y({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bn={};mt(Bn,{base2:()=>vc});var vc=Y({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var In={};mt(In,{base256emoji:()=>Cc});var Cs=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}"),Ac=Cs.reduce((e,t,r)=>(e[r]=t,e),[]),Bc=Cs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Ic(e){return e.reduce((t,r)=>(t+=Ac[r],t),"")}function _c(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Bc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Cc=xe({prefix:"\u{1F680}",name:"base256emoji",encode:Ic,decode:_c});var Cn={};mt(Cn,{base64:()=>Tc,base64pad:()=>Dc,base64url:()=>_n,base64urlpad:()=>Pc});var Tc=Y({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Dc=Y({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_n=Y({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pc=Y({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Tn={};mt(Tn,{base8:()=>Lc});var Lc=Y({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Dn={};mt(Dn,{identity:()=>Uc});var Uc=xe({prefix:"\0",name:"identity",encode:e=>ds(e),decode:e=>hs(e)});var Ch=new TextEncoder,Th=new TextDecoder;var Un={};mt(Un,{sha256:()=>Ze,sha512:()=>Nc});function Ln({name:e,code:t,encode:r}){return new Pn(e,t,r)}var Pn=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?ie(this.code,r):r.then(n=>ie(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ds(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Ze=Ln({name:"sha2-256",code:18,encode:Ds("SHA-256")}),Nc=Ln({name:"sha2-512",code:19,encode:Ds("SHA-512")});var $e={...Dn,...Bn,...Tn,...vn,...An,...gn,...xn,...bn,...Cn,...In},Hh={...Un,...Sn};function Ls(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ps=Ls("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),On=Ls("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=bt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Kc={utf8:Ps,"utf-8":Ps,hex:$e.base16,latin1:On,ascii:On,binary:On,...$e},Ar=Kc;function ct(e,t="utf8"){let r=Ar[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function F(e,t="utf8"){let r=Ar[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var kc=parseInt("11111",2),Rn=parseInt("10000000",2),Mc=parseInt("01111111",2),Us={0:We,1:We,2:Vc,3:zc,4:Fc,5:qc,6:Hc,16:We,22:We,48:We};function Nn(e,t={offset:0}){let r=e[t.offset]&kc;if(t.offset++,Us[r]!=null)return Us[r](e,t);throw new Error("No decoder for tag "+r)}function Ye(e,t){let r=0;if((e[t.offset]&Rn)===Rn){let n=e[t.offset]&Mc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function We(e,t){Ye(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Nn(e,t);if(n===null)break;r.push(n)}return r}function Vc(e,t){let r=Ye(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Hc(e,t){let r=Ye(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let u=e[t.offset];if(t.offset++,c.push(u&127),u<128){c.reverse();let d=0;for(let l=0;l<c.length;l++)d+=c[l]<<l*7;a+=`.${d}`,c=[]}}return a}function qc(e,t){return t.offset++,null}function zc(e,t){let r=Ye(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Fc(e,t){let r=Ye(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function jc(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new gt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Kn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=jc(e.byteLength);return new gt(Uint8Array.from([t.byteLength|Rn]),t)}function Os(e){let t=new gt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new gt(Uint8Array.from([2]),Kn(t),t)}function Rs(e){let t=Uint8Array.from([0]),r=new gt(t,e);return new gt(Uint8Array.from([3]),Kn(r),r)}function Br(e,t=48){let r=new gt;for(let n of e)r.append(n);return new gt(Uint8Array.from([t]),Kn(r),r)}async function Ns(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),s}var Gc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Zc=Uint8Array.from([6,5,43,129,4,0,34]),$c=Uint8Array.from([6,5,43,129,4,0,35]),Wc={ext:!0,kty:"EC",crv:"P-256"},Yc={ext:!0,kty:"EC",crv:"P-384"},Xc={ext:!0,kty:"EC",crv:"P-521"},kn=32,Mn=48,Vn=66;function Ks(e){let t=Nn(e);return ks(t)}function ks(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===kn*2+1)return n=F(t.subarray(r,r+kn),"base64url"),o=F(t.subarray(r+kn),"base64url"),new Ae({...Wc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Mn*2+1)return n=F(t.subarray(r,r+Mn),"base64url"),o=F(t.subarray(r+Mn),"base64url"),new Ae({...Yc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Vn*2+1)return n=F(t.subarray(r,r+Vn),"base64url"),o=F(t.subarray(r+Vn),"base64url"),new Ae({...Xc,key_ops:["verify"],x:n,y:o});throw new Ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ms(e){return Br([Os(Uint8Array.from([1])),Br([Qc(e.crv)],160),Br([Rs(new gt(Uint8Array.from([4]),ct(e.x??"","base64url"),ct(e.y??"","base64url")))],161)]).subarray()}function Qc(e){if(e==="P-256")return Gc;if(e==="P-384")return Zc;if(e==="P-521")return $c;throw new Ct(`Invalid curve ${e}`)}var Ae=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ms(this.jwk)),this._raw}toMultihash(){return Bt.digest(Be(this))}toCID(){return et.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}async verify(t,r,n){return Ns(this.jwk,r,t,n)}};var ae=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Rt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Xe(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function pt(e,...t){if(!Rt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ir(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Xe(e.outputLen),Xe(e.blockLen)}function _e(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Hs(e,t){pt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Nt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function _r(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function It(e,t){return e<<32-t|e>>>t}var qs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Jc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function At(e){if(pt(e),qs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Jc[e[r]];return t}var Ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function Vs(e){if(e>=Ot._0&&e<=Ot._9)return e-Ot._0;if(e>=Ot.A&&e<=Ot.F)return e-(Ot.A-10);if(e>=Ot.a&&e<=Ot.f)return e-(Ot.a-10)}function ce(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(qs)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Vs(e.charCodeAt(s)),a=Vs(e.charCodeAt(s+1));if(i===void 0||a===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Hn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Qe(e){return typeof e=="string"&&(e=Hn(e)),pt(e),e}function lt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];pt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}var Ie=class{};function qn(e){let t=n=>e().update(Qe(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ce(e=32){if(ae&&typeof ae.getRandomValues=="function")return ae.getRandomValues(new Uint8Array(e));if(ae&&typeof ae.randomBytes=="function")return Uint8Array.from(ae.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function tf(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),c=n?4:0,u=n?0:4;e.setUint32(t+c,i,n),e.setUint32(t+u,a,n)}function zs(e,t,r){return e&t^~e&r}function Fs(e,t,r){return e&t^e&r^t&r}var Je=class extends Ie{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=_r(this.buffer)}update(t){_e(this),t=Qe(t),pt(t);let{view:r,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=_r(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(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){_e(this),Hs(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Nt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)r[l]=0;tf(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=_r(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 l=0;l<u;l++)a.setUint32(4*l,d[l],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Kt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var st=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Cr=BigInt(4294967295),js=BigInt(32);function ef(e,t=!1){return t?{h:Number(e&Cr),l:Number(e>>js&Cr)}:{h:Number(e>>js&Cr)|0,l:Number(e&Cr)|0}}function Gs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=ef(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var zn=(e,t,r)=>e>>>r,Fn=(e,t,r)=>e<<32-r|t>>>r,fe=(e,t,r)=>e>>>r|t<<32-r,ue=(e,t,r)=>e<<32-r|t>>>r,tr=(e,t,r)=>e<<64-r|t>>>r-32,er=(e,t,r)=>e>>>r-32|t<<64-r;function Tt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Zs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),$s=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ws=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ys=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Xs=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Qs=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var nf=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]),Yt=new Uint32Array(64),jn=class extends Je{constructor(t=32){super(64,t,8,!1),this.A=Kt[0]|0,this.B=Kt[1]|0,this.C=Kt[2]|0,this.D=Kt[3]|0,this.E=Kt[4]|0,this.F=Kt[5]|0,this.G=Kt[6]|0,this.H=Kt[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,r){for(let l=0;l<16;l++,r+=4)Yt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let f=Yt[l-15],p=Yt[l-2],h=It(f,7)^It(f,18)^f>>>3,E=It(p,17)^It(p,19)^p>>>10;Yt[l]=E+Yt[l-7]+h+Yt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:d}=this;for(let l=0;l<64;l++){let f=It(a,6)^It(a,11)^It(a,25),p=d+f+zs(a,c,u)+nf[l]+Yt[l]|0,E=(It(n,2)^It(n,13)^It(n,22))+Fs(n,o,s)|0;d=u,u=c,c=a,a=i+p|0,i=s,s=o,o=n,n=p+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,u=u+this.G|0,d=d+this.H|0,this.set(n,o,s,i,a,c,u,d)}roundClean(){Nt(Yt)}destroy(){this.set(0,0,0,0,0,0,0,0),Nt(this.buffer)}};var Js=Gs(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),of=Js[0],sf=Js[1],Xt=new Uint32Array(80),Qt=new Uint32Array(80),Gn=class extends Je{constructor(t=64){super(128,t,16,!1),this.Ah=st[0]|0,this.Al=st[1]|0,this.Bh=st[2]|0,this.Bl=st[3]|0,this.Ch=st[4]|0,this.Cl=st[5]|0,this.Dh=st[6]|0,this.Dl=st[7]|0,this.Eh=st[8]|0,this.El=st[9]|0,this.Fh=st[10]|0,this.Fl=st[11]|0,this.Gh=st[12]|0,this.Gl=st[13]|0,this.Hh=st[14]|0,this.Hl=st[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:d,Fh:l,Fl:f,Gh:p,Gl:h,Hh:E,Hl:v}=this;return[t,r,n,o,s,i,a,c,u,d,l,f,p,h,E,v]}set(t,r,n,o,s,i,a,c,u,d,l,f,p,h,E,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=d|0,this.Fh=l|0,this.Fl=f|0,this.Gh=p|0,this.Gl=h|0,this.Hh=E|0,this.Hl=v|0}process(t,r){for(let w=0;w<16;w++,r+=4)Xt[w]=t.getUint32(r),Qt[w]=t.getUint32(r+=4);for(let w=16;w<80;w++){let P=Xt[w-15]|0,R=Qt[w-15]|0,V=fe(P,R,1)^fe(P,R,8)^zn(P,R,7),M=ue(P,R,1)^ue(P,R,8)^Fn(P,R,7),N=Xt[w-2]|0,x=Qt[w-2]|0,T=fe(N,x,19)^tr(N,x,61)^zn(N,x,6),K=ue(N,x,19)^er(N,x,61)^Fn(N,x,6),D=Ws(M,K,Qt[w-7],Qt[w-16]),b=Ys(D,V,T,Xt[w-7],Xt[w-16]);Xt[w]=b|0,Qt[w]=D|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:d,Eh:l,El:f,Fh:p,Fl:h,Gh:E,Gl:v,Hh:g,Hl:B}=this;for(let w=0;w<80;w++){let P=fe(l,f,14)^fe(l,f,18)^tr(l,f,41),R=ue(l,f,14)^ue(l,f,18)^er(l,f,41),V=l&p^~l&E,M=f&h^~f&v,N=Xs(B,R,M,sf[w],Qt[w]),x=Qs(N,g,P,V,of[w],Xt[w]),T=N|0,K=fe(n,o,28)^tr(n,o,34)^tr(n,o,39),D=ue(n,o,28)^er(n,o,34)^er(n,o,39),b=n&s^n&a^s&a,m=o&i^o&c^i&c;g=E|0,B=v|0,E=p|0,v=h|0,p=l|0,h=f|0,{h:l,l:f}=Tt(u|0,d|0,x|0,T|0),u=a|0,d=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let y=Zs(T,D,m);n=$s(y,x,K,b),o=y|0}({h:n,l:o}=Tt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Tt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Tt(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:d}=Tt(this.Dh|0,this.Dl|0,u|0,d|0),{h:l,l:f}=Tt(this.Eh|0,this.El|0,l|0,f|0),{h:p,l:h}=Tt(this.Fh|0,this.Fl|0,p|0,h|0),{h:E,l:v}=Tt(this.Gh|0,this.Gl|0,E|0,v|0),{h:g,l:B}=Tt(this.Hh|0,this.Hl|0,g|0,B|0),this.set(n,o,s,i,a,c,u,d,l,f,p,h,E,v,g,B)}roundClean(){Nt(Xt,Qt)}destroy(){Nt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ti=qn(()=>new jn);var ei=qn(()=>new Gn);var Wn=BigInt(0),$n=BigInt(1);function kt(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}"`;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function xt(e,t,r=""){let n=Rt(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,a=s?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return e}function rr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function ri(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Wn:BigInt("0x"+e)}function Te(e){return ri(At(e))}function Mt(e){return pt(e),ri(At(Uint8Array.from(e).reverse()))}function Tr(e,t){return ce(e.toString(16).padStart(t*2,"0"))}function Yn(e,t){return Tr(e,t).reverse()}function q(e,t,r){let n;if(typeof t=="string")try{n=ce(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(Rt(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function ni(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Xn(e){return Uint8Array.from(e)}var Zn=e=>typeof e=="bigint"&&Wn<=e;function oi(e,t,r){return Zn(e)&&Zn(t)&&Zn(r)&&t<=e&&e<r}function nr(e,t,r,n){if(!oi(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Dr(e){let t;for(t=0;e>Wn;e>>=$n,t+=1);return t}var Jt=e=>($n<<BigInt(e))-$n;function si(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=p=>new Uint8Array(p),o=p=>Uint8Array.of(p),s=n(e),i=n(e),a=0,c=()=>{s.fill(1),i.fill(0),a=0},u=(...p)=>r(i,s,...p),d=(p=n(0))=>{i=u(o(0),p),s=u(),p.length!==0&&(i=u(o(1),p),s=u())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,h=[];for(;p<t;){s=u();let E=s.slice();h.push(E),p+=s.length}return lt(...h)};return(p,h)=>{c(),d(p);let E;for(;!(E=h(l()));)d();return c(),E}}function te(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,s,i){let a=e[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(r).forEach(([o,s])=>n(o,s,!0))}var Qn=()=>{throw new Error("not implemented")};function De(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let s=e(r,...n);return t.set(r,s),s}}var ht=BigInt(0),rt=BigInt(1),le=BigInt(2),ci=BigInt(3),fi=BigInt(4),ui=BigInt(5),af=BigInt(7),li=BigInt(8),cf=BigInt(9),hi=BigInt(16);function Q(e,t){let r=e%t;return r>=ht?r:t+r}function j(e,t,r){let n=e;for(;t-- >ht;)n*=n,n%=r;return n}function ii(e,t){if(e===ht)throw new Error("invert: expected non-zero number");if(t<=ht)throw new Error("invert: expected positive modulus, got "+t);let r=Q(e,t),n=t,o=ht,s=rt,i=rt,a=ht;for(;r!==ht;){let u=n/r,d=n%r,l=o-i*u,f=s-a*u;n=r,r=d,o=i,s=a,i=l,a=f}if(n!==rt)throw new Error("invert: does not exist");return Q(o,t)}function Jn(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function di(e,t){let r=(e.ORDER+rt)/fi,n=e.pow(t,r);return Jn(e,n,t),n}function ff(e,t){let r=(e.ORDER-ui)/li,n=e.mul(t,le),o=e.pow(n,r),s=e.mul(t,o),i=e.mul(e.mul(s,le),o),a=e.mul(s,e.sub(i,e.ONE));return Jn(e,a,t),a}function uf(e){let t=wt(e),r=pi(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+af)/hi;return(a,c)=>{let u=a.pow(c,i),d=a.mul(u,n),l=a.mul(u,o),f=a.mul(u,s),p=a.eql(a.sqr(d),c),h=a.eql(a.sqr(l),c);u=a.cmov(u,d,p),d=a.cmov(f,l,h);let E=a.eql(a.sqr(d),c),v=a.cmov(u,d,E);return Jn(a,v,c),v}}function pi(e){if(e<ci)throw new Error("sqrt is not defined for small field");let t=e-rt,r=0;for(;t%le===ht;)t/=le,r++;let n=le,o=wt(e);for(;ai(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return di;let s=o.pow(n,t),i=(t+rt)/le;return function(c,u){if(c.is0(u))return u;if(ai(c,u)!==1)throw new Error("Cannot find square root");let d=r,l=c.mul(c.ONE,s),f=c.pow(u,t),p=c.pow(u,i);for(;!c.eql(f,c.ONE);){if(c.is0(f))return c.ZERO;let h=1,E=c.sqr(f);for(;!c.eql(E,c.ONE);)if(h++,E=c.sqr(E),h===d)throw new Error("Cannot find square root");let v=rt<<BigInt(d-h-1),g=c.pow(l,v);d=h,l=c.sqr(g),f=c.mul(f,l),p=c.mul(p,g)}return p}}function lf(e){return e%fi===ci?di:e%li===ui?ff:e%hi===cf?uf(e):pi(e)}var Vt=(e,t)=>(Q(e,t)&rt)===rt,hf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function to(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=hf.reduce((n,o)=>(n[o]="function",n),t);return te(e,r),e}function df(e,t,r){if(r<ht)throw new Error("invalid exponent, negatives unsupported");if(r===ht)return e.ONE;if(r===rt)return t;let n=e.ONE,o=t;for(;r>ht;)r&rt&&(n=e.mul(n,o)),o=e.sqr(o),r>>=rt;return n}function or(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((i,a,c)=>e.is0(a)?i:(n[c]=i,e.mul(i,a)),e.ONE),s=e.inv(o);return t.reduceRight((i,a,c)=>e.is0(a)?i:(n[c]=e.mul(i,n[c]),e.mul(i,a)),s),n}function ai(e,t){let r=(e.ORDER-rt)/le,n=e.pow(t,r),o=e.eql(n,e.ONE),s=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Pr(e,t){t!==void 0&&Xe(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function wt(e,t,r=!1,n={}){if(e<=ht)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,s,i=!1,a;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let f=t;f.BITS&&(o=f.BITS),f.sqrt&&(s=f.sqrt),typeof f.isLE=="boolean"&&(r=f.isLE),typeof f.modFromBytes=="boolean"&&(i=f.modFromBytes),a=f.allowedLengths}else typeof t=="number"&&(o=t),n.sqrt&&(s=n.sqrt);let{nBitLength:c,nByteLength:u}=Pr(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d,l=Object.freeze({ORDER:e,isLE:r,BITS:c,BYTES:u,MASK:Jt(c),ZERO:ht,ONE:rt,allowedLengths:a,create:f=>Q(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return ht<=f&&f<e},is0:f=>f===ht,isValidNot0:f=>!l.is0(f)&&l.isValid(f),isOdd:f=>(f&rt)===rt,neg:f=>Q(-f,e),eql:(f,p)=>f===p,sqr:f=>Q(f*f,e),add:(f,p)=>Q(f+p,e),sub:(f,p)=>Q(f-p,e),mul:(f,p)=>Q(f*p,e),pow:(f,p)=>df(l,f,p),div:(f,p)=>Q(f*ii(p,e),e),sqrN:f=>f*f,addN:(f,p)=>f+p,subN:(f,p)=>f-p,mulN:(f,p)=>f*p,inv:f=>ii(f,e),sqrt:s||(f=>(d||(d=lf(e)),d(l,f))),toBytes:f=>r?Yn(f,u):Tr(f,u),fromBytes:(f,p=!0)=>{if(a){if(!a.includes(f.length)||f.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+f.length);let E=new Uint8Array(u);E.set(f,r?0:E.length-f.length),f=E}if(f.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+f.length);let h=r?Mt(f):Te(f);if(i&&(h=Q(h,e)),!p&&!l.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:f=>or(l,f),cmov:(f,p,h)=>h?p:f});return Object.freeze(l)}function mi(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function eo(e){let t=mi(e);return t+Math.ceil(t/2)}function ro(e,t,r=!1){let n=e.length,o=mi(t),s=eo(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Mt(e):Te(e),a=Q(i,t-rt)+rt;return r?Yn(a,o):Tr(a,o)}var Pe=BigInt(0),he=BigInt(1);function sr(e,t){let r=t.negate();return e?r:t}function Ht(e,t){let r=or(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function xi(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function no(e,t){xi(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=Jt(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function yi(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,a=Number(e&o),c=e>>i;a>n&&(a-=s,c+=he);let u=t*n,d=u+Math.abs(a)-1,l=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:d,isZero:l,isNeg:f,isNegF:p,offsetF:u}}function pf(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function mf(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var oo=new WeakMap,wi=new WeakMap;function so(e){return wi.get(e)||1}function bi(e){if(e!==Pe)throw new Error("invalid wNAF")}var Le=class{constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Pe;)r&he&&(n=n.add(o)),o=o.double(),r>>=he;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=no(r,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,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=no(t,this.bits);for(let a=0;a<i.windows;a++){let{nextN:c,offset:u,isZero:d,isNeg:l,isNegF:f,offsetF:p}=yi(n,a,i);n=c,d?s=s.add(sr(f,r[p])):o=o.add(sr(l,r[u]))}return bi(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=no(t,this.bits);for(let i=0;i<s.windows&&n!==Pe;i++){let{nextN:a,offset:c,isZero:u,isNeg:d}=yi(n,i,s);if(n=a,!u){let l=r[c];o=o.add(d?l.negate():l)}}return bi(n),o}getPrecomputes(t,r,n){let o=oo.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),oo.set(r,o))),o}cached(t,r,n){let o=so(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=so(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){xi(r,this.bits),wi.set(t,r),oo.delete(t)}hasCache(t){return so(t)!==1}};function Ei(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>Pe||n>Pe;)r&he&&(s=s.add(o)),n&he&&(i=i.add(o)),o=o.double(),r>>=he,n>>=he;return{p1:s,p2:i}}function Ue(e,t,r,n){pf(r,e),mf(n,t);let o=r.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=e.ZERO,a=Dr(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let u=Jt(c),d=new Array(Number(u)+1).fill(i),l=Math.floor((t.BITS-1)/c)*c,f=i;for(let p=l;p>=0;p-=c){d.fill(i);for(let E=0;E<s;E++){let v=n[E],g=Number(v>>BigInt(p)&u);d[g]=d[g].add(r[E])}let h=i;for(let E=d.length-1,v=i;E>0;E--)v=v.add(d[E]),h=h.add(v);if(f=f.add(h),p!==0)for(let E=0;E<c;E++)f=f.double()}return f}function gi(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return to(t),t}else return wt(e,{isLE:r})}function Lr(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let u=t[c];if(!(typeof u=="bigint"&&u>Pe))throw new Error(`CURVE.${c} must be positive bigint`)}let o=gi(t.p,r.Fp,n),s=gi(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}var ee=BigInt(0),nt=BigInt(1),io=BigInt(2),yf=BigInt(8);function bf(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function gf(e,t={}){let r=Lr("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i}=s;te(t,{},{uvRatio:"function"});let a=io<<BigInt(o.BYTES*8)-nt,c=v=>n.create(v),u=t.uvRatio||((v,g)=>{try{return{isValid:!0,value:n.sqrt(n.div(v,g))}}catch{return{isValid:!1,value:ee}}});if(!bf(n,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function d(v,g,B=!1){let w=B?nt:ee;return nr("coordinate "+v,g,w,a),g}function l(v){if(!(v instanceof h))throw new Error("ExtendedPoint expected")}let f=De((v,g)=>{let{X:B,Y:w,Z:P}=v,R=v.is0();g==null&&(g=R?yf:n.inv(P));let V=c(B*g),M=c(w*g),N=n.mul(P,g);if(R)return{x:ee,y:nt};if(N!==nt)throw new Error("invZ was invalid");return{x:V,y:M}}),p=De(v=>{let{a:g,d:B}=s;if(v.is0())throw new Error("bad point: ZERO");let{X:w,Y:P,Z:R,T:V}=v,M=c(w*w),N=c(P*P),x=c(R*R),T=c(x*x),K=c(M*g),D=c(x*c(K+N)),b=c(T+c(B*c(M*N)));if(D!==b)throw new Error("bad point: equation left != right (1)");let m=c(w*P),y=c(R*V);if(m!==y)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(g,B,w,P){this.X=d("x",g),this.Y=d("y",B),this.Z=d("z",w,!0),this.T=d("t",P),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof h)throw new Error("extended point not allowed");let{x:B,y:w}=g||{};return d("x",B),d("y",w),new h(B,w,nt,c(B*w))}static fromBytes(g,B=!1){let w=n.BYTES,{a:P,d:R}=s;g=Xn(xt(g,w,"point")),kt(B,"zip215");let V=Xn(g),M=g[w-1];V[w-1]=M&-129;let N=Mt(V),x=B?a:n.ORDER;nr("point.y",N,ee,x);let T=c(N*N),K=c(T-nt),D=c(R*T-P),{isValid:b,value:m}=u(K,D);if(!b)throw new Error("bad point: invalid y coordinate");let y=(m&nt)===nt,S=(M&128)!==0;if(!B&&m===ee&&S)throw new Error("bad point: x=0 and x_0=1");return S!==y&&(m=c(-m)),h.fromAffine({x:m,y:N})}static fromHex(g,B=!1){return h.fromBytes(q("point",g),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,B=!0){return E.createCache(this,g),B||this.multiply(io),this}assertValidity(){p(this)}equals(g){l(g);let{X:B,Y:w,Z:P}=this,{X:R,Y:V,Z:M}=g,N=c(B*M),x=c(R*P),T=c(w*M),K=c(V*P);return N===x&&T===K}is0(){return this.equals(h.ZERO)}negate(){return new h(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:g}=s,{X:B,Y:w,Z:P}=this,R=c(B*B),V=c(w*w),M=c(io*c(P*P)),N=c(g*R),x=B+w,T=c(c(x*x)-R-V),K=N+V,D=K-M,b=N-V,m=c(T*D),y=c(K*b),S=c(T*b),I=c(D*K);return new h(m,y,I,S)}add(g){l(g);let{a:B,d:w}=s,{X:P,Y:R,Z:V,T:M}=this,{X:N,Y:x,Z:T,T:K}=g,D=c(P*N),b=c(R*x),m=c(M*w*K),y=c(V*T),S=c((P+R)*(N+x)-D-b),I=y-m,L=y+m,_=c(b-B*D),C=c(S*I),O=c(L*_),k=c(S*_),Z=c(I*L);return new h(C,O,Z,k)}subtract(g){return this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:w}=E.cached(this,g,P=>Ht(h,P));return Ht(h,[B,w])[0]}multiplyUnsafe(g,B=h.ZERO){if(!o.isValid(g))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return g===ee?h.ZERO:this.is0()||g===nt?this:E.unsafe(this,g,w=>Ht(h,w),B)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return E.unsafe(this,s.n).is0()}toAffine(g){return f(this,g)}clearCofactor(){return i===nt?this:this.multiplyUnsafe(i)}toBytes(){let{x:g,y:B}=this.toAffine(),w=n.toBytes(B);return w[w.length-1]|=g&nt?128:0,w}toHex(){return At(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(g){return Ht(h,g)}static msm(g,B){return Ue(h,o,g,B)}_setWindowSize(g){this.precompute(g)}toRawBytes(){return this.toBytes()}}h.BASE=new h(s.Gx,s.Gy,nt,c(s.Gx*s.Gy)),h.ZERO=new h(ee,nt,nt,ee),h.Fp=n,h.Fn=o;let E=new Le(h,o.BITS);return h.BASE.precompute(8),h}var Ur=class{constructor(t){this.ep=t}static fromBytes(t){Qn()}static fromHex(t){Qn()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return At(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.init(this.ep.precompute(t,r))}toRawBytes(){return this.toBytes()}};function xf(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');te(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:s,Fn:i}=e,a=r.randomBytes||Ce,c=r.adjustScalarBytes||(x=>x),u=r.domain||((x,T,K)=>{if(kt(K,"phflag"),T.length||K)throw new Error("Contexts/pre-hash are not supported");return x});function d(x){return i.create(Mt(x))}function l(x){let T=w.secretKey;x=q("private key",x,T);let K=q("hashed private key",t(x),2*T),D=c(K.slice(0,T)),b=K.slice(T,2*T),m=d(D);return{head:D,prefix:b,scalar:m}}function f(x){let{head:T,prefix:K,scalar:D}=l(x),b=o.multiply(D),m=b.toBytes();return{head:T,prefix:K,scalar:D,point:b,pointBytes:m}}function p(x){return f(x).pointBytes}function h(x=Uint8Array.of(),...T){let K=lt(...T);return d(t(u(K,q("context",x),!!n)))}function E(x,T,K={}){x=q("message",x),n&&(x=n(x));let{prefix:D,scalar:b,pointBytes:m}=f(T),y=h(K.context,D,x),S=o.multiply(y).toBytes(),I=h(K.context,S,m,x),L=i.create(y+I*b);if(!i.isValid(L))throw new Error("sign failed: invalid s");let _=lt(S,i.toBytes(L));return xt(_,w.signature,"result")}let v={zip215:!0};function g(x,T,K,D=v){let{context:b,zip215:m}=D,y=w.signature;x=q("signature",x,y),T=q("message",T),K=q("publicKey",K,w.publicKey),m!==void 0&&kt(m,"zip215"),n&&(T=n(T));let S=y/2,I=x.subarray(0,S),L=Mt(x.subarray(S,y)),_,C,O;try{_=e.fromBytes(K,m),C=e.fromBytes(I,m),O=o.multiplyUnsafe(L)}catch{return!1}if(!m&&_.isSmallOrder())return!1;let k=h(b,C.toBytes(),_.toBytes(),T);return C.add(_.multiplyUnsafe(k)).subtract(O).clearCofactor().is0()}let B=s.BYTES,w={secretKey:B,publicKey:B,signature:2*B,seed:B};function P(x=a(w.seed)){return xt(x,w.seed,"seed")}function R(x){let T=N.randomSecretKey(x);return{secretKey:T,publicKey:p(T)}}function V(x){return Rt(x)&&x.length===i.BYTES}function M(x,T){try{return!!e.fromBytes(x,T)}catch{return!1}}let N={getExtendedPublicKey:f,randomSecretKey:P,isValidSecretKey:V,isValidPublicKey:M,toMontgomery(x){let{y:T}=e.fromBytes(x),K=w.publicKey,D=K===32;if(!D&&K!==57)throw new Error("only defined for 25519 and 448");let b=D?s.div(nt+T,nt-T):s.div(T-nt,T+nt);return s.toBytes(b)},toMontgomeryPriv(x){let T=w.secretKey;xt(x,T);let K=t(x.subarray(0,T));return c(K).subarray(0,T)},randomPrivateKey:P,precompute(x=8,T=e.BASE){return T.precompute(x,!1)}};return Object.freeze({keygen:R,getPublicKey:p,sign:E,verify:g,utils:N,Point:e,lengths:w})}function wf(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=wt(t.n,e.nBitLength,!0),o={Fp:r,Fn:n,uvRatio:e.uvRatio},s={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:s}}function Ef(e,t){let r=t.Point;return Object.assign({},t,{ExtendedPoint:r,CURVE:e,nBitLength:r.Fn.BITS,nByteLength:r.Fn.BYTES})}function Si(e){let{CURVE:t,curveOpts:r,hash:n,eddsaOpts:o}=wf(e),s=gf(t,r),i=xf(s,n,o);return Ef(e,i)}var Sf=BigInt(0),qt=BigInt(1),vi=BigInt(2),Wd=BigInt(3),vf=BigInt(5),Af=BigInt(8),Oe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ir={p:Oe,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Af,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Bf(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Oe,a=e*e%s*e%s,c=j(a,vi,s)*a%s,u=j(c,qt,s)*e%s,d=j(u,vf,s)*u%s,l=j(d,t,s)*d%s,f=j(l,r,s)*l%s,p=j(f,n,s)*f%s,h=j(p,o,s)*p%s,E=j(h,o,s)*p%s,v=j(E,t,s)*d%s;return{pow_p_5_8:j(v,vi,s)*e%s,b2:a}}function If(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var ao=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function uo(e,t){let r=Oe,n=Q(t*t*t,r),o=Q(n*n*t,r),s=Bf(e*o).pow_p_5_8,i=Q(e*n*s,r),a=Q(t*i*i,r),c=i,u=Q(i*ao,r),d=a===e,l=a===Q(-e,r),f=a===Q(-e*ao,r);return d&&(i=c),(l||f)&&(i=u),Vt(i,r)&&(i=Q(-i,r)),{isValid:d||l,value:i}}var re=wt(ir.p,{isLE:!0}),_f=wt(ir.n,{isLE:!0}),Cf={...ir,Fp:re,hash:ei,adjustScalarBytes:If,uvRatio:uo},zt=Si(Cf);var co=ao,Tf=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Df=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Pf=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Lf=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ai=e=>uo(qt,e),Uf=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),fo=e=>zt.Point.Fp.create(Mt(e)&Uf);function Bi(e){let{d:t}=ir,r=Oe,n=g=>re.create(g),o=n(co*e*e),s=n((o+qt)*Pf),i=BigInt(-1),a=n((i-t*o)*n(o+t)),{isValid:c,value:u}=uo(s,a),d=n(u*e);Vt(d,r)||(d=n(-d)),c||(u=d),c||(i=o);let l=n(i*(o-qt)*Lf-a),f=u*u,p=n((u+u)*a),h=n(l*Tf),E=n(qt-f),v=n(qt+f);return new zt.Point(n(p*v),n(E*h),n(h*v),n(p*E))}function Of(e){pt(e,64);let t=fo(e.subarray(0,32)),r=Bi(t),n=fo(e.subarray(32,64)),o=Bi(n);return new Ft(r.add(o))}var Ft=class e extends Ur{constructor(t){super(t)}static fromAffine(t){return new e(zt.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static hashToCurve(t){return Of(q("ristrettoHash",t,64))}static fromBytes(t){pt(t,32);let{a:r,d:n}=ir,o=Oe,s=P=>re.create(P),i=fo(t);if(!ni(re.toBytes(i),t)||Vt(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),c=s(qt+r*a),u=s(qt-r*a),d=s(c*c),l=s(u*u),f=s(r*n*d-l),{isValid:p,value:h}=Ai(s(f*l)),E=s(h*u),v=s(h*E*f),g=s((i+i)*E);Vt(g,o)&&(g=s(-g));let B=s(c*v),w=s(g*B);if(!p||Vt(w,o)||B===Sf)throw new Error("invalid ristretto255 encoding 2");return new e(new zt.Point(g,B,qt,w))}static fromHex(t){return e.fromBytes(q("ristrettoHex",t,32))}static msm(t,r){return Ue(e,zt.Point.Fn,t,r)}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=Oe,i=v=>re.create(v),a=i(i(n+r)*i(n-r)),c=i(t*r),u=i(c*c),{value:d}=Ai(i(a*u)),l=i(d*a),f=i(d*c),p=i(l*f*o),h;if(Vt(o*p,s)){let v=i(r*co),g=i(t*co);t=v,r=g,h=i(l*Df)}else h=f;Vt(t*p,s)&&(r=i(-r));let E=i((n-r)*h);return Vt(E,s)&&(E=i(-E)),re.toBytes(E)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=u=>re.create(u),a=i(r*s)===i(n*o),c=i(n*s)===i(r*o);return a||c}is0(){return this.equals(e.ZERO)}};Ft.BASE=new Ft(zt.Point.BASE);Ft.ZERO=new Ft(zt.Point.ZERO);Ft.Fp=re;Ft.Fn=_f;var ar=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Or=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Ii={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Or("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 Rr=Ii;var Nr=32;var lo,Rf=(async()=>{try{return await Rr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Nf(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Rr.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Rr.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Kf(e,t,r){return zt.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function _i(e,t,r){return lo==null&&(lo=await Rf),lo?Nf(e,t,r):Kf(e,t,r)}function Kr(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var kr=class{type="Ed25519";raw;constructor(t){this.raw=ho(t,Nr)}toMultihash(){return Bt.digest(Be(this))}toCID(){return et.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=_i(this.raw,r,t);return Kr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Ti(e){return e=ho(e,Nr),new kr(e)}function ho(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new Ct(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Mf=Math.pow(2,7),Vf=Math.pow(2,14),Hf=Math.pow(2,21),po=Math.pow(2,28),mo=Math.pow(2,35),yo=Math.pow(2,42),bo=Math.pow(2,49),G=128,ft=127;function Dt(e){if(e<Mf)return 1;if(e<Vf)return 2;if(e<Hf)return 3;if(e<po)return 4;if(e<mo)return 5;if(e<yo)return 6;if(e<bo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cr(e,t,r=0){switch(Dt(e)){case 8:t[r++]=e&255|G,e/=128;case 7:t[r++]=e&255|G,e/=128;case 6:t[r++]=e&255|G,e/=128;case 5:t[r++]=e&255|G,e/=128;case 4:t[r++]=e&255|G,e>>>=7;case 3:t[r++]=e&255|G,e>>>=7;case 2:t[r++]=e&255|G,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function go(e,t){let r=e[t],n=0;if(n+=r&ft,r<G||(r=e[t+1],n+=(r&ft)<<7,r<G)||(r=e[t+2],n+=(r&ft)<<14,r<G)||(r=e[t+3],n+=(r&ft)<<21,r<G)||(r=e[t+4],n+=(r&ft)*po,r<G)||(r=e[t+5],n+=(r&ft)*mo,r<G)||(r=e[t+6],n+=(r&ft)*yo,r<G)||(r=e[t+7],n+=(r&ft)*bo,r<G))return n;throw new RangeError("Could not decode varint")}function qf(e,t){let r=e.get(t),n=0;if(n+=r&ft,r<G||(r=e.get(t+1),n+=(r&ft)<<7,r<G)||(r=e.get(t+2),n+=(r&ft)<<14,r<G)||(r=e.get(t+3),n+=(r&ft)<<21,r<G)||(r=e.get(t+4),n+=(r&ft)*po,r<G)||(r=e.get(t+5),n+=(r&ft)*mo,r<G)||(r=e.get(t+6),n+=(r&ft)*yo,r<G)||(r=e.get(t+7),n+=(r&ft)*bo,r<G))return n;throw new RangeError("Could not decode varint")}function xo(e,t=0){return e instanceof Uint8Array?go(e,t):qf(e,t)}var wo=new Float32Array([-0]),ne=new Uint8Array(wo.buffer);function Di(e,t,r){wo[0]=e,t[r]=ne[0],t[r+1]=ne[1],t[r+2]=ne[2],t[r+3]=ne[3]}function Pi(e,t){return ne[0]=e[t],ne[1]=e[t+1],ne[2]=e[t+2],ne[3]=e[t+3],wo[0]}var Eo=new Float64Array([-0]),ut=new Uint8Array(Eo.buffer);function Li(e,t,r){Eo[0]=e,t[r]=ut[0],t[r+1]=ut[1],t[r+2]=ut[2],t[r+3]=ut[3],t[r+4]=ut[4],t[r+5]=ut[5],t[r+6]=ut[6],t[r+7]=ut[7]}function Ui(e,t){return ut[0]=e[t],ut[1]=e[t+1],ut[2]=e[t+2],ut[3]=e[t+3],ut[4]=e[t+4],ut[5]=e[t+5],ut[6]=e[t+6],ut[7]=e[t+7],Eo[0]}var Ff=BigInt(Number.MAX_SAFE_INTEGER),jf=BigInt(Number.MIN_SAFE_INTEGER),Et=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return de;if(t<Ff&&t>jf)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Oi&&(o=0n,++n>Oi&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return de;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):de}},de=new Et(0,0);de.toBigInt=function(){return 0n};de.zzEncode=de.zzDecode=function(){return this};de.length=function(){return 1};var Oi=4294967296n;function Ri(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ni(e,t,r){if(r-t<1)return"";let o,s=[],i=0,a;for(;t<r;)a=e[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function So(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function _t(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Mr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var vo=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,_t(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 _t(this,4);return Mr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _t(this,4);return Mr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw _t(this,4);let t=Pi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw _t(this,4);let t=Ui(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw _t(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ni(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw _t(this,t);this.pos+=t}else do if(this.pos>=this.len)throw _t(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 Et(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw _t(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw _t(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw _t(this,8);let t=Mr(this.buf,this.pos+=4),r=Mr(this.buf,this.pos+=4);return new Et(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=go(this.buf,this.pos);return this.pos+=Dt(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 Ao(e){return new vo(e instanceof Uint8Array?e:e.subarray())}function Vr(e,t,r){let n=Ao(e);return t.decode(n,void 0,r)}function Bo(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return bt(i);o+i>t&&(n=bt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var pe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Io(){}var Co=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Gf=Bo();function Zf(e){return globalThis.Buffer!=null?bt(e):Gf(e)}var ur=class{len;head;tail;states;constructor(){this.len=0,this.head=new pe(Io,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new pe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new To((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(Hr,10,Et.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Et.fromBigInt(t);return this._push(Hr,r.length(),r)}uint64Number(t){return this._push(cr,Dt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=Et.fromBigInt(t).zzEncode();return this._push(Hr,r.length(),r)}sint64Number(t){let r=Et.fromNumber(t).zzEncode();return this._push(Hr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(_o,1,t?1:0)}fixed32(t){return this._push(fr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Et.fromBigInt(t);return this._push(fr,4,r.lo)._push(fr,4,r.hi)}fixed64Number(t){let r=Et.fromNumber(t);return this._push(fr,4,r.lo)._push(fr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Di,4,t)}double(t){return this._push(Li,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(_o,1,0):this.uint32(r)._push(Wf,r,t)}string(t){let r=Ri(t);return r!==0?this.uint32(r)._push(So,r,t):this._push(_o,1,0)}fork(){return this.states=new Co(this),this.head=this.tail=new pe(Io,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new pe(Io,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Zf(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function _o(e,t,r){t[r]=e&255}function $f(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var To=class extends pe{next;constructor(t,r){super($f,t,r),this.next=void 0}};function Hr(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function fr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Wf(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(ur.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Yf,t,e),this},ur.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Xf,t,e),this});function Yf(e,t,r){t.set(e,r)}function Xf(e,t,r){e.length<40?So(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(ct(e),r)}function Do(){return new ur}function qr(e,t){let r=Do();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Re;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(Re||(Re={}));function zr(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Po(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return zr("enum",Re.VARINT,r,n)}function Fr(e,t){return zr("message",Re.LENGTH_DELIMITED,e,t)}var St;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(St||(St={}));var Lo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Lo||(Lo={}));(function(e){e.codec=()=>Po(Lo)})(St||(St={}));var lr;(function(e){let t;e.codec=()=>(t==null&&(t=Fr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),St.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let a=r.uint32();switch(a>>>3){case 1:{s.Type=St.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return s})),t),e.encode=r=>qr(r,e.codec()),e.decode=(r,n)=>Vr(r,e.codec(),n)})(lr||(lr={}));var Uo;(function(e){let t;e.codec=()=>(t==null&&(t=Fr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),St.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let a=r.uint32();switch(a>>>3){case 1:{s.Type=St.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return s})),t),e.encode=r=>qr(r,e.codec()),e.decode=(r,n)=>Vr(r,e.codec(),n)})(Uo||(Uo={}));var jr=class extends Ie{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Ir(t);let n=Qe(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Nt(s)}update(t){return _e(this),this.iHash.update(t),this}digestInto(t){_e(this),pt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Oo=(e,t,r)=>new jr(e,t).update(r).digest();Oo.create=(e,t)=>new jr(e,t);var ki=(e,t)=>(e+(e>=0?t:-t)/Mi)/t;function Jf(e,t,r){let[[n,o],[s,i]]=t,a=ki(i*e,r),c=ki(-o*e,r),u=e-a*n-c*s,d=-a*o-c*i,l=u<Gt,f=d<Gt;l&&(u=-u),f&&(d=-d);let p=Jt(Math.ceil(Dr(r)/2))+Ke;if(u<Gt||u>=p||d<Gt||d>=p)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:d}}function No(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Ro(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return kt(r.lowS,"lowS"),kt(r.prehash,"prehash"),r.format!==void 0&&No(r.format),r}var Ko=class extends Error{constructor(t=""){super(t)}},jt={Err:Ko,_tlv:{encode:(e,t)=>{let{Err:r}=jt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=rr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?rr(o.length/2|128):"";return rr(e)+s+o+t},decode(e,t){let{Err:r}=jt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)i=i<<8|d;if(n+=c,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=jt;if(e<Gt)throw new t("integer: negative integers are not allowed");let r=rr(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=jt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Te(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=jt,o=q("signature",e),{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:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=jt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}},Gt=BigInt(0),Ke=BigInt(1),Mi=BigInt(2),Gr=BigInt(3),tu=BigInt(4);function Ne(e,t){let{BYTES:r}=e,n;if(typeof t=="bigint")n=t;else{let o=q("private key",t);try{n=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof t}`)}}if(!e.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function eu(e,t={}){let r=Lr("weierstrass",e,t),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i,n:a}=s;te(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:c}=t;if(c&&(!n.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=Hi(n,o);function d(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(D,b,m){let{x:y,y:S}=b.toAffine(),I=n.toBytes(y);if(kt(m,"isCompressed"),m){d();let L=!n.isOdd(S);return lt(Vi(L),I)}else return lt(Uint8Array.of(4),I,n.toBytes(S))}function f(D){xt(D,void 0,"Point");let{publicKey:b,publicKeyUncompressed:m}=u,y=D.length,S=D[0],I=D.subarray(1);if(y===b&&(S===2||S===3)){let L=n.fromBytes(I);if(!n.isValid(L))throw new Error("bad point: is not on curve, wrong x");let _=E(L),C;try{C=n.sqrt(_)}catch(Z){let z=Z instanceof Error?": "+Z.message:"";throw new Error("bad point: is not on curve, sqrt error"+z)}d();let O=n.isOdd(C);return(S&1)===1!==O&&(C=n.neg(C)),{x:L,y:C}}else if(y===m&&S===4){let L=n.BYTES,_=n.fromBytes(I.subarray(0,L)),C=n.fromBytes(I.subarray(L,L*2));if(!v(_,C))throw new Error("bad point: is not on curve");return{x:_,y:C}}else throw new Error(`bad point: got length ${y}, expected compressed=${b} or uncompressed=${m}`)}let p=t.toBytes||l,h=t.fromBytes||f;function E(D){let b=n.sqr(D),m=n.mul(b,D);return n.add(n.add(m,n.mul(D,s.a)),s.b)}function v(D,b){let m=n.sqr(b),y=E(D);return n.eql(m,y)}if(!v(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let g=n.mul(n.pow(s.a,Gr),tu),B=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(g,B)))throw new Error("bad curve params: a or b");function w(D,b,m=!1){if(!n.isValid(b)||m&&n.is0(b))throw new Error(`bad point coordinate ${D}`);return b}function P(D){if(!(D instanceof x))throw new Error("ProjectivePoint expected")}function R(D){if(!c||!c.basises)throw new Error("no endo");return Jf(D,c.basises,o.ORDER)}let V=De((D,b)=>{let{X:m,Y:y,Z:S}=D;if(n.eql(S,n.ONE))return{x:m,y};let I=D.is0();b==null&&(b=I?n.ONE:n.inv(S));let L=n.mul(m,b),_=n.mul(y,b),C=n.mul(S,b);if(I)return{x:n.ZERO,y:n.ZERO};if(!n.eql(C,n.ONE))throw new Error("invZ was invalid");return{x:L,y:_}}),M=De(D=>{if(D.is0()){if(t.allowInfinityPoint&&!n.is0(D.Y))return;throw new Error("bad point: ZERO")}let{x:b,y:m}=D.toAffine();if(!n.isValid(b)||!n.isValid(m))throw new Error("bad point: x or y not field elements");if(!v(b,m))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function N(D,b,m,y,S){return m=new x(n.mul(m.X,D),m.Y,m.Z),b=sr(y,b),m=sr(S,m),b.add(m)}class x{constructor(b,m,y){this.X=w("x",b),this.Y=w("y",m,!0),this.Z=w("z",y),Object.freeze(this)}static CURVE(){return s}static fromAffine(b){let{x:m,y}=b||{};if(!b||!n.isValid(m)||!n.isValid(y))throw new Error("invalid affine point");if(b instanceof x)throw new Error("projective point not allowed");return n.is0(m)&&n.is0(y)?x.ZERO:new x(m,y,n.ONE)}static fromBytes(b){let m=x.fromAffine(h(xt(b,void 0,"point")));return m.assertValidity(),m}static fromHex(b){return x.fromBytes(q("pointHex",b))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(b=8,m=!0){return K.createCache(this,b),m||this.multiply(Gr),this}assertValidity(){M(this)}hasEvenY(){let{y:b}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(b)}equals(b){P(b);let{X:m,Y:y,Z:S}=this,{X:I,Y:L,Z:_}=b,C=n.eql(n.mul(m,_),n.mul(I,S)),O=n.eql(n.mul(y,_),n.mul(L,S));return C&&O}negate(){return new x(this.X,n.neg(this.Y),this.Z)}double(){let{a:b,b:m}=s,y=n.mul(m,Gr),{X:S,Y:I,Z:L}=this,_=n.ZERO,C=n.ZERO,O=n.ZERO,k=n.mul(S,S),Z=n.mul(I,I),z=n.mul(L,L),H=n.mul(S,I);return H=n.add(H,H),O=n.mul(S,L),O=n.add(O,O),_=n.mul(b,O),C=n.mul(y,z),C=n.add(_,C),_=n.sub(Z,C),C=n.add(Z,C),C=n.mul(_,C),_=n.mul(H,_),O=n.mul(y,O),z=n.mul(b,z),H=n.sub(k,z),H=n.mul(b,H),H=n.add(H,O),O=n.add(k,k),k=n.add(O,k),k=n.add(k,z),k=n.mul(k,H),C=n.add(C,k),z=n.mul(I,L),z=n.add(z,z),k=n.mul(z,H),_=n.sub(_,k),O=n.mul(z,Z),O=n.add(O,O),O=n.add(O,O),new x(_,C,O)}add(b){P(b);let{X:m,Y:y,Z:S}=this,{X:I,Y:L,Z:_}=b,C=n.ZERO,O=n.ZERO,k=n.ZERO,Z=s.a,z=n.mul(s.b,Gr),H=n.mul(m,I),$=n.mul(y,L),tt=n.mul(S,_),dt=n.add(m,y),W=n.add(I,L);dt=n.mul(dt,W),W=n.add(H,$),dt=n.sub(dt,W),W=n.add(m,S);let at=n.add(I,_);return W=n.mul(W,at),at=n.add(H,tt),W=n.sub(W,at),at=n.add(y,S),C=n.add(L,_),at=n.mul(at,C),C=n.add($,tt),at=n.sub(at,C),k=n.mul(Z,W),C=n.mul(z,tt),k=n.add(C,k),C=n.sub($,k),k=n.add($,k),O=n.mul(C,k),$=n.add(H,H),$=n.add($,H),tt=n.mul(Z,tt),W=n.mul(z,W),$=n.add($,tt),tt=n.sub(H,tt),tt=n.mul(Z,tt),W=n.add(W,tt),H=n.mul($,W),O=n.add(O,H),H=n.mul(at,W),C=n.mul(dt,C),C=n.sub(C,H),H=n.mul(dt,$),k=n.mul(at,k),k=n.add(k,H),new x(C,O,k)}subtract(b){return this.add(b.negate())}is0(){return this.equals(x.ZERO)}multiply(b){let{endo:m}=t;if(!o.isValidNot0(b))throw new Error("invalid scalar: out of range");let y,S,I=L=>K.cached(this,L,_=>Ht(x,_));if(m){let{k1neg:L,k1:_,k2neg:C,k2:O}=R(b),{p:k,f:Z}=I(_),{p:z,f:H}=I(O);S=Z.add(H),y=N(m.beta,k,z,L,C)}else{let{p:L,f:_}=I(b);y=L,S=_}return Ht(x,[y,S])[0]}multiplyUnsafe(b){let{endo:m}=t,y=this;if(!o.isValid(b))throw new Error("invalid scalar: out of range");if(b===Gt||y.is0())return x.ZERO;if(b===Ke)return y;if(K.hasCache(this))return this.multiply(b);if(m){let{k1neg:S,k1:I,k2neg:L,k2:_}=R(b),{p1:C,p2:O}=Ei(x,y,I,_);return N(m.beta,C,O,S,L)}else return K.unsafe(y,b)}multiplyAndAddUnsafe(b,m,y){let S=this.multiplyUnsafe(m).add(b.multiplyUnsafe(y));return S.is0()?void 0:S}toAffine(b){return V(this,b)}isTorsionFree(){let{isTorsionFree:b}=t;return i===Ke?!0:b?b(x,this):K.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:b}=t;return i===Ke?this:b?b(x,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(b=!0){return kt(b,"isCompressed"),this.assertValidity(),p(x,this,b)}toHex(b=!0){return At(this.toBytes(b))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(b=!0){return this.toBytes(b)}_setWindowSize(b){this.precompute(b)}static normalizeZ(b){return Ht(x,b)}static msm(b,m){return Ue(x,o,b,m)}static fromPrivateKey(b){return x.BASE.multiply(Ne(o,b))}}x.BASE=new x(s.Gx,s.Gy,n.ONE),x.ZERO=new x(n.ZERO,n.ONE,n.ZERO),x.Fp=n,x.Fn=o;let T=o.BITS,K=new Le(x,t.endo?Math.ceil(T/2):T);return x.BASE.precompute(8),x}function Vi(e){return Uint8Array.of(e?2:3)}function Hi(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ru(e,t={}){let{Fn:r}=e,n=t.randomBytes||Ce,o=Object.assign(Hi(e.Fp,r),{seed:eo(r.ORDER)});function s(p){try{return!!Ne(r,p)}catch{return!1}}function i(p,h){let{publicKey:E,publicKeyUncompressed:v}=o;try{let g=p.length;return h===!0&&g!==E||h===!1&&g!==v?!1:!!e.fromBytes(p)}catch{return!1}}function a(p=n(o.seed)){return ro(xt(p,o.seed,"seed"),r.ORDER)}function c(p,h=!0){return e.BASE.multiply(Ne(r,p)).toBytes(h)}function u(p){let h=a(p);return{secretKey:h,publicKey:c(h)}}function d(p){if(typeof p=="bigint")return!1;if(p instanceof e)return!0;let{secretKey:h,publicKey:E,publicKeyUncompressed:v}=o;if(r.allowedLengths||h===E)return;let g=q("key",p).length;return g===E||g===v}function l(p,h,E=!0){if(d(p)===!0)throw new Error("first arg must be private key");if(d(h)===!1)throw new Error("second arg must be public key");let v=Ne(r,p);return e.fromHex(h).multiply(v).toBytes(E)}return Object.freeze({getPublicKey:c,getSharedSecret:l,keygen:u,Point:e,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:s,randomPrivateKey:a,normPrivateKeyToScalar:p=>Ne(r,p),precompute(p=8,h=e.BASE){return h.precompute(p,!1)}},lengths:o})}function nu(e,t,r={}){Ir(t),te(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||Ce,o=r.hmac||((m,...y)=>Oo(t,m,lt(...y))),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:u,getPublicKey:d,getSharedSecret:l,utils:f,lengths:p}=ru(e,r),h={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},E="compact";function v(m){let y=a>>Ke;return m>y}function g(m,y){if(!i.isValidNot0(y))throw new Error(`invalid signature ${m}: out of range 1..Point.Fn.ORDER`);return y}function B(m,y){No(y);let S=p.signature,I=y==="compact"?S:y==="recovered"?S+1:void 0;return xt(m,I,`${y} signature`)}class w{constructor(y,S,I){this.r=g("r",y),this.s=g("s",S),I!=null&&(this.recovery=I),Object.freeze(this)}static fromBytes(y,S=E){B(y,S);let I;if(S==="der"){let{r:O,s:k}=jt.toSig(xt(y));return new w(O,k)}S==="recovered"&&(I=y[0],S="compact",y=y.subarray(1));let L=i.BYTES,_=y.subarray(0,L),C=y.subarray(L,L*2);return new w(i.fromBytes(_),i.fromBytes(C),I)}static fromHex(y,S){return this.fromBytes(ce(y),S)}addRecoveryBit(y){return new w(this.r,this.s,y)}recoverPublicKey(y){let S=s.ORDER,{r:I,s:L,recovery:_}=this;if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");if(a*Mi<S&&_>1)throw new Error("recovery id is ambiguous for h>1 curve");let O=_===2||_===3?I+a:I;if(!s.isValid(O))throw new Error("recovery id 2 or 3 invalid");let k=s.toBytes(O),Z=e.fromBytes(lt(Vi((_&1)===0),k)),z=i.inv(O),H=R(q("msgHash",y)),$=i.create(-H*z),tt=i.create(L*z),dt=e.BASE.multiplyUnsafe($).add(Z.multiplyUnsafe(tt));if(dt.is0())throw new Error("point at infinify");return dt.assertValidity(),dt}hasHighS(){return v(this.s)}toBytes(y=E){if(No(y),y==="der")return ce(jt.hexFromSig(this));let S=i.toBytes(this.r),I=i.toBytes(this.s);if(y==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return lt(Uint8Array.of(this.recovery),S,I)}return lt(S,I)}toHex(y){return At(this.toBytes(y))}assertValidity(){}static fromCompact(y){return w.fromBytes(q("sig",y),"compact")}static fromDER(y){return w.fromBytes(q("sig",y),"der")}normalizeS(){return this.hasHighS()?new w(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return At(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return At(this.toBytes("compact"))}}let P=r.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");let S=Te(y),I=y.length*8-c;return I>0?S>>BigInt(I):S},R=r.bits2int_modN||function(y){return i.create(P(y))},V=Jt(c);function M(m){return nr("num < 2^"+c,m,Gt,V),i.toBytes(m)}function N(m,y){return xt(m,void 0,"message"),y?xt(t(m),void 0,"prehashed message"):m}function x(m,y,S){if(["recovered","canonical"].some($=>$ in S))throw new Error("sign() legacy options not supported");let{lowS:I,prehash:L,extraEntropy:_}=Ro(S,h);m=N(m,L);let C=R(m),O=Ne(i,y),k=[M(O),M(C)];if(_!=null&&_!==!1){let $=_===!0?n(p.secretKey):_;k.push(q("extraEntropy",$))}let Z=lt(...k),z=C;function H($){let tt=P($);if(!i.isValidNot0(tt))return;let dt=i.inv(tt),W=e.BASE.multiply(tt).toAffine(),at=i.create(W.x);if(at===Gt)return;let br=i.create(dt*i.create(z+at*O));if(br===Gt)return;let as=(W.x===at?0:2)|Number(W.y&Ke),cs=br;return I&&v(br)&&(cs=i.neg(br),as^=1),new w(at,cs,as)}return{seed:Z,k2sig:H}}function T(m,y,S={}){m=q("message",m);let{seed:I,k2sig:L}=x(m,y,S);return si(t.outputLen,i.BYTES,o)(I,L)}function K(m){let y,S=typeof m=="string"||Rt(m),I=!S&&m!==null&&typeof m=="object"&&typeof m.r=="bigint"&&typeof m.s=="bigint";if(!S&&!I)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(I)y=new w(m.r,m.s);else if(S){try{y=w.fromBytes(q("sig",m),"der")}catch(L){if(!(L instanceof jt.Err))throw L}if(!y)try{y=w.fromBytes(q("sig",m),"compact")}catch{return!1}}return y||!1}function D(m,y,S,I={}){let{lowS:L,prehash:_,format:C}=Ro(I,h);if(S=q("publicKey",S),y=N(q("message",y),_),"strict"in I)throw new Error("options.strict was renamed to lowS");let O=C===void 0?K(m):w.fromBytes(q("sig",m),C);if(O===!1)return!1;try{let k=e.fromBytes(S);if(L&&O.hasHighS())return!1;let{r:Z,s:z}=O,H=R(y),$=i.inv(z),tt=i.create(H*$),dt=i.create(Z*$),W=e.BASE.multiplyUnsafe(tt).add(k.multiplyUnsafe(dt));return W.is0()?!1:i.create(W.x)===Z}catch{return!1}}function b(m,y,S={}){let{prehash:I}=Ro(S,h);return y=N(y,I),w.fromBytes(m,"recovered").recoverPublicKey(y).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:l,utils:f,lengths:p,Point:e,sign:T,verify:D,recoverPublicKey:b,Signature:w,hash:t})}function ou(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0,o=wt(t.n,{BITS:e.nBitLength,allowedLengths:n,modFromBytes:e.wrapPrivateKey}),s={Fp:r,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:s}}function su(e){let{CURVE:t,curveOpts:r}=ou(e),n={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,hash:e.hash,ecdsaOpts:n}}function iu(e,t){let r=t.Point;return Object.assign({},t,{ProjectivePoint:r,CURVE:Object.assign({},e,Pr(r.Fn.ORDER,r.Fn.BITS))})}function qi(e){let{CURVE:t,curveOpts:r,hash:n,ecdsaOpts:o}=su(e),s=eu(t,r),i=nu(s,n,o);return iu(e,i)}function zi(e,t){let r=n=>qi({...e,hash:n});return{...r(t),create:r}}var Mo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},au={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Fi=BigInt(2);function cu(e){let t=Mo.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,d=u*u*e%t,l=j(d,r,t)*d%t,f=j(l,r,t)*d%t,p=j(f,Fi,t)*u%t,h=j(p,o,t)*p%t,E=j(h,s,t)*h%t,v=j(E,a,t)*E%t,g=j(v,c,t)*v%t,B=j(g,a,t)*E%t,w=j(B,r,t)*d%t,P=j(w,i,t)*h%t,R=j(P,n,t)*u%t,V=j(R,Fi,t);if(!ko.eql(ko.sqr(V),e))throw new Error("Cannot find square root");return V}var ko=wt(Mo.p,{sqrt:cu}),ke=zi({...Mo,Fp:ko,lowS:!0,endo:au},ti);function ji(e,t,r,n){let o=Ze.digest(r instanceof Uint8Array?r:r.subarray());if(Kr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),ke.verify(t,s,e))).catch(s=>{throw s.name==="AbortError"?s:new ar(String(s))});try{return n?.signal?.throwIfAborted(),ke.verify(t,o.digest,e)}catch(s){throw new ar(String(s))}}var Zr=class{type="secp256k1";raw;_key;constructor(t){this._key=Zi(t),this.raw=Gi(this._key)}toMultihash(){return Bt.digest(Be(this))}toCID(){return et.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,r,n){return ji(this._key,r,t,n)}};function $i(e){return new Zr(e)}function Gi(e){return ke.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Zi(e){try{return ke.ProjectivePoint.fromHex(e),e}catch(t){throw new gr(String(t))}}function Wi(e){let{Type:t,Data:r}=lr.decode(e.digest),n=r??new Uint8Array;switch(t){case St.Ed25519:return Ti(n);case St.secp256k1:return $i(n);case St.ECDSA:return Ks(n);default:throw new He}}function Be(e){return lr.encode({Type:St[e.type],Data:e.raw})}var Yi=Symbol.for("nodejs.util.inspect.custom"),fu=114,hr=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()})`}[hn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return et.createV1(fu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return yt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Yi](){return`PeerId(${this.toString()})`}},$r=class extends hr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Wr=class extends hr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Yr=class extends hr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},uu=2336,dr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Bt.digest(ct(this.url))}[Yi](){return`PeerId(${this.url})`}[hn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return et.createV1(uu,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=F(t)),t.toString()===this.toString())}};var lu=114,Xi=2336;function Qi(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=je(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return hu(et.parse(e));if(t==null)throw new Ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=je(t.decode(e))}return Ji(r)}function Ji(e){if(pu(e))return new $r({multihash:e});if(du(e))try{let t=Wi(e);if(t.type==="Ed25519")return new Wr({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Yr({multihash:e,publicKey:t})}catch{let r=F(e.digest);return new dr(new URL(r))}throw new wr("Supplied PeerID Multihash is invalid")}function hu(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==lu&&e.code!==Xi)throw new xr("Supplied PeerID CID is invalid");if(e.code===Xi){let t=F(e.multihash.digest);return new dr(new URL(t))}return Ji(e.multihash)}function du(e){return e.code===Bt.code}function pu(e){return e.code===Ze.code}var it=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},Zt=class extends Error{static name="ValidationError";name="ValidationError"},pr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Xr=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Qr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*o)-1;for(;;){let d=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let f=Number.parseInt(l,t);if(!Number.isNaN(f))return f});if(d===void 0)break;if(s*=t,s+=d,s>u||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var mu=45,yu=15,Jr=new Qr;function Vo(e){if(!(e.length>yu))return Jr.new(e).parseWith(()=>Jr.readIPv4Addr())}function Ho(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>mu))return Jr.new(e).parseWith(()=>Jr.readIPv6Addr())}function tn(e){return!!Vo(e)}function ea(e){return!!Ho(e)}function zo(e){return t=>F(t,e)}function Fo(e){return t=>ct(t,e)}function Me(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function me(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function ra(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=ct(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=me(n);return Ut([r,o],r.length+o.length)}function na(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=me(n);return Ut([r,o],r.length+o.length)}function jo(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=F(t,"base32"),o=Me(r);return`${n}:${o}`}var Go=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new it("Invalid byte value in IP address");t[n]=o}),t},oa=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=tn(r[n]),i;s&&(i=Go(r[n]),r[n]=F(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,F(i.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let s=parseInt(r[n],16);if(isNaN(s)||s<0||s>65535)throw new it("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},sa=function(e){if(e.byteLength!==4)throw new it("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},ia=function(e){if(e.byteLength!==16)throw new it("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],s=e[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new it(`Invalid IPv6 address "${r}"`)}};function aa(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new it(`Invalid IPv6 address "${e}"`)}}var qo=Object.values($e).map(e=>e.decoder),bu=function(){let e=qo[0].or(qo[1]);return qo.slice(2).forEach(t=>e=e.or(t)),e}();function ca(e){return bu.decode(e)}function fa(e){return t=>e.encoder.encode(t)}function gu(e){if(parseInt(e).toString()!==e)throw new Zt("Value must be an integer")}function xu(e){if(e<0)throw new Zt("Value must be a positive integer, or zero")}function wu(e){return t=>{if(t>e)throw new Zt(`Value must be smaller than or equal to ${e}`)}}function Eu(...e){return t=>{for(let r of e)r(t)}}var mr=Eu(gu,xu,wu(65535));var ot=-1,Zo=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new Xr(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},vt=new Zo,Xu=[{code:4,name:"ip4",size:32,valueToBytes:Go,bytesToValue:sa,validate:e=>{if(!tn(e))throw new Zt(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:me,bytesToValue:Me,validate:mr},{code:273,name:"udp",size:16,valueToBytes:me,bytesToValue:Me,validate:mr},{code:33,name:"dccp",size:16,valueToBytes:me,bytesToValue:Me,validate:mr},{code:41,name:"ip6",size:128,valueToBytes:oa,bytesToValue:ia,stringToValue:aa,validate:e=>{if(!ea(e))throw new Zt(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ot},{code:43,name:"ipcidr",size:8,bytesToValue:zo("base10"),valueToBytes:Fo("base10")},{code:53,name:"dns",size:ot,resolvable:!0},{code:54,name:"dns4",size:ot,resolvable:!0},{code:55,name:"dns6",size:ot,resolvable:!0},{code:56,name:"dnsaddr",size:ot,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:me,bytesToValue:Me,validate:mr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ot,path:!0,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ot,bytesToValue:zo("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?Fo("base58btc")(e):et.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:jo,valueToBytes:ra},{code:445,name:"onion3",size:296,bytesToValue:jo,valueToBytes:na},{code:446,name:"garlic64",size:ot},{code:447,name:"garlic32",size:ot},{code:448,name:"tls"},{code:449,name:"sni",size:ot},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ot,bytesToValue:fa(_n),valueToBytes:ca},{code:480,name:"http"},{code:481,name:"http-path",size:ot,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ot}];Xu.forEach(e=>{vt.addProtocol(e)});function ua(e){let t=[],r=0;for(;r<e.length;){let n=xo(e,r),o=vt.getProtocol(n),s=Dt(n),i=Qu(o,e,r+s),a=0;i>0&&o.size===ot&&(a=Dt(i));let c=s+a+i,u={code:n,name:o.name,bytes:e.subarray(r,r+c)};if(i>0){let d=r+s+a,l=e.subarray(d,d+i);u.value=o.bytesToValue?.(l)??F(l)}t.push(u),r+=c}return t}function la(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=vt.getProtocol(n.code),s=Dt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??ct(n.value),a=i.byteLength,o.size===ot&&(c=Dt(a)));let u=new Uint8Array(s+c+a),d=0;cr(n.code,u,d),d+=s,i!=null&&(o.size===ot&&(cr(a,u,d),d+=c),u.set(i,d)),n.bytes=u}r.push(n.bytes),t+=n.bytes.byteLength}return Ut(r,t)}function ha(e){if(e.charAt(0)!=="/")throw new it('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let s=1;s<e.length;s++){let i=e.charAt(s);i!=="/"&&(r==="protocol"?o+=e.charAt(s):n+=e.charAt(s));let a=s===e.length-1;if(i==="/"||a){let c=vt.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new it(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new it(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}t.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new it("Incomplete multiaddr");return t}function da(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=vt.getProtocol(t.code);if(r==null)throw new it(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Qu(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:xo(t,r)}var Ju=Symbol.for("nodejs.util.inspect.custom"),es=Symbol.for("@multiformats/multiaddr"),tl=[53,54,55,56],ts=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}};function el(e){if(e==null&&(e="/"),ma(e))return e.getComponents();if(e instanceof Uint8Array)return ua(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),ha(e);if(Array.isArray(e))return e;throw new it("Must be a string, Uint8Array, Component[], or another Multiaddr")}var sn=class e{[es]=!0;#t;#e;#r;constructor(t="/",r={}){this.#t=el(t),r.validate!==!1&&rl(this)}get bytes(){return this.#r==null&&(this.#r=la(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=da(this.#t)),this.#e}toJSON(){return this.toString()}toOptions(){let t,r,n,o,s="";for(let{code:a,name:c,value:u}of this.#t)a===42&&(s=`%${u??""}`),tl.includes(a)&&(r="tcp",o=443,n=`${u??""}${s}`,t=a===55?6:4),(a===6||a===273)&&(r=c==="tcp"?"tcp":"udp",o=parseInt(u??"")),(a===4||a===41)&&(r="tcp",n=`${u??""}${s}`,t=a===41?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}getComponents(){return[...this.#t]}protos(){return this.#t.map(({code:t,value:r})=>{let n=vt.getProtocol(t);return{code:t,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#t.map(({code:t})=>t)}protoNames(){return this.#t.map(({name:t})=>t)}tuples(){return this.#t.map(({code:t,value:r})=>{if(r==null)return[t];let n=vt.getProtocol(t),o=[t];return r!=null&&o.push(n.valueToBytes?.(r)??ct(r)),o})}stringTuples(){return this.#t.map(({code:t,value:r})=>r==null?[t]:[t,r])}encapsulate(t){let r=new e(t);return new e([...this.#t,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new pr(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}getPeerId(){try{let t=[];this.#t.forEach(({code:n,value:o})=>{n===421&&t.push([n,o]),n===290&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?F(X.decode(`z${n}`),"base58btc"):F(et.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let t of this.#t)if(vt.getProtocol(t.code).path)return t.value??null;return null}equals(t){return yt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=pa.get(r.name);if(n==null)throw new ts(`no available resolver for ${r.name}`);return(await n(this,t)).map(s=>oe(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(){return!(this.#t.length!==2||this.#t[0].code!==4&&this.#t[0].code!==41||this.#t[1].code!==6&&this.#t[1].code!==273)}[Ju](){return`Multiaddr(${this.toString()})`}};function rl(e){e.getComponents().forEach(t=>{let r=vt.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}var fy=parseInt("0xFFFF",16),uy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var pa=new Map;function ma(e){return!!e?.[es]}function oe(e){return new sn(e)}var al=A("dns4"),cl=A("dns6"),fl=A("dnsaddr"),be=J(A("dns"),fl,al,cl),fn=J(A("ip4"),A("ip6")),Ve=J(U(fn,A("tcp")),U(be,A("tcp"))),un=U(fn,A("udp")),ul=U(un,A("utp")),ll=U(un,A("quic")),hl=U(un,A("quic-v1")),rs=J(U(Ve,A("ws")),U(be,A("ws"))),an=J(U(rs,A("p2p")),rs),ns=J(U(Ve,A("wss")),U(be,A("wss")),U(Ve,A("tls"),A("ws")),U(be,A("tls"),A("ws"))),cn=J(U(ns,A("p2p")),ns),os=J(U(Ve,A("http")),U(fn,A("http")),U(be,A("http"))),ss=J(U(Ve,A("https")),U(fn,A("https")),U(be,A("https"))),ga=U(un,A("webrtc-direct"),A("certhash")),Ea=J(U(ga,A("p2p")),ga),xa=U(hl,A("webtransport"),A("certhash"),A("certhash")),Sa=J(U(xa,A("p2p")),xa),va=J(U(an,A("p2p-webrtc-star"),A("p2p")),U(cn,A("p2p-webrtc-star"),A("p2p")),U(an,A("p2p-webrtc-star")),U(cn,A("p2p-webrtc-star"))),Yy=J(U(an,A("p2p-websocket-star"),A("p2p")),U(cn,A("p2p-websocket-star"),A("p2p")),U(an,A("p2p-websocket-star")),U(cn,A("p2p-websocket-star"))),Aa=J(U(os,A("p2p-webrtc-direct"),A("p2p")),U(ss,A("p2p-webrtc-direct"),A("p2p")),U(os,A("p2p-webrtc-direct")),U(ss,A("p2p-webrtc-direct"))),ge=J(rs,ns,os,ss,va,Aa,Ve,ul,ll,be,Ea,Sa),Xy=J(U(ge,A("p2p-stardust"),A("p2p")),U(ge,A("p2p-stardust"))),se=J(U(ge,A("p2p")),va,Aa,Ea,Sa,A("p2p")),wa=J(U(se,A("p2p-circuit"),se),U(se,A("p2p-circuit")),U(A("p2p-circuit"),se),U(ge,A("p2p-circuit")),U(A("p2p-circuit"),ge),A("p2p-circuit")),Ba=()=>J(U(wa,Ba),wa),ye=Ba(),Ia=J(U(ye,se,ye),U(se,ye),U(ye,se),ye,se);var Qy=J(U(ye,A("webrtc"),A("p2p")),U(ye,A("webrtc")),U(ge,A("webrtc"),A("p2p")),U(ge,A("webrtc")),A("webrtc"));function _a(e){function t(r){let n;try{n=oe(r)}catch{return!1}let o=e(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return t}function U(...e){function t(r){if(r.length<e.length)return null;let n=r;return e.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:_a(t),partialMatch:t}}function J(...e){function t(n){let o=null;return e.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:_a(t),partialMatch:t}}function A(e){let t=e;function r(o){let s;try{s=oe(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===t}function n(o){return o.length===0?null:o[0]===t?o.slice(1):null}return{toString:function(){return t},matches:r,partialMatch:n}}var dl="bootstrap",pl=50,ml=1e3,is=class extends Er{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(t,r={list:[]}){if(r.list==null||r.list.length===0)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.log=t.logger.forComponent("libp2p:bootstrap"),this.timeout=r.timeout??ml,this.list=[];for(let n of r.list){if(!Ia.matches(n)){this.log.error("Invalid multiaddr");continue}let o=oe(n),s=o.getPeerId();if(s==null){this.log.error("Invalid bootstrap multiaddr without peer id");continue}let i={id:Qi(s),multiaddrs:[o]};this.list.push(i)}this._init=r}[fs]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[us]=["@libp2p/peer-discovery"];isStarted(){return!!this.timer}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{this.log.error(t)})},this.timeout))}async _discoverBootstrapPeers(){if(this.timer!=null)for(let t of this.list){if(await this.components.peerStore.merge(t.id,{tags:{[this._init.tagName??dl]:{value:this._init.tagValue??pl,ttl:this._init.tagTTL}},multiaddrs:t.multiaddrs}),this.timer==null)return;this.safeDispatchEvent("peer",{detail:t}),this.components.connectionManager.openConnection(t.id).catch(r=>{this.log.error("could not dial bootstrap peer %p",t.id,r)})}}stop(){this.timer!=null&&clearTimeout(this.timer),this.timer=void 0}};function yl(e){return t=>new is(t,e)}return La(bl);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|