@libp2p/plaintext 3.0.21-a34745c01 → 3.0.22

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:()=>Tc});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 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 ks(t){return new TextEncoder().encode(t)}function Ns(t){return new TextDecoder().decode(t)}function Ec(t){return t?.buffer instanceof ArrayBuffer}function rt(t){return Ec(t)?t:t.slice()}function Sc(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 vc=Sc,Ac=vc,Ms=Ac;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 Bc(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 Ic(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 Lc(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=Lc(n);return Et({prefix:e,name:t,encode(s){return Ic(s,n,r)},decode(s){return Bc(s,o,r,t)}})}var W=Ve({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tc=Ve({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var vn={};H(vn,{base32:()=>St,base32hex:()=>Cc,base32hexpad:()=>Oc,base32hexpadupper:()=>Fc,base32hexupper:()=>Uc,base32pad:()=>_c,base32padupper:()=>Rc,base32upper:()=>Dc,base32z:()=>Kc});var St=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dc=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_c=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Rc=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Cc=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uc=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Oc=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Fc=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kc=$({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 Nc=zs,Vs=128,Pc=127,Mc=~Pc,qc=Math.pow(2,31);function zs(t,e,r){e=e||[],r=r||0;for(var n=r;t>=qc;)e[r++]=t&255|Vs,t/=128;for(;t&Mc;)e[r++]=t&255|Vs,t>>>=7;return e[r]=t|0,zs.bytes=r-n+1,e}var Vc=Bn,Hc=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>=Hc);return Bn.bytes=s-n,r}var zc=Math.pow(2,7),jc=Math.pow(2,14),$c=Math.pow(2,21),Zc=Math.pow(2,28),Yc=Math.pow(2,35),Gc=Math.pow(2,42),Xc=Math.pow(2,49),Wc=Math.pow(2,56),Jc=Math.pow(2,63),Qc=function(t){return t<zc?1:t<jc?2:t<$c?3:t<Zc?4:t<Yc?5:t<Gc?6:t<Xc?7:t<Wc?8:t<Jc?9:10},ef={encode:Nc,decode:Vc,encodingLength:Qc},tf=ef,Jt=tf;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=rt(n),this.bytes=rt(o)}};function $s(t,e){let{bytes:r,version:n}=t;return n===0?nf(r,Ln(t),e??W.encoder):of(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=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!==er)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==sf)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[af]===!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]=rf(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 rf(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 nf(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 of(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,sf=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 af=Symbol.for("@ipld/js-cid/CID");var Tn={};H(Tn,{identity:()=>Be});var Gs=0,cf="identity",Xs=Ce;function ff(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:cf,encode:Xs,digest:ff};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 uf(t){return t.buffer instanceof ArrayBuffer}function Ie(t){return uf(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 _n={};H(_n,{base10:()=>lf});var lf=Ve({prefix:"9",name:"base10",alphabet:"0123456789"});var Rn={};H(Rn,{base16:()=>hf,base16upper:()=>df});var hf=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),df=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Cn={};H(Cn,{base2:()=>pf});var pf=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Un={};H(Un,{base256emoji:()=>gf});var oi=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}"),mf=oi.reduce((t,e,r)=>(t[r]=e,t),[]),bf=oi.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function yf(t){return t.reduce((e,r)=>(e+=mf[r],e),"")}function xf(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=bf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var gf=Et({prefix:"\u{1F680}",name:"base256emoji",encode:yf,decode:xf});var On={};H(On,{base64:()=>wf,base64pad:()=>Ef,base64url:()=>Sf,base64urlpad:()=>vf});var wf=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ef=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Sf=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vf=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fn={};H(Fn,{base8:()=>Af});var Af=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kn={};H(Kn,{identity:()=>Bf});var Bf=Et({prefix:"\0",name:"identity",encode:t=>Ns(t),decode:t=>ks(t)});var kd=new TextEncoder,Nd=new TextDecoder;var Pn={};H(Pn,{sha256:()=>Ur,sha512:()=>Df});var Tf=20;function Nn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new kn(t,e,r,n,o)}var kn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,s){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Tf,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?si(n,this.code,r?.truncate):n.then(o=>si(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function si(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 ai(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Ur=Nn({name:"sha2-256",code:18,encode:ai("SHA-256")}),Df=Nn({name:"sha2-512",code:19,encode:ai("SHA-512")});var Mn={...Kn,...Cn,...Fn,..._n,...Rn,...vn,...An,...Sn,...On,...Un},Xd={...Pn,...Tn};function ci(t=0){return new Uint8Array(t)}function qn(t=0){return new Uint8Array(t)}function ui(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var fi=ui("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Vn=ui("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=qn(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),_f={utf8:fi,"utf-8":fi,hex:Mn.base16,latin1:Vn,ascii:Vn,binary:Vn,...Mn},Or=_f;function ee(t,e="utf8"){let r=Or[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function Z(t,e="utf8"){let r=Or[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var Rf=parseInt("11111",2),Hn=parseInt("10000000",2),Cf=parseInt("01111111",2),li={0:rr,1:rr,2:Uf,3:Kf,4:kf,5:Ff,6:Of,16:rr,22:rr,48:rr};function Le(t,e={offset:0}){let r=t[e.offset]&Rf;if(e.offset++,li[r]!=null)return li[r](t,e);throw new Error("No decoder for tag "+r)}function nr(t,e){let r=0;if((t[e.offset]&Hn)===Hn){let n=t[e.offset]&Cf,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 rr(t,e){nr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Le(t,e);if(n===null)break;r.push(n)}return r}function Uf(t,e){let r=nr(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 Of(t,e){let r=nr(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 Ff(t,e){return e.offset++,null}function Kf(t,e){let r=nr(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 kf(t,e){let r=nr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function Nf(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=Nf(t.byteLength);return new oe(Uint8Array.from([e.byteLength|Hn]),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]),zn(e),e)}function Fr(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 Pf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Mf=Uint8Array.from([6,5,43,129,4,0,34]),qf=Uint8Array.from([6,5,43,129,4,0,35]),Vf={ext:!0,kty:"EC",crv:"P-256"},Hf={ext:!0,kty:"EC",crv:"P-384"},zf={ext:!0,kty:"EC",crv:"P-521"},jn=32,$n=48,Zn=66;function hi(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===jn*2+1)return n=Z(e.subarray(r,r+jn),"base64url"),o=Z(e.subarray(r+jn),"base64url"),new Lt({...Vf,key_ops:["verify"],x:n,y:o});if(e.byteLength===$n*2+1)return n=Z(e.subarray(r,r+$n),"base64url"),o=Z(e.subarray(r+$n),"base64url"),new Lt({...Hf,key_ops:["verify"],x:n,y:o});if(e.byteLength===Zn*2+1)return n=Z(e.subarray(r,r+Zn),"base64url"),o=Z(e.subarray(r+Zn),"base64url"),new Lt({...zf,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 He([pe(Uint8Array.from([1])),He([jf(t.crv)],160),He([Fr(new oe(Uint8Array.from([4]),ee(t.x??"","base64url"),ee(t.y??"","base64url")))],161)]).subarray()}function jf(t){if(t==="P-256")return Pf;if(t==="P-384")return Mf;if(t==="P-521")return qf;throw new j(`Invalid curve ${t}`)}var Lt=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(Tt(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 Yn(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 me(t,e,r=""){let n=Yn(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(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 Dt(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 kr(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 Fe(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Nr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function xe(t,e){return t<<32-e|t>>>e}var mi=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",$f=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Pr(t){if(me(t),mi)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=$f[t[r]];return e}var Oe={_0:48,_9:57,A:65,F:70,a:97,f:102};function pi(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 or(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(mi)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=pi(t.charCodeAt(s)),a=pi(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 Gn(...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 Xn(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 Wn=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function yi(t,e,r){return t&e^~t&r}function xi(t,e,r){return t&e^t&r^e&r}var sr=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=Nr(this.buffer)}update(e){Dt(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=Nr(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){Dt(this),kr(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Fe(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=Nr(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 Mr=BigInt(4294967295),gi=BigInt(32);function Zf(t,e=!1){return e?{h:Number(t&Mr),l:Number(t>>gi&Mr)}:{h:Number(t>>gi&Mr)|0,l:Number(t&Mr)|0}}function wi(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}=Zf(t[s],e);[n[s],o[s]]=[i,a]}return[n,o]}var Jn=(t,e,r)=>t>>>r,Qn=(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,ir=(t,e,r)=>t<<64-r|e>>>r-32,ar=(t,e,r)=>t>>>r-32|e<<64-r;function Te(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var Ei=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Si=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,vi=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Ai=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,Bi=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ii=(t,e,r,n,o,s)=>e+r+n+o+s+(t/2**32|0)|0;var Gf=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),eo=class extends sr{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 b=je[l-15],h=je[l-2],p=xe(b,7)^xe(b,18)^b>>>3,w=xe(h,17)^xe(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 b=xe(a,6)^xe(a,11)^xe(a,25),h=u+b+yi(a,f,c)+Gf[l]+je[l]|0,w=(xe(n,2)^xe(n,13)^xe(n,22))+xi(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(){Fe(je)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Fe(this.buffer)}},to=class extends eo{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 Li=wi(["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))),Xf=Li[0],Wf=Li[1],$e=new Uint32Array(80),Ze=new Uint32Array(80),ro=class extends sr{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)$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,U=nt(T,L,1)^nt(T,L,8)^Jn(T,L,7),R=ot(T,L,1)^ot(T,L,8)^Qn(T,L,7),I=$e[v-2]|0,F=Ze[v-2]|0,V=nt(I,F,19)^ir(I,F,61)^Jn(I,F,6),K=ot(I,F,19)^ar(I,F,61)^Qn(I,F,6),d=vi(R,K,Ze[v-7],Ze[v-16]),x=Ai(d,U,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: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)^ir(l,b,41),L=ot(l,b,14)^ot(l,b,18)^ar(l,b,41),U=l&h^~l&w,R=b&p^~b&m,I=Bi(S,L,R,Wf[v],Ze[v]),F=Ii(I,y,T,U,Xf[v],$e[v]),V=I|0,K=nt(n,o,28)^ir(n,o,34)^ir(n,o,39),d=ot(n,o,28)^ar(n,o,34)^ar(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}=Te(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=Ei(V,d,A);n=Si(E,F,K,x),o=E|0}({h:n,l:o}=Te(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Te(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:f}=Te(this.Ch|0,this.Cl|0,a|0,f|0),{h:c,l:u}=Te(this.Dh|0,this.Dl|0,c|0,u|0),{h:l,l:b}=Te(this.Eh|0,this.El|0,l|0,b|0),{h,l:p}=Te(this.Fh|0,this.Fl|0,h|0,p|0),{h:w,l:m}=Te(this.Gh|0,this.Gl|0,w|0,m|0),{h:y,l:S}=Te(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(){Fe($e,Ze)}destroy(){this.destroyed=!0,Fe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},no=class extends ro{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 _t=Xn(()=>new to,Wn(1));var qr=Xn(()=>new no,Wn(3));var P=(t,e,r)=>me(t,e,r),so=ze,Rt=Pr,te=(...t)=>Gn(...t),Ct=t=>or(t),st=Yn,cr=t=>bi(t),Hr=BigInt(0),oo=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 zr(t){if(typeof t=="bigint"){if(!Vr(t))throw new RangeError("positive bigint expected, got "+t)}else so(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 fr(t){let e=zr(t).toString(16);return e.length&1?"0"+e:e}function Ti(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Hr:BigInt("0x"+t)}function it(t){return Ti(Pr(t))}function De(t){return Ti(Pr(ur(me(t)).reverse()))}function jr(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 or(r.padStart(e*2,"0"))}function io(t,e){return jr(t,e).reverse()}function Di(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 ur(t){return Uint8Array.from(P(t))}function $r(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 Vr=t=>typeof t=="bigint"&&Hr<=t;function Jf(t,e,r){return Vr(t)&&Vr(e)&&Vr(r)&&e<=t&&t<r}function Ut(t,e,r,n){if(!Jf(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Ot(t){if(t<Hr)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>Hr;t>>=oo,e+=1);return e}var lr=t=>(oo<<BigInt(t))-oo;function _i(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},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 ao=()=>{throw new Error("not implemented")};var ae=BigInt(0),Y=BigInt(1),at=BigInt(2),Oi=BigInt(3),Fi=BigInt(4),Ki=BigInt(5),Qf=BigInt(7),ki=BigInt(8),eu=BigInt(9),Ni=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 Ri(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,b=s-a*c;n=r,r=u,o=i,s=a,i=l,a=b}if(n!==Y)throw new Error("invert: does not exist");return J(o,e)}function co(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Pi(t,e){let r=t,n=(r.ORDER+Y)/Fi,o=r.pow(e,n);return co(r,o,e),o}function tu(t,e){let r=t,n=(r.ORDER-Ki)/ki,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 co(r,f,e),f}function ru(t){let e=Ft(t),r=Mi(t),n=r(e,e.neg(e.ONE)),o=r(e,n),s=r(e,e.neg(n)),i=(t+Qf)/Ni;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 co(c,y,f),y})}function Mi(t){if(t<Oi)throw new Error("sqrt is not defined for small field");let e=t-Y,r=0;for(;e%at===ae;)e/=at,r++;let n=at,o=Ft(t);for(;Ci(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Pi;let s=o.pow(n,e),i=(e+Y)/at;return function(f,c){let u=f;if(u.is0(c))return c;if(Ci(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=Y<<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 nu(t){return t%Fi===Oi?Pi:t%ki===Ki?tu:t%Ni===eu?ru(t):Mi(t)}var ke=(t,e)=>(J(t,e)&Y)===Y,ou=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ou.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<=Y)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function su(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 hr(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 Ci(t,e){let r=t,n=(r.ORDER-Y)/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 iu(t,e){if(e!==void 0&&so(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,Zr=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}=iu(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 su(this,e,r)}div(e,r){return J(e*Ri(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 Ri(e,this.ORDER)}sqrt(e){let r=Ui.get(this);return r||Ui.set(this,r=nu(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?io(e,this.BYTES):jr(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?De(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 hr(this,e)}cmov(e,r,n){return ge(n,"condition"),n?r:e}};Object.freeze(Zr.prototype);function Ft(t,e={}){return new Zr(t,e)}function qi(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 uo(t){let e=qi(t);return e+Math.ceil(e/2)}function lo(t,e,r=!1){P(t);let n=t.length,o=qi(e),s=Math.max(uo(e),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?De(t):it(t),a=J(i,e-Y)+Y;return r?io(a,o):jr(a,o)}var Kt=BigInt(0),ct=BigInt(1);function dr(t,e){let r=e.negate();return t?r:e}function ft(t,e){let r=hr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function ji(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function ho(t,e){ji(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,s=lr(t),i=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Vi(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 po=new WeakMap,$i=new WeakMap;function mo(t){return $i.get(t)||1}function Hi(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&ct&&(n=n.add(o)),o=o.double(),r>>=ct;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=ho(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=ho(e,this.bits);for(let a=0;a<i.windows;a++){let{nextN:f,offset:c,isZero:u,isNeg:l,isNegF:b,offsetF:h}=Vi(n,a,i);n=f,u?s=s.add(dr(b,r[h])):o=o.add(dr(l,r[c]))}return Hi(n),{p:o,f:s}}wNAFUnsafe(e,r,n,o=this.ZERO){let s=ho(e,this.bits);for(let i=0;i<s.windows&&n!==Kt;i++){let{nextN:a,offset:f,isZero:c,isNeg:u}=Vi(n,i,s);if(n=a,!c){let l=r[f];o=o.add(u?l.negate():l)}}return Hi(n),o}getPrecomputes(e,r,n){let o=po.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),po.set(r,o))),o}cached(e,r,n){let o=mo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let s=mo(e);return s===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,o)}createCache(e,r){ji(r,this.bits),$i.set(e,r),po.delete(e)}hasCache(e){return mo(e)!==1}};function Zi(t,e,r,n){let o=e,s=t.ZERO,i=t.ZERO;for(;r>Kt||n>Kt;)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 zi(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return fo(e),e}else return Ft(t,{isLE:r})}function Yr(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=zi(e.p,r.Fp,n),s=zi(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 Gr(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Ye=BigInt(0),se=BigInt(1),bo=BigInt(2),au=BigInt(8);function cu(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 Yi(t,e={}){let r=e,n=Yr("edwards",t,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;Ee(r,{},{uvRatio:"function"});let f=bo<<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(!cu(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function l(w,m,y=!1){let S=y?se:Ye;return Ut("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(Ye,se,se,Ye);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=ur(P(m,S,"point")),ge(y,"zip215");let L=ur(m),U=m[S-1];L[S-1]=U&-129;let R=De(L),I=y?f:o.ORDER;Ut("point.y",R,Ye,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===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,y=!1){return h.fromBytes(Ct(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(bo),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(bo*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===Ye?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?au:o.inv(L));let R=c(v*S),I=c(T*S),F=o.mul(L,S);if(U)return{x:Ye,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 Rt(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 Xr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){ao()}static fromHex(e){ao()}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 Rt(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 Gi(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?cr: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(De(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=De(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:Gr(I,y),getPublicKey:y,sign:v,verify:L,utils:K,Point:t,lengths:R})}function pr(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 fu(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 uu(t){if(!st(t)&&typeof t!="string")throw new Error("DST must be Uint8Array or ascii string");let e=typeof t=="string"?$r(t):t;if(e.length===0)throw new Error("DST must be non-empty");return e}function yo(t,e,r,n){P(t),we(r),e=uu(e),e.length>255&&(e=n(te($r("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,pr(e.length,1)),f=new Uint8Array(s),c=pr(r,2),u=new Array(i),l=n(te(f,t,c,pr(0,1),a));u[0]=n(te(l,pr(1,1),a));for(let h=1;h<i;h++){let p=[fu(l,u[h-1]),pr(h+1,1),a];u[h]=n(te(...p))}return te(...u).slice(0,r)}var Xi="HashToScalar-";var lu=BigInt(0),Ne=BigInt(1),Wi=BigInt(2);var hu=BigInt(5),du=BigInt(8),Nt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Eo={p:Nt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:du,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function pu(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Nt,a=t*t%s*t%s,f=z(a,Wi,s)*a%s,c=z(f,Ne,s)*t%s,u=z(c,hu,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,Wi,s)*t%s,b2:a}}function mu(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}var xo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function So(t,e){let r=Nt,n=J(e*e*e,r),o=J(n*n*e,r),s=pu(t*o).pow_p_5_8,i=J(t*n*s,r),a=J(e*i*i,r),f=i,c=J(i*xo,r),u=a===t,l=a===J(-t,r),b=a===J(-t*xo,r);return u&&(i=f),(l||b)&&(i=c),ke(i,r)&&(i=J(-i,r)),{isValid:u||l,value:i}}var Xe=Yi(Eo,{uvRatio:So}),Ge=Xe.Fp,ea=Xe.Fn;function bu(t){return Gi(Xe,qr,Object.assign({adjustScalarBytes:mu,zip215:!0},t))}var ta=bu({});var go=xo,yu=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),xu=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),gu=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),wu=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ji=t=>So(Ne,t),Eu=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),wo=t=>Ge.create(De(t)&Eu);function Qi(t){let{d:e}=Eo,r=Nt,n=y=>Ge.create(y),o=n(go*t*t),s=n((o+Ne)*gu),i=BigInt(-1),a=n((i-e*o)*n(o+e)),{isValid:f,value:c}=So(s,a),u=n(c*t);ke(u,r)||(u=n(-u)),f||(c=u),f||(i=o);let l=n(i*(o-Ne)*wu-a),b=c*c,h=n((c+c)*a),p=n(l*yu),w=n(Ne-b),m=n(Ne+b);return new Xe(n(h*m),n(w*p),n(p*m),n(h*w))}var We=class t extends Xr{static BASE=new t(Xe.BASE);static ZERO=new t(Xe.ZERO);static Fp=Ge;static Fn=ea;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){me(e,32);let{a:r,d:n}=Eo,o=Nt,s=T=>Ge.create(T),i=wo(e);if(!Di(Ge.toBytes(i),e)||ke(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),f=s(Ne+r*a),c=s(Ne-r*a),u=s(f*f),l=s(c*c),b=s(r*n*u-l),{isValid:h,value:p}=Ji(s(b*l)),w=s(p*c),m=s(p*w*b),y=s((i+i)*w);ke(y,o)&&(y=s(-y));let S=s(f*m),v=s(y*S);if(!h||ke(v,o)||S===lu)throw new Error("invalid ristretto255 encoding 2");return new t(new Xe(y,S,Ne,v))}static fromHex(e){return t.fromBytes(or(e))}toBytes(){let{X:e,Y:r,Z:n,T:o}=this.ep,s=Nt,i=m=>Ge.create(m),a=i(i(n+r)*i(n-r)),f=i(e*r),c=i(f*f),{value:u}=Ji(i(a*c)),l=i(u*a),b=i(u*f),h=i(l*b*o),p;if(ke(o*h,s)){let m=i(r*go),y=i(e*go);e=m,r=y,p=i(l*xu)}else p=b;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 Su=Object.freeze({Point:We,hashToCurve(t,e){let r=e?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":e.DST,n=yo(t,r,64,qr);return Su.deriveToCurve(n)},hashToScalar(t,e={DST:Xi}){let r=yo(t,e.DST,64,qr);return ea.create(De(r))},deriveToCurve(t){me(t,64);let e=wo(t.subarray(0,32)),r=Qi(e),n=wo(t.subarray(32,64)),o=Qi(n);return new We(r.add(o))}});var mr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Wr=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 Wr("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 Pt=32;var vo,vu=(async()=>{try{return await ye.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Au(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 Bu(t,e,r){return ta.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}async function ra(t,e,r){return vo==null&&(vo=await vu),vo?Au(t,e,r):Bu(t,e,r)}function Jr(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Qr=class{type="Ed25519";raw;constructor(e){this.raw=Ao(e,Pt)}toMultihash(){return Be.digest(Tt(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=ra(this.raw,r,e);return Jr(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function sa(t){return t=Ao(t,Pt),new Qr(t)}function Ao(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 ia(t=0){return new Uint8Array(t)}var Iu=Math.pow(2,7),Lu=Math.pow(2,14),Tu=Math.pow(2,21),Bo=Math.pow(2,28),Io=Math.pow(2,35),Lo=Math.pow(2,42),To=Math.pow(2,49),q=128,fe=127;function Pe(t){if(t<Iu)return 1;if(t<Lu)return 2;if(t<Tu)return 3;if(t<Bo)return 4;if(t<Io)return 5;if(t<Lo)return 6;if(t<To)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Do(t,e,r=0){switch(Pe(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 Du(t,e,r=0){switch(Pe(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 _o(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)*Bo,r<q)||(r=t[e+5],n+=(r&fe)*Io,r<q)||(r=t[e+6],n+=(r&fe)*Lo,r<q)||(r=t[e+7],n+=(r&fe)*To,r<q))return n;throw new RangeError("Could not decode varint")}function _u(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)*Bo,r<q)||(r=t.get(e+5),n+=(r&fe)*Io,r<q)||(r=t.get(e+6),n+=(r&fe)*Lo,r<q)||(r=t.get(e+7),n+=(r&fe)*To,r<q))return n;throw new RangeError("Could not decode varint")}function aa(t,e,r=0){return e==null&&(e=ia(Pe(t))),e instanceof Uint8Array?Do(t,e,r):Du(t,e,r)}function ca(t,e=0){return t instanceof Uint8Array?_o(t,e):_u(t,e)}var Ro=new Float32Array([-0]),Je=new Uint8Array(Ro.buffer);function fa(t,e,r){Ro[0]=t,e[r]=Je[0],e[r+1]=Je[1],e[r+2]=Je[2],e[r+3]=Je[3]}function ua(t,e){return Je[0]=t[e],Je[1]=t[e+1],Je[2]=t[e+2],Je[3]=t[e+3],Ro[0]}var Co=new Float64Array([-0]),ue=new Uint8Array(Co.buffer);function la(t,e,r){Co[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 ha(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],Co[0]}var Cu=BigInt(Number.MAX_SAFE_INTEGER),Uu=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<Cu&&e>Uu)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 pa(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 ma(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 Uo(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 en(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Oo=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 en(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Se(this,4);return en(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Se(this,4);let e=ua(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Se(this,4);let e=ha(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 ma(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=en(this.buf,this.pos+=4),r=en(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=_o(this.buf,this.pos);return this.pos+=Pe(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 br(t){return new Oo(t instanceof Uint8Array?t:t.subarray())}function lt(t,e,r){let n=br(t);return e.decode(n,void 0,r)}function ht(t=0){return new Uint8Array(t)}var Po={};H(Po,{base10:()=>Mu});var z0=new Uint8Array(0);function ya(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 xa(t){return new TextEncoder().encode(t)}function ga(t){return new TextDecoder().decode(t)}function Ou(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 Fu=Ou,Ku=Fu,Ea=Ku;var Fo=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")}},Ko=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 Sa(this,e)}},ko=class{decoders;constructor(e){this.decoders=e}or(e){return Sa(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 Sa(t,e){return new ko({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var No=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 Fo(e,r,n),this.decoder=new Ko(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Mt({name:t,prefix:e,encode:r,decode:n}){return new No(t,e,r,n)}function Qe({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ea(r,t);return Mt({prefix:e,name:t,encode:n,decode:s=>Me(o(s))})}function ku(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 Nu(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 Pu(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=Pu(n);return Mt({prefix:e,name:t,encode(s){return Nu(s,n,r)},decode(s){return ku(s,o,r,t)}})}var Mu=Qe({prefix:"9",name:"base10",alphabet:"0123456789"});var Mo={};H(Mo,{base16:()=>qu,base16upper:()=>Vu});var qu=G({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Vu=G({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qo={};H(qo,{base2:()=>Hu});var Hu=G({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vo={};H(Vo,{base256emoji:()=>Yu});var va=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}"),zu=va.reduce((t,e,r)=>(t[r]=e,t),[]),ju=va.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function $u(t){return t.reduce((e,r)=>(e+=zu[r],e),"")}function Zu(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=ju[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Yu=Mt({prefix:"\u{1F680}",name:"base256emoji",encode:$u,decode:Zu});var Ho={};H(Ho,{base32:()=>qt,base32hex:()=>Ju,base32hexpad:()=>el,base32hexpadupper:()=>tl,base32hexupper:()=>Qu,base32pad:()=>Xu,base32padupper:()=>Wu,base32upper:()=>Gu,base32z:()=>rl});var qt=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gu=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xu=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wu=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ju=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qu=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),el=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tl=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rl=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zo={};H(zo,{base36:()=>yr,base36upper:()=>nl});var yr=Qe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nl=Qe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jo={};H(jo,{base58btc:()=>_e,base58flickr:()=>ol});var _e=Qe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ol=Qe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $o={};H($o,{base64:()=>sl,base64pad:()=>il,base64url:()=>al,base64urlpad:()=>cl});var sl=G({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),il=G({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),al=G({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cl=G({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zo={};H(Zo,{base8:()=>fl});var fl=G({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Yo={};H(Yo,{identity:()=>ul});var ul=Mt({prefix:"\0",name:"identity",encode:t=>ga(t),decode:t=>xa(t)});var im=new TextEncoder,am=new TextDecoder;var Xo={};H(Xo,{identity:()=>Ul});var dl=Ia,Aa=128,pl=127,ml=~pl,bl=Math.pow(2,31);function Ia(t,e,r){e=e||[],r=r||0;for(var n=r;t>=bl;)e[r++]=t&255|Aa,t/=128;for(;t&ml;)e[r++]=t&255|Aa,t>>>=7;return e[r]=t|0,Ia.bytes=r-n+1,e}var yl=Go,xl=128,Ba=127;function Go(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw Go.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Ba)<<o:(i&Ba)*Math.pow(2,o),o+=7}while(i>=xl);return Go.bytes=s-n,r}var gl=Math.pow(2,7),wl=Math.pow(2,14),El=Math.pow(2,21),Sl=Math.pow(2,28),vl=Math.pow(2,35),Al=Math.pow(2,42),Bl=Math.pow(2,49),Il=Math.pow(2,56),Ll=Math.pow(2,63),Tl=function(t){return t<gl?1:t<wl?2:t<El?3:t<Sl?4:t<vl?5:t<Al?6:t<Bl?7:t<Il?8:t<Ll?9:10},Dl={encode:dl,decode:yl,encodingLength:Tl},_l=Dl,xr=_l;function gr(t,e=0){return[xr.decode(t,e),xr.decode.bytes]}function Vt(t,e,r=0){return xr.encode(t,e,r),e}function Ht(t){return xr.encodingLength(t)}function jt(t,e){let r=e.byteLength,n=Ht(t),o=n+Ht(r),s=new Uint8Array(o+r);return Vt(t,s,0),Vt(r,s,n),s.set(e,o),new zt(t,r,e,s)}function La(t){let e=Me(t),[r,n]=gr(e),[o,s]=gr(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new zt(r,o,i,e)}function Ta(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ya(t.bytes,r.bytes)}}var zt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var Da=0,Rl="identity",_a=Me;function Cl(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 jt(Da,_a(t))}var Ul={code:Da,name:Rl,encode:_a,digest:Cl};var Qo={};H(Qo,{sha256:()=>Fl,sha512:()=>Kl});var Ol=20;function Jo({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Wo(t,e,r,n,o)}var Wo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,s){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Ol,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?Ra(n,this.code,r?.truncate):n.then(o=>Ra(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ra(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 jt(e,t)}function Ua(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Fl=Jo({name:"sha2-256",code:18,encode:Ua("SHA-256")}),Kl=Jo({name:"sha2-512",code:19,encode:Ua("SHA-512")});function Oa(t,e){let{bytes:r,version:n}=t;return n===0?Nl(r,es(t),e??_e.encoder):Pl(r,es(t),e??qt.encoder)}var Fa=new WeakMap;function es(t){let e=Fa.get(t);if(e==null){let r=new Map;return Fa.set(t,r),r}return e}var rn=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!==Ml)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=jt(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&&Ta(e.multihash,n.multihash)}toString(e){return Oa(this,e)}toJSON(){return{"/":Oa(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??Ka(n,o,s.bytes))}else if(r[ql]===!0){let{version:n,multihash:o,code:s}=r,i=La(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=Ka(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=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 zt(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]=gr(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]=kl(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 es(s).set(n,e),s}};function kl(t,e){switch(t[0]){case"Q":{let r=e??_e;return[_e.prefix,r.decode(`${_e.prefix}${t}`)]}case _e.prefix:{let r=e??_e;return[_e.prefix,r.decode(t)]}case qt.prefix:{let r=e??qt;return[qt.prefix,r.decode(t)]}case yr.prefix:{let r=e??yr;return[yr.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 Nl(t,e,r){let{prefix:n}=r;if(n!==_e.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 Pl(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,Ml=18;function Ka(t,e,r){let n=Ht(t),o=n+Ht(e),s=new Uint8Array(o+r.byteLength);return Vt(t,s,0),Vt(e,s,n),s.set(r,o),s}var ql=Symbol.for("@ipld/js-cid/CID");var ts={...Yo,...qo,...Zo,...Po,...Mo,...Ho,...zo,...jo,...$o,...Vo},Dm={...Qo,...Xo};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(Do,Pe(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(fa,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=pa(e);return r!==0?this.uint32(r)._push(Uo,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?Uo(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=br(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=Le(t);return ds(e)}function ds(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 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 He([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=Le(t,{offset:0});return ps(e)}function ps(t){let e=Le(t[1],{offset:0});return{kty:"RSA",n:Z(e[0],"base64url"),e:Z(e[1],"base64url")}}function ms(t){if(t.n==null||t.e==null)throw new j("JWK was missing components");return He([Xl,Fr(He([pe(ee(t.n,"base64url")),pe(ee(t.e,"base64url"))]))]).subarray()}function za(t){let e=Le(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=Le(t,{offset:0});return an(r,t,e)}function an(t,e,r){let n=ps(t);if(r==null){let o=_t(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=_t(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=_t(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),Fe(o)}update(e){return Dt(this),this.iHash.update(e),this}digestInto(e){Dt(this),kr(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){Ut("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=lr(Math.ceil(Ot(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=fr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?fr(o.length/2|128):"";return fr(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(zr(t),t<Re)throw new e("integer: negative integers are not allowed");let r=fr(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=Yr("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=dr(A,d),x=dr(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(Ct(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}=Zi(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 Rt(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let F=o.BITS,V=new kt(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?cr:e.randomBytes,o=Object.assign(rc(t.Fp,r),{seed:Math.max(uo(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,lo(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=Gr(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?cr: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(Ct(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 Ct(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 Rt(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=lr(c);function F(E){return Ut("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=Ft(Ss.p,{sqrt:sh}),ih=ec(Ss,{Fp:Es,endo:oh}),Zt=nc(ih,_t);var sc=33;function ic(t,e,r,n){let o=Ur.digest(r instanceof Uint8Array?r:r.subarray());if(Jr(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 mr(String(s))});try{return n?.signal?.throwIfAborted(),Zt.verify(e,o.digest,t,{prehash:!1,format:"der"})}catch(s){throw new mr(String(s))}}var un=class{type="secp256k1";raw;_key;constructor(e){this._key=cc(e),this.raw=ac(this._key)}toMultihash(){return Be.digest(Tt(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===Pt)return sa(t);if(t.byteLength===sc)return fc(t);let e=Le(t),r=e[1]?.[0];if(r===Ws||r===Js||r===Qs)return hi(e);if(e[0]?.[0]===Xa)return an(e,t);throw new j("Could not extract public key from raw bytes")}function Tt(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=Z(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=Pe(e.maxDataLength));let n=e?.lengthDecoder??ca,o=e?.lengthEncoder??aa;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:ci(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 Jr=Object.defineProperty;var na=Object.getOwnPropertyDescriptor;var oa=Object.getOwnPropertyNames;var sa=Object.prototype.hasOwnProperty;var ht=(e,t)=>{for(var r in t)Jr(e,r,{get:t[r],enumerable:!0})},ia=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oa(t))!sa.call(e,o)&&o!==r&&Jr(e,o,{get:()=>t[o],enumerable:!(n=na(t,o))||n.enumerable});return e};var aa=e=>ia(Jr({},"__esModule",{value:!0}),e);var tu={};ht(tu,{plaintext:()=>Qf});var pr=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},Ne=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},j=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},me=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var ye=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Me=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Qr=Symbol.for("@libp2p/peer-id");var $o=Symbol.for("@libp2p/service-capabilities");var on={};ht(on,{base58btc:()=>G,base58flickr:()=>ma});var _u=new Uint8Array(0);function Go(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Ct(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return Qt(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Qt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Xo(e){return new TextEncoder().encode(e)}function Wo(e){return new TextDecoder().decode(e)}function ca(e){return e?.buffer instanceof ArrayBuffer}function Qt(e){return ca(e)?e:e.slice()}function fa(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=e.length,f=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var E=0,p=0,w=0,v=b.length;w!==v&&b[w]===0;)w++,E++;for(var B=(v-w)*u+1>>>0,D=new Uint8Array(B);w!==v;){for(var _=b[w],F=0,C=B-1;(_!==0||F<p)&&C!==-1;C--,F++)_+=256*D[C]>>>0,D[C]=_%a>>>0,_=_/a>>>0;if(_!==0)throw new Error("Non-zero carry");p=F,w++}for(var L=B-p;L!==B&&D[L]===0;)L++;for(var K=f.repeat(E);L<B;++L)K+=e.charAt(D[L]);return K}function m(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var E=0;if(b[E]!==" "){for(var p=0,w=0;b[E]===f;)p++,E++;for(var v=(b.length-E)*c+1>>>0,B=new Uint8Array(v);b[E];){var D=r[b.charCodeAt(E)];if(D===255)return;for(var _=0,F=v-1;(D!==0||_<w)&&F!==-1;F--,_++)D+=a*B[F]>>>0,B[F]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");w=_,E++}if(b[E]!==" "){for(var C=v-w;C!==v&&B[C]===0;)C++;for(var L=new Uint8Array(p+(v-C)),K=p;C!==v;)L[K++]=B[C++];return L}}}function d(b){var E=m(b);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:m,decode:d}}var ua=fa,la=ua,Qo=la;var tn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},en=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ts(this,t)}},rn=class{decoders;constructor(t){this.decoders=t}or(t){return ts(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ts(e,t){return new rn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var nn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new tn(t,r,n),this.decoder=new en(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function be({name:e,prefix:t,encode:r,decode:n}){return new nn(e,t,r,n)}function Mt({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Qo(r,e);return be({prefix:t,name:e,encode:n,decode:s=>Ct(o(s))})}function ha(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,f=0;for(let c=0;c<o;++c){let u=t[e[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 da(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let f=0;f<e.length;++f)for(a=a<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function pa(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function z({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=pa(n);return be({prefix:t,name:e,encode(s){return da(s,n,r)},decode(s){return ha(s,o,r,e)}})}var G=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ma=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var sn={};ht(sn,{base32:()=>ge,base32hex:()=>xa,base32hexpad:()=>Ea,base32hexpadupper:()=>Sa,base32hexupper:()=>wa,base32pad:()=>ba,base32padupper:()=>ga,base32upper:()=>ya,base32z:()=>va});var ge=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ya=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ba=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ga=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xa=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wa=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ea=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sa=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),va=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var an={};ht(an,{base36:()=>qe,base36upper:()=>Aa});var qe=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Aa=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ba=ns,es=128,Ia=127,La=~Ia,Ta=Math.pow(2,31);function ns(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Ta;)t[r++]=e&255|es,e/=128;for(;e&La;)t[r++]=e&255|es,e>>>=7;return t[r]=e|0,ns.bytes=r-n+1,t}var _a=cn,Ra=128,rs=127;function cn(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw cn.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&rs)<<o:(i&rs)*Math.pow(2,o),o+=7}while(i>=Ra);return cn.bytes=s-n,r}var Da=Math.pow(2,7),Ca=Math.pow(2,14),Oa=Math.pow(2,21),Fa=Math.pow(2,28),Ka=Math.pow(2,35),ka=Math.pow(2,42),Ua=Math.pow(2,49),Pa=Math.pow(2,56),Na=Math.pow(2,63),Ma=function(e){return e<Da?1:e<Ca?2:e<Oa?3:e<Fa?4:e<Ka?5:e<ka?6:e<Ua?7:e<Pa?8:e<Na?9:10},qa={encode:Ba,decode:_a,encodingLength:Ma},Ha=qa,He=Ha;function Ve(e,t=0){return[He.decode(e,t),He.decode.bytes]}function xe(e,t,r=0){return He.encode(e,t,r),t}function we(e){return He.encodingLength(e)}function It(e,t){let r=t.byteLength,n=we(e),o=n+we(r),s=new Uint8Array(o+r);return xe(e,s,0),xe(r,s,n),s.set(t,o),new Ee(e,r,t,s)}function fn(e){let t=Ct(e),[r,n]=Ve(t),[o,s]=Ve(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ee(r,o,i,t)}function os(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Go(e.bytes,r.bytes)}}var Ee=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=Qt(n),this.bytes=Qt(o)}};function ss(e,t){let{bytes:r,version:n}=e;return n===0?ja(r,un(e),t??G.encoder):za(r,un(e),t??ge.encoder)}var is=new WeakMap;function un(e){let t=is.get(e);if(t==null){let r=new Map;return is.set(e,r),r}return t}var it=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=Qt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==je)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Za)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=It(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&os(t.multihash,n.multihash)}toString(t){return ss(this,t)}toJSON(){return{"/":ss(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??as(n,o,s.bytes))}else if(r[Ya]===!0){let{version:n,multihash:o,code:s}=r,i=fn(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==je)throw new Error(`Version 0 CID must use dag-pb (code: ${je}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=as(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,je,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Ct(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Ee(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,m]=Ve(t.subarray(r));return r+=m,l},o=n(),s=je;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(t,r){let[n,o]=Va(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return un(s).set(n,t),s}};function Va(e,t){switch(e[0]){case"Q":{let r=t??G;return[G.prefix,r.decode(`${G.prefix}${e}`)]}case G.prefix:{let r=t??G;return[G.prefix,r.decode(e)]}case ge.prefix:{let r=t??ge;return[ge.prefix,r.decode(e)]}case qe.prefix:{let r=t??qe;return[qe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function ja(e,t,r){let{prefix:n}=r;if(n!==G.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function za(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var je=112,Za=18;function as(e,t,r){let n=we(e),o=n+we(t),s=new Uint8Array(o+r.byteLength);return xe(e,s,0),xe(t,s,n),s.set(r,o),s}var Ya=Symbol.for("@ipld/js-cid/CID");var ln={};ht(ln,{identity:()=>Lt});var cs=0,$a="identity",fs=Ct;function Ga(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return It(cs,fs(e))}var Lt={code:cs,name:$a,encode:fs,digest:Ga};function at(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Xa(e){return e.buffer instanceof ArrayBuffer}function bt(e){return Xa(e)?e:e.slice()}var us="1.2.840.10045.3.1.7",ls="1.3.132.0.34",hs="1.3.132.0.35";async function ds(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,bt(t),bt(r.subarray()));return n?.signal?.throwIfAborted(),s}function xt(e=0){return new Uint8Array(e)}function dt(e=0){return new Uint8Array(e)}function Wa(e){return e?.buffer instanceof ArrayBuffer}function ps(e){if(Wa(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function yr(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=dt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return ps(r)}var ys=Symbol.for("@achingbrain/uint8arraylist");function ms(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function br(e){return!!e?.[ys]}var rt=class e{bufs;length;[ys]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(br(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(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(br(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ms(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ms(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(br(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return yr(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:yr(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,f=a+i.byteLength;if(o=f,t>=f)continue;let c=t>=a&&t<f,u=r>a&&r<=f;if(c&&u){if(t===a&&r===f){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(r-t)));break}if(c){if(t===0){n.push(i);continue}n.push(i.subarray(t-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-t}}indexOf(t,r=0){if(!br(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,f=this.byteLength-n.byteLength,c=n.byteLength-1,u;for(let l=r;l<=f;l+=u){u=0;for(let m=c;m>=0;m--){let d=this.get(l+m);if(n[m]!==d){u=Math.max(1,m-a[d]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=dt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!at(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var hn={};ht(hn,{base10:()=>Ja});var Ja=Mt({prefix:"9",name:"base10",alphabet:"0123456789"});var dn={};ht(dn,{base16:()=>Qa,base16upper:()=>tc});var Qa=z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tc=z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pn={};ht(pn,{base2:()=>ec});var ec=z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var mn={};ht(mn,{base256emoji:()=>ic});var bs=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}"),rc=bs.reduce((e,t,r)=>(e[r]=t,e),[]),nc=bs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function oc(e){return e.reduce((t,r)=>(t+=rc[r],t),"")}function sc(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=nc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var ic=be({prefix:"\u{1F680}",name:"base256emoji",encode:oc,decode:sc});var yn={};ht(yn,{base64:()=>ac,base64pad:()=>cc,base64url:()=>fc,base64urlpad:()=>uc});var ac=z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),cc=z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fc=z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),uc=z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var bn={};ht(bn,{base8:()=>lc});var lc=z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gn={};ht(gn,{identity:()=>hc});var hc=be({prefix:"\0",name:"identity",encode:e=>Wo(e),decode:e=>Xo(e)});var pl=new TextEncoder,ml=new TextDecoder;var En={};ht(En,{sha256:()=>gr,sha512:()=>yc});var mc=20;function wn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new xn(e,t,r,n,o)}var xn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??mc,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?gs(n,this.code,r?.truncate):n.then(o=>gs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function gs(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return It(t,e)}function ws(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var gr=wn({name:"sha2-256",code:18,encode:ws("SHA-256")}),yc=wn({name:"sha2-512",code:19,encode:ws("SHA-512")});var Sn={...gn,...pn,...bn,...hn,...dn,...sn,...an,...on,...yn,...mn},Ll={...En,...ln};function Ss(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Es=Ss("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),vn=Ss("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=dt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),bc={utf8:Es,"utf-8":Es,hex:Sn.base16,latin1:vn,ascii:vn,binary:vn,...Sn},xr=bc;function X(e,t="utf8"){let r=xr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Z(e,t="utf8"){let r=xr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var gc=parseInt("11111",2),An=parseInt("10000000",2),xc=parseInt("01111111",2),vs={0:ze,1:ze,2:wc,3:vc,4:Ac,5:Sc,6:Ec,16:ze,22:ze,48:ze};function Tt(e,t={offset:0}){let r=e[t.offset]&gc;if(t.offset++,vs[r]!=null)return vs[r](e,t);throw new Error("No decoder for tag "+r)}function Ze(e,t){let r=0;if((e[t.offset]&An)===An){let n=e[t.offset]&xc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function ze(e,t){Ze(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Tt(e,t);if(n===null)break;r.push(n)}return r}function wc(e,t){let r=Ze(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Ec(e,t){let r=Ze(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,f=[];for(;t.offset<n;){let c=e[t.offset];if(t.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 Sc(e,t){return t.offset++,null}function vc(e,t){let r=Ze(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Ac(e,t){let r=Ze(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Bc(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new rt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Bn(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Bc(e.byteLength);return new rt(Uint8Array.from([t.byteLength|An]),t)}function pt(e){let t=new rt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new rt(Uint8Array.from([2]),Bn(t),t)}function wr(e){let t=Uint8Array.from([0]),r=new rt(t,e);return new rt(Uint8Array.from([3]),Bn(r),r)}function qt(e,t=48){let r=new rt;for(let n of e)r.append(n);return new rt(Uint8Array.from([t]),Bn(r),r)}var Ic=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Lc=Uint8Array.from([6,5,43,129,4,0,34]),Tc=Uint8Array.from([6,5,43,129,4,0,35]),_c={ext:!0,kty:"EC",crv:"P-256"},Rc={ext:!0,kty:"EC",crv:"P-384"},Dc={ext:!0,kty:"EC",crv:"P-521"},In=32,Ln=48,Tn=66;function As(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===In*2+1)return n=Z(t.subarray(r,r+In),"base64url"),o=Z(t.subarray(r+In),"base64url"),new ve({..._c,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ln*2+1)return n=Z(t.subarray(r,r+Ln),"base64url"),o=Z(t.subarray(r+Ln),"base64url"),new ve({...Rc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Tn*2+1)return n=Z(t.subarray(r,r+Tn),"base64url"),o=Z(t.subarray(r+Tn),"base64url"),new ve({...Dc,key_ops:["verify"],x:n,y:o});throw new j(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Bs(e){return qt([pt(Uint8Array.from([1])),qt([Cc(e.crv)],160),qt([wr(new rt(Uint8Array.from([4]),X(e.x??"","base64url"),X(e.y??"","base64url")))],161)]).subarray()}function Cc(e){if(e==="P-256")return Ic;if(e==="P-384")return Lc;if(e==="P-521")return Tc;throw new j(`Invalid curve ${e}`)}var ve=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Bs(this.jwk)),this._raw}toMultihash(){return Lt.digest(Ae(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}async verify(t,r,n){return ds(this.jwk,r,t,n)}};function _n(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ht(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function mt(e,t,r=""){let n=_n(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,a=s?` of length ${t}`:"",f=n?`length=${o}`:`type=${typeof e}`,c=i+"expected Uint8Array"+a+", got "+f;throw n?new RangeError(c):new TypeError(c)}return e}function Er(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Ht(e.outputLen),Ht(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Be(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Sr(e,t){mt(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Ft(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function vr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function wt(e,t){return e<<32-t|e>>>t}var Ls=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Oc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ar(e){if(mt(e),Ls)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Oc[e[r]];return t}var Ot={_0:48,_9:57,A:65,F:70,a:97,f:102};function Is(e){if(e>=Ot._0&&e<=Ot._9)return e-Ot._0;if(e>=Ot.A&&e<=Ot.F)return e-(Ot.A-10);if(e>=Ot.a&&e<=Ot.f)return e-(Ot.a-10)}function Ye(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(Ls)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Is(e.charCodeAt(s)),a=Is(e.charCodeAt(s+1));if(i===void 0||a===void 0){let f=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+a}return n}function Rn(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];mt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Dn(e,t={}){let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Ts(e=32){Ht(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Cn=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function _s(e,t,r){return e&t^~e&r}function Rs(e,t,r){return e&t^e&r^t&r}var $e=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=vr(this.buffer)}update(t){Be(this),mt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let f=vr(t);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Be(this),Sr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ft(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=vr(t),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:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Kt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ot=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Br=BigInt(4294967295),Ds=BigInt(32);function Fc(e,t=!1){return t?{h:Number(e&Br),l:Number(e>>Ds&Br)}:{h:Number(e>>Ds&Br)|0,l:Number(e&Br)|0}}function Cs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Fc(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var On=(e,t,r)=>e>>>r,Fn=(e,t,r)=>e<<32-r|t>>>r,te=(e,t,r)=>e>>>r|t<<32-r,ee=(e,t,r)=>e<<32-r|t>>>r,Ge=(e,t,r)=>e<<64-r|t>>>r-32,Xe=(e,t,r)=>e>>>r-32|t<<64-r;function _t(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Os=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Fs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ks=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ks=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Us=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ps=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var kc=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]),Vt=new Uint32Array(64),Kn=class extends $e{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:f}=this;return[t,r,n,o,s,i,a,f]}set(t,r,n,o,s,i,a,f){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=f|0}process(t,r){for(let l=0;l<16;l++,r+=4)Vt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let m=Vt[l-15],d=Vt[l-2],b=wt(m,7)^wt(m,18)^m>>>3,E=wt(d,17)^wt(d,19)^d>>>10;Vt[l]=E+Vt[l-7]+b+Vt[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 m=wt(a,6)^wt(a,11)^wt(a,25),d=u+m+_s(a,f,c)+kc[l]+Vt[l]|0,E=(wt(n,2)^wt(n,13)^wt(n,22))+Rs(n,o,s)|0;u=c,c=f,f=a,a=i+d|0,i=s,s=o,o=n,n=d+E|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,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(){Ft(Vt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ft(this.buffer)}},kn=class extends Kn{A=Kt[0]|0;B=Kt[1]|0;C=Kt[2]|0;D=Kt[3]|0;E=Kt[4]|0;F=Kt[5]|0;G=Kt[6]|0;H=Kt[7]|0;constructor(){super(32)}};var Ns=Cs(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Uc=Ns[0],Pc=Ns[1],jt=new Uint32Array(80),zt=new Uint32Array(80),Un=class extends $e{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:f,Eh:c,El:u,Fh:l,Fl:m,Gh:d,Gl:b,Hh:E,Hl:p}=this;return[t,r,n,o,s,i,a,f,c,u,l,m,d,b,E,p]}set(t,r,n,o,s,i,a,f,c,u,l,m,d,b,E,p){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=f|0,this.Eh=c|0,this.El=u|0,this.Fh=l|0,this.Fl=m|0,this.Gh=d|0,this.Gl=b|0,this.Hh=E|0,this.Hl=p|0}process(t,r){for(let B=0;B<16;B++,r+=4)jt[B]=t.getUint32(r),zt[B]=t.getUint32(r+=4);for(let B=16;B<80;B++){let D=jt[B-15]|0,_=zt[B-15]|0,F=te(D,_,1)^te(D,_,8)^On(D,_,7),C=ee(D,_,1)^ee(D,_,8)^Fn(D,_,7),L=jt[B-2]|0,K=zt[B-2]|0,H=te(L,K,19)^Ge(L,K,61)^On(L,K,6),k=ee(L,K,19)^Xe(L,K,61)^Fn(L,K,6),h=Ks(C,k,zt[B-7],zt[B-16]),y=ks(h,F,H,jt[B-7],jt[B-16]);jt[B]=y|0,zt[B]=h|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:f,Dh:c,Dl:u,Eh:l,El:m,Fh:d,Fl:b,Gh:E,Gl:p,Hh:w,Hl:v}=this;for(let B=0;B<80;B++){let D=te(l,m,14)^te(l,m,18)^Ge(l,m,41),_=ee(l,m,14)^ee(l,m,18)^Xe(l,m,41),F=l&d^~l&E,C=m&b^~m&p,L=Us(v,_,C,Pc[B],zt[B]),K=Ps(L,w,D,F,Uc[B],jt[B]),H=L|0,k=te(n,o,28)^Ge(n,o,34)^Ge(n,o,39),h=ee(n,o,28)^Xe(n,o,34)^Xe(n,o,39),y=n&s^n&a^s&a,S=o&i^o&f^i&f;w=E|0,v=p|0,E=d|0,p=b|0,d=l|0,b=m|0,{h:l,l:m}=_t(c|0,u|0,K|0,H|0),c=a|0,u=f|0,a=s|0,f=i|0,s=n|0,i=o|0;let x=Os(H,h,S);n=Fs(x,K,k,y),o=x|0}({h:n,l:o}=_t(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=_t(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:f}=_t(this.Ch|0,this.Cl|0,a|0,f|0),{h:c,l:u}=_t(this.Dh|0,this.Dl|0,c|0,u|0),{h:l,l:m}=_t(this.Eh|0,this.El|0,l|0,m|0),{h:d,l:b}=_t(this.Fh|0,this.Fl|0,d|0,b|0),{h:E,l:p}=_t(this.Gh|0,this.Gl|0,E|0,p|0),{h:w,l:v}=_t(this.Hh|0,this.Hl|0,w|0,v|0),this.set(n,o,s,i,a,f,c,u,l,m,d,b,E,p,w,v)}roundClean(){Ft(jt,zt)}destroy(){this.destroyed=!0,Ft(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pn=class extends Un{Ah=ot[0]|0;Al=ot[1]|0;Bh=ot[2]|0;Bl=ot[3]|0;Ch=ot[4]|0;Cl=ot[5]|0;Dh=ot[6]|0;Dl=ot[7]|0;Eh=ot[8]|0;El=ot[9]|0;Fh=ot[10]|0;Fl=ot[11]|0;Gh=ot[12]|0;Gl=ot[13]|0;Hh=ot[14]|0;Hl=ot[15]|0;constructor(){super(64)}};var Ie=Dn(()=>new kn,Cn(1));var Ir=Dn(()=>new Pn,Cn(3));var N=(e,t,r)=>mt(e,t,r),Mn=Ht,Le=Ar,Q=(...e)=>Rn(...e),Te=e=>Ye(e),re=_n,We=e=>Ts(e),Tr=BigInt(0),Nn=BigInt(1);function Et(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function _r(e){if(typeof e=="bigint"){if(!Lr(e))throw new RangeError("positive bigint expected, got "+e)}else Mn(e);return e}function St(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function Je(e){let t=_r(e).toString(16);return t.length&1?"0"+t:t}function Ms(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Tr:BigInt("0x"+e)}function ne(e){return Ms(Ar(e))}function Rt(e){return Ms(Ar(Qe(mt(e)).reverse()))}function Rr(e,t){if(Ht(t),t===0)throw new RangeError("zero length");e=_r(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Ye(r.padStart(t*2,"0"))}function qn(e,t){return Rr(e,t).reverse()}function qs(e,t){if(e=N(e),t=N(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Qe(e){return Uint8Array.from(N(e))}function Dr(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var Lr=e=>typeof e=="bigint"&&Tr<=e;function Nc(e,t,r){return Lr(e)&&Lr(t)&&Lr(r)&&t<=e&&e<r}function _e(e,t,r,n){if(!Nc(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Re(e){if(e<Tr)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>Tr;e>>=Nn,t+=1);return t}var tr=e=>(Nn<<BigInt(e))-Nn;function Hs(e,t,r){if(Ht(e,"hashLen"),Ht(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=p=>new Uint8Array(p),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,f=n(e),c=n(e),u=0,l=()=>{f.fill(1),c.fill(0),u=0},m=(...p)=>r(c,Q(f,...p)),d=(p=o)=>{c=m(s,p),f=m(),p.length!==0&&(c=m(i,p),f=m())},b=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let p=0,w=[];for(;p<t;){f=m();let v=f.slice();w.push(v),p+=f.length}return Q(...w)};return(p,w)=>{l(),d(p);let v;for(;(v=w(b()))===void 0;)d();return l(),v}}function vt(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(s,i,a){if(!a&&i!=="function"&&!Object.hasOwn(e,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let f=e[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(t,!1),o(r,!0)}var Hn=()=>{throw new Error("not implemented")};var st=BigInt(0),Y=BigInt(1),oe=BigInt(2),Zs=BigInt(3),Ys=BigInt(4),$s=BigInt(5),Mc=BigInt(7),Gs=BigInt(8),qc=BigInt(9),Xs=BigInt(16);function W(e,t){if(t<=st)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=st?r:t+r}function V(e,t,r){if(t<st)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >st;)n*=n,n%=r;return n}function Vs(e,t){if(e===st)throw new Error("invert: expected non-zero number");if(t<=st)throw new Error("invert: expected positive modulus, got "+t);let r=W(e,t),n=t,o=st,s=Y,i=Y,a=st;for(;r!==st;){let c=n/r,u=n-r*c,l=o-i*c,m=s-a*c;n=r,r=u,o=i,s=a,i=l,a=m}if(n!==Y)throw new Error("invert: does not exist");return W(o,t)}function Vn(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function Ws(e,t){let r=e,n=(r.ORDER+Y)/Ys,o=r.pow(t,n);return Vn(r,o,t),o}function Hc(e,t){let r=e,n=(r.ORDER-$s)/Gs,o=r.mul(t,oe),s=r.pow(o,n),i=r.mul(t,s),a=r.mul(r.mul(i,oe),s),f=r.mul(i,r.sub(a,r.ONE));return Vn(r,f,t),f}function Vc(e){let t=De(e),r=Js(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+Mc)/Xs;return((a,f)=>{let c=a,u=c.pow(f,i),l=c.mul(u,n),m=c.mul(u,o),d=c.mul(u,s),b=c.eql(c.sqr(l),f),E=c.eql(c.sqr(m),f);u=c.cmov(u,l,b),l=c.cmov(d,m,E);let p=c.eql(c.sqr(l),f),w=c.cmov(u,l,p);return Vn(c,w,f),w})}function Js(e){if(e<Zs)throw new Error("sqrt is not defined for small field");let t=e-Y,r=0;for(;t%oe===st;)t/=oe,r++;let n=oe,o=De(e);for(;js(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ws;let s=o.pow(n,t),i=(t+Y)/oe;return function(f,c){let u=f;if(u.is0(c))return c;if(js(u,c)!==1)throw new Error("Cannot find square root");let l=r,m=u.mul(u.ONE,s),d=u.pow(c,t),b=u.pow(c,i);for(;!u.eql(d,u.ONE);){if(u.is0(d))return u.ZERO;let E=1,p=u.sqr(d);for(;!u.eql(p,u.ONE);)if(E++,p=u.sqr(p),E===l)throw new Error("Cannot find square root");let w=Y<<BigInt(l-E-1),v=u.pow(m,w);l=E,m=u.sqr(v),d=u.mul(d,m),b=u.mul(b,v)}return b}}function jc(e){return e%Ys===Zs?Ws:e%Gs===$s?Hc:e%Xs===qc?Vc(e):Js(e)}var kt=(e,t)=>(W(e,t)&Y)===Y,zc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function jn(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=zc.reduce((n,o)=>(n[o]="function",n),t);if(vt(e,r),St(e.BYTES,"BYTES"),St(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Y)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function Zc(e,t,r){let n=e;if(r<st)throw new Error("invalid exponent, negatives unsupported");if(r===st)return n.ONE;if(r===Y)return t;let o=n.ONE,s=t;for(;r>st;)r&Y&&(o=n.mul(o,s)),s=n.sqr(s),r>>=Y;return o}function er(e,t,r=!1){let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((a,f,c)=>n.is0(f)?a:(o[c]=a,n.mul(a,f)),n.ONE),i=n.inv(s);return t.reduceRight((a,f,c)=>n.is0(f)?a:(o[c]=n.mul(a,o[c]),n.mul(a,f)),i),o}function js(e,t){let r=e,n=(r.ORDER-Y)/oe,o=r.pow(t,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 Yc(e,t){if(t!==void 0&&Mn(t),e<=st)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Re(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var zs=new WeakMap,Cr=class{ORDER;BITS;BYTES;isLE;ZERO=st;ONE=Y;_lengths;_mod;constructor(t,r={}){if(t<=Y)throw new Error("invalid field: expected ORDER > 1, got "+t);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}=Yc(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return W(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return st<=t&&t<this.ORDER}is0(t){return t===st}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Y)===Y}neg(t){return W(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return W(t*t,this.ORDER)}add(t,r){return W(t+r,this.ORDER)}sub(t,r){return W(t-r,this.ORDER)}mul(t,r){return W(t*r,this.ORDER)}pow(t,r){return Zc(this,t,r)}div(t,r){return W(t*Vs(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Vs(t,this.ORDER)}sqrt(t){let r=zs.get(this);return r||zs.set(this,r=jc(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?qn(t,this.BYTES):Rr(t,this.BYTES)}fromBytes(t,r=!1){N(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let c=new Uint8Array(o);c.set(t,s?0:c.length-t.length),t=c}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let f=s?Rt(t):ne(t);if(a&&(f=W(f,i)),!r&&!this.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f}invertBatch(t){return er(this,t)}cmov(t,r,n){return Et(n,"condition"),n?r:t}};Object.freeze(Cr.prototype);function De(e,t={}){return new Cr(e,t)}function Qs(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Y)throw new Error("field order must be greater than 1");let t=Re(e-Y);return Math.ceil(t/8)}function zn(e){let t=Qs(e);return t+Math.ceil(t/2)}function Zn(e,t,r=!1){N(e);let n=e.length,o=Qs(t),s=Math.max(zn(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Rt(e):ne(e),a=W(i,t-Y)+Y;return r?qn(a,o):Rr(a,o)}var Ce=BigInt(0),se=BigInt(1);function rr(e,t){let r=t.negate();return e?r:t}function ie(e,t){let r=er(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function ni(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Yn(e,t){ni(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=tr(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ti(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,a=Number(e&o),f=e>>i;a>n&&(a-=s,f+=se);let c=t*n,u=c+Math.abs(a)-1,l=a===0,m=a<0,d=t%2!==0;return{nextN:f,offset:u,isZero:l,isNeg:m,isNegF:d,offsetF:c}}var $n=new WeakMap,oi=new WeakMap;function Gn(e){return oi.get(e)||1}function ei(e){if(e!==Ce)throw new Error("invalid wNAF")}var Oe=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Ce;)r&se&&(n=n.add(o)),o=o.double(),r>>=se;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Yn(r,this.bits),s=[],i=t,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(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=Yn(t,this.bits);for(let a=0;a<i.windows;a++){let{nextN:f,offset:c,isZero:u,isNeg:l,isNegF:m,offsetF:d}=ti(n,a,i);n=f,u?s=s.add(rr(m,r[d])):o=o.add(rr(l,r[c]))}return ei(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=Yn(t,this.bits);for(let i=0;i<s.windows&&n!==Ce;i++){let{nextN:a,offset:f,isZero:c,isNeg:u}=ti(n,i,s);if(n=a,!c){let l=r[f];o=o.add(u?l.negate():l)}}return ei(n),o}getPrecomputes(t,r,n){let o=$n.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),$n.set(r,o))),o}cached(t,r,n){let o=Gn(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=Gn(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){ni(r,this.bits),oi.set(t,r),$n.delete(t)}hasCache(t){return Gn(t)!==1}};function si(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>Ce||n>Ce;)r&se&&(s=s.add(o)),n&se&&(i=i.add(o)),o=o.double(),r>>=se,n>>=se;return{p1:s,p2:i}}function ri(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return jn(t),t}else return De(e,{isLE:r})}function Or(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let f of["p","n","h"]){let c=t[f];if(!(typeof c=="bigint"&&c>Ce))throw new Error(`CURVE.${f} must be positive bigint`)}let o=ri(t.p,r.Fp,n),s=ri(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let f of a)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Fr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Zt=BigInt(0),nt=BigInt(1),Xn=BigInt(2),$c=BigInt(8);function Gc(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function ii(e,t={}){let r=t,n=Or("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;vt(r,{},{uvRatio:"function"});let f=Xn<<BigInt(s.BYTES*8)-nt,c=E=>o.create(E),u=r.uvRatio===void 0?(E,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(E,p))}}catch{return{isValid:!1,value:Zt}}}:r.uvRatio;if(!Gc(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function l(E,p,w=!1){let v=w?nt:Zt;return _e("coordinate "+E,p,v,f),p}function m(E){if(!(E instanceof d))throw new Error("EdwardsPoint expected")}class d{static BASE=new d(i.Gx,i.Gy,nt,c(i.Gx*i.Gy));static ZERO=new d(Zt,nt,nt,Zt);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,w,v,B){this.X=l("x",p),this.Y=l("y",w),this.Z=l("z",v,!0),this.T=l("t",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){if(p instanceof d)throw new Error("extended point not allowed");let{x:w,y:v}=p||{};return l("x",w),l("y",v),new d(w,v,nt,c(w*v))}static fromBytes(p,w=!1){let v=o.BYTES,{a:B,d:D}=i;p=Qe(N(p,v,"point")),Et(w,"zip215");let _=Qe(p),F=p[v-1];_[v-1]=F&-129;let C=Rt(_),L=w?f:o.ORDER;_e("point.y",C,Zt,L);let K=c(C*C),H=c(K-nt),k=c(D*K-B),{isValid:h,value:y}=u(H,k);if(!h)throw new Error("bad point: invalid y coordinate");let S=(y&nt)===nt,x=(F&128)!==0;if(!w&&y===Zt&&x)throw new Error("bad point: x=0 and x_0=1");return x!==S&&(y=c(-y)),d.fromAffine({x:y,y:C})}static fromHex(p,w=!1){return d.fromBytes(Te(p),w)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,w=!0){return b.createCache(this,p),w||this.multiply(Xn),this}assertValidity(){let p=this,{a:w,d:v}=i;if(p.is0())throw new Error("bad point: ZERO");let{X:B,Y:D,Z:_,T:F}=p,C=c(B*B),L=c(D*D),K=c(_*_),H=c(K*K),k=c(C*w),h=c(K*c(k+L)),y=c(H+c(v*c(C*L)));if(h!==y)throw new Error("bad point: equation left != right (1)");let S=c(B*D),x=c(_*F);if(S!==x)throw new Error("bad point: equation left != right (2)")}equals(p){m(p);let{X:w,Y:v,Z:B}=this,{X:D,Y:_,Z:F}=p,C=c(w*F),L=c(D*B),K=c(v*F),H=c(_*B);return C===L&&K===H}is0(){return this.equals(d.ZERO)}negate(){return new d(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:p}=i,{X:w,Y:v,Z:B}=this,D=c(w*w),_=c(v*v),F=c(Xn*c(B*B)),C=c(p*D),L=w+v,K=c(c(L*L)-D-_),H=C+_,k=H-F,h=C-_,y=c(K*k),S=c(H*h),x=c(K*h),g=c(k*H);return new d(y,S,g,x)}add(p){m(p);let{a:w,d:v}=i,{X:B,Y:D,Z:_,T:F}=this,{X:C,Y:L,Z:K,T:H}=p,k=c(B*C),h=c(D*L),y=c(F*v*H),S=c(_*K),x=c((B+D)*(C+L)-k-h),g=S-y,A=S+y,T=c(h-w*k),I=c(x*g),R=c(A*T),O=c(x*T),P=c(g*A);return new d(I,R,P,O)}subtract(p){return m(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:w,f:v}=b.cached(this,p,B=>ie(d,B));return ie(d,[w,v])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===Zt?d.ZERO:this.is0()||p===nt?this:b.unsafe(this,p,w=>ie(d,w))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,i.n).is0()}toAffine(p){let w=this,v=p,{X:B,Y:D,Z:_}=w,F=w.is0();v==null&&(v=F?$c:o.inv(_));let C=c(B*v),L=c(D*v),K=o.mul(_,v);if(F)return{x:Zt,y:nt};if(K!==nt)throw new Error("invZ was invalid");return{x:C,y:L}}clearCofactor(){return a===nt?this:this.multiplyUnsafe(a)}toBytes(){let{x:p,y:w}=this.toAffine(),v=o.toBytes(w);return v[v.length-1]|=p&nt?128:0,v}toHex(){return Le(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Oe(d,s.BITS);return s.BITS>=8&&d.BASE.precompute(8),Object.freeze(d.prototype),Object.freeze(d),d}var Kr=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){Hn()}static fromHex(t){Hn()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return Le(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};function ai(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;vt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:s}=o,{BASE:i,Fp:a,Fn:f}=e,c=n.outputLen,u=2*a.BYTES;if(c!==void 0&&(St(c,"hash.outputLen"),c!==u))throw new Error(`hash.outputLen must be ${u}, got ${c}`);let l=o.randomBytes===void 0?We:o.randomBytes,m=o.adjustScalarBytes===void 0?h=>h:o.adjustScalarBytes,d=o.domain===void 0?(h,y,S)=>{if(Et(S,"phflag"),y.length||S)throw new Error("Contexts/pre-hash are not supported");return h}:o.domain;function b(h){return f.create(Rt(h))}function E(h){let y=C.secretKey;N(h,C.secretKey,"secretKey");let S=N(n(h),2*y,"hashedSecretKey"),x=m(S.slice(0,y)),g=S.slice(y,2*y),A=b(x);return{head:x,prefix:g,scalar:A}}function p(h){let{head:y,prefix:S,scalar:x}=E(h),g=i.multiply(x),A=g.toBytes();return{head:y,prefix:S,scalar:x,point:g,pointBytes:A}}function w(h){return p(h).pointBytes}function v(h=Uint8Array.of(),...y){let S=Q(...y);return b(n(d(S,N(h,void 0,"context"),!!s)))}function B(h,y,S={}){h=N(h,void 0,"message"),s&&(h=s(h));let{prefix:x,scalar:g,pointBytes:A}=p(y),T=v(S.context,x,h),I=i.multiply(T).toBytes(),R=v(S.context,I,A,h),O=f.create(T+R*g);if(!f.isValid(O))throw new Error("sign failed: invalid s");let P=Q(I,f.toBytes(O));return N(P,C.signature,"result")}let D={zip215:o.zip215};function _(h,y,S,x=D){let{context:g}=x,A=x.zip215===void 0?!!D.zip215:x.zip215,T=C.signature;h=N(h,T,"signature"),y=N(y,void 0,"message"),S=N(S,C.publicKey,"publicKey"),A!==void 0&&Et(A,"zip215"),s&&(y=s(y));let I=T/2,R=h.subarray(0,I),O=Rt(h.subarray(I,T)),P,M,U;try{P=e.fromBytes(S,A),M=e.fromBytes(R,A),U=i.multiplyUnsafe(O)}catch{return!1}if(!A&&P.isSmallOrder())return!1;let J=v(g,R,S,y);return M.add(P.multiplyUnsafe(J)).subtract(U).clearCofactor().is0()}let F=a.BYTES,C={secretKey:F,publicKey:F,signature:2*F,seed:F};function L(h){return h=h===void 0?l(C.seed):h,N(h,C.seed,"seed")}function K(h){return re(h)&&h.length===C.secretKey}function H(h,y){try{return!!e.fromBytes(h,y===void 0?D.zip215:y)}catch{return!1}}let k={getExtendedPublicKey:p,randomSecretKey:L,isValidSecretKey:K,isValidPublicKey:H,toMontgomery(h){let{y}=e.fromBytes(h),S=C.publicKey,x=S===32;if(!x&&S!==57)throw new Error("only defined for 25519 and 448");let g=x?a.div(nt+y,nt-y):a.div(y-nt,y+nt);return a.toBytes(g)},toMontgomerySecret(h){let y=C.secretKey;N(h,y);let S=n(h.subarray(0,y));return m(S).subarray(0,y)}};return Object.freeze(C),Object.freeze(k),Object.freeze({keygen:Fr(L,w),getPublicKey:w,sign:B,verify:_,utils:k,Point:e,lengths:C})}function nr(e,t){if(St(e),St(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function Xc(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function Wc(e){if(!re(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?Dr(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function Wn(e,t,r,n){N(e),St(r),t=Wc(t),t.length>255&&(t=n(Q(Dr("H2C-OVERSIZE-DST-"),t)));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=Q(t,nr(t.length,1)),f=new Uint8Array(s),c=nr(r,2),u=new Array(i),l=n(Q(f,e,c,nr(0,1),a));u[0]=n(Q(l,nr(1,1),a));for(let d=1;d<i;d++){let b=[Xc(l,u[d-1]),nr(d+1,1),a];u[d]=n(Q(...b))}return Q(...u).slice(0,r)}var ci="HashToScalar-";var Jc=BigInt(0),Ut=BigInt(1),fi=BigInt(2);var Qc=BigInt(5),tf=BigInt(8),Fe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),eo={p:Fe,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:tf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ef(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Fe,a=e*e%s*e%s,f=V(a,fi,s)*a%s,c=V(f,Ut,s)*e%s,u=V(c,Qc,s)*c%s,l=V(u,t,s)*u%s,m=V(l,r,s)*l%s,d=V(m,n,s)*m%s,b=V(d,o,s)*d%s,E=V(b,o,s)*d%s,p=V(E,t,s)*u%s;return{pow_p_5_8:V(p,fi,s)*e%s,b2:a}}function rf(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Jn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ro(e,t){let r=Fe,n=W(t*t*t,r),o=W(n*n*t,r),s=ef(e*o).pow_p_5_8,i=W(e*n*s,r),a=W(t*i*i,r),f=i,c=W(i*Jn,r),u=a===e,l=a===W(-e,r),m=a===W(-e*Jn,r);return u&&(i=f),(l||m)&&(i=c),kt(i,r)&&(i=W(-i,r)),{isValid:u||l,value:i}}var $t=ii(eo,{uvRatio:ro}),Yt=$t.Fp,hi=$t.Fn;function nf(e){return ai($t,Ir,Object.assign({adjustScalarBytes:rf,zip215:!0},e))}var di=nf({});var Qn=Jn,of=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),sf=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),af=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),cf=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ui=e=>ro(Ut,e),ff=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),to=e=>Yt.create(Rt(e)&ff);function li(e){let{d:t}=eo,r=Fe,n=w=>Yt.create(w),o=n(Qn*e*e),s=n((o+Ut)*af),i=BigInt(-1),a=n((i-t*o)*n(o+t)),{isValid:f,value:c}=ro(s,a),u=n(c*e);kt(u,r)||(u=n(-u)),f||(c=u),f||(i=o);let l=n(i*(o-Ut)*cf-a),m=c*c,d=n((c+c)*a),b=n(l*of),E=n(Ut-m),p=n(Ut+m);return new $t(n(d*p),n(E*b),n(b*p),n(d*E))}var Gt=class e extends Kr{static BASE=new e($t.BASE);static ZERO=new e($t.ZERO);static Fp=Yt;static Fn=hi;constructor(t){super(t)}static fromAffine(t){return new e($t.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){mt(t,32);let{a:r,d:n}=eo,o=Fe,s=D=>Yt.create(D),i=to(t);if(!qs(Yt.toBytes(i),t)||kt(i,o))throw new Error("invalid ristretto255 encoding 1");let a=s(i*i),f=s(Ut+r*a),c=s(Ut-r*a),u=s(f*f),l=s(c*c),m=s(r*n*u-l),{isValid:d,value:b}=ui(s(m*l)),E=s(b*c),p=s(b*E*m),w=s((i+i)*E);kt(w,o)&&(w=s(-w));let v=s(f*p),B=s(w*v);if(!d||kt(B,o)||v===Jc)throw new Error("invalid ristretto255 encoding 2");return new e(new $t(w,v,Ut,B))}static fromHex(t){return e.fromBytes(Ye(t))}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,s=Fe,i=p=>Yt.create(p),a=i(i(n+r)*i(n-r)),f=i(t*r),c=i(f*f),{value:u}=ui(i(a*c)),l=i(u*a),m=i(u*f),d=i(l*m*o),b;if(kt(o*d,s)){let p=i(r*Qn),w=i(t*Qn);t=p,r=w,b=i(l*sf)}else b=m;kt(t*d,s)&&(r=i(-r));let E=i((n-r)*b);return kt(E,s)&&(E=i(-E)),Yt.toBytes(E)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:s}=t.ep,i=c=>Yt.create(c),a=i(r*s)===i(n*o),f=i(n*s)===i(r*o);return a||f}is0(){return this.equals(e.ZERO)}};Object.freeze(Gt.BASE);Object.freeze(Gt.ZERO);Object.freeze(Gt.prototype);Object.freeze(Gt);var uf=Object.freeze({Point:Gt,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=Wn(e,r,64,Ir);return uf.deriveToCurve(n)},hashToScalar(e,t={DST:ci}){let r=Wn(e,t.DST,64,Ir);return hi.create(Rt(r))},deriveToCurve(e){mt(e,64);let t=to(e.subarray(0,32)),r=li(t),n=to(e.subarray(32,64)),o=li(n);return new Gt(r.add(o))}});var or=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},kr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var gt={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new kr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Ke=32;var no,lf=(async()=>{try{return await gt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function hf(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await gt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await gt.get().subtle.verify({name:"Ed25519"},n,bt(t),bt(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function df(e,t,r){return di.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function pi(e,t,r){return no==null&&(no=await lf),no?hf(e,t,r):df(e,t,r)}function Ur(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Pr=class{type="Ed25519";raw;constructor(t){this.raw=oo(t,Ke)}toMultihash(){return Lt.digest(Ae(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=pi(this.raw,r,t);return Ur(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function bi(e){return e=oo(e,Ke),new Pr(e)}function oo(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new j(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var pf=Math.pow(2,7),mf=Math.pow(2,14),yf=Math.pow(2,21),so=Math.pow(2,28),io=Math.pow(2,35),ao=Math.pow(2,42),co=Math.pow(2,49),q=128,ct=127;function Pt(e){if(e<pf)return 1;if(e<mf)return 2;if(e<yf)return 3;if(e<so)return 4;if(e<io)return 5;if(e<ao)return 6;if(e<co)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function fo(e,t,r=0){switch(Pt(e)){case 8:t[r++]=e&255|q,e/=128;case 7:t[r++]=e&255|q,e/=128;case 6:t[r++]=e&255|q,e/=128;case 5:t[r++]=e&255|q,e/=128;case 4:t[r++]=e&255|q,e>>>=7;case 3:t[r++]=e&255|q,e>>>=7;case 2:t[r++]=e&255|q,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function bf(e,t,r=0){switch(Pt(e)){case 8:t.set(r++,e&255|q),e/=128;case 7:t.set(r++,e&255|q),e/=128;case 6:t.set(r++,e&255|q),e/=128;case 5:t.set(r++,e&255|q),e/=128;case 4:t.set(r++,e&255|q),e>>>=7;case 3:t.set(r++,e&255|q),e>>>=7;case 2:t.set(r++,e&255|q),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function uo(e,t){let r=e[t],n=0;if(n+=r&ct,r<q||(r=e[t+1],n+=(r&ct)<<7,r<q)||(r=e[t+2],n+=(r&ct)<<14,r<q)||(r=e[t+3],n+=(r&ct)<<21,r<q)||(r=e[t+4],n+=(r&ct)*so,r<q)||(r=e[t+5],n+=(r&ct)*io,r<q)||(r=e[t+6],n+=(r&ct)*ao,r<q)||(r=e[t+7],n+=(r&ct)*co,r<q))return n;throw new RangeError("Could not decode varint")}function gf(e,t){let r=e.get(t),n=0;if(n+=r&ct,r<q||(r=e.get(t+1),n+=(r&ct)<<7,r<q)||(r=e.get(t+2),n+=(r&ct)<<14,r<q)||(r=e.get(t+3),n+=(r&ct)<<21,r<q)||(r=e.get(t+4),n+=(r&ct)*so,r<q)||(r=e.get(t+5),n+=(r&ct)*io,r<q)||(r=e.get(t+6),n+=(r&ct)*ao,r<q)||(r=e.get(t+7),n+=(r&ct)*co,r<q))return n;throw new RangeError("Could not decode varint")}function gi(e,t,r=0){return t==null&&(t=dt(Pt(e))),t instanceof Uint8Array?fo(e,t,r):bf(e,t,r)}function xi(e,t=0){return e instanceof Uint8Array?uo(e,t):gf(e,t)}var lo=new Float32Array([-0]),Xt=new Uint8Array(lo.buffer);function wi(e,t,r){lo[0]=e,t[r]=Xt[0],t[r+1]=Xt[1],t[r+2]=Xt[2],t[r+3]=Xt[3]}function Ei(e,t){return Xt[0]=e[t],Xt[1]=e[t+1],Xt[2]=e[t+2],Xt[3]=e[t+3],lo[0]}var ho=new Float64Array([-0]),ft=new Uint8Array(ho.buffer);function Si(e,t,r){ho[0]=e,t[r]=ft[0],t[r+1]=ft[1],t[r+2]=ft[2],t[r+3]=ft[3],t[r+4]=ft[4],t[r+5]=ft[5],t[r+6]=ft[6],t[r+7]=ft[7]}function vi(e,t){return ft[0]=e[t],ft[1]=e[t+1],ft[2]=e[t+2],ft[3]=e[t+3],ft[4]=e[t+4],ft[5]=e[t+5],ft[6]=e[t+6],ft[7]=e[t+7],ho[0]}var wf=BigInt(Number.MAX_SAFE_INTEGER),Ef=BigInt(Number.MIN_SAFE_INTEGER),yt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ae;if(t<wf&&t>Ef)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ai&&(o=0n,++n>Ai&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ae;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):ae}},ae=new yt(0,0);ae.toBigInt=function(){return 0n};ae.zzEncode=ae.zzDecode=function(){return this};ae.length=function(){return 1};var Ai=4294967296n;function Bi(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ii(e,t,r){if(r-t<1)return"";let o,s=[],i=0,a;for(;t<r;)a=e[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function po(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function At(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Nr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var mo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=bt(t),this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,At(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw At(this,4);return Nr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw At(this,4);return Nr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw At(this,4);let t=Ei(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw At(this,4);let t=vi(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw At(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ii(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw At(this,t);this.pos+=t}else do if(this.pos>=this.len)throw At(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new yt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw At(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw At(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw At(this,8);let t=Nr(this.buf,this.pos+=4),r=Nr(this.buf,this.pos+=4);return new yt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=uo(this.buf,this.pos);return this.pos+=Pt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function sr(e){return new mo(e instanceof Uint8Array?e:e.subarray())}function ce(e,t,r){let n=sr(e);return t.decode(n,void 0,r)}function yo(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return dt(i);o+i>t&&(n=dt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var fe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function bo(){}var xo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Sf=yo();function vf(e){return globalThis.Buffer!=null?dt(e):Sf(e)}var ar=class{len;head;tail;states;constructor(){this.len=0,this.head=new fe(bo,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new fe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new wo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Mr,10,yt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=yt.fromBigInt(t);return this._push(Mr,r.length(),r)}uint64Number(t){return this._push(fo,Pt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=yt.fromBigInt(t).zzEncode();return this._push(Mr,r.length(),r)}sint64Number(t){let r=yt.fromNumber(t).zzEncode();return this._push(Mr,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(go,1,t?1:0)}fixed32(t){return this._push(ir,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=yt.fromBigInt(t);return this._push(ir,4,r.lo)._push(ir,4,r.hi)}fixed64Number(t){let r=yt.fromNumber(t);return this._push(ir,4,r.lo)._push(ir,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(wi,4,t)}double(t){return this._push(Si,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(go,1,0):this.uint32(r)._push(Bf,r,t)}string(t){let r=Bi(t);return r!==0?this.uint32(r)._push(po,r,t):this._push(go,1,0)}fork(){return this.states=new xo(this),this.head=this.tail=new fe(bo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new fe(bo,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=vf(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function go(e,t,r){t[r]=e&255}function Af(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var wo=class extends fe{next;constructor(t,r){super(Af,t,r),this.next=void 0}};function Mr(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function ir(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Bf(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(ar.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(If,t,e),this},ar.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Lf,t,e),this});function If(e,t,r){t.set(e,r)}function Lf(e,t,r){e.length<40?po(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(X(e),r)}function Eo(){return new ar}function ue(e,t){let r=Eo();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*le(e,t,r){let n=sr(e);yield*t.stream(n,void 0,"$",r)}var qr={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Hr(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function cr(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,a){let f=t(i);a.int32(f)},n=function(i){let a=i.int32();return t(a)},o=function*(i){let a=i.int32();yield t(a)};return Hr("enum",qr.VARINT,r,n,o)}function he(e,t,r){return Hr("message",qr.LENGTH_DELIMITED,e,t,r)}var ut;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ut||(ut={}));var So;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(So||(So={}));(function(e){e.codec=()=>cr(So)})(ut||(ut={}));var Wt;(function(e){let t;e.codec=()=>(t==null&&(t=he((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),ut.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=ut.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:ut.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return ue(s,e.codec())}e.encode=r;function n(s,i){return ce(s,e.codec(),i)}e.decode=n;function o(s,i){return le(s,e.codec(),i)}e.stream=o})(Wt||(Wt={}));var vo;(function(e){let t;e.codec=()=>(t==null&&(t=he((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),ut.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=ut.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:ut.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return ue(s,e.codec())}e.encode=r;function n(s,i){return ce(s,e.codec(),i)}e.decode=n;function o(s,i){return le(s,e.codec(),i)}e.stream=o})(vo||(vo={}));var ur={};ht(ur,{MAX_RSA_KEY_SIZE:()=>Ao,generateRSAKeyPair:()=>Oi,jwkToJWKKeyPair:()=>Fi,jwkToPkcs1:()=>Df,jwkToPkix:()=>To,jwkToRSAPrivateKey:()=>Ro,pkcs1MessageToJwk:()=>Io,pkcs1MessageToRSAPrivateKey:()=>_o,pkcs1ToJwk:()=>Rf,pkcs1ToRSAPrivateKey:()=>Di,pkixMessageToJwk:()=>Lo,pkixMessageToRSAPublicKey:()=>Vr,pkixToJwk:()=>Cf,pkixToRSAPublicKey:()=>Ci});var ke=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=ur.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return it.createV1(114,this._multihash)}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}verify(t,r,n){return Ri(this.jwk,r,t,n)}},fr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=ur.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}sign(t,r){return _i(this.jwk,t,r)}};var Ao=8192,Bo=18,Tf=1062,_f=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Rf(e){let t=Tt(e);return Io(t)}function Io(e){return{n:Z(e[1],"base64url"),e:Z(e[2],"base64url"),d:Z(e[3],"base64url"),p:Z(e[4],"base64url"),q:Z(e[5],"base64url"),dp:Z(e[6],"base64url"),dq:Z(e[7],"base64url"),qi:Z(e[8],"base64url"),kty:"RSA"}}function Df(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new j("JWK was missing components");return qt([pt(Uint8Array.from([0])),pt(X(e.n,"base64url")),pt(X(e.e,"base64url")),pt(X(e.d,"base64url")),pt(X(e.p,"base64url")),pt(X(e.q,"base64url")),pt(X(e.dp,"base64url")),pt(X(e.dq,"base64url")),pt(X(e.qi,"base64url"))]).subarray()}function Cf(e){let t=Tt(e,{offset:0});return Lo(t)}function Lo(e){let t=Tt(e[1],{offset:0});return{kty:"RSA",n:Z(t[0],"base64url"),e:Z(t[1],"base64url")}}function To(e){if(e.n==null||e.e==null)throw new j("JWK was missing components");return qt([_f,wr(qt([pt(X(e.n,"base64url")),pt(X(e.e,"base64url"))]))]).subarray()}function Di(e){let t=Tt(e);return _o(t)}function _o(e){let t=Io(e);return Ro(t)}function Ci(e,t){if(e.byteLength>=Tf)throw new me("Key size is too large");let r=Tt(e,{offset:0});return Vr(r,e,t)}function Vr(e,t,r){let n=Lo(e);if(r==null){let o=Ie(Wt.encode({Type:ut.RSA,Data:t}));r=It(Bo,o)}return new ke(n,r)}function Ro(e){if(ki(e)>Ao)throw new j("Key size is too large");let t=Fi(e),r=Ie(Wt.encode({Type:ut.RSA,Data:To(t.publicKey)})),n=It(Bo,r);return new fr(t.privateKey,new ke(t.publicKey,n))}async function Oi(e){if(e>Ao)throw new j("Key size is too large");let t=await Ki(e),r=Ie(Wt.encode({Type:ut.RSA,Data:To(t.publicKey)})),n=It(Bo,r);return new fr(t.privateKey,new ke(t.publicKey,n))}function Fi(e){if(e==null)throw new j("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}var Ui="1.2.840.113549.1.1.1";async function Ki(e,t){let r=await gt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await Of(r,t);return{privateKey:n[0],publicKey:n[1]}}async function _i(e,t,r){let n=await gt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await gt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,bt(t instanceof Uint8Array?t:t.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Ri(e,t,r,n){let o=await gt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await gt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,bt(t),bt(r instanceof Uint8Array?r:r.subarray()));return n?.signal?.throwIfAborted(),s}async function Of(e,t){if(e.privateKey==null||e.publicKey==null)throw new j("Private and public key are required");let r=await Promise.all([gt.get().subtle.exportKey("jwk",e.privateKey),gt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function ki(e){if(e.kty!=="RSA")throw new j("invalid key type");if(e.n==null)throw new j("invalid key modulus");return X(e.n,"base64url").length*8}var jr=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(Er(t),mt(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Ft(o)}update(t){return Be(this),this.iHash.update(t),this}digestInto(t){Be(this),Sr(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Pi=(()=>{let e=((t,r,n)=>new jr(t,r).update(n).digest());return e.create=(t,r)=>new jr(t,r),e})();var Ni=(e,t)=>(e+(e>=0?t:-t)/Mi)/t;function Ff(e,t,r){_e("scalar",e,Dt,r);let[[n,o],[s,i]]=t,a=Ni(i*e,r),f=Ni(-o*e,r),c=e-a*n-f*s,u=-a*o-f*i,l=c<Dt,m=u<Dt;l&&(c=-c),m&&(u=-u);let d=tr(Math.ceil(Re(r)/2))+Jt;if(c<Dt||c>=d||u<Dt||u>=d)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:c,k2neg:m,k2:u}}function Co(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Do(e,t){vt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Et(r.lowS,"lowS"),Et(r.prehash,"prehash"),r.format!==void 0&&Co(r.format),r}var Oo=class extends Error{constructor(t=""){super(t)}},Bt={Err:Oo,_tlv:{encode:(e,t)=>{let{Err:r}=Bt;if(St(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Je(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Je(o.length/2|128):"";return Je(e)+s+o+t},decode(e,t){let{Err:r}=Bt;t=N(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let 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=t.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=t.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=Bt;if(_r(e),e<Dt)throw new t("integer: negative integers are not allowed");let r=Je(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Bt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ne(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Bt,o=N(e,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:f}=n.decode(2,s),{v:c,l:u}=n.decode(2,f);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(c)}},hexFromSig(e){let{_tlv:t,_int:r}=Bt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}};Object.freeze(Bt._tlv);Object.freeze(Bt._int);Object.freeze(Bt);var Dt=BigInt(0),Jt=BigInt(1),Mi=BigInt(2),zr=BigInt(3),Kf=BigInt(4);function qi(e,t={}){let r=Or("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;vt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:f,allowInfinityPoint:c}=t;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let u=Vi(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function m(k,h,y){if(c&&h.is0())return Uint8Array.of(0);let{x:S,y:x}=h.toAffine(),g=n.toBytes(S);if(Et(y,"isCompressed"),y){l();let A=!n.isOdd(x);return Q(Hi(A),g)}else return Q(Uint8Array.of(4),g,n.toBytes(x))}function d(k){N(k,void 0,"Point");let{publicKey:h,publicKeyUncompressed:y}=u,S=k.length,x=k[0],g=k.subarray(1);if(c&&S===1&&x===0)return{x:n.ZERO,y:n.ZERO};if(S===h&&(x===2||x===3)){let A=n.fromBytes(g);if(!n.isValid(A))throw new Error("bad point: is not on curve, wrong x");let T=p(A),I;try{I=n.sqrt(T)}catch(P){let M=P instanceof Error?": "+P.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}l();let R=n.isOdd(I);return(x&1)===1!==R&&(I=n.neg(I)),{x:A,y:I}}else if(S===y&&x===4){let A=n.BYTES,T=n.fromBytes(g.subarray(0,A)),I=n.fromBytes(g.subarray(A,A*2));if(!w(T,I))throw new Error("bad point: is not on curve");return{x:T,y:I}}else throw new Error(`bad point: got length ${S}, expected compressed=${h} or uncompressed=${y}`)}let b=t.toBytes===void 0?m:t.toBytes,E=t.fromBytes===void 0?d:t.fromBytes;function p(k){let h=n.sqr(k),y=n.mul(h,k);return n.add(n.add(y,n.mul(k,s.a)),s.b)}function w(k,h){let y=n.sqr(h),S=p(k);return n.eql(y,S)}if(!w(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let v=n.mul(n.pow(s.a,zr),Kf),B=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(v,B)))throw new Error("bad curve params: a or b");function D(k,h,y=!1){if(!n.isValid(h)||y&&n.is0(h))throw new Error(`bad point coordinate ${k}`);return h}function _(k){if(!(k instanceof L))throw new Error("Weierstrass Point expected")}function F(k){if(!f||!f.basises)throw new Error("no endo");return Ff(k,f.basises,o.ORDER)}function C(k,h,y,S,x){return y=new L(n.mul(y.X,k),y.Y,y.Z),h=rr(S,h),y=rr(x,y),h.add(y)}class L{static BASE=new L(s.Gx,s.Gy,n.ONE);static ZERO=new L(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(h,y,S){this.X=D("x",h),this.Y=D("y",y,!0),this.Z=D("z",S),Object.freeze(this)}static CURVE(){return s}static fromAffine(h){let{x:y,y:S}=h||{};if(!h||!n.isValid(y)||!n.isValid(S))throw new Error("invalid affine point");if(h instanceof L)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(S)?L.ZERO:new L(y,S,n.ONE)}static fromBytes(h){let y=L.fromAffine(E(N(h,void 0,"point")));return y.assertValidity(),y}static fromHex(h){return L.fromBytes(Te(h))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(h=8,y=!0){return H.createCache(this,h),y||this.multiply(zr),this}assertValidity(){let h=this;if(h.is0()){if(t.allowInfinityPoint&&n.is0(h.X)&&n.eql(h.Y,n.ONE)&&n.is0(h.Z))return;throw new Error("bad point: ZERO")}let{x:y,y:S}=h.toAffine();if(!n.isValid(y)||!n.isValid(S))throw new Error("bad point: x or y not field elements");if(!w(y,S))throw new Error("bad point: equation left != right");if(!h.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(h)}equals(h){_(h);let{X:y,Y:S,Z:x}=this,{X:g,Y:A,Z:T}=h,I=n.eql(n.mul(y,T),n.mul(g,x)),R=n.eql(n.mul(S,T),n.mul(A,x));return I&&R}negate(){return new L(this.X,n.neg(this.Y),this.Z)}double(){let{a:h,b:y}=s,S=n.mul(y,zr),{X:x,Y:g,Z:A}=this,T=n.ZERO,I=n.ZERO,R=n.ZERO,O=n.mul(x,x),P=n.mul(g,g),M=n.mul(A,A),U=n.mul(x,g);return U=n.add(U,U),R=n.mul(x,A),R=n.add(R,R),T=n.mul(h,R),I=n.mul(S,M),I=n.add(T,I),T=n.sub(P,I),I=n.add(P,I),I=n.mul(T,I),T=n.mul(U,T),R=n.mul(S,R),M=n.mul(h,M),U=n.sub(O,M),U=n.mul(h,U),U=n.add(U,R),R=n.add(O,O),O=n.add(R,O),O=n.add(O,M),O=n.mul(O,U),I=n.add(I,O),M=n.mul(g,A),M=n.add(M,M),O=n.mul(M,U),T=n.sub(T,O),R=n.mul(M,P),R=n.add(R,R),R=n.add(R,R),new L(T,I,R)}add(h){_(h);let{X:y,Y:S,Z:x}=this,{X:g,Y:A,Z:T}=h,I=n.ZERO,R=n.ZERO,O=n.ZERO,P=s.a,M=n.mul(s.b,zr),U=n.mul(y,g),J=n.mul(S,A),tt=n.mul(x,T),et=n.add(y,S),$=n.add(g,A);et=n.mul(et,$),$=n.add(U,J),et=n.sub(et,$),$=n.add(y,x);let lt=n.add(g,T);return $=n.mul($,lt),lt=n.add(U,tt),$=n.sub($,lt),lt=n.add(S,x),I=n.add(A,T),lt=n.mul(lt,I),I=n.add(J,tt),lt=n.sub(lt,I),O=n.mul(P,$),I=n.mul(M,tt),O=n.add(I,O),I=n.sub(J,O),O=n.add(J,O),R=n.mul(I,O),J=n.add(U,U),J=n.add(J,U),tt=n.mul(P,tt),$=n.mul(M,$),J=n.add(J,tt),tt=n.sub(U,tt),tt=n.mul(P,tt),$=n.add($,tt),U=n.mul(J,$),R=n.add(R,U),U=n.mul(lt,$),I=n.mul(et,I),I=n.sub(I,U),U=n.mul(et,J),O=n.mul(lt,O),O=n.add(O,U),new L(I,R,O)}subtract(h){return _(h),this.add(h.negate())}is0(){return this.equals(L.ZERO)}multiply(h){let{endo:y}=t;if(!o.isValidNot0(h))throw new RangeError("invalid scalar: out of range");let S,x,g=A=>H.cached(this,A,T=>ie(L,T));if(y){let{k1neg:A,k1:T,k2neg:I,k2:R}=F(h),{p:O,f:P}=g(T),{p:M,f:U}=g(R);x=P.add(U),S=C(y.beta,O,M,A,I)}else{let{p:A,f:T}=g(h);S=A,x=T}return ie(L,[S,x])[0]}multiplyUnsafe(h){let{endo:y}=t,S=this,x=h;if(!o.isValid(x))throw new RangeError("invalid scalar: out of range");if(x===Dt||S.is0())return L.ZERO;if(x===Jt)return S;if(H.hasCache(this))return this.multiply(x);if(y){let{k1neg:g,k1:A,k2neg:T,k2:I}=F(x),{p1:R,p2:O}=si(L,S,A,I);return C(y.beta,R,O,g,T)}else return H.unsafe(S,x)}toAffine(h){let y=this,S=h,{X:x,Y:g,Z:A}=y;if(n.eql(A,n.ONE))return{x,y:g};let T=y.is0();S==null&&(S=T?n.ONE:n.inv(A));let I=n.mul(x,S),R=n.mul(g,S),O=n.mul(A,S);if(T)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:I,y:R}}isTorsionFree(){let{isTorsionFree:h}=t;return i===Jt?!0:h?h(L,this):H.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:h}=t;return i===Jt?this:h?h(L,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===Jt?this.is0():this.clearCofactor().is0()}toBytes(h=!0){return Et(h,"isCompressed"),this.assertValidity(),b(L,this,h)}toHex(h=!0){return Le(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let K=o.BITS,H=new Oe(L,t.endo?Math.ceil(K/2):K);return K>=8&&L.BASE.precompute(8),Object.freeze(L.prototype),Object.freeze(L),L}function Hi(e){return Uint8Array.of(e?2:3)}function Vi(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function kf(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?We:t.randomBytes,o=Object.assign(Vi(e.Fp,r),{seed:Math.max(zn(r.ORDER),16)});function s(d){try{let b=r.fromBytes(d);return r.isValidNot0(b)}catch{return!1}}function i(d,b){let{publicKey:E,publicKeyUncompressed:p}=o;try{let w=d.length;return b===!0&&w!==E||b===!1&&w!==p?!1:!!e.fromBytes(d)}catch{return!1}}function a(d){return d=d===void 0?n(o.seed):d,Zn(N(d,o.seed,"seed"),r.ORDER)}function f(d,b=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(b)}function c(d){let{secretKey:b,publicKey:E,publicKeyUncompressed:p}=o,w=r._lengths;if(!re(d))return;let v=N(d,void 0,"key").length,B=v===E||v===p,D=v===b||!!w?.includes(v);if(!(B&&D))return B}function u(d,b,E=!0){if(c(d)===!0)throw new Error("first arg must be private key");if(c(b)===!1)throw new Error("second arg must be public key");let p=r.fromBytes(d);return e.fromBytes(b).multiply(p).toBytes(E)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},m=Fr(a,f);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:f,getSharedSecret:u,keygen:m,Point:e,utils:l,lengths:o})}function ji(e,t,r={}){let n=t;Er(n),vt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?We:r.randomBytes,s=r.hmac===void 0?(x,g)=>Pi(n,x,g):r.hmac,{Fp:i,Fn:a}=e,{ORDER:f,BITS:c}=a,{keygen:u,getPublicKey:l,getSharedSecret:m,utils:d,lengths:b}=kf(e,r),E={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},p=f*Mi+Jt<i.ORDER;function w(x){let g=f>>Jt;return x>g}function v(x,g){if(!a.isValidNot0(g))throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);return g}function B(){if(p)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(x,g){Co(g);let A=b.signature,T=g==="compact"?A:g==="recovered"?A+1:void 0;return N(x,T)}class _{r;s;recovery;constructor(g,A,T){if(this.r=v("r",g),this.s=v("s",A),T!=null){if(B(),![0,1,2,3].includes(T))throw new Error("invalid recovery id");this.recovery=T}Object.freeze(this)}static fromBytes(g,A=E.format){D(g,A);let T;if(A==="der"){let{r:P,s:M}=Bt.toSig(N(g));return new _(P,M)}A==="recovered"&&(T=g[0],A="compact",g=g.subarray(1));let I=b.signature/2,R=g.subarray(0,I),O=g.subarray(I,I*2);return new _(a.fromBytes(R),a.fromBytes(O),T)}static fromHex(g,A){return this.fromBytes(Te(g),A)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new _(this.r,this.s,g)}recoverPublicKey(g){let{r:A,s:T}=this,I=this.assertRecovery(),R=I===2||I===3?A+f:A;if(!i.isValid(R))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(R),P=e.fromBytes(Q(Hi((I&1)===0),O)),M=a.inv(R),U=C(N(g,void 0,"msgHash")),J=a.create(-U*M),tt=a.create(T*M),et=e.BASE.multiplyUnsafe(J).add(P.multiplyUnsafe(tt));if(et.is0())throw new Error("invalid recovery: point at infinify");return et.assertValidity(),et}hasHighS(){return w(this.s)}toBytes(g=E.format){if(Co(g),g==="der")return Te(Bt.hexFromSig(this));let{r:A,s:T}=this,I=a.toBytes(A),R=a.toBytes(T);return g==="recovered"?(B(),Q(Uint8Array.of(this.assertRecovery()),I,R)):Q(I,R)}toHex(g){return Le(this.toBytes(g))}}Object.freeze(_.prototype),Object.freeze(_);let F=r.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let A=ne(g),T=g.length*8-c;return T>0?A>>BigInt(T):A}:r.bits2int,C=r.bits2int_modN===void 0?function(g){return a.create(F(g))}:r.bits2int_modN,L=tr(c);function K(x){return _e("num < 2^"+c,x,Dt,L),a.toBytes(x)}function H(x,g){return N(x,void 0,"message"),g?N(n(x),void 0,"prehashed message"):x}function k(x,g,A){let{lowS:T,prehash:I,extraEntropy:R}=Do(A,E);x=H(x,I);let O=C(x),P=a.fromBytes(g);if(!a.isValidNot0(P))throw new Error("invalid private key");let M=[K(P),K(O)];if(R!=null&&R!==!1){let et=R===!0?o(b.secretKey):R;M.push(N(et,void 0,"extraEntropy"))}let U=Q(...M),J=O;function tt(et){let $=F(et);if(!a.isValidNot0($))return;let lt=a.inv($),pe=e.BASE.multiply($).toAffine(),Pe=a.create(pe.x);if(Pe===Dt)return;let dr=a.create(lt*a.create(J+Pe*P));if(dr===Dt)return;let Zo=(pe.x===Pe?0:2)|Number(pe.y&Jt),Yo=dr;return T&&w(dr)&&(Yo=a.neg(dr),Zo^=1),new _(Pe,Yo,p?void 0:Zo)}return{seed:U,k2sig:tt}}function h(x,g,A={}){let{seed:T,k2sig:I}=k(x,g,A);return Hs(n.outputLen,a.BYTES,s)(T,I).toBytes(A.format)}function y(x,g,A,T={}){let{lowS:I,prehash:R,format:O}=Do(T,E);if(A=N(A,void 0,"publicKey"),g=H(g,R),!re(x)){let P=x instanceof _?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+P)}D(x,O);try{let P=_.fromBytes(x,O),M=e.fromBytes(A);if(I&&P.hasHighS())return!1;let{r:U,s:J}=P,tt=C(g),et=a.inv(J),$=a.create(tt*et),lt=a.create(U*et),pe=e.BASE.multiplyUnsafe($).add(M.multiplyUnsafe(lt));return pe.is0()?!1:a.create(pe.x)===U}catch{return!1}}function S(x,g,A={}){let{prehash:T}=Do(A,E);return g=H(g,T),_.fromBytes(x,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:u,getPublicKey:l,getSharedSecret:m,utils:d,lengths:b,Point:e,sign:h,verify:y,recoverPublicKey:S,Signature:_,hash:n})}var Ko={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Uf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var zi=BigInt(2);function Pf(e){let t=Ko.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),f=BigInt(88),c=e*e*e%t,u=c*c*e%t,l=V(u,r,t)*u%t,m=V(l,r,t)*u%t,d=V(m,zi,t)*c%t,b=V(d,o,t)*d%t,E=V(b,s,t)*b%t,p=V(E,a,t)*E%t,w=V(p,f,t)*p%t,v=V(w,a,t)*E%t,B=V(v,r,t)*u%t,D=V(B,i,t)*b%t,_=V(D,n,t)*c%t,F=V(_,zi,t);if(!Fo.eql(Fo.sqr(F),e))throw new Error("Cannot find square root");return F}var Fo=De(Ko.p,{sqrt:Pf}),Nf=qi(Ko,{Fp:Fo,endo:Uf}),Ue=ji(Nf,Ie);var Zi=33;function Yi(e,t,r,n){let o=gr.digest(r instanceof Uint8Array?r:r.subarray());if(Ur(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ue.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new or(String(s))});try{return n?.signal?.throwIfAborted(),Ue.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new or(String(s))}}var Zr=class{type="secp256k1";raw;_key;constructor(t){this._key=Gi(t),this.raw=$i(this._key)}toMultihash(){return Lt.digest(Ae(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}verify(t,r,n){return Yi(this._key,r,t,n)}};function Xi(e){return new Zr(e)}function $i(e){return Ue.Point.fromBytes(e).toBytes()}function Gi(e){try{return Ue.Point.fromBytes(e),e}catch(t){throw new me(String(t))}}function Wi(e){if(e.byteLength===Ke)return bi(e);if(e.byteLength===Zi)return Xi(e);let t=Tt(e),r=t[1]?.[0];if(r===us||r===ls||r===hs)return As(t);if(t[0]?.[0]===Ui)return Vr(t,e);throw new j("Could not extract public key from raw bytes")}function Ae(e){return Wt.encode({Type:ut[e.type],Data:e.raw})}var Ji=Symbol.for("nodejs.util.inspect.custom"),Mf=114,lr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Qr]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return it.createV1(Mf,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return at(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return at(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ji](){return`PeerId(${this.toString()})`}},Yr=class extends lr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},$r=class extends lr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Gr=class extends lr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},qf=2336,ko=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Lt.digest(X(this.url))}[Ji](){return`PeerId(${this.url})`}[Qr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return it.createV1(qf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Z(t)),t.toString()===this.toString())}};function Qi(e){if(e.type==="Ed25519")return new $r({multihash:e.toCID().multihash,publicKey:e});if(e.type==="secp256k1")return new Gr({multihash:e.toCID().multihash,publicKey:e});if(e.type==="RSA")return new Yr({multihash:e.toCID().multihash,publicKey:e});throw new Me}var Uo=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},ta=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function Po(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout},signal:i}=t,a,f,u=new Promise((l,m)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(i?.aborted){m(ta(i));return}if(i&&(f=()=>{m(ta(i))},i.addEventListener("abort",f,{once:!0})),e.then(l,m),r===Number.POSITIVE_INFINITY)return;let d=new Uo;a=s.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(b){m(b)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?m(o):(d.message=o??`Promise timed out after ${r} milliseconds`,m(d))},r)}).finally(()=>{u.clear(),f&&i&&i.removeEventListener("abort",f)});return u.clear=()=>{s.clearTimeout.call(void 0,a),a=void 0},u}var Hf=e=>{let t=e.addEventListener||e.on||e.addListener,r=e.removeEventListener||e.off||e.removeListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function Vf(e,t,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=[t].flat(),f=[],{addListener:c,removeListener:u}=Hf(e),l=async(...d)=>{let b=r.multiArgs?d:d[0];if(r.filter)try{if(!await r.filter(b))return}catch(E){n(),i(E);return}f.push(b),r.count===f.length&&(n(),s(f))},m=(...d)=>{n(),i(r.rejectionMultiArgs?d:d[0])};n=()=>{for(let d of a)u(d,l);for(let d of r.rejectionEvents)a.includes(d)||u(d,m)};for(let d of a)c(d,l);for(let d of r.rejectionEvents)a.includes(d)||c(d,m);r.signal&&r.signal.addEventListener("abort",()=>{m(r.signal.reason)},{once:!0}),r.resolveImmediately&&s(f)});if(o.cancel=n,typeof r.timeout=="number"){let s=Po(o,{milliseconds:r.timeout});return s.cancel=()=>{n(),s.clear()},s}return o}function ea(e,t,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=Vf(e,t,r),o=n.then(s=>s[0]);return o.cancel=n.cancel,o}var de=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"};function jf(e){return e.reason}async function No(e,t,r){if(t==null)return e;let n=r?.translateError??jf;if(t.aborted)return e.catch(()=>{}),Promise.reject(n(t));let o;try{return await Promise.race([e,new Promise((s,i)=>{o=()=>{i(n(t))},t.addEventListener("abort",o)})])}finally{o!=null&&t.removeEventListener("abort",o)}}var Zf=4194304,Xr=class extends Error{static name="UnwrappedError";name="UnwrappedError"},qo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ho=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Vo=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Yf(e){return typeof e?.closeRead=="function"}function $f(e){return typeof e?.close=="function"}function Mo(e){return Yf(e)?e.remoteWriteStatus!=="writable"&&e.readBufferLength===0:$f(e)?e.status!=="open":!1}function Gf(e){return e?.addEventListener!=null&&e?.removeEventListener!=null&&e?.send!=null&&e?.push!=null&&e?.log!=null}function Xf(e,t){let r=t?.maxBufferSize??Zf,n=new rt,o,s=!1;if(!Gf(e))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()};e.addEventListener("message",i);let a=u=>{u.error!=null?o?.reject(u.error):o?.resolve()};e.addEventListener("close",a);let f=()=>{o?.resolve()};e.addEventListener("remoteCloseWrite",f);let c={readBuffer:n,async read(u){if(s===!0)throw new Xr("Stream was unwrapped");if(Mo(e)){if(n.byteLength===0&&u?.bytes==null)return null;if(u?.bytes!=null&&n.byteLength<u.bytes)throw e.log.error("closed after reading %d/%d bytes",n.byteLength,u.bytes),new de(`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 No(o.promise,u?.signal),Mo(e)){if(n.byteLength===0&&u?.bytes==null)return null;break}o=Promise.withResolvers()}let m=u?.bytes??n.byteLength;if(n.byteLength<m){if(Mo(e))throw e.log.error("closed while reading %d/%d bytes",n.byteLength,m),new de(`Unexpected EOF - stream closed while reading ${n.byteLength}/${m} bytes`);return c.read(u)}let d=n.sublist(0,m);return n.consume(m),d},async write(u,l){if(s===!0)throw new Xr("Stream was unwrapped");e.send(u)||await ea(e,"drain",{signal:l?.signal,rejectionEvents:["close"]})},unwrap(){return s||(s=!0,e.removeEventListener("message",i),e.removeEventListener("close",a),e.removeEventListener("remoteCloseWrite",f),n.byteLength>0&&(e.log("stream unwrapped with %d unread bytes",n.byteLength),e.unshift(n))),e}};return c}function Wf(e,t={}){let r=Xf(e,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Pt(t.maxDataLength));let n=t?.lengthDecoder??xi,o=t?.lengthEncoder??gi;return{async read(i){let a=-1,f=new rt;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 qo("Invalid message length");if(t?.maxLengthLength!=null&&f.byteLength>t.maxLengthLength)throw new Vo(`Message length length too long - ${f.byteLength} > ${t.maxLengthLength}`);if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Ho(`Message length too long - ${a} > ${t.maxDataLength}`);let c=await r.read({...i,bytes:a});if(c==null)throw e.log.error("tried to read %d bytes but the stream closed",a),new de(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(c.byteLength!==a)throw e.log.error("read %d/%d bytes before the stream closed",c.byteLength,a),new de(`Unexpected EOF - read ${c.byteLength}/${a} bytes before the stream closed`);return c},async write(i,a){await r.write(new rt(o(i.byteLength),i),a)},async writeV(i,a){let f=new rt(...i.flatMap(c=>[o(c.byteLength),c]));await r.write(f,a)},unwrap(){return r.unwrap()}}}function ra(e,t){let r=Wf(e,t),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 Wr;(function(e){let t;e.codec=()=>(t==null&&(t=he((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.id!=null&&(i.uint32(10),i.bytes(s.id)),s.pubkey!=null&&(i.uint32(18),hr.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=hr.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*hr.codec().stream(s,s.uint32(),`${a}.pubkey`,{limits:f.limits?.pubkey});break}default:{s.skipType(u&7);break}}}})),t);function r(s){return ue(s,e.codec())}e.encode=r;function n(s,i){return ce(s,e.codec(),i)}e.decode=n;function o(s,i){return le(s,e.codec(),i)}e.stream=o})(Wr||(Wr={}));var Nt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(Nt||(Nt={}));var jo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(jo||(jo={}));(function(e){e.codec=()=>cr(jo)})(Nt||(Nt={}));var hr;(function(e){let t;e.codec=()=>(t==null&&(t=he((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),Nt.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:xt(0)},c=i==null?s.len:s.pos+i;for(;s.pos<c;){let u=s.uint32();switch(u>>>3){case 1:{f.Type=Nt.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:Nt.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return ue(s,e.codec())}e.encode=r;function n(s,i){return ce(s,e.codec(),i)}e.decode=n;function o(s,i){return le(s,e.codec(),i)}e.stream=o})(hr||(hr={}));var Jf="/plaintext/2.0.0",zo=class{protocol=Jf;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[$o]=["@libp2p/connection-encryption"];async secureInbound(t,r){return this._encrypt(t,r)}async secureOutbound(t,r){return this._encrypt(t,r)}async _encrypt(t,r){let n=t.log?.newScope("plaintext")??this.log,o=ra(t).pb(Wr);n("write pubkey exchange to peer %p",r?.remotePeer);let s=this.privateKey.publicKey;await o.write({id:s.toMultihash().bytes,pubkey:{Type:Nt[s.type],Data:s.raw}},r);let i=await o.read(r),a;try{if(i.pubkey==null)throw new ye("Public key missing");if(i.pubkey.Data.byteLength===0)throw new ye("Public key data too short");if(i.id==null)throw new ye("Remote id missing");let f=Wi(i.pubkey.Data);if(a=Qi(f),!at(a.toMultihash().bytes,i.id))throw new Ne("Public key did not match id")}catch(f){throw n.error("invalid public key - %e",f),new Ne(`Invalid public key - ${f.message}`)}if(r?.remotePeer!=null&&!a.equals(r?.remotePeer))throw new pr;return n("plaintext key exchange completed successfully with peer %p",a),{connection:o.unwrap().unwrap(),remotePeer:a}}};function Qf(){return e=>new zo(e)}return aa(tu);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js: