@libp2p/peer-collections 7.0.20-29797a5bb → 7.0.20-5b8813abc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerCollections = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPeerCollections=(()=>{var pn=Object.defineProperty;var Wc=Object.getOwnPropertyDescriptor;var Jc=Object.getOwnPropertyNames;var Qc=Object.prototype.hasOwnProperty;var q=(r,t)=>{for(var e in t)pn(r,e,{get:t[e],enumerable:!0})},ta=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jc(t))!Qc.call(r,o)&&o!==e&&pn(r,o,{get:()=>t[o],enumerable:!(n=Wc(t,o))||n.enumerable});return r};var ea=r=>ta(pn({},"__esModule",{value:!0}),r);var jh={};q(jh,{PeerFilter:()=>wr,PeerList:()=>Wt,PeerMap:()=>Gt,PeerSet:()=>Xt,peerFilter:()=>$c,peerList:()=>Vc,peerMap:()=>zc,peerSet:()=>qc,trackedPeerList:()=>Xc,trackedPeerMap:()=>Yc,trackedPeerSet:()=>Gc});var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Sr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var _r=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Me=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var mn=Symbol.for("@libp2p/peer-id");var wn={};q(wn,{base58btc:()=>Y,base58flickr:()=>aa});var Gh=new Uint8Array(0);function xs(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 Tt(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 gs(r){return new TextEncoder().encode(r)}function ws(r){return new TextDecoder().decode(r)}function ra(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,f=r.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var w=0,p=0,b=0,S=d.length;b!==S&&d[b]===0;)b++,w++;for(var _=(S-b)*u+1>>>0,T=new Uint8Array(_);b!==S;){for(var I=d[b],F=0,L=_-1;(I!==0||F<p)&&L!==-1;L--,F++)I+=256*T[L]>>>0,T[L]=I%c>>>0,I=I/c>>>0;if(I!==0)throw new Error("Non-zero carry");p=F,b++}for(var B=_-p;B!==_&&T[B]===0;)B++;for(var O=f.repeat(w);B<_;++B)O+=r.charAt(T[B]);return O}function E(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var w=0;if(d[w]!==" "){for(var p=0,b=0;d[w]===f;)p++,w++;for(var S=(d.length-w)*a+1>>>0,_=new Uint8Array(S);d[w];){var T=e[d.charCodeAt(w)];if(T===255)return;for(var I=0,F=S-1;(T!==0||I<b)&&F!==-1;F--,I++)T+=c*_[F]>>>0,_[F]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");b=I,w++}if(d[w]!==" "){for(var L=S-b;L!==S&&_[L]===0;)L++;for(var B=new Uint8Array(p+(S-L)),O=p;L!==S;)B[O++]=_[L++];return B}}}function m(d){var w=E(d);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:E,decode:m}}var na=ra,oa=na,Ss=oa;var bn=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")}},yn=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 _s(this,t)}},xn=class{decoders;constructor(t){this.decoders=t}or(t){return _s(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 _s(r,t){return new xn({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var gn=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 bn(t,e,n),this.decoder=new yn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function de({name:r,prefix:t,encode:e,decode:n}){return new gn(r,t,e,n)}function kt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ss(e,r);return de({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function sa(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[r[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,i+=e,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function ia(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function ca(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function H({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=ca(n);return de({prefix:t,name:r,encode(s){return ia(s,n,e)},decode(s){return sa(s,o,e,r)}})}var Y=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),aa=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var En={};q(En,{base32:()=>pe,base32hex:()=>la,base32hexpad:()=>pa,base32hexpadupper:()=>ma,base32hexupper:()=>da,base32pad:()=>ua,base32padupper:()=>ha,base32upper:()=>fa,base32z:()=>ba});var pe=H({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fa=H({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ua=H({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ha=H({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),la=H({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),da=H({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),pa=H({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ma=H({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ba=H({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Sn={};q(Sn,{base36:()=>Pe,base36upper:()=>ya});var Pe=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ya=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xa=Bs,vs=128,ga=127,wa=~ga,Ea=Math.pow(2,31);function Bs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ea;)t[e++]=r&255|vs,r/=128;for(;r&wa;)t[e++]=r&255|vs,r>>>=7;return t[e]=r|0,Bs.bytes=e-n+1,t}var Sa=_n,_a=128,As=127;function _n(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw _n.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&As)<<o:(i&As)*Math.pow(2,o),o+=7}while(i>=_a);return _n.bytes=s-n,e}var va=Math.pow(2,7),Aa=Math.pow(2,14),Ba=Math.pow(2,21),Ia=Math.pow(2,28),Ta=Math.pow(2,35),Da=Math.pow(2,42),Ca=Math.pow(2,49),La=Math.pow(2,56),Ua=Math.pow(2,63),Fa=function(r){return r<va?1:r<Aa?2:r<Ba?3:r<Ia?4:r<Ta?5:r<Da?6:r<Ca?7:r<La?8:r<Ua?9:10},Ra={encode:xa,decode:Sa,encodingLength:Fa},Oa=Ra,ze=Oa;function qe(r,t=0){return[ze.decode(r,t),ze.decode.bytes]}function me(r,t,e=0){return ze.encode(r,t,e),t}function be(r){return ze.encodingLength(r)}function xe(r,t){let e=t.byteLength,n=be(r),o=n+be(e),s=new Uint8Array(o+e);return me(r,s,0),me(e,s,n),s.set(t,o),new ye(r,e,t,s)}function Ve(r){let t=Tt(r),[e,n]=qe(t),[o,s]=qe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ye(e,o,i,t)}function Is(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&xs(r.bytes,e.bytes)}}var ye=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Ts(r,t){let{bytes:e,version:n}=r;return n===0?Na(e,vn(r),t??Y.encoder):Ka(e,vn(r),t??pe.encoder)}var Ds=new WeakMap;function vn(r){let t=Ds.get(r);if(t==null){let e=new Map;return Ds.set(r,e),e}return t}var at=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!==He)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ma)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=xe(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&&Is(t.multihash,n.multihash)}toString(t){return Ts(this,t)}toJSON(){return{"/":Ts(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??Cs(n,o,s.bytes))}else if(e[Pa]===!0){let{version:n,multihash:o,code:s}=e,i=Ve(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!==He)throw new Error(`Version 0 CID must use dag-pb (code: ${He}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Cs(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,He,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=Tt(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 ye(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,E]=qe(t.subarray(e));return e+=E,h},o=n(),s=He;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),f=n(),a=e+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,e){let[n,o]=ka(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return vn(s).set(n,t),s}};function ka(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case pe.prefix:{let e=t??pe;return[pe.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.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 Na(r,t,e){let{prefix:n}=e;if(n!==Y.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 Ka(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 He=112,Ma=18;function Cs(r,t,e){let n=be(r),o=n+be(t),s=new Uint8Array(o+e.byteLength);return me(r,s,0),me(t,s,n),s.set(e,o),s}var Pa=Symbol.for("@ipld/js-cid/CID");var An={};q(An,{identity:()=>dt});var Ls=0,za="identity",Us=Tt;function qa(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return xe(Ls,Us(r))}var dt={code:Ls,name:za,encode:Us,digest:qa};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 Va(r){return r.buffer instanceof ArrayBuffer}function ge(r){return Va(r)?r:r.slice()}async function Fs(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,ge(t),ge(e.subarray()));return n?.signal?.throwIfAborted(),s}function Dt(r=0){return new Uint8Array(r)}function je(r=0){return new Uint8Array(r)}function Bn(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=je(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Rs(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}var ks=Symbol.for("@achingbrain/uint8arraylist");function Os(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?.[ks]}var ft=class r{bufs;length;[ks]=!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;for(let o of n.bufs)this.bufs.push(o)}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=Os(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Os(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 Bn(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Bn(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,f=c+i.byteLength;if(o=f,t>=f)continue;let a=t>=c&&t<f,u=e>c&&e<=f;if(a&&u){if(t===c&&e===f){n.push(i);break}let h=t-c;n.push(i.subarray(h,h+(e-t)));break}if(a){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===f){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!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 h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let c=i,f=this.byteLength-n.byteLength,a=n.byteLength-1,u;for(let h=e;h<=f;h+=u){u=0;for(let E=a;E>=0;E--){let m=this.get(h+E);if(n[E]!==m){u=Math.max(1,E-c[m]);break}}if(u===0)return h}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=je(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=Dt(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=Dt(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=Dt(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=je(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=Dt(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=Dt(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=Dt(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=Dt(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=Dt(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(!Rs(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 Ln={};q(Ln,{base10:()=>Wa});var Tl=new Uint8Array(0);function Ns(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Ct(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return Qt(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return Qt(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function Ks(r){return new TextEncoder().encode(r)}function Ms(r){return new TextDecoder().decode(r)}function Ha(r){return r?.buffer instanceof ArrayBuffer}function Qt(r){return Ha(r)?r:r.slice()}function ja(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,f=r.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var w=0,p=0,b=0,S=d.length;b!==S&&d[b]===0;)b++,w++;for(var _=(S-b)*u+1>>>0,T=new Uint8Array(_);b!==S;){for(var I=d[b],F=0,L=_-1;(I!==0||F<p)&&L!==-1;L--,F++)I+=256*T[L]>>>0,T[L]=I%c>>>0,I=I/c>>>0;if(I!==0)throw new Error("Non-zero carry");p=F,b++}for(var B=_-p;B!==_&&T[B]===0;)B++;for(var O=f.repeat(w);B<_;++B)O+=r.charAt(T[B]);return O}function E(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var w=0;if(d[w]!==" "){for(var p=0,b=0;d[w]===f;)p++,w++;for(var S=(d.length-w)*a+1>>>0,_=new Uint8Array(S);d[w];){var T=e[d.charCodeAt(w)];if(T===255)return;for(var I=0,F=S-1;(T!==0||I<b)&&F!==-1;F--,I++)T+=c*_[F]>>>0,_[F]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");b=I,w++}if(d[w]!==" "){for(var L=S-b;L!==S&&_[L]===0;)L++;for(var B=new Uint8Array(p+(S-L)),O=p;L!==S;)B[O++]=_[L++];return B}}}function m(d){var w=E(d);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:E,decode:m}}var Za=ja,$a=Za,zs=$a;var In=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")}},Tn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return qs(this,t)}},Dn=class{decoders;constructor(t){this.decoders=t}or(t){return qs(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function qs(r,t){return new Dn({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Cn=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 In(t,e,n),this.decoder=new Tn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function we({name:r,prefix:t,encode:e,decode:n}){return new Cn(r,t,e,n)}function Nt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=zs(e,r);return we({prefix:t,name:r,encode:n,decode:s=>Ct(o(s))})}function Ya(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[r[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,i+=e,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Ga(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Xa(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Xa(n);return we({prefix:t,name:r,encode(s){return Ga(s,n,e)},decode(s){return Ya(s,o,e,r)}})}var Wa=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var Un={};q(Un,{base16:()=>Ja,base16upper:()=>Qa});var Ja=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qa=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fn={};q(Fn,{base2:()=>tf});var tf=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rn={};q(Rn,{base256emoji:()=>sf});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}"),ef=Vs.reduce((r,t,e)=>(r[e]=t,r),[]),rf=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 nf(r){return r.reduce((t,e)=>(t+=ef[e],t),"")}function of(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=rf[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var sf=we({prefix:"\u{1F680}",name:"base256emoji",encode:nf,decode:of});var On={};q(On,{base32:()=>Ee,base32hex:()=>uf,base32hexpad:()=>lf,base32hexpadupper:()=>df,base32hexupper:()=>hf,base32pad:()=>af,base32padupper:()=>ff,base32upper:()=>cf,base32z:()=>pf});var Ee=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),cf=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),af=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ff=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uf=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hf=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lf=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),df=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pf=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kn={};q(kn,{base36:()=>Ze,base36upper:()=>mf});var Ze=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mf=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Nn={};q(Nn,{base58btc:()=>St,base58flickr:()=>bf});var St=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bf=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Kn={};q(Kn,{base64:()=>yf,base64pad:()=>xf,base64url:()=>gf,base64urlpad:()=>wf});var yf=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xf=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gf=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wf=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Mn={};q(Mn,{base8:()=>Ef});var Ef=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Pn={};q(Pn,{identity:()=>Sf});var Sf=we({prefix:"\0",name:"identity",encode:r=>Ms(r),decode:r=>Ks(r)});var Hl=new TextEncoder,jl=new TextDecoder;var qn={};q(qn,{identity:()=>jf});var Af=Zs,Hs=128,Bf=127,If=~Bf,Tf=Math.pow(2,31);function Zs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Tf;)t[e++]=r&255|Hs,r/=128;for(;r&If;)t[e++]=r&255|Hs,r>>>=7;return t[e]=r|0,Zs.bytes=e-n+1,t}var Df=zn,Cf=128,js=127;function zn(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw zn.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&js)<<o:(i&js)*Math.pow(2,o),o+=7}while(i>=Cf);return zn.bytes=s-n,e}var Lf=Math.pow(2,7),Uf=Math.pow(2,14),Ff=Math.pow(2,21),Rf=Math.pow(2,28),Of=Math.pow(2,35),kf=Math.pow(2,42),Nf=Math.pow(2,49),Kf=Math.pow(2,56),Mf=Math.pow(2,63),Pf=function(r){return r<Lf?1:r<Uf?2:r<Ff?3:r<Rf?4:r<Of?5:r<kf?6:r<Nf?7:r<Kf?8:r<Mf?9:10},zf={encode:Af,decode:Df,encodingLength:Pf},qf=zf,$e=qf;function Ye(r,t=0){return[$e.decode(r,t),$e.decode.bytes]}function Se(r,t,e=0){return $e.encode(r,t,e),t}function _e(r){return $e.encodingLength(r)}function Ae(r,t){let e=t.byteLength,n=_e(r),o=n+_e(e),s=new Uint8Array(o+e);return Se(r,s,0),Se(e,s,n),s.set(t,o),new ve(r,e,t,s)}function $s(r){let t=Ct(r),[e,n]=Ye(t),[o,s]=Ye(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ve(e,o,i,t)}function Ys(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ns(r.bytes,e.bytes)}}var ve=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=Qt(n),this.bytes=Qt(o)}};var Gs=0,Vf="identity",Xs=Ct;function Hf(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return Ae(Gs,Xs(r))}var jf={code:Gs,name:Vf,encode:Xs,digest:Hf};var jn={};q(jn,{sha256:()=>$f,sha512:()=>Yf});var Zf=20;function Hn({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new Vn(r,t,e,n,o)}var Vn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??Zf,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Ws(n,this.code,e?.truncate):n.then(o=>Ws(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ws(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return Ae(t,r)}function Qs(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var $f=Hn({name:"sha2-256",code:18,encode:Qs("SHA-256")}),Yf=Hn({name:"sha2-512",code:19,encode:Qs("SHA-512")});function ti(r,t){let{bytes:e,version:n}=r;return n===0?Xf(e,Zn(r),t??St.encoder):Wf(e,Zn(r),t??Ee.encoder)}var ei=new WeakMap;function Zn(r){let t=ei.get(r);if(t==null){let e=new Map;return ei.set(r,e),e}return t}var Ir=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=Qt(o),this["/"]=this.bytes}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!==Xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Jf)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=Ae(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&&Ys(t.multihash,n.multihash)}toString(t){return ti(this,t)}toJSON(){return{"/":ti(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??ri(n,o,s.bytes))}else if(e[Qf]===!0){let{version:n,multihash:o,code:s}=e,i=$s(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!==Xe)throw new Error(`Version 0 CID must use dag-pb (code: ${Xe}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ri(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Xe,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=Ct(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 ve(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,E]=Ye(t.subarray(e));return e+=E,h},o=n(),s=Xe;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),f=n(),a=e+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,e){let[n,o]=Gf(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Zn(s).set(n,t),s}};function Gf(r,t){switch(r[0]){case"Q":{let e=t??St;return[St.prefix,e.decode(`${St.prefix}${r}`)]}case St.prefix:{let e=t??St;return[St.prefix,e.decode(r)]}case Ee.prefix:{let e=t??Ee;return[Ee.prefix,e.decode(r)]}case Ze.prefix:{let e=t??Ze;return[Ze.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 Xf(r,t,e){let{prefix:n}=e;if(n!==St.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 Wf(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 Xe=112,Jf=18;function ri(r,t,e){let n=_e(r),o=n+_e(t),s=new Uint8Array(o+e.byteLength);return Se(r,s,0),Se(t,s,n),s.set(e,o),s}var Qf=Symbol.for("@ipld/js-cid/CID");var $n={...Pn,...Fn,...Mn,...Ln,...Un,...On,...kn,...Nn,...Kn,...Rn},dd={...jn,...qn};function ni(r=0){return new Uint8Array(r)}function Yn(r=0){return new Uint8Array(r)}function si(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var oi=si("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Gn=si("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=Yn(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),tu={utf8:oi,"utf-8":oi,hex:$n.base16,latin1:Gn,ascii:Gn,binary:Gn,...$n},Tr=tu;function nt(r,t="utf8"){let e=Tr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function lt(r,t="utf8"){let e=Tr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var eu=parseInt("11111",2),Xn=parseInt("10000000",2),ru=parseInt("01111111",2),ii={0:We,1:We,2:nu,3:iu,4:cu,5:su,6:ou,16:We,22:We,48:We};function Wn(r,t={offset:0}){let e=r[t.offset]&eu;if(t.offset++,ii[e]!=null)return ii[e](r,t);throw new Error("No decoder for tag "+e)}function Je(r,t){let e=0;if((r[t.offset]&Xn)===Xn){let n=r[t.offset]&ru,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 We(r,t){Je(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Wn(r,t);if(n===null)break;e.push(n)}return e}function nu(r,t){let e=Je(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 ou(r,t){let e=Je(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,f=[];for(;t.offset<n;){let a=r[t.offset];if(t.offset++,f.push(a&127),a<128){f.reverse();let u=0;for(let h=0;h<f.length;h++)u+=f[h]<<h*7;c+=`.${u}`,f=[]}}return c}function su(r,t){return t.offset++,null}function iu(r,t){let e=Je(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function cu(r,t){let e=Je(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function au(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new ft;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Jn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=au(r.byteLength);return new ft(Uint8Array.from([t.byteLength|Xn]),t)}function ci(r){let t=new ft,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new ft(Uint8Array.from([2]),Jn(t),t)}function ai(r){let t=Uint8Array.from([0]),e=new ft(t,r);return new ft(Uint8Array.from([3]),Jn(e),e)}function Dr(r,t=48){let e=new ft;for(let n of r)e.append(n);return new ft(Uint8Array.from([t]),Jn(e),e)}var fu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),uu=Uint8Array.from([6,5,43,129,4,0,34]),hu=Uint8Array.from([6,5,43,129,4,0,35]),lu={ext:!0,kty:"EC",crv:"P-256"},du={ext:!0,kty:"EC",crv:"P-384"},pu={ext:!0,kty:"EC",crv:"P-521"},Qn=32,to=48,eo=66;function fi(r){let t=Wn(r);return ui(t)}function ui(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===Qn*2+1)return n=lt(t.subarray(e,e+Qn),"base64url"),o=lt(t.subarray(e+Qn),"base64url"),new Be({...lu,key_ops:["verify"],x:n,y:o});if(t.byteLength===to*2+1)return n=lt(t.subarray(e,e+to),"base64url"),o=lt(t.subarray(e+to),"base64url"),new Be({...du,key_ops:["verify"],x:n,y:o});if(t.byteLength===eo*2+1)return n=lt(t.subarray(e,e+eo),"base64url"),o=lt(t.subarray(e+eo),"base64url"),new Be({...pu,key_ops:["verify"],x:n,y:o});throw new It(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function hi(r){return Dr([ci(Uint8Array.from([1])),Dr([mu(r.crv)],160),Dr([ai(new ft(Uint8Array.from([4]),nt(r.x??"","base64url"),nt(r.y??"","base64url")))],161)]).subarray()}function mu(r){if(r==="P-256")return fu;if(r==="P-384")return uu;if(r==="P-521")return hu;throw new It(`Invalid curve ${r}`)}var Be=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=hi(this.jwk)),this._raw}toMultihash(){return dt.digest(Ie(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Y.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 Fs(this.jwk,e,t,n)}};function ro(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in r&&r.BYTES_PER_ELEMENT===1}function Kt(r,t=""){if(typeof r!="number"){let e=t&&`"${t}" `;throw new TypeError(`${e}expected number, got ${typeof r}`)}if(!Number.isSafeInteger(r)||r<0){let e=t&&`"${t}" `;throw new RangeError(`${e}expected integer >= 0, got ${r}`)}}function ut(r,t,e=""){let n=ro(r),o=r?.length,s=t!==void 0;if(!n||s&&o!==t){let i=e&&`"${e}" `,c=s?` of length ${t}`:"",f=n?`length=${o}`:`type=${typeof r}`,a=i+"expected Uint8Array"+c+", got "+f;throw n?new RangeError(a):new TypeError(a)}return r}function Cr(r){if(typeof r!="function"||typeof r.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Kt(r.outputLen),Kt(r.blockLen),r.outputLen<1)throw new Error('"outputLen" must be >= 1');if(r.blockLen<1)throw new Error('"blockLen" must be >= 1')}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 Lr(r,t){ut(r,void 0,"digestInto() output");let e=t.outputLen;if(r.length<e)throw new RangeError('"digestInto() output" expected to be of length >='+e)}function Ut(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Ur(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function mt(r,t){return r<<32-t|r>>>t}var di=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",bu=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Fr(r){if(ut(r),di)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=bu[r[e]];return t}var Lt={_0:48,_9:57,A:65,F:70,a:97,f:102};function li(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt.A&&r<=Lt.F)return r-(Lt.A-10);if(r>=Lt.a&&r<=Lt.f)return r-(Lt.a-10)}function Qe(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);if(di)try{return Uint8Array.fromHex(r)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=r.length,e=t/2;if(t%2)throw new RangeError("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=li(r.charCodeAt(s)),c=li(r.charCodeAt(s+1));if(i===void 0||c===void 0){let f=r[s]+r[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function no(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ut(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function oo(r,t={}){let e=(o,s)=>r(s).update(o).digest(),n=r(void 0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.canXOF=n.canXOF,e.create=o=>r(o),Object.assign(e,t),Object.freeze(e)}function pi(r=32){Kt(r,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(r>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${r}`);return t.getRandomValues(new Uint8Array(r))}var so=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function mi(r,t,e){return r&t^~r&e}function bi(r,t,e){return r&t^r&e^t&e}var tr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,o){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Ur(this.buffer)}update(t){Te(this),ut(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=Ur(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Te(this),Lr(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 h=i;h<o;h++)e[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=Ur(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let a=f/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ft=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Rr=BigInt(4294967295),yi=BigInt(32);function yu(r,t=!1){return t?{h:Number(r&Rr),l:Number(r>>yi&Rr)}:{h:Number(r>>yi&Rr)|0,l:Number(r&Rr)|0}}function xi(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:c}=yu(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var io=(r,t,e)=>r>>>e,co=(r,t,e)=>r<<32-e|t>>>e,te=(r,t,e)=>r>>>e|t<<32-e,ee=(r,t,e)=>r<<32-e|t>>>e,er=(r,t,e)=>r<<64-e|t>>>e-32,rr=(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 gi=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),wi=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ei=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Si=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,_i=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),vi=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var gu=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]),Mt=new Uint32Array(64),ao=class extends tr{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,e,n,o,s,i,c,f]}set(t,e,n,o,s,i,c,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,e){for(let h=0;h<16;h++,e+=4)Mt[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let E=Mt[h-15],m=Mt[h-2],d=mt(E,7)^mt(E,18)^E>>>3,w=mt(m,17)^mt(m,19)^m>>>10;Mt[h]=w+Mt[h-7]+d+Mt[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:a,H:u}=this;for(let h=0;h<64;h++){let E=mt(c,6)^mt(c,11)^mt(c,25),m=u+E+mi(c,f,a)+gu[h]+Mt[h]|0,w=(mt(n,2)^mt(n,13)^mt(n,22))+bi(n,o,s)|0;u=a,a=f,f=c,c=i+m|0,i=s,s=o,o=n,n=m+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,f,a,u)}roundClean(){Ut(Mt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ut(this.buffer)}},fo=class extends ao{A=Ft[0]|0;B=Ft[1]|0;C=Ft[2]|0;D=Ft[3]|0;E=Ft[4]|0;F=Ft[5]|0;G=Ft[6]|0;H=Ft[7]|0;constructor(){super(32)}};var Ai=xi(["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))),wu=Ai[0],Eu=Ai[1],Pt=new Uint32Array(80),zt=new Uint32Array(80),uo=class extends tr{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:a,El:u,Fh:h,Fl:E,Gh:m,Gl:d,Hh:w,Hl:p}=this;return[t,e,n,o,s,i,c,f,a,u,h,E,m,d,w,p]}set(t,e,n,o,s,i,c,f,a,u,h,E,m,d,w,p){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=u|0,this.Fh=h|0,this.Fl=E|0,this.Gh=m|0,this.Gl=d|0,this.Hh=w|0,this.Hl=p|0}process(t,e){for(let _=0;_<16;_++,e+=4)Pt[_]=t.getUint32(e),zt[_]=t.getUint32(e+=4);for(let _=16;_<80;_++){let T=Pt[_-15]|0,I=zt[_-15]|0,F=te(T,I,1)^te(T,I,8)^io(T,I,7),L=ee(T,I,1)^ee(T,I,8)^co(T,I,7),B=Pt[_-2]|0,O=zt[_-2]|0,z=te(B,O,19)^er(B,O,61)^io(B,O,6),k=ee(B,O,19)^rr(B,O,61)^co(B,O,6),l=Ei(L,k,zt[_-7],zt[_-16]),y=Si(l,F,z,Pt[_-7],Pt[_-16]);Pt[_]=y|0,zt[_]=l|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:a,Dl:u,Eh:h,El:E,Fh:m,Fl:d,Gh:w,Gl:p,Hh:b,Hl:S}=this;for(let _=0;_<80;_++){let T=te(h,E,14)^te(h,E,18)^er(h,E,41),I=ee(h,E,14)^ee(h,E,18)^rr(h,E,41),F=h&m^~h&w,L=E&d^~E&p,B=_i(S,I,L,Eu[_],zt[_]),O=vi(B,b,T,F,wu[_],Pt[_]),z=B|0,k=te(n,o,28)^er(n,o,34)^er(n,o,39),l=ee(n,o,28)^rr(n,o,34)^rr(n,o,39),y=n&s^n&c^s&c,v=o&i^o&f^i&f;b=w|0,S=p|0,w=m|0,p=d|0,m=h|0,d=E|0,{h,l:E}=_t(a|0,u|0,O|0,z|0),a=c|0,u=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let g=gi(z,l,v);n=wi(g,O,k,y),o=g|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:c,l:f}=_t(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l:u}=_t(this.Dh|0,this.Dl|0,a|0,u|0),{h,l:E}=_t(this.Eh|0,this.El|0,h|0,E|0),{h:m,l:d}=_t(this.Fh|0,this.Fl|0,m|0,d|0),{h:w,l:p}=_t(this.Gh|0,this.Gl|0,w|0,p|0),{h:b,l:S}=_t(this.Hh|0,this.Hl|0,b|0,S|0),this.set(n,o,s,i,c,f,a,u,h,E,m,d,w,p,b,S)}roundClean(){Ut(Pt,zt)}destroy(){this.destroyed=!0,Ut(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ho=class extends uo{Ah=et[0]|0;Al=et[1]|0;Bh=et[2]|0;Bl=et[3]|0;Ch=et[4]|0;Cl=et[5]|0;Dh=et[6]|0;Dl=et[7]|0;Eh=et[8]|0;El=et[9]|0;Fh=et[10]|0;Fl=et[11]|0;Gh=et[12]|0;Gl=et[13]|0;Hh=et[14]|0;Hl=et[15]|0;constructor(){super(64)}};var Bi=oo(()=>new fo,so(1));var Or=oo(()=>new ho,so(3));var M=(r,t,e)=>ut(r,t,e),po=Kt,De=Fr,W=(...r)=>no(...r),Ce=r=>Qe(r),re=ro,nr=r=>pi(r),Nr=BigInt(0),lo=BigInt(1);function bt(r,t=""){if(typeof r!="boolean"){let e=t&&`"${t}" `;throw new TypeError(e+"expected boolean, got type="+typeof r)}return r}function Kr(r){if(typeof r=="bigint"){if(!kr(r))throw new RangeError("positive bigint expected, got "+r)}else po(r);return r}function yt(r,t=""){if(typeof r!="number"){let e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof r)}if(!Number.isSafeInteger(r)){let e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+r)}}function or(r){let t=Kr(r).toString(16);return t.length&1?"0"+t:t}function Ii(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);return r===""?Nr:BigInt("0x"+r)}function ne(r){return Ii(Fr(r))}function vt(r){return Ii(Fr(sr(ut(r)).reverse()))}function Mr(r,t){if(Kt(t),t===0)throw new RangeError("zero length");r=Kr(r);let e=r.toString(16);if(e.length>t*2)throw new RangeError("number too large");return Qe(e.padStart(t*2,"0"))}function mo(r,t){return Mr(r,t).reverse()}function Ti(r,t){if(r=M(r),t=M(t),r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function sr(r){return Uint8Array.from(M(r))}function Pr(r){if(typeof r!="string")throw new TypeError("ascii string expected, got "+typeof r);return Uint8Array.from(r,(t,e)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${r[e]}" with code ${n} at position ${e}`);return n})}var kr=r=>typeof r=="bigint"&&Nr<=r;function Su(r,t,e){return kr(r)&&kr(t)&&kr(e)&&t<=r&&r<e}function Le(r,t,e,n){if(!Su(t,e,n))throw new RangeError("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Ue(r){if(r<Nr)throw new Error("expected non-negative bigint, got "+r);let t;for(t=0;r>Nr;r>>=lo,t+=1);return t}var ir=r=>(lo<<BigInt(r))-lo;function Di(r,t,e){if(Kt(r,"hashLen"),Kt(t,"qByteLen"),typeof e!="function")throw new TypeError("hmacFn must be a function");let n=p=>new Uint8Array(p),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,f=n(r),a=n(r),u=0,h=()=>{f.fill(1),a.fill(0),u=0},E=(...p)=>e(a,W(f,...p)),m=(p=o)=>{a=E(s,p),f=E(),p.length!==0&&(a=E(i,p),f=E())},d=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let p=0,b=[];for(;p<t;){f=E();let S=f.slice();b.push(S),p+=f.length}return W(...b)};return(p,b)=>{h(),m(p);let S;for(;(S=b(d()))===void 0;)m();return h(),S}}function xt(r,t={},e={}){if(Object.prototype.toString.call(r)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,c){if(!c&&i!=="function"&&!Object.hasOwn(r,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=r[s];if(c&&f===void 0)return;let a=typeof f;if(a!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${a}`)}let o=(s,i)=>Object.entries(s).forEach(([c,f])=>n(c,f,i));o(t,!1),o(e,!0)}var bo=()=>{throw new Error("not implemented")};var rt=BigInt(0),Z=BigInt(1),oe=BigInt(2),Fi=BigInt(3),Ri=BigInt(4),Oi=BigInt(5),_u=BigInt(7),ki=BigInt(8),vu=BigInt(9),Ni=BigInt(16);function G(r,t){if(t<=rt)throw new Error("mod: expected positive modulus, got "+t);let e=r%t;return e>=rt?e:t+e}function V(r,t,e){if(t<rt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=r;for(;t-- >rt;)n*=n,n%=e;return n}function Ci(r,t){if(r===rt)throw new Error("invert: expected non-zero number");if(t<=rt)throw new Error("invert: expected positive modulus, got "+t);let e=G(r,t),n=t,o=rt,s=Z,i=Z,c=rt;for(;e!==rt;){let a=n/e,u=n-e*a,h=o-i*a,E=s-c*a;n=e,e=u,o=i,s=c,i=h,c=E}if(n!==Z)throw new Error("invert: does not exist");return G(o,t)}function yo(r,t,e){let n=r;if(!n.eql(n.sqr(t),e))throw new Error("Cannot find square root")}function Ki(r,t){let e=r,n=(e.ORDER+Z)/Ri,o=e.pow(t,n);return yo(e,o,t),o}function Au(r,t){let e=r,n=(e.ORDER-Oi)/ki,o=e.mul(t,oe),s=e.pow(o,n),i=e.mul(t,s),c=e.mul(e.mul(i,oe),s),f=e.mul(i,e.sub(c,e.ONE));return yo(e,f,t),f}function Bu(r){let t=Fe(r),e=Mi(r),n=e(t,t.neg(t.ONE)),o=e(t,n),s=e(t,t.neg(n)),i=(r+_u)/Ni;return((c,f)=>{let a=c,u=a.pow(f,i),h=a.mul(u,n),E=a.mul(u,o),m=a.mul(u,s),d=a.eql(a.sqr(h),f),w=a.eql(a.sqr(E),f);u=a.cmov(u,h,d),h=a.cmov(m,E,w);let p=a.eql(a.sqr(h),f),b=a.cmov(u,h,p);return yo(a,b,f),b})}function Mi(r){if(r<Fi)throw new Error("sqrt is not defined for small field");let t=r-Z,e=0;for(;t%oe===rt;)t/=oe,e++;let n=oe,o=Fe(r);for(;Li(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Ki;let s=o.pow(n,t),i=(t+Z)/oe;return function(f,a){let u=f;if(u.is0(a))return a;if(Li(u,a)!==1)throw new Error("Cannot find square root");let h=e,E=u.mul(u.ONE,s),m=u.pow(a,t),d=u.pow(a,i);for(;!u.eql(m,u.ONE);){if(u.is0(m))return u.ZERO;let w=1,p=u.sqr(m);for(;!u.eql(p,u.ONE);)if(w++,p=u.sqr(p),w===h)throw new Error("Cannot find square root");let b=Z<<BigInt(h-w-1),S=u.pow(E,b);h=w,E=u.sqr(S),m=u.mul(m,E),d=u.mul(d,S)}return d}}function Iu(r){return r%Ri===Fi?Ki:r%ki===Oi?Au:r%Ni===vu?Bu(r):Mi(r)}var Rt=(r,t)=>(G(r,t)&Z)===Z,Tu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xo(r){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},e=Tu.reduce((n,o)=>(n[o]="function",n),t);if(xt(r,e),yt(r.BYTES,"BYTES"),yt(r.BITS,"BITS"),r.BYTES<1||r.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(r.ORDER<=Z)throw new Error("invalid field: expected ORDER > 1, got "+r.ORDER);return r}function Du(r,t,e){let n=r;if(e<rt)throw new Error("invalid exponent, negatives unsupported");if(e===rt)return n.ONE;if(e===Z)return t;let o=n.ONE,s=t;for(;e>rt;)e&Z&&(o=n.mul(o,s)),s=n.sqr(s),e>>=Z;return o}function cr(r,t,e=!1){let n=r,o=new Array(t.length).fill(e?n.ZERO:void 0),s=t.reduce((c,f,a)=>n.is0(f)?c:(o[a]=c,n.mul(c,f)),n.ONE),i=n.inv(s);return t.reduceRight((c,f,a)=>n.is0(f)?c:(o[a]=n.mul(c,o[a]),n.mul(c,f)),i),o}function Li(r,t){let e=r,n=(e.ORDER-Z)/oe,o=e.pow(t,n),s=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Cu(r,t){if(t!==void 0&&po(t),r<=rt)throw new Error("invalid n length: expected positive n, got "+r);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let e=Ue(r);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected bit length (${e}) >= n.length (${t})`);let n=t!==void 0?t:e,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Ui=new WeakMap,zr=class{ORDER;BITS;BYTES;isLE;ZERO=rt;ONE=Z;_lengths;_mod;constructor(t,e={}){if(t<=Z)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(n=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));let{nBitLength:o,nByteLength:s}=Cu(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return G(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return rt<=t&&t<this.ORDER}is0(t){return t===rt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Z)===Z}neg(t){return G(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return G(t*t,this.ORDER)}add(t,e){return G(t+e,this.ORDER)}sub(t,e){return G(t-e,this.ORDER)}mul(t,e){return G(t*e,this.ORDER)}pow(t,e){return Du(this,t,e)}div(t,e){return G(t*Ci(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return Ci(t,this.ORDER)}sqrt(t){let e=Ui.get(this);return e||Ui.set(this,e=Iu(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?mo(t,this.BYTES):Mr(t,this.BYTES)}fromBytes(t,e=!1){M(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let a=new Uint8Array(o);a.set(t,s?0:a.length-t.length),t=a}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let f=s?vt(t):ne(t);if(c&&(f=G(f,i)),!e&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return cr(this,t)}cmov(t,e,n){return bt(n,"condition"),n?e:t}};Object.freeze(zr.prototype);function Fe(r,t={}){return new zr(r,t)}function Pi(r){if(typeof r!="bigint")throw new Error("field order must be bigint");if(r<=Z)throw new Error("field order must be greater than 1");let t=Ue(r-Z);return Math.ceil(t/8)}function go(r){let t=Pi(r);return t+Math.ceil(t/2)}function wo(r,t,e=!1){M(r);let n=r.length,o=Pi(t),s=Math.max(go(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?vt(r):ne(r),c=G(i,t-Z)+Z;return e?mo(c,o):Mr(c,o)}var Re=BigInt(0),se=BigInt(1);function ar(r,t){let e=t.negate();return r?e:t}function ie(r,t){let e=cr(r.Fp,t.map(n=>n.Z));return t.map((n,o)=>r.fromAffine(n.toAffine(e[o])))}function Hi(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Eo(r,t){Hi(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=ir(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function zi(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),f=r>>i;c>n&&(c-=s,f+=se);let a=t*n,u=a+Math.abs(c)-1,h=c===0,E=c<0,m=t%2!==0;return{nextN:f,offset:u,isZero:h,isNeg:E,isNegF:m,offsetF:a}}var So=new WeakMap,ji=new WeakMap;function _o(r){return ji.get(r)||1}function qi(r){if(r!==Re)throw new Error("invalid wNAF")}var Oe=class{BASE;ZERO;Fn;bits;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>Re;)e&se&&(n=n.add(o)),o=o.double(),e>>=se;return n}precomputeWindow(t,e){let{windows:n,windowSize:o}=Eo(e,this.bits),s=[],i=t,c=i;for(let f=0;f<n;f++){c=i,s.push(c);for(let a=1;a<o;a++)c=c.add(i),s.push(c);i=c.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=Eo(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:f,offset:a,isZero:u,isNeg:h,isNegF:E,offsetF:m}=zi(n,c,i);n=f,u?s=s.add(ar(E,e[m])):o=o.add(ar(h,e[a]))}return qi(n),{p:o,f:s}}wNAFUnsafe(t,e,n,o=this.ZERO){let s=Eo(t,this.bits);for(let i=0;i<s.windows&&n!==Re;i++){let{nextN:c,offset:f,isZero:a,isNeg:u}=zi(n,i,s);if(n=c,!a){let h=e[f];o=o.add(u?h.negate():h)}}return qi(n),o}getPrecomputes(t,e,n){let o=So.get(e);return o||(o=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(o=n(o)),So.set(e,o))),o}cached(t,e,n){let o=_o(t);return this.wNAF(o,this.getPrecomputes(o,t,n),e)}unsafe(t,e,n,o){let s=_o(t);return s===1?this._unsafeLadder(t,e,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),e,o)}createCache(t,e){Hi(e,this.bits),ji.set(t,e),So.delete(t)}hasCache(t){return _o(t)!==1}};function Zi(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>Re||n>Re;)e&se&&(s=s.add(o)),n&se&&(i=i.add(o)),o=o.double(),e>>=se,n>>=se;return{p1:s,p2:i}}function Vi(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return xo(t),t}else return Fe(r,{isLE:e})}function qr(r,t,e={},n){if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(let f of["p","n","h"]){let a=t[f];if(!(typeof a=="bigint"&&a>Re))throw new Error(`CURVE.${f} must be positive bigint`)}let o=Vi(t.p,e.Fp,n),s=Vi(t.n,e.Fn,n),c=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Vr(r,t){return function(n){let o=r(n);return{secretKey:o,publicKey:t(o)}}}var qt=BigInt(0),tt=BigInt(1),vo=BigInt(2),Lu=BigInt(8);function Uu(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),c=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,c)}function $i(r,t={}){let e=t,n=qr("edwards",r,e,e.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;xt(e,{},{uvRatio:"function"});let f=vo<<BigInt(s.BYTES*8)-tt,a=w=>o.create(w),u=e.uvRatio===void 0?(w,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(w,p))}}catch{return{isValid:!1,value:qt}}}:e.uvRatio;if(!Uu(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function h(w,p,b=!1){let S=b?tt:qt;return Le("coordinate "+w,p,S,f),p}function E(w){if(!(w instanceof m))throw new Error("EdwardsPoint expected")}class m{static BASE=new m(i.Gx,i.Gy,tt,a(i.Gx*i.Gy));static ZERO=new m(qt,tt,tt,qt);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,b,S,_){this.X=h("x",p),this.Y=h("y",b),this.Z=h("z",S,!0),this.T=h("t",_),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof m)throw new Error("extended point not allowed");let{x:b,y:S}=p||{};return h("x",b),h("y",S),new m(b,S,tt,a(b*S))}static fromBytes(p,b=!1){let S=o.BYTES,{a:_,d:T}=i;p=sr(M(p,S,"point")),bt(b,"zip215");let I=sr(p),F=p[S-1];I[S-1]=F&-129;let L=vt(I),B=b?f:o.ORDER;Le("point.y",L,qt,B);let O=a(L*L),z=a(O-tt),k=a(T*O-_),{isValid:l,value:y}=u(z,k);if(!l)throw new Error("bad point: invalid y coordinate");let v=(y&tt)===tt,g=(F&128)!==0;if(!b&&y===qt&&g)throw new Error("bad point: x=0 and x_0=1");return g!==v&&(y=a(-y)),m.fromAffine({x:y,y:L})}static fromHex(p,b=!1){return m.fromBytes(Ce(p),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,b=!0){return d.createCache(this,p),b||this.multiply(vo),this}assertValidity(){let p=this,{a:b,d:S}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:_,Y:T,Z:I,T:F}=p,L=a(_*_),B=a(T*T),O=a(I*I),z=a(O*O),k=a(L*b),l=a(O*a(k+B)),y=a(z+a(S*a(L*B)));if(l!==y)throw new Error("bad point: equation left != right (1)");let v=a(_*T),g=a(I*F);if(v!==g)throw new Error("bad point: equation left != right (2)")}equals(p){E(p);let{X:b,Y:S,Z:_}=this,{X:T,Y:I,Z:F}=p,L=a(b*F),B=a(T*_),O=a(S*F),z=a(I*_);return L===B&&O===z}is0(){return this.equals(m.ZERO)}negate(){return new m(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:p}=i,{X:b,Y:S,Z:_}=this,T=a(b*b),I=a(S*S),F=a(vo*a(_*_)),L=a(p*T),B=b+S,O=a(a(B*B)-T-I),z=L+I,k=z-F,l=L-I,y=a(O*k),v=a(z*l),g=a(O*l),x=a(k*z);return new m(y,v,x,g)}add(p){E(p);let{a:b,d:S}=i,{X:_,Y:T,Z:I,T:F}=this,{X:L,Y:B,Z:O,T:z}=p,k=a(_*L),l=a(T*B),y=a(F*S*z),v=a(I*O),g=a((_+T)*(L+B)-k-l),x=v-y,A=v+y,C=a(l-b*k),D=a(g*x),U=a(A*C),R=a(g*C),K=a(x*A);return new m(D,U,K,R)}subtract(p){return E(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:S}=d.cached(this,p,_=>ie(m,_));return ie(m,[b,S])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===qt?m.ZERO:this.is0()||p===tt?this:d.unsafe(this,p,b=>ie(m,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return d.unsafe(this,i.n).is0()}toAffine(p){let b=this,S=p,{X:_,Y:T,Z:I}=b,F=b.is0();S==null&&(S=F?Lu:o.inv(I));let L=a(_*S),B=a(T*S),O=o.mul(I,S);if(F)return{x:qt,y:tt};if(O!==tt)throw new Error("invZ was invalid");return{x:L,y:B}}clearCofactor(){return c===tt?this:this.multiplyUnsafe(c)}toBytes(){let{x:p,y:b}=this.toAffine(),S=o.toBytes(b);return S[S.length-1]|=p&tt?128:0,S}toHex(){return De(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let d=new Oe(m,s.BITS);return s.BITS>=8&&m.BASE.precompute(8),Object.freeze(m.prototype),Object.freeze(m),m}var Hr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){bo()}static fromHex(t){bo()}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 De(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.ep.precompute(t,e),this}};function Yi(r,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=e;xt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:f}=r,a=n.outputLen,u=2*c.BYTES;if(a!==void 0&&(yt(a,"hash.outputLen"),a!==u))throw new Error(`hash.outputLen must be ${u}, got ${a}`);let h=o.randomBytes===void 0?nr:o.randomBytes,E=o.adjustScalarBytes===void 0?l=>l:o.adjustScalarBytes,m=o.domain===void 0?(l,y,v)=>{if(bt(v,"phflag"),y.length||v)throw new Error("Contexts/pre-hash are not supported");return l}:o.domain;function d(l){return f.create(vt(l))}function w(l){let y=L.secretKey;M(l,L.secretKey,"secretKey");let v=M(n(l),2*y,"hashedSecretKey"),g=E(v.slice(0,y)),x=v.slice(y,2*y),A=d(g);return{head:g,prefix:x,scalar:A}}function p(l){let{head:y,prefix:v,scalar:g}=w(l),x=i.multiply(g),A=x.toBytes();return{head:y,prefix:v,scalar:g,point:x,pointBytes:A}}function b(l){return p(l).pointBytes}function S(l=Uint8Array.of(),...y){let v=W(...y);return d(n(m(v,M(l,void 0,"context"),!!s)))}function _(l,y,v={}){l=M(l,void 0,"message"),s&&(l=s(l));let{prefix:g,scalar:x,pointBytes:A}=p(y),C=S(v.context,g,l),D=i.multiply(C).toBytes(),U=S(v.context,D,A,l),R=f.create(C+U*x);if(!f.isValid(R))throw new Error("sign failed: invalid s");let K=W(D,f.toBytes(R));return M(K,L.signature,"result")}let T={zip215:o.zip215};function I(l,y,v,g=T){let{context:x}=g,A=g.zip215===void 0?!!T.zip215:g.zip215,C=L.signature;l=M(l,C,"signature"),y=M(y,void 0,"message"),v=M(v,L.publicKey,"publicKey"),A!==void 0&&bt(A,"zip215"),s&&(y=s(y));let D=C/2,U=l.subarray(0,D),R=vt(l.subarray(D,C)),K,P,N;try{K=r.fromBytes(v,A),P=r.fromBytes(U,A),N=i.multiplyUnsafe(R)}catch{return!1}if(!A&&K.isSmallOrder())return!1;let X=S(x,U,v,y);return P.add(K.multiplyUnsafe(X)).subtract(N).clearCofactor().is0()}let F=c.BYTES,L={secretKey:F,publicKey:F,signature:2*F,seed:F};function B(l){return l=l===void 0?h(L.seed):l,M(l,L.seed,"seed")}function O(l){return re(l)&&l.length===L.secretKey}function z(l,y){try{return!!r.fromBytes(l,y===void 0?T.zip215:y)}catch{return!1}}let k={getExtendedPublicKey:p,randomSecretKey:B,isValidSecretKey:O,isValidPublicKey:z,toMontgomery(l){let{y}=r.fromBytes(l),v=L.publicKey,g=v===32;if(!g&&v!==57)throw new Error("only defined for 25519 and 448");let x=g?c.div(tt+y,tt-y):c.div(y-tt,y+tt);return c.toBytes(x)},toMontgomerySecret(l){let y=L.secretKey;M(l,y);let v=n(l.subarray(0,y));return E(v).subarray(0,y)}};return Object.freeze(L),Object.freeze(k),Object.freeze({keygen:Vr(B,b),getPublicKey:b,sign:_,verify:I,utils:k,Point:r,lengths:L})}function fr(r,t){if(yt(r),yt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(r<0||r>2**(8*t)-1)throw new Error("invalid I2OSP input: "+r);let e=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)e[n]=r&255,r>>>=8;return new Uint8Array(e)}function Fu(r,t){let e=new Uint8Array(r.length);for(let n=0;n<r.length;n++)e[n]=r[n]^t[n];return e}function Ru(r){if(!re(r)&&typeof r!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof r=="string"?Pr(r):r;if(t.length===0)throw new Error("DST must be non-empty");return t}function Ao(r,t,e,n){M(r),yt(e),t=Ru(t),t.length>255&&(t=n(W(Pr("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(e/o);if(e>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=W(t,fr(t.length,1)),f=new Uint8Array(s),a=fr(e,2),u=new Array(i),h=n(W(f,r,a,fr(0,1),c));u[0]=n(W(h,fr(1,1),c));for(let m=1;m<i;m++){let d=[Fu(h,u[m-1]),fr(m+1,1),c];u[m]=n(W(...d))}return W(...u).slice(0,e)}var Gi="HashToScalar-";var Ou=BigInt(0),Ot=BigInt(1),Xi=BigInt(2);var ku=BigInt(5),Nu=BigInt(8),ke=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Do={p:ke,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Nu,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ku(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=ke,c=r*r%s*r%s,f=V(c,Xi,s)*c%s,a=V(f,Ot,s)*r%s,u=V(a,ku,s)*a%s,h=V(u,t,s)*u%s,E=V(h,e,s)*h%s,m=V(E,n,s)*E%s,d=V(m,o,s)*m%s,w=V(d,o,s)*m%s,p=V(w,t,s)*u%s;return{pow_p_5_8:V(p,Xi,s)*r%s,b2:c}}function Mu(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var Bo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Co(r,t){let e=ke,n=G(t*t*t,e),o=G(n*n*t,e),s=Ku(r*o).pow_p_5_8,i=G(r*n*s,e),c=G(t*i*i,e),f=i,a=G(i*Bo,e),u=c===r,h=c===G(-r,e),E=c===G(-r*Bo,e);return u&&(i=f),(h||E)&&(i=a),Rt(i,e)&&(i=G(-i,e)),{isValid:u||h,value:i}}var Ht=$i(Do,{uvRatio:Co}),Vt=Ht.Fp,Qi=Ht.Fn;function Pu(r){return Yi(Ht,Or,Object.assign({adjustScalarBytes:Mu,zip215:!0},r))}var tc=Pu({});var Io=Bo,zu=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),qu=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Vu=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Hu=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Wi=r=>Co(Ot,r),ju=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),To=r=>Vt.create(vt(r)&ju);function Ji(r){let{d:t}=Do,e=ke,n=b=>Vt.create(b),o=n(Io*r*r),s=n((o+Ot)*Vu),i=BigInt(-1),c=n((i-t*o)*n(o+t)),{isValid:f,value:a}=Co(s,c),u=n(a*r);Rt(u,e)||(u=n(-u)),f||(a=u),f||(i=o);let h=n(i*(o-Ot)*Hu-c),E=a*a,m=n((a+a)*c),d=n(h*zu),w=n(Ot-E),p=n(Ot+E);return new Ht(n(m*p),n(w*d),n(d*p),n(m*w))}var jt=class r extends Hr{static BASE=new r(Ht.BASE);static ZERO=new r(Ht.ZERO);static Fp=Vt;static Fn=Qi;constructor(t){super(t)}static fromAffine(t){return new r(Ht.fromAffine(t))}assertSame(t){if(!(t instanceof r))throw new Error("RistrettoPoint expected")}init(t){return new r(t)}static fromBytes(t){ut(t,32);let{a:e,d:n}=Do,o=ke,s=T=>Vt.create(T),i=To(t);if(!Ti(Vt.toBytes(i),t)||Rt(i,o))throw new Error("invalid ristretto255 encoding 1");let c=s(i*i),f=s(Ot+e*c),a=s(Ot-e*c),u=s(f*f),h=s(a*a),E=s(e*n*u-h),{isValid:m,value:d}=Wi(s(E*h)),w=s(d*a),p=s(d*w*E),b=s((i+i)*w);Rt(b,o)&&(b=s(-b));let S=s(f*p),_=s(b*S);if(!m||Rt(_,o)||S===Ou)throw new Error("invalid ristretto255 encoding 2");return new r(new Ht(b,S,Ot,_))}static fromHex(t){return r.fromBytes(Qe(t))}toBytes(){let{X:t,Y:e,Z:n,T:o}=this.ep,s=ke,i=p=>Vt.create(p),c=i(i(n+e)*i(n-e)),f=i(t*e),a=i(f*f),{value:u}=Wi(i(c*a)),h=i(u*c),E=i(u*f),m=i(h*E*o),d;if(Rt(o*m,s)){let p=i(e*Io),b=i(t*Io);t=p,e=b,d=i(h*qu)}else d=E;Rt(t*m,s)&&(e=i(-e));let w=i((n-e)*d);return Rt(w,s)&&(w=i(-w)),Vt.toBytes(w)}equals(t){this.assertSame(t);let{X:e,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=a=>Vt.create(a),c=i(e*s)===i(n*o),f=i(n*s)===i(e*o);return c||f}is0(){return this.equals(r.ZERO)}};Object.freeze(jt.BASE);Object.freeze(jt.ZERO);Object.freeze(jt.prototype);Object.freeze(jt);var Zu=Object.freeze({Point:jt,hashToCurve(r,t){let e=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=Ao(r,e,64,Or);return Zu.deriveToCurve(n)},hashToScalar(r,t={DST:Gi}){let e=Ao(r,t.DST,64,Or);return Qi.create(vt(e))},deriveToCurve(r){ut(r,64);let t=To(r.subarray(0,32)),e=Ji(t),n=To(r.subarray(32,64)),o=Ji(n);return new jt(e.add(o))}});var ur=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},jr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Zr={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new jr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var $r=32;var Lo,$u=(async()=>{try{return await Zr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Yu(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await Zr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Zr.get().subtle.verify({name:"Ed25519"},n,ge(t),ge(e instanceof Uint8Array?e:e.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Gu(r,t,e){return tc.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function ec(r,t,e){return Lo==null&&(Lo=await $u),Lo?Yu(r,t,e):Gu(r,t,e)}function Yr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Gr=class{type="Ed25519";raw;constructor(t){this.raw=Uo(t,$r)}toMultihash(){return dt.digest(Ie(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Y.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=ec(this.raw,e,t);return Yr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function nc(r){return r=Uo(r,$r),new Gr(r)}function Uo(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 Wu=Math.pow(2,7),Ju=Math.pow(2,14),Qu=Math.pow(2,21),oc=Math.pow(2,28),sc=Math.pow(2,35),ic=Math.pow(2,42),cc=Math.pow(2,49),st=128,Zt=127;function hr(r){if(r<Wu)return 1;if(r<Ju)return 2;if(r<Qu)return 3;if(r<oc)return 4;if(r<sc)return 5;if(r<ic)return 6;if(r<cc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ac(r,t,e=0){switch(hr(r)){case 8:t[e++]=r&255|st,r/=128;case 7:t[e++]=r&255|st,r/=128;case 6:t[e++]=r&255|st,r/=128;case 5:t[e++]=r&255|st,r/=128;case 4:t[e++]=r&255|st,r>>>=7;case 3:t[e++]=r&255|st,r>>>=7;case 2:t[e++]=r&255|st,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function fc(r,t){let e=r[t],n=0;if(n+=e&Zt,e<st||(e=r[t+1],n+=(e&Zt)<<7,e<st)||(e=r[t+2],n+=(e&Zt)<<14,e<st)||(e=r[t+3],n+=(e&Zt)<<21,e<st)||(e=r[t+4],n+=(e&Zt)*oc,e<st)||(e=r[t+5],n+=(e&Zt)*sc,e<st)||(e=r[t+6],n+=(e&Zt)*ic,e<st)||(e=r[t+7],n+=(e&Zt)*cc,e<st))return n;throw new RangeError("Could not decode varint")}var Fo=new Float32Array([-0]),$t=new Uint8Array(Fo.buffer);function uc(r,t,e){Fo[0]=r,t[e]=$t[0],t[e+1]=$t[1],t[e+2]=$t[2],t[e+3]=$t[3]}function hc(r,t){return $t[0]=r[t],$t[1]=r[t+1],$t[2]=r[t+2],$t[3]=r[t+3],Fo[0]}var Ro=new Float64Array([-0]),ot=new Uint8Array(Ro.buffer);function lc(r,t,e){Ro[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3],t[e+4]=ot[4],t[e+5]=ot[5],t[e+6]=ot[6],t[e+7]=ot[7]}function dc(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],ot[4]=r[t+4],ot[5]=r[t+5],ot[6]=r[t+6],ot[7]=r[t+7],Ro[0]}var th=BigInt(Number.MAX_SAFE_INTEGER),eh=BigInt(Number.MIN_SAFE_INTEGER),ht=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ce;if(t<th&&t>eh)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>pc&&(o=0n,++n>pc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ce;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ce}},ce=new ht(0,0);ce.toBigInt=function(){return 0n};ce.zzEncode=ce.zzDecode=function(){return this};ce.length=function(){return 1};var pc=4294967296n;function mc(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 bc(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Oo(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 gt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Xr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ko=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,gt(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 gt(this,4);return Xr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw gt(this,4);return Xr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw gt(this,4);let t=hc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw gt(this,4);let t=dc(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 gt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return bc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw gt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw gt(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 ht(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 gt(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 gt(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 gt(this,8);let t=Xr(this.buf,this.pos+=4),e=Xr(this.buf,this.pos+=4);return new ht(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=fc(this.buf,this.pos);return this.pos+=hr(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 lr(r){return new ko(r instanceof Uint8Array?r:r.subarray())}function Wr(r,t,e){let n=lr(r);return t.decode(n,void 0,e)}function ae(r=0){return new Uint8Array(r)}var No={};q(No,{base10:()=>rh});var rh=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var Ko={};q(Ko,{base16:()=>nh,base16upper:()=>oh});var nh=H({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),oh=H({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mo={};q(Mo,{base2:()=>sh});var sh=H({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Po={};q(Po,{base256emoji:()=>uh});var xc=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}"),ih=xc.reduce((r,t,e)=>(r[e]=t,r),[]),ch=xc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function ah(r){return r.reduce((t,e)=>(t+=ih[e],t),"")}function fh(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=ch[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var uh=de({prefix:"\u{1F680}",name:"base256emoji",encode:ah,decode:fh});var zo={};q(zo,{base64:()=>hh,base64pad:()=>lh,base64url:()=>dh,base64urlpad:()=>ph});var hh=H({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),lh=H({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dh=H({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ph=H({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qo={};q(qo,{base8:()=>mh});var mh=H({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vo={};q(Vo,{identity:()=>bh});var bh=de({prefix:"\0",name:"identity",encode:r=>ws(r),decode:r=>gs(r)});var y0=new TextEncoder,x0=new TextDecoder;var Zo={};q(Zo,{sha256:()=>dr,sha512:()=>wh});var gh=20;function jo({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new Ho(r,t,e,n,o)}var Ho=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??gh,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?gc(n,this.code,e?.truncate):n.then(o=>gc(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function gc(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return xe(t,r)}function Ec(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var dr=jo({name:"sha2-256",code:18,encode:Ec("SHA-256")}),wh=jo({name:"sha2-512",code:19,encode:Ec("SHA-512")});var $o={...Vo,...Mo,...qo,...No,...Ko,...En,...Sn,...wn,...zo,...Po},C0={...Zo,...An};function _c(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Sc=_c("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yo=_c("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=ae(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Eh={utf8:Sc,"utf-8":Sc,hex:$o.base16,latin1:Yo,ascii:Yo,binary:Yo,...$o},vc=Eh;function Ac(r,t="utf8"){let e=vc[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Go(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ae(i);o+i>t&&(n=ae(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var fe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Xo(){}var Jo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Sh=Go();function _h(r){return globalThis.Buffer!=null?ae(r):Sh(r)}var mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new fe(Xo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new fe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Qo((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(Jr,10,ht.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ht.fromBigInt(t);return this._push(Jr,e.length(),e)}uint64Number(t){return this._push(ac,hr(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=ht.fromBigInt(t).zzEncode();return this._push(Jr,e.length(),e)}sint64Number(t){let e=ht.fromNumber(t).zzEncode();return this._push(Jr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Wo,1,t?1:0)}fixed32(t){return this._push(pr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ht.fromBigInt(t);return this._push(pr,4,e.lo)._push(pr,4,e.hi)}fixed64Number(t){let e=ht.fromNumber(t);return this._push(pr,4,e.lo)._push(pr,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(uc,4,t)}double(t){return this._push(lc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Wo,1,0):this.uint32(e)._push(Ah,e,t)}string(t){let e=mc(t);return e!==0?this.uint32(e)._push(Oo,e,t):this._push(Wo,1,0)}fork(){return this.states=new Jo(this),this.head=this.tail=new fe(Xo,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 fe(Xo,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=_h(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Wo(r,t,e){t[e]=r&255}function vh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Qo=class extends fe{next;constructor(t,e){super(vh,t,e),this.next=void 0}};function Jr(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 pr(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 Ah(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(mr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Bh,t,r),this},mr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Ih,t,r),this});function Bh(r,t,e){t.set(r,e)}function Ih(r,t,e){r.length<40?Oo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Ac(r),e)}function ts(){return new mr}function Qr(r,t){let e=ts();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}function*tn(r,t,e){let n=lr(r);yield*t.stream(n,void 0,"$",e)}var en={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function rn(r,t,e,n,o){return{name:r,type:t,encode:e,decode:n,stream:o}}function es(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return rn("enum",en.VARINT,e,n,o)}function nn(r,t,e){return rn("message",en.LENGTH_DELIMITED,r,t,e)}var it;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(it||(it={}));var rs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(rs||(rs={}));(function(r){r.codec=()=>es(rs)})(it||(it={}));var br;(function(r){let t;r.codec=()=>(t==null&&(t=nn((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),it.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=it.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:it.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Qr(s,r.codec())}r.encode=e;function n(s,i){return Wr(s,r.codec(),i)}r.decode=n;function o(s,i){return tn(s,r.codec(),i)}r.stream=o})(br||(br={}));var ns;(function(r){let t;r.codec=()=>(t==null&&(t=nn((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),it.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=it.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:it.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Qr(s,r.codec())}r.encode=e;function n(s,i){return Wr(s,r.codec(),i)}r.decode=n;function o(s,i){return tn(s,r.codec(),i)}r.stream=o})(ns||(ns={}));var on=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(Cr(t),ut(e,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(e.length>n?t.create().update(e).digest():e);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ut(o)}update(t){return Te(this),this.iHash.update(t),this}digestInto(t){Te(this),Lr(t,this),this.finished=!0;let e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Bc=(()=>{let r=((t,e,n)=>new on(t,e).update(n).digest());return r.create=(t,e)=>new on(t,e),r})();var Ic=(r,t)=>(r+(r>=0?t:-t)/Tc)/t;function Dh(r,t,e){Le("scalar",r,At,e);let[[n,o],[s,i]]=t,c=Ic(i*r,e),f=Ic(-o*r,e),a=r-c*n-f*s,u=-c*o-f*i,h=a<At,E=u<At;h&&(a=-a),E&&(u=-u);let m=ir(Math.ceil(Ue(e)/2))+Yt;if(a<At||a>=m||u<At||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:a,k2neg:E,k2:u}}function ss(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function os(r,t){xt(r);let e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return bt(e.lowS,"lowS"),bt(e.prehash,"prehash"),e.format!==void 0&&ss(e.format),e}var is=class extends Error{constructor(t=""){super(t)}},wt={Err:is,_tlv:{encode:(r,t)=>{let{Err:e}=wt;if(yt(r,"tag"),r<0||r>255)throw new e("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=or(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?or(o.length/2|128):"";return or(r)+s+o+t},decode(r,t){let{Err:e}=wt;t=M(t,void 0,"DER data");let n=0;if(r<0||r>255)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new e("tlv.decode(long): indefinite length not supported");if(f>4)throw new e("tlv.decode(long): byte length is too big");let a=t.subarray(n,n+f);if(a.length!==f)throw new e("tlv.decode: length bytes not complete");if(a[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of a)i=i<<8|u;if(n+=f,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=wt;if(Kr(r),r<At)throw new t("integer: negative integers are not allowed");let e=or(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}=wt;if(r.length<1)throw new t("invalid signature integer: empty");if(r[0]&128)throw new t("invalid signature integer: negative");if(r.length>1&&r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ne(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=wt,o=M(r,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:f}=n.decode(2,s),{v:a,l:u}=n.decode(2,f);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(a)}},hexFromSig(r){let{_tlv:t,_int:e}=wt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};Object.freeze(wt._tlv);Object.freeze(wt._int);Object.freeze(wt);var At=BigInt(0),Yt=BigInt(1),Tc=BigInt(2),sn=BigInt(3),Ch=BigInt(4);function Dc(r,t={}){let e=qr("weierstrass",r,t),n=e.Fp,o=e.Fn,s=e.CURVE,{h:i,n:c}=s;xt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:a}=t;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=Lc(n,o);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(k,l,y){if(a&&l.is0())return Uint8Array.of(0);let{x:v,y:g}=l.toAffine(),x=n.toBytes(v);if(bt(y,"isCompressed"),y){h();let A=!n.isOdd(g);return W(Cc(A),x)}else return W(Uint8Array.of(4),x,n.toBytes(g))}function m(k){M(k,void 0,"Point");let{publicKey:l,publicKeyUncompressed:y}=u,v=k.length,g=k[0],x=k.subarray(1);if(a&&v===1&&g===0)return{x:n.ZERO,y:n.ZERO};if(v===l&&(g===2||g===3)){let A=n.fromBytes(x);if(!n.isValid(A))throw new Error("bad point: is not on curve, wrong x");let C=p(A),D;try{D=n.sqrt(C)}catch(K){let P=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+P)}h();let U=n.isOdd(D);return(g&1)===1!==U&&(D=n.neg(D)),{x:A,y:D}}else if(v===y&&g===4){let A=n.BYTES,C=n.fromBytes(x.subarray(0,A)),D=n.fromBytes(x.subarray(A,A*2));if(!b(C,D))throw new Error("bad point: is not on curve");return{x:C,y:D}}else throw new Error(`bad point: got length ${v}, expected compressed=${l} or uncompressed=${y}`)}let d=t.toBytes===void 0?E:t.toBytes,w=t.fromBytes===void 0?m:t.fromBytes;function p(k){let l=n.sqr(k),y=n.mul(l,k);return n.add(n.add(y,n.mul(k,s.a)),s.b)}function b(k,l){let y=n.sqr(l),v=p(k);return n.eql(y,v)}if(!b(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(s.a,sn),Ch),_=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(S,_)))throw new Error("bad curve params: a or b");function T(k,l,y=!1){if(!n.isValid(l)||y&&n.is0(l))throw new Error(`bad point coordinate ${k}`);return l}function I(k){if(!(k instanceof B))throw new Error("Weierstrass Point expected")}function F(k){if(!f||!f.basises)throw new Error("no endo");return Dh(k,f.basises,o.ORDER)}function L(k,l,y,v,g){return y=new B(n.mul(y.X,k),y.Y,y.Z),l=ar(v,l),y=ar(g,y),l.add(y)}class B{static BASE=new B(s.Gx,s.Gy,n.ONE);static ZERO=new B(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(l,y,v){this.X=T("x",l),this.Y=T("y",y,!0),this.Z=T("z",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(l){let{x:y,y:v}=l||{};if(!l||!n.isValid(y)||!n.isValid(v))throw new Error("invalid affine point");if(l instanceof B)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(v)?B.ZERO:new B(y,v,n.ONE)}static fromBytes(l){let y=B.fromAffine(w(M(l,void 0,"point")));return y.assertValidity(),y}static fromHex(l){return B.fromBytes(Ce(l))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(l=8,y=!0){return z.createCache(this,l),y||this.multiply(sn),this}assertValidity(){let l=this;if(l.is0()){if(t.allowInfinityPoint&&n.is0(l.X)&&n.eql(l.Y,n.ONE)&&n.is0(l.Z))return;throw new Error("bad point: ZERO")}let{x:y,y:v}=l.toAffine();if(!n.isValid(y)||!n.isValid(v))throw new Error("bad point: x or y not field elements");if(!b(y,v))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:l}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(l)}equals(l){I(l);let{X:y,Y:v,Z:g}=this,{X:x,Y:A,Z:C}=l,D=n.eql(n.mul(y,C),n.mul(x,g)),U=n.eql(n.mul(v,C),n.mul(A,g));return D&&U}negate(){return new B(this.X,n.neg(this.Y),this.Z)}double(){let{a:l,b:y}=s,v=n.mul(y,sn),{X:g,Y:x,Z:A}=this,C=n.ZERO,D=n.ZERO,U=n.ZERO,R=n.mul(g,g),K=n.mul(x,x),P=n.mul(A,A),N=n.mul(g,x);return N=n.add(N,N),U=n.mul(g,A),U=n.add(U,U),C=n.mul(l,U),D=n.mul(v,P),D=n.add(C,D),C=n.sub(K,D),D=n.add(K,D),D=n.mul(C,D),C=n.mul(N,C),U=n.mul(v,U),P=n.mul(l,P),N=n.sub(R,P),N=n.mul(l,N),N=n.add(N,U),U=n.add(R,R),R=n.add(U,R),R=n.add(R,P),R=n.mul(R,N),D=n.add(D,R),P=n.mul(x,A),P=n.add(P,P),R=n.mul(P,N),C=n.sub(C,R),U=n.mul(P,K),U=n.add(U,U),U=n.add(U,U),new B(C,D,U)}add(l){I(l);let{X:y,Y:v,Z:g}=this,{X:x,Y:A,Z:C}=l,D=n.ZERO,U=n.ZERO,R=n.ZERO,K=s.a,P=n.mul(s.b,sn),N=n.mul(y,x),X=n.mul(v,A),J=n.mul(g,C),Q=n.add(y,v),$=n.add(x,A);Q=n.mul(Q,$),$=n.add(N,X),Q=n.sub(Q,$),$=n.add(y,g);let ct=n.add(x,C);return $=n.mul($,ct),ct=n.add(N,J),$=n.sub($,ct),ct=n.add(v,g),D=n.add(A,C),ct=n.mul(ct,D),D=n.add(X,J),ct=n.sub(ct,D),R=n.mul(K,$),D=n.mul(P,J),R=n.add(D,R),D=n.sub(X,R),R=n.add(X,R),U=n.mul(D,R),X=n.add(N,N),X=n.add(X,N),J=n.mul(K,J),$=n.mul(P,$),X=n.add(X,J),J=n.sub(N,J),J=n.mul(K,J),$=n.add($,J),N=n.mul(X,$),U=n.add(U,N),N=n.mul(ct,$),D=n.mul(Q,D),D=n.sub(D,N),N=n.mul(Q,X),R=n.mul(ct,R),R=n.add(R,N),new B(D,U,R)}subtract(l){return I(l),this.add(l.negate())}is0(){return this.equals(B.ZERO)}multiply(l){let{endo:y}=t;if(!o.isValidNot0(l))throw new RangeError("invalid scalar: out of range");let v,g,x=A=>z.cached(this,A,C=>ie(B,C));if(y){let{k1neg:A,k1:C,k2neg:D,k2:U}=F(l),{p:R,f:K}=x(C),{p:P,f:N}=x(U);g=K.add(N),v=L(y.beta,R,P,A,D)}else{let{p:A,f:C}=x(l);v=A,g=C}return ie(B,[v,g])[0]}multiplyUnsafe(l){let{endo:y}=t,v=this,g=l;if(!o.isValid(g))throw new RangeError("invalid scalar: out of range");if(g===At||v.is0())return B.ZERO;if(g===Yt)return v;if(z.hasCache(this))return this.multiply(g);if(y){let{k1neg:x,k1:A,k2neg:C,k2:D}=F(g),{p1:U,p2:R}=Zi(B,v,A,D);return L(y.beta,U,R,x,C)}else return z.unsafe(v,g)}toAffine(l){let y=this,v=l,{X:g,Y:x,Z:A}=y;if(n.eql(A,n.ONE))return{x:g,y:x};let C=y.is0();v==null&&(v=C?n.ONE:n.inv(A));let D=n.mul(g,v),U=n.mul(x,v),R=n.mul(A,v);if(C)return{x:n.ZERO,y:n.ZERO};if(!n.eql(R,n.ONE))throw new Error("invZ was invalid");return{x:D,y:U}}isTorsionFree(){let{isTorsionFree:l}=t;return i===Yt?!0:l?l(B,this):z.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:l}=t;return i===Yt?this:l?l(B,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===Yt?this.is0():this.clearCofactor().is0()}toBytes(l=!0){return bt(l,"isCompressed"),this.assertValidity(),d(B,this,l)}toHex(l=!0){return De(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let O=o.BITS,z=new Oe(B,t.endo?Math.ceil(O/2):O);return O>=8&&B.BASE.precompute(8),Object.freeze(B.prototype),Object.freeze(B),B}function Cc(r){return Uint8Array.of(r?2:3)}function Lc(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Lh(r,t={}){let{Fn:e}=r,n=t.randomBytes===void 0?nr:t.randomBytes,o=Object.assign(Lc(r.Fp,e),{seed:Math.max(go(e.ORDER),16)});function s(m){try{let d=e.fromBytes(m);return e.isValidNot0(d)}catch{return!1}}function i(m,d){let{publicKey:w,publicKeyUncompressed:p}=o;try{let b=m.length;return d===!0&&b!==w||d===!1&&b!==p?!1:!!r.fromBytes(m)}catch{return!1}}function c(m){return m=m===void 0?n(o.seed):m,wo(M(m,o.seed,"seed"),e.ORDER)}function f(m,d=!0){return r.BASE.multiply(e.fromBytes(m)).toBytes(d)}function a(m){let{secretKey:d,publicKey:w,publicKeyUncompressed:p}=o,b=e._lengths;if(!re(m))return;let S=M(m,void 0,"key").length,_=S===w||S===p,T=S===d||!!b?.includes(S);if(!(_&&T))return _}function u(m,d,w=!0){if(a(m)===!0)throw new Error("first arg must be private key");if(a(d)===!1)throw new Error("second arg must be public key");let p=e.fromBytes(m);return r.fromBytes(d).multiply(p).toBytes(w)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},E=Vr(c,f);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:E,Point:r,utils:h,lengths:o})}function Uc(r,t,e={}){let n=t;Cr(n),xt(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),e=Object.assign({},e);let o=e.randomBytes===void 0?nr:e.randomBytes,s=e.hmac===void 0?(g,x)=>Bc(n,g,x):e.hmac,{Fp:i,Fn:c}=r,{ORDER:f,BITS:a}=c,{keygen:u,getPublicKey:h,getSharedSecret:E,utils:m,lengths:d}=Lh(r,e),w={prehash:!0,lowS:typeof e.lowS=="boolean"?e.lowS:!0,format:"compact",extraEntropy:!1},p=f*Tc+Yt<i.ORDER;function b(g){let x=f>>Yt;return g>x}function S(g,x){if(!c.isValidNot0(x))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return x}function _(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function T(g,x){ss(x);let A=d.signature,C=x==="compact"?A:x==="recovered"?A+1:void 0;return M(g,C)}class I{r;s;recovery;constructor(x,A,C){if(this.r=S("r",x),this.s=S("s",A),C!=null){if(_(),![0,1,2,3].includes(C))throw new Error("invalid recovery id");this.recovery=C}Object.freeze(this)}static fromBytes(x,A=w.format){T(x,A);let C;if(A==="der"){let{r:K,s:P}=wt.toSig(M(x));return new I(K,P)}A==="recovered"&&(C=x[0],A="compact",x=x.subarray(1));let D=d.signature/2,U=x.subarray(0,D),R=x.subarray(D,D*2);return new I(c.fromBytes(U),c.fromBytes(R),C)}static fromHex(x,A){return this.fromBytes(Ce(x),A)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new I(this.r,this.s,x)}recoverPublicKey(x){let{r:A,s:C}=this,D=this.assertRecovery(),U=D===2||D===3?A+f:A;if(!i.isValid(U))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let R=i.toBytes(U),K=r.fromBytes(W(Cc((D&1)===0),R)),P=c.inv(U),N=L(M(x,void 0,"msgHash")),X=c.create(-N*P),J=c.create(C*P),Q=r.BASE.multiplyUnsafe(X).add(K.multiplyUnsafe(J));if(Q.is0())throw new Error("invalid recovery: point at infinify");return Q.assertValidity(),Q}hasHighS(){return b(this.s)}toBytes(x=w.format){if(ss(x),x==="der")return Ce(wt.hexFromSig(this));let{r:A,s:C}=this,D=c.toBytes(A),U=c.toBytes(C);return x==="recovered"?(_(),W(Uint8Array.of(this.assertRecovery()),D,U)):W(D,U)}toHex(x){return De(this.toBytes(x))}}Object.freeze(I.prototype),Object.freeze(I);let F=e.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let A=ne(x),C=x.length*8-a;return C>0?A>>BigInt(C):A}:e.bits2int,L=e.bits2int_modN===void 0?function(x){return c.create(F(x))}:e.bits2int_modN,B=ir(a);function O(g){return Le("num < 2^"+a,g,At,B),c.toBytes(g)}function z(g,x){return M(g,void 0,"message"),x?M(n(g),void 0,"prehashed message"):g}function k(g,x,A){let{lowS:C,prehash:D,extraEntropy:U}=os(A,w);g=z(g,D);let R=L(g),K=c.fromBytes(x);if(!c.isValidNot0(K))throw new Error("invalid private key");let P=[O(K),O(R)];if(U!=null&&U!==!1){let Q=U===!0?o(d.secretKey):U;P.push(M(Q,void 0,"extraEntropy"))}let N=W(...P),X=R;function J(Q){let $=F(Q);if(!c.isValidNot0($))return;let ct=c.inv($),le=r.BASE.multiply($).toAffine(),Ke=c.create(le.x);if(Ke===At)return;let Er=c.create(ct*c.create(X+Ke*K));if(Er===At)return;let bs=(le.x===Ke?0:2)|Number(le.y&Yt),ys=Er;return C&&b(Er)&&(ys=c.neg(Er),bs^=1),new I(Ke,ys,p?void 0:bs)}return{seed:N,k2sig:J}}function l(g,x,A={}){let{seed:C,k2sig:D}=k(g,x,A);return Di(n.outputLen,c.BYTES,s)(C,D).toBytes(A.format)}function y(g,x,A,C={}){let{lowS:D,prehash:U,format:R}=os(C,w);if(A=M(A,void 0,"publicKey"),x=z(x,U),!re(g)){let K=g instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}T(g,R);try{let K=I.fromBytes(g,R),P=r.fromBytes(A);if(D&&K.hasHighS())return!1;let{r:N,s:X}=K,J=L(x),Q=c.inv(X),$=c.create(J*Q),ct=c.create(N*Q),le=r.BASE.multiplyUnsafe($).add(P.multiplyUnsafe(ct));return le.is0()?!1:c.create(le.x)===N}catch{return!1}}function v(g,x,A={}){let{prehash:C}=os(A,w);return x=z(x,C),I.fromBytes(g,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:u,getPublicKey:h,getSharedSecret:E,utils:m,lengths:d,Point:r,sign:l,verify:y,recoverPublicKey:v,Signature:I,hash:n})}var as={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Uh={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Fc=BigInt(2);function Fh(r){let t=as.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),a=r*r*r%t,u=a*a*r%t,h=V(u,e,t)*u%t,E=V(h,e,t)*u%t,m=V(E,Fc,t)*a%t,d=V(m,o,t)*m%t,w=V(d,s,t)*d%t,p=V(w,c,t)*w%t,b=V(p,f,t)*p%t,S=V(b,c,t)*w%t,_=V(S,e,t)*u%t,T=V(_,i,t)*d%t,I=V(T,n,t)*a%t,F=V(I,Fc,t);if(!cs.eql(cs.sqr(F),r))throw new Error("Cannot find square root");return F}var cs=Fe(as.p,{sqrt:Fh}),Rh=Dc(as,{Fp:cs,endo:Uh}),Ne=Uc(Rh,Bi);function Rc(r,t,e,n){let o=dr.digest(e instanceof Uint8Array?e:e.subarray());if(Yr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ne.verify(t,s,r,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new ur(String(s))});try{return n?.signal?.throwIfAborted(),Ne.verify(t,o.digest,r,{prehash:!1,format:"der"})}catch(s){throw new ur(String(s))}}var cn=class{type="secp256k1";raw;_key;constructor(t){this._key=kc(t),this.raw=Oc(this._key)}toMultihash(){return dt.digest(Ie(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Y.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 Rc(this._key,e,t,n)}};function Nc(r){return new cn(r)}function Oc(r){return Ne.Point.fromBytes(r).toBytes()}function kc(r){try{return Ne.Point.fromBytes(r),r}catch(t){throw new Sr(String(t))}}function Kc(r){let{Type:t,Data:e}=br.decode(r.digest),n=e??new Uint8Array;switch(t){case it.Ed25519:return nc(n);case it.secp256k1:return Nc(n);case it.ECDSA:return fi(n);default:throw new Me}}function Ie(r){return br.encode({Type:it[r.type],Data:r.raw})}var Mc=Symbol.for("nodejs.util.inspect.custom"),Oh=114,yr=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()})`}[mn]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return at.createV1(Oh,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")}[Mc](){return`PeerId(${this.toString()})`}},an=class extends yr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},fn=class extends yr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},un=class extends yr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},kh=2336,hn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=dt.digest(nt(this.url))}[Mc](){return`PeerId(${this.url})`}[mn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return at.createV1(kh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=lt(t)),t.toString()===this.toString())}};function Pc(r){if(Kh(r))return new an({multihash:r});if(Nh(r))try{let t=Kc(r);if(t.type==="Ed25519")return new fn({multihash:r,publicKey:t});if(t.type==="secp256k1")return new un({multihash:r,publicKey:t})}catch{let e=lt(r.digest);return new hn(new URL(e))}throw new _r("Supplied PeerID Multihash is invalid")}function Nh(r){return r.code===dt.code}function Kh(r){return r.code===dr.code}function Bt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function ln(r){let t=Ve(Y.decode(`z${r}`));return Pc(t)}var Gt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return Bt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return Bt(this.map.values(),t=>t.key)}values(){return Bt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function zc(){return new Gt}var Xt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return Bt(this.set.entries(),t=>{let e=ln(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=ln(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return Bt(this.set.values(),t=>ln(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function qc(){return new Xt}var Wt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return Bt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return Bt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function Vc(){return new Wt}var fs={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Hc={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},jc=new globalThis.TextEncoder;function Mh(r,t){let e=fs[t],n=Hc[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Ph(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=fs[t],o=Hc[t],s=r;for(;s.length>0;){let i=jc.encodeInto(s,e);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(e[c]),o=BigInt.asUintN(t,o*n)}return o}function us(r,{size:t=32,utf8Buffer:e}={}){if(!fs[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Ph(r,t,e);r=jc.encode(r)}return Mh(r,t)}var xr={hash:r=>Number(us(r,{size:32})),hashV:(r,t)=>zh(xr.hash(r,t))};function zh(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),nt(t,"base16")}var hs=64,Et=class{fp;h;seed;constructor(t,e,n,o=2){if(o>hs)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=ni(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?pt(this.fp,t.fp):!1}};function ue(r,t){return Math.floor(Math.random()*(t-r))+r}var he=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");let e=ue(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var qh=500,gr=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??xr,this.seed=t.seed??ue(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=nt(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new he(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new he(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[ue(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new he(this.bucketSize));for(let c=0;c<qh;c++){let f=this.buckets[i].swap(e);if(f!=null&&(i=(i^f.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new he(this.bucketSize)),this.buckets[i].add(f)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=nt(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=nt(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Vh={1:.5,2:.84,4:.95,8:.98};function Hh(r=.001){return r>.002?2:r>1e-5?4:8}function Zc(r,t=.001){let e=Hh(t),n=Vh[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),hs);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var dn=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??xr,this.seed=t.seed??ue(0,Math.pow(2,10)),this.filterSeries=[new gr({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=nt(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new gr({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=nt(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=nt(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function ls(r,t=.001,e){return new dn({...Zc(r,t),...e??{}})}var wr=class{filter;constructor(t,e){this.filter=ls(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function $c(r,t=.001){return new wr(r,t)}var ds=class extends Gt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Yc(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ds({name:t,metrics:e}):n=new Gt,n}var ps=class extends Xt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Gc(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ps({name:t,metrics:e}):n=new Xt,n}var ms=class extends Wt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function Xc(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ms({name:t,metrics:e}):n=new Wt,n}return ea(jh);})();
2
+ "use strict";var Libp2PPeerCollections=(()=>{var pn=Object.defineProperty;var Wc=Object.getOwnPropertyDescriptor;var Jc=Object.getOwnPropertyNames;var Qc=Object.prototype.hasOwnProperty;var q=(r,t)=>{for(var e in t)pn(r,e,{get:t[e],enumerable:!0})},ta=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jc(t))!Qc.call(r,o)&&o!==e&&pn(r,o,{get:()=>t[o],enumerable:!(n=Wc(t,o))||n.enumerable});return r};var ea=r=>ta(pn({},"__esModule",{value:!0}),r);var jh={};q(jh,{PeerFilter:()=>wr,PeerList:()=>Jt,PeerMap:()=>Xt,PeerSet:()=>Wt,peerFilter:()=>$c,peerList:()=>Vc,peerMap:()=>zc,peerSet:()=>qc,trackedPeerList:()=>Xc,trackedPeerMap:()=>Yc,trackedPeerSet:()=>Gc});var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Sr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var _r=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Me=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var mn=Symbol.for("@libp2p/peer-id");var wn={};q(wn,{base58btc:()=>Y,base58flickr:()=>fa});var Gh=new Uint8Array(0);function gs(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 Tt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return Qt(r);if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return Qt(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));throw new Error("Unknown type, must be binary type")}function xs(r){return new TextEncoder().encode(r)}function ws(r){return new TextDecoder().decode(r)}function ra(r){return r?.buffer instanceof ArrayBuffer}function Qt(r){return ra(r)?r:r.slice()}function na(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,f=r.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var w=0,p=0,b=0,S=d.length;b!==S&&d[b]===0;)b++,w++;for(var _=(S-b)*u+1>>>0,T=new Uint8Array(_);b!==S;){for(var I=d[b],R=0,L=_-1;(I!==0||R<p)&&L!==-1;L--,R++)I+=256*T[L]>>>0,T[L]=I%c>>>0,I=I/c>>>0;if(I!==0)throw new Error("Non-zero carry");p=R,b++}for(var B=_-p;B!==_&&T[B]===0;)B++;for(var O=f.repeat(w);B<_;++B)O+=r.charAt(T[B]);return O}function E(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var w=0;if(d[w]!==" "){for(var p=0,b=0;d[w]===f;)p++,w++;for(var S=(d.length-w)*a+1>>>0,_=new Uint8Array(S);d[w];){var T=e[d.charCodeAt(w)];if(T===255)return;for(var I=0,R=S-1;(T!==0||I<b)&&R!==-1;R--,I++)T+=c*_[R]>>>0,_[R]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");b=I,w++}if(d[w]!==" "){for(var L=S-b;L!==S&&_[L]===0;)L++;for(var B=new Uint8Array(p+(S-L)),O=p;L!==S;)B[O++]=_[L++];return B}}}function m(d){var w=E(d);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:E,decode:m}}var oa=na,sa=oa,Ss=sa;var bn=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")}},yn=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 _s(this,t)}},gn=class{decoders;constructor(t){this.decoders=t}or(t){return _s(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 _s(r,t){return new gn({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var xn=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 bn(t,e,n),this.decoder=new yn(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function de({name:r,prefix:t,encode:e,decode:n}){return new xn(r,t,e,n)}function kt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ss(e,r);return de({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function ia(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[r[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,i+=e,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function ca(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function aa(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function H({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=aa(n);return de({prefix:t,name:r,encode(s){return ca(s,n,e)},decode(s){return ia(s,o,e,r)}})}var Y=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fa=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var En={};q(En,{base32:()=>pe,base32hex:()=>da,base32hexpad:()=>ma,base32hexpadupper:()=>ba,base32hexupper:()=>pa,base32pad:()=>ha,base32padupper:()=>la,base32upper:()=>ua,base32z:()=>ya});var pe=H({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ua=H({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ha=H({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),la=H({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),da=H({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pa=H({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ma=H({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ba=H({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ya=H({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Sn={};q(Sn,{base36:()=>Pe,base36upper:()=>ga});var Pe=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ga=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xa=Bs,vs=128,wa=127,Ea=~wa,Sa=Math.pow(2,31);function Bs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Sa;)t[e++]=r&255|vs,r/=128;for(;r&Ea;)t[e++]=r&255|vs,r>>>=7;return t[e]=r|0,Bs.bytes=e-n+1,t}var _a=_n,va=128,As=127;function _n(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw _n.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&As)<<o:(i&As)*Math.pow(2,o),o+=7}while(i>=va);return _n.bytes=s-n,e}var Aa=Math.pow(2,7),Ba=Math.pow(2,14),Ia=Math.pow(2,21),Ta=Math.pow(2,28),Da=Math.pow(2,35),Ca=Math.pow(2,42),La=Math.pow(2,49),Fa=Math.pow(2,56),Ra=Math.pow(2,63),Ua=function(r){return r<Aa?1:r<Ba?2:r<Ia?3:r<Ta?4:r<Da?5:r<Ca?6:r<La?7:r<Fa?8:r<Ra?9:10},Oa={encode:xa,decode:_a,encodingLength:Ua},ka=Oa,ze=ka;function qe(r,t=0){return[ze.decode(r,t),ze.decode.bytes]}function me(r,t,e=0){return ze.encode(r,t,e),t}function be(r){return ze.encodingLength(r)}function ge(r,t){let e=t.byteLength,n=be(r),o=n+be(e),s=new Uint8Array(o+e);return me(r,s,0),me(e,s,n),s.set(t,o),new ye(r,e,t,s)}function Ve(r){let t=Tt(r),[e,n]=qe(t),[o,s]=qe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ye(e,o,i,t)}function Is(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&gs(r.bytes,e.bytes)}}var ye=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=Qt(n),this.bytes=Qt(o)}};function Ts(r,t){let{bytes:e,version:n}=r;return n===0?Ka(e,vn(r),t??Y.encoder):Ma(e,vn(r),t??pe.encoder)}var Ds=new WeakMap;function vn(r){let t=Ds.get(r);if(t==null){let e=new Map;return Ds.set(r,e),e}return t}var at=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=Qt(o),this["/"]=this.bytes}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!==He)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Pa)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=ge(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&&Is(t.multihash,n.multihash)}toString(t){return Ts(this,t)}toJSON(){return{"/":Ts(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??Cs(n,o,s.bytes))}else if(e[za]===!0){let{version:n,multihash:o,code:s}=e,i=Ve(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!==He)throw new Error(`Version 0 CID must use dag-pb (code: ${He}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Cs(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,He,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=Tt(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 ye(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,E]=qe(t.subarray(e));return e+=E,h},o=n(),s=He;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),f=n(),a=e+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,e){let[n,o]=Na(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return vn(s).set(n,t),s}};function Na(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case pe.prefix:{let e=t??pe;return[pe.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.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 Ka(r,t,e){let{prefix:n}=e;if(n!==Y.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 Ma(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 He=112,Pa=18;function Cs(r,t,e){let n=be(r),o=n+be(t),s=new Uint8Array(o+e.byteLength);return me(r,s,0),me(t,s,n),s.set(e,o),s}var za=Symbol.for("@ipld/js-cid/CID");var An={};q(An,{identity:()=>dt});var Ls=0,qa="identity",Fs=Tt;function Va(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return ge(Ls,Fs(r))}var dt={code:Ls,name:qa,encode:Fs,digest:Va};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 Ha(r){return r.buffer instanceof ArrayBuffer}function xe(r){return Ha(r)?r:r.slice()}async function Rs(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,xe(t),xe(e.subarray()));return n?.signal?.throwIfAborted(),s}function Dt(r=0){return new Uint8Array(r)}function je(r=0){return new Uint8Array(r)}function Bn(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=je(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Us(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}var ks=Symbol.for("@achingbrain/uint8arraylist");function Os(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?.[ks]}var ft=class r{bufs;length;[ks]=!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;for(let o of n.bufs)this.bufs.push(o)}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=Os(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Os(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 Bn(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Bn(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=n,s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,f=c+i.byteLength;if(o=f,t>=f)continue;let a=t>=c&&t<f,u=e>c&&e<=f;if(a&&u){if(t===c&&e===f){n.push(i);break}let h=t-c;n.push(i.subarray(h,h+(e-t)));break}if(a){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===f){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!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 h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let c=i,f=this.byteLength-n.byteLength,a=n.byteLength-1,u;for(let h=e;h<=f;h+=u){u=0;for(let E=a;E>=0;E--){let m=this.get(h+E);if(n[E]!==m){u=Math.max(1,E-c[m]);break}}if(u===0)return h}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=je(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=Dt(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=Dt(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=Dt(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=je(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=Dt(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=Dt(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=Dt(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=Dt(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=Dt(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(!Us(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 In={};q(In,{base10:()=>ja});var ja=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var Tn={};q(Tn,{base16:()=>Za,base16upper:()=>$a});var Za=H({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$a=H({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Dn={};q(Dn,{base2:()=>Ya});var Ya=H({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cn={};q(Cn,{base256emoji:()=>Qa});var Ns=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}"),Ga=Ns.reduce((r,t,e)=>(r[e]=t,r),[]),Xa=Ns.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Wa(r){return r.reduce((t,e)=>(t+=Ga[e],t),"")}function Ja(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Xa[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Qa=de({prefix:"\u{1F680}",name:"base256emoji",encode:Wa,decode:Ja});var Ln={};q(Ln,{base64:()=>tf,base64pad:()=>ef,base64url:()=>rf,base64urlpad:()=>nf});var tf=H({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ef=H({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rf=H({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),nf=H({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fn={};q(Fn,{base8:()=>of});var of=H({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Rn={};q(Rn,{identity:()=>sf});var sf=de({prefix:"\0",name:"identity",encode:r=>ws(r),decode:r=>xs(r)});var kl=new TextEncoder,Nl=new TextDecoder;var kn={};q(kn,{sha256:()=>Ze,sha512:()=>uf});var ff=20;function On({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new Un(r,t,e,n,o)}var Un=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??ff,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Ks(n,this.code,e?.truncate):n.then(o=>Ks(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ks(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return ge(t,r)}function Ps(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ze=On({name:"sha2-256",code:18,encode:Ps("SHA-256")}),uf=On({name:"sha2-512",code:19,encode:Ps("SHA-512")});var Nn={...Rn,...Dn,...Fn,...In,...Tn,...En,...Sn,...wn,...Ln,...Cn},Gl={...kn,...An};function zs(r=0){return new Uint8Array(r)}function Kn(r=0){return new Uint8Array(r)}function Vs(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var qs=Vs("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Mn=Vs("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=Kn(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),hf={utf8:qs,"utf-8":qs,hex:Nn.base16,latin1:Mn,ascii:Mn,binary:Mn,...Nn},Br=hf;function nt(r,t="utf8"){let e=Br[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function lt(r,t="utf8"){let e=Br[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var lf=parseInt("11111",2),Pn=parseInt("10000000",2),df=parseInt("01111111",2),Hs={0:$e,1:$e,2:pf,3:yf,4:gf,5:bf,6:mf,16:$e,22:$e,48:$e};function zn(r,t={offset:0}){let e=r[t.offset]&lf;if(t.offset++,Hs[e]!=null)return Hs[e](r,t);throw new Error("No decoder for tag "+e)}function Ye(r,t){let e=0;if((r[t.offset]&Pn)===Pn){let n=r[t.offset]&df,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 $e(r,t){Ye(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=zn(r,t);if(n===null)break;e.push(n)}return e}function pf(r,t){let e=Ye(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 mf(r,t){let e=Ye(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,f=[];for(;t.offset<n;){let a=r[t.offset];if(t.offset++,f.push(a&127),a<128){f.reverse();let u=0;for(let h=0;h<f.length;h++)u+=f[h]<<h*7;c+=`.${u}`,f=[]}}return c}function bf(r,t){return t.offset++,null}function yf(r,t){let e=Ye(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 gf(r,t){let e=Ye(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function xf(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new ft;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function qn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=xf(r.byteLength);return new ft(Uint8Array.from([t.byteLength|Pn]),t)}function js(r){let t=new ft,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new ft(Uint8Array.from([2]),qn(t),t)}function Zs(r){let t=Uint8Array.from([0]),e=new ft(t,r);return new ft(Uint8Array.from([3]),qn(e),e)}function Ir(r,t=48){let e=new ft;for(let n of r)e.append(n);return new ft(Uint8Array.from([t]),qn(e),e)}var wf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ef=Uint8Array.from([6,5,43,129,4,0,34]),Sf=Uint8Array.from([6,5,43,129,4,0,35]),_f={ext:!0,kty:"EC",crv:"P-256"},vf={ext:!0,kty:"EC",crv:"P-384"},Af={ext:!0,kty:"EC",crv:"P-521"},Vn=32,Hn=48,jn=66;function $s(r){let t=zn(r);return Ys(t)}function Ys(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===Vn*2+1)return n=lt(t.subarray(e,e+Vn),"base64url"),o=lt(t.subarray(e+Vn),"base64url"),new we({..._f,key_ops:["verify"],x:n,y:o});if(t.byteLength===Hn*2+1)return n=lt(t.subarray(e,e+Hn),"base64url"),o=lt(t.subarray(e+Hn),"base64url"),new we({...vf,key_ops:["verify"],x:n,y:o});if(t.byteLength===jn*2+1)return n=lt(t.subarray(e,e+jn),"base64url"),o=lt(t.subarray(e+jn),"base64url"),new we({...Af,key_ops:["verify"],x:n,y:o});throw new It(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Gs(r){return Ir([js(Uint8Array.from([1])),Ir([Bf(r.crv)],160),Ir([Zs(new ft(Uint8Array.from([4]),nt(r.x??"","base64url"),nt(r.y??"","base64url")))],161)]).subarray()}function Bf(r){if(r==="P-256")return wf;if(r==="P-384")return Ef;if(r==="P-521")return Sf;throw new It(`Invalid curve ${r}`)}var we=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Gs(this.jwk)),this._raw}toMultihash(){return dt.digest(Ee(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Y.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 Rs(this.jwk,e,t,n)}};function Zn(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in r&&r.BYTES_PER_ELEMENT===1}function Nt(r,t=""){if(typeof r!="number"){let e=t&&`"${t}" `;throw new TypeError(`${e}expected number, got ${typeof r}`)}if(!Number.isSafeInteger(r)||r<0){let e=t&&`"${t}" `;throw new RangeError(`${e}expected integer >= 0, got ${r}`)}}function ut(r,t,e=""){let n=Zn(r),o=r?.length,s=t!==void 0;if(!n||s&&o!==t){let i=e&&`"${e}" `,c=s?` of length ${t}`:"",f=n?`length=${o}`:`type=${typeof r}`,a=i+"expected Uint8Array"+c+", got "+f;throw n?new RangeError(a):new TypeError(a)}return r}function Tr(r){if(typeof r!="function"||typeof r.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Nt(r.outputLen),Nt(r.blockLen),r.outputLen<1)throw new Error('"outputLen" must be >= 1');if(r.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Se(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 Dr(r,t){ut(r,void 0,"digestInto() output");let e=t.outputLen;if(r.length<e)throw new RangeError('"digestInto() output" expected to be of length >='+e)}function Lt(...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 mt(r,t){return r<<32-t|r>>>t}var Ws=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",If=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Lr(r){if(ut(r),Ws)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=If[r[e]];return t}var Ct={_0:48,_9:57,A:65,F:70,a:97,f:102};function Xs(r){if(r>=Ct._0&&r<=Ct._9)return r-Ct._0;if(r>=Ct.A&&r<=Ct.F)return r-(Ct.A-10);if(r>=Ct.a&&r<=Ct.f)return r-(Ct.a-10)}function Ge(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);if(Ws)try{return Uint8Array.fromHex(r)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=r.length,e=t/2;if(t%2)throw new RangeError("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=Xs(r.charCodeAt(s)),c=Xs(r.charCodeAt(s+1));if(i===void 0||c===void 0){let f=r[s]+r[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function $n(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ut(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function Yn(r,t={}){let e=(o,s)=>r(s).update(o).digest(),n=r(void 0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.canXOF=n.canXOF,e.create=o=>r(o),Object.assign(e,t),Object.freeze(e)}function Js(r=32){Nt(r,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(r>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${r}`);return t.getRandomValues(new Uint8Array(r))}var Gn=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function Qs(r,t,e){return r&t^~r&e}function ti(r,t,e){return r&t^r&e^t&e}var Xe=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,o){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Cr(this.buffer)}update(t){Se(this),ut(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let f=Cr(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Se(this),Dr(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Lt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)e[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let c=Cr(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let a=f/4,u=this.get();if(a>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ft=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var et=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Fr=BigInt(4294967295),ei=BigInt(32);function Tf(r,t=!1){return t?{h:Number(r&Fr),l:Number(r>>ei&Fr)}:{h:Number(r>>ei&Fr)|0,l:Number(r&Fr)|0}}function ri(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:c}=Tf(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var Xn=(r,t,e)=>r>>>e,Wn=(r,t,e)=>r<<32-e|t>>>e,ee=(r,t,e)=>r>>>e|t<<32-e,re=(r,t,e)=>r<<32-e|t>>>e,We=(r,t,e)=>r<<64-e|t>>>e-32,Je=(r,t,e)=>r>>>e-32|t<<64-e;function St(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ni=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),oi=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,si=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),ii=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,ci=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),ai=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var Cf=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]),Kt=new Uint32Array(64),Jn=class extends Xe{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[t,e,n,o,s,i,c,f]}set(t,e,n,o,s,i,c,f){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(t,e){for(let h=0;h<16;h++,e+=4)Kt[h]=t.getUint32(e,!1);for(let h=16;h<64;h++){let E=Kt[h-15],m=Kt[h-2],d=mt(E,7)^mt(E,18)^E>>>3,w=mt(m,17)^mt(m,19)^m>>>10;Kt[h]=w+Kt[h-7]+d+Kt[h-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:a,H:u}=this;for(let h=0;h<64;h++){let E=mt(c,6)^mt(c,11)^mt(c,25),m=u+E+Qs(c,f,a)+Cf[h]+Kt[h]|0,w=(mt(n,2)^mt(n,13)^mt(n,22))+ti(n,o,s)|0;u=a,a=f,f=c,c=i+m|0,i=s,s=o,o=n,n=m+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,u=u+this.H|0,this.set(n,o,s,i,c,f,a,u)}roundClean(){Lt(Kt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Lt(this.buffer)}},Qn=class extends Jn{A=Ft[0]|0;B=Ft[1]|0;C=Ft[2]|0;D=Ft[3]|0;E=Ft[4]|0;F=Ft[5]|0;G=Ft[6]|0;H=Ft[7]|0;constructor(){super(32)}};var fi=ri(["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))),Lf=fi[0],Ff=fi[1],Mt=new Uint32Array(80),Pt=new Uint32Array(80),to=class extends Xe{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:f,Eh:a,El:u,Fh:h,Fl:E,Gh:m,Gl:d,Hh:w,Hl:p}=this;return[t,e,n,o,s,i,c,f,a,u,h,E,m,d,w,p]}set(t,e,n,o,s,i,c,f,a,u,h,E,m,d,w,p){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=u|0,this.Fh=h|0,this.Fl=E|0,this.Gh=m|0,this.Gl=d|0,this.Hh=w|0,this.Hl=p|0}process(t,e){for(let _=0;_<16;_++,e+=4)Mt[_]=t.getUint32(e),Pt[_]=t.getUint32(e+=4);for(let _=16;_<80;_++){let T=Mt[_-15]|0,I=Pt[_-15]|0,R=ee(T,I,1)^ee(T,I,8)^Xn(T,I,7),L=re(T,I,1)^re(T,I,8)^Wn(T,I,7),B=Mt[_-2]|0,O=Pt[_-2]|0,z=ee(B,O,19)^We(B,O,61)^Xn(B,O,6),k=re(B,O,19)^Je(B,O,61)^Wn(B,O,6),l=si(L,k,Pt[_-7],Pt[_-16]),y=ii(l,R,z,Mt[_-7],Mt[_-16]);Mt[_]=y|0,Pt[_]=l|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:f,Dh:a,Dl:u,Eh:h,El:E,Fh:m,Fl:d,Gh:w,Gl:p,Hh:b,Hl:S}=this;for(let _=0;_<80;_++){let T=ee(h,E,14)^ee(h,E,18)^We(h,E,41),I=re(h,E,14)^re(h,E,18)^Je(h,E,41),R=h&m^~h&w,L=E&d^~E&p,B=ci(S,I,L,Ff[_],Pt[_]),O=ai(B,b,T,R,Lf[_],Mt[_]),z=B|0,k=ee(n,o,28)^We(n,o,34)^We(n,o,39),l=re(n,o,28)^Je(n,o,34)^Je(n,o,39),y=n&s^n&c^s&c,v=o&i^o&f^i&f;b=w|0,S=p|0,w=m|0,p=d|0,m=h|0,d=E|0,{h,l:E}=St(a|0,u|0,O|0,z|0),a=c|0,u=f|0,c=s|0,f=i|0,s=n|0,i=o|0;let x=ni(z,l,v);n=oi(x,O,k,y),o=x|0}({h:n,l:o}=St(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=St(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:f}=St(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l:u}=St(this.Dh|0,this.Dl|0,a|0,u|0),{h,l:E}=St(this.Eh|0,this.El|0,h|0,E|0),{h:m,l:d}=St(this.Fh|0,this.Fl|0,m|0,d|0),{h:w,l:p}=St(this.Gh|0,this.Gl|0,w|0,p|0),{h:b,l:S}=St(this.Hh|0,this.Hl|0,b|0,S|0),this.set(n,o,s,i,c,f,a,u,h,E,m,d,w,p,b,S)}roundClean(){Lt(Mt,Pt)}destroy(){this.destroyed=!0,Lt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},eo=class extends to{Ah=et[0]|0;Al=et[1]|0;Bh=et[2]|0;Bl=et[3]|0;Ch=et[4]|0;Cl=et[5]|0;Dh=et[6]|0;Dl=et[7]|0;Eh=et[8]|0;El=et[9]|0;Fh=et[10]|0;Fl=et[11]|0;Gh=et[12]|0;Gl=et[13]|0;Hh=et[14]|0;Hl=et[15]|0;constructor(){super(64)}};var ui=Yn(()=>new Qn,Gn(1));var Rr=Yn(()=>new eo,Gn(3));var M=(r,t,e)=>ut(r,t,e),no=Nt,_e=Lr,W=(...r)=>$n(...r),ve=r=>Ge(r),ne=Zn,Qe=r=>Js(r),Or=BigInt(0),ro=BigInt(1);function bt(r,t=""){if(typeof r!="boolean"){let e=t&&`"${t}" `;throw new TypeError(e+"expected boolean, got type="+typeof r)}return r}function kr(r){if(typeof r=="bigint"){if(!Ur(r))throw new RangeError("positive bigint expected, got "+r)}else no(r);return r}function yt(r,t=""){if(typeof r!="number"){let e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof r)}if(!Number.isSafeInteger(r)){let e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+r)}}function tr(r){let t=kr(r).toString(16);return t.length&1?"0"+t:t}function hi(r){if(typeof r!="string")throw new TypeError("hex string expected, got "+typeof r);return r===""?Or:BigInt("0x"+r)}function oe(r){return hi(Lr(r))}function _t(r){return hi(Lr(er(ut(r)).reverse()))}function Nr(r,t){if(Nt(t),t===0)throw new RangeError("zero length");r=kr(r);let e=r.toString(16);if(e.length>t*2)throw new RangeError("number too large");return Ge(e.padStart(t*2,"0"))}function oo(r,t){return Nr(r,t).reverse()}function li(r,t){if(r=M(r),t=M(t),r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function er(r){return Uint8Array.from(M(r))}function Kr(r){if(typeof r!="string")throw new TypeError("ascii string expected, got "+typeof r);return Uint8Array.from(r,(t,e)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${r[e]}" with code ${n} at position ${e}`);return n})}var Ur=r=>typeof r=="bigint"&&Or<=r;function Rf(r,t,e){return Ur(r)&&Ur(t)&&Ur(e)&&t<=r&&r<e}function Ae(r,t,e,n){if(!Rf(t,e,n))throw new RangeError("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Be(r){if(r<Or)throw new Error("expected non-negative bigint, got "+r);let t;for(t=0;r>Or;r>>=ro,t+=1);return t}var rr=r=>(ro<<BigInt(r))-ro;function di(r,t,e){if(Nt(r,"hashLen"),Nt(t,"qByteLen"),typeof e!="function")throw new TypeError("hmacFn must be a function");let n=p=>new Uint8Array(p),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,f=n(r),a=n(r),u=0,h=()=>{f.fill(1),a.fill(0),u=0},E=(...p)=>e(a,W(f,...p)),m=(p=o)=>{a=E(s,p),f=E(),p.length!==0&&(a=E(i,p),f=E())},d=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let p=0,b=[];for(;p<t;){f=E();let S=f.slice();b.push(S),p+=f.length}return W(...b)};return(p,b)=>{h(),m(p);let S;for(;(S=b(d()))===void 0;)m();return h(),S}}function gt(r,t={},e={}){if(Object.prototype.toString.call(r)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,c){if(!c&&i!=="function"&&!Object.hasOwn(r,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=r[s];if(c&&f===void 0)return;let a=typeof f;if(a!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${a}`)}let o=(s,i)=>Object.entries(s).forEach(([c,f])=>n(c,f,i));o(t,!1),o(e,!0)}var so=()=>{throw new Error("not implemented")};var rt=BigInt(0),j=BigInt(1),se=BigInt(2),yi=BigInt(3),gi=BigInt(4),xi=BigInt(5),Uf=BigInt(7),wi=BigInt(8),Of=BigInt(9),Ei=BigInt(16);function G(r,t){if(t<=rt)throw new Error("mod: expected positive modulus, got "+t);let e=r%t;return e>=rt?e:t+e}function V(r,t,e){if(t<rt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=r;for(;t-- >rt;)n*=n,n%=e;return n}function pi(r,t){if(r===rt)throw new Error("invert: expected non-zero number");if(t<=rt)throw new Error("invert: expected positive modulus, got "+t);let e=G(r,t),n=t,o=rt,s=j,i=j,c=rt;for(;e!==rt;){let a=n/e,u=n-e*a,h=o-i*a,E=s-c*a;n=e,e=u,o=i,s=c,i=h,c=E}if(n!==j)throw new Error("invert: does not exist");return G(o,t)}function io(r,t,e){let n=r;if(!n.eql(n.sqr(t),e))throw new Error("Cannot find square root")}function Si(r,t){let e=r,n=(e.ORDER+j)/gi,o=e.pow(t,n);return io(e,o,t),o}function kf(r,t){let e=r,n=(e.ORDER-xi)/wi,o=e.mul(t,se),s=e.pow(o,n),i=e.mul(t,s),c=e.mul(e.mul(i,se),s),f=e.mul(i,e.sub(c,e.ONE));return io(e,f,t),f}function Nf(r){let t=Ie(r),e=_i(r),n=e(t,t.neg(t.ONE)),o=e(t,n),s=e(t,t.neg(n)),i=(r+Uf)/Ei;return((c,f)=>{let a=c,u=a.pow(f,i),h=a.mul(u,n),E=a.mul(u,o),m=a.mul(u,s),d=a.eql(a.sqr(h),f),w=a.eql(a.sqr(E),f);u=a.cmov(u,h,d),h=a.cmov(m,E,w);let p=a.eql(a.sqr(h),f),b=a.cmov(u,h,p);return io(a,b,f),b})}function _i(r){if(r<yi)throw new Error("sqrt is not defined for small field");let t=r-j,e=0;for(;t%se===rt;)t/=se,e++;let n=se,o=Ie(r);for(;mi(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Si;let s=o.pow(n,t),i=(t+j)/se;return function(f,a){let u=f;if(u.is0(a))return a;if(mi(u,a)!==1)throw new Error("Cannot find square root");let h=e,E=u.mul(u.ONE,s),m=u.pow(a,t),d=u.pow(a,i);for(;!u.eql(m,u.ONE);){if(u.is0(m))return u.ZERO;let w=1,p=u.sqr(m);for(;!u.eql(p,u.ONE);)if(w++,p=u.sqr(p),w===h)throw new Error("Cannot find square root");let b=j<<BigInt(h-w-1),S=u.pow(E,b);h=w,E=u.sqr(S),m=u.mul(m,E),d=u.mul(d,S)}return d}}function Kf(r){return r%gi===yi?Si:r%wi===xi?kf:r%Ei===Of?Nf(r):_i(r)}var Rt=(r,t)=>(G(r,t)&j)===j,Mf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function co(r){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},e=Mf.reduce((n,o)=>(n[o]="function",n),t);if(gt(r,e),yt(r.BYTES,"BYTES"),yt(r.BITS,"BITS"),r.BYTES<1||r.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(r.ORDER<=j)throw new Error("invalid field: expected ORDER > 1, got "+r.ORDER);return r}function Pf(r,t,e){let n=r;if(e<rt)throw new Error("invalid exponent, negatives unsupported");if(e===rt)return n.ONE;if(e===j)return t;let o=n.ONE,s=t;for(;e>rt;)e&j&&(o=n.mul(o,s)),s=n.sqr(s),e>>=j;return o}function nr(r,t,e=!1){let n=r,o=new Array(t.length).fill(e?n.ZERO:void 0),s=t.reduce((c,f,a)=>n.is0(f)?c:(o[a]=c,n.mul(c,f)),n.ONE),i=n.inv(s);return t.reduceRight((c,f,a)=>n.is0(f)?c:(o[a]=n.mul(c,o[a]),n.mul(c,f)),i),o}function mi(r,t){let e=r,n=(e.ORDER-j)/se,o=e.pow(t,n),s=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!s&&!i&&!c)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function zf(r,t){if(t!==void 0&&no(t),r<=rt)throw new Error("invalid n length: expected positive n, got "+r);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let e=Be(r);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected bit length (${e}) >= n.length (${t})`);let n=t!==void 0?t:e,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var bi=new WeakMap,Mr=class{ORDER;BITS;BYTES;isLE;ZERO=rt;ONE=j;_lengths;_mod;constructor(t,e={}){if(t<=j)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(n=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));let{nBitLength:o,nByteLength:s}=zf(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return G(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return rt<=t&&t<this.ORDER}is0(t){return t===rt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&j)===j}neg(t){return G(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return G(t*t,this.ORDER)}add(t,e){return G(t+e,this.ORDER)}sub(t,e){return G(t-e,this.ORDER)}mul(t,e){return G(t*e,this.ORDER)}pow(t,e){return Pf(this,t,e)}div(t,e){return G(t*pi(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return pi(t,this.ORDER)}sqrt(t){let e=bi.get(this);return e||bi.set(this,e=Kf(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?oo(t,this.BYTES):Nr(t,this.BYTES)}fromBytes(t,e=!1){M(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:c}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let a=new Uint8Array(o);a.set(t,s?0:a.length-t.length),t=a}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let f=s?_t(t):oe(t);if(c&&(f=G(f,i)),!e&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return nr(this,t)}cmov(t,e,n){return bt(n,"condition"),n?e:t}};Object.freeze(Mr.prototype);function Ie(r,t={}){return new Mr(r,t)}function vi(r){if(typeof r!="bigint")throw new Error("field order must be bigint");if(r<=j)throw new Error("field order must be greater than 1");let t=Be(r-j);return Math.ceil(t/8)}function ao(r){let t=vi(r);return t+Math.ceil(t/2)}function fo(r,t,e=!1){M(r);let n=r.length,o=vi(t),s=Math.max(ao(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?_t(r):oe(r),c=G(i,t-j)+j;return e?oo(c,o):Nr(c,o)}var Te=BigInt(0),ie=BigInt(1);function or(r,t){let e=t.negate();return r?e:t}function ce(r,t){let e=nr(r.Fp,t.map(n=>n.Z));return t.map((n,o)=>r.fromAffine(n.toAffine(e[o])))}function Ti(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function uo(r,t){Ti(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=rr(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Ai(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),f=r>>i;c>n&&(c-=s,f+=ie);let a=t*n,u=a+Math.abs(c)-1,h=c===0,E=c<0,m=t%2!==0;return{nextN:f,offset:u,isZero:h,isNeg:E,isNegF:m,offsetF:a}}var ho=new WeakMap,Di=new WeakMap;function lo(r){return Di.get(r)||1}function Bi(r){if(r!==Te)throw new Error("invalid wNAF")}var De=class{BASE;ZERO;Fn;bits;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>Te;)e&ie&&(n=n.add(o)),o=o.double(),e>>=ie;return n}precomputeWindow(t,e){let{windows:n,windowSize:o}=uo(e,this.bits),s=[],i=t,c=i;for(let f=0;f<n;f++){c=i,s.push(c);for(let a=1;a<o;a++)c=c.add(i),s.push(c);i=c.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=uo(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:f,offset:a,isZero:u,isNeg:h,isNegF:E,offsetF:m}=Ai(n,c,i);n=f,u?s=s.add(or(E,e[m])):o=o.add(or(h,e[a]))}return Bi(n),{p:o,f:s}}wNAFUnsafe(t,e,n,o=this.ZERO){let s=uo(t,this.bits);for(let i=0;i<s.windows&&n!==Te;i++){let{nextN:c,offset:f,isZero:a,isNeg:u}=Ai(n,i,s);if(n=c,!a){let h=e[f];o=o.add(u?h.negate():h)}}return Bi(n),o}getPrecomputes(t,e,n){let o=ho.get(e);return o||(o=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(o=n(o)),ho.set(e,o))),o}cached(t,e,n){let o=lo(t);return this.wNAF(o,this.getPrecomputes(o,t,n),e)}unsafe(t,e,n,o){let s=lo(t);return s===1?this._unsafeLadder(t,e,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),e,o)}createCache(t,e){Ti(e,this.bits),Di.set(t,e),ho.delete(t)}hasCache(t){return lo(t)!==1}};function Ci(r,t,e,n){let o=t,s=r.ZERO,i=r.ZERO;for(;e>Te||n>Te;)e&ie&&(s=s.add(o)),n&ie&&(i=i.add(o)),o=o.double(),e>>=ie,n>>=ie;return{p1:s,p2:i}}function Ii(r,t,e){if(t){if(t.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return co(t),t}else return Ie(r,{isLE:e})}function Pr(r,t,e={},n){if(n===void 0&&(n=r==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${r} CURVE object`);for(let f of["p","n","h"]){let a=t[f];if(!(typeof a=="bigint"&&a>Te))throw new Error(`CURVE.${f} must be positive bigint`)}let o=Ii(t.p,e.Fp,n),s=Ii(t.n,e.Fn,n),c=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function zr(r,t){return function(n){let o=r(n);return{secretKey:o,publicKey:t(o)}}}var zt=BigInt(0),tt=BigInt(1),po=BigInt(2),qf=BigInt(8);function Vf(r,t,e,n){let o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),c=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,c)}function Li(r,t={}){let e=t,n=Pr("edwards",r,e,e.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:c}=i;gt(e,{},{uvRatio:"function"});let f=po<<BigInt(s.BYTES*8)-tt,a=w=>o.create(w),u=e.uvRatio===void 0?(w,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(w,p))}}catch{return{isValid:!1,value:zt}}}:e.uvRatio;if(!Vf(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function h(w,p,b=!1){let S=b?tt:zt;return Ae("coordinate "+w,p,S,f),p}function E(w){if(!(w instanceof m))throw new Error("EdwardsPoint expected")}class m{static BASE=new m(i.Gx,i.Gy,tt,a(i.Gx*i.Gy));static ZERO=new m(zt,tt,tt,zt);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,b,S,_){this.X=h("x",p),this.Y=h("y",b),this.Z=h("z",S,!0),this.T=h("t",_),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof m)throw new Error("extended point not allowed");let{x:b,y:S}=p||{};return h("x",b),h("y",S),new m(b,S,tt,a(b*S))}static fromBytes(p,b=!1){let S=o.BYTES,{a:_,d:T}=i;p=er(M(p,S,"point")),bt(b,"zip215");let I=er(p),R=p[S-1];I[S-1]=R&-129;let L=_t(I),B=b?f:o.ORDER;Ae("point.y",L,zt,B);let O=a(L*L),z=a(O-tt),k=a(T*O-_),{isValid:l,value:y}=u(z,k);if(!l)throw new Error("bad point: invalid y coordinate");let v=(y&tt)===tt,x=(R&128)!==0;if(!b&&y===zt&&x)throw new Error("bad point: x=0 and x_0=1");return x!==v&&(y=a(-y)),m.fromAffine({x:y,y:L})}static fromHex(p,b=!1){return m.fromBytes(ve(p),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,b=!0){return d.createCache(this,p),b||this.multiply(po),this}assertValidity(){let p=this,{a:b,d:S}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:_,Y:T,Z:I,T:R}=p,L=a(_*_),B=a(T*T),O=a(I*I),z=a(O*O),k=a(L*b),l=a(O*a(k+B)),y=a(z+a(S*a(L*B)));if(l!==y)throw new Error("bad point: equation left != right (1)");let v=a(_*T),x=a(I*R);if(v!==x)throw new Error("bad point: equation left != right (2)")}equals(p){E(p);let{X:b,Y:S,Z:_}=this,{X:T,Y:I,Z:R}=p,L=a(b*R),B=a(T*_),O=a(S*R),z=a(I*_);return L===B&&O===z}is0(){return this.equals(m.ZERO)}negate(){return new m(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:p}=i,{X:b,Y:S,Z:_}=this,T=a(b*b),I=a(S*S),R=a(po*a(_*_)),L=a(p*T),B=b+S,O=a(a(B*B)-T-I),z=L+I,k=z-R,l=L-I,y=a(O*k),v=a(z*l),x=a(O*l),g=a(k*z);return new m(y,v,g,x)}add(p){E(p);let{a:b,d:S}=i,{X:_,Y:T,Z:I,T:R}=this,{X:L,Y:B,Z:O,T:z}=p,k=a(_*L),l=a(T*B),y=a(R*S*z),v=a(I*O),x=a((_+T)*(L+B)-k-l),g=v-y,A=v+y,C=a(l-b*k),D=a(x*g),F=a(A*C),U=a(x*C),K=a(g*A);return new m(D,F,K,U)}subtract(p){return E(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:S}=d.cached(this,p,_=>ce(m,_));return ce(m,[b,S])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===zt?m.ZERO:this.is0()||p===tt?this:d.unsafe(this,p,b=>ce(m,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return d.unsafe(this,i.n).is0()}toAffine(p){let b=this,S=p,{X:_,Y:T,Z:I}=b,R=b.is0();S==null&&(S=R?qf:o.inv(I));let L=a(_*S),B=a(T*S),O=o.mul(I,S);if(R)return{x:zt,y:tt};if(O!==tt)throw new Error("invZ was invalid");return{x:L,y:B}}clearCofactor(){return c===tt?this:this.multiplyUnsafe(c)}toBytes(){let{x:p,y:b}=this.toAffine(),S=o.toBytes(b);return S[S.length-1]|=p&tt?128:0,S}toHex(){return _e(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let d=new De(m,s.BITS);return s.BITS>=8&&m.BASE.precompute(8),Object.freeze(m.prototype),Object.freeze(m),m}var qr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){so()}static fromHex(t){so()}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 _e(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.ep.precompute(t,e),this}};function Fi(r,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=e;gt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:c,Fn:f}=r,a=n.outputLen,u=2*c.BYTES;if(a!==void 0&&(yt(a,"hash.outputLen"),a!==u))throw new Error(`hash.outputLen must be ${u}, got ${a}`);let h=o.randomBytes===void 0?Qe:o.randomBytes,E=o.adjustScalarBytes===void 0?l=>l:o.adjustScalarBytes,m=o.domain===void 0?(l,y,v)=>{if(bt(v,"phflag"),y.length||v)throw new Error("Contexts/pre-hash are not supported");return l}:o.domain;function d(l){return f.create(_t(l))}function w(l){let y=L.secretKey;M(l,L.secretKey,"secretKey");let v=M(n(l),2*y,"hashedSecretKey"),x=E(v.slice(0,y)),g=v.slice(y,2*y),A=d(x);return{head:x,prefix:g,scalar:A}}function p(l){let{head:y,prefix:v,scalar:x}=w(l),g=i.multiply(x),A=g.toBytes();return{head:y,prefix:v,scalar:x,point:g,pointBytes:A}}function b(l){return p(l).pointBytes}function S(l=Uint8Array.of(),...y){let v=W(...y);return d(n(m(v,M(l,void 0,"context"),!!s)))}function _(l,y,v={}){l=M(l,void 0,"message"),s&&(l=s(l));let{prefix:x,scalar:g,pointBytes:A}=p(y),C=S(v.context,x,l),D=i.multiply(C).toBytes(),F=S(v.context,D,A,l),U=f.create(C+F*g);if(!f.isValid(U))throw new Error("sign failed: invalid s");let K=W(D,f.toBytes(U));return M(K,L.signature,"result")}let T={zip215:o.zip215};function I(l,y,v,x=T){let{context:g}=x,A=x.zip215===void 0?!!T.zip215:x.zip215,C=L.signature;l=M(l,C,"signature"),y=M(y,void 0,"message"),v=M(v,L.publicKey,"publicKey"),A!==void 0&&bt(A,"zip215"),s&&(y=s(y));let D=C/2,F=l.subarray(0,D),U=_t(l.subarray(D,C)),K,P,N;try{K=r.fromBytes(v,A),P=r.fromBytes(F,A),N=i.multiplyUnsafe(U)}catch{return!1}if(!A&&K.isSmallOrder())return!1;let X=S(g,F,v,y);return P.add(K.multiplyUnsafe(X)).subtract(N).clearCofactor().is0()}let R=c.BYTES,L={secretKey:R,publicKey:R,signature:2*R,seed:R};function B(l){return l=l===void 0?h(L.seed):l,M(l,L.seed,"seed")}function O(l){return ne(l)&&l.length===L.secretKey}function z(l,y){try{return!!r.fromBytes(l,y===void 0?T.zip215:y)}catch{return!1}}let k={getExtendedPublicKey:p,randomSecretKey:B,isValidSecretKey:O,isValidPublicKey:z,toMontgomery(l){let{y}=r.fromBytes(l),v=L.publicKey,x=v===32;if(!x&&v!==57)throw new Error("only defined for 25519 and 448");let g=x?c.div(tt+y,tt-y):c.div(y-tt,y+tt);return c.toBytes(g)},toMontgomerySecret(l){let y=L.secretKey;M(l,y);let v=n(l.subarray(0,y));return E(v).subarray(0,y)}};return Object.freeze(L),Object.freeze(k),Object.freeze({keygen:zr(B,b),getPublicKey:b,sign:_,verify:I,utils:k,Point:r,lengths:L})}function sr(r,t){if(yt(r),yt(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(r<0||r>2**(8*t)-1)throw new Error("invalid I2OSP input: "+r);let e=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)e[n]=r&255,r>>>=8;return new Uint8Array(e)}function Hf(r,t){let e=new Uint8Array(r.length);for(let n=0;n<r.length;n++)e[n]=r[n]^t[n];return e}function jf(r){if(!ne(r)&&typeof r!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof r=="string"?Kr(r):r;if(t.length===0)throw new Error("DST must be non-empty");return t}function mo(r,t,e,n){M(r),yt(e),t=jf(t),t.length>255&&(t=n(W(Kr("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(e/o);if(e>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=W(t,sr(t.length,1)),f=new Uint8Array(s),a=sr(e,2),u=new Array(i),h=n(W(f,r,a,sr(0,1),c));u[0]=n(W(h,sr(1,1),c));for(let m=1;m<i;m++){let d=[Hf(h,u[m-1]),sr(m+1,1),c];u[m]=n(W(...d))}return W(...u).slice(0,e)}var Ri="HashToScalar-";var Zf=BigInt(0),Ut=BigInt(1),Ui=BigInt(2);var $f=BigInt(5),Yf=BigInt(8),Ce=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),xo={p:Ce,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Yf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Gf(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ce,c=r*r%s*r%s,f=V(c,Ui,s)*c%s,a=V(f,Ut,s)*r%s,u=V(a,$f,s)*a%s,h=V(u,t,s)*u%s,E=V(h,e,s)*h%s,m=V(E,n,s)*E%s,d=V(m,o,s)*m%s,w=V(d,o,s)*m%s,p=V(w,t,s)*u%s;return{pow_p_5_8:V(p,Ui,s)*r%s,b2:c}}function Xf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var bo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function wo(r,t){let e=Ce,n=G(t*t*t,e),o=G(n*n*t,e),s=Gf(r*o).pow_p_5_8,i=G(r*n*s,e),c=G(t*i*i,e),f=i,a=G(i*bo,e),u=c===r,h=c===G(-r,e),E=c===G(-r*bo,e);return u&&(i=f),(h||E)&&(i=a),Rt(i,e)&&(i=G(-i,e)),{isValid:u||h,value:i}}var Vt=Li(xo,{uvRatio:wo}),qt=Vt.Fp,Ni=Vt.Fn;function Wf(r){return Fi(Vt,Rr,Object.assign({adjustScalarBytes:Xf,zip215:!0},r))}var Ki=Wf({});var yo=bo,Jf=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Qf=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),tu=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),eu=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Oi=r=>wo(Ut,r),ru=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),go=r=>qt.create(_t(r)&ru);function ki(r){let{d:t}=xo,e=Ce,n=b=>qt.create(b),o=n(yo*r*r),s=n((o+Ut)*tu),i=BigInt(-1),c=n((i-t*o)*n(o+t)),{isValid:f,value:a}=wo(s,c),u=n(a*r);Rt(u,e)||(u=n(-u)),f||(a=u),f||(i=o);let h=n(i*(o-Ut)*eu-c),E=a*a,m=n((a+a)*c),d=n(h*Jf),w=n(Ut-E),p=n(Ut+E);return new Vt(n(m*p),n(w*d),n(d*p),n(m*w))}var Ht=class r extends qr{static BASE=new r(Vt.BASE);static ZERO=new r(Vt.ZERO);static Fp=qt;static Fn=Ni;constructor(t){super(t)}static fromAffine(t){return new r(Vt.fromAffine(t))}assertSame(t){if(!(t instanceof r))throw new Error("RistrettoPoint expected")}init(t){return new r(t)}static fromBytes(t){ut(t,32);let{a:e,d:n}=xo,o=Ce,s=T=>qt.create(T),i=go(t);if(!li(qt.toBytes(i),t)||Rt(i,o))throw new Error("invalid ristretto255 encoding 1");let c=s(i*i),f=s(Ut+e*c),a=s(Ut-e*c),u=s(f*f),h=s(a*a),E=s(e*n*u-h),{isValid:m,value:d}=Oi(s(E*h)),w=s(d*a),p=s(d*w*E),b=s((i+i)*w);Rt(b,o)&&(b=s(-b));let S=s(f*p),_=s(b*S);if(!m||Rt(_,o)||S===Zf)throw new Error("invalid ristretto255 encoding 2");return new r(new Vt(b,S,Ut,_))}static fromHex(t){return r.fromBytes(Ge(t))}toBytes(){let{X:t,Y:e,Z:n,T:o}=this.ep,s=Ce,i=p=>qt.create(p),c=i(i(n+e)*i(n-e)),f=i(t*e),a=i(f*f),{value:u}=Oi(i(c*a)),h=i(u*c),E=i(u*f),m=i(h*E*o),d;if(Rt(o*m,s)){let p=i(e*yo),b=i(t*yo);t=p,e=b,d=i(h*Qf)}else d=E;Rt(t*m,s)&&(e=i(-e));let w=i((n-e)*d);return Rt(w,s)&&(w=i(-w)),qt.toBytes(w)}equals(t){this.assertSame(t);let{X:e,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=a=>qt.create(a),c=i(e*s)===i(n*o),f=i(n*s)===i(e*o);return c||f}is0(){return this.equals(r.ZERO)}};Object.freeze(Ht.BASE);Object.freeze(Ht.ZERO);Object.freeze(Ht.prototype);Object.freeze(Ht);var nu=Object.freeze({Point:Ht,hashToCurve(r,t){let e=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=mo(r,e,64,Rr);return nu.deriveToCurve(n)},hashToScalar(r,t={DST:Ri}){let e=mo(r,t.DST,64,Rr);return Ni.create(_t(e))},deriveToCurve(r){ut(r,64);let t=go(r.subarray(0,32)),e=ki(t),n=go(r.subarray(32,64)),o=ki(n);return new Ht(e.add(o))}});var ir=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Vr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Hr={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Vr("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 jr=32;var Eo,ou=(async()=>{try{return await Hr.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function su(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await Hr.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Hr.get().subtle.verify({name:"Ed25519"},n,xe(t),xe(e instanceof Uint8Array?e:e.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function iu(r,t,e){return Ki.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function Mi(r,t,e){return Eo==null&&(Eo=await ou),Eo?su(r,t,e):iu(r,t,e)}function Zr(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var $r=class{type="Ed25519";raw;constructor(t){this.raw=So(t,jr)}toMultihash(){return dt.digest(Ee(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Y.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=Mi(this.raw,e,t);return Zr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function zi(r){return r=So(r,jr),new $r(r)}function So(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}function jt(r=0){return new Uint8Array(r)}var au=Math.pow(2,7),fu=Math.pow(2,14),uu=Math.pow(2,21),qi=Math.pow(2,28),Vi=Math.pow(2,35),Hi=Math.pow(2,42),ji=Math.pow(2,49),st=128,Zt=127;function cr(r){if(r<au)return 1;if(r<fu)return 2;if(r<uu)return 3;if(r<qi)return 4;if(r<Vi)return 5;if(r<Hi)return 6;if(r<ji)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Zi(r,t,e=0){switch(cr(r)){case 8:t[e++]=r&255|st,r/=128;case 7:t[e++]=r&255|st,r/=128;case 6:t[e++]=r&255|st,r/=128;case 5:t[e++]=r&255|st,r/=128;case 4:t[e++]=r&255|st,r>>>=7;case 3:t[e++]=r&255|st,r>>>=7;case 2:t[e++]=r&255|st,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function $i(r,t){let e=r[t],n=0;if(n+=e&Zt,e<st||(e=r[t+1],n+=(e&Zt)<<7,e<st)||(e=r[t+2],n+=(e&Zt)<<14,e<st)||(e=r[t+3],n+=(e&Zt)<<21,e<st)||(e=r[t+4],n+=(e&Zt)*qi,e<st)||(e=r[t+5],n+=(e&Zt)*Vi,e<st)||(e=r[t+6],n+=(e&Zt)*Hi,e<st)||(e=r[t+7],n+=(e&Zt)*ji,e<st))return n;throw new RangeError("Could not decode varint")}var _o=new Float32Array([-0]),$t=new Uint8Array(_o.buffer);function Yi(r,t,e){_o[0]=r,t[e]=$t[0],t[e+1]=$t[1],t[e+2]=$t[2],t[e+3]=$t[3]}function Gi(r,t){return $t[0]=r[t],$t[1]=r[t+1],$t[2]=r[t+2],$t[3]=r[t+3],_o[0]}var vo=new Float64Array([-0]),ot=new Uint8Array(vo.buffer);function Xi(r,t,e){vo[0]=r,t[e]=ot[0],t[e+1]=ot[1],t[e+2]=ot[2],t[e+3]=ot[3],t[e+4]=ot[4],t[e+5]=ot[5],t[e+6]=ot[6],t[e+7]=ot[7]}function Wi(r,t){return ot[0]=r[t],ot[1]=r[t+1],ot[2]=r[t+2],ot[3]=r[t+3],ot[4]=r[t+4],ot[5]=r[t+5],ot[6]=r[t+6],ot[7]=r[t+7],vo[0]}var hu=BigInt(Number.MAX_SAFE_INTEGER),lu=BigInt(Number.MIN_SAFE_INTEGER),ht=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 ae;if(t<hu&&t>lu)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>Ji&&(o=0n,++n>Ji&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ae;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):ae}},ae=new ht(0,0);ae.toBigInt=function(){return 0n};ae.zzEncode=ae.zzDecode=function(){return this};ae.length=function(){return 1};var Ji=4294967296n;function Qi(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 tc(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Ao(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function xt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Yr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Bo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,xt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw xt(this,4);return Yr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw xt(this,4);return Yr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw xt(this,4);let t=Gi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw xt(this,4);let t=Wi(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw xt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return tc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw xt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw xt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ht(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw xt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw xt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw xt(this,8);let t=Yr(this.buf,this.pos+=4),e=Yr(this.buf,this.pos+=4);return new ht(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=$i(this.buf,this.pos);return this.pos+=cr(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 ar(r){return new Bo(r instanceof Uint8Array?r:r.subarray())}function Gr(r,t,e){let n=ar(r);return t.decode(n,void 0,e)}var Lo={};q(Lo,{base10:()=>xu});var Vp=new Uint8Array(0);function rc(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 Ot(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 nc(r){return new TextEncoder().encode(r)}function oc(r){return new TextDecoder().decode(r)}function du(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,f=r.charAt(0),a=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var w=0,p=0,b=0,S=d.length;b!==S&&d[b]===0;)b++,w++;for(var _=(S-b)*u+1>>>0,T=new Uint8Array(_);b!==S;){for(var I=d[b],R=0,L=_-1;(I!==0||R<p)&&L!==-1;L--,R++)I+=256*T[L]>>>0,T[L]=I%c>>>0,I=I/c>>>0;if(I!==0)throw new Error("Non-zero carry");p=R,b++}for(var B=_-p;B!==_&&T[B]===0;)B++;for(var O=f.repeat(w);B<_;++B)O+=r.charAt(T[B]);return O}function E(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var w=0;if(d[w]!==" "){for(var p=0,b=0;d[w]===f;)p++,w++;for(var S=(d.length-w)*a+1>>>0,_=new Uint8Array(S);d[w];){var T=e[d.charCodeAt(w)];if(T===255)return;for(var I=0,R=S-1;(T!==0||I<b)&&R!==-1;R--,I++)T+=c*_[R]>>>0,_[R]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");b=I,w++}if(d[w]!==" "){for(var L=S-b;L!==S&&_[L]===0;)L++;for(var B=new Uint8Array(p+(S-L)),O=p;L!==S;)B[O++]=_[L++];return B}}}function m(d){var w=E(d);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:E,decode:m}}var pu=du,mu=pu,ic=mu;var Io=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")}},To=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 cc(this,t)}},Do=class{decoders;constructor(t){this.decoders=t}or(t){return cc(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 cc(r,t){return new Do({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Co=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 Io(t,e,n),this.decoder=new To(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Le({name:r,prefix:t,encode:e,decode:n}){return new Co(r,t,e,n)}function Yt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ic(e,r);return Le({prefix:t,name:r,encode:n,decode:s=>Ot(o(s))})}function bu(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,c=0,f=0;for(let a=0;a<o;++a){let u=t[r[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,i+=e,i>=8&&(i-=8,s[f++]=255&c>>i)}if(i>=e||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function yu(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function gu(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function Z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=gu(n);return Le({prefix:t,name:r,encode(s){return yu(s,n,e)},decode(s){return bu(s,o,e,r)}})}var xu=Yt({prefix:"9",name:"base10",alphabet:"0123456789"});var Fo={};q(Fo,{base16:()=>wu,base16upper:()=>Eu});var wu=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Eu=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ro={};q(Ro,{base2:()=>Su});var Su=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Uo={};q(Uo,{base256emoji:()=>Iu});var ac=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}"),_u=ac.reduce((r,t,e)=>(r[e]=t,r),[]),vu=ac.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Au(r){return r.reduce((t,e)=>(t+=_u[e],t),"")}function Bu(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=vu[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Iu=Le({prefix:"\u{1F680}",name:"base256emoji",encode:Au,decode:Bu});var Oo={};q(Oo,{base32:()=>Fe,base32hex:()=>Lu,base32hexpad:()=>Ru,base32hexpadupper:()=>Uu,base32hexupper:()=>Fu,base32pad:()=>Du,base32padupper:()=>Cu,base32upper:()=>Tu,base32z:()=>Ou});var Fe=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tu=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Du=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Cu=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lu=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fu=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ru=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Uu=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ou=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ko={};q(ko,{base36:()=>fr,base36upper:()=>ku});var fr=Yt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ku=Yt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var No={};q(No,{base58btc:()=>vt,base58flickr:()=>Nu});var vt=Yt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Nu=Yt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ko={};q(Ko,{base64:()=>Ku,base64pad:()=>Mu,base64url:()=>Pu,base64urlpad:()=>zu});var Ku=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mu=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pu=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),zu=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Mo={};q(Mo,{base8:()=>qu});var qu=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Po={};q(Po,{identity:()=>Vu});var Vu=Le({prefix:"\0",name:"identity",encode:r=>oc(r),decode:r=>nc(r)});var s0=new TextEncoder,i0=new TextDecoder;var qo={};q(qo,{identity:()=>lh});var Zu=hc,fc=128,$u=127,Yu=~$u,Gu=Math.pow(2,31);function hc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Gu;)t[e++]=r&255|fc,r/=128;for(;r&Yu;)t[e++]=r&255|fc,r>>>=7;return t[e]=r|0,hc.bytes=e-n+1,t}var Xu=zo,Wu=128,uc=127;function zo(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw zo.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&uc)<<o:(i&uc)*Math.pow(2,o),o+=7}while(i>=Wu);return zo.bytes=s-n,e}var Ju=Math.pow(2,7),Qu=Math.pow(2,14),th=Math.pow(2,21),eh=Math.pow(2,28),rh=Math.pow(2,35),nh=Math.pow(2,42),oh=Math.pow(2,49),sh=Math.pow(2,56),ih=Math.pow(2,63),ch=function(r){return r<Ju?1:r<Qu?2:r<th?3:r<eh?4:r<rh?5:r<nh?6:r<oh?7:r<sh?8:r<ih?9:10},ah={encode:Zu,decode:Xu,encodingLength:ch},fh=ah,ur=fh;function hr(r,t=0){return[ur.decode(r,t),ur.decode.bytes]}function Re(r,t,e=0){return ur.encode(r,t,e),t}function Ue(r){return ur.encodingLength(r)}function ke(r,t){let e=t.byteLength,n=Ue(r),o=n+Ue(e),s=new Uint8Array(o+e);return Re(r,s,0),Re(e,s,n),s.set(t,o),new Oe(r,e,t,s)}function lc(r){let t=Ot(r),[e,n]=hr(t),[o,s]=hr(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Oe(e,o,i,t)}function dc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&rc(r.bytes,e.bytes)}}var Oe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var pc=0,uh="identity",mc=Ot;function hh(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return ke(pc,mc(r))}var lh={code:pc,name:uh,encode:mc,digest:hh};var jo={};q(jo,{sha256:()=>ph,sha512:()=>mh});var dh=20;function Ho({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new Vo(r,t,e,n,o)}var Vo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??dh,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?bc(n,this.code,e?.truncate):n.then(o=>bc(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function bc(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return ke(t,r)}function gc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ph=Ho({name:"sha2-256",code:18,encode:gc("SHA-256")}),mh=Ho({name:"sha2-512",code:19,encode:gc("SHA-512")});function xc(r,t){let{bytes:e,version:n}=r;return n===0?yh(e,Zo(r),t??vt.encoder):gh(e,Zo(r),t??Fe.encoder)}var wc=new WeakMap;function Zo(r){let t=wc.get(r);if(t==null){let e=new Map;return wc.set(r,e),e}return t}var Wr=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!==dr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==xh)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=ke(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&&dc(t.multihash,n.multihash)}toString(t){return xc(this,t)}toJSON(){return{"/":xc(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??Ec(n,o,s.bytes))}else if(e[wh]===!0){let{version:n,multihash:o,code:s}=e,i=lc(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!==dr)throw new Error(`Version 0 CID must use dag-pb (code: ${dr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Ec(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,dr,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=Ot(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 Oe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,E]=hr(t.subarray(e));return e+=E,h},o=n(),s=dr;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),f=n(),a=e+f,u=a-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:u,size:a}}static parse(t,e){let[n,o]=bh(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 Zo(s).set(n,t),s}};function bh(r,t){switch(r[0]){case"Q":{let e=t??vt;return[vt.prefix,e.decode(`${vt.prefix}${r}`)]}case vt.prefix:{let e=t??vt;return[vt.prefix,e.decode(r)]}case Fe.prefix:{let e=t??Fe;return[Fe.prefix,e.decode(r)]}case fr.prefix:{let e=t??fr;return[fr.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 yh(r,t,e){let{prefix:n}=e;if(n!==vt.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 gh(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 dr=112,xh=18;function Ec(r,t,e){let n=Ue(r),o=n+Ue(t),s=new Uint8Array(o+e.byteLength);return Re(r,s,0),Re(t,s,n),s.set(e,o),s}var wh=Symbol.for("@ipld/js-cid/CID");var $o={...Po,...Ro,...Mo,...Lo,...Fo,...Oo,...ko,...No,...Ko,...Uo},T0={...jo,...qo};function _c(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Sc=_c("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yo=_c("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=jt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Eh={utf8:Sc,"utf-8":Sc,hex:$o.base16,latin1:Yo,ascii:Yo,binary:Yo,...$o},vc=Eh;function Ac(r,t="utf8"){let e=vc[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Go(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return jt(i);o+i>t&&(n=jt(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var fe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Xo(){}var Jo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Sh=Go();function _h(r){return globalThis.Buffer!=null?jt(r):Sh(r)}var mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new fe(Xo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new fe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Qo((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(Jr,10,ht.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=ht.fromBigInt(t);return this._push(Jr,e.length(),e)}uint64Number(t){return this._push(Zi,cr(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=ht.fromBigInt(t).zzEncode();return this._push(Jr,e.length(),e)}sint64Number(t){let e=ht.fromNumber(t).zzEncode();return this._push(Jr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Wo,1,t?1:0)}fixed32(t){return this._push(pr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=ht.fromBigInt(t);return this._push(pr,4,e.lo)._push(pr,4,e.hi)}fixed64Number(t){let e=ht.fromNumber(t);return this._push(pr,4,e.lo)._push(pr,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(Yi,4,t)}double(t){return this._push(Xi,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Wo,1,0):this.uint32(e)._push(Ah,e,t)}string(t){let e=Qi(t);return e!==0?this.uint32(e)._push(Ao,e,t):this._push(Wo,1,0)}fork(){return this.states=new Jo(this),this.head=this.tail=new fe(Xo,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 fe(Xo,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=_h(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Wo(r,t,e){t[e]=r&255}function vh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Qo=class extends fe{next;constructor(t,e){super(vh,t,e),this.next=void 0}};function Jr(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 pr(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 Ah(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(mr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Bh,t,r),this},mr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Ih,t,r),this});function Bh(r,t,e){t.set(r,e)}function Ih(r,t,e){r.length<40?Ao(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Ac(r),e)}function ts(){return new mr}function Qr(r,t){let e=ts();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}function*tn(r,t,e){let n=ar(r);yield*t.stream(n,void 0,"$",e)}var en={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function rn(r,t,e,n,o){return{name:r,type:t,encode:e,decode:n,stream:o}}function es(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(i,c){let f=t(i);c.int32(f)},n=function(i){let c=i.int32();return t(c)},o=function*(i){let c=i.int32();yield t(c)};return rn("enum",en.VARINT,e,n,o)}function nn(r,t,e){return rn("message",en.LENGTH_DELIMITED,r,t,e)}var it;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(it||(it={}));var rs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(rs||(rs={}));(function(r){r.codec=()=>es(rs)})(it||(it={}));var br;(function(r){let t;r.codec=()=>(t==null&&(t=nn((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),it.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=it.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:it.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Qr(s,r.codec())}r.encode=e;function n(s,i){return Gr(s,r.codec(),i)}r.decode=n;function o(s,i){return tn(s,r.codec(),i)}r.stream=o})(br||(br={}));var ns;(function(r){let t;r.codec=()=>(t==null&&(t=nn((s,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),it.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),c.lengthDelimited!==!1&&i.ldelim()},(s,i,c={})=>{let f={},a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=it.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,c,f={}){let a=i==null?s.len:s.pos+i;for(;s.pos<a;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${c}.Type`,value:it.codec().decode(s)};break}case 2:{yield{field:`${c}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function e(s){return Qr(s,r.codec())}r.encode=e;function n(s,i){return Gr(s,r.codec(),i)}r.decode=n;function o(s,i){return tn(s,r.codec(),i)}r.stream=o})(ns||(ns={}));var on=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,e){if(Tr(t),ut(e,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(e.length>n?t.create().update(e).digest():e);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Lt(o)}update(t){return Se(this),this.iHash.update(t),this}digestInto(t){Se(this),Dr(t,this),this.finished=!0;let e=t.subarray(0,this.outputLen);this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Bc=(()=>{let r=((t,e,n)=>new on(t,e).update(n).digest());return r.create=(t,e)=>new on(t,e),r})();var Ic=(r,t)=>(r+(r>=0?t:-t)/Tc)/t;function Dh(r,t,e){Ae("scalar",r,At,e);let[[n,o],[s,i]]=t,c=Ic(i*r,e),f=Ic(-o*r,e),a=r-c*n-f*s,u=-c*o-f*i,h=a<At,E=u<At;h&&(a=-a),E&&(u=-u);let m=rr(Math.ceil(Be(e)/2))+Gt;if(a<At||a>=m||u<At||u>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:a,k2neg:E,k2:u}}function ss(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function os(r,t){gt(r);let e={};for(let n of Object.keys(t))e[n]=r[n]===void 0?t[n]:r[n];return bt(e.lowS,"lowS"),bt(e.prehash,"prehash"),e.format!==void 0&&ss(e.format),e}var is=class extends Error{constructor(t=""){super(t)}},wt={Err:is,_tlv:{encode:(r,t)=>{let{Err:e}=wt;if(yt(r,"tag"),r<0||r>255)throw new e("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=tr(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?tr(o.length/2|128):"";return tr(r)+s+o+t},decode(r,t){let{Err:e}=wt;t=M(t,void 0,"DER data");let n=0;if(r<0||r>255)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new e("tlv.decode(long): indefinite length not supported");if(f>4)throw new e("tlv.decode(long): byte length is too big");let a=t.subarray(n,n+f);if(a.length!==f)throw new e("tlv.decode: length bytes not complete");if(a[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of a)i=i<<8|u;if(n+=f,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=wt;if(kr(r),r<At)throw new t("integer: negative integers are not allowed");let e=tr(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}=wt;if(r.length<1)throw new t("invalid signature integer: empty");if(r[0]&128)throw new t("invalid signature integer: negative");if(r.length>1&&r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return oe(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=wt,o=M(r,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:f}=n.decode(2,s),{v:a,l:u}=n.decode(2,f);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(a)}},hexFromSig(r){let{_tlv:t,_int:e}=wt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};Object.freeze(wt._tlv);Object.freeze(wt._int);Object.freeze(wt);var At=BigInt(0),Gt=BigInt(1),Tc=BigInt(2),sn=BigInt(3),Ch=BigInt(4);function Dc(r,t={}){let e=Pr("weierstrass",r,t),n=e.Fp,o=e.Fn,s=e.CURVE,{h:i,n:c}=s;gt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:a}=t;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=Lc(n,o);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function E(k,l,y){if(a&&l.is0())return Uint8Array.of(0);let{x:v,y:x}=l.toAffine(),g=n.toBytes(v);if(bt(y,"isCompressed"),y){h();let A=!n.isOdd(x);return W(Cc(A),g)}else return W(Uint8Array.of(4),g,n.toBytes(x))}function m(k){M(k,void 0,"Point");let{publicKey:l,publicKeyUncompressed:y}=u,v=k.length,x=k[0],g=k.subarray(1);if(a&&v===1&&x===0)return{x:n.ZERO,y:n.ZERO};if(v===l&&(x===2||x===3)){let A=n.fromBytes(g);if(!n.isValid(A))throw new Error("bad point: is not on curve, wrong x");let C=p(A),D;try{D=n.sqrt(C)}catch(K){let P=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+P)}h();let F=n.isOdd(D);return(x&1)===1!==F&&(D=n.neg(D)),{x:A,y:D}}else if(v===y&&x===4){let A=n.BYTES,C=n.fromBytes(g.subarray(0,A)),D=n.fromBytes(g.subarray(A,A*2));if(!b(C,D))throw new Error("bad point: is not on curve");return{x:C,y:D}}else throw new Error(`bad point: got length ${v}, expected compressed=${l} or uncompressed=${y}`)}let d=t.toBytes===void 0?E:t.toBytes,w=t.fromBytes===void 0?m:t.fromBytes;function p(k){let l=n.sqr(k),y=n.mul(l,k);return n.add(n.add(y,n.mul(k,s.a)),s.b)}function b(k,l){let y=n.sqr(l),v=p(k);return n.eql(y,v)}if(!b(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(s.a,sn),Ch),_=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(S,_)))throw new Error("bad curve params: a or b");function T(k,l,y=!1){if(!n.isValid(l)||y&&n.is0(l))throw new Error(`bad point coordinate ${k}`);return l}function I(k){if(!(k instanceof B))throw new Error("Weierstrass Point expected")}function R(k){if(!f||!f.basises)throw new Error("no endo");return Dh(k,f.basises,o.ORDER)}function L(k,l,y,v,x){return y=new B(n.mul(y.X,k),y.Y,y.Z),l=or(v,l),y=or(x,y),l.add(y)}class B{static BASE=new B(s.Gx,s.Gy,n.ONE);static ZERO=new B(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(l,y,v){this.X=T("x",l),this.Y=T("y",y,!0),this.Z=T("z",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(l){let{x:y,y:v}=l||{};if(!l||!n.isValid(y)||!n.isValid(v))throw new Error("invalid affine point");if(l instanceof B)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(v)?B.ZERO:new B(y,v,n.ONE)}static fromBytes(l){let y=B.fromAffine(w(M(l,void 0,"point")));return y.assertValidity(),y}static fromHex(l){return B.fromBytes(ve(l))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(l=8,y=!0){return z.createCache(this,l),y||this.multiply(sn),this}assertValidity(){let l=this;if(l.is0()){if(t.allowInfinityPoint&&n.is0(l.X)&&n.eql(l.Y,n.ONE)&&n.is0(l.Z))return;throw new Error("bad point: ZERO")}let{x:y,y:v}=l.toAffine();if(!n.isValid(y)||!n.isValid(v))throw new Error("bad point: x or y not field elements");if(!b(y,v))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:l}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(l)}equals(l){I(l);let{X:y,Y:v,Z:x}=this,{X:g,Y:A,Z:C}=l,D=n.eql(n.mul(y,C),n.mul(g,x)),F=n.eql(n.mul(v,C),n.mul(A,x));return D&&F}negate(){return new B(this.X,n.neg(this.Y),this.Z)}double(){let{a:l,b:y}=s,v=n.mul(y,sn),{X:x,Y:g,Z:A}=this,C=n.ZERO,D=n.ZERO,F=n.ZERO,U=n.mul(x,x),K=n.mul(g,g),P=n.mul(A,A),N=n.mul(x,g);return N=n.add(N,N),F=n.mul(x,A),F=n.add(F,F),C=n.mul(l,F),D=n.mul(v,P),D=n.add(C,D),C=n.sub(K,D),D=n.add(K,D),D=n.mul(C,D),C=n.mul(N,C),F=n.mul(v,F),P=n.mul(l,P),N=n.sub(U,P),N=n.mul(l,N),N=n.add(N,F),F=n.add(U,U),U=n.add(F,U),U=n.add(U,P),U=n.mul(U,N),D=n.add(D,U),P=n.mul(g,A),P=n.add(P,P),U=n.mul(P,N),C=n.sub(C,U),F=n.mul(P,K),F=n.add(F,F),F=n.add(F,F),new B(C,D,F)}add(l){I(l);let{X:y,Y:v,Z:x}=this,{X:g,Y:A,Z:C}=l,D=n.ZERO,F=n.ZERO,U=n.ZERO,K=s.a,P=n.mul(s.b,sn),N=n.mul(y,g),X=n.mul(v,A),J=n.mul(x,C),Q=n.add(y,v),$=n.add(g,A);Q=n.mul(Q,$),$=n.add(N,X),Q=n.sub(Q,$),$=n.add(y,x);let ct=n.add(g,C);return $=n.mul($,ct),ct=n.add(N,J),$=n.sub($,ct),ct=n.add(v,x),D=n.add(A,C),ct=n.mul(ct,D),D=n.add(X,J),ct=n.sub(ct,D),U=n.mul(K,$),D=n.mul(P,J),U=n.add(D,U),D=n.sub(X,U),U=n.add(X,U),F=n.mul(D,U),X=n.add(N,N),X=n.add(X,N),J=n.mul(K,J),$=n.mul(P,$),X=n.add(X,J),J=n.sub(N,J),J=n.mul(K,J),$=n.add($,J),N=n.mul(X,$),F=n.add(F,N),N=n.mul(ct,$),D=n.mul(Q,D),D=n.sub(D,N),N=n.mul(Q,X),U=n.mul(ct,U),U=n.add(U,N),new B(D,F,U)}subtract(l){return I(l),this.add(l.negate())}is0(){return this.equals(B.ZERO)}multiply(l){let{endo:y}=t;if(!o.isValidNot0(l))throw new RangeError("invalid scalar: out of range");let v,x,g=A=>z.cached(this,A,C=>ce(B,C));if(y){let{k1neg:A,k1:C,k2neg:D,k2:F}=R(l),{p:U,f:K}=g(C),{p:P,f:N}=g(F);x=K.add(N),v=L(y.beta,U,P,A,D)}else{let{p:A,f:C}=g(l);v=A,x=C}return ce(B,[v,x])[0]}multiplyUnsafe(l){let{endo:y}=t,v=this,x=l;if(!o.isValid(x))throw new RangeError("invalid scalar: out of range");if(x===At||v.is0())return B.ZERO;if(x===Gt)return v;if(z.hasCache(this))return this.multiply(x);if(y){let{k1neg:g,k1:A,k2neg:C,k2:D}=R(x),{p1:F,p2:U}=Ci(B,v,A,D);return L(y.beta,F,U,g,C)}else return z.unsafe(v,x)}toAffine(l){let y=this,v=l,{X:x,Y:g,Z:A}=y;if(n.eql(A,n.ONE))return{x,y:g};let C=y.is0();v==null&&(v=C?n.ONE:n.inv(A));let D=n.mul(x,v),F=n.mul(g,v),U=n.mul(A,v);if(C)return{x:n.ZERO,y:n.ZERO};if(!n.eql(U,n.ONE))throw new Error("invZ was invalid");return{x:D,y:F}}isTorsionFree(){let{isTorsionFree:l}=t;return i===Gt?!0:l?l(B,this):z.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:l}=t;return i===Gt?this:l?l(B,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===Gt?this.is0():this.clearCofactor().is0()}toBytes(l=!0){return bt(l,"isCompressed"),this.assertValidity(),d(B,this,l)}toHex(l=!0){return _e(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let O=o.BITS,z=new De(B,t.endo?Math.ceil(O/2):O);return O>=8&&B.BASE.precompute(8),Object.freeze(B.prototype),Object.freeze(B),B}function Cc(r){return Uint8Array.of(r?2:3)}function Lc(r,t){return{secretKey:t.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Lh(r,t={}){let{Fn:e}=r,n=t.randomBytes===void 0?Qe:t.randomBytes,o=Object.assign(Lc(r.Fp,e),{seed:Math.max(ao(e.ORDER),16)});function s(m){try{let d=e.fromBytes(m);return e.isValidNot0(d)}catch{return!1}}function i(m,d){let{publicKey:w,publicKeyUncompressed:p}=o;try{let b=m.length;return d===!0&&b!==w||d===!1&&b!==p?!1:!!r.fromBytes(m)}catch{return!1}}function c(m){return m=m===void 0?n(o.seed):m,fo(M(m,o.seed,"seed"),e.ORDER)}function f(m,d=!0){return r.BASE.multiply(e.fromBytes(m)).toBytes(d)}function a(m){let{secretKey:d,publicKey:w,publicKeyUncompressed:p}=o,b=e._lengths;if(!ne(m))return;let S=M(m,void 0,"key").length,_=S===w||S===p,T=S===d||!!b?.includes(S);if(!(_&&T))return _}function u(m,d,w=!0){if(a(m)===!0)throw new Error("first arg must be private key");if(a(d)===!1)throw new Error("second arg must be public key");let p=e.fromBytes(m);return r.fromBytes(d).multiply(p).toBytes(w)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c},E=zr(c,f);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:E,Point:r,utils:h,lengths:o})}function Fc(r,t,e={}){let n=t;Tr(n),gt(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),e=Object.assign({},e);let o=e.randomBytes===void 0?Qe:e.randomBytes,s=e.hmac===void 0?(x,g)=>Bc(n,x,g):e.hmac,{Fp:i,Fn:c}=r,{ORDER:f,BITS:a}=c,{keygen:u,getPublicKey:h,getSharedSecret:E,utils:m,lengths:d}=Lh(r,e),w={prehash:!0,lowS:typeof e.lowS=="boolean"?e.lowS:!0,format:"compact",extraEntropy:!1},p=f*Tc+Gt<i.ORDER;function b(x){let g=f>>Gt;return x>g}function S(x,g){if(!c.isValidNot0(g))throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);return g}function _(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function T(x,g){ss(g);let A=d.signature,C=g==="compact"?A:g==="recovered"?A+1:void 0;return M(x,C)}class I{r;s;recovery;constructor(g,A,C){if(this.r=S("r",g),this.s=S("s",A),C!=null){if(_(),![0,1,2,3].includes(C))throw new Error("invalid recovery id");this.recovery=C}Object.freeze(this)}static fromBytes(g,A=w.format){T(g,A);let C;if(A==="der"){let{r:K,s:P}=wt.toSig(M(g));return new I(K,P)}A==="recovered"&&(C=g[0],A="compact",g=g.subarray(1));let D=d.signature/2,F=g.subarray(0,D),U=g.subarray(D,D*2);return new I(c.fromBytes(F),c.fromBytes(U),C)}static fromHex(g,A){return this.fromBytes(ve(g),A)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new I(this.r,this.s,g)}recoverPublicKey(g){let{r:A,s:C}=this,D=this.assertRecovery(),F=D===2||D===3?A+f:A;if(!i.isValid(F))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let U=i.toBytes(F),K=r.fromBytes(W(Cc((D&1)===0),U)),P=c.inv(F),N=L(M(g,void 0,"msgHash")),X=c.create(-N*P),J=c.create(C*P),Q=r.BASE.multiplyUnsafe(X).add(K.multiplyUnsafe(J));if(Q.is0())throw new Error("invalid recovery: point at infinify");return Q.assertValidity(),Q}hasHighS(){return b(this.s)}toBytes(g=w.format){if(ss(g),g==="der")return ve(wt.hexFromSig(this));let{r:A,s:C}=this,D=c.toBytes(A),F=c.toBytes(C);return g==="recovered"?(_(),W(Uint8Array.of(this.assertRecovery()),D,F)):W(D,F)}toHex(g){return _e(this.toBytes(g))}}Object.freeze(I.prototype),Object.freeze(I);let R=e.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let A=oe(g),C=g.length*8-a;return C>0?A>>BigInt(C):A}:e.bits2int,L=e.bits2int_modN===void 0?function(g){return c.create(R(g))}:e.bits2int_modN,B=rr(a);function O(x){return Ae("num < 2^"+a,x,At,B),c.toBytes(x)}function z(x,g){return M(x,void 0,"message"),g?M(n(x),void 0,"prehashed message"):x}function k(x,g,A){let{lowS:C,prehash:D,extraEntropy:F}=os(A,w);x=z(x,D);let U=L(x),K=c.fromBytes(g);if(!c.isValidNot0(K))throw new Error("invalid private key");let P=[O(K),O(U)];if(F!=null&&F!==!1){let Q=F===!0?o(d.secretKey):F;P.push(M(Q,void 0,"extraEntropy"))}let N=W(...P),X=U;function J(Q){let $=R(Q);if(!c.isValidNot0($))return;let ct=c.inv($),le=r.BASE.multiply($).toAffine(),Ke=c.create(le.x);if(Ke===At)return;let Er=c.create(ct*c.create(X+Ke*K));if(Er===At)return;let bs=(le.x===Ke?0:2)|Number(le.y&Gt),ys=Er;return C&&b(Er)&&(ys=c.neg(Er),bs^=1),new I(Ke,ys,p?void 0:bs)}return{seed:N,k2sig:J}}function l(x,g,A={}){let{seed:C,k2sig:D}=k(x,g,A);return di(n.outputLen,c.BYTES,s)(C,D).toBytes(A.format)}function y(x,g,A,C={}){let{lowS:D,prehash:F,format:U}=os(C,w);if(A=M(A,void 0,"publicKey"),g=z(g,F),!ne(x)){let K=x instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}T(x,U);try{let K=I.fromBytes(x,U),P=r.fromBytes(A);if(D&&K.hasHighS())return!1;let{r:N,s:X}=K,J=L(g),Q=c.inv(X),$=c.create(J*Q),ct=c.create(N*Q),le=r.BASE.multiplyUnsafe($).add(P.multiplyUnsafe(ct));return le.is0()?!1:c.create(le.x)===N}catch{return!1}}function v(x,g,A={}){let{prehash:C}=os(A,w);return g=z(g,C),I.fromBytes(x,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:h,getSharedSecret:E,utils:m,lengths:d,Point:r,sign:l,verify:y,recoverPublicKey:v,Signature:I,hash:n})}var as={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Fh={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Rc=BigInt(2);function Rh(r){let t=as.p,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),a=r*r*r%t,u=a*a*r%t,h=V(u,e,t)*u%t,E=V(h,e,t)*u%t,m=V(E,Rc,t)*a%t,d=V(m,o,t)*m%t,w=V(d,s,t)*d%t,p=V(w,c,t)*w%t,b=V(p,f,t)*p%t,S=V(b,c,t)*w%t,_=V(S,e,t)*u%t,T=V(_,i,t)*d%t,I=V(T,n,t)*a%t,R=V(I,Rc,t);if(!cs.eql(cs.sqr(R),r))throw new Error("Cannot find square root");return R}var cs=Ie(as.p,{sqrt:Rh}),Uh=Dc(as,{Fp:cs,endo:Fh}),Ne=Fc(Uh,ui);function Uc(r,t,e,n){let o=Ze.digest(e instanceof Uint8Array?e:e.subarray());if(Zr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ne.verify(t,s,r,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new ir(String(s))});try{return n?.signal?.throwIfAborted(),Ne.verify(t,o.digest,r,{prehash:!1,format:"der"})}catch(s){throw new ir(String(s))}}var cn=class{type="secp256k1";raw;_key;constructor(t){this._key=kc(t),this.raw=Oc(this._key)}toMultihash(){return dt.digest(Ee(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return Y.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 Uc(this._key,e,t,n)}};function Nc(r){return new cn(r)}function Oc(r){return Ne.Point.fromBytes(r).toBytes()}function kc(r){try{return Ne.Point.fromBytes(r),r}catch(t){throw new Sr(String(t))}}function Kc(r){let{Type:t,Data:e}=br.decode(r.digest),n=e??new Uint8Array;switch(t){case it.Ed25519:return zi(n);case it.secp256k1:return Nc(n);case it.ECDSA:return $s(n);default:throw new Me}}function Ee(r){return br.encode({Type:it[r.type],Data:r.raw})}var Mc=Symbol.for("nodejs.util.inspect.custom"),Oh=114,yr=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()})`}[mn]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return at.createV1(Oh,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")}[Mc](){return`PeerId(${this.toString()})`}},an=class extends yr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},fn=class extends yr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},un=class extends yr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},kh=2336,hn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=dt.digest(nt(this.url))}[Mc](){return`PeerId(${this.url})`}[mn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return at.createV1(kh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=lt(t)),t.toString()===this.toString())}};function Pc(r){if(Kh(r))return new an({multihash:r});if(Nh(r))try{let t=Kc(r);if(t.type==="Ed25519")return new fn({multihash:r,publicKey:t});if(t.type==="secp256k1")return new un({multihash:r,publicKey:t})}catch{let e=lt(r.digest);return new hn(new URL(e))}throw new _r("Supplied PeerID Multihash is invalid")}function Nh(r){return r.code===dt.code}function Kh(r){return r.code===Ze.code}function Bt(r,t){let e={[Symbol.iterator]:()=>e,next:()=>{let n=r.next(),o=n.value;return n.done===!0||o==null?{done:!0,value:void 0}:{done:!1,value:t(o)}}};return e}function ln(r){let t=Ve(Y.decode(`z${r}`));return Pc(t)}var Xt=class{map;constructor(t){if(this.map=new Map,t!=null)for(let[e,n]of t.entries())this.map.set(e.toString(),{key:e,value:n})}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(t){return this.map.delete(t.toString())}entries(){return Bt(this.map.entries(),t=>[t[1].key,t[1].value])}forEach(t){this.map.forEach((e,n)=>{t(e.value,e.key,this)})}get(t){return this.map.get(t.toString())?.value}has(t){return this.map.has(t.toString())}set(t,e){this.map.set(t.toString(),{key:t,value:e})}keys(){return Bt(this.map.values(),t=>t.key)}values(){return Bt(this.map.values(),t=>t.value)}get size(){return this.map.size}};function zc(){return new Xt}var Wt=class r{set;constructor(t){if(this.set=new Set,t!=null)for(let e of t)this.set.add(e.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(t){this.set.add(t.toString())}clear(){this.set.clear()}delete(t){this.set.delete(t.toString())}entries(){return Bt(this.set.entries(),t=>{let e=ln(t[0]);return[e,e]})}forEach(t){this.set.forEach(e=>{let n=ln(e);t(n,n,this)})}has(t){return this.set.has(t.toString())}values(){return Bt(this.set.values(),t=>ln(t))}intersection(t){let e=new r;for(let n of t)this.has(n)&&e.add(n);return e}difference(t){let e=new r;for(let n of this)t.has(n)||e.add(n);return e}union(t){let e=new r;for(let n of t)e.add(n);for(let n of this)e.add(n);return e}};function qc(){return new Wt}var Jt=class r{list;constructor(t){if(this.list=[],t!=null)for(let e of t)this.list.push(e)}[Symbol.iterator](){return Bt(this.list.entries(),t=>t[1])}concat(t){let e=new r(this);for(let n of t)e.push(n);return e}entries(){return Bt(this.list.entries(),t=>[t[0],t[1]])}every(t){return this.list.every((e,n)=>t(e,n,this))}filter(t){let e=new r;return this.list.forEach((n,o)=>{t(n,o,this)&&e.push(n)}),e}find(t){let e=this.list.find((n,o)=>t(n,o,this));if(e!=null)return e}findIndex(t){return this.list.findIndex((e,n)=>t(e,n,this))}forEach(t){this.list.forEach((e,n)=>{t(e,n,this)})}includes(t){return this.includes(t)}indexOf(t){return this.list.findIndex(e=>e.equals(t))}pop(){let t=this.list.pop();if(t!=null)return t}push(...t){for(let e of t)this.list.push(e)}shift(){let t=this.list.shift();if(t!=null)return t}unshift(...t){let e=this.list.length;for(let n=t.length-1;n>-1;n--)e=this.list.unshift(t[n]);return e}clear(){this.list=[]}get length(){return this.list.length}};function Vc(){return new Jt}var fs={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},Hc={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},jc=new globalThis.TextEncoder;function Mh(r,t){let e=fs[t],n=Hc[t];for(let o=0;o<r.length;o++)n^=BigInt(r[o]),n=BigInt.asUintN(t,n*e);return n}function Ph(r,t,e){if(e.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");let n=fs[t],o=Hc[t],s=r;for(;s.length>0;){let i=jc.encodeInto(s,e);s=s.slice(i.read);for(let c=0;c<i.written;c++)o^=BigInt(e[c]),o=BigInt.asUintN(t,o*n)}return o}function us(r,{size:t=32,utf8Buffer:e}={}){if(!fs[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof r=="string"){if(e)return Ph(r,t,e);r=jc.encode(r)}return Mh(r,t)}var gr={hash:r=>Number(us(r,{size:32})),hashV:(r,t)=>zh(gr.hash(r,t))};function zh(r){let t=r.toString(16);return t.length%2===1&&(t=`0${t}`),nt(t,"base16")}var hs=64,Et=class{fp;h;seed;constructor(t,e,n,o=2){if(o>hs)throw new TypeError("Invalid Fingerprint Size");let s=e.hashV(t,n),i=zs(o);for(let c=0;c<i.length;c++)i[c]=s[c];i.length===0&&(i[0]=7),this.fp=i,this.h=e,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(t){return t?.fp instanceof Uint8Array?pt(this.fp,t.fp):!1}};function ue(r,t){return Math.floor(Math.random()*(t-r))+r}var he=class{contents;constructor(t){this.contents=new Array(t).fill(null)}has(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");return this.contents.some(e=>t.equals(e))}add(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");for(let e=0;e<this.contents.length;e++)if(this.contents[e]==null)return this.contents[e]=t,!0;return!0}swap(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");let e=ue(0,this.contents.length-1),n=this.contents[e];return this.contents[e]=t,n}remove(t){if(!(t instanceof Et))throw new TypeError("Invalid Fingerprint");let e=this.contents.findIndex(n=>t.equals(n));return e>-1?(this.contents[e]=null,!0):!1}};var qh=500,xr=class{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(t){this.filterSize=t.filterSize,this.bucketSize=t.bucketSize??4,this.fingerprintSize=t.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=t.hash??gr,this.seed=t.seed??ue(0,Math.pow(2,10))}add(t){typeof t=="string"&&(t=nt(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=(n^e.hash())%this.filterSize;if(this.buckets[n]==null&&(this.buckets[n]=new he(this.bucketSize)),this.buckets[o]==null&&(this.buckets[o]=new he(this.bucketSize)),this.buckets[n].add(e)||this.buckets[o].add(e))return this.count++,!0;let s=[n,o],i=s[ue(0,s.length-1)];this.buckets[i]==null&&(this.buckets[i]=new he(this.bucketSize));for(let c=0;c<qh;c++){let f=this.buckets[i].swap(e);if(f!=null&&(i=(i^f.hash())%this.filterSize,this.buckets[i]==null&&(this.buckets[i]=new he(this.bucketSize)),this.buckets[i].add(f)))return this.count++,!0}return!1}has(t){typeof t=="string"&&(t=nt(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.has(e)??!1;if(o)return o;let s=(n^e.hash())%this.filterSize;return this.buckets[s]?.has(e)??!1}remove(t){typeof t=="string"&&(t=nt(t));let e=new Et(t,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(t,this.seed)%this.filterSize,o=this.buckets[n]?.remove(e)??!1;if(o)return this.count--,o;let s=(n^e.hash())%this.filterSize,i=this.buckets[s]?.remove(e)??!1;return i&&this.count--,i}get reliable(){return Math.floor(100*(this.count/this.filterSize))<=90}},Vh={1:.5,2:.84,4:.95,8:.98};function Hh(r=.001){return r>.002?2:r>1e-5?4:8}function Zc(r,t=.001){let e=Hh(t),n=Vh[e],o=Math.round(r/n),s=Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*e)),hs);return{filterSize:o,bucketSize:e,fingerprintSize:s}}var dn=class{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(t){this.bucketSize=t.bucketSize??4,this.filterSize=t.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=t.fingerprintSize??2,this.scale=t.scale??2,this.hash=t.hash??gr,this.seed=t.seed??ue(0,Math.pow(2,10)),this.filterSeries=[new xr({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(t){if(typeof t=="string"&&(t=nt(t)),this.has(t))return!0;let e=this.filterSeries.find(n=>n.reliable);if(e==null){let n=this.filterSize*Math.pow(this.scale,this.filterSeries.length);e=new xr({filterSize:n,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(e)}return e.add(t)}has(t){typeof t=="string"&&(t=nt(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].has(t))return!0;return!1}remove(t){typeof t=="string"&&(t=nt(t));for(let e=0;e<this.filterSeries.length;e++)if(this.filterSeries[e].remove(t))return!0;return!1}get count(){return this.filterSeries.reduce((t,e)=>t+e.count,0)}};function ls(r,t=.001,e){return new dn({...Zc(r,t),...e??{}})}var wr=class{filter;constructor(t,e){this.filter=ls(t,e)}has(t){return this.filter.has(t.toMultihash().bytes)}add(t){this.filter.add(t.toMultihash().bytes)}remove(t){this.filter.remove?.(t.toMultihash().bytes)}};function $c(r,t=.001){return new wr(r,t)}var ds=class extends Xt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Yc(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ds({name:t,metrics:e}):n=new Xt,n}var ps=class extends Wt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}add(t){super.add(t),this.updateComponentMetric()}delete(t){super.delete(t),this.updateComponentMetric()}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function Gc(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ps({name:t,metrics:e}):n=new Wt,n}var ms=class extends Jt{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}pop(){let t=super.pop();return this.updateComponentMetric(),t}push(...t){super.push(...t),this.updateComponentMetric()}shift(){let t=super.shift();return this.updateComponentMetric(),t}unshift(...t){let e=super.unshift(...t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.length)}};function Xc(r){let{name:t,metrics:e}=r,n;return e!=null?n=new ms({name:t,metrics:e}):n=new Jt,n}return ea(jh);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js: