@libp2p/plaintext 3.0.20-29797a5bb → 3.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.Libp2PPlaintext = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPlaintext=(()=>{var bn=Object.defineProperty;var bc=Object.getOwnPropertyDescriptor;var yc=Object.getOwnPropertyNames;var xc=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var r in e)bn(t,r,{get:e[r],enumerable:!0})},gc=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of yc(e))!xc.call(t,o)&&o!==r&&bn(t,o,{get:()=>e[o],enumerable:!(n=bc(e,o))||n.enumerable});return t};var wc=t=>gc(bn({},"__esModule",{value:!0}),t);var Eh={};H(Eh,{plaintext:()=>wh});var _r=class extends Error{static name="UnexpectedPeerError";constructor(e="Unexpected Peer"){super(e),this.name="UnexpectedPeerError"}},Gt=class extends Error{static name="InvalidCryptoExchangeError";constructor(e="Invalid crypto exchange"){super(e),this.name="InvalidCryptoExchangeError"}},j=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},gt=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var wt=class extends Error{static name="ProtocolError";constructor(e="Protocol error"){super(e),this.name="ProtocolError"}};var Xt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var yn=Symbol.for("@libp2p/peer-id");var Fs=Symbol.for("@libp2p/service-capabilities");var Sn={};H(Sn,{base58btc:()=>W,base58flickr:()=>Lc});var Xh=new Uint8Array(0);function Ks(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Ce(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ks(t){return new TextEncoder().encode(t)}function Ns(t){return new TextDecoder().decode(t)}function Ec(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,f=t.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,m=0,y=0,S=p.length;y!==S&&p[y]===0;)y++,w++;for(var v=(S-y)*u+1>>>0,T=new Uint8Array(v);y!==S;){for(var L=p[y],U=0,R=v-1;(L!==0||U<m)&&R!==-1;R--,U++)L+=256*T[R]>>>0,T[R]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");m=U,y++}for(var I=v-m;I!==v&&T[I]===0;)I++;for(var F=f.repeat(w);I<v;++I)F+=t.charAt(T[I]);return F}function b(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var m=0,y=0;p[w]===f;)m++,w++;for(var S=(p.length-w)*c+1>>>0,v=new Uint8Array(S);p[w];){var T=r[p.charCodeAt(w)];if(T===255)return;for(var L=0,U=S-1;(T!==0||L<y)&&U!==-1;U--,L++)T+=a*v[U]>>>0,v[U]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");y=L,w++}if(p[w]!==" "){for(var R=S-y;R!==S&&v[R]===0;)R++;for(var I=new Uint8Array(m+(S-R)),F=m;R!==S;)I[F++]=v[R++];return I}}}function h(p){var w=b(p);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:b,decode:h}}var Sc=Ec,vc=Sc,Ms=vc;var xn=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},gn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return qs(this,e)}},wn=class{decoders;constructor(e){this.decoders=e}or(e){return qs(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function qs(t,e){return new wn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var En=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new xn(e,r,n),this.decoder=new gn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Et({name:t,prefix:e,encode:r,decode:n}){return new En(t,e,r,n)}function Ve({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ms(r,t);return Et({prefix:e,name:t,encode:n,decode:s=>Ce(o(s))})}function Ac(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,f=0;for(let c=0;c<o;++c){let u=e[t[c]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Bc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let f=0;f<t.length;++f)for(a=a<<8|t[f],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Ic(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function $({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Ic(n);return Et({prefix:e,name:t,encode(s){return Bc(s,n,r)},decode(s){return Ac(s,o,r,t)}})}var W=Ve({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lc=Ve({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var vn={};H(vn,{base32:()=>St,base32hex:()=>Rc,base32hexpad:()=>Uc,base32hexpadupper:()=>Oc,base32hexupper:()=>Cc,base32pad:()=>Dc,base32padupper:()=>_c,base32upper:()=>Tc,base32z:()=>Fc});var St=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Tc=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Dc=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_c=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Rc=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Cc=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uc=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Oc=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Fc=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var An={};H(An,{base36:()=>Wt,base36upper:()=>Kc});var Wt=Ve({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Kc=Ve({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var kc=zs,Vs=128,Nc=127,Pc=~Nc,Mc=Math.pow(2,31);function zs(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Mc;)e[r++]=t&255|Vs,t/=128;for(;t&Pc;)e[r++]=t&255|Vs,t>>>=7;return e[r]=t|0,zs.bytes=r-n+1,e}var qc=Bn,Vc=128,Hs=127;function Bn(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw Bn.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Hs)<<o:(i&Hs)*Math.pow(2,o),o+=7}while(i>=Vc);return Bn.bytes=s-n,r}var Hc=Math.pow(2,7),zc=Math.pow(2,14),jc=Math.pow(2,21),$c=Math.pow(2,28),Zc=Math.pow(2,35),Yc=Math.pow(2,42),Gc=Math.pow(2,49),Xc=Math.pow(2,56),Wc=Math.pow(2,63),Jc=function(t){return t<Hc?1:t<zc?2:t<jc?3:t<$c?4:t<Zc?5:t<Yc?6:t<Gc?7:t<Xc?8:t<Wc?9:10},Qc={encode:kc,decode:qc,encodingLength:Jc},ef=Qc,Jt=ef;function Qt(t,e=0){return[Jt.decode(t,e),Jt.decode.bytes]}function vt(t,e,r=0){return Jt.encode(t,e,r),e}function At(t){return Jt.encodingLength(t)}function Ae(t,e){let r=e.byteLength,n=At(t),o=n+At(r),s=new Uint8Array(o+r);return vt(t,s,0),vt(r,s,n),s.set(e,o),new Bt(t,r,e,s)}function In(t){let e=Ce(t),[r,n]=Qt(e),[o,s]=Qt(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Bt(r,o,i,e)}function js(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ks(t.bytes,r.bytes)}}var Bt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function $s(t,e){let{bytes:r,version:n}=t;return n===0?rf(r,Ln(t),e??W.encoder):nf(r,Ln(t),e??St.encoder)}var Zs=new WeakMap;function Ln(t){let e=Zs.get(t);if(e==null){let r=new Map;return Zs.set(t,r),r}return e}var ce=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==er)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==of)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ae(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&js(e.multihash,n.multihash)}toString(e){return $s(this,e)}toJSON(){return{"/":$s(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i??Ys(n,o,s.bytes))}else if(r[sf]===!0){let{version:n,multihash:o,code:s}=r,i=In(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==er)throw new Error(`Version 0 CID must use dag-pb (code: ${er}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ys(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,er,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Ce(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Bt(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,b]=Qt(e.subarray(r));return r+=b,l},o=n(),s=er;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),f=n(),c=r+f,u=c-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:u,size:c}}static parse(e,r){let[n,o]=tf(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ln(s).set(n,e),s}};function tf(t,e){switch(t[0]){case"Q":{let r=e??W;return[W.prefix,r.decode(`${W.prefix}${t}`)]}case W.prefix:{let r=e??W;return[W.prefix,r.decode(t)]}case St.prefix:{let r=e??St;return[St.prefix,r.decode(t)]}case Wt.prefix:{let r=e??Wt;return[Wt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function rf(t,e,r){let{prefix:n}=r;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function nf(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var er=112,of=18;function Ys(t,e,r){let n=At(t),o=n+At(e),s=new Uint8Array(o+r.byteLength);return vt(t,s,0),vt(e,s,n),s.set(r,o),s}var sf=Symbol.for("@ipld/js-cid/CID");var Tn={};H(Tn,{identity:()=>Be});var Gs=0,af="identity",Xs=Ce;function cf(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ae(Gs,Xs(t))}var Be={code:Gs,name:af,encode:Xs,digest:cf};function de(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function ff(t){return t.buffer instanceof ArrayBuffer}function Ie(t){return ff(t)?t:t.slice()}var Ws="1.2.840.10045.3.1.7",Js="1.3.132.0.34",Qs="1.3.132.0.35";async function ei(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,Ie(e),Ie(r.subarray()));return n?.signal?.throwIfAborted(),s}function Ue(t=0){return new Uint8Array(t)}function tr(t=0){return new Uint8Array(t)}function Dn(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=tr(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function ti(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var ni=Symbol.for("@achingbrain/uint8arraylist");function ri(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Cr(t){return!!t?.[ni]}var oe=class t{bufs;length;[ni]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Cr(n)){r+=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+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Cr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=ri(this.bufs,e);return r.buf[r.index]}set(e,r){let n=ri(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Cr(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return Dn(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:Dn(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),s=new t;return s.length=o,s.bufs=n,s}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,f=a+i.byteLength;if(o=f,e>=f)continue;let c=e>=a&&e<f,u=r>a&&r<=f;if(c&&u){if(e===a&&r===f){n.push(i);break}let l=e-a;n.push(i.subarray(l,l+(r-e)));break}if(c){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(u){if(r===f){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Cr(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,f=this.byteLength-n.byteLength,c=n.byteLength-1,u;for(let l=r;l<=f;l+=u){u=0;for(let b=c;b>=0;b--){let h=this.get(l+b);if(n[b]!==h){u=Math.max(1,b-a[h]);break}}if(u===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=tr(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Ue(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Ue(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Ue(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=tr(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Ue(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Ue(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Ue(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Ue(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Ue(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ti(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var On={};H(On,{base10:()=>yf});var Dd=new Uint8Array(0);function oi(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Oe(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return rt(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return rt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function si(t){return new TextEncoder().encode(t)}function ii(t){return new TextDecoder().decode(t)}function uf(t){return t?.buffer instanceof ArrayBuffer}function rt(t){return uf(t)?t:t.slice()}function lf(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,f=t.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,m=0,y=0,S=p.length;y!==S&&p[y]===0;)y++,w++;for(var v=(S-y)*u+1>>>0,T=new Uint8Array(v);y!==S;){for(var L=p[y],U=0,R=v-1;(L!==0||U<m)&&R!==-1;R--,U++)L+=256*T[R]>>>0,T[R]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");m=U,y++}for(var I=v-m;I!==v&&T[I]===0;)I++;for(var F=f.repeat(w);I<v;++I)F+=t.charAt(T[I]);return F}function b(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var m=0,y=0;p[w]===f;)m++,w++;for(var S=(p.length-w)*c+1>>>0,v=new Uint8Array(S);p[w];){var T=r[p.charCodeAt(w)];if(T===255)return;for(var L=0,U=S-1;(T!==0||L<y)&&U!==-1;U--,L++)T+=a*v[U]>>>0,v[U]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");y=L,w++}if(p[w]!==" "){for(var R=S-y;R!==S&&v[R]===0;)R++;for(var I=new Uint8Array(m+(S-R)),F=m;R!==S;)I[F++]=v[R++];return I}}}function h(p){var w=b(p);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:b,decode:h}}var hf=lf,df=hf,ci=df;var _n=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Rn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return fi(this,e)}},Cn=class{decoders;constructor(e){this.decoders=e}or(e){return fi(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function fi(t,e){return new Cn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Un=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new _n(e,r,n),this.decoder=new Rn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Lt({name:t,prefix:e,encode:r,decode:n}){return new Un(t,e,r,n)}function He({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=ci(r,t);return Lt({prefix:e,name:t,encode:n,decode:s=>Oe(o(s))})}function pf(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,f=0;for(let c=0;c<o;++c){let u=e[t[c]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function mf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let f=0;f<t.length;++f)for(a=a<<8|t[f],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function bf(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function Z({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=bf(n);return Lt({prefix:e,name:t,encode(s){return mf(s,n,r)},decode(s){return pf(s,o,r,t)}})}var yf=He({prefix:"9",name:"base10",alphabet:"0123456789"});var Fn={};H(Fn,{base16:()=>xf,base16upper:()=>gf});var xf=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gf=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Kn={};H(Kn,{base2:()=>wf});var wf=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kn={};H(kn,{base256emoji:()=>Bf});var ui=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=ui.reduce((t,e,r)=>(t[r]=e,t),[]),Sf=ui.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function vf(t){return t.reduce((e,r)=>(e+=Ef[r],e),"")}function Af(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Sf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Bf=Lt({prefix:"\u{1F680}",name:"base256emoji",encode:vf,decode:Af});var Nn={};H(Nn,{base32:()=>Tt,base32hex:()=>Df,base32hexpad:()=>Rf,base32hexpadupper:()=>Cf,base32hexupper:()=>_f,base32pad:()=>Lf,base32padupper:()=>Tf,base32upper:()=>If,base32z:()=>Uf});var Tt=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),If=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lf=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tf=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Df=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_f=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rf=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cf=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Uf=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pn={};H(Pn,{base36:()=>rr,base36upper:()=>Of});var rr=He({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Of=He({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Mn={};H(Mn,{base58btc:()=>Le,base58flickr:()=>Ff});var Le=He({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ff=He({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qn={};H(qn,{base64:()=>Kf,base64pad:()=>kf,base64url:()=>Nf,base64urlpad:()=>Pf});var Kf=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),kf=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nf=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Pf=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Vn={};H(Vn,{base8:()=>Mf});var Mf=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hn={};H(Hn,{identity:()=>qf});var qf=Lt({prefix:"\0",name:"identity",encode:t=>ii(t),decode:t=>si(t)});var jd=new TextEncoder,$d=new TextDecoder;var jn={};H(jn,{identity:()=>uu});var zf=di,li=128,jf=127,$f=~jf,Zf=Math.pow(2,31);function di(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Zf;)e[r++]=t&255|li,t/=128;for(;t&$f;)e[r++]=t&255|li,t>>>=7;return e[r]=t|0,di.bytes=r-n+1,e}var Yf=zn,Gf=128,hi=127;function zn(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw zn.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&hi)<<o:(i&hi)*Math.pow(2,o),o+=7}while(i>=Gf);return zn.bytes=s-n,r}var Xf=Math.pow(2,7),Wf=Math.pow(2,14),Jf=Math.pow(2,21),Qf=Math.pow(2,28),eu=Math.pow(2,35),tu=Math.pow(2,42),ru=Math.pow(2,49),nu=Math.pow(2,56),ou=Math.pow(2,63),su=function(t){return t<Xf?1:t<Wf?2:t<Jf?3:t<Qf?4:t<eu?5:t<tu?6:t<ru?7:t<nu?8:t<ou?9:10},iu={encode:zf,decode:Yf,encodingLength:su},au=iu,nr=au;function or(t,e=0){return[nr.decode(t,e),nr.decode.bytes]}function Dt(t,e,r=0){return nr.encode(t,e,r),e}function _t(t){return nr.encodingLength(t)}function Ct(t,e){let r=e.byteLength,n=_t(t),o=n+_t(r),s=new Uint8Array(o+r);return Dt(t,s,0),Dt(r,s,n),s.set(e,o),new Rt(t,r,e,s)}function pi(t){let e=Oe(t),[r,n]=or(e),[o,s]=or(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Rt(r,o,i,e)}function mi(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&oi(t.bytes,r.bytes)}}var Rt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=rt(n),this.bytes=rt(o)}};var bi=0,cu="identity",yi=Oe;function fu(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ct(bi,yi(t))}var uu={code:bi,name:cu,encode:yi,digest:fu};var Yn={};H(Yn,{sha256:()=>hu,sha512:()=>du});var lu=20;function Zn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new $n(t,e,r,n,o)}var $n=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,s){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??lu,this.maxDigestLength=s}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?xi(n,this.code,r?.truncate):n.then(o=>xi(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function xi(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ct(e,t)}function wi(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var hu=Zn({name:"sha2-256",code:18,encode:wi("SHA-256")}),du=Zn({name:"sha2-512",code:19,encode:wi("SHA-512")});function Ei(t,e){let{bytes:r,version:n}=t;return n===0?mu(r,Gn(t),e??Le.encoder):bu(r,Gn(t),e??Tt.encoder)}var Si=new WeakMap;function Gn(t){let e=Si.get(t);if(e==null){let r=new Map;return Si.set(t,r),r}return e}var Or=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=rt(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:e,multihash:r}=this;if(e!==ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==yu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ct(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&mi(e.multihash,n.multihash)}toString(e){return Ei(this,e)}toJSON(){return{"/":Ei(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i??vi(n,o,s.bytes))}else if(r[xu]===!0){let{version:n,multihash:o,code:s}=r,i=pi(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==ir)throw new Error(`Version 0 CID must use dag-pb (code: ${ir}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=vi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ir,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Oe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Rt(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,b]=or(e.subarray(r));return r+=b,l},o=n(),s=ir;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),f=n(),c=r+f,u=c-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:u,size:c}}static parse(e,r){let[n,o]=pu(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Gn(s).set(n,e),s}};function pu(t,e){switch(t[0]){case"Q":{let r=e??Le;return[Le.prefix,r.decode(`${Le.prefix}${t}`)]}case Le.prefix:{let r=e??Le;return[Le.prefix,r.decode(t)]}case Tt.prefix:{let r=e??Tt;return[Tt.prefix,r.decode(t)]}case rr.prefix:{let r=e??rr;return[rr.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function mu(t,e,r){let{prefix:n}=r;if(n!==Le.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function bu(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var ir=112,yu=18;function vi(t,e,r){let n=_t(t),o=n+_t(e),s=new Uint8Array(o+r.byteLength);return Dt(t,s,0),Dt(e,s,n),s.set(r,o),s}var xu=Symbol.for("@ipld/js-cid/CID");var Xn={...Hn,...Kn,...Vn,...On,...Fn,...Nn,...Pn,...Mn,...qn,...kn},pp={...Yn,...jn};function Ai(t=0){return new Uint8Array(t)}function Wn(t=0){return new Uint8Array(t)}function Ii(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Bi=Ii("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Jn=Ii("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Wn(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),gu={utf8:Bi,"utf-8":Bi,hex:Xn.base16,latin1:Jn,ascii:Jn,binary:Jn,...Xn},Fr=gu;function ee(t,e="utf8"){let r=Fr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function Y(t,e="utf8"){let r=Fr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var wu=parseInt("11111",2),Qn=parseInt("10000000",2),Eu=parseInt("01111111",2),Li={0:ar,1:ar,2:Su,3:Bu,4:Iu,5:Au,6:vu,16:ar,22:ar,48:ar};function Te(t,e={offset:0}){let r=t[e.offset]&wu;if(e.offset++,Li[r]!=null)return Li[r](t,e);throw new Error("No decoder for tag "+r)}function cr(t,e){let r=0;if((t[e.offset]&Qn)===Qn){let n=t[e.offset]&Eu,o="0x";e.offset++;for(let s=0;s<n;s++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function ar(t,e){cr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Te(t,e);if(n===null)break;r.push(n)}return r}function Su(t,e){let r=cr(t,e),n=e.offset,o=e.offset+r,s=[];for(let i=n;i<o;i++)i===n&&t[i]===0||s.push(t[i]);return e.offset+=r,Uint8Array.from(s)}function vu(t,e){let r=cr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,f=[];for(;e.offset<n;){let c=t[e.offset];if(e.offset++,f.push(c&127),c<128){f.reverse();let u=0;for(let l=0;l<f.length;l++)u+=f[l]<<l*7;a+=`.${u}`,f=[]}}return a}function Au(t,e){return e.offset++,null}function Bu(t,e){let r=cr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Iu(t,e){let r=cr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function Lu(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new oe;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function eo(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=Lu(t.byteLength);return new oe(Uint8Array.from([e.byteLength|Qn]),e)}function pe(t){let e=new oe,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new oe(Uint8Array.from([2]),eo(e),e)}function Kr(t){let e=Uint8Array.from([0]),r=new oe(e,t);return new oe(Uint8Array.from([3]),eo(r),r)}function ze(t,e=48){let r=new oe;for(let n of t)r.append(n);return new oe(Uint8Array.from([e]),eo(r),r)}var Tu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Du=Uint8Array.from([6,5,43,129,4,0,34]),_u=Uint8Array.from([6,5,43,129,4,0,35]),Ru={ext:!0,kty:"EC",crv:"P-256"},Cu={ext:!0,kty:"EC",crv:"P-384"},Uu={ext:!0,kty:"EC",crv:"P-521"},to=32,ro=48,no=66;function Ti(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===to*2+1)return n=Y(e.subarray(r,r+to),"base64url"),o=Y(e.subarray(r+to),"base64url"),new Ut({...Ru,key_ops:["verify"],x:n,y:o});if(e.byteLength===ro*2+1)return n=Y(e.subarray(r,r+ro),"base64url"),o=Y(e.subarray(r+ro),"base64url"),new Ut({...Cu,key_ops:["verify"],x:n,y:o});if(e.byteLength===no*2+1)return n=Y(e.subarray(r,r+no),"base64url"),o=Y(e.subarray(r+no),"base64url"),new Ut({...Uu,key_ops:["verify"],x:n,y:o});throw new j(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Di(t){return ze([pe(Uint8Array.from([1])),ze([Ou(t.crv)],160),ze([Kr(new oe(Uint8Array.from([4]),ee(t.x??"","base64url"),ee(t.y??"","base64url")))],161)]).subarray()}function Ou(t){if(t==="P-256")return Tu;if(t==="P-384")return Du;if(t==="P-521")return _u;throw new j(`Invalid curve ${t}`)}var Ut=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Di(this.jwk)),this._raw}toMultihash(){return Be.digest(Ot(this))}toCID(){return ce.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:de(this.raw,e.raw)}async verify(e,r,n){return ei(this.jwk,r,e,n)}};function oo(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function je(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function me(t,e,r=""){let n=oo(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,a=s?` of length ${e}`:"",f=n?`length=${o}`:`type=${typeof t}`,c=i+"expected Uint8Array"+a+", got "+f;throw n?new RangeError(c):new TypeError(c)}return t}function kr(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(je(t.outputLen),je(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Ft(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Nr(t,e){me(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Ke(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Pr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function xe(t,e){return t<<32-e|t>>>e}var Ri=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Fu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Mr(t){if(me(t),Ri)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Fu[t[r]];return e}var Fe={_0:48,_9:57,A:65,F:70,a:97,f:102};function _i(t){if(t>=Fe._0&&t<=Fe._9)return t-Fe._0;if(t>=Fe.A&&t<=Fe.F)return t-(Fe.A-10);if(t>=Fe.a&&t<=Fe.f)return t-(Fe.a-10)}function fr(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Ri)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=_i(t.charCodeAt(s)),a=_i(t.charCodeAt(s+1));if(i===void 0||a===void 0){let f=t[s]+t[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+a}return n}function so(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];me(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function io(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Ci(t=32){je(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ao=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Ui(t,e,r){return t&e^~t&r}function Oi(t,e,r){return t&e^t&r^e&r}var ur=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Pr(this.buffer)}update(e){Ft(this),me(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let f=Pr(e);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ft(this),Nr(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ke(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let a=Pr(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let c=f/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<c;l++)a.setUint32(4*l,u[l],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=a,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ie=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var qr=BigInt(4294967295),Fi=BigInt(32);function Ku(t,e=!1){return e?{h:Number(t&qr),l:Number(t>>Fi&qr)}:{h:Number(t>>Fi&qr)|0,l:Number(t&qr)|0}}function Ki(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Ku(t[s],e);[n[s],o[s]]=[i,a]}return[n,o]}var co=(t,e,r)=>t>>>r,fo=(t,e,r)=>t<<32-r|e>>>r,nt=(t,e,r)=>t>>>r|e<<32-r,ot=(t,e,r)=>t<<32-r|e>>>r,lr=(t,e,r)=>t<<64-r|e>>>r-32,hr=(t,e,r)=>t>>>r-32|e<<64-r;function De(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var ki=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Ni=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Pi=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Mi=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,qi=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Vi=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;var Nu=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]),$e=new Uint32Array(64),uo=class extends ur{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:a,H:f}=this;return[e,r,n,o,s,i,a,f]}set(e,r,n,o,s,i,a,f){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=f|0}process(e,r){for(let l=0;l<16;l++,r+=4)$e[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let b=$e[l-15],h=$e[l-2],p=xe(b,7)^xe(b,18)^b>>>3,w=xe(h,17)^xe(h,19)^h>>>10;$e[l]=w+$e[l-7]+p+$e[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:f,G:c,H:u}=this;for(let l=0;l<64;l++){let b=xe(a,6)^xe(a,11)^xe(a,25),h=u+b+Ui(a,f,c)+Nu[l]+$e[l]|0,w=(xe(n,2)^xe(n,13)^xe(n,22))+Oi(n,o,s)|0;u=c,c=f,f=a,a=i+h|0,i=s,s=o,o=n,n=h+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,f=f+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,f,c,u)}roundClean(){Ke($e)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ke(this.buffer)}},lo=class extends uo{A=ke[0]|0;B=ke[1]|0;C=ke[2]|0;D=ke[3]|0;E=ke[4]|0;F=ke[5]|0;G=ke[6]|0;H=ke[7]|0;constructor(){super(32)}};var Hi=Ki(["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(t=>BigInt(t))),Pu=Hi[0],Mu=Hi[1],Ze=new Uint32Array(80),Ye=new Uint32Array(80),ho=class extends ur{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:f,Eh:c,El:u,Fh:l,Fl:b,Gh:h,Gl:p,Hh:w,Hl:m}=this;return[e,r,n,o,s,i,a,f,c,u,l,b,h,p,w,m]}set(e,r,n,o,s,i,a,f,c,u,l,b,h,p,w,m){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=f|0,this.Eh=c|0,this.El=u|0,this.Fh=l|0,this.Fl=b|0,this.Gh=h|0,this.Gl=p|0,this.Hh=w|0,this.Hl=m|0}process(e,r){for(let v=0;v<16;v++,r+=4)Ze[v]=e.getUint32(r),Ye[v]=e.getUint32(r+=4);for(let v=16;v<80;v++){let T=Ze[v-15]|0,L=Ye[v-15]|0,U=nt(T,L,1)^nt(T,L,8)^co(T,L,7),R=ot(T,L,1)^ot(T,L,8)^fo(T,L,7),I=Ze[v-2]|0,F=Ye[v-2]|0,V=nt(I,F,19)^lr(I,F,61)^co(I,F,6),K=ot(I,F,19)^hr(I,F,61)^fo(I,F,6),d=Pi(R,K,Ye[v-7],Ye[v-16]),x=Mi(d,U,V,Ze[v-7],Ze[v-16]);Ze[v]=x|0,Ye[v]=d|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:f,Dh:c,Dl:u,Eh:l,El:b,Fh:h,Fl:p,Gh:w,Gl:m,Hh:y,Hl:S}=this;for(let v=0;v<80;v++){let T=nt(l,b,14)^nt(l,b,18)^lr(l,b,41),L=ot(l,b,14)^ot(l,b,18)^hr(l,b,41),U=l&h^~l&w,R=b&p^~b&m,I=qi(S,L,R,Mu[v],Ye[v]),F=Vi(I,y,T,U,Pu[v],Ze[v]),V=I|0,K=nt(n,o,28)^lr(n,o,34)^lr(n,o,39),d=ot(n,o,28)^hr(n,o,34)^hr(n,o,39),x=n&s^n&a^s&a,A=o&i^o&f^i&f;y=w|0,S=m|0,w=h|0,m=p|0,h=l|0,p=b|0,{h:l,l:b}=De(c|0,u|0,F|0,V|0),c=a|0,u=f|0,a=s|0,f=i|0,s=n|0,i=o|0;let E=ki(V,d,A);n=Ni(E,F,K,x),o=E|0}({h:n,l:o}=De(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=De(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:f}=De(this.Ch|0,this.Cl|0,a|0,f|0),{h:c,l:u}=De(this.Dh|0,this.Dl|0,c|0,u|0),{h:l,l:b}=De(this.Eh|0,this.El|0,l|0,b|0),{h,l:p}=De(this.Fh|0,this.Fl|0,h|0,p|0),{h:w,l:m}=De(this.Gh|0,this.Gl|0,w|0,m|0),{h:y,l:S}=De(this.Hh|0,this.Hl|0,y|0,S|0),this.set(n,o,s,i,a,f,c,u,l,b,h,p,w,m,y,S)}roundClean(){Ke(Ze,Ye)}destroy(){this.destroyed=!0,Ke(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},po=class extends ho{Ah=ie[0]|0;Al=ie[1]|0;Bh=ie[2]|0;Bl=ie[3]|0;Ch=ie[4]|0;Cl=ie[5]|0;Dh=ie[6]|0;Dl=ie[7]|0;Eh=ie[8]|0;El=ie[9]|0;Fh=ie[10]|0;Fl=ie[11]|0;Gh=ie[12]|0;Gl=ie[13]|0;Hh=ie[14]|0;Hl=ie[15]|0;constructor(){super(64)}};var Kt=io(()=>new lo,ao(1));var Vr=io(()=>new po,ao(3));var P=(t,e,r)=>me(t,e,r),bo=je,kt=Mr,te=(...t)=>so(...t),Nt=t=>fr(t),st=oo,dr=t=>Ci(t),zr=BigInt(0),mo=BigInt(1);function ge(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function jr(t){if(typeof t=="bigint"){if(!Hr(t))throw new RangeError("positive bigint expected, got "+t)}else bo(t);return t}function we(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function pr(t){let e=jr(t).toString(16);return e.length&1?"0"+e:e}function zi(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?zr:BigInt("0x"+t)}function it(t){return zi(Mr(t))}function _e(t){return zi(Mr(mr(me(t)).reverse()))}function $r(t,e){if(je(e),e===0)throw new RangeError("zero length");t=jr(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return fr(r.padStart(e*2,"0"))}function yo(t,e){return $r(t,e).reverse()}function ji(t,e){if(t=P(t),e=P(e),t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function mr(t){return Uint8Array.from(P(t))}function Zr(t){if(typeof t!="string")throw new TypeError("ascii string expected, got "+typeof t);return Uint8Array.from(t,(e,r)=>{let n=e.charCodeAt(0);if(e.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})}var Hr=t=>typeof t=="bigint"&&zr<=t;function qu(t,e,r){return Hr(t)&&Hr(e)&&Hr(r)&&e<=t&&t<r}function Pt(t,e,r,n){if(!qu(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Mt(t){if(t<zr)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>zr;t>>=mo,e+=1);return e}var br=t=>(mo<<BigInt(t))-mo;function $i(t,e,r){if(je(t,"hashLen"),je(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=m=>new Uint8Array(m),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,f=n(t),c=n(t),u=0,l=()=>{f.fill(1),c.fill(0),u=0},b=(...m)=>r(c,te(f,...m)),h=(m=o)=>{c=b(s,m),f=b(),m.length!==0&&(c=b(i,m),f=b())},p=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let m=0,y=[];for(;m<e;){f=b();let S=f.slice();y.push(S),m+=f.length}return te(...y)};return(m,y)=>{l(),h(m);let S;for(;(S=y(p()))===void 0;)h();return l(),S}}function Ee(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,a){if(!a&&i!=="function"&&!Object.hasOwn(t,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=t[s];if(a&&f===void 0)return;let c=typeof f;if(c!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${c}`)}let o=(s,i)=>Object.entries(s).forEach(([a,f])=>n(a,f,i));o(e,!1),o(r,!0)}var xo=()=>{throw new Error("not implemented")};var ae=BigInt(0),G=BigInt(1),at=BigInt(2),Xi=BigInt(3),Wi=BigInt(4),Ji=BigInt(5),Vu=BigInt(7),Qi=BigInt(8),Hu=BigInt(9),ea=BigInt(16);function J(t,e){if(e<=ae)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=ae?r:e+r}function z(t,e,r){if(e<ae)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >ae;)n*=n,n%=r;return n}function Zi(t,e){if(t===ae)throw new Error("invert: expected non-zero number");if(e<=ae)throw new Error("invert: expected positive modulus, got "+e);let r=J(t,e),n=e,o=ae,s=G,i=G,a=ae;for(;r!==ae;){let c=n/r,u=n-r*c,l=o-i*c,b=s-a*c;n=r,r=u,o=i,s=a,i=l,a=b}if(n!==G)throw new Error("invert: does not exist");return J(o,e)}function go(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function ta(t,e){let r=t,n=(r.ORDER+G)/Wi,o=r.pow(e,n);return go(r,o,e),o}function zu(t,e){let r=t,n=(r.ORDER-Ji)/Qi,o=r.mul(e,at),s=r.pow(o,n),i=r.mul(e,s),a=r.mul(r.mul(i,at),s),f=r.mul(i,r.sub(a,r.ONE));return go(r,f,e),f}function ju(t){let e=qt(t),r=ra(t),n=r(e,e.neg(e.ONE)),o=r(e,n),s=r(e,e.neg(n)),i=(t+Vu)/ea;return((a,f)=>{let c=a,u=c.pow(f,i),l=c.mul(u,n),b=c.mul(u,o),h=c.mul(u,s),p=c.eql(c.sqr(l),f),w=c.eql(c.sqr(b),f);u=c.cmov(u,l,p),l=c.cmov(h,b,w);let m=c.eql(c.sqr(l),f),y=c.cmov(u,l,m);return go(c,y,f),y})}function ra(t){if(t<Xi)throw new Error("sqrt is not defined for small field");let e=t-G,r=0;for(;e%at===ae;)e/=at,r++;let n=at,o=qt(t);for(;Yi(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return ta;let s=o.pow(n,e),i=(e+G)/at;return function(f,c){let u=f;if(u.is0(c))return c;if(Yi(u,c)!==1)throw new Error("Cannot find square root");let l=r,b=u.mul(u.ONE,s),h=u.pow(c,e),p=u.pow(c,i);for(;!u.eql(h,u.ONE);){if(u.is0(h))return u.ZERO;let w=1,m=u.sqr(h);for(;!u.eql(m,u.ONE);)if(w++,m=u.sqr(m),w===l)throw new Error("Cannot find square root");let y=G<<BigInt(l-w-1),S=u.pow(b,y);l=w,b=u.sqr(S),h=u.mul(h,b),p=u.mul(p,S)}return p}}function $u(t){return t%Wi===Xi?ta:t%Qi===Ji?zu:t%ea===Hu?ju(t):ra(t)}var Ne=(t,e)=>(J(t,e)&G)===G,Zu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Zu.reduce((n,o)=>(n[o]="function",n),e);if(Ee(t,r),we(t.BYTES,"BYTES"),we(t.BITS,"BITS"),t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=G)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Yu(t,e,r){let n=t;if(r<ae)throw new Error("invalid exponent, negatives unsupported");if(r===ae)return n.ONE;if(r===G)return e;let o=n.ONE,s=e;for(;r>ae;)r&G&&(o=n.mul(o,s)),s=n.sqr(s),r>>=G;return o}function yr(t,e,r=!1){let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),s=e.reduce((a,f,c)=>n.is0(f)?a:(o[c]=a,n.mul(a,f)),n.ONE),i=n.inv(s);return e.reduceRight((a,f,c)=>n.is0(f)?a:(o[c]=n.mul(a,o[c]),n.mul(a,f)),i),o}function Yi(t,e){let r=t,n=(r.ORDER-G)/at,o=r.pow(e,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Gu(t,e){if(e!==void 0&&bo(e),t<=ae)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=Mt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${e})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Gi=new WeakMap,Yr=class{ORDER;BITS;BYTES;isLE;ZERO=ae;ONE=G;_lengths;_mod;constructor(e,r={}){if(e<=G)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=Gu(e,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(e){return J(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ae<=e&&e<this.ORDER}is0(e){return e===ae}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&G)===G}neg(e){return J(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return J(e*e,this.ORDER)}add(e,r){return J(e+r,this.ORDER)}sub(e,r){return J(e-r,this.ORDER)}mul(e,r){return J(e*r,this.ORDER)}pow(e,r){return Yu(this,e,r)}div(e,r){return J(e*Zi(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return Zi(e,this.ORDER)}sqrt(e){let r=Gi.get(this);return r||Gi.set(this,r=$u(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?yo(e,this.BYTES):$r(e,this.BYTES)}fromBytes(e,r=!1){P(e);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,s?0:c.length-e.length),e=c}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let f=s?_e(e):it(e);if(a&&(f=J(f,i)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(e){return yr(this,e)}cmov(e,r,n){return ge(n,"condition"),n?r:e}};Object.freeze(Yr.prototype);function qt(t,e={}){return new Yr(t,e)}function na(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=G)throw new Error("field order must be greater than 1");let e=Mt(t-G);return Math.ceil(e/8)}function Eo(t){let e=na(t);return e+Math.ceil(e/2)}function So(t,e,r=!1){P(t);let n=t.length,o=na(e),s=Math.max(Eo(e),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?_e(t):it(t),a=J(i,e-G)+G;return r?yo(a,o):$r(a,o)}var Vt=BigInt(0),ct=BigInt(1);function xr(t,e){let r=e.negate();return t?r:e}function ft(t,e){let r=yr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function aa(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function vo(t,e){aa(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,s=br(t),i=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function oa(t,e,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,a=Number(t&o),f=t>>i;a>n&&(a-=s,f+=ct);let c=e*n,u=c+Math.abs(a)-1,l=a===0,b=a<0,h=e%2!==0;return{nextN:f,offset:u,isZero:l,isNeg:b,isNegF:h,offsetF:c}}var Ao=new WeakMap,ca=new WeakMap;function Bo(t){return ca.get(t)||1}function sa(t){if(t!==Vt)throw new Error("invalid wNAF")}var Ht=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>Vt;)r&ct&&(n=n.add(o)),o=o.double(),r>>=ct;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=vo(r,this.bits),s=[],i=e,a=i;for(let f=0;f<n;f++){a=i,s.push(a);for(let c=1;c<o;c++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=vo(e,this.bits);for(let a=0;a<i.windows;a++){let{nextN:f,offset:c,isZero:u,isNeg:l,isNegF:b,offsetF:h}=oa(n,a,i);n=f,u?s=s.add(xr(b,r[h])):o=o.add(xr(l,r[c]))}return sa(n),{p:o,f:s}}wNAFUnsafe(e,r,n,o=this.ZERO){let s=vo(e,this.bits);for(let i=0;i<s.windows&&n!==Vt;i++){let{nextN:a,offset:f,isZero:c,isNeg:u}=oa(n,i,s);if(n=a,!c){let l=r[f];o=o.add(u?l.negate():l)}}return sa(n),o}getPrecomputes(e,r,n){let o=Ao.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Ao.set(r,o))),o}cached(e,r,n){let o=Bo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let s=Bo(e);return s===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,o)}createCache(e,r){aa(r,this.bits),ca.set(e,r),Ao.delete(e)}hasCache(e){return Bo(e)!==1}};function fa(t,e,r,n){let o=e,s=t.ZERO,i=t.ZERO;for(;r>Vt||n>Vt;)r&ct&&(s=s.add(o)),n&ct&&(i=i.add(o)),o=o.double(),r>>=ct,n>>=ct;return{p1:s,p2:i}}function ia(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wo(e),e}else return qt(t,{isLE:r})}function Gr(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let f of["p","n","h"]){let c=e[f];if(!(typeof c=="bigint"&&c>Vt))throw new Error(`CURVE.${f} must be positive bigint`)}let o=ia(e.p,r.Fp,n),s=ia(e.n,r.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let f of a)if(!o.isValid(e[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}function Xr(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Ge=BigInt(0),se=BigInt(1),Io=BigInt(2),Xu=BigInt(8);function Wu(t,e,r,n){let o=t.sqr(r),s=t.sqr(n),i=t.add(t.mul(e.a,o),s),a=t.add(t.ONE,t.mul(e.d,t.mul(o,s)));return t.eql(i,a)}function ua(t,e={}){let r=e,n=Gr("edwards",t,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;Ee(r,{},{uvRatio:"function"});let f=Io<<BigInt(s.BYTES*8)-se,c=w=>o.create(w),u=r.uvRatio===void 0?(w,m)=>{try{return{isValid:!0,value:o.sqrt(o.div(w,m))}}catch{return{isValid:!1,value:Ge}}}:r.uvRatio;if(!Wu(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function l(w,m,y=!1){let S=y?se:Ge;return Pt("coordinate "+w,m,S,f),m}function b(w){if(!(w instanceof h))throw new Error("EdwardsPoint expected")}class h{static BASE=new h(i.Gx,i.Gy,se,c(i.Gx*i.Gy));static ZERO=new h(Ge,se,se,Ge);static Fp=o;static Fn=s;X;Y;Z;T;constructor(m,y,S,v){this.X=l("x",m),this.Y=l("y",y),this.Z=l("z",S,!0),this.T=l("t",v),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){if(m instanceof h)throw new Error("extended point not allowed");let{x:y,y:S}=m||{};return l("x",y),l("y",S),new h(y,S,se,c(y*S))}static fromBytes(m,y=!1){let S=o.BYTES,{a:v,d:T}=i;m=mr(P(m,S,"point")),ge(y,"zip215");let L=mr(m),U=m[S-1];L[S-1]=U&-129;let R=_e(L),I=y?f:o.ORDER;Pt("point.y",R,Ge,I);let F=c(R*R),V=c(F-se),K=c(T*F-v),{isValid:d,value:x}=u(V,K);if(!d)throw new Error("bad point: invalid y coordinate");let A=(x&se)===se,E=(U&128)!==0;if(!y&&x===Ge&&E)throw new Error("bad point: x=0 and x_0=1");return E!==A&&(x=c(-x)),h.fromAffine({x,y:R})}static fromHex(m,y=!1){return h.fromBytes(Nt(m),y)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,y=!0){return p.createCache(this,m),y||this.multiply(Io),this}assertValidity(){let m=this,{a:y,d:S}=i;if(m.is0())throw new Error("bad point: ZERO");let{X:v,Y:T,Z:L,T:U}=m,R=c(v*v),I=c(T*T),F=c(L*L),V=c(F*F),K=c(R*y),d=c(F*c(K+I)),x=c(V+c(S*c(R*I)));if(d!==x)throw new Error("bad point: equation left != right (1)");let A=c(v*T),E=c(L*U);if(A!==E)throw new Error("bad point: equation left != right (2)")}equals(m){b(m);let{X:y,Y:S,Z:v}=this,{X:T,Y:L,Z:U}=m,R=c(y*U),I=c(T*v),F=c(S*U),V=c(L*v);return R===I&&F===V}is0(){return this.equals(h.ZERO)}negate(){return new h(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:m}=i,{X:y,Y:S,Z:v}=this,T=c(y*y),L=c(S*S),U=c(Io*c(v*v)),R=c(m*T),I=y+S,F=c(c(I*I)-T-L),V=R+L,K=V-U,d=R-L,x=c(F*K),A=c(V*d),E=c(F*d),g=c(K*V);return new h(x,A,g,E)}add(m){b(m);let{a:y,d:S}=i,{X:v,Y:T,Z:L,T:U}=this,{X:R,Y:I,Z:F,T:V}=m,K=c(v*R),d=c(T*I),x=c(U*S*V),A=c(L*F),E=c((v+T)*(R+I)-K-d),g=A-x,B=A+x,_=c(d-y*K),D=c(E*g),C=c(B*_),O=c(E*_),N=c(g*B);return new h(D,C,N,O)}subtract(m){return b(m),this.add(m.negate())}multiply(m){if(!s.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:y,f:S}=p.cached(this,m,v=>ft(h,v));return ft(h,[y,S])[0]}multiplyUnsafe(m){if(!s.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===Ge?h.ZERO:this.is0()||m===se?this:p.unsafe(this,m,y=>ft(h,y))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return p.unsafe(this,i.n).is0()}toAffine(m){let y=this,S=m,{X:v,Y:T,Z:L}=y,U=y.is0();S==null&&(S=U?Xu:o.inv(L));let R=c(v*S),I=c(T*S),F=o.mul(L,S);if(U)return{x:Ge,y:se};if(F!==se)throw new Error("invZ was invalid");return{x:R,y:I}}clearCofactor(){return a===se?this:this.multiplyUnsafe(a)}toBytes(){let{x:m,y}=this.toAffine(),S=o.toBytes(y);return S[S.length-1]|=m&se?128:0,S}toHex(){return kt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let p=new Ht(h,s.BITS);return s.BITS>=8&&h.BASE.precompute(8),Object.freeze(h.prototype),Object.freeze(h),h}var Wr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){xo()}static fromHex(e){xo()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return kt(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,r){return this.ep.precompute(e,r),this}};function la(t,e,r={}){if(typeof e!="function")throw new Error('"hash" function param is required');let n=e,o=r;Ee(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:a,Fn:f}=t,c=n.outputLen,u=2*a.BYTES;if(c!==void 0&&(we(c,"hash.outputLen"),c!==u))throw new Error(`hash.outputLen must be ${u}, got ${c}`);let l=o.randomBytes===void 0?dr:o.randomBytes,b=o.adjustScalarBytes===void 0?d=>d:o.adjustScalarBytes,h=o.domain===void 0?(d,x,A)=>{if(ge(A,"phflag"),x.length||A)throw new Error("Contexts/pre-hash are not supported");return d}:o.domain;function p(d){return f.create(_e(d))}function w(d){let x=R.secretKey;P(d,R.secretKey,"secretKey");let A=P(n(d),2*x,"hashedSecretKey"),E=b(A.slice(0,x)),g=A.slice(x,2*x),B=p(E);return{head:E,prefix:g,scalar:B}}function m(d){let{head:x,prefix:A,scalar:E}=w(d),g=i.multiply(E),B=g.toBytes();return{head:x,prefix:A,scalar:E,point:g,pointBytes:B}}function y(d){return m(d).pointBytes}function S(d=Uint8Array.of(),...x){let A=te(...x);return p(n(h(A,P(d,void 0,"context"),!!s)))}function v(d,x,A={}){d=P(d,void 0,"message"),s&&(d=s(d));let{prefix:E,scalar:g,pointBytes:B}=m(x),_=S(A.context,E,d),D=i.multiply(_).toBytes(),C=S(A.context,D,B,d),O=f.create(_+C*g);if(!f.isValid(O))throw new Error("sign failed: invalid s");let N=te(D,f.toBytes(O));return P(N,R.signature,"result")}let T={zip215:o.zip215};function L(d,x,A,E=T){let{context:g}=E,B=E.zip215===void 0?!!T.zip215:E.zip215,_=R.signature;d=P(d,_,"signature"),x=P(x,void 0,"message"),A=P(A,R.publicKey,"publicKey"),B!==void 0&&ge(B,"zip215"),s&&(x=s(x));let D=_/2,C=d.subarray(0,D),O=_e(d.subarray(D,_)),N,M,k;try{N=t.fromBytes(A,B),M=t.fromBytes(C,B),k=i.multiplyUnsafe(O)}catch{return!1}if(!B&&N.isSmallOrder())return!1;let Q=S(g,C,A,x);return M.add(N.multiplyUnsafe(Q)).subtract(k).clearCofactor().is0()}let U=a.BYTES,R={secretKey:U,publicKey:U,signature:2*U,seed:U};function I(d){return d=d===void 0?l(R.seed):d,P(d,R.seed,"seed")}function F(d){return st(d)&&d.length===R.secretKey}function V(d,x){try{return!!t.fromBytes(d,x===void 0?T.zip215:x)}catch{return!1}}let K={getExtendedPublicKey:m,randomSecretKey:I,isValidSecretKey:F,isValidPublicKey:V,toMontgomery(d){let{y:x}=t.fromBytes(d),A=R.publicKey,E=A===32;if(!E&&A!==57)throw new Error("only defined for 25519 and 448");let g=E?a.div(se+x,se-x):a.div(x-se,x+se);return a.toBytes(g)},toMontgomerySecret(d){let x=R.secretKey;P(d,x);let A=n(d.subarray(0,x));return b(A).subarray(0,x)}};return Object.freeze(R),Object.freeze(K),Object.freeze({keygen:Xr(I,y),getPublicKey:y,sign:v,verify:L,utils:K,Point:t,lengths:R})}function gr(t,e){if(we(t),we(e),e<0||e>4)throw new Error("invalid I2OSP length: "+e);if(t<0||t>2**(8*e)-1)throw new Error("invalid I2OSP input: "+t);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function Ju(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function Qu(t){if(!st(t)&&typeof t!="string")throw new Error("DST must be Uint8Array or ascii string");let e=typeof t=="string"?Zr(t):t;if(e.length===0)throw new Error("DST must be non-empty");return e}function Lo(t,e,r,n){P(t),we(r),e=Qu(e),e.length>255&&(e=n(te(Zr("H2C-OVERSIZE-DST-"),e)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(r/o);if(r>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=te(e,gr(e.length,1)),f=new Uint8Array(s),c=gr(r,2),u=new Array(i),l=n(te(f,t,c,gr(0,1),a));u[0]=n(te(l,gr(1,1),a));for(let h=1;h<i;h++){let p=[Ju(l,u[h-1]),gr(h+1,1),a];u[h]=n(te(...p))}return te(...u).slice(0,r)}var ha="HashToScalar-";var el=BigInt(0),Pe=BigInt(1),da=BigInt(2);var tl=BigInt(5),rl=BigInt(8),zt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ro={p:zt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:rl,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function nl(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=zt,a=t*t%s*t%s,f=z(a,da,s)*a%s,c=z(f,Pe,s)*t%s,u=z(c,tl,s)*c%s,l=z(u,e,s)*u%s,b=z(l,r,s)*l%s,h=z(b,n,s)*b%s,p=z(h,o,s)*h%s,w=z(p,o,s)*h%s,m=z(w,e,s)*u%s;return{pow_p_5_8:z(m,da,s)*t%s,b2:a}}function ol(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}var To=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Co(t,e){let r=zt,n=J(e*e*e,r),o=J(n*n*e,r),s=nl(t*o).pow_p_5_8,i=J(t*n*s,r),a=J(e*i*i,r),f=i,c=J(i*To,r),u=a===t,l=a===J(-t,r),b=a===J(-t*To,r);return u&&(i=f),(l||b)&&(i=c),Ne(i,r)&&(i=J(-i,r)),{isValid:u||l,value:i}}var We=ua(Ro,{uvRatio:Co}),Xe=We.Fp,ba=We.Fn;function sl(t){return la(We,Vr,Object.assign({adjustScalarBytes:ol,zip215:!0},t))}var ya=sl({});var Do=To,il=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),al=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),cl=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),fl=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),pa=t=>Co(Pe,t),ul=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),_o=t=>Xe.create(_e(t)&ul);function ma(t){let{d:e}=Ro,r=zt,n=y=>Xe.create(y),o=n(Do*t*t),s=n((o+Pe)*cl),i=BigInt(-1),a=n((i-e*o)*n(o+e)),{isValid:f,value:c}=Co(s,a),u=n(c*t);Ne(u,r)||(u=n(-u)),f||(c=u),f||(i=o);let l=n(i*(o-Pe)*fl-a),b=c*c,h=n((c+c)*a),p=n(l*il),w=n(Pe-b),m=n(Pe+b);return new We(n(h*m),n(w*p),n(p*m),n(h*w))}var Je=class t extends Wr{static BASE=new t(We.BASE);static ZERO=new t(We.ZERO);static Fp=Xe;static Fn=ba;constructor(e){super(e)}static fromAffine(e){return new t(We.fromAffine(e))}assertSame(e){if(!(e instanceof t))throw new Error("RistrettoPoint expected")}init(e){return new t(e)}static fromBytes(e){me(e,32);let{a:r,d:n}=Ro,o=zt,s=T=>Xe.create(T),i=_o(e);if(!ji(Xe.toBytes(i),e)||Ne(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),f=s(Pe+r*a),c=s(Pe-r*a),u=s(f*f),l=s(c*c),b=s(r*n*u-l),{isValid:h,value:p}=pa(s(b*l)),w=s(p*c),m=s(p*w*b),y=s((i+i)*w);Ne(y,o)&&(y=s(-y));let S=s(f*m),v=s(y*S);if(!h||Ne(v,o)||S===el)throw new Error("invalid ristretto255 encoding 2");return new t(new We(y,S,Pe,v))}static fromHex(e){return t.fromBytes(fr(e))}toBytes(){let{X:e,Y:r,Z:n,T:o}=this.ep,s=zt,i=m=>Xe.create(m),a=i(i(n+r)*i(n-r)),f=i(e*r),c=i(f*f),{value:u}=pa(i(a*c)),l=i(u*a),b=i(u*f),h=i(l*b*o),p;if(Ne(o*h,s)){let m=i(r*Do),y=i(e*Do);e=m,r=y,p=i(l*al)}else p=b;Ne(e*h,s)&&(r=i(-r));let w=i((n-r)*p);return Ne(w,s)&&(w=i(-w)),Xe.toBytes(w)}equals(e){this.assertSame(e);let{X:r,Y:n}=this.ep,{X:o,Y:s}=e.ep,i=c=>Xe.create(c),a=i(r*s)===i(n*o),f=i(n*s)===i(r*o);return a||f}is0(){return this.equals(t.ZERO)}};Object.freeze(Je.BASE);Object.freeze(Je.ZERO);Object.freeze(Je.prototype);Object.freeze(Je);var ll=Object.freeze({Point:Je,hashToCurve(t,e){let r=e?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":e.DST,n=Lo(t,r,64,Vr);return ll.deriveToCurve(n)},hashToScalar(t,e={DST:ha}){let r=Lo(t,e.DST,64,Vr);return ba.create(_e(r))},deriveToCurve(t){me(t,64);let e=_o(t.subarray(0,32)),r=ma(e),n=_o(t.subarray(32,64)),o=ma(n);return new Je(r.add(o))}});var wr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Jr=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var ye={get(t=globalThis){let e=t.crypto;if(e?.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 e}};var jt=32;var Uo,hl=(async()=>{try{return await ye.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function dl(t,e,r){if(t.buffer instanceof ArrayBuffer){let n=await ye.get().subtle.importKey("raw",t.buffer,{name:"Ed25519"},!1,["verify"]);return await ye.get().subtle.verify({name:"Ed25519"},n,Ie(e),Ie(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function pl(t,e,r){return ya.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}async function xa(t,e,r){return Uo==null&&(Uo=await hl),Uo?dl(t,e,r):pl(t,e,r)}function Qr(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var en=class{type="Ed25519";raw;constructor(e){this.raw=Oo(e,jt)}toMultihash(){return Be.digest(Ot(this))}toCID(){return ce.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:de(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=xa(this.raw,r,e);return Qr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function Ea(t){return t=Oo(t,jt),new en(t)}function Oo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new j(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}function Sa(t=0){return new Uint8Array(t)}var ml=Math.pow(2,7),bl=Math.pow(2,14),yl=Math.pow(2,21),Fo=Math.pow(2,28),Ko=Math.pow(2,35),ko=Math.pow(2,42),No=Math.pow(2,49),q=128,fe=127;function Me(t){if(t<ml)return 1;if(t<bl)return 2;if(t<yl)return 3;if(t<Fo)return 4;if(t<Ko)return 5;if(t<ko)return 6;if(t<No)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Po(t,e,r=0){switch(Me(t)){case 8:e[r++]=t&255|q,t/=128;case 7:e[r++]=t&255|q,t/=128;case 6:e[r++]=t&255|q,t/=128;case 5:e[r++]=t&255|q,t/=128;case 4:e[r++]=t&255|q,t>>>=7;case 3:e[r++]=t&255|q,t>>>=7;case 2:e[r++]=t&255|q,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function xl(t,e,r=0){switch(Me(t)){case 8:e.set(r++,t&255|q),t/=128;case 7:e.set(r++,t&255|q),t/=128;case 6:e.set(r++,t&255|q),t/=128;case 5:e.set(r++,t&255|q),t/=128;case 4:e.set(r++,t&255|q),t>>>=7;case 3:e.set(r++,t&255|q),t>>>=7;case 2:e.set(r++,t&255|q),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function Mo(t,e){let r=t[e],n=0;if(n+=r&fe,r<q||(r=t[e+1],n+=(r&fe)<<7,r<q)||(r=t[e+2],n+=(r&fe)<<14,r<q)||(r=t[e+3],n+=(r&fe)<<21,r<q)||(r=t[e+4],n+=(r&fe)*Fo,r<q)||(r=t[e+5],n+=(r&fe)*Ko,r<q)||(r=t[e+6],n+=(r&fe)*ko,r<q)||(r=t[e+7],n+=(r&fe)*No,r<q))return n;throw new RangeError("Could not decode varint")}function gl(t,e){let r=t.get(e),n=0;if(n+=r&fe,r<q||(r=t.get(e+1),n+=(r&fe)<<7,r<q)||(r=t.get(e+2),n+=(r&fe)<<14,r<q)||(r=t.get(e+3),n+=(r&fe)<<21,r<q)||(r=t.get(e+4),n+=(r&fe)*Fo,r<q)||(r=t.get(e+5),n+=(r&fe)*Ko,r<q)||(r=t.get(e+6),n+=(r&fe)*ko,r<q)||(r=t.get(e+7),n+=(r&fe)*No,r<q))return n;throw new RangeError("Could not decode varint")}function va(t,e,r=0){return e==null&&(e=Sa(Me(t))),e instanceof Uint8Array?Po(t,e,r):xl(t,e,r)}function Aa(t,e=0){return t instanceof Uint8Array?Mo(t,e):gl(t,e)}var qo=new Float32Array([-0]),Qe=new Uint8Array(qo.buffer);function Ba(t,e,r){qo[0]=t,e[r]=Qe[0],e[r+1]=Qe[1],e[r+2]=Qe[2],e[r+3]=Qe[3]}function Ia(t,e){return Qe[0]=t[e],Qe[1]=t[e+1],Qe[2]=t[e+2],Qe[3]=t[e+3],qo[0]}var Vo=new Float64Array([-0]),ue=new Uint8Array(Vo.buffer);function La(t,e,r){Vo[0]=t,e[r]=ue[0],e[r+1]=ue[1],e[r+2]=ue[2],e[r+3]=ue[3],e[r+4]=ue[4],e[r+5]=ue[5],e[r+6]=ue[6],e[r+7]=ue[7]}function Ta(t,e){return ue[0]=t[e],ue[1]=t[e+1],ue[2]=t[e+2],ue[3]=t[e+3],ue[4]=t[e+4],ue[5]=t[e+5],ue[6]=t[e+6],ue[7]=t[e+7],Vo[0]}var El=BigInt(Number.MAX_SAFE_INTEGER),Sl=BigInt(Number.MIN_SAFE_INTEGER),be=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return ut;if(e<El&&e>Sl)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Da&&(o=0n,++n>Da&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return ut;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):ut}},ut=new be(0,0);ut.toBigInt=function(){return 0n};ut.zzEncode=ut.zzDecode=function(){return this};ut.length=function(){return 1};var Da=4294967296n;function _a(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Ra(t,e,r){if(r-e<1)return"";let o,s=[],i=0,a;for(;e<r;)a=t[e++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&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 Ho(t,e,r){let n=r,o,s;for(let i=0;i<t.length;++i)o=t.charCodeAt(i),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((s=t.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Se(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function tn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var zo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Se(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Se(this,4);return tn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Se(this,4);return tn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Se(this,4);let e=Ia(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Se(this,4);let e=Ta(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Se(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return Ra(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Se(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Se(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new be(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Se(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Se(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Se(this,8);let e=tn(this.buf,this.pos+=4),r=tn(this.buf,this.pos+=4);return new be(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Mo(this.buf,this.pos);return this.pos+=Me(e),e}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 Er(t){return new zo(t instanceof Uint8Array?t:t.subarray())}function lt(t,e,r){let n=Er(t);return e.decode(n,void 0,r)}function ht(t=0){return new Uint8Array(t)}var jo={};H(jo,{base10:()=>vl});var vl=Ve({prefix:"9",name:"base10",alphabet:"0123456789"});var $o={};H($o,{base16:()=>Al,base16upper:()=>Bl});var Al=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Bl=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Zo={};H(Zo,{base2:()=>Il});var Il=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Yo={};H(Yo,{base256emoji:()=>Rl});var Ua=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}"),Ll=Ua.reduce((t,e,r)=>(t[r]=e,t),[]),Tl=Ua.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Dl(t){return t.reduce((e,r)=>(e+=Ll[r],e),"")}function _l(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Tl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Rl=Et({prefix:"\u{1F680}",name:"base256emoji",encode:Dl,decode:_l});var Go={};H(Go,{base64:()=>Cl,base64pad:()=>Ul,base64url:()=>Ol,base64urlpad:()=>Fl});var Cl=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ul=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ol=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fl=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Xo={};H(Xo,{base8:()=>Kl});var Kl=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wo={};H(Wo,{identity:()=>kl});var kl=Et({prefix:"\0",name:"identity",encode:t=>Ns(t),decode:t=>ks(t)});var bm=new TextEncoder,ym=new TextDecoder;var es={};H(es,{sha256:()=>rn,sha512:()=>ql});var Ml=20;function Qo({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Jo(t,e,r,n,o)}var Jo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,s){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Ml,this.maxDigestLength=s}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Oa(n,this.code,r?.truncate):n.then(o=>Oa(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Oa(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ae(e,t)}function Ka(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var rn=Qo({name:"sha2-256",code:18,encode:Ka("SHA-256")}),ql=Qo({name:"sha2-512",code:19,encode:Ka("SHA-512")});var ts={...Wo,...Zo,...Xo,...jo,...$o,...vn,...An,...Sn,...Go,...Yo},Dm={...es,...Tn};function Na(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ka=Na("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),rs=Na("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=ht(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Vl={utf8:ka,"utf-8":ka,hex:ts.base16,latin1:rs,ascii:rs,binary:rs,...ts},Pa=Vl;function Ma(t,e="utf8"){let r=Pa[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function ns(t){let e=t??8192,r=e>>>1,n,o=e;return function(i){if(i<1||i>r)return ht(i);o+i>e&&(n=ht(e),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var dt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function os(){}var is=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Hl=ns();function zl(t){return globalThis.Buffer!=null?ht(t):Hl(t)}var vr=class{len;head;tail;states;constructor(){this.len=0,this.head=new dt(os,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new dt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new as((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(nn,10,be.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=be.fromBigInt(e);return this._push(nn,r.length(),r)}uint64Number(e){return this._push(Po,Me(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=be.fromBigInt(e).zzEncode();return this._push(nn,r.length(),r)}sint64Number(e){let r=be.fromNumber(e).zzEncode();return this._push(nn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ss,1,e?1:0)}fixed32(e){return this._push(Sr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=be.fromBigInt(e);return this._push(Sr,4,r.lo)._push(Sr,4,r.hi)}fixed64Number(e){let r=be.fromNumber(e);return this._push(Sr,4,r.lo)._push(Sr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Ba,4,e)}double(e){return this._push(La,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(ss,1,0):this.uint32(r)._push($l,r,e)}string(e){let r=_a(e);return r!==0?this.uint32(r)._push(Ho,r,e):this._push(ss,1,0)}fork(){return this.states=new is(this),this.head=this.tail=new dt(os,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 dt(os,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=zl(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function ss(t,e,r){e[r]=t&255}function jl(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var as=class extends dt{next;constructor(e,r){super(jl,e,r),this.next=void 0}};function nn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Sr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function $l(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(vr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Zl,e,t),this},vr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Yl,e,t),this});function Zl(t,e,r){e.set(t,r)}function Yl(t,e,r){t.length<40?Ho(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Ma(t),r)}function cs(){return new vr}function pt(t,e){let r=cs();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*mt(t,e,r){let n=Er(t);yield*e.stream(n,void 0,"$",r)}var on={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function sn(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function Ar(t){function e(s){if(t[s.toString()]==null)throw new Error("Invalid enum value");return t[s]}let r=function(i,a){let f=e(i);a.int32(f)},n=function(i){let a=i.int32();return e(a)},o=function*(i){let a=i.int32();yield e(a)};return sn("enum",on.VARINT,r,n,o)}function bt(t,e,r){return sn("message",on.LENGTH_DELIMITED,t,e,r)}var le;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(le||(le={}));var fs;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(fs||(fs={}));(function(t){t.codec=()=>Ar(fs)})(le||(le={}));var et;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),le.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=le.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:le.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),e);function r(s){return pt(s,t.codec())}t.encode=r;function n(s,i){return lt(s,t.codec(),i)}t.decode=n;function o(s,i){return mt(s,t.codec(),i)}t.stream=o})(et||(et={}));var us;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),le.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=le.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:le.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),e);function r(s){return pt(s,t.codec())}t.encode=r;function n(s,i){return lt(s,t.codec(),i)}t.decode=n;function o(s,i){return mt(s,t.codec(),i)}t.stream=o})(us||(us={}));var Ir={};H(Ir,{MAX_RSA_KEY_SIZE:()=>ls,generateRSAKeyPair:()=>$a,jwkToJWKKeyPair:()=>Za,jwkToPkcs1:()=>Jl,jwkToPkix:()=>ms,jwkToRSAPrivateKey:()=>ys,pkcs1MessageToJwk:()=>ds,pkcs1MessageToRSAPrivateKey:()=>bs,pkcs1ToJwk:()=>Wl,pkcs1ToRSAPrivateKey:()=>za,pkixMessageToJwk:()=>ps,pkixMessageToRSAPublicKey:()=>an,pkixToJwk:()=>Ql,pkixToRSAPublicKey:()=>ja});var $t=class{type="RSA";jwk;_raw;_multihash;constructor(e,r){this.jwk=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Ir.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ce.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:de(this.raw,e.raw)}verify(e,r,n){return Ha(this.jwk,r,e,n)}},Br=class{type="RSA";jwk;_raw;publicKey;constructor(e,r){this.jwk=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Ir.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:de(this.raw,e.raw)}sign(e,r){return Va(this.jwk,e,r)}};var ls=8192,hs=18,Gl=1062,Xl=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Wl(t){let e=Te(t);return ds(e)}function ds(t){return{n:Y(t[1],"base64url"),e:Y(t[2],"base64url"),d:Y(t[3],"base64url"),p:Y(t[4],"base64url"),q:Y(t[5],"base64url"),dp:Y(t[6],"base64url"),dq:Y(t[7],"base64url"),qi:Y(t[8],"base64url"),kty:"RSA"}}function Jl(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new j("JWK was missing components");return ze([pe(Uint8Array.from([0])),pe(ee(t.n,"base64url")),pe(ee(t.e,"base64url")),pe(ee(t.d,"base64url")),pe(ee(t.p,"base64url")),pe(ee(t.q,"base64url")),pe(ee(t.dp,"base64url")),pe(ee(t.dq,"base64url")),pe(ee(t.qi,"base64url"))]).subarray()}function Ql(t){let e=Te(t,{offset:0});return ps(e)}function ps(t){let e=Te(t[1],{offset:0});return{kty:"RSA",n:Y(e[0],"base64url"),e:Y(e[1],"base64url")}}function ms(t){if(t.n==null||t.e==null)throw new j("JWK was missing components");return ze([Xl,Kr(ze([pe(ee(t.n,"base64url")),pe(ee(t.e,"base64url"))]))]).subarray()}function za(t){let e=Te(t);return bs(e)}function bs(t){let e=ds(t);return ys(e)}function ja(t,e){if(t.byteLength>=Gl)throw new gt("Key size is too large");let r=Te(t,{offset:0});return an(r,t,e)}function an(t,e,r){let n=ps(t);if(r==null){let o=Kt(et.encode({Type:le.RSA,Data:e}));r=Ae(hs,o)}return new $t(n,r)}function ys(t){if(Ga(t)>ls)throw new j("Key size is too large");let e=Za(t),r=Kt(et.encode({Type:le.RSA,Data:ms(e.publicKey)})),n=Ae(hs,r);return new Br(e.privateKey,new $t(e.publicKey,n))}async function $a(t){if(t>ls)throw new j("Key size is too large");let e=await Ya(t),r=Kt(et.encode({Type:le.RSA,Data:ms(e.publicKey)})),n=Ae(hs,r);return new Br(e.privateKey,new $t(e.publicKey,n))}function Za(t){if(t==null)throw new j("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var Xa="1.2.840.113549.1.1.1";async function Ya(t,e){let r=await ye.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await eh(r,e);return{privateKey:n[0],publicKey:n[1]}}async function Va(t,e,r){let n=await ye.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await ye.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,Ie(e instanceof Uint8Array?e:e.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Ha(t,e,r,n){let o=await ye.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await ye.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,Ie(e),Ie(r instanceof Uint8Array?r:r.subarray()));return n?.signal?.throwIfAborted(),s}async function eh(t,e){if(t.privateKey==null||t.publicKey==null)throw new j("Private and public key are required");let r=await Promise.all([ye.get().subtle.exportKey("jwk",t.privateKey),ye.get().subtle.exportKey("jwk",t.publicKey)]);return e?.signal?.throwIfAborted(),r}function Ga(t){if(t.kty!=="RSA")throw new j("invalid key type");if(t.n==null)throw new j("invalid key modulus");return ee(t.n,"base64url").length*8}var cn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(kr(e),me(r,void 0,"key"),this.iHash=e.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(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ke(o)}update(e){return Ft(this),this.iHash.update(e),this}digestInto(e){Ft(this),Nr(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Wa=(()=>{let t=((e,r,n)=>new cn(e,r).update(n).digest());return t.create=(e,r)=>new cn(e,r),t})();var Ja=(t,e)=>(t+(t>=0?e:-e)/Qa)/e;function th(t,e,r){Pt("scalar",t,Re,r);let[[n,o],[s,i]]=e,a=Ja(i*t,r),f=Ja(-o*t,r),c=t-a*n-f*s,u=-a*o-f*i,l=c<Re,b=u<Re;l&&(c=-c),b&&(u=-u);let h=br(Math.ceil(Mt(r)/2))+tt;if(c<Re||c>=h||u<Re||u>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:c,k2neg:b,k2:u}}function gs(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function xs(t,e){Ee(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return ge(r.lowS,"lowS"),ge(r.prehash,"prehash"),r.format!==void 0&&gs(r.format),r}var ws=class extends Error{constructor(e=""){super(e)}},ve={Err:ws,_tlv:{encode:(t,e)=>{let{Err:r}=ve;if(we(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(typeof e!="string")throw new TypeError('"data" expected string, got type='+typeof e);if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=pr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?pr(o.length/2|128):"";return pr(t)+s+o+e},decode(t,e){let{Err:r}=ve;e=P(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let c=e.subarray(n,n+f);if(c.length!==f)throw new r("tlv.decode: length bytes not complete");if(c[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of c)i=i<<8|u;if(n+=f,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+i)}}},_int:{encode(t){let{Err:e}=ve;if(jr(t),t<Re)throw new e("integer: negative integers are not allowed");let r=pr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=ve;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return it(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=ve,o=P(t,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:c,l:u}=n.decode(2,f);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(c)}},hexFromSig(t){let{_tlv:e,_int:r}=ve,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),s=n+o;return e.encode(48,s)}};Object.freeze(ve._tlv);Object.freeze(ve._int);Object.freeze(ve);var Re=BigInt(0),tt=BigInt(1),Qa=BigInt(2),fn=BigInt(3),rh=BigInt(4);function ec(t,e={}){let r=Gr("weierstrass",t,e),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;Ee(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:c}=e;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=rc(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function b(K,d,x){if(c&&d.is0())return Uint8Array.of(0);let{x:A,y:E}=d.toAffine(),g=n.toBytes(A);if(ge(x,"isCompressed"),x){l();let B=!n.isOdd(E);return te(tc(B),g)}else return te(Uint8Array.of(4),g,n.toBytes(E))}function h(K){P(K,void 0,"Point");let{publicKey:d,publicKeyUncompressed:x}=u,A=K.length,E=K[0],g=K.subarray(1);if(c&&A===1&&E===0)return{x:n.ZERO,y:n.ZERO};if(A===d&&(E===2||E===3)){let B=n.fromBytes(g);if(!n.isValid(B))throw new Error("bad point: is not on curve, wrong x");let _=m(B),D;try{D=n.sqrt(_)}catch(N){let M=N instanceof Error?": "+N.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}l();let C=n.isOdd(D);return(E&1)===1!==C&&(D=n.neg(D)),{x:B,y:D}}else if(A===x&&E===4){let B=n.BYTES,_=n.fromBytes(g.subarray(0,B)),D=n.fromBytes(g.subarray(B,B*2));if(!y(_,D))throw new Error("bad point: is not on curve");return{x:_,y:D}}else throw new Error(`bad point: got length ${A}, expected compressed=${d} or uncompressed=${x}`)}let p=e.toBytes===void 0?b:e.toBytes,w=e.fromBytes===void 0?h:e.fromBytes;function m(K){let d=n.sqr(K),x=n.mul(d,K);return n.add(n.add(x,n.mul(K,s.a)),s.b)}function y(K,d){let x=n.sqr(d),A=m(K);return n.eql(x,A)}if(!y(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(s.a,fn),rh),v=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(S,v)))throw new Error("bad curve params: a or b");function T(K,d,x=!1){if(!n.isValid(d)||x&&n.is0(d))throw new Error(`bad point coordinate ${K}`);return d}function L(K){if(!(K instanceof I))throw new Error("Weierstrass Point expected")}function U(K){if(!f||!f.basises)throw new Error("no endo");return th(K,f.basises,o.ORDER)}function R(K,d,x,A,E){return x=new I(n.mul(x.X,K),x.Y,x.Z),d=xr(A,d),x=xr(E,x),d.add(x)}class I{static BASE=new I(s.Gx,s.Gy,n.ONE);static ZERO=new I(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,x,A){this.X=T("x",d),this.Y=T("y",x,!0),this.Z=T("z",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(d){let{x,y:A}=d||{};if(!d||!n.isValid(x)||!n.isValid(A))throw new Error("invalid affine point");if(d instanceof I)throw new Error("projective point not allowed");return n.is0(x)&&n.is0(A)?I.ZERO:new I(x,A,n.ONE)}static fromBytes(d){let x=I.fromAffine(w(P(d,void 0,"point")));return x.assertValidity(),x}static fromHex(d){return I.fromBytes(Nt(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,x=!0){return V.createCache(this,d),x||this.multiply(fn),this}assertValidity(){let d=this;if(d.is0()){if(e.allowInfinityPoint&&n.is0(d.X)&&n.eql(d.Y,n.ONE)&&n.is0(d.Z))return;throw new Error("bad point: ZERO")}let{x,y:A}=d.toAffine();if(!n.isValid(x)||!n.isValid(A))throw new Error("bad point: x or y not field elements");if(!y(x,A))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){L(d);let{X:x,Y:A,Z:E}=this,{X:g,Y:B,Z:_}=d,D=n.eql(n.mul(x,_),n.mul(g,E)),C=n.eql(n.mul(A,_),n.mul(B,E));return D&&C}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:x}=s,A=n.mul(x,fn),{X:E,Y:g,Z:B}=this,_=n.ZERO,D=n.ZERO,C=n.ZERO,O=n.mul(E,E),N=n.mul(g,g),M=n.mul(B,B),k=n.mul(E,g);return k=n.add(k,k),C=n.mul(E,B),C=n.add(C,C),_=n.mul(d,C),D=n.mul(A,M),D=n.add(_,D),_=n.sub(N,D),D=n.add(N,D),D=n.mul(_,D),_=n.mul(k,_),C=n.mul(A,C),M=n.mul(d,M),k=n.sub(O,M),k=n.mul(d,k),k=n.add(k,C),C=n.add(O,O),O=n.add(C,O),O=n.add(O,M),O=n.mul(O,k),D=n.add(D,O),M=n.mul(g,B),M=n.add(M,M),O=n.mul(M,k),_=n.sub(_,O),C=n.mul(M,N),C=n.add(C,C),C=n.add(C,C),new I(_,D,C)}add(d){L(d);let{X:x,Y:A,Z:E}=this,{X:g,Y:B,Z:_}=d,D=n.ZERO,C=n.ZERO,O=n.ZERO,N=s.a,M=n.mul(s.b,fn),k=n.mul(x,g),Q=n.mul(A,B),re=n.mul(E,_),ne=n.add(x,A),X=n.add(g,B);ne=n.mul(ne,X),X=n.add(k,Q),ne=n.sub(ne,X),X=n.add(x,E);let he=n.add(g,_);return X=n.mul(X,he),he=n.add(k,re),X=n.sub(X,he),he=n.add(A,E),D=n.add(B,_),he=n.mul(he,D),D=n.add(Q,re),he=n.sub(he,D),O=n.mul(N,X),D=n.mul(M,re),O=n.add(D,O),D=n.sub(Q,O),O=n.add(Q,O),C=n.mul(D,O),Q=n.add(k,k),Q=n.add(Q,k),re=n.mul(N,re),X=n.mul(M,X),Q=n.add(Q,re),re=n.sub(k,re),re=n.mul(N,re),X=n.add(X,re),k=n.mul(Q,X),C=n.add(C,k),k=n.mul(he,X),D=n.mul(ne,D),D=n.sub(D,k),k=n.mul(ne,Q),O=n.mul(he,O),O=n.add(O,k),new I(D,C,O)}subtract(d){return L(d),this.add(d.negate())}is0(){return this.equals(I.ZERO)}multiply(d){let{endo:x}=e;if(!o.isValidNot0(d))throw new RangeError("invalid scalar: out of range");let A,E,g=B=>V.cached(this,B,_=>ft(I,_));if(x){let{k1neg:B,k1:_,k2neg:D,k2:C}=U(d),{p:O,f:N}=g(_),{p:M,f:k}=g(C);E=N.add(k),A=R(x.beta,O,M,B,D)}else{let{p:B,f:_}=g(d);A=B,E=_}return ft(I,[A,E])[0]}multiplyUnsafe(d){let{endo:x}=e,A=this,E=d;if(!o.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===Re||A.is0())return I.ZERO;if(E===tt)return A;if(V.hasCache(this))return this.multiply(E);if(x){let{k1neg:g,k1:B,k2neg:_,k2:D}=U(E),{p1:C,p2:O}=fa(I,A,B,D);return R(x.beta,C,O,g,_)}else return V.unsafe(A,E)}toAffine(d){let x=this,A=d,{X:E,Y:g,Z:B}=x;if(n.eql(B,n.ONE))return{x:E,y:g};let _=x.is0();A==null&&(A=_?n.ONE:n.inv(B));let D=n.mul(E,A),C=n.mul(g,A),O=n.mul(B,A);if(_)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:D,y:C}}isTorsionFree(){let{isTorsionFree:d}=e;return i===tt?!0:d?d(I,this):V.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:d}=e;return i===tt?this:d?d(I,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===tt?this.is0():this.clearCofactor().is0()}toBytes(d=!0){return ge(d,"isCompressed"),this.assertValidity(),p(I,this,d)}toHex(d=!0){return kt(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let F=o.BITS,V=new Ht(I,e.endo?Math.ceil(F/2):F);return F>=8&&I.BASE.precompute(8),Object.freeze(I.prototype),Object.freeze(I),I}function tc(t){return Uint8Array.of(t?2:3)}function rc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function nh(t,e={}){let{Fn:r}=t,n=e.randomBytes===void 0?dr:e.randomBytes,o=Object.assign(rc(t.Fp,r),{seed:Math.max(Eo(r.ORDER),16)});function s(h){try{let p=r.fromBytes(h);return r.isValidNot0(p)}catch{return!1}}function i(h,p){let{publicKey:w,publicKeyUncompressed:m}=o;try{let y=h.length;return p===!0&&y!==w||p===!1&&y!==m?!1:!!t.fromBytes(h)}catch{return!1}}function a(h){return h=h===void 0?n(o.seed):h,So(P(h,o.seed,"seed"),r.ORDER)}function f(h,p=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(p)}function c(h){let{secretKey:p,publicKey:w,publicKeyUncompressed:m}=o,y=r._lengths;if(!st(h))return;let S=P(h,void 0,"key").length,v=S===w||S===m,T=S===p||!!y?.includes(S);if(!(v&&T))return v}function u(h,p,w=!0){if(c(h)===!0)throw new Error("first arg must be private key");if(c(p)===!1)throw new Error("second arg must be public key");let m=r.fromBytes(h);return t.fromBytes(p).multiply(m).toBytes(w)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},b=Xr(a,f);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:b,Point:t,utils:l,lengths:o})}function nc(t,e,r={}){let n=e;kr(n),Ee(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?dr:r.randomBytes,s=r.hmac===void 0?(E,g)=>Wa(n,E,g):r.hmac,{Fp:i,Fn:a}=t,{ORDER:f,BITS:c}=a,{keygen:u,getPublicKey:l,getSharedSecret:b,utils:h,lengths:p}=nh(t,r),w={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},m=f*Qa+tt<i.ORDER;function y(E){let g=f>>tt;return E>g}function S(E,g){if(!a.isValidNot0(g))throw new Error(`invalid signature ${E}: out of range 1..Point.Fn.ORDER`);return g}function v(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function T(E,g){gs(g);let B=p.signature,_=g==="compact"?B:g==="recovered"?B+1:void 0;return P(E,_)}class L{r;s;recovery;constructor(g,B,_){if(this.r=S("r",g),this.s=S("s",B),_!=null){if(v(),![0,1,2,3].includes(_))throw new Error("invalid recovery id");this.recovery=_}Object.freeze(this)}static fromBytes(g,B=w.format){T(g,B);let _;if(B==="der"){let{r:N,s:M}=ve.toSig(P(g));return new L(N,M)}B==="recovered"&&(_=g[0],B="compact",g=g.subarray(1));let D=p.signature/2,C=g.subarray(0,D),O=g.subarray(D,D*2);return new L(a.fromBytes(C),a.fromBytes(O),_)}static fromHex(g,B){return this.fromBytes(Nt(g),B)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new L(this.r,this.s,g)}recoverPublicKey(g){let{r:B,s:_}=this,D=this.assertRecovery(),C=D===2||D===3?B+f:B;if(!i.isValid(C))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(C),N=t.fromBytes(te(tc((D&1)===0),O)),M=a.inv(C),k=R(P(g,void 0,"msgHash")),Q=a.create(-k*M),re=a.create(_*M),ne=t.BASE.multiplyUnsafe(Q).add(N.multiplyUnsafe(re));if(ne.is0())throw new Error("invalid recovery: point at infinify");return ne.assertValidity(),ne}hasHighS(){return y(this.s)}toBytes(g=w.format){if(gs(g),g==="der")return Nt(ve.hexFromSig(this));let{r:B,s:_}=this,D=a.toBytes(B),C=a.toBytes(_);return g==="recovered"?(v(),te(Uint8Array.of(this.assertRecovery()),D,C)):te(D,C)}toHex(g){return kt(this.toBytes(g))}}Object.freeze(L.prototype),Object.freeze(L);let U=r.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let B=it(g),_=g.length*8-c;return _>0?B>>BigInt(_):B}:r.bits2int,R=r.bits2int_modN===void 0?function(g){return a.create(U(g))}:r.bits2int_modN,I=br(c);function F(E){return Pt("num < 2^"+c,E,Re,I),a.toBytes(E)}function V(E,g){return P(E,void 0,"message"),g?P(n(E),void 0,"prehashed message"):E}function K(E,g,B){let{lowS:_,prehash:D,extraEntropy:C}=xs(B,w);E=V(E,D);let O=R(E),N=a.fromBytes(g);if(!a.isValidNot0(N))throw new Error("invalid private key");let M=[F(N),F(O)];if(C!=null&&C!==!1){let ne=C===!0?o(p.secretKey):C;M.push(P(ne,void 0,"extraEntropy"))}let k=te(...M),Q=O;function re(ne){let X=U(ne);if(!a.isValidNot0(X))return;let he=a.inv(X),xt=t.BASE.multiply(X).toAffine(),Yt=a.create(xt.x);if(Yt===Re)return;let Dr=a.create(he*a.create(Q+Yt*N));if(Dr===Re)return;let Us=(xt.x===Yt?0:2)|Number(xt.y&tt),Os=Dr;return _&&y(Dr)&&(Os=a.neg(Dr),Us^=1),new L(Yt,Os,m?void 0:Us)}return{seed:k,k2sig:re}}function d(E,g,B={}){let{seed:_,k2sig:D}=K(E,g,B);return $i(n.outputLen,a.BYTES,s)(_,D).toBytes(B.format)}function x(E,g,B,_={}){let{lowS:D,prehash:C,format:O}=xs(_,w);if(B=P(B,void 0,"publicKey"),g=V(g,C),!st(E)){let N=E instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+N)}T(E,O);try{let N=L.fromBytes(E,O),M=t.fromBytes(B);if(D&&N.hasHighS())return!1;let{r:k,s:Q}=N,re=R(g),ne=a.inv(Q),X=a.create(re*ne),he=a.create(k*ne),xt=t.BASE.multiplyUnsafe(X).add(M.multiplyUnsafe(he));return xt.is0()?!1:a.create(xt.x)===k}catch{return!1}}function A(E,g,B={}){let{prehash:_}=xs(B,w);return g=V(g,_),L.fromBytes(E,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:b,utils:h,lengths:p,Point:t,sign:d,verify:x,recoverPublicKey:A,Signature:L,hash:n})}var Ss={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},oh={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var oc=BigInt(2);function sh(t){let e=Ss.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),f=BigInt(88),c=t*t*t%e,u=c*c*t%e,l=z(u,r,e)*u%e,b=z(l,r,e)*u%e,h=z(b,oc,e)*c%e,p=z(h,o,e)*h%e,w=z(p,s,e)*p%e,m=z(w,a,e)*w%e,y=z(m,f,e)*m%e,S=z(y,a,e)*w%e,v=z(S,r,e)*u%e,T=z(v,i,e)*p%e,L=z(T,n,e)*c%e,U=z(L,oc,e);if(!Es.eql(Es.sqr(U),t))throw new Error("Cannot find square root");return U}var Es=qt(Ss.p,{sqrt:sh}),ih=ec(Ss,{Fp:Es,endo:oh}),Zt=nc(ih,Kt);var sc=33;function ic(t,e,r,n){let o=rn.digest(r instanceof Uint8Array?r:r.subarray());if(Qr(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Zt.verify(e,s,t,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new wr(String(s))});try{return n?.signal?.throwIfAborted(),Zt.verify(e,o.digest,t,{prehash:!1,format:"der"})}catch(s){throw new wr(String(s))}}var un=class{type="secp256k1";raw;_key;constructor(e){this._key=cc(e),this.raw=ac(this._key)}toMultihash(){return Be.digest(Ot(this))}toCID(){return ce.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:de(this.raw,e.raw)}verify(e,r,n){return ic(this._key,r,e,n)}};function fc(t){return new un(t)}function ac(t){return Zt.Point.fromBytes(t).toBytes()}function cc(t){try{return Zt.Point.fromBytes(t),t}catch(e){throw new gt(String(e))}}function uc(t){if(t.byteLength===jt)return Ea(t);if(t.byteLength===sc)return fc(t);let e=Te(t),r=e[1]?.[0];if(r===Ws||r===Js||r===Qs)return Ti(e);if(e[0]?.[0]===Xa)return an(e,t);throw new j("Could not extract public key from raw bytes")}function Ot(t){return et.encode({Type:le[t.type],Data:t.raw})}var lc=Symbol.for("nodejs.util.inspect.custom"),ah=114,Lr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[yn]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ce.createV1(ah,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return de(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return de(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[lc](){return`PeerId(${this.toString()})`}},ln=class extends Lr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},hn=class extends Lr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},dn=class extends Lr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},ch=2336,vs=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Be.digest(ee(this.url))}[lc](){return`PeerId(${this.url})`}[yn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ce.createV1(ch,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Y(e)),e.toString()===this.toString())}};function hc(t){if(t.type==="Ed25519")return new hn({multihash:t.toCID().multihash,publicKey:t});if(t.type==="secp256k1")return new dn({multihash:t.toCID().multihash,publicKey:t});if(t.type==="RSA")return new ln({multihash:t.toCID().multihash,publicKey:t});throw new Xt}var As=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},dc=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function Bs(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout},signal:i}=e,a,f,u=new Promise((l,b)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(i?.aborted){b(dc(i));return}if(i&&(f=()=>{b(dc(i))},i.addEventListener("abort",f,{once:!0})),t.then(l,b),r===Number.POSITIVE_INFINITY)return;let h=new As;a=s.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(p){b(p)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?l():o instanceof Error?b(o):(h.message=o??`Promise timed out after ${r} milliseconds`,b(h))},r)}).finally(()=>{u.clear(),f&&i&&i.removeEventListener("abort",f)});return u.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},u}var fh=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function uh(t,e,r){let n,o=new Promise((s,i)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),f=[],{addListener:c,removeListener:u}=fh(t),l=async(...h)=>{let p=r.multiArgs?h:h[0];if(r.filter)try{if(!await r.filter(p))return}catch(w){n(),i(w);return}f.push(p),r.count===f.length&&(n(),s(f))},b=(...h)=>{n(),i(r.rejectionMultiArgs?h:h[0])};n=()=>{for(let h of a)u(h,l);for(let h of r.rejectionEvents)a.includes(h)||u(h,b)};for(let h of a)c(h,l);for(let h of r.rejectionEvents)a.includes(h)||c(h,b);r.signal&&r.signal.addEventListener("abort",()=>{b(r.signal.reason)},{once:!0}),r.resolveImmediately&&s(f)});if(o.cancel=n,typeof r.timeout=="number"){let s=Bs(o,{milliseconds:r.timeout});return s.cancel=()=>{n(),s.clear()},s}return o}function pc(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=uh(t,e,r),o=n.then(s=>s[0]);return o.cancel=n.cancel,o}var yt=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"};function lh(t){return t.reason}async function Is(t,e,r){if(e==null)return t;let n=r?.translateError??lh;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((s,i)=>{o=()=>{i(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var dh=4194304,pn=class extends Error{static name="UnwrappedError";name="UnwrappedError"},Ts=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ds=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},_s=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function ph(t){return typeof t?.closeRead=="function"}function mh(t){return typeof t?.close=="function"}function Ls(t){return ph(t)?t.remoteWriteStatus!=="writable"&&t.readBufferLength===0:mh(t)?t.status!=="open":!1}function bh(t){return t?.addEventListener!=null&&t?.removeEventListener!=null&&t?.send!=null&&t?.push!=null&&t?.log!=null}function yh(t,e){let r=e?.maxBufferSize??dh,n=new oe,o,s=!1;if(!bh(t))throw new j("Argument should be a Stream or a Multiaddr");let i=u=>{if(n.append(u.data),n.byteLength>r){let l=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${l} > ${r}`))}o?.resolve()};t.addEventListener("message",i);let a=u=>{u.error!=null?o?.reject(u.error):o?.resolve()};t.addEventListener("close",a);let f=()=>{o?.resolve()};t.addEventListener("remoteCloseWrite",f);let c={readBuffer:n,async read(u){if(s===!0)throw new pn("Stream was unwrapped");if(Ls(t)){if(n.byteLength===0&&u?.bytes==null)return null;if(u?.bytes!=null&&n.byteLength<u.bytes)throw t.log.error("closed after reading %d/%d bytes",n.byteLength,u.bytes),new yt(`Unexpected EOF - stream closed after reading ${n.byteLength}/${u.bytes} bytes`)}let l=u?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=l){o.resolve();break}if(await Is(o.promise,u?.signal),Ls(t)){if(n.byteLength===0&&u?.bytes==null)return null;break}o=Promise.withResolvers()}let b=u?.bytes??n.byteLength;if(n.byteLength<b){if(Ls(t))throw t.log.error("closed while reading %d/%d bytes",n.byteLength,b),new yt(`Unexpected EOF - stream closed while reading ${n.byteLength}/${b} bytes`);return c.read(u)}let h=n.sublist(0,b);return n.consume(b),h},async write(u,l){if(s===!0)throw new pn("Stream was unwrapped");t.send(u)||await pc(t,"drain",{signal:l?.signal,rejectionEvents:["close"]})},unwrap(){return s||(s=!0,t.removeEventListener("message",i),t.removeEventListener("close",a),t.removeEventListener("remoteCloseWrite",f),n.byteLength>0&&(t.log("stream unwrapped with %d unread bytes",n.byteLength),t.unshift(n))),t}};return c}function xh(t,e={}){let r=yh(t,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=Me(e.maxDataLength));let n=e?.lengthDecoder??Aa,o=e?.lengthEncoder??va;return{async read(i){let a=-1,f=new oe;for(;;){let u=await r.read({...i,bytes:1});if(u==null)break;f.append(u);try{a=n(f)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new Ts("Invalid message length");if(e?.maxLengthLength!=null&&f.byteLength>e.maxLengthLength)throw new _s(`Message length length too long - ${f.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Ds(`Message length too long - ${a} > ${e.maxDataLength}`);let c=await r.read({...i,bytes:a});if(c==null)throw t.log.error("tried to read %d bytes but the stream closed",a),new yt(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(c.byteLength!==a)throw t.log.error("read %d/%d bytes before the stream closed",c.byteLength,a),new yt(`Unexpected EOF - read ${c.byteLength}/${a} bytes before the stream closed`);return c},async write(i,a){await r.write(new oe(o(i.byteLength),i),a)},async writeV(i,a){let f=new oe(...i.flatMap(c=>[o(c.byteLength),c]));await r.write(f,a)},unwrap(){return r.unwrap()}}}function mc(t,e){let r=xh(t,e),n={read:async(o,s)=>{let i=await r.read(s);return o.decode(i)},write:async(o,s,i)=>{await r.write(s.encode(o),i)},writeV:async(o,s,i)=>{await r.writeV(o.map(a=>s.encode(a)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>r.unwrap()};return n}var mn;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.id!=null&&(i.uint32(10),i.bytes(s.id)),s.pubkey!=null&&(i.uint32(18),Tr.codec().encode(s.pubkey,i)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.id=s.bytes();break}case 2:{f.pubkey=Tr.codec().decode(s,s.uint32(),{limits:a.limits?.pubkey});break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.id`,value:s.bytes()};break}case 2:{yield*Tr.codec().stream(s,s.uint32(),`${a}.pubkey`,{limits:f.limits?.pubkey});break}default:{s.skipType(u&7);break}}}})),e);function r(s){return pt(s,t.codec())}t.encode=r;function n(s,i){return lt(s,t.codec(),i)}t.decode=n;function o(s,i){return mt(s,t.codec(),i)}t.stream=o})(mn||(mn={}));var qe;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(qe||(qe={}));var Rs;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(Rs||(Rs={}));(function(t){t.codec=()=>Ar(Rs)})(qe||(qe={}));var Tr;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),qe.codec().encode(s.Type,i)),s.Data!=null&&s.Data.byteLength>0&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={Data:Ai(0)},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=qe.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:qe.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),e);function r(s){return pt(s,t.codec())}t.encode=r;function n(s,i){return lt(s,t.codec(),i)}t.decode=n;function o(s,i){return mt(s,t.codec(),i)}t.stream=o})(Tr||(Tr={}));var gh="/plaintext/2.0.0",Cs=class{protocol=gh;privateKey;log;constructor(e){this.privateKey=e.privateKey,this.log=e.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[Fs]=["@libp2p/connection-encryption"];async secureInbound(e,r){return this._encrypt(e,r)}async secureOutbound(e,r){return this._encrypt(e,r)}async _encrypt(e,r){let n=e.log?.newScope("plaintext")??this.log,o=mc(e).pb(mn);n("write pubkey exchange to peer %p",r?.remotePeer);let s=this.privateKey.publicKey;await o.write({id:s.toMultihash().bytes,pubkey:{Type:qe[s.type],Data:s.raw}},r);let i=await o.read(r),a;try{if(i.pubkey==null)throw new wt("Public key missing");if(i.pubkey.Data.byteLength===0)throw new wt("Public key data too short");if(i.id==null)throw new wt("Remote id missing");let f=uc(i.pubkey.Data);if(a=hc(f),!de(a.toMultihash().bytes,i.id))throw new Gt("Public key did not match id")}catch(f){throw n.error("invalid public key - %e",f),new Gt(`Invalid public key - ${f.message}`)}if(r?.remotePeer!=null&&!a.equals(r?.remotePeer))throw new _r;return n("plaintext key exchange completed successfully with peer %p",a),{connection:o.unwrap().unwrap(),remotePeer:a}}};function wh(){return t=>new Cs(t)}return wc(Eh);})();
2
+ "use strict";var Libp2PPlaintext=(()=>{var gn=Object.defineProperty;var vc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Bc=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var r in e)gn(t,r,{get:e[r],enumerable:!0})},Ic=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ac(e))!Bc.call(t,o)&&o!==r&&gn(t,o,{get:()=>e[o],enumerable:!(n=vc(e,o))||n.enumerable});return t};var Lc=t=>Ic(gn({},"__esModule",{value:!0}),t);var Fh={};H(Fh,{plaintext:()=>Ch});var Fr=class extends Error{static name="UnexpectedPeerError";constructor(e="Unexpected Peer"){super(e),this.name="UnexpectedPeerError"}},Xt=class extends Error{static name="InvalidCryptoExchangeError";constructor(e="Invalid crypto exchange"){super(e),this.name="InvalidCryptoExchangeError"}},j=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},wt=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Et=class extends Error{static name="ProtocolError";constructor(e="Protocol error"){super(e),this.name="ProtocolError"}};var Wt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var wn=Symbol.for("@libp2p/peer-id");var Ns=Symbol.for("@libp2p/service-capabilities");var Bn={};H(Bn,{base58btc:()=>W,base58flickr:()=>Oc});var cd=new Uint8Array(0);function ks(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Fe(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return ot(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return ot(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Ks(t){return new TextEncoder().encode(t)}function Ps(t){return new TextDecoder().decode(t)}function Tc(t){return t?.buffer instanceof ArrayBuffer}function ot(t){return Tc(t)?t:t.slice()}function Dc(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,f=t.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,m=0,b=0,S=p.length;b!==S&&p[b]===0;)b++,w++;for(var v=(S-b)*u+1>>>0,T=new Uint8Array(v);b!==S;){for(var L=p[b],F=0,R=v-1;(L!==0||F<m)&&R!==-1;R--,F++)L+=256*T[R]>>>0,T[R]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");m=F,b++}for(var I=v-m;I!==v&&T[I]===0;)I++;for(var O=f.repeat(w);I<v;++I)O+=t.charAt(T[I]);return O}function y(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var m=0,b=0;p[w]===f;)m++,w++;for(var S=(p.length-w)*c+1>>>0,v=new Uint8Array(S);p[w];){var T=r[p.charCodeAt(w)];if(T===255)return;for(var L=0,F=S-1;(T!==0||L<b)&&F!==-1;F--,L++)T+=a*v[F]>>>0,v[F]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");b=L,w++}if(p[w]!==" "){for(var R=S-b;R!==S&&v[R]===0;)R++;for(var I=new Uint8Array(m+(S-R)),O=m;R!==S;)I[O++]=v[R++];return I}}}function h(p){var w=y(p);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:y,decode:h}}var _c=Dc,Rc=_c,qs=Rc;var En=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Sn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Vs(this,e)}},vn=class{decoders;constructor(e){this.decoders=e}or(e){return Vs(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Vs(t,e){return new vn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var An=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new En(e,r,n),this.decoder=new Sn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function St({name:t,prefix:e,encode:r,decode:n}){return new An(t,e,r,n)}function Ve({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=qs(r,t);return St({prefix:e,name:t,encode:n,decode:s=>Fe(o(s))})}function Cc(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,f=0;for(let c=0;c<o;++c){let u=e[t[c]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Fc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let f=0;f<t.length;++f)for(a=a<<8|t[f],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Uc(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function $({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Uc(n);return St({prefix:e,name:t,encode(s){return Fc(s,n,r)},decode(s){return Cc(s,o,r,t)}})}var W=Ve({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Oc=Ve({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var In={};H(In,{base32:()=>vt,base32hex:()=>Pc,base32hexpad:()=>qc,base32hexpadupper:()=>Vc,base32hexupper:()=>Mc,base32pad:()=>kc,base32padupper:()=>Kc,base32upper:()=>Nc,base32z:()=>Hc});var vt=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Nc=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),kc=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kc=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Pc=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Mc=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qc=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vc=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Hc=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ln={};H(Ln,{base36:()=>Jt,base36upper:()=>zc});var Jt=Ve({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zc=Ve({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jc=js,Hs=128,$c=127,Zc=~$c,Yc=Math.pow(2,31);function js(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Yc;)e[r++]=t&255|Hs,t/=128;for(;t&Zc;)e[r++]=t&255|Hs,t>>>=7;return e[r]=t|0,js.bytes=r-n+1,e}var Gc=Tn,Xc=128,zs=127;function Tn(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw Tn.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&zs)<<o:(i&zs)*Math.pow(2,o),o+=7}while(i>=Xc);return Tn.bytes=s-n,r}var Wc=Math.pow(2,7),Jc=Math.pow(2,14),Qc=Math.pow(2,21),ef=Math.pow(2,28),tf=Math.pow(2,35),rf=Math.pow(2,42),nf=Math.pow(2,49),of=Math.pow(2,56),sf=Math.pow(2,63),af=function(t){return t<Wc?1:t<Jc?2:t<Qc?3:t<ef?4:t<tf?5:t<rf?6:t<nf?7:t<of?8:t<sf?9:10},cf={encode:jc,decode:Gc,encodingLength:af},ff=cf,Qt=ff;function er(t,e=0){return[Qt.decode(t,e),Qt.decode.bytes]}function At(t,e,r=0){return Qt.encode(t,e,r),e}function Bt(t){return Qt.encodingLength(t)}function Be(t,e){let r=e.byteLength,n=Bt(t),o=n+Bt(r),s=new Uint8Array(o+r);return At(t,s,0),At(r,s,n),s.set(e,o),new It(t,r,e,s)}function Dn(t){let e=Fe(t),[r,n]=er(e),[o,s]=er(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new It(r,o,i,e)}function $s(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ks(t.bytes,r.bytes)}}var It=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=ot(n),this.bytes=ot(o)}};function Zs(t,e){let{bytes:r,version:n}=t;return n===0?lf(r,_n(t),e??W.encoder):hf(r,_n(t),e??vt.encoder)}var Ys=new WeakMap;function _n(t){let e=Ys.get(t);if(e==null){let r=new Map;return Ys.set(t,r),r}return e}var ce=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=ot(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:e,multihash:r}=this;if(e!==tr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==df)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Be(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&$s(e.multihash,n.multihash)}toString(e){return Zs(this,e)}toJSON(){return{"/":Zs(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i??Gs(n,o,s.bytes))}else if(r[pf]===!0){let{version:n,multihash:o,code:s}=r,i=Dn(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==tr)throw new Error(`Version 0 CID must use dag-pb (code: ${tr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Gs(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,tr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Fe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new It(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,y]=er(e.subarray(r));return r+=y,l},o=n(),s=tr;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),f=n(),c=r+f,u=c-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:u,size:c}}static parse(e,r){let[n,o]=uf(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return _n(s).set(n,e),s}};function uf(t,e){switch(t[0]){case"Q":{let r=e??W;return[W.prefix,r.decode(`${W.prefix}${t}`)]}case W.prefix:{let r=e??W;return[W.prefix,r.decode(t)]}case vt.prefix:{let r=e??vt;return[vt.prefix,r.decode(t)]}case Jt.prefix:{let r=e??Jt;return[Jt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function lf(t,e,r){let{prefix:n}=r;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function hf(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var tr=112,df=18;function Gs(t,e,r){let n=Bt(t),o=n+Bt(e),s=new Uint8Array(o+r.byteLength);return At(t,s,0),At(e,s,n),s.set(r,o),s}var pf=Symbol.for("@ipld/js-cid/CID");var Rn={};H(Rn,{identity:()=>Ie});var Xs=0,mf="identity",Ws=Fe;function yf(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Be(Xs,Ws(t))}var Ie={code:Xs,name:mf,encode:Ws,digest:yf};function pe(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function bf(t){return t.buffer instanceof ArrayBuffer}function Le(t){return bf(t)?t:t.slice()}var Js="1.2.840.10045.3.1.7",Qs="1.3.132.0.34",ei="1.3.132.0.35";async function ti(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,Le(e),Le(r.subarray()));return n?.signal?.throwIfAborted(),s}function Ue(t=0){return new Uint8Array(t)}function rr(t=0){return new Uint8Array(t)}function Cn(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=rr(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function ri(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var oi=Symbol.for("@achingbrain/uint8arraylist");function ni(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Or(t){return!!t?.[oi]}var oe=class t{bufs;length;[oi]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Or(n)){r+=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+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Or(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=ni(this.bufs,e);return r.buf[r.index]}set(e,r){let n=ni(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Or(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return Cn(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:Cn(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),s=new t;return s.length=o,s.bufs=n,s}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,f=a+i.byteLength;if(o=f,e>=f)continue;let c=e>=a&&e<f,u=r>a&&r<=f;if(c&&u){if(e===a&&r===f){n.push(i);break}let l=e-a;n.push(i.subarray(l,l+(r-e)));break}if(c){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(u){if(r===f){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Or(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,f=this.byteLength-n.byteLength,c=n.byteLength-1,u;for(let l=r;l<=f;l+=u){u=0;for(let y=c;y>=0;y--){let h=this.get(l+y);if(n[y]!==h){u=Math.max(1,y-a[h]);break}}if(u===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=rr(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Ue(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Ue(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Ue(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=rr(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Ue(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Ue(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Ue(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Ue(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Ue(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ri(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var Fn={};H(Fn,{base10:()=>xf});var xf=Ve({prefix:"9",name:"base10",alphabet:"0123456789"});var Un={};H(Un,{base16:()=>gf,base16upper:()=>wf});var gf=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),wf=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var On={};H(On,{base2:()=>Ef});var Ef=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Nn={};H(Nn,{base256emoji:()=>If});var si=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}"),Sf=si.reduce((t,e,r)=>(t[r]=e,t),[]),vf=si.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Af(t){return t.reduce((e,r)=>(e+=Sf[r],e),"")}function Bf(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=vf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var If=St({prefix:"\u{1F680}",name:"base256emoji",encode:Af,decode:Bf});var kn={};H(kn,{base64:()=>Lf,base64pad:()=>Tf,base64url:()=>Df,base64urlpad:()=>_f});var Lf=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tf=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Df=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_f=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Kn={};H(Kn,{base8:()=>Rf});var Rf=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Pn={};H(Pn,{identity:()=>Cf});var Cf=St({prefix:"\0",name:"identity",encode:t=>Ps(t),decode:t=>Ks(t)});var Gd=new TextEncoder,Xd=new TextDecoder;var Vn={};H(Vn,{sha256:()=>Nr,sha512:()=>Nf});var Of=20;function qn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Mn(t,e,r,n,o)}var Mn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,s){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Of,this.maxDigestLength=s}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ii(n,this.code,r?.truncate):n.then(o=>ii(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ii(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Be(e,t)}function ci(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Nr=qn({name:"sha2-256",code:18,encode:ci("SHA-256")}),Nf=qn({name:"sha2-512",code:19,encode:ci("SHA-512")});var Hn={...Pn,...On,...Kn,...Fn,...Un,...In,...Ln,...Bn,...kn,...Nn},cp={...Vn,...Rn};function fi(t=0){return new Uint8Array(t)}function zn(t=0){return new Uint8Array(t)}function li(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ui=li("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),jn=li("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=zn(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),kf={utf8:ui,"utf-8":ui,hex:Hn.base16,latin1:jn,ascii:jn,binary:jn,...Hn},kr=kf;function ee(t,e="utf8"){let r=kr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function Z(t,e="utf8"){let r=kr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var Kf=parseInt("11111",2),$n=parseInt("10000000",2),Pf=parseInt("01111111",2),hi={0:nr,1:nr,2:Mf,3:Hf,4:zf,5:Vf,6:qf,16:nr,22:nr,48:nr};function Te(t,e={offset:0}){let r=t[e.offset]&Kf;if(e.offset++,hi[r]!=null)return hi[r](t,e);throw new Error("No decoder for tag "+r)}function or(t,e){let r=0;if((t[e.offset]&$n)===$n){let n=t[e.offset]&Pf,o="0x";e.offset++;for(let s=0;s<n;s++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function nr(t,e){or(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Te(t,e);if(n===null)break;r.push(n)}return r}function Mf(t,e){let r=or(t,e),n=e.offset,o=e.offset+r,s=[];for(let i=n;i<o;i++)i===n&&t[i]===0||s.push(t[i]);return e.offset+=r,Uint8Array.from(s)}function qf(t,e){let r=or(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,f=[];for(;e.offset<n;){let c=t[e.offset];if(e.offset++,f.push(c&127),c<128){f.reverse();let u=0;for(let l=0;l<f.length;l++)u+=f[l]<<l*7;a+=`.${u}`,f=[]}}return a}function Vf(t,e){return e.offset++,null}function Hf(t,e){let r=or(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function zf(t,e){let r=or(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function jf(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new oe;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Zn(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=jf(t.byteLength);return new oe(Uint8Array.from([e.byteLength|$n]),e)}function me(t){let e=new oe,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new oe(Uint8Array.from([2]),Zn(e),e)}function Kr(t){let e=Uint8Array.from([0]),r=new oe(e,t);return new oe(Uint8Array.from([3]),Zn(r),r)}function He(t,e=48){let r=new oe;for(let n of t)r.append(n);return new oe(Uint8Array.from([e]),Zn(r),r)}var $f=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Zf=Uint8Array.from([6,5,43,129,4,0,34]),Yf=Uint8Array.from([6,5,43,129,4,0,35]),Gf={ext:!0,kty:"EC",crv:"P-256"},Xf={ext:!0,kty:"EC",crv:"P-384"},Wf={ext:!0,kty:"EC",crv:"P-521"},Yn=32,Gn=48,Xn=66;function di(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===Yn*2+1)return n=Z(e.subarray(r,r+Yn),"base64url"),o=Z(e.subarray(r+Yn),"base64url"),new Tt({...Gf,key_ops:["verify"],x:n,y:o});if(e.byteLength===Gn*2+1)return n=Z(e.subarray(r,r+Gn),"base64url"),o=Z(e.subarray(r+Gn),"base64url"),new Tt({...Xf,key_ops:["verify"],x:n,y:o});if(e.byteLength===Xn*2+1)return n=Z(e.subarray(r,r+Xn),"base64url"),o=Z(e.subarray(r+Xn),"base64url"),new Tt({...Wf,key_ops:["verify"],x:n,y:o});throw new j(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function pi(t){return He([me(Uint8Array.from([1])),He([Jf(t.crv)],160),He([Kr(new oe(Uint8Array.from([4]),ee(t.x??"","base64url"),ee(t.y??"","base64url")))],161)]).subarray()}function Jf(t){if(t==="P-256")return $f;if(t==="P-384")return Zf;if(t==="P-521")return Yf;throw new j(`Invalid curve ${t}`)}var Tt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=pi(this.jwk)),this._raw}toMultihash(){return Ie.digest(Dt(this))}toCID(){return ce.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}async verify(e,r,n){return ti(this.jwk,r,e,n)}};function Wn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function ze(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function ye(t,e,r=""){let n=Wn(t),o=t?.length,s=e!==void 0;if(!n||s&&o!==e){let i=r&&`"${r}" `,a=s?` of length ${e}`:"",f=n?`length=${o}`:`type=${typeof t}`,c=i+"expected Uint8Array"+a+", got "+f;throw n?new RangeError(c):new TypeError(c)}return t}function Pr(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(ze(t.outputLen),ze(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function _t(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Mr(t,e){ye(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Ne(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function qr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ge(t,e){return t<<32-e|t>>>e}var yi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Qf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vr(t){if(ye(t),yi)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Qf[t[r]];return e}var Oe={_0:48,_9:57,A:65,F:70,a:97,f:102};function mi(t){if(t>=Oe._0&&t<=Oe._9)return t-Oe._0;if(t>=Oe.A&&t<=Oe.F)return t-(Oe.A-10);if(t>=Oe.a&&t<=Oe.f)return t-(Oe.a-10)}function sr(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(yi)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=mi(t.charCodeAt(s)),a=mi(t.charCodeAt(s+1));if(i===void 0||a===void 0){let f=t[s]+t[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+a}return n}function Jn(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];ye(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let s=t[n];r.set(s,o),o+=s.length}return r}function Qn(t,e={}){let r=(o,s)=>t(s).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function bi(t=32){ze(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var eo=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function xi(t,e,r){return t&e^~t&r}function gi(t,e,r){return t&e^t&r^e&r}var ir=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=qr(this.buffer)}update(e){_t(this),ye(e);let{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let f=qr(e);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_t(this),Mr(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ne(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let a=qr(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let c=f/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<c;l++)a.setUint32(4*l,u[l],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=a,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ie=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Hr=BigInt(4294967295),wi=BigInt(32);function eu(t,e=!1){return e?{h:Number(t&Hr),l:Number(t>>wi&Hr)}:{h:Number(t>>wi&Hr)|0,l:Number(t&Hr)|0}}function Ei(t,e=!1){let r=t.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=eu(t[s],e);[n[s],o[s]]=[i,a]}return[n,o]}var to=(t,e,r)=>t>>>r,ro=(t,e,r)=>t<<32-r|e>>>r,st=(t,e,r)=>t>>>r|e<<32-r,it=(t,e,r)=>t<<32-r|e>>>r,ar=(t,e,r)=>t<<64-r|e>>>r-32,cr=(t,e,r)=>t>>>r-32|e<<64-r;function De(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Si=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),vi=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Ai=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Bi=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Ii=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Li=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;var ru=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]),je=new Uint32Array(64),no=class extends ir{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:s,F:i,G:a,H:f}=this;return[e,r,n,o,s,i,a,f]}set(e,r,n,o,s,i,a,f){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=f|0}process(e,r){for(let l=0;l<16;l++,r+=4)je[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let y=je[l-15],h=je[l-2],p=ge(y,7)^ge(y,18)^y>>>3,w=ge(h,17)^ge(h,19)^h>>>10;je[l]=w+je[l-7]+p+je[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:f,G:c,H:u}=this;for(let l=0;l<64;l++){let y=ge(a,6)^ge(a,11)^ge(a,25),h=u+y+xi(a,f,c)+ru[l]+je[l]|0,w=(ge(n,2)^ge(n,13)^ge(n,22))+gi(n,o,s)|0;u=c,c=f,f=a,a=i+h|0,i=s,s=o,o=n,n=h+w|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,f=f+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,f,c,u)}roundClean(){Ne(je)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ne(this.buffer)}},oo=class extends no{A=ke[0]|0;B=ke[1]|0;C=ke[2]|0;D=ke[3]|0;E=ke[4]|0;F=ke[5]|0;G=ke[6]|0;H=ke[7]|0;constructor(){super(32)}};var Ti=Ei(["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(t=>BigInt(t))),nu=Ti[0],ou=Ti[1],$e=new Uint32Array(80),Ze=new Uint32Array(80),so=class extends ir{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:f,Eh:c,El:u,Fh:l,Fl:y,Gh:h,Gl:p,Hh:w,Hl:m}=this;return[e,r,n,o,s,i,a,f,c,u,l,y,h,p,w,m]}set(e,r,n,o,s,i,a,f,c,u,l,y,h,p,w,m){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=f|0,this.Eh=c|0,this.El=u|0,this.Fh=l|0,this.Fl=y|0,this.Gh=h|0,this.Gl=p|0,this.Hh=w|0,this.Hl=m|0}process(e,r){for(let v=0;v<16;v++,r+=4)$e[v]=e.getUint32(r),Ze[v]=e.getUint32(r+=4);for(let v=16;v<80;v++){let T=$e[v-15]|0,L=Ze[v-15]|0,F=st(T,L,1)^st(T,L,8)^to(T,L,7),R=it(T,L,1)^it(T,L,8)^ro(T,L,7),I=$e[v-2]|0,O=Ze[v-2]|0,V=st(I,O,19)^ar(I,O,61)^to(I,O,6),N=it(I,O,19)^cr(I,O,61)^ro(I,O,6),d=Ai(R,N,Ze[v-7],Ze[v-16]),x=Bi(d,F,V,$e[v-7],$e[v-16]);$e[v]=x|0,Ze[v]=d|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:f,Dh:c,Dl:u,Eh:l,El:y,Fh:h,Fl:p,Gh:w,Gl:m,Hh:b,Hl:S}=this;for(let v=0;v<80;v++){let T=st(l,y,14)^st(l,y,18)^ar(l,y,41),L=it(l,y,14)^it(l,y,18)^cr(l,y,41),F=l&h^~l&w,R=y&p^~y&m,I=Ii(S,L,R,ou[v],Ze[v]),O=Li(I,b,T,F,nu[v],$e[v]),V=I|0,N=st(n,o,28)^ar(n,o,34)^ar(n,o,39),d=it(n,o,28)^cr(n,o,34)^cr(n,o,39),x=n&s^n&a^s&a,A=o&i^o&f^i&f;b=w|0,S=m|0,w=h|0,m=p|0,h=l|0,p=y|0,{h:l,l:y}=De(c|0,u|0,O|0,V|0),c=a|0,u=f|0,a=s|0,f=i|0,s=n|0,i=o|0;let E=Si(V,d,A);n=vi(E,O,N,x),o=E|0}({h:n,l:o}=De(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=De(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:f}=De(this.Ch|0,this.Cl|0,a|0,f|0),{h:c,l:u}=De(this.Dh|0,this.Dl|0,c|0,u|0),{h:l,l:y}=De(this.Eh|0,this.El|0,l|0,y|0),{h,l:p}=De(this.Fh|0,this.Fl|0,h|0,p|0),{h:w,l:m}=De(this.Gh|0,this.Gl|0,w|0,m|0),{h:b,l:S}=De(this.Hh|0,this.Hl|0,b|0,S|0),this.set(n,o,s,i,a,f,c,u,l,y,h,p,w,m,b,S)}roundClean(){Ne($e,Ze)}destroy(){this.destroyed=!0,Ne(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},io=class extends so{Ah=ie[0]|0;Al=ie[1]|0;Bh=ie[2]|0;Bl=ie[3]|0;Ch=ie[4]|0;Cl=ie[5]|0;Dh=ie[6]|0;Dl=ie[7]|0;Eh=ie[8]|0;El=ie[9]|0;Fh=ie[10]|0;Fl=ie[11]|0;Gh=ie[12]|0;Gl=ie[13]|0;Hh=ie[14]|0;Hl=ie[15]|0;constructor(){super(64)}};var Rt=Qn(()=>new oo,eo(1));var zr=Qn(()=>new io,eo(3));var P=(t,e,r)=>ye(t,e,r),co=ze,Ct=Vr,te=(...t)=>Jn(...t),Ft=t=>sr(t),at=Wn,fr=t=>bi(t),$r=BigInt(0),ao=BigInt(1);function we(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function Zr(t){if(typeof t=="bigint"){if(!jr(t))throw new RangeError("positive bigint expected, got "+t)}else co(t);return t}function Ee(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function ur(t){let e=Zr(t).toString(16);return e.length&1?"0"+e:e}function Di(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?$r:BigInt("0x"+t)}function ct(t){return Di(Vr(t))}function _e(t){return Di(Vr(lr(ye(t)).reverse()))}function Yr(t,e){if(ze(e),e===0)throw new RangeError("zero length");t=Zr(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return sr(r.padStart(e*2,"0"))}function fo(t,e){return Yr(t,e).reverse()}function _i(t,e){if(t=P(t),e=P(e),t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function lr(t){return Uint8Array.from(P(t))}function Gr(t){if(typeof t!="string")throw new TypeError("ascii string expected, got "+typeof t);return Uint8Array.from(t,(e,r)=>{let n=e.charCodeAt(0);if(e.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})}var jr=t=>typeof t=="bigint"&&$r<=t;function su(t,e,r){return jr(t)&&jr(e)&&jr(r)&&e<=t&&t<r}function Ut(t,e,r,n){if(!su(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Ot(t){if(t<$r)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>$r;t>>=ao,e+=1);return e}var hr=t=>(ao<<BigInt(t))-ao;function Ri(t,e,r){if(ze(t,"hashLen"),ze(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=m=>new Uint8Array(m),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,f=n(t),c=n(t),u=0,l=()=>{f.fill(1),c.fill(0),u=0},y=(...m)=>r(c,te(f,...m)),h=(m=o)=>{c=y(s,m),f=y(),m.length!==0&&(c=y(i,m),f=y())},p=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let m=0,b=[];for(;m<e;){f=y();let S=f.slice();b.push(S),m+=f.length}return te(...b)};return(m,b)=>{l(),h(m);let S;for(;(S=b(p()))===void 0;)h();return l(),S}}function Se(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,a){if(!a&&i!=="function"&&!Object.hasOwn(t,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=t[s];if(a&&f===void 0)return;let c=typeof f;if(c!==i||f===null)throw new TypeError(`param "${s}" is invalid: expected ${i}, got ${c}`)}let o=(s,i)=>Object.entries(s).forEach(([a,f])=>n(a,f,i));o(e,!1),o(r,!0)}var uo=()=>{throw new Error("not implemented")};var ae=BigInt(0),Y=BigInt(1),ft=BigInt(2),Oi=BigInt(3),Ni=BigInt(4),ki=BigInt(5),iu=BigInt(7),Ki=BigInt(8),au=BigInt(9),Pi=BigInt(16);function J(t,e){if(e<=ae)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=ae?r:e+r}function z(t,e,r){if(e<ae)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >ae;)n*=n,n%=r;return n}function Ci(t,e){if(t===ae)throw new Error("invert: expected non-zero number");if(e<=ae)throw new Error("invert: expected positive modulus, got "+e);let r=J(t,e),n=e,o=ae,s=Y,i=Y,a=ae;for(;r!==ae;){let c=n/r,u=n-r*c,l=o-i*c,y=s-a*c;n=r,r=u,o=i,s=a,i=l,a=y}if(n!==Y)throw new Error("invert: does not exist");return J(o,e)}function lo(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Mi(t,e){let r=t,n=(r.ORDER+Y)/Ni,o=r.pow(e,n);return lo(r,o,e),o}function cu(t,e){let r=t,n=(r.ORDER-ki)/Ki,o=r.mul(e,ft),s=r.pow(o,n),i=r.mul(e,s),a=r.mul(r.mul(i,ft),s),f=r.mul(i,r.sub(a,r.ONE));return lo(r,f,e),f}function fu(t){let e=Nt(t),r=qi(t),n=r(e,e.neg(e.ONE)),o=r(e,n),s=r(e,e.neg(n)),i=(t+iu)/Pi;return((a,f)=>{let c=a,u=c.pow(f,i),l=c.mul(u,n),y=c.mul(u,o),h=c.mul(u,s),p=c.eql(c.sqr(l),f),w=c.eql(c.sqr(y),f);u=c.cmov(u,l,p),l=c.cmov(h,y,w);let m=c.eql(c.sqr(l),f),b=c.cmov(u,l,m);return lo(c,b,f),b})}function qi(t){if(t<Oi)throw new Error("sqrt is not defined for small field");let e=t-Y,r=0;for(;e%ft===ae;)e/=ft,r++;let n=ft,o=Nt(t);for(;Fi(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Mi;let s=o.pow(n,e),i=(e+Y)/ft;return function(f,c){let u=f;if(u.is0(c))return c;if(Fi(u,c)!==1)throw new Error("Cannot find square root");let l=r,y=u.mul(u.ONE,s),h=u.pow(c,e),p=u.pow(c,i);for(;!u.eql(h,u.ONE);){if(u.is0(h))return u.ZERO;let w=1,m=u.sqr(h);for(;!u.eql(m,u.ONE);)if(w++,m=u.sqr(m),w===l)throw new Error("Cannot find square root");let b=Y<<BigInt(l-w-1),S=u.pow(y,b);l=w,y=u.sqr(S),h=u.mul(h,y),p=u.mul(p,S)}return p}}function uu(t){return t%Ni===Oi?Mi:t%Ki===ki?cu:t%Pi===au?fu(t):qi(t)}var Ke=(t,e)=>(J(t,e)&Y)===Y,lu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ho(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=lu.reduce((n,o)=>(n[o]="function",n),e);if(Se(t,r),Ee(t.BYTES,"BYTES"),Ee(t.BITS,"BITS"),t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=Y)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function hu(t,e,r){let n=t;if(r<ae)throw new Error("invalid exponent, negatives unsupported");if(r===ae)return n.ONE;if(r===Y)return e;let o=n.ONE,s=e;for(;r>ae;)r&Y&&(o=n.mul(o,s)),s=n.sqr(s),r>>=Y;return o}function dr(t,e,r=!1){let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),s=e.reduce((a,f,c)=>n.is0(f)?a:(o[c]=a,n.mul(a,f)),n.ONE),i=n.inv(s);return e.reduceRight((a,f,c)=>n.is0(f)?a:(o[c]=n.mul(a,o[c]),n.mul(a,f)),i),o}function Fi(t,e){let r=t,n=(r.ORDER-Y)/ft,o=r.pow(e,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function du(t,e){if(e!==void 0&&co(e),t<=ae)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=Ot(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${e})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Ui=new WeakMap,Xr=class{ORDER;BITS;BYTES;isLE;ZERO=ae;ONE=Y;_lengths;_mod;constructor(e,r={}){if(e<=Y)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=du(e,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(e){return J(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ae<=e&&e<this.ORDER}is0(e){return e===ae}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Y)===Y}neg(e){return J(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return J(e*e,this.ORDER)}add(e,r){return J(e+r,this.ORDER)}sub(e,r){return J(e-r,this.ORDER)}mul(e,r){return J(e*r,this.ORDER)}pow(e,r){return hu(this,e,r)}div(e,r){return J(e*Ci(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return Ci(e,this.ORDER)}sqrt(e){let r=Ui.get(this);return r||Ui.set(this,r=uu(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?fo(e,this.BYTES):Yr(e,this.BYTES)}fromBytes(e,r=!1){P(e);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let c=new Uint8Array(o);c.set(e,s?0:c.length-e.length),e=c}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let f=s?_e(e):ct(e);if(a&&(f=J(f,i)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(e){return dr(this,e)}cmov(e,r,n){return we(n,"condition"),n?r:e}};Object.freeze(Xr.prototype);function Nt(t,e={}){return new Xr(t,e)}function Vi(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=Y)throw new Error("field order must be greater than 1");let e=Ot(t-Y);return Math.ceil(e/8)}function po(t){let e=Vi(t);return e+Math.ceil(e/2)}function mo(t,e,r=!1){P(t);let n=t.length,o=Vi(e),s=Math.max(po(e),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?_e(t):ct(t),a=J(i,e-Y)+Y;return r?fo(a,o):Yr(a,o)}var kt=BigInt(0),ut=BigInt(1);function pr(t,e){let r=e.negate();return t?r:e}function lt(t,e){let r=dr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function $i(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function yo(t,e){$i(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,s=hr(t),i=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Hi(t,e,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,a=Number(t&o),f=t>>i;a>n&&(a-=s,f+=ut);let c=e*n,u=c+Math.abs(a)-1,l=a===0,y=a<0,h=e%2!==0;return{nextN:f,offset:u,isZero:l,isNeg:y,isNegF:h,offsetF:c}}var bo=new WeakMap,Zi=new WeakMap;function xo(t){return Zi.get(t)||1}function zi(t){if(t!==kt)throw new Error("invalid wNAF")}var Kt=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>kt;)r&ut&&(n=n.add(o)),o=o.double(),r>>=ut;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=yo(r,this.bits),s=[],i=e,a=i;for(let f=0;f<n;f++){a=i,s.push(a);for(let c=1;c<o;c++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=yo(e,this.bits);for(let a=0;a<i.windows;a++){let{nextN:f,offset:c,isZero:u,isNeg:l,isNegF:y,offsetF:h}=Hi(n,a,i);n=f,u?s=s.add(pr(y,r[h])):o=o.add(pr(l,r[c]))}return zi(n),{p:o,f:s}}wNAFUnsafe(e,r,n,o=this.ZERO){let s=yo(e,this.bits);for(let i=0;i<s.windows&&n!==kt;i++){let{nextN:a,offset:f,isZero:c,isNeg:u}=Hi(n,i,s);if(n=a,!c){let l=r[f];o=o.add(u?l.negate():l)}}return zi(n),o}getPrecomputes(e,r,n){let o=bo.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),bo.set(r,o))),o}cached(e,r,n){let o=xo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let s=xo(e);return s===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,o)}createCache(e,r){$i(r,this.bits),Zi.set(e,r),bo.delete(e)}hasCache(e){return xo(e)!==1}};function Yi(t,e,r,n){let o=e,s=t.ZERO,i=t.ZERO;for(;r>kt||n>kt;)r&ut&&(s=s.add(o)),n&ut&&(i=i.add(o)),o=o.double(),r>>=ut,n>>=ut;return{p1:s,p2:i}}function ji(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ho(e),e}else return Nt(t,{isLE:r})}function Wr(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let f of["p","n","h"]){let c=e[f];if(!(typeof c=="bigint"&&c>kt))throw new Error(`CURVE.${f} must be positive bigint`)}let o=ji(e.p,r.Fp,n),s=ji(e.n,r.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let f of a)if(!o.isValid(e[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}function Jr(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Ye=BigInt(0),se=BigInt(1),go=BigInt(2),pu=BigInt(8);function mu(t,e,r,n){let o=t.sqr(r),s=t.sqr(n),i=t.add(t.mul(e.a,o),s),a=t.add(t.ONE,t.mul(e.d,t.mul(o,s)));return t.eql(i,a)}function Gi(t,e={}){let r=e,n=Wr("edwards",t,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;Se(r,{},{uvRatio:"function"});let f=go<<BigInt(s.BYTES*8)-se,c=w=>o.create(w),u=r.uvRatio===void 0?(w,m)=>{try{return{isValid:!0,value:o.sqrt(o.div(w,m))}}catch{return{isValid:!1,value:Ye}}}:r.uvRatio;if(!mu(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function l(w,m,b=!1){let S=b?se:Ye;return Ut("coordinate "+w,m,S,f),m}function y(w){if(!(w instanceof h))throw new Error("EdwardsPoint expected")}class h{static BASE=new h(i.Gx,i.Gy,se,c(i.Gx*i.Gy));static ZERO=new h(Ye,se,se,Ye);static Fp=o;static Fn=s;X;Y;Z;T;constructor(m,b,S,v){this.X=l("x",m),this.Y=l("y",b),this.Z=l("z",S,!0),this.T=l("t",v),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){if(m instanceof h)throw new Error("extended point not allowed");let{x:b,y:S}=m||{};return l("x",b),l("y",S),new h(b,S,se,c(b*S))}static fromBytes(m,b=!1){let S=o.BYTES,{a:v,d:T}=i;m=lr(P(m,S,"point")),we(b,"zip215");let L=lr(m),F=m[S-1];L[S-1]=F&-129;let R=_e(L),I=b?f:o.ORDER;Ut("point.y",R,Ye,I);let O=c(R*R),V=c(O-se),N=c(T*O-v),{isValid:d,value:x}=u(V,N);if(!d)throw new Error("bad point: invalid y coordinate");let A=(x&se)===se,E=(F&128)!==0;if(!b&&x===Ye&&E)throw new Error("bad point: x=0 and x_0=1");return E!==A&&(x=c(-x)),h.fromAffine({x,y:R})}static fromHex(m,b=!1){return h.fromBytes(Ft(m),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,b=!0){return p.createCache(this,m),b||this.multiply(go),this}assertValidity(){let m=this,{a:b,d:S}=i;if(m.is0())throw new Error("bad point: ZERO");let{X:v,Y:T,Z:L,T:F}=m,R=c(v*v),I=c(T*T),O=c(L*L),V=c(O*O),N=c(R*b),d=c(O*c(N+I)),x=c(V+c(S*c(R*I)));if(d!==x)throw new Error("bad point: equation left != right (1)");let A=c(v*T),E=c(L*F);if(A!==E)throw new Error("bad point: equation left != right (2)")}equals(m){y(m);let{X:b,Y:S,Z:v}=this,{X:T,Y:L,Z:F}=m,R=c(b*F),I=c(T*v),O=c(S*F),V=c(L*v);return R===I&&O===V}is0(){return this.equals(h.ZERO)}negate(){return new h(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:m}=i,{X:b,Y:S,Z:v}=this,T=c(b*b),L=c(S*S),F=c(go*c(v*v)),R=c(m*T),I=b+S,O=c(c(I*I)-T-L),V=R+L,N=V-F,d=R-L,x=c(O*N),A=c(V*d),E=c(O*d),g=c(N*V);return new h(x,A,g,E)}add(m){y(m);let{a:b,d:S}=i,{X:v,Y:T,Z:L,T:F}=this,{X:R,Y:I,Z:O,T:V}=m,N=c(v*R),d=c(T*I),x=c(F*S*V),A=c(L*O),E=c((v+T)*(R+I)-N-d),g=A-x,B=A+x,_=c(d-b*N),D=c(E*g),C=c(B*_),U=c(E*_),K=c(g*B);return new h(D,C,K,U)}subtract(m){return y(m),this.add(m.negate())}multiply(m){if(!s.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:S}=p.cached(this,m,v=>lt(h,v));return lt(h,[b,S])[0]}multiplyUnsafe(m){if(!s.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===Ye?h.ZERO:this.is0()||m===se?this:p.unsafe(this,m,b=>lt(h,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return p.unsafe(this,i.n).is0()}toAffine(m){let b=this,S=m,{X:v,Y:T,Z:L}=b,F=b.is0();S==null&&(S=F?pu:o.inv(L));let R=c(v*S),I=c(T*S),O=o.mul(L,S);if(F)return{x:Ye,y:se};if(O!==se)throw new Error("invZ was invalid");return{x:R,y:I}}clearCofactor(){return a===se?this:this.multiplyUnsafe(a)}toBytes(){let{x:m,y:b}=this.toAffine(),S=o.toBytes(b);return S[S.length-1]|=m&se?128:0,S}toHex(){return Ct(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let p=new Kt(h,s.BITS);return s.BITS>=8&&h.BASE.precompute(8),Object.freeze(h.prototype),Object.freeze(h),h}var Qr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){uo()}static fromHex(e){uo()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Ct(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,r){return this.ep.precompute(e,r),this}};function Xi(t,e,r={}){if(typeof e!="function")throw new Error('"hash" function param is required');let n=e,o=r;Se(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:a,Fn:f}=t,c=n.outputLen,u=2*a.BYTES;if(c!==void 0&&(Ee(c,"hash.outputLen"),c!==u))throw new Error(`hash.outputLen must be ${u}, got ${c}`);let l=o.randomBytes===void 0?fr:o.randomBytes,y=o.adjustScalarBytes===void 0?d=>d:o.adjustScalarBytes,h=o.domain===void 0?(d,x,A)=>{if(we(A,"phflag"),x.length||A)throw new Error("Contexts/pre-hash are not supported");return d}:o.domain;function p(d){return f.create(_e(d))}function w(d){let x=R.secretKey;P(d,R.secretKey,"secretKey");let A=P(n(d),2*x,"hashedSecretKey"),E=y(A.slice(0,x)),g=A.slice(x,2*x),B=p(E);return{head:E,prefix:g,scalar:B}}function m(d){let{head:x,prefix:A,scalar:E}=w(d),g=i.multiply(E),B=g.toBytes();return{head:x,prefix:A,scalar:E,point:g,pointBytes:B}}function b(d){return m(d).pointBytes}function S(d=Uint8Array.of(),...x){let A=te(...x);return p(n(h(A,P(d,void 0,"context"),!!s)))}function v(d,x,A={}){d=P(d,void 0,"message"),s&&(d=s(d));let{prefix:E,scalar:g,pointBytes:B}=m(x),_=S(A.context,E,d),D=i.multiply(_).toBytes(),C=S(A.context,D,B,d),U=f.create(_+C*g);if(!f.isValid(U))throw new Error("sign failed: invalid s");let K=te(D,f.toBytes(U));return P(K,R.signature,"result")}let T={zip215:o.zip215};function L(d,x,A,E=T){let{context:g}=E,B=E.zip215===void 0?!!T.zip215:E.zip215,_=R.signature;d=P(d,_,"signature"),x=P(x,void 0,"message"),A=P(A,R.publicKey,"publicKey"),B!==void 0&&we(B,"zip215"),s&&(x=s(x));let D=_/2,C=d.subarray(0,D),U=_e(d.subarray(D,_)),K,M,k;try{K=t.fromBytes(A,B),M=t.fromBytes(C,B),k=i.multiplyUnsafe(U)}catch{return!1}if(!B&&K.isSmallOrder())return!1;let Q=S(g,C,A,x);return M.add(K.multiplyUnsafe(Q)).subtract(k).clearCofactor().is0()}let F=a.BYTES,R={secretKey:F,publicKey:F,signature:2*F,seed:F};function I(d){return d=d===void 0?l(R.seed):d,P(d,R.seed,"seed")}function O(d){return at(d)&&d.length===R.secretKey}function V(d,x){try{return!!t.fromBytes(d,x===void 0?T.zip215:x)}catch{return!1}}let N={getExtendedPublicKey:m,randomSecretKey:I,isValidSecretKey:O,isValidPublicKey:V,toMontgomery(d){let{y:x}=t.fromBytes(d),A=R.publicKey,E=A===32;if(!E&&A!==57)throw new Error("only defined for 25519 and 448");let g=E?a.div(se+x,se-x):a.div(x-se,x+se);return a.toBytes(g)},toMontgomerySecret(d){let x=R.secretKey;P(d,x);let A=n(d.subarray(0,x));return y(A).subarray(0,x)}};return Object.freeze(R),Object.freeze(N),Object.freeze({keygen:Jr(I,b),getPublicKey:b,sign:v,verify:L,utils:N,Point:t,lengths:R})}function mr(t,e){if(Ee(t),Ee(e),e<0||e>4)throw new Error("invalid I2OSP length: "+e);if(t<0||t>2**(8*e)-1)throw new Error("invalid I2OSP input: "+t);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function yu(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function bu(t){if(!at(t)&&typeof t!="string")throw new Error("DST must be Uint8Array or ascii string");let e=typeof t=="string"?Gr(t):t;if(e.length===0)throw new Error("DST must be non-empty");return e}function wo(t,e,r,n){P(t),Ee(r),e=bu(e),e.length>255&&(e=n(te(Gr("H2C-OVERSIZE-DST-"),e)));let{outputLen:o,blockLen:s}=n,i=Math.ceil(r/o);if(r>65535||i>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=te(e,mr(e.length,1)),f=new Uint8Array(s),c=mr(r,2),u=new Array(i),l=n(te(f,t,c,mr(0,1),a));u[0]=n(te(l,mr(1,1),a));for(let h=1;h<i;h++){let p=[yu(l,u[h-1]),mr(h+1,1),a];u[h]=n(te(...p))}return te(...u).slice(0,r)}var Wi="HashToScalar-";var xu=BigInt(0),Pe=BigInt(1),Ji=BigInt(2);var gu=BigInt(5),wu=BigInt(8),Pt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ao={p:Pt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:wu,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Eu(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Pt,a=t*t%s*t%s,f=z(a,Ji,s)*a%s,c=z(f,Pe,s)*t%s,u=z(c,gu,s)*c%s,l=z(u,e,s)*u%s,y=z(l,r,s)*l%s,h=z(y,n,s)*y%s,p=z(h,o,s)*h%s,w=z(p,o,s)*h%s,m=z(w,e,s)*u%s;return{pow_p_5_8:z(m,Ji,s)*t%s,b2:a}}function Su(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}var Eo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Bo(t,e){let r=Pt,n=J(e*e*e,r),o=J(n*n*e,r),s=Eu(t*o).pow_p_5_8,i=J(t*n*s,r),a=J(e*i*i,r),f=i,c=J(i*Eo,r),u=a===t,l=a===J(-t,r),y=a===J(-t*Eo,r);return u&&(i=f),(l||y)&&(i=c),Ke(i,r)&&(i=J(-i,r)),{isValid:u||l,value:i}}var Xe=Gi(Ao,{uvRatio:Bo}),Ge=Xe.Fp,ta=Xe.Fn;function vu(t){return Xi(Xe,zr,Object.assign({adjustScalarBytes:Su,zip215:!0},t))}var ra=vu({});var So=Eo,Au=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Bu=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Iu=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Lu=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Qi=t=>Bo(Pe,t),Tu=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),vo=t=>Ge.create(_e(t)&Tu);function ea(t){let{d:e}=Ao,r=Pt,n=b=>Ge.create(b),o=n(So*t*t),s=n((o+Pe)*Iu),i=BigInt(-1),a=n((i-e*o)*n(o+e)),{isValid:f,value:c}=Bo(s,a),u=n(c*t);Ke(u,r)||(u=n(-u)),f||(c=u),f||(i=o);let l=n(i*(o-Pe)*Lu-a),y=c*c,h=n((c+c)*a),p=n(l*Au),w=n(Pe-y),m=n(Pe+y);return new Xe(n(h*m),n(w*p),n(p*m),n(h*w))}var We=class t extends Qr{static BASE=new t(Xe.BASE);static ZERO=new t(Xe.ZERO);static Fp=Ge;static Fn=ta;constructor(e){super(e)}static fromAffine(e){return new t(Xe.fromAffine(e))}assertSame(e){if(!(e instanceof t))throw new Error("RistrettoPoint expected")}init(e){return new t(e)}static fromBytes(e){ye(e,32);let{a:r,d:n}=Ao,o=Pt,s=T=>Ge.create(T),i=vo(e);if(!_i(Ge.toBytes(i),e)||Ke(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),f=s(Pe+r*a),c=s(Pe-r*a),u=s(f*f),l=s(c*c),y=s(r*n*u-l),{isValid:h,value:p}=Qi(s(y*l)),w=s(p*c),m=s(p*w*y),b=s((i+i)*w);Ke(b,o)&&(b=s(-b));let S=s(f*m),v=s(b*S);if(!h||Ke(v,o)||S===xu)throw new Error("invalid ristretto255 encoding 2");return new t(new Xe(b,S,Pe,v))}static fromHex(e){return t.fromBytes(sr(e))}toBytes(){let{X:e,Y:r,Z:n,T:o}=this.ep,s=Pt,i=m=>Ge.create(m),a=i(i(n+r)*i(n-r)),f=i(e*r),c=i(f*f),{value:u}=Qi(i(a*c)),l=i(u*a),y=i(u*f),h=i(l*y*o),p;if(Ke(o*h,s)){let m=i(r*So),b=i(e*So);e=m,r=b,p=i(l*Bu)}else p=y;Ke(e*h,s)&&(r=i(-r));let w=i((n-r)*p);return Ke(w,s)&&(w=i(-w)),Ge.toBytes(w)}equals(e){this.assertSame(e);let{X:r,Y:n}=this.ep,{X:o,Y:s}=e.ep,i=c=>Ge.create(c),a=i(r*s)===i(n*o),f=i(n*s)===i(r*o);return a||f}is0(){return this.equals(t.ZERO)}};Object.freeze(We.BASE);Object.freeze(We.ZERO);Object.freeze(We.prototype);Object.freeze(We);var Du=Object.freeze({Point:We,hashToCurve(t,e){let r=e?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":e.DST,n=wo(t,r,64,zr);return Du.deriveToCurve(n)},hashToScalar(t,e={DST:Wi}){let r=wo(t,e.DST,64,zr);return ta.create(_e(r))},deriveToCurve(t){ye(t,64);let e=vo(t.subarray(0,32)),r=ea(e),n=vo(t.subarray(32,64)),o=ea(n);return new We(r.add(o))}});var yr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},en=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var xe={get(t=globalThis){let e=t.crypto;if(e?.subtle==null)throw new en("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 e}};var Mt=32;var Io,_u=(async()=>{try{return await xe.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Ru(t,e,r){if(t.buffer instanceof ArrayBuffer){let n=await xe.get().subtle.importKey("raw",t.buffer,{name:"Ed25519"},!1,["verify"]);return await xe.get().subtle.verify({name:"Ed25519"},n,Le(e),Le(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Cu(t,e,r){return ra.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}async function na(t,e,r){return Io==null&&(Io=await _u),Io?Ru(t,e,r):Cu(t,e,r)}function tn(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var rn=class{type="Ed25519";raw;constructor(e){this.raw=Lo(e,Mt)}toMultihash(){return Ie.digest(Dt(this))}toCID(){return ce.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=na(this.raw,r,e);return tn(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ia(t){return t=Lo(t,Mt),new rn(t)}function Lo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new j(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}function Je(t=0){return new Uint8Array(t)}var Fu=Math.pow(2,7),Uu=Math.pow(2,14),Ou=Math.pow(2,21),aa=Math.pow(2,28),ca=Math.pow(2,35),fa=Math.pow(2,42),ua=Math.pow(2,49),he=128,Qe=127;function br(t){if(t<Fu)return 1;if(t<Uu)return 2;if(t<Ou)return 3;if(t<aa)return 4;if(t<ca)return 5;if(t<fa)return 6;if(t<ua)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function la(t,e,r=0){switch(br(t)){case 8:e[r++]=t&255|he,t/=128;case 7:e[r++]=t&255|he,t/=128;case 6:e[r++]=t&255|he,t/=128;case 5:e[r++]=t&255|he,t/=128;case 4:e[r++]=t&255|he,t>>>=7;case 3:e[r++]=t&255|he,t>>>=7;case 2:e[r++]=t&255|he,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function ha(t,e){let r=t[e],n=0;if(n+=r&Qe,r<he||(r=t[e+1],n+=(r&Qe)<<7,r<he)||(r=t[e+2],n+=(r&Qe)<<14,r<he)||(r=t[e+3],n+=(r&Qe)<<21,r<he)||(r=t[e+4],n+=(r&Qe)*aa,r<he)||(r=t[e+5],n+=(r&Qe)*ca,r<he)||(r=t[e+6],n+=(r&Qe)*fa,r<he)||(r=t[e+7],n+=(r&Qe)*ua,r<he))return n;throw new RangeError("Could not decode varint")}var To=new Float32Array([-0]),et=new Uint8Array(To.buffer);function da(t,e,r){To[0]=t,e[r]=et[0],e[r+1]=et[1],e[r+2]=et[2],e[r+3]=et[3]}function pa(t,e){return et[0]=t[e],et[1]=t[e+1],et[2]=t[e+2],et[3]=t[e+3],To[0]}var Do=new Float64Array([-0]),fe=new Uint8Array(Do.buffer);function ma(t,e,r){Do[0]=t,e[r]=fe[0],e[r+1]=fe[1],e[r+2]=fe[2],e[r+3]=fe[3],e[r+4]=fe[4],e[r+5]=fe[5],e[r+6]=fe[6],e[r+7]=fe[7]}function ya(t,e){return fe[0]=t[e],fe[1]=t[e+1],fe[2]=t[e+2],fe[3]=t[e+3],fe[4]=t[e+4],fe[5]=t[e+5],fe[6]=t[e+6],fe[7]=t[e+7],Do[0]}var Nu=BigInt(Number.MAX_SAFE_INTEGER),ku=BigInt(Number.MIN_SAFE_INTEGER),be=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return ht;if(e<Nu&&e>ku)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>ba&&(o=0n,++n>ba&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return ht;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):ht}},ht=new be(0,0);ht.toBigInt=function(){return 0n};ht.zzEncode=ht.zzDecode=function(){return this};ht.length=function(){return 1};var ba=4294967296n;function xa(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function ga(t,e,r){if(r-e<1)return"";let o,s=[],i=0,a;for(;e<r;)a=t[e++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&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 _o(t,e,r){let n=r,o,s;for(let i=0;i<t.length;++i)o=t.charCodeAt(i),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((s=t.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function ve(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function nn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Ro=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ve(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ve(this,4);return nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ve(this,4);return nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ve(this,4);let e=pa(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ve(this,4);let e=ya(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw ve(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return ga(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ve(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ve(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new be(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw ve(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw ve(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ve(this,8);let e=nn(this.buf,this.pos+=4),r=nn(this.buf,this.pos+=4);return new be(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ha(this.buf,this.pos);return this.pos+=br(e),e}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 xr(t){return new Ro(t instanceof Uint8Array?t:t.subarray())}function dt(t,e,r){let n=xr(t);return e.decode(n,void 0,r)}var No={};H(No,{base10:()=>zu});var rm=new Uint8Array(0);function Ea(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Me(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function Sa(t){return new TextEncoder().encode(t)}function va(t){return new TextDecoder().decode(t)}function Ku(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,f=t.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var w=0,m=0,b=0,S=p.length;b!==S&&p[b]===0;)b++,w++;for(var v=(S-b)*u+1>>>0,T=new Uint8Array(v);b!==S;){for(var L=p[b],F=0,R=v-1;(L!==0||F<m)&&R!==-1;R--,F++)L+=256*T[R]>>>0,T[R]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");m=F,b++}for(var I=v-m;I!==v&&T[I]===0;)I++;for(var O=f.repeat(w);I<v;++I)O+=t.charAt(T[I]);return O}function y(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var w=0;if(p[w]!==" "){for(var m=0,b=0;p[w]===f;)m++,w++;for(var S=(p.length-w)*c+1>>>0,v=new Uint8Array(S);p[w];){var T=r[p.charCodeAt(w)];if(T===255)return;for(var L=0,F=S-1;(T!==0||L<b)&&F!==-1;F--,L++)T+=a*v[F]>>>0,v[F]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");b=L,w++}if(p[w]!==" "){for(var R=S-b;R!==S&&v[R]===0;)R++;for(var I=new Uint8Array(m+(S-R)),O=m;R!==S;)I[O++]=v[R++];return I}}}function h(p){var w=y(p);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:y,decode:h}}var Pu=Ku,Mu=Pu,Ba=Mu;var Co=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Fo=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ia(this,e)}},Uo=class{decoders;constructor(e){this.decoders=e}or(e){return Ia(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ia(t,e){return new Uo({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Oo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Co(e,r,n),this.decoder=new Fo(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function qt({name:t,prefix:e,encode:r,decode:n}){return new Oo(t,e,r,n)}function tt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ba(r,t);return qt({prefix:e,name:t,encode:n,decode:s=>Me(o(s))})}function qu(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,f=0;for(let c=0;c<o;++c){let u=e[t[c]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[f++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Vu(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let f=0;f<t.length;++f)for(a=a<<8|t[f],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Hu(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function G({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Hu(n);return qt({prefix:e,name:t,encode(s){return Vu(s,n,r)},decode(s){return qu(s,o,r,t)}})}var zu=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var ko={};H(ko,{base16:()=>ju,base16upper:()=>$u});var ju=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$u=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ko={};H(Ko,{base2:()=>Zu});var Zu=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Po={};H(Po,{base256emoji:()=>Ju});var La=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}"),Yu=La.reduce((t,e,r)=>(t[r]=e,t),[]),Gu=La.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Xu(t){return t.reduce((e,r)=>(e+=Yu[r],e),"")}function Wu(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Gu[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Ju=qt({prefix:"\u{1F680}",name:"base256emoji",encode:Xu,decode:Wu});var Mo={};H(Mo,{base32:()=>Vt,base32hex:()=>rl,base32hexpad:()=>ol,base32hexpadupper:()=>sl,base32hexupper:()=>nl,base32pad:()=>el,base32padupper:()=>tl,base32upper:()=>Qu,base32z:()=>il});var Vt=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qu=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),el=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tl=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rl=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nl=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ol=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sl=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),il=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var qo={};H(qo,{base36:()=>gr,base36upper:()=>al});var gr=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),al=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vo={};H(Vo,{base58btc:()=>Re,base58flickr:()=>cl});var Re=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),cl=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ho={};H(Ho,{base64:()=>fl,base64pad:()=>ul,base64url:()=>ll,base64urlpad:()=>hl});var fl=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ul=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ll=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hl=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zo={};H(zo,{base8:()=>dl});var dl=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jo={};H(jo,{identity:()=>pl});var pl=qt({prefix:"\0",name:"identity",encode:t=>va(t),decode:t=>Sa(t)});var xm=new TextEncoder,gm=new TextDecoder;var Zo={};H(Zo,{identity:()=>kl});var bl=_a,Ta=128,xl=127,gl=~xl,wl=Math.pow(2,31);function _a(t,e,r){e=e||[],r=r||0;for(var n=r;t>=wl;)e[r++]=t&255|Ta,t/=128;for(;t&gl;)e[r++]=t&255|Ta,t>>>=7;return e[r]=t|0,_a.bytes=r-n+1,e}var El=$o,Sl=128,Da=127;function $o(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw $o.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Da)<<o:(i&Da)*Math.pow(2,o),o+=7}while(i>=Sl);return $o.bytes=s-n,r}var vl=Math.pow(2,7),Al=Math.pow(2,14),Bl=Math.pow(2,21),Il=Math.pow(2,28),Ll=Math.pow(2,35),Tl=Math.pow(2,42),Dl=Math.pow(2,49),_l=Math.pow(2,56),Rl=Math.pow(2,63),Cl=function(t){return t<vl?1:t<Al?2:t<Bl?3:t<Il?4:t<Ll?5:t<Tl?6:t<Dl?7:t<_l?8:t<Rl?9:10},Fl={encode:bl,decode:El,encodingLength:Cl},Ul=Fl,wr=Ul;function Er(t,e=0){return[wr.decode(t,e),wr.decode.bytes]}function Ht(t,e,r=0){return wr.encode(t,e,r),e}function zt(t){return wr.encodingLength(t)}function $t(t,e){let r=e.byteLength,n=zt(t),o=n+zt(r),s=new Uint8Array(o+r);return Ht(t,s,0),Ht(r,s,n),s.set(e,o),new jt(t,r,e,s)}function Ra(t){let e=Me(t),[r,n]=Er(e),[o,s]=Er(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new jt(r,o,i,e)}function Ca(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ea(t.bytes,r.bytes)}}var jt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var Fa=0,Ol="identity",Ua=Me;function Nl(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return $t(Fa,Ua(t))}var kl={code:Fa,name:Ol,encode:Ua,digest:Nl};var Xo={};H(Xo,{sha256:()=>Pl,sha512:()=>Ml});var Kl=20;function Go({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Yo(t,e,r,n,o)}var Yo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,s){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Kl,this.maxDigestLength=s}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Oa(n,this.code,r?.truncate):n.then(o=>Oa(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Oa(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return $t(e,t)}function ka(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Pl=Go({name:"sha2-256",code:18,encode:ka("SHA-256")}),Ml=Go({name:"sha2-512",code:19,encode:ka("SHA-512")});function Ka(t,e){let{bytes:r,version:n}=t;return n===0?Vl(r,Wo(t),e??Re.encoder):Hl(r,Wo(t),e??Vt.encoder)}var Pa=new WeakMap;function Wo(t){let e=Pa.get(t);if(e==null){let r=new Map;return Pa.set(t,r),r}return e}var sn=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==vr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zl)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=$t(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Ca(e.multihash,n.multihash)}toString(e){return Ka(this,e)}toJSON(){return{"/":Ka(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i??Ma(n,o,s.bytes))}else if(r[jl]===!0){let{version:n,multihash:o,code:s}=r,i=Ra(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==vr)throw new Error(`Version 0 CID must use dag-pb (code: ${vr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ma(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,vr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Me(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new jt(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,y]=Er(e.subarray(r));return r+=y,l},o=n(),s=vr;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),f=n(),c=r+f,u=c-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:u,size:c}}static parse(e,r){let[n,o]=ql(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wo(s).set(n,e),s}};function ql(t,e){switch(t[0]){case"Q":{let r=e??Re;return[Re.prefix,r.decode(`${Re.prefix}${t}`)]}case Re.prefix:{let r=e??Re;return[Re.prefix,r.decode(t)]}case Vt.prefix:{let r=e??Vt;return[Vt.prefix,r.decode(t)]}case gr.prefix:{let r=e??gr;return[gr.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Vl(t,e,r){let{prefix:n}=r;if(n!==Re.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function Hl(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var vr=112,zl=18;function Ma(t,e,r){let n=zt(t),o=n+zt(e),s=new Uint8Array(o+r.byteLength);return Ht(t,s,0),Ht(e,s,n),s.set(r,o),s}var jl=Symbol.for("@ipld/js-cid/CID");var Jo={...jo,...Ko,...zo,...No,...ko,...Mo,...qo,...Vo,...Ho,...Po},qm={...Xo,...Zo};function Va(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var qa=Va("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Qo=Va("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Je(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),$l={utf8:qa,"utf-8":qa,hex:Jo.base16,latin1:Qo,ascii:Qo,binary:Qo,...Jo},Ha=$l;function za(t,e="utf8"){let r=Ha[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function es(t){let e=t??8192,r=e>>>1,n,o=e;return function(i){if(i<1||i>r)return Je(i);o+i>e&&(n=Je(e),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var pt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function ts(){}var ns=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Zl=es();function Yl(t){return globalThis.Buffer!=null?Je(t):Zl(t)}var Br=class{len;head;tail;states;constructor(){this.len=0,this.head=new pt(ts,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new pt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new os((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(an,10,be.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=be.fromBigInt(e);return this._push(an,r.length(),r)}uint64Number(e){return this._push(la,br(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=be.fromBigInt(e).zzEncode();return this._push(an,r.length(),r)}sint64Number(e){let r=be.fromNumber(e).zzEncode();return this._push(an,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(rs,1,e?1:0)}fixed32(e){return this._push(Ar,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=be.fromBigInt(e);return this._push(Ar,4,r.lo)._push(Ar,4,r.hi)}fixed64Number(e){let r=be.fromNumber(e);return this._push(Ar,4,r.lo)._push(Ar,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(da,4,e)}double(e){return this._push(ma,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(rs,1,0):this.uint32(r)._push(Xl,r,e)}string(e){let r=xa(e);return r!==0?this.uint32(r)._push(_o,r,e):this._push(rs,1,0)}fork(){return this.states=new ns(this),this.head=this.tail=new pt(ts,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 pt(ts,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Yl(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function rs(t,e,r){e[r]=t&255}function Gl(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var os=class extends pt{next;constructor(e,r){super(Gl,e,r),this.next=void 0}};function an(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Ar(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Xl(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Br.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Wl,e,t),this},Br.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Jl,e,t),this});function Wl(t,e,r){e.set(t,r)}function Jl(t,e,r){t.length<40?_o(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(za(t),r)}function ss(){return new Br}function mt(t,e){let r=ss();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*yt(t,e,r){let n=xr(t);yield*e.stream(n,void 0,"$",r)}var cn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function fn(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function Ir(t){function e(s){if(t[s.toString()]==null)throw new Error("Invalid enum value");return t[s]}let r=function(i,a){let f=e(i);a.int32(f)},n=function(i){let a=i.int32();return e(a)},o=function*(i){let a=i.int32();yield e(a)};return fn("enum",cn.VARINT,r,n,o)}function bt(t,e,r){return fn("message",cn.LENGTH_DELIMITED,t,e,r)}var ue;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(ue||(ue={}));var is;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(is||(is={}));(function(t){t.codec=()=>Ir(is)})(ue||(ue={}));var rt;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),ue.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=ue.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:ue.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),e);function r(s){return mt(s,t.codec())}t.encode=r;function n(s,i){return dt(s,t.codec(),i)}t.decode=n;function o(s,i){return yt(s,t.codec(),i)}t.stream=o})(rt||(rt={}));var as;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),ue.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=ue.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:ue.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),e);function r(s){return mt(s,t.codec())}t.encode=r;function n(s,i){return dt(s,t.codec(),i)}t.decode=n;function o(s,i){return yt(s,t.codec(),i)}t.stream=o})(as||(as={}));var Tr={};H(Tr,{MAX_RSA_KEY_SIZE:()=>cs,generateRSAKeyPair:()=>Xa,jwkToJWKKeyPair:()=>Wa,jwkToPkcs1:()=>rh,jwkToPkix:()=>hs,jwkToRSAPrivateKey:()=>ps,pkcs1MessageToJwk:()=>us,pkcs1MessageToRSAPrivateKey:()=>ds,pkcs1ToJwk:()=>th,pkcs1ToRSAPrivateKey:()=>Ya,pkixMessageToJwk:()=>ls,pkixMessageToRSAPublicKey:()=>un,pkixToJwk:()=>nh,pkixToRSAPublicKey:()=>Ga});var Zt=class{type="RSA";jwk;_raw;_multihash;constructor(e,r){this.jwk=e,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Tr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ce.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}verify(e,r,n){return Za(this.jwk,r,e,n)}},Lr=class{type="RSA";jwk;_raw;publicKey;constructor(e,r){this.jwk=e,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Tr.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}sign(e,r){return $a(this.jwk,e,r)}};var cs=8192,fs=18,Ql=1062,eh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function th(t){let e=Te(t);return us(e)}function us(t){return{n:Z(t[1],"base64url"),e:Z(t[2],"base64url"),d:Z(t[3],"base64url"),p:Z(t[4],"base64url"),q:Z(t[5],"base64url"),dp:Z(t[6],"base64url"),dq:Z(t[7],"base64url"),qi:Z(t[8],"base64url"),kty:"RSA"}}function rh(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new j("JWK was missing components");return He([me(Uint8Array.from([0])),me(ee(t.n,"base64url")),me(ee(t.e,"base64url")),me(ee(t.d,"base64url")),me(ee(t.p,"base64url")),me(ee(t.q,"base64url")),me(ee(t.dp,"base64url")),me(ee(t.dq,"base64url")),me(ee(t.qi,"base64url"))]).subarray()}function nh(t){let e=Te(t,{offset:0});return ls(e)}function ls(t){let e=Te(t[1],{offset:0});return{kty:"RSA",n:Z(e[0],"base64url"),e:Z(e[1],"base64url")}}function hs(t){if(t.n==null||t.e==null)throw new j("JWK was missing components");return He([eh,Kr(He([me(ee(t.n,"base64url")),me(ee(t.e,"base64url"))]))]).subarray()}function Ya(t){let e=Te(t);return ds(e)}function ds(t){let e=us(t);return ps(e)}function Ga(t,e){if(t.byteLength>=Ql)throw new wt("Key size is too large");let r=Te(t,{offset:0});return un(r,t,e)}function un(t,e,r){let n=ls(t);if(r==null){let o=Rt(rt.encode({Type:ue.RSA,Data:e}));r=Be(fs,o)}return new Zt(n,r)}function ps(t){if(Qa(t)>cs)throw new j("Key size is too large");let e=Wa(t),r=Rt(rt.encode({Type:ue.RSA,Data:hs(e.publicKey)})),n=Be(fs,r);return new Lr(e.privateKey,new Zt(e.publicKey,n))}async function Xa(t){if(t>cs)throw new j("Key size is too large");let e=await Ja(t),r=Rt(rt.encode({Type:ue.RSA,Data:hs(e.publicKey)})),n=Be(fs,r);return new Lr(e.privateKey,new Zt(e.publicKey,n))}function Wa(t){if(t==null)throw new j("Missing key parameter");return{privateKey:t,publicKey:{kty:t.kty,n:t.n,e:t.e}}}var ec="1.2.840.113549.1.1.1";async function Ja(t,e){let r=await xe.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await oh(r,e);return{privateKey:n[0],publicKey:n[1]}}async function $a(t,e,r){let n=await xe.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await xe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,Le(e instanceof Uint8Array?e:e.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Za(t,e,r,n){let o=await xe.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await xe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,Le(e),Le(r instanceof Uint8Array?r:r.subarray()));return n?.signal?.throwIfAborted(),s}async function oh(t,e){if(t.privateKey==null||t.publicKey==null)throw new j("Private and public key are required");let r=await Promise.all([xe.get().subtle.exportKey("jwk",t.privateKey),xe.get().subtle.exportKey("jwk",t.publicKey)]);return e?.signal?.throwIfAborted(),r}function Qa(t){if(t.kty!=="RSA")throw new j("invalid key type");if(t.n==null)throw new j("invalid key modulus");return ee(t.n,"base64url").length*8}var ln=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(Pr(e),ye(r,void 0,"key"),this.iHash=e.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(r.length>n?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ne(o)}update(e){return _t(this),this.iHash.update(e),this}digestInto(e){_t(this),Mr(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},tc=(()=>{let t=((e,r,n)=>new ln(e,r).update(n).digest());return t.create=(e,r)=>new ln(e,r),t})();var rc=(t,e)=>(t+(t>=0?e:-e)/nc)/e;function sh(t,e,r){Ut("scalar",t,Ce,r);let[[n,o],[s,i]]=e,a=rc(i*t,r),f=rc(-o*t,r),c=t-a*n-f*s,u=-a*o-f*i,l=c<Ce,y=u<Ce;l&&(c=-c),y&&(u=-u);let h=hr(Math.ceil(Ot(r)/2))+nt;if(c<Ce||c>=h||u<Ce||u>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:c,k2neg:y,k2:u}}function ys(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function ms(t,e){Se(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return we(r.lowS,"lowS"),we(r.prehash,"prehash"),r.format!==void 0&&ys(r.format),r}var bs=class extends Error{constructor(e=""){super(e)}},Ae={Err:bs,_tlv:{encode:(t,e)=>{let{Err:r}=Ae;if(Ee(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(typeof e!="string")throw new TypeError('"data" expected string, got type='+typeof e);if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=ur(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?ur(o.length/2|128):"";return ur(t)+s+o+e},decode(t,e){let{Err:r}=Ae;e=P(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],s=!!(o&128),i=0;if(!s)i=o;else{let f=o&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");let c=e.subarray(n,n+f);if(c.length!==f)throw new r("tlv.decode: length bytes not complete");if(c[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of c)i=i<<8|u;if(n+=f,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+i)}}},_int:{encode(t){let{Err:e}=Ae;if(Zr(t),t<Ce)throw new e("integer: negative integers are not allowed");let r=ur(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=Ae;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ct(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Ae,o=P(t,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:c,l:u}=n.decode(2,f);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(c)}},hexFromSig(t){let{_tlv:e,_int:r}=Ae,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),s=n+o;return e.encode(48,s)}};Object.freeze(Ae._tlv);Object.freeze(Ae._int);Object.freeze(Ae);var Ce=BigInt(0),nt=BigInt(1),nc=BigInt(2),hn=BigInt(3),ih=BigInt(4);function oc(t,e={}){let r=Wr("weierstrass",t,e),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;Se(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:c}=e;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=ic(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function y(N,d,x){if(c&&d.is0())return Uint8Array.of(0);let{x:A,y:E}=d.toAffine(),g=n.toBytes(A);if(we(x,"isCompressed"),x){l();let B=!n.isOdd(E);return te(sc(B),g)}else return te(Uint8Array.of(4),g,n.toBytes(E))}function h(N){P(N,void 0,"Point");let{publicKey:d,publicKeyUncompressed:x}=u,A=N.length,E=N[0],g=N.subarray(1);if(c&&A===1&&E===0)return{x:n.ZERO,y:n.ZERO};if(A===d&&(E===2||E===3)){let B=n.fromBytes(g);if(!n.isValid(B))throw new Error("bad point: is not on curve, wrong x");let _=m(B),D;try{D=n.sqrt(_)}catch(K){let M=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}l();let C=n.isOdd(D);return(E&1)===1!==C&&(D=n.neg(D)),{x:B,y:D}}else if(A===x&&E===4){let B=n.BYTES,_=n.fromBytes(g.subarray(0,B)),D=n.fromBytes(g.subarray(B,B*2));if(!b(_,D))throw new Error("bad point: is not on curve");return{x:_,y:D}}else throw new Error(`bad point: got length ${A}, expected compressed=${d} or uncompressed=${x}`)}let p=e.toBytes===void 0?y:e.toBytes,w=e.fromBytes===void 0?h:e.fromBytes;function m(N){let d=n.sqr(N),x=n.mul(d,N);return n.add(n.add(x,n.mul(N,s.a)),s.b)}function b(N,d){let x=n.sqr(d),A=m(N);return n.eql(x,A)}if(!b(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(s.a,hn),ih),v=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(S,v)))throw new Error("bad curve params: a or b");function T(N,d,x=!1){if(!n.isValid(d)||x&&n.is0(d))throw new Error(`bad point coordinate ${N}`);return d}function L(N){if(!(N instanceof I))throw new Error("Weierstrass Point expected")}function F(N){if(!f||!f.basises)throw new Error("no endo");return sh(N,f.basises,o.ORDER)}function R(N,d,x,A,E){return x=new I(n.mul(x.X,N),x.Y,x.Z),d=pr(A,d),x=pr(E,x),d.add(x)}class I{static BASE=new I(s.Gx,s.Gy,n.ONE);static ZERO=new I(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,x,A){this.X=T("x",d),this.Y=T("y",x,!0),this.Z=T("z",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(d){let{x,y:A}=d||{};if(!d||!n.isValid(x)||!n.isValid(A))throw new Error("invalid affine point");if(d instanceof I)throw new Error("projective point not allowed");return n.is0(x)&&n.is0(A)?I.ZERO:new I(x,A,n.ONE)}static fromBytes(d){let x=I.fromAffine(w(P(d,void 0,"point")));return x.assertValidity(),x}static fromHex(d){return I.fromBytes(Ft(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,x=!0){return V.createCache(this,d),x||this.multiply(hn),this}assertValidity(){let d=this;if(d.is0()){if(e.allowInfinityPoint&&n.is0(d.X)&&n.eql(d.Y,n.ONE)&&n.is0(d.Z))return;throw new Error("bad point: ZERO")}let{x,y:A}=d.toAffine();if(!n.isValid(x)||!n.isValid(A))throw new Error("bad point: x or y not field elements");if(!b(x,A))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){L(d);let{X:x,Y:A,Z:E}=this,{X:g,Y:B,Z:_}=d,D=n.eql(n.mul(x,_),n.mul(g,E)),C=n.eql(n.mul(A,_),n.mul(B,E));return D&&C}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:x}=s,A=n.mul(x,hn),{X:E,Y:g,Z:B}=this,_=n.ZERO,D=n.ZERO,C=n.ZERO,U=n.mul(E,E),K=n.mul(g,g),M=n.mul(B,B),k=n.mul(E,g);return k=n.add(k,k),C=n.mul(E,B),C=n.add(C,C),_=n.mul(d,C),D=n.mul(A,M),D=n.add(_,D),_=n.sub(K,D),D=n.add(K,D),D=n.mul(_,D),_=n.mul(k,_),C=n.mul(A,C),M=n.mul(d,M),k=n.sub(U,M),k=n.mul(d,k),k=n.add(k,C),C=n.add(U,U),U=n.add(C,U),U=n.add(U,M),U=n.mul(U,k),D=n.add(D,U),M=n.mul(g,B),M=n.add(M,M),U=n.mul(M,k),_=n.sub(_,U),C=n.mul(M,K),C=n.add(C,C),C=n.add(C,C),new I(_,D,C)}add(d){L(d);let{X:x,Y:A,Z:E}=this,{X:g,Y:B,Z:_}=d,D=n.ZERO,C=n.ZERO,U=n.ZERO,K=s.a,M=n.mul(s.b,hn),k=n.mul(x,g),Q=n.mul(A,B),re=n.mul(E,_),ne=n.add(x,A),X=n.add(g,B);ne=n.mul(ne,X),X=n.add(k,Q),ne=n.sub(ne,X),X=n.add(x,E);let de=n.add(g,_);return X=n.mul(X,de),de=n.add(k,re),X=n.sub(X,de),de=n.add(A,E),D=n.add(B,_),de=n.mul(de,D),D=n.add(Q,re),de=n.sub(de,D),U=n.mul(K,X),D=n.mul(M,re),U=n.add(D,U),D=n.sub(Q,U),U=n.add(Q,U),C=n.mul(D,U),Q=n.add(k,k),Q=n.add(Q,k),re=n.mul(K,re),X=n.mul(M,X),Q=n.add(Q,re),re=n.sub(k,re),re=n.mul(K,re),X=n.add(X,re),k=n.mul(Q,X),C=n.add(C,k),k=n.mul(de,X),D=n.mul(ne,D),D=n.sub(D,k),k=n.mul(ne,Q),U=n.mul(de,U),U=n.add(U,k),new I(D,C,U)}subtract(d){return L(d),this.add(d.negate())}is0(){return this.equals(I.ZERO)}multiply(d){let{endo:x}=e;if(!o.isValidNot0(d))throw new RangeError("invalid scalar: out of range");let A,E,g=B=>V.cached(this,B,_=>lt(I,_));if(x){let{k1neg:B,k1:_,k2neg:D,k2:C}=F(d),{p:U,f:K}=g(_),{p:M,f:k}=g(C);E=K.add(k),A=R(x.beta,U,M,B,D)}else{let{p:B,f:_}=g(d);A=B,E=_}return lt(I,[A,E])[0]}multiplyUnsafe(d){let{endo:x}=e,A=this,E=d;if(!o.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===Ce||A.is0())return I.ZERO;if(E===nt)return A;if(V.hasCache(this))return this.multiply(E);if(x){let{k1neg:g,k1:B,k2neg:_,k2:D}=F(E),{p1:C,p2:U}=Yi(I,A,B,D);return R(x.beta,C,U,g,_)}else return V.unsafe(A,E)}toAffine(d){let x=this,A=d,{X:E,Y:g,Z:B}=x;if(n.eql(B,n.ONE))return{x:E,y:g};let _=x.is0();A==null&&(A=_?n.ONE:n.inv(B));let D=n.mul(E,A),C=n.mul(g,A),U=n.mul(B,A);if(_)return{x:n.ZERO,y:n.ZERO};if(!n.eql(U,n.ONE))throw new Error("invZ was invalid");return{x:D,y:C}}isTorsionFree(){let{isTorsionFree:d}=e;return i===nt?!0:d?d(I,this):V.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:d}=e;return i===nt?this:d?d(I,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===nt?this.is0():this.clearCofactor().is0()}toBytes(d=!0){return we(d,"isCompressed"),this.assertValidity(),p(I,this,d)}toHex(d=!0){return Ct(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let O=o.BITS,V=new Kt(I,e.endo?Math.ceil(O/2):O);return O>=8&&I.BASE.precompute(8),Object.freeze(I.prototype),Object.freeze(I),I}function sc(t){return Uint8Array.of(t?2:3)}function ic(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function ah(t,e={}){let{Fn:r}=t,n=e.randomBytes===void 0?fr:e.randomBytes,o=Object.assign(ic(t.Fp,r),{seed:Math.max(po(r.ORDER),16)});function s(h){try{let p=r.fromBytes(h);return r.isValidNot0(p)}catch{return!1}}function i(h,p){let{publicKey:w,publicKeyUncompressed:m}=o;try{let b=h.length;return p===!0&&b!==w||p===!1&&b!==m?!1:!!t.fromBytes(h)}catch{return!1}}function a(h){return h=h===void 0?n(o.seed):h,mo(P(h,o.seed,"seed"),r.ORDER)}function f(h,p=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(p)}function c(h){let{secretKey:p,publicKey:w,publicKeyUncompressed:m}=o,b=r._lengths;if(!at(h))return;let S=P(h,void 0,"key").length,v=S===w||S===m,T=S===p||!!b?.includes(S);if(!(v&&T))return v}function u(h,p,w=!0){if(c(h)===!0)throw new Error("first arg must be private key");if(c(p)===!1)throw new Error("second arg must be public key");let m=r.fromBytes(h);return t.fromBytes(p).multiply(m).toBytes(w)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},y=Jr(a,f);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:y,Point:t,utils:l,lengths:o})}function ac(t,e,r={}){let n=e;Pr(n),Se(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?fr:r.randomBytes,s=r.hmac===void 0?(E,g)=>tc(n,E,g):r.hmac,{Fp:i,Fn:a}=t,{ORDER:f,BITS:c}=a,{keygen:u,getPublicKey:l,getSharedSecret:y,utils:h,lengths:p}=ah(t,r),w={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},m=f*nc+nt<i.ORDER;function b(E){let g=f>>nt;return E>g}function S(E,g){if(!a.isValidNot0(g))throw new Error(`invalid signature ${E}: out of range 1..Point.Fn.ORDER`);return g}function v(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function T(E,g){ys(g);let B=p.signature,_=g==="compact"?B:g==="recovered"?B+1:void 0;return P(E,_)}class L{r;s;recovery;constructor(g,B,_){if(this.r=S("r",g),this.s=S("s",B),_!=null){if(v(),![0,1,2,3].includes(_))throw new Error("invalid recovery id");this.recovery=_}Object.freeze(this)}static fromBytes(g,B=w.format){T(g,B);let _;if(B==="der"){let{r:K,s:M}=Ae.toSig(P(g));return new L(K,M)}B==="recovered"&&(_=g[0],B="compact",g=g.subarray(1));let D=p.signature/2,C=g.subarray(0,D),U=g.subarray(D,D*2);return new L(a.fromBytes(C),a.fromBytes(U),_)}static fromHex(g,B){return this.fromBytes(Ft(g),B)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new L(this.r,this.s,g)}recoverPublicKey(g){let{r:B,s:_}=this,D=this.assertRecovery(),C=D===2||D===3?B+f:B;if(!i.isValid(C))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let U=i.toBytes(C),K=t.fromBytes(te(sc((D&1)===0),U)),M=a.inv(C),k=R(P(g,void 0,"msgHash")),Q=a.create(-k*M),re=a.create(_*M),ne=t.BASE.multiplyUnsafe(Q).add(K.multiplyUnsafe(re));if(ne.is0())throw new Error("invalid recovery: point at infinify");return ne.assertValidity(),ne}hasHighS(){return b(this.s)}toBytes(g=w.format){if(ys(g),g==="der")return Ft(Ae.hexFromSig(this));let{r:B,s:_}=this,D=a.toBytes(B),C=a.toBytes(_);return g==="recovered"?(v(),te(Uint8Array.of(this.assertRecovery()),D,C)):te(D,C)}toHex(g){return Ct(this.toBytes(g))}}Object.freeze(L.prototype),Object.freeze(L);let F=r.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let B=ct(g),_=g.length*8-c;return _>0?B>>BigInt(_):B}:r.bits2int,R=r.bits2int_modN===void 0?function(g){return a.create(F(g))}:r.bits2int_modN,I=hr(c);function O(E){return Ut("num < 2^"+c,E,Ce,I),a.toBytes(E)}function V(E,g){return P(E,void 0,"message"),g?P(n(E),void 0,"prehashed message"):E}function N(E,g,B){let{lowS:_,prehash:D,extraEntropy:C}=ms(B,w);E=V(E,D);let U=R(E),K=a.fromBytes(g);if(!a.isValidNot0(K))throw new Error("invalid private key");let M=[O(K),O(U)];if(C!=null&&C!==!1){let ne=C===!0?o(p.secretKey):C;M.push(P(ne,void 0,"extraEntropy"))}let k=te(...M),Q=U;function re(ne){let X=F(ne);if(!a.isValidNot0(X))return;let de=a.inv(X),gt=t.BASE.multiply(X).toAffine(),Gt=a.create(gt.x);if(Gt===Ce)return;let Cr=a.create(de*a.create(Q+Gt*K));if(Cr===Ce)return;let Us=(gt.x===Gt?0:2)|Number(gt.y&nt),Os=Cr;return _&&b(Cr)&&(Os=a.neg(Cr),Us^=1),new L(Gt,Os,m?void 0:Us)}return{seed:k,k2sig:re}}function d(E,g,B={}){let{seed:_,k2sig:D}=N(E,g,B);return Ri(n.outputLen,a.BYTES,s)(_,D).toBytes(B.format)}function x(E,g,B,_={}){let{lowS:D,prehash:C,format:U}=ms(_,w);if(B=P(B,void 0,"publicKey"),g=V(g,C),!at(E)){let K=E instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}T(E,U);try{let K=L.fromBytes(E,U),M=t.fromBytes(B);if(D&&K.hasHighS())return!1;let{r:k,s:Q}=K,re=R(g),ne=a.inv(Q),X=a.create(re*ne),de=a.create(k*ne),gt=t.BASE.multiplyUnsafe(X).add(M.multiplyUnsafe(de));return gt.is0()?!1:a.create(gt.x)===k}catch{return!1}}function A(E,g,B={}){let{prehash:_}=ms(B,w);return g=V(g,_),L.fromBytes(E,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:y,utils:h,lengths:p,Point:t,sign:d,verify:x,recoverPublicKey:A,Signature:L,hash:n})}var gs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ch={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var cc=BigInt(2);function fh(t){let e=gs.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),f=BigInt(88),c=t*t*t%e,u=c*c*t%e,l=z(u,r,e)*u%e,y=z(l,r,e)*u%e,h=z(y,cc,e)*c%e,p=z(h,o,e)*h%e,w=z(p,s,e)*p%e,m=z(w,a,e)*w%e,b=z(m,f,e)*m%e,S=z(b,a,e)*w%e,v=z(S,r,e)*u%e,T=z(v,i,e)*p%e,L=z(T,n,e)*c%e,F=z(L,cc,e);if(!xs.eql(xs.sqr(F),t))throw new Error("Cannot find square root");return F}var xs=Nt(gs.p,{sqrt:fh}),uh=oc(gs,{Fp:xs,endo:ch}),Yt=ac(uh,Rt);var fc=33;function uc(t,e,r,n){let o=Nr.digest(r instanceof Uint8Array?r:r.subarray());if(tn(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Yt.verify(e,s,t,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new yr(String(s))});try{return n?.signal?.throwIfAborted(),Yt.verify(e,o.digest,t,{prehash:!1,format:"der"})}catch(s){throw new yr(String(s))}}var dn=class{type="secp256k1";raw;_key;constructor(e){this._key=hc(e),this.raw=lc(this._key)}toMultihash(){return Ie.digest(Dt(this))}toCID(){return ce.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}verify(e,r,n){return uc(this._key,r,e,n)}};function dc(t){return new dn(t)}function lc(t){return Yt.Point.fromBytes(t).toBytes()}function hc(t){try{return Yt.Point.fromBytes(t),t}catch(e){throw new wt(String(e))}}function pc(t){if(t.byteLength===Mt)return ia(t);if(t.byteLength===fc)return dc(t);let e=Te(t),r=e[1]?.[0];if(r===Js||r===Qs||r===ei)return di(e);if(e[0]?.[0]===ec)return un(e,t);throw new j("Could not extract public key from raw bytes")}function Dt(t){return rt.encode({Type:ue[t.type],Data:t.raw})}var mc=Symbol.for("nodejs.util.inspect.custom"),lh=114,Dr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[wn]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ce.createV1(lh,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return pe(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return pe(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[mc](){return`PeerId(${this.toString()})`}},pn=class extends Dr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},mn=class extends Dr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},yn=class extends Dr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},hh=2336,ws=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ie.digest(ee(this.url))}[mc](){return`PeerId(${this.url})`}[wn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ce.createV1(hh,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=Z(e)),e.toString()===this.toString())}};function yc(t){if(t.type==="Ed25519")return new mn({multihash:t.toCID().multihash,publicKey:t});if(t.type==="secp256k1")return new yn({multihash:t.toCID().multihash,publicKey:t});if(t.type==="RSA")return new pn({multihash:t.toCID().multihash,publicKey:t});throw new Wt}var Es=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},bc=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function Ss(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout},signal:i}=e,a,f,u=new Promise((l,y)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(i?.aborted){y(bc(i));return}if(i&&(f=()=>{y(bc(i))},i.addEventListener("abort",f,{once:!0})),t.then(l,y),r===Number.POSITIVE_INFINITY)return;let h=new Es;a=s.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(p){y(p)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?l():o instanceof Error?y(o):(h.message=o??`Promise timed out after ${r} milliseconds`,y(h))},r)}).finally(()=>{u.clear(),f&&i&&i.removeEventListener("abort",f)});return u.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},u}var dh=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function ph(t,e,r){let n,o=new Promise((s,i)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),f=[],{addListener:c,removeListener:u}=dh(t),l=async(...h)=>{let p=r.multiArgs?h:h[0];if(r.filter)try{if(!await r.filter(p))return}catch(w){n(),i(w);return}f.push(p),r.count===f.length&&(n(),s(f))},y=(...h)=>{n(),i(r.rejectionMultiArgs?h:h[0])};n=()=>{for(let h of a)u(h,l);for(let h of r.rejectionEvents)a.includes(h)||u(h,y)};for(let h of a)c(h,l);for(let h of r.rejectionEvents)a.includes(h)||c(h,y);r.signal&&r.signal.addEventListener("abort",()=>{y(r.signal.reason)},{once:!0}),r.resolveImmediately&&s(f)});if(o.cancel=n,typeof r.timeout=="number"){let s=Ss(o,{milliseconds:r.timeout});return s.cancel=()=>{n(),s.clear()},s}return o}function xc(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=ph(t,e,r),o=n.then(s=>s[0]);return o.cancel=n.cancel,o}var xt=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"};function mh(t){return t.reason}async function vs(t,e,r){if(e==null)return t;let n=r?.translateError??mh;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((s,i)=>{o=()=>{i(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}function gc(t=0){return new Uint8Array(t)}var yh=Math.pow(2,7),bh=Math.pow(2,14),xh=Math.pow(2,21),As=Math.pow(2,28),Bs=Math.pow(2,35),Is=Math.pow(2,42),Ls=Math.pow(2,49),q=128,le=127;function _r(t){if(t<yh)return 1;if(t<bh)return 2;if(t<xh)return 3;if(t<As)return 4;if(t<Bs)return 5;if(t<Is)return 6;if(t<Ls)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function gh(t,e,r=0){switch(_r(t)){case 8:e[r++]=t&255|q,t/=128;case 7:e[r++]=t&255|q,t/=128;case 6:e[r++]=t&255|q,t/=128;case 5:e[r++]=t&255|q,t/=128;case 4:e[r++]=t&255|q,t>>>=7;case 3:e[r++]=t&255|q,t>>>=7;case 2:e[r++]=t&255|q,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function wh(t,e,r=0){switch(_r(t)){case 8:e.set(r++,t&255|q),t/=128;case 7:e.set(r++,t&255|q),t/=128;case 6:e.set(r++,t&255|q),t/=128;case 5:e.set(r++,t&255|q),t/=128;case 4:e.set(r++,t&255|q),t>>>=7;case 3:e.set(r++,t&255|q),t>>>=7;case 2:e.set(r++,t&255|q),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function Eh(t,e){let r=t[e],n=0;if(n+=r&le,r<q||(r=t[e+1],n+=(r&le)<<7,r<q)||(r=t[e+2],n+=(r&le)<<14,r<q)||(r=t[e+3],n+=(r&le)<<21,r<q)||(r=t[e+4],n+=(r&le)*As,r<q)||(r=t[e+5],n+=(r&le)*Bs,r<q)||(r=t[e+6],n+=(r&le)*Is,r<q)||(r=t[e+7],n+=(r&le)*Ls,r<q))return n;throw new RangeError("Could not decode varint")}function Sh(t,e){let r=t.get(e),n=0;if(n+=r&le,r<q||(r=t.get(e+1),n+=(r&le)<<7,r<q)||(r=t.get(e+2),n+=(r&le)<<14,r<q)||(r=t.get(e+3),n+=(r&le)<<21,r<q)||(r=t.get(e+4),n+=(r&le)*As,r<q)||(r=t.get(e+5),n+=(r&le)*Bs,r<q)||(r=t.get(e+6),n+=(r&le)*Is,r<q)||(r=t.get(e+7),n+=(r&le)*Ls,r<q))return n;throw new RangeError("Could not decode varint")}function wc(t,e,r=0){return e==null&&(e=gc(_r(t))),e instanceof Uint8Array?gh(t,e,r):wh(t,e,r)}function Ec(t,e=0){return t instanceof Uint8Array?Eh(t,e):Sh(t,e)}var Bh=4194304,bn=class extends Error{static name="UnwrappedError";name="UnwrappedError"},Ds=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},_s=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Rs=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Ih(t){return typeof t?.closeRead=="function"}function Lh(t){return typeof t?.close=="function"}function Ts(t){return Ih(t)?t.remoteWriteStatus!=="writable"&&t.readBufferLength===0:Lh(t)?t.status!=="open":!1}function Th(t){return t?.addEventListener!=null&&t?.removeEventListener!=null&&t?.send!=null&&t?.push!=null&&t?.log!=null}function Dh(t,e){let r=e?.maxBufferSize??Bh,n=new oe,o,s=!1;if(!Th(t))throw new j("Argument should be a Stream or a Multiaddr");let i=u=>{if(n.append(u.data),n.byteLength>r){let l=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${l} > ${r}`))}o?.resolve()};t.addEventListener("message",i);let a=u=>{u.error!=null?o?.reject(u.error):o?.resolve()};t.addEventListener("close",a);let f=()=>{o?.resolve()};t.addEventListener("remoteCloseWrite",f);let c={readBuffer:n,async read(u){if(s===!0)throw new bn("Stream was unwrapped");if(Ts(t)){if(n.byteLength===0&&u?.bytes==null)return null;if(u?.bytes!=null&&n.byteLength<u.bytes)throw t.log.error("closed after reading %d/%d bytes",n.byteLength,u.bytes),new xt(`Unexpected EOF - stream closed after reading ${n.byteLength}/${u.bytes} bytes`)}let l=u?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=l){o.resolve();break}if(await vs(o.promise,u?.signal),Ts(t)){if(n.byteLength===0&&u?.bytes==null)return null;break}o=Promise.withResolvers()}let y=u?.bytes??n.byteLength;if(n.byteLength<y){if(Ts(t))throw t.log.error("closed while reading %d/%d bytes",n.byteLength,y),new xt(`Unexpected EOF - stream closed while reading ${n.byteLength}/${y} bytes`);return c.read(u)}let h=n.sublist(0,y);return n.consume(y),h},async write(u,l){if(s===!0)throw new bn("Stream was unwrapped");t.send(u)||await xc(t,"drain",{signal:l?.signal,rejectionEvents:["close"]})},unwrap(){return s||(s=!0,t.removeEventListener("message",i),t.removeEventListener("close",a),t.removeEventListener("remoteCloseWrite",f),n.byteLength>0&&(t.log("stream unwrapped with %d unread bytes",n.byteLength),t.unshift(n))),t}};return c}function _h(t,e={}){let r=Dh(t,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=_r(e.maxDataLength));let n=e?.lengthDecoder??Ec,o=e?.lengthEncoder??wc;return{async read(i){let a=-1,f=new oe;for(;;){let u=await r.read({...i,bytes:1});if(u==null)break;f.append(u);try{a=n(f)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new Ds("Invalid message length");if(e?.maxLengthLength!=null&&f.byteLength>e.maxLengthLength)throw new Rs(`Message length length too long - ${f.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new _s(`Message length too long - ${a} > ${e.maxDataLength}`);let c=await r.read({...i,bytes:a});if(c==null)throw t.log.error("tried to read %d bytes but the stream closed",a),new xt(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(c.byteLength!==a)throw t.log.error("read %d/%d bytes before the stream closed",c.byteLength,a),new xt(`Unexpected EOF - read ${c.byteLength}/${a} bytes before the stream closed`);return c},async write(i,a){await r.write(new oe(o(i.byteLength),i),a)},async writeV(i,a){let f=new oe(...i.flatMap(c=>[o(c.byteLength),c]));await r.write(f,a)},unwrap(){return r.unwrap()}}}function Sc(t,e){let r=_h(t,e),n={read:async(o,s)=>{let i=await r.read(s);return o.decode(i)},write:async(o,s,i)=>{await r.write(s.encode(o),i)},writeV:async(o,s,i)=>{await r.writeV(o.map(a=>s.encode(a)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>r.unwrap()};return n}var xn;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.id!=null&&(i.uint32(10),i.bytes(s.id)),s.pubkey!=null&&(i.uint32(18),Rr.codec().encode(s.pubkey,i)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.id=s.bytes();break}case 2:{f.pubkey=Rr.codec().decode(s,s.uint32(),{limits:a.limits?.pubkey});break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.id`,value:s.bytes()};break}case 2:{yield*Rr.codec().stream(s,s.uint32(),`${a}.pubkey`,{limits:f.limits?.pubkey});break}default:{s.skipType(u&7);break}}}})),e);function r(s){return mt(s,t.codec())}t.encode=r;function n(s,i){return dt(s,t.codec(),i)}t.decode=n;function o(s,i){return yt(s,t.codec(),i)}t.stream=o})(xn||(xn={}));var qe;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(qe||(qe={}));var Cs;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(Cs||(Cs={}));(function(t){t.codec=()=>Ir(Cs)})(qe||(qe={}));var Rr;(function(t){let e;t.codec=()=>(e==null&&(e=bt((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),qe.codec().encode(s.Type,i)),s.Data!=null&&s.Data.byteLength>0&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let f={Data:fi(0)},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=qe.codec().decode(s);break}case 2:{f.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return f},function*(s,i,a,f={}){let c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:qe.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),e);function r(s){return mt(s,t.codec())}t.encode=r;function n(s,i){return dt(s,t.codec(),i)}t.decode=n;function o(s,i){return yt(s,t.codec(),i)}t.stream=o})(Rr||(Rr={}));var Rh="/plaintext/2.0.0",Fs=class{protocol=Rh;privateKey;log;constructor(e){this.privateKey=e.privateKey,this.log=e.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[Ns]=["@libp2p/connection-encryption"];async secureInbound(e,r){return this._encrypt(e,r)}async secureOutbound(e,r){return this._encrypt(e,r)}async _encrypt(e,r){let n=e.log?.newScope("plaintext")??this.log,o=Sc(e).pb(xn);n("write pubkey exchange to peer %p",r?.remotePeer);let s=this.privateKey.publicKey;await o.write({id:s.toMultihash().bytes,pubkey:{Type:qe[s.type],Data:s.raw}},r);let i=await o.read(r),a;try{if(i.pubkey==null)throw new Et("Public key missing");if(i.pubkey.Data.byteLength===0)throw new Et("Public key data too short");if(i.id==null)throw new Et("Remote id missing");let f=pc(i.pubkey.Data);if(a=yc(f),!pe(a.toMultihash().bytes,i.id))throw new Xt("Public key did not match id")}catch(f){throw n.error("invalid public key - %e",f),new Xt(`Invalid public key - ${f.message}`)}if(r?.remotePeer!=null&&!a.equals(r?.remotePeer))throw new Fr;return n("plaintext key exchange completed successfully with peer %p",a),{connection:o.unwrap().unwrap(),remotePeer:a}}};function Ch(){return t=>new Fs(t)}return Lc(Fh);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js: