@libp2p/plaintext 2.0.22-6f96de86c → 2.0.22-9b33d202e

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,32 +1,19 @@
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 Cr=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var ui=Object.prototype.hasOwnProperty;var pt=(r,t)=>{for(var e in t)Cr(r,e,{get:t[e],enumerable:!0})},li=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fi(t))!ui.call(r,o)&&o!==e&&Cr(r,o,{get:()=>t[o],enumerable:!(n=ci(t,o))||n.enumerable});return r};var hi=r=>li(Cr({},"__esModule",{value:!0}),r);var sf={};pt(sf,{plaintext:()=>of});var Dr=Symbol.for("@libp2p/peer-id");var Xe=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},De=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},tt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},fe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var ue=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Te=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var co=Symbol.for("@libp2p/service-capabilities"),uf=Symbol.for("@libp2p/service-dependencies");var Pr={};pt(Pr,{base58btc:()=>X,base58flickr:()=>xi});var Kf=new Uint8Array(0);function fo(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Dt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function uo(r){return new TextEncoder().encode(r)}function lo(r){return new TextDecoder().decode(r)}function di(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var y=0,h=0,x=0,v=E.length;x!==v&&E[x]===0;)x++,y++;for(var p=(v-x)*f+1>>>0,B=new Uint8Array(p);x!==v;){for(var R=E[x],T=0,L=p-1;(R!==0||T<h)&&L!==-1;L--,T++)R+=256*B[L]>>>0,B[L]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");h=T,x++}for(var _=p-h;_!==p&&B[_]===0;)_++;for(var C=c.repeat(y);_<p;++_)C+=r.charAt(B[_]);return C}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var y=0;if(E[y]!==" "){for(var h=0,x=0;E[y]===c;)h++,y++;for(var v=(E.length-y)*u+1>>>0,p=new Uint8Array(v);E[y];){var B=e[E.charCodeAt(y)];if(B===255)return;for(var R=0,T=v-1;(B!==0||R<x)&&T!==-1;T--,R++)B+=a*p[T]>>>0,p[T]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");x=R,y++}if(E[y]!==" "){for(var L=v-x;L!==v&&p[L]===0;)L++;for(var _=new Uint8Array(h+(v-L)),C=h;L!==v;)_[C++]=p[L++];return _}}}function S(E){var y=m(E);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:m,decode:S}}var pi=di,mi=pi,po=mi;var Tr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Rr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return mo(this,t)}},Kr=class{decoders;constructor(t){this.decoders=t}or(t){return mo(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function mo(r,t){return new Kr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ur=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Tr(t,e,n),this.decoder=new Rr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function le({name:r,prefix:t,encode:e,decode:n}){return new Ur(r,t,e,n)}function kt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=po(e,r);return le({prefix:t,name:r,encode:n,decode:s=>Dt(o(s))})}function yi(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=e||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function bi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function W({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return le({prefix:t,name:r,encode(o){return bi(o,n,e)},decode(o){return yi(o,n,e,r)}})}var X=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xi=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Nr={};pt(Nr,{base32:()=>he,base32hex:()=>Si,base32hexpad:()=>vi,base32hexpadupper:()=>Bi,base32hexupper:()=>Ai,base32pad:()=>wi,base32padupper:()=>Ei,base32upper:()=>gi,base32z:()=>Ii});var he=W({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gi=W({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wi=W({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ei=W({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Si=W({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ai=W({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vi=W({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Bi=W({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ii=W({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kr={};pt(kr,{base36:()=>Re,base36upper:()=>Li});var Re=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Li=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var _i=xo,yo=128,Ci=127,Di=~Ci,Ti=Math.pow(2,31);function xo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ti;)t[e++]=r&255|yo,r/=128;for(;r&Di;)t[e++]=r&255|yo,r>>>=7;return t[e]=r|0,xo.bytes=e-n+1,t}var Ri=Or,Ki=128,bo=127;function Or(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Or.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&bo)<<o:(i&bo)*Math.pow(2,o),o+=7}while(i>=Ki);return Or.bytes=s-n,e}var Ui=Math.pow(2,7),Pi=Math.pow(2,14),Ni=Math.pow(2,21),ki=Math.pow(2,28),Oi=Math.pow(2,35),Mi=Math.pow(2,42),Hi=Math.pow(2,49),qi=Math.pow(2,56),Vi=Math.pow(2,63),Fi=function(r){return r<Ui?1:r<Pi?2:r<Ni?3:r<ki?4:r<Oi?5:r<Mi?6:r<Hi?7:r<qi?8:r<Vi?9:10},zi={encode:_i,decode:Ri,encodingLength:Fi},Gi=zi,Ke=Gi;function Ue(r,t=0){return[Ke.decode(r,t),Ke.decode.bytes]}function de(r,t,e=0){return Ke.encode(r,t,e),t}function pe(r){return Ke.encodingLength(r)}function St(r,t){let e=t.byteLength,n=pe(r),o=n+pe(e),s=new Uint8Array(o+e);return de(r,s,0),de(e,s,n),s.set(t,o),new me(r,e,t,s)}function Mr(r){let t=Dt(r),[e,n]=Ue(t),[o,s]=Ue(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new me(e,o,i,t)}function go(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&fo(r.bytes,e.bytes)}}var me=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function wo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Zi(e,Hr(r),t??X.encoder);default:return Wi(e,Hr(r),t??he.encoder)}}var Eo=new WeakMap;function Hr(r){let t=Eo.get(r);if(t==null){let e=new Map;return Eo.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Pe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Yi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=St(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&go(t.multihash,n.multihash)}toString(t){return wo(this,t)}toJSON(){return{"/":wo(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??So(n,o,s.bytes))}else if(e[Xi]===!0){let{version:n,multihash:o,code:s}=e,i=Mr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Pe)throw new Error(`Version 0 CID must use dag-pb (code: ${Pe}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=So(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Pe,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Dt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new me(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,m]=Ue(t.subarray(e));return e+=m,l},o=n(),s=Pe;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),u=e+c,f=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,e){let[n,o]=ji(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Hr(s).set(n,t),s}};function ji(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case he.prefix:{let e=t??he;return[he.prefix,e.decode(r)]}case Re.prefix:{let e=t??Re;return[Re.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Zi(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Wi(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Pe=112,Yi=18;function So(r,t,e){let n=pe(r),o=n+pe(t),s=new Uint8Array(o+e.byteLength);return de(r,s,0),de(t,s,n),s.set(e,o),s}var Xi=Symbol.for("@ipld/js-cid/CID");var qr={};pt(qr,{identity:()=>It});var Ao=0,$i="identity",vo=Dt;function Ji(r){return St(Ao,vo(r))}var It={code:Ao,name:$i,encode:vo,digest:Ji};function ft(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function At(r=0){return new Uint8Array(r)}function mt(r=0){return new Uint8Array(r)}function Je(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=mt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Io=Symbol.for("@achingbrain/uint8arraylist");function Bo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Qe(r){return!!r?.[Io]}var rt=class r{bufs;length;[Io]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Qe(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Qe(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Bo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Bo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Qe(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Je(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Je(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,f=e>a&&e<=c;if(u&&f){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Qe(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=e;l<=c;l+=f){f=0;for(let m=u;m>=0;m--){let S=this.get(l+m);if(n[m]!==S){f=Math.max(1,m-a[S]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ft(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Vr={};pt(Vr,{base10:()=>Qi});var Qi=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var Fr={};pt(Fr,{base16:()=>ta,base16upper:()=>ea});var ta=W({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ea=W({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zr={};pt(zr,{base2:()=>ra});var ra=W({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gr={};pt(Gr,{base256emoji:()=>aa});var Lo=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),na=Lo.reduce((r,t,e)=>(r[e]=t,r),[]),oa=Lo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function sa(r){return r.reduce((t,e)=>(t+=na[e],t),"")}function ia(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=oa[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var aa=le({prefix:"\u{1F680}",name:"base256emoji",encode:sa,decode:ia});var jr={};pt(jr,{base64:()=>ca,base64pad:()=>fa,base64url:()=>ua,base64urlpad:()=>la});var ca=W({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fa=W({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ua=W({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),la=W({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zr={};pt(Zr,{base8:()=>ha});var ha=W({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wr={};pt(Wr,{identity:()=>da});var da=le({prefix:"\0",name:"identity",encode:r=>lo(r),decode:r=>uo(r)});var yu=new TextEncoder,bu=new TextDecoder;var $r={};pt($r,{sha256:()=>tr,sha512:()=>ya});function Xr({name:r,code:t,encode:e}){return new Yr(r,t,e)}var Yr=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?St(this.code,e):e.then(n=>St(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Co(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var tr=Xr({name:"sha2-256",code:18,encode:Co("SHA-256")}),ya=Xr({name:"sha2-512",code:19,encode:Co("SHA-512")});var Jr={...Wr,...zr,...Zr,...Vr,...Fr,...Nr,...kr,...Pr,...jr,...Gr},Cu={...$r,...qr};function To(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Do=To("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Qr=To("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=mt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ba={utf8:Do,"utf-8":Do,hex:Jr.base16,latin1:Qr,ascii:Qr,binary:Qr,...Jr},er=ba;function $(r,t="utf8"){let e=er[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function J(r,t="utf8"){let e=er[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var xa=parseInt("11111",2),tn=parseInt("10000000",2),ga=parseInt("01111111",2),Ro={0:Ne,1:Ne,2:wa,3:Aa,4:va,5:Sa,6:Ea,16:Ne,22:Ne,48:Ne};function Lt(r,t={offset:0}){let e=r[t.offset]&xa;if(t.offset++,Ro[e]!=null)return Ro[e](r,t);throw new Error("No decoder for tag "+e)}function ke(r,t){let e=0;if((r[t.offset]&tn)===tn){let n=r[t.offset]&ga,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Ne(r,t){ke(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Lt(r,t);if(n===null)break;e.push(n)}return e}function wa(r,t){let e=ke(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Ea(r,t){let e=ke(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let u=r[t.offset];if(t.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function Sa(r,t){return t.offset++,null}function Aa(r,t){let e=ke(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function va(r,t){let e=ke(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Ba(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new rt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function en(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Ba(r.byteLength);return new rt(Uint8Array.from([t.byteLength|tn]),t)}function yt(r){let t=new rt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new rt(Uint8Array.from([2]),en(t),t)}function rr(r){let t=Uint8Array.from([0]),e=new rt(t,r);return new rt(Uint8Array.from([3]),en(e),e)}function Ot(r,t=48){let e=new rt;for(let n of r)e.append(n);return new rt(Uint8Array.from([t]),en(e),e)}var Ko="1.2.840.10045.3.1.7",Uo="1.3.132.0.34",Po="1.3.132.0.35";async function No(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Ia=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),La=Uint8Array.from([6,5,43,129,4,0,34]),_a=Uint8Array.from([6,5,43,129,4,0,35]),Ca={ext:!0,kty:"EC",crv:"P-256"},Da={ext:!0,kty:"EC",crv:"P-384"},Ta={ext:!0,kty:"EC",crv:"P-521"},rn=32,nn=48,on=66;function ko(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===rn*2+1)return n=J(t.subarray(e,e+rn),"base64url"),o=J(t.subarray(e+rn),"base64url"),new be({...Ca,key_ops:["verify"],x:n,y:o});if(t.byteLength===nn*2+1)return n=J(t.subarray(e,e+nn),"base64url"),o=J(t.subarray(e+nn),"base64url"),new be({...Da,key_ops:["verify"],x:n,y:o});if(t.byteLength===on*2+1)return n=J(t.subarray(e,e+on),"base64url"),o=J(t.subarray(e+on),"base64url"),new be({...Ta,key_ops:["verify"],x:n,y:o});throw new tt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Oo(r){return Ot([yt(Uint8Array.from([1])),Ot([Ra(r.crv)],160),Ot([rr(new rt(Uint8Array.from([4]),$(r.x??"","base64url"),$(r.y??"","base64url")))],161)]).subarray()}function Ra(r){if(r==="P-256")return Ia;if(r==="P-384")return La;if(r==="P-521")return _a;throw new tt(`Invalid curve ${r}`)}var be=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Oo(this.jwk)),this._raw}toMultihash(){return It.digest(xe(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}async verify(t,e){return No(this.jwk,e,t)}};function Mo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ka(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ge(r,...t){if(!Ka(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Ho(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mo(r.outputLen),Mo(r.blockLen)}function we(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function qo(r,t){ge(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Xt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function nr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function vt(r,t){return r<<32-t|r>>>t}var ul=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function Vo(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Oe(r){return typeof r=="string"&&(r=Vo(r)),ge(r),r}function sn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ge(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Ee=class{clone(){return this._cloneInto()}};function or(r){let t=n=>r().update(Oe(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function sr(r=32){if(Xt&&typeof Xt.getRandomValues=="function")return Xt.getRandomValues(new Uint8Array(r));if(Xt&&typeof Xt.randomBytes=="function")return Uint8Array.from(Xt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Ua(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,u=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+u,a,n)}function Fo(r,t,e){return r&t^~r&e}function zo(r,t,e){return r&t^r&e^t&e}var Se=class extends Ee{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=nr(this.buffer)}update(t){we(this);let{view:e,buffer:n,blockLen:o}=this;t=Oe(t);let s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=nr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){we(this),qo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Ua(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=nr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Pa=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Mt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),an=class extends Se{constructor(t=32){super(64,t,8,!1),this.A=Mt[0]|0,this.B=Mt[1]|0,this.C=Mt[2]|0,this.D=Mt[3]|0,this.E=Mt[4]|0,this.F=Mt[5]|0,this.G=Mt[6]|0,this.H=Mt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)Ht[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let m=Ht[l-15],S=Ht[l-2],E=vt(m,7)^vt(m,18)^m>>>3,y=vt(S,17)^vt(S,19)^S>>>10;Ht[l]=y+Ht[l-7]+E+Ht[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let m=vt(a,6)^vt(a,11)^vt(a,25),S=f+m+Fo(a,c,u)+Pa[l]+Ht[l]|0,y=(vt(n,2)^vt(n,13)^vt(n,22))+zo(n,o,s)|0;f=u,u=c,c=a,a=i+S|0,i=s,s=o,o=n,n=S+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,u,f)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var $t=or(()=>new an);var ir=BigInt(4294967295),cn=BigInt(32);function Go(r,t=!1){return t?{h:Number(r&ir),l:Number(r>>cn&ir)}:{h:Number(r>>cn&ir)|0,l:Number(r&ir)|0}}function Na(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Go(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var ka=(r,t)=>BigInt(r>>>0)<<cn|BigInt(t>>>0),Oa=(r,t,e)=>r>>>e,Ma=(r,t,e)=>r<<32-e|t>>>e,Ha=(r,t,e)=>r>>>e|t<<32-e,qa=(r,t,e)=>r<<32-e|t>>>e,Va=(r,t,e)=>r<<64-e|t>>>e-32,Fa=(r,t,e)=>r>>>e-32|t<<64-e,za=(r,t)=>t,Ga=(r,t)=>r,ja=(r,t,e)=>r<<e|t>>>32-e,Za=(r,t,e)=>t<<e|r>>>32-e,Wa=(r,t,e)=>t<<e-32|r>>>64-e,Ya=(r,t,e)=>r<<e-32|t>>>64-e;function Xa(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var $a=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Ja=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Qa=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),tc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,ec=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),rc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var nc={fromBig:Go,split:Na,toBig:ka,shrSH:Oa,shrSL:Ma,rotrSH:Ha,rotrSL:qa,rotrBH:Va,rotrBL:Fa,rotr32H:za,rotr32L:Ga,rotlSH:ja,rotlSL:Za,rotlBH:Wa,rotlBL:Ya,add:Xa,add3L:$a,add3H:Ja,add4L:Qa,add4H:tc,add5H:rc,add5L:ec},U=nc;var[oc,sc]=U.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),qt=new Uint32Array(80),Vt=new Uint32Array(80),fn=class extends Se{constructor(t=64){super(128,t,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:m,Gh:S,Gl:E,Hh:y,Hl:h}=this;return[t,e,n,o,s,i,a,c,u,f,l,m,S,E,y,h]}set(t,e,n,o,s,i,a,c,u,f,l,m,S,E,y,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=m|0,this.Gh=S|0,this.Gl=E|0,this.Hh=y|0,this.Hl=h|0}process(t,e){for(let p=0;p<16;p++,e+=4)qt[p]=t.getUint32(e),Vt[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let B=qt[p-15]|0,R=Vt[p-15]|0,T=U.rotrSH(B,R,1)^U.rotrSH(B,R,8)^U.shrSH(B,R,7),L=U.rotrSL(B,R,1)^U.rotrSL(B,R,8)^U.shrSL(B,R,7),_=qt[p-2]|0,C=Vt[p-2]|0,z=U.rotrSH(_,C,19)^U.rotrBH(_,C,61)^U.shrSH(_,C,6),H=U.rotrSL(_,C,19)^U.rotrBL(_,C,61)^U.shrSL(_,C,6),N=U.add4L(L,H,Vt[p-7],Vt[p-16]),et=U.add4H(N,T,z,qt[p-7],qt[p-16]);qt[p]=et|0,Vt[p]=N|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:m,Fh:S,Fl:E,Gh:y,Gl:h,Hh:x,Hl:v}=this;for(let p=0;p<80;p++){let B=U.rotrSH(l,m,14)^U.rotrSH(l,m,18)^U.rotrBH(l,m,41),R=U.rotrSL(l,m,14)^U.rotrSL(l,m,18)^U.rotrBL(l,m,41),T=l&S^~l&y,L=m&E^~m&h,_=U.add5L(v,R,L,sc[p],Vt[p]),C=U.add5H(_,x,B,T,oc[p],qt[p]),z=_|0,H=U.rotrSH(n,o,28)^U.rotrBH(n,o,34)^U.rotrBH(n,o,39),N=U.rotrSL(n,o,28)^U.rotrBL(n,o,34)^U.rotrBL(n,o,39),et=n&s^n&a^s&a,w=o&i^o&c^i&c;x=y|0,v=h|0,y=S|0,h=E|0,S=l|0,E=m|0,{h:l,l:m}=U.add(u|0,f|0,C|0,z|0),u=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=U.add3L(z,N,w);n=U.add3H(I,C,H,et),o=I|0}({h:n,l:o}=U.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=U.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=U.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=U.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:m}=U.add(this.Eh|0,this.El|0,l|0,m|0),{h:S,l:E}=U.add(this.Fh|0,this.Fl|0,S|0,E|0),{h:y,l:h}=U.add(this.Gh|0,this.Gl|0,y|0,h|0),{h:x,l:v}=U.add(this.Hh|0,this.Hl|0,x|0,v|0),this.set(n,o,s,i,a,c,u,f,l,m,S,E,y,h,x,v)}roundClean(){qt.fill(0),Vt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var un=or(()=>new fn);var pn=BigInt(0),dn=BigInt(1);function Jt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function mn(r){if(!Jt(r))throw new Error("Uint8Array expected")}function _t(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Me(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Wo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?pn:BigInt("0x"+r)}var Yo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ic=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Ft(r){if(mn(r),Yo)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=ic[r[e]];return t}var Tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function jo(r){if(r>=Tt._0&&r<=Tt._9)return r-Tt._0;if(r>=Tt.A&&r<=Tt.F)return r-(Tt.A-10);if(r>=Tt.a&&r<=Tt.f)return r-(Tt.a-10)}function He(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Yo)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=jo(r.charCodeAt(s)),a=jo(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Rt(r){return Wo(Ft(r))}function Qt(r){return mn(r),Wo(Ft(Uint8Array.from(r).reverse()))}function te(r,t){return He(r.toString(16).padStart(t*2,"0"))}function Ae(r,t){return te(r,t).reverse()}function Z(r,t,e){let n;if(typeof t=="string")try{n=He(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Jt(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function zt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];mn(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var ln=r=>typeof r=="bigint"&&pn<=r;function ar(r,t,e){return ln(r)&&ln(t)&&ln(e)&&t<=r&&r<e}function gt(r,t,e,n){if(!ar(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Xo(r){let t;for(t=0;r>pn;r>>=dn,t+=1);return t}var ee=r=>(dn<<BigInt(r))-dn,hn=r=>new Uint8Array(r),Zo=r=>Uint8Array.from(r);function $o(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=hn(r),o=hn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=hn(0))=>{o=a(Zo([0]),l),n=a(),l.length!==0&&(o=a(Zo([1]),l),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,m=[];for(;l<t;){n=a();let S=n.slice();m.push(S),l+=n.length}return zt(...m)};return(l,m)=>{i(),c(l);let S;for(;!(S=m(u()));)c();return i(),S}}var ac={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Jt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Kt(r,t,e={}){let n=(o,s,i)=>{let a=ac[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function ve(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var nt=BigInt(0),G=BigInt(1),re=BigInt(2),cc=BigInt(3),yn=BigInt(4),Jo=BigInt(5),Qo=BigInt(8),fc=BigInt(9),uc=BigInt(16);function F(r,t){let e=r%t;return e>=nt?e:t+e}function lc(r,t,e){if(t<nt)throw new Error("invalid exponent, negatives unsupported");if(e<=nt)throw new Error("invalid modulus");if(e===G)return nt;let n=G;for(;t>nt;)t&G&&(n=n*r%e),r=r*r%e,t>>=G;return n}function j(r,t,e){let n=r;for(;t-- >nt;)n*=n,n%=e;return n}function cr(r,t){if(r===nt)throw new Error("invert: expected non-zero number");if(t<=nt)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=nt,s=G,i=G,a=nt;for(;e!==nt;){let u=n/e,f=n%e,l=o-i*u,m=s-a*u;n=e,e=f,o=i,s=a,i=l,a=m}if(n!==G)throw new Error("invert: does not exist");return F(o,t)}function hc(r){let t=(r-G)/re,e,n,o;for(e=r-G,n=0;e%re===nt;e/=re,n++);for(o=re;o<r&&lc(o,t,r)!==r-G;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+G)/yn;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(e+G)/re;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,o),e),l=a.pow(c,s),m=a.pow(c,e);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let S=1;for(let y=a.sqr(m);S<u&&!a.eql(y,a.ONE);S++)y=a.sqr(y);let E=a.pow(f,G<<BigInt(u-S-1));f=a.sqr(E),l=a.mul(l,E),m=a.mul(m,f),u=S}return l}}function dc(r){if(r%yn===cc){let t=(r+G)/yn;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Qo===Jo){let t=(r-Jo)/Qo;return function(n,o){let s=n.mul(o,re),i=n.pow(s,t),a=n.mul(o,i),c=n.mul(n.mul(a,re),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),o))throw new Error("Cannot find square root");return u}}return r%uc,hc(r)}var ts=(r,t)=>(F(r,t)&G)===G,pc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bn(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=pc.reduce((n,o)=>(n[o]="function",n),t);return Kt(r,e)}function mc(r,t,e){if(e<nt)throw new Error("invalid exponent, negatives unsupported");if(e===nt)return r.ONE;if(e===G)return t;let n=r.ONE,o=t;for(;e>nt;)e&G&&(n=r.mul(n,o)),o=r.sqr(o),e>>=G;return n}function yc(r,t){let e=new Array(t.length),n=t.reduce((s,i,a)=>r.is0(i)?s:(e[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,a)=>r.is0(i)?s:(e[a]=r.mul(s,e[a]),r.mul(s,i)),o),e}function xn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Gt(r,t,e=!1,n={}){if(r<=nt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=xn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:ee(o),ZERO:nt,ONE:G,create:c=>F(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return nt<=c&&c<r},is0:c=>c===nt,isOdd:c=>(c&G)===G,neg:c=>F(-c,r),eql:(c,u)=>c===u,sqr:c=>F(c*c,r),add:(c,u)=>F(c+u,r),sub:(c,u)=>F(c-u,r),mul:(c,u)=>F(c*u,r),pow:(c,u)=>mc(a,c,u),div:(c,u)=>F(c*cr(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>cr(c,r),sqrt:n.sqrt||(c=>(i||(i=dc(r)),i(a,c))),invertBatch:c=>yc(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>e?Ae(c,s):te(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?Qt(c):Rt(c)}});return Object.freeze(a)}function es(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function gn(r){let t=es(r);return t+Math.ceil(t/2)}function rs(r,t,e=!1){let n=r.length,o=es(t),s=gn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Qt(r):Rt(r),a=F(i,t-G)+G;return e?Ae(a,o):te(a,o)}var ns=BigInt(0),vn=BigInt(1);function wn(r,t){let e=t.negate();return r?e:t}function ss(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function En(r,t){ss(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=ee(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function os(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=vn);let u=t*n,f=u+Math.abs(a)-1,l=a===0,m=a<0,S=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:m,isNegF:S,offsetF:u}}function bc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function xc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Sn=new WeakMap,is=new WeakMap;function An(r){return is.get(r)||1}function fr(r,t){return{constTimeNegate:wn,hasPrecomputes(e){return An(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>ns;)n&vn&&(o=o.add(s)),s=s.double(),n>>=vn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=En(n,t),i=[],a=e,c=a;for(let u=0;u<o;u++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=En(e,t);for(let c=0;c<a.windows;c++){let{nextN:u,offset:f,isZero:l,isNeg:m,isNegF:S,offsetF:E}=os(o,c,a);o=u,l?i=i.add(wn(S,n[E])):s=s.add(wn(m,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=En(e,t);for(let a=0;a<i.windows&&o!==ns;a++){let{nextN:c,offset:u,isZero:f,isNeg:l}=os(o,a,i);if(o=c,!f){let m=n[u];s=s.add(l?m.negate():m)}}return s},getPrecomputes(e,n,o){let s=Sn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Sn.set(n,o(s))),s},wNAFCached(e,n,o){let s=An(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=An(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){ss(n,t),is.set(e,n),Sn.delete(e)}}}function ur(r,t,e,n){if(bc(e,r),xc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Xo(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,a=ee(i),c=new Array(Number(a)+1).fill(o),u=Math.floor((t.BITS-1)/i)*i,f=o;for(let l=u;l>=0;l-=i){c.fill(o);for(let S=0;S<n.length;S++){let E=n[S],y=Number(E>>BigInt(l)&a);c[y]=c[y].add(e[S])}let m=o;for(let S=c.length-1,E=o;S>0;S--)E=E.add(c[S]),m=m.add(E);if(f=f.add(m),l!==0)for(let S=0;S<i;S++)f=f.double()}return f}function qe(r){return bn(r.Fp),Kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ct=BigInt(0),ht=BigInt(1),as=BigInt(2),gc=BigInt(8),wc={zip215:!0};function Ec(r){let t=qe(r);return Kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function cs(r){let t=Ec(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,u=as<<BigInt(a*8)-ht,f=e.create,l=Gt(t.n,t.nBitLength),m=t.uvRatio||((b,d)=>{try{return{isValid:!0,value:e.sqrt(b*e.inv(d))}}catch{return{isValid:!1,value:Ct}}}),S=t.adjustScalarBytes||(b=>b),E=t.domain||((b,d,g)=>{if(_t("phflag",g),d.length||g)throw new Error("Contexts/pre-hash are not supported");return b});function y(b,d,g=!1){let A=g?ht:Ct;gt("coordinate "+b,d,A,u)}function h(b){if(!(b instanceof p))throw new Error("ExtendedPoint expected")}let x=ve((b,d)=>{let{ex:g,ey:A,ez:K}=b,P=b.is0();d==null&&(d=P?gc:e.inv(K));let k=f(g*d),O=f(A*d),M=f(K*d);if(P)return{x:Ct,y:ht};if(M!==ht)throw new Error("invZ was invalid");return{x:k,y:O}}),v=ve(b=>{let{a:d,d:g}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:A,ey:K,ez:P,et:k}=b,O=f(A*A),M=f(K*K),V=f(P*P),Q=f(V*V),Y=f(O*d),it=f(V*f(Y+M)),dt=f(Q+f(g*f(O*M)));if(it!==dt)throw new Error("bad point: equation left != right (1)");let ot=f(A*K),at=f(P*k);if(ot!==at)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(d,g,A,K){y("x",d),y("y",g),y("z",A,!0),y("t",K),this.ex=d,this.ey=g,this.ez=A,this.et=K,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof p)throw new Error("extended point not allowed");let{x:g,y:A}=d||{};return y("x",g),y("y",A),new p(g,A,ht,f(g*A))}static normalizeZ(d){let g=e.invertBatch(d.map(A=>A.ez));return d.map((A,K)=>A.toAffine(g[K])).map(p.fromAffine)}static msm(d,g){return ur(p,l,d,g)}_setWindowSize(d){T.setWindowSize(this,d)}assertValidity(){v(this)}equals(d){h(d);let{ex:g,ey:A,ez:K}=this,{ex:P,ey:k,ez:O}=d,M=f(g*O),V=f(P*K),Q=f(A*O),Y=f(k*K);return M===V&&Q===Y}is0(){return this.equals(p.ZERO)}negate(){return new p(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:g,ey:A,ez:K}=this,P=f(g*g),k=f(A*A),O=f(as*f(K*K)),M=f(d*P),V=g+A,Q=f(f(V*V)-P-k),Y=M+k,it=Y-O,dt=M-k,ot=f(Q*it),at=f(Y*dt),xt=f(Q*dt),Et=f(it*Y);return new p(ot,at,Et,xt)}add(d){h(d);let{a:g,d:A}=t,{ex:K,ey:P,ez:k,et:O}=this,{ex:M,ey:V,ez:Q,et:Y}=d,it=f(K*M),dt=f(P*V),ot=f(O*A*Y),at=f(k*Q),xt=f((K+P)*(M+V)-it-dt),Et=at-ot,Ce=at+ot,ao=f(dt-g*it),oi=f(xt*Et),si=f(Ce*ao),ii=f(xt*ao),ai=f(Et*Ce);return new p(oi,si,ai,ii)}subtract(d){return this.add(d.negate())}wNAF(d){return T.wNAFCached(this,d,p.normalizeZ)}multiply(d){let g=d;gt("scalar",g,ht,n);let{p:A,f:K}=this.wNAF(g);return p.normalizeZ([A,K])[0]}multiplyUnsafe(d,g=p.ZERO){let A=d;return gt("scalar",A,Ct,n),A===Ct?R:this.is0()||A===ht?this:T.wNAFCachedUnsafe(this,A,p.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(d){return x(this,d)}clearCofactor(){let{h:d}=t;return d===ht?this:this.multiplyUnsafe(d)}static fromHex(d,g=!1){let{d:A,a:K}=t,P=e.BYTES;d=Z("pointHex",d,P),_t("zip215",g);let k=d.slice(),O=d[P-1];k[P-1]=O&-129;let M=Qt(k),V=g?u:e.ORDER;gt("pointHex.y",M,Ct,V);let Q=f(M*M),Y=f(Q-ht),it=f(A*Q-K),{isValid:dt,value:ot}=m(Y,it);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let at=(ot&ht)===ht,xt=(O&128)!==0;if(!g&&ot===Ct&&xt)throw new Error("Point.fromHex: x=0 and x_0=1");return xt!==at&&(ot=f(-ot)),p.fromAffine({x:ot,y:M})}static fromPrivateKey(d){let{scalar:g}=C(d);return B.multiply(g)}toRawBytes(){let{x:d,y:g}=this.toAffine(),A=Ae(g,e.BYTES);return A[A.length-1]|=d&ht?128:0,A}toHex(){return Ft(this.toRawBytes())}}p.BASE=new p(t.Gx,t.Gy,ht,f(t.Gx*t.Gy)),p.ZERO=new p(Ct,ht,ht,Ct);let{BASE:B,ZERO:R}=p,T=fr(p,a*8);function L(b){return F(b,n)}function _(b){return L(Qt(b))}function C(b){let d=e.BYTES;b=Z("private key",b,d);let g=Z("hashed private key",s(b),2*d),A=S(g.slice(0,d)),K=g.slice(d,2*d),P=_(A);return{head:A,prefix:K,scalar:P}}function z(b){let{head:d,prefix:g,scalar:A}=C(b),K=B.multiply(A),P=K.toRawBytes();return{head:d,prefix:g,scalar:A,point:K,pointBytes:P}}function H(b){return z(b).pointBytes}function N(b=new Uint8Array,...d){let g=zt(...d);return _(s(E(g,Z("context",b),!!o)))}function et(b,d,g={}){b=Z("message",b),o&&(b=o(b));let{prefix:A,scalar:K,pointBytes:P}=z(d),k=N(g.context,A,b),O=B.multiply(k).toRawBytes(),M=N(g.context,O,P,b),V=L(k+M*K);gt("signature.s",V,Ct,n);let Q=zt(O,Ae(V,e.BYTES));return Z("result",Q,e.BYTES*2)}let w=wc;function I(b,d,g,A=w){let{context:K,zip215:P}=A,k=e.BYTES;b=Z("signature",b,2*k),d=Z("message",d),g=Z("publicKey",g,k),P!==void 0&&_t("zip215",P),o&&(d=o(d));let O=Qt(b.slice(k,2*k)),M,V,Q;try{M=p.fromHex(g,P),V=p.fromHex(b.slice(0,k),P),Q=B.multiplyUnsafe(O)}catch{return!1}if(!P&&M.isSmallOrder())return!1;let Y=N(K,V.toRawBytes(),M.toRawBytes(),d);return V.add(M.multiplyUnsafe(Y)).subtract(Q).clearCofactor().equals(p.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:H,sign:et,verify:I,ExtendedPoint:p,utils:{getExtendedPublicKey:z,randomPrivateKey:()=>i(e.BYTES),precompute(b=8,d=p.BASE){return d._setWindowSize(b),d.multiply(BigInt(3)),d}}}}var Bn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),fs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Gl=BigInt(0),Sc=BigInt(1),us=BigInt(2),jl=BigInt(3),Ac=BigInt(5),vc=BigInt(8);function Bc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Bn,a=r*r%s*r%s,c=j(a,us,s)*a%s,u=j(c,Sc,s)*r%s,f=j(u,Ac,s)*u%s,l=j(f,t,s)*f%s,m=j(l,e,s)*l%s,S=j(m,n,s)*m%s,E=j(S,o,s)*S%s,y=j(E,o,s)*S%s,h=j(y,t,s)*f%s;return{pow_p_5_8:j(h,us,s)*r%s,b2:a}}function Ic(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Lc(r,t){let e=Bn,n=F(t*t*t,e),o=F(n*n*t,e),s=Bc(r*o).pow_p_5_8,i=F(r*n*s,e),a=F(t*i*i,e),c=i,u=F(i*fs,e),f=a===r,l=a===F(-r,e),m=a===F(-r*fs,e);return f&&(i=c),(l||m)&&(i=u),ts(i,e)&&(i=F(-i,e)),{isValid:f||l,value:i}}var ls=Gt(Bn,void 0,!0),_c={a:ls.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ls,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:vc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:un,randomBytes:sr,adjustScalarBytes:Ic,uvRatio:Lc},hs=cs(_c);var Be=32;function ds(r,t,e){return hs.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var lr=class{type="Ed25519";raw;constructor(t){this.raw=In(t,Be)}toMultihash(){return It.digest(xe(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e){return ds(this.raw,e,t)}};function ys(r){return r=In(r,Be),new lr(r)}function In(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new tt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Cc=Math.pow(2,7),Dc=Math.pow(2,14),Tc=Math.pow(2,21),Ln=Math.pow(2,28),_n=Math.pow(2,35),Cn=Math.pow(2,42),Dn=Math.pow(2,49),q=128,ut=127;function Ut(r){if(r<Cc)return 1;if(r<Dc)return 2;if(r<Tc)return 3;if(r<Ln)return 4;if(r<_n)return 5;if(r<Cn)return 6;if(r<Dn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Tn(r,t,e=0){switch(Ut(r)){case 8:t[e++]=r&255|q,r/=128;case 7:t[e++]=r&255|q,r/=128;case 6:t[e++]=r&255|q,r/=128;case 5:t[e++]=r&255|q,r/=128;case 4:t[e++]=r&255|q,r>>>=7;case 3:t[e++]=r&255|q,r>>>=7;case 2:t[e++]=r&255|q,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Rc(r,t,e=0){switch(Ut(r)){case 8:t.set(e++,r&255|q),r/=128;case 7:t.set(e++,r&255|q),r/=128;case 6:t.set(e++,r&255|q),r/=128;case 5:t.set(e++,r&255|q),r/=128;case 4:t.set(e++,r&255|q),r>>>=7;case 3:t.set(e++,r&255|q),r>>>=7;case 2:t.set(e++,r&255|q),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Rn(r,t){let e=r[t],n=0;if(n+=e&ut,e<q||(e=r[t+1],n+=(e&ut)<<7,e<q)||(e=r[t+2],n+=(e&ut)<<14,e<q)||(e=r[t+3],n+=(e&ut)<<21,e<q)||(e=r[t+4],n+=(e&ut)*Ln,e<q)||(e=r[t+5],n+=(e&ut)*_n,e<q)||(e=r[t+6],n+=(e&ut)*Cn,e<q)||(e=r[t+7],n+=(e&ut)*Dn,e<q))return n;throw new RangeError("Could not decode varint")}function Kc(r,t){let e=r.get(t),n=0;if(n+=e&ut,e<q||(e=r.get(t+1),n+=(e&ut)<<7,e<q)||(e=r.get(t+2),n+=(e&ut)<<14,e<q)||(e=r.get(t+3),n+=(e&ut)<<21,e<q)||(e=r.get(t+4),n+=(e&ut)*Ln,e<q)||(e=r.get(t+5),n+=(e&ut)*_n,e<q)||(e=r.get(t+6),n+=(e&ut)*Cn,e<q)||(e=r.get(t+7),n+=(e&ut)*Dn,e<q))return n;throw new RangeError("Could not decode varint")}function bs(r,t,e=0){return t==null&&(t=mt(Ut(r))),t instanceof Uint8Array?Tn(r,t,e):Rc(r,t,e)}function xs(r,t=0){return r instanceof Uint8Array?Rn(r,t):Kc(r,t)}var Kn=new Float32Array([-0]),jt=new Uint8Array(Kn.buffer);function gs(r,t,e){Kn[0]=r,t[e]=jt[0],t[e+1]=jt[1],t[e+2]=jt[2],t[e+3]=jt[3]}function ws(r,t){return jt[0]=r[t],jt[1]=r[t+1],jt[2]=r[t+2],jt[3]=r[t+3],Kn[0]}var Un=new Float64Array([-0]),lt=new Uint8Array(Un.buffer);function Es(r,t,e){Un[0]=r,t[e]=lt[0],t[e+1]=lt[1],t[e+2]=lt[2],t[e+3]=lt[3],t[e+4]=lt[4],t[e+5]=lt[5],t[e+6]=lt[6],t[e+7]=lt[7]}function Ss(r,t){return lt[0]=r[t],lt[1]=r[t+1],lt[2]=r[t+2],lt[3]=r[t+3],lt[4]=r[t+4],lt[5]=r[t+5],lt[6]=r[t+6],lt[7]=r[t+7],Un[0]}var Pc=BigInt(Number.MAX_SAFE_INTEGER),Nc=BigInt(Number.MIN_SAFE_INTEGER),wt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ne;if(t<Pc&&t>Nc)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>As&&(o=0n,++n>As&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ne;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ne}},ne=new wt(0,0);ne.toBigInt=function(){return 0n};ne.zzEncode=ne.zzDecode=function(){return this};ne.length=function(){return 1};var As=4294967296n;function vs(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Bs(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Pn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Bt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function hr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Nn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Bt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Bt(this,4);return hr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Bt(this,4);return hr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Bt(this,4);let t=ws(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Bt(this,4);let t=Ss(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Bt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Bs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Bt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Bt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new wt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Bt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Bt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Bt(this,8);let t=hr(this.buf,this.pos+=4),e=hr(this.buf,this.pos+=4);return new wt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Rn(this.buf,this.pos);return this.pos+=Ut(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 kn(r){return new Nn(r instanceof Uint8Array?r:r.subarray())}function oe(r,t,e){let n=kn(r);return t.decode(n,void 0,e)}function On(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return mt(i);o+i>t&&(n=mt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var se=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Mn(){}var qn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},kc=On();function Oc(r){return globalThis.Buffer!=null?mt(r):kc(r)}var Fe=class{len;head;tail;states;constructor(){this.len=0,this.head=new se(Mn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new se(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Vn((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(dr,10,wt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=wt.fromBigInt(t);return this._push(dr,e.length(),e)}uint64Number(t){return this._push(Tn,Ut(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=wt.fromBigInt(t).zzEncode();return this._push(dr,e.length(),e)}sint64Number(t){let e=wt.fromNumber(t).zzEncode();return this._push(dr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Hn,1,t?1:0)}fixed32(t){return this._push(Ve,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=wt.fromBigInt(t);return this._push(Ve,4,e.lo)._push(Ve,4,e.hi)}fixed64Number(t){let e=wt.fromNumber(t);return this._push(Ve,4,e.lo)._push(Ve,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(gs,4,t)}double(t){return this._push(Es,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Hn,1,0):this.uint32(e)._push(Hc,e,t)}string(t){let e=vs(t);return e!==0?this.uint32(e)._push(Pn,e,t):this._push(Hn,1,0)}fork(){return this.states=new qn(this),this.head=this.tail=new se(Mn,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 se(Mn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Oc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Hn(r,t,e){t[e]=r&255}function Mc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Vn=class extends se{next;constructor(t,e){super(Mc,t,e),this.next=void 0}};function dr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Ve(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Hc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Fe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(qc,t,r),this},Fe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Vc,t,r),this});function qc(r,t,e){t.set(r,e)}function Vc(r,t,e){r.length<40?Pn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($(r),e)}function Fn(){return new Fe}function ie(r,t){let e=Fn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ie;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ie||(Ie={}));function pr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ze(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return pr("enum",Ie.VARINT,e,n)}function ae(r,t){return pr("message",Ie.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(bt||(bt={}));var zn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(zn||(zn={}));(function(r){r.codec=()=>ze(zn)})(bt||(bt={}));var Zt;(function(r){let t;r.codec=()=>(t==null&&(t=ae((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Zt||(Zt={}));var Gn;(function(r){let t;r.codec=()=>(t==null&&(t=ae((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Gn||(Gn={}));var Ge=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},mr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var _s={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new mr("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 Wt=_s;var Ze={};pt(Ze,{MAX_RSA_KEY_SIZE:()=>jn,generateRSAKeyPair:()=>Ks,jwkToJWKKeyPair:()=>Us,jwkToPkcs1:()=>jc,jwkToPkix:()=>Xn,jwkToRSAPrivateKey:()=>Jn,pkcs1MessageToJwk:()=>Wn,pkcs1MessageToRSAPrivateKey:()=>$n,pkcs1ToJwk:()=>Gc,pkcs1ToRSAPrivateKey:()=>Ts,pkixMessageToJwk:()=>Yn,pkixMessageToRSAPublicKey:()=>yr,pkixToJwk:()=>Zc,pkixToRSAPublicKey:()=>Rs});var Le=class{type="RSA";jwk;_raw;_multihash;constructor(t,e){this.jwk=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=Ze.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ct.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e){return Ds(this.jwk,e,t)}},je=class{type="RSA";jwk;_raw;publicKey;constructor(t,e){this.jwk=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=Ze.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}sign(t){return Cs(this.jwk,t)}};var jn=8192,Zn=18,Fc=1062,zc=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Gc(r){let t=Lt(r);return Wn(t)}function Wn(r){return{n:J(r[1],"base64url"),e:J(r[2],"base64url"),d:J(r[3],"base64url"),p:J(r[4],"base64url"),q:J(r[5],"base64url"),dp:J(r[6],"base64url"),dq:J(r[7],"base64url"),qi:J(r[8],"base64url"),kty:"RSA"}}function jc(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new tt("JWK was missing components");return Ot([yt(Uint8Array.from([0])),yt($(r.n,"base64url")),yt($(r.e,"base64url")),yt($(r.d,"base64url")),yt($(r.p,"base64url")),yt($(r.q,"base64url")),yt($(r.dp,"base64url")),yt($(r.dq,"base64url")),yt($(r.qi,"base64url"))]).subarray()}function Zc(r){let t=Lt(r,{offset:0});return Yn(t)}function Yn(r){let t=Lt(r[1],{offset:0});return{kty:"RSA",n:J(t[0],"base64url"),e:J(t[1],"base64url")}}function Xn(r){if(r.n==null||r.e==null)throw new tt("JWK was missing components");return Ot([zc,rr(Ot([yt($(r.n,"base64url")),yt($(r.e,"base64url"))]))]).subarray()}function Ts(r){let t=Lt(r);return $n(t)}function $n(r){let t=Wn(r);return Jn(t)}function Rs(r,t){if(r.byteLength>=Fc)throw new fe("Key size is too large");let e=Lt(r,{offset:0});return yr(e,r,t)}function yr(r,t,e){let n=Yn(r);if(e==null){let o=$t(Zt.encode({Type:bt.RSA,Data:t}));e=St(Zn,o)}return new Le(n,e)}function Jn(r){if(Ns(r)>jn)throw new tt("Key size is too large");let t=Us(r),e=$t(Zt.encode({Type:bt.RSA,Data:Xn(t.publicKey)})),n=St(Zn,e);return new je(t.privateKey,new Le(t.publicKey,n))}async function Ks(r){if(r>jn)throw new tt("Key size is too large");let t=await Ps(r),e=$t(Zt.encode({Type:bt.RSA,Data:Xn(t.publicKey)})),n=St(Zn,e);return new je(t.privateKey,new Le(t.publicKey,n))}function Us(r){if(r==null)throw new tt("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var ks="1.2.840.113549.1.1.1";async function Ps(r){let t=await Wt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Wc(t);return{privateKey:e[0],publicKey:e[1]}}async function Cs(r,t){let e=await Wt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Wt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ds(r,t,e){let n=await Wt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Wt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Wc(r){if(r.privateKey==null||r.publicKey==null)throw new tt("Private and public key are required");return Promise.all([Wt.get().subtle.exportKey("jwk",r.privateKey),Wt.get().subtle.exportKey("jwk",r.publicKey)])}function Ns(r){if(r.kty!=="RSA")throw new tt("invalid key type");if(r.n==null)throw new tt("invalid key modulus");return $(r.n,"base64url").length*8}var br=class extends Ee{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ho(t);let n=Oe(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return we(this),this.iHash.update(t),this}digestInto(t){we(this),ge(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Qn=(r,t,e)=>new br(r,t).update(e).digest();Qn.create=(r,t)=>new br(r,t);function Os(r){r.lowS!==void 0&&_t("lowS",r.lowS),r.prehash!==void 0&&_t("prehash",r.prehash)}function Yc(r){let t=qe(r);Kt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var to=class extends Error{constructor(t=""){super(t)}},Pt={Err:to,_tlv:{encode:(r,t)=>{let{Err:e}=Pt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Me(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Me(o.length/2|128):"";return Me(r)+s+o+t},decode(r,t){let{Err:e}=Pt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+c);if(u.length!==c)throw new e("tlv.decode: length bytes not complete");if(u[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of u)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Pt;if(r<Nt)throw new t("integer: negative integers are not allowed");let e=Me(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Pt;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Rt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Pt,o=Z("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:u,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(u)}},hexFromSig(r){let{_tlv:t,_int:e}=Pt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Nt=BigInt(0),st=BigInt(1),xd=BigInt(2),Ms=BigInt(3),gd=BigInt(4);function Xc(r){let t=Yc(r),{Fp:e}=t,n=Gt(t.n,t.nBitLength),o=t.toBytes||((y,h,x)=>{let v=h.toAffine();return zt(Uint8Array.from([4]),e.toBytes(v.x),e.toBytes(v.y))}),s=t.fromBytes||(y=>{let h=y.subarray(1),x=e.fromBytes(h.subarray(0,e.BYTES)),v=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x,y:v}});function i(y){let{a:h,b:x}=t,v=e.sqr(y),p=e.mul(v,y);return e.add(e.add(p,e.mul(y,h)),x)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return ar(y,st,t.n)}function c(y){let{allowedPrivateKeyLengths:h,nByteLength:x,wrapPrivateKey:v,n:p}=t;if(h&&typeof y!="bigint"){if(Jt(y)&&(y=Ft(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(x*2,"0")}let B;try{B=typeof y=="bigint"?y:Rt(Z("private key",y,x))}catch{throw new Error("invalid private key, expected hex or "+x+" bytes, got "+typeof y)}return v&&(B=F(B,p)),gt("private key",B,st,p),B}function u(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}let f=ve((y,h)=>{let{px:x,py:v,pz:p}=y;if(e.eql(p,e.ONE))return{x,y:v};let B=y.is0();h==null&&(h=B?e.ONE:e.inv(p));let R=e.mul(x,h),T=e.mul(v,h),L=e.mul(p,h);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:R,y:T}}),l=ve(y=>{if(y.is0()){if(t.allowInfinityPoint&&!e.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:x}=y.toAffine();if(!e.isValid(h)||!e.isValid(x))throw new Error("bad point: x or y not FE");let v=e.sqr(x),p=i(h);if(!e.eql(v,p))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(h,x,v){if(h==null||!e.isValid(h))throw new Error("x required");if(x==null||!e.isValid(x))throw new Error("y required");if(v==null||!e.isValid(v))throw new Error("z required");this.px=h,this.py=x,this.pz=v,Object.freeze(this)}static fromAffine(h){let{x,y:v}=h||{};if(!h||!e.isValid(x)||!e.isValid(v))throw new Error("invalid affine point");if(h instanceof m)throw new Error("projective point not allowed");let p=B=>e.eql(B,e.ZERO);return p(x)&&p(v)?m.ZERO:new m(x,v,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let x=e.invertBatch(h.map(v=>v.pz));return h.map((v,p)=>v.toAffine(x[p])).map(m.fromAffine)}static fromHex(h){let x=m.fromAffine(s(Z("pointHex",h)));return x.assertValidity(),x}static fromPrivateKey(h){return m.BASE.multiply(c(h))}static msm(h,x){return ur(m,n,h,x)}_setWindowSize(h){E.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:x,py:v,pz:p}=this,{px:B,py:R,pz:T}=h,L=e.eql(e.mul(x,T),e.mul(B,p)),_=e.eql(e.mul(v,T),e.mul(R,p));return L&&_}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:x}=t,v=e.mul(x,Ms),{px:p,py:B,pz:R}=this,T=e.ZERO,L=e.ZERO,_=e.ZERO,C=e.mul(p,p),z=e.mul(B,B),H=e.mul(R,R),N=e.mul(p,B);return N=e.add(N,N),_=e.mul(p,R),_=e.add(_,_),T=e.mul(h,_),L=e.mul(v,H),L=e.add(T,L),T=e.sub(z,L),L=e.add(z,L),L=e.mul(T,L),T=e.mul(N,T),_=e.mul(v,_),H=e.mul(h,H),N=e.sub(C,H),N=e.mul(h,N),N=e.add(N,_),_=e.add(C,C),C=e.add(_,C),C=e.add(C,H),C=e.mul(C,N),L=e.add(L,C),H=e.mul(B,R),H=e.add(H,H),C=e.mul(H,N),T=e.sub(T,C),_=e.mul(H,z),_=e.add(_,_),_=e.add(_,_),new m(T,L,_)}add(h){u(h);let{px:x,py:v,pz:p}=this,{px:B,py:R,pz:T}=h,L=e.ZERO,_=e.ZERO,C=e.ZERO,z=t.a,H=e.mul(t.b,Ms),N=e.mul(x,B),et=e.mul(v,R),w=e.mul(p,T),I=e.add(x,v),D=e.add(B,R);I=e.mul(I,D),D=e.add(N,et),I=e.sub(I,D),D=e.add(x,p);let b=e.add(B,T);return D=e.mul(D,b),b=e.add(N,w),D=e.sub(D,b),b=e.add(v,p),L=e.add(R,T),b=e.mul(b,L),L=e.add(et,w),b=e.sub(b,L),C=e.mul(z,D),L=e.mul(H,w),C=e.add(L,C),L=e.sub(et,C),C=e.add(et,C),_=e.mul(L,C),et=e.add(N,N),et=e.add(et,N),w=e.mul(z,w),D=e.mul(H,D),et=e.add(et,w),w=e.sub(N,w),w=e.mul(z,w),D=e.add(D,w),N=e.mul(et,D),_=e.add(_,N),N=e.mul(b,D),L=e.mul(I,L),L=e.sub(L,N),N=e.mul(I,et),C=e.mul(b,C),C=e.add(C,N),new m(L,_,C)}subtract(h){return this.add(h.negate())}is0(){return this.equals(m.ZERO)}wNAF(h){return E.wNAFCached(this,h,m.normalizeZ)}multiplyUnsafe(h){let{endo:x,n:v}=t;gt("scalar",h,Nt,v);let p=m.ZERO;if(h===Nt)return p;if(this.is0()||h===st)return this;if(!x||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,h,m.normalizeZ);let{k1neg:B,k1:R,k2neg:T,k2:L}=x.splitScalar(h),_=p,C=p,z=this;for(;R>Nt||L>Nt;)R&st&&(_=_.add(z)),L&st&&(C=C.add(z)),z=z.double(),R>>=st,L>>=st;return B&&(_=_.negate()),T&&(C=C.negate()),C=new m(e.mul(C.px,x.beta),C.py,C.pz),_.add(C)}multiply(h){let{endo:x,n:v}=t;gt("scalar",h,st,v);let p,B;if(x){let{k1neg:R,k1:T,k2neg:L,k2:_}=x.splitScalar(h),{p:C,f:z}=this.wNAF(T),{p:H,f:N}=this.wNAF(_);C=E.constTimeNegate(R,C),H=E.constTimeNegate(L,H),H=new m(e.mul(H.px,x.beta),H.py,H.pz),p=C.add(H),B=z.add(N)}else{let{p:R,f:T}=this.wNAF(h);p=R,B=T}return m.normalizeZ([p,B])[0]}multiplyAndAddUnsafe(h,x,v){let p=m.BASE,B=(T,L)=>L===Nt||L===st||!T.equals(p)?T.multiplyUnsafe(L):T.multiply(L),R=B(this,x).add(B(h,v));return R.is0()?void 0:R}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:x}=t;if(h===st)return!0;if(x)return x(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:x}=t;return h===st?this:x?x(m,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return _t("isCompressed",h),this.assertValidity(),o(m,this,h)}toHex(h=!0){return _t("isCompressed",h),Ft(this.toRawBytes(h))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let S=t.nBitLength,E=fr(m,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function $c(r){let t=qe(r);return Kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Hs(r){let t=$c(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(w){return F(w,n)}function a(w){return cr(w,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:l}=Xc({...t,toBytes(w,I,D){let b=I.toAffine(),d=e.toBytes(b.x),g=zt;return _t("isCompressed",D),D?g(Uint8Array.from([I.hasEvenY()?2:3]),d):g(Uint8Array.from([4]),d,e.toBytes(b.y))},fromBytes(w){let I=w.length,D=w[0],b=w.subarray(1);if(I===o&&(D===2||D===3)){let d=Rt(b);if(!ar(d,st,e.ORDER))throw new Error("Point is not on curve");let g=f(d),A;try{A=e.sqrt(g)}catch(k){let O=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+O)}let K=(A&st)===st;return(D&1)===1!==K&&(A=e.neg(A)),{x:d,y:A}}else if(I===s&&D===4){let d=e.fromBytes(b.subarray(0,e.BYTES)),g=e.fromBytes(b.subarray(e.BYTES,2*e.BYTES));return{x:d,y:g}}else{let d=o,g=s;throw new Error("invalid Point, expected length of "+d+", or uncompressed "+g+", got "+I)}}}),m=w=>Ft(te(w,t.nByteLength));function S(w){let I=n>>st;return w>I}function E(w){return S(w)?i(-w):w}let y=(w,I,D)=>Rt(w.slice(I,D));class h{constructor(I,D,b){gt("r",I,st,n),gt("s",D,st,n),this.r=I,this.s=D,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(I){let D=t.nByteLength;return I=Z("compactSignature",I,D*2),new h(y(I,0,D),y(I,D,2*D))}static fromDER(I){let{r:D,s:b}=Pt.toSig(Z("DER",I));return new h(D,b)}assertValidity(){}addRecoveryBit(I){return new h(this.r,this.s,I)}recoverPublicKey(I){let{r:D,s:b,recovery:d}=this,g=T(Z("msgHash",I));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let A=d===2||d===3?D+t.n:D;if(A>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let K=(d&1)===0?"02":"03",P=c.fromHex(K+m(A)),k=a(A),O=i(-g*k),M=i(b*k),V=c.BASE.multiplyAndAddUnsafe(P,O,M);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return He(this.toDERHex())}toDERHex(){return Pt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return He(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let x={isValidPrivateKey(w){try{return u(w),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let w=gn(t.n);return rs(t.randomBytes(w),t.n)},precompute(w=8,I=c.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function v(w,I=!0){return c.fromPrivateKey(w).toRawBytes(I)}function p(w){let I=Jt(w),D=typeof w=="string",b=(I||D)&&w.length;return I?b===o||b===s:D?b===2*o||b===2*s:w instanceof c}function B(w,I,D=!0){if(p(w))throw new Error("first arg must be private key");if(!p(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(u(w)).toRawBytes(D)}let R=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let I=Rt(w),D=w.length*8-t.nBitLength;return D>0?I>>BigInt(D):I},T=t.bits2int_modN||function(w){return i(R(w))},L=ee(t.nBitLength);function _(w){return gt("num < 2^"+t.nBitLength,w,Nt,L),te(w,t.nByteLength)}function C(w,I,D=z){if(["recovered","canonical"].some(Y=>Y in D))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:d}=t,{lowS:g,prehash:A,extraEntropy:K}=D;g==null&&(g=!0),w=Z("msgHash",w),Os(D),A&&(w=Z("prehashed msgHash",b(w)));let P=T(w),k=u(I),O=[_(k),_(P)];if(K!=null&&K!==!1){let Y=K===!0?d(e.BYTES):K;O.push(Z("extraEntropy",Y))}let M=zt(...O),V=P;function Q(Y){let it=R(Y);if(!l(it))return;let dt=a(it),ot=c.BASE.multiply(it).toAffine(),at=i(ot.x);if(at===Nt)return;let xt=i(dt*i(V+at*k));if(xt===Nt)return;let Et=(ot.x===at?0:2)|Number(ot.y&st),Ce=xt;return g&&S(xt)&&(Ce=E(xt),Et^=1),new h(at,Ce,Et)}return{seed:M,k2sig:Q}}let z={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function N(w,I,D=z){let{seed:b,k2sig:d}=C(w,I,D),g=t;return $o(g.hash.outputLen,g.nByteLength,g.hmac)(b,d)}c.BASE._setWindowSize(8);function et(w,I,D,b=H){let d=w;I=Z("msgHash",I),D=Z("publicKey",D);let{lowS:g,prehash:A,format:K}=b;if(Os(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(K!==void 0&&K!=="compact"&&K!=="der")throw new Error("format must be compact or der");let P=typeof d=="string"||Jt(d),k=!P&&!K&&typeof d=="object"&&d!==null&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!P&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,M;try{if(k&&(O=new h(d.r,d.s)),P){try{K!=="compact"&&(O=h.fromDER(d))}catch(Et){if(!(Et instanceof Pt.Err))throw Et}!O&&K!=="der"&&(O=h.fromCompact(d))}M=c.fromHex(D)}catch{return!1}if(!O||g&&O.hasHighS())return!1;A&&(I=t.hash(I));let{r:V,s:Q}=O,Y=T(I),it=a(Q),dt=i(Y*it),ot=i(V*it),at=c.BASE.multiplyAndAddUnsafe(M,dt,ot)?.toAffine();return at?i(at.x)===V:!1}return{CURVE:t,getPublicKey:v,getSharedSecret:B,sign:N,verify:et,ProjectivePoint:c,Signature:h,utils:x}}function Jc(r){return{hash:r,hmac:(t,...e)=>Qn(r,t,sn(...e)),randomBytes:sr}}function qs(r,t){let e=n=>Hs({...r,...Jc(n)});return{...e(t),create:e}}var zs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Vs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qc=BigInt(1),eo=BigInt(2),Fs=(r,t)=>(r+t/eo)/t;function tf(r){let t=zs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%t,f=u*u*r%t,l=j(f,e,t)*f%t,m=j(l,e,t)*f%t,S=j(m,eo,t)*u%t,E=j(S,o,t)*S%t,y=j(E,s,t)*E%t,h=j(y,a,t)*y%t,x=j(h,c,t)*h%t,v=j(x,a,t)*y%t,p=j(v,e,t)*f%t,B=j(p,i,t)*E%t,R=j(B,n,t)*u%t,T=j(R,eo,t);if(!ro.eql(ro.sqr(T),r))throw new Error("Cannot find square root");return T}var ro=Gt(zs,void 0,void 0,{sqrt:tf}),ce=qs({a:BigInt(0),b:BigInt(7),Fp:ro,n:Vs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Vs,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Qc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=Fs(s*r,t),c=Fs(-n*r,t),u=F(r-a*e-c*o,t),f=F(-a*n-c*s,t),l=u>i,m=f>i;if(l&&(u=t-u),m&&(f=t-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:m,k2:f}}}},$t),_d=BigInt(0);var Cd=ce.ProjectivePoint;function Gs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var js=33;function Zs(r,t,e){let n=tr.digest(e instanceof Uint8Array?e:e.subarray());if(Gs(n))return n.then(({digest:o})=>ce.verify(t,o,r)).catch(o=>{throw new Ge(String(o))});try{return ce.verify(t,n.digest,r)}catch(o){throw new Ge(String(o))}}var xr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ys(t),this.raw=Ws(this._key)}toMultihash(){return It.digest(xe(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e){return Zs(this._key,e,t)}};function Xs(r){return new xr(r)}function Ws(r){return ce.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ys(r){try{return ce.ProjectivePoint.fromHex(r),r}catch(t){throw new fe(String(t))}}function $s(r){if(r.byteLength===Be)return ys(r);if(r.byteLength===js)return Xs(r);let t=Lt(r),e=t[1]?.[0];if(e===Ko||e===Uo||e===Po)return ko(t);if(t[0]?.[0]===ks)return yr(t,r);throw new tt("Could not extract public key from raw bytes")}function xe(r){return Zt.encode({Type:bt[r.type],Data:r.raw})}var Js=Symbol.for("nodejs.util.inspect.custom"),ef=114,We=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()})`}[Dr]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(ef,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ft(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ft(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Js](){return`PeerId(${this.toString()})`}},gr=class extends We{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},wr=class extends We{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Er=class extends We{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},rf=2336,no=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=It.digest($(this.url))}[Js](){return`PeerId(${this.url})`}[Dr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(rf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=J(t)),t.toString()===this.toString())}};function Qs(r){if(r.type==="Ed25519")return new wr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Er({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new gr({multihash:r.toCID().multihash,publicKey:r});throw new Te}function _e(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Sr=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Ye(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Sr(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Sr(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var oo=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=_e(),this.haveNext=_e()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=_e(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=_e(),await Ye(this.readNext.promise,e?.signal,e)}};function ti(){return new oo}var Ar=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function ei(r,t){let e=ti();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new rt;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:c,value:u}=await Ye(n.next(),i?.signal);return c===!0?null:u}for(;o.byteLength<i.bytes;){let{value:c,done:u}=await Ye(n.next(),i?.signal);if(u===!0)throw new Ar("unexpected end of input");o.append(c)}let a=o.sublist(0,i.bytes);return o.consume(i.bytes),a},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var vr=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Br=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Ir=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function ri(r,t={}){let e=ei(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Ut(t.maxDataLength));let n=t?.lengthDecoder??xs,o=t?.lengthEncoder??bs;return{read:async i=>{let a=-1,c=new rt;for(;;){c.append(await e.read({...i,bytes:1}));try{a=n(c)}catch(u){if(u instanceof RangeError)continue;throw u}if(a<0)throw new vr("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new Ir("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Br("message length too long");return e.read({...i,bytes:a})},write:async(i,a)=>{await e.write(new rt(o(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new rt(...i.flatMap(u=>[o(u.byteLength),u]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function ni(r,t){let e=ri(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.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:()=>e.unwrap()};return n}var Lr;(function(r){let t;r.codec=()=>(t==null&&(t=ae((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubkey!=null&&(n.uint32(18),_r.codec().encode(e.pubkey,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.id=e.bytes();break}case 2:{s.pubkey=_r.codec().decode(e,e.uint32(),{limits:o.limits?.pubkey});break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(Lr||(Lr={}));var Yt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Yt||(Yt={}));var so;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(so||(so={}));(function(r){r.codec=()=>ze(so)})(Yt||(Yt={}));var _r;(function(r){let t;r.codec=()=>(t==null&&(t=ae((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Yt.codec().encode(e.Type,n)),e.Data!=null&&e.Data.byteLength>0&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={Data:At(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=Yt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ie(e,r.codec()),r.decode=(e,n)=>oe(e,r.codec(),n)})(_r||(_r={}));var nf="/plaintext/2.0.0",io=class{protocol=nf;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[co]=["@libp2p/connection-encryption"];async secureInbound(t,e){return this._encrypt(t,e)}async secureOutbound(t,e){return this._encrypt(t,e)}async _encrypt(t,e){let n=ni(t).pb(Lr);this.log("write pubkey exchange to peer %p",e?.remotePeer);let o=this.privateKey.publicKey,[,s]=await Promise.all([n.write({id:o.toMultihash().bytes,pubkey:{Type:Yt[o.type],Data:o.raw}},e),n.read(e)]),i;try{if(s.pubkey==null)throw new ue("Public key missing");if(s.pubkey.Data.byteLength===0)throw new ue("Public key data too short");if(s.id==null)throw new ue("Remote id missing");let a=$s(s.pubkey.Data);if(i=Qs(a),!ft(i.toMultihash().bytes,s.id))throw new De("Public key did not match id")}catch(a){throw this.log.error(a),new De("Invalid public key - "+a.message)}if(e?.remotePeer!=null&&!i.equals(e?.remotePeer))throw new Xe;return this.log("plaintext key exchange completed successfully with peer %p",i),{conn:n.unwrap().unwrap(),remotePeer:i}}};function of(){return r=>new io(r)}return hi(sf);})();
2
+ "use strict";var Libp2PPlaintext=(()=>{var Or=Object.defineProperty;var Ii=Object.getOwnPropertyDescriptor;var Li=Object.getOwnPropertyNames;var _i=Object.prototype.hasOwnProperty;var pt=(r,t)=>{for(var e in t)Or(r,e,{get:t[e],enumerable:!0})},Ci=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Li(t))!_i.call(r,o)&&o!==e&&Or(r,o,{get:()=>t[o],enumerable:!(n=Ii(t,o))||n.enumerable});return r};var Di=r=>Ci(Or({},"__esModule",{value:!0}),r);var rf={};pt(rf,{plaintext:()=>ef});var Hr=Symbol.for("@libp2p/peer-id");var rr=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},Ue=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"}},de=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var pe=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var bo=Symbol.for("@libp2p/service-capabilities"),af=Symbol.for("@libp2p/service-dependencies");var Fr={};pt(Fr,{base58btc:()=>W,base58flickr:()=>Ni});var Df=new Uint8Array(0);function go(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Tt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function wo(r){return new TextEncoder().encode(r)}function Eo(r){return new TextDecoder().decode(r)}function Ti(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var y=0,h=0,b=0,v=E.length;b!==v&&E[b]===0;)b++,y++;for(var p=(v-b)*f+1>>>0,B=new Uint8Array(p);b!==v;){for(var R=E[b],T=0,L=p-1;(R!==0||T<h)&&L!==-1;L--,T++)R+=256*B[L]>>>0,B[L]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");h=T,b++}for(var _=p-h;_!==p&&B[_]===0;)_++;for(var C=c.repeat(y);_<p;++_)C+=r.charAt(B[_]);return C}function m(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var y=0;if(E[y]!==" "){for(var h=0,b=0;E[y]===c;)h++,y++;for(var v=(E.length-y)*u+1>>>0,p=new Uint8Array(v);E[y];){var B=e[E.charCodeAt(y)];if(B===255)return;for(var R=0,T=v-1;(B!==0||R<b)&&T!==-1;T--,R++)B+=a*p[T]>>>0,p[T]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");b=R,y++}if(E[y]!==" "){for(var L=v-b;L!==v&&p[L]===0;)L++;for(var _=new Uint8Array(h+(v-L)),C=h;L!==v;)_[C++]=p[L++];return _}}}function S(E){var y=m(E);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:m,decode:S}}var Ri=Ti,Ui=Ri,Ao=Ui;var Mr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},qr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return vo(this,t)}},Vr=class{decoders;constructor(t){this.decoders=t}or(t){return vo(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function vo(r,t){return new Vr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var zr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Mr(t,e,n),this.decoder=new qr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function me({name:r,prefix:t,encode:e,decode:n}){return new zr(r,t,e,n)}function qt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ao(e,r);return me({prefix:t,name:r,encode:n,decode:s=>Tt(o(s))})}function Ki(r,t,e,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,c=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=e||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return i}function Pi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return me({prefix:t,name:r,encode(o){return Pi(o,n,e)},decode(o){return Ki(o,n,e,r)}})}var W=qt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ni=qt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gr={};pt(Gr,{base32:()=>ye,base32hex:()=>Mi,base32hexpad:()=>Vi,base32hexpadupper:()=>zi,base32hexupper:()=>qi,base32pad:()=>Oi,base32padupper:()=>Hi,base32upper:()=>ki,base32z:()=>Fi});var ye=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ki=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Oi=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hi=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Mi=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qi=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Vi=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zi=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Fi=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jr={};pt(jr,{base36:()=>Pe,base36upper:()=>Gi});var Pe=qt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gi=qt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ji=Lo,Bo=128,Zi=127,Wi=~Zi,Yi=Math.pow(2,31);function Lo(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Yi;)t[e++]=r&255|Bo,r/=128;for(;r&Wi;)t[e++]=r&255|Bo,r>>>=7;return t[e]=r|0,Lo.bytes=e-n+1,t}var Xi=Zr,$i=128,Io=127;function Zr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Zr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Io)<<o:(i&Io)*Math.pow(2,o),o+=7}while(i>=$i);return Zr.bytes=s-n,e}var Ji=Math.pow(2,7),Qi=Math.pow(2,14),ta=Math.pow(2,21),ea=Math.pow(2,28),ra=Math.pow(2,35),na=Math.pow(2,42),oa=Math.pow(2,49),sa=Math.pow(2,56),ia=Math.pow(2,63),aa=function(r){return r<Ji?1:r<Qi?2:r<ta?3:r<ea?4:r<ra?5:r<na?6:r<oa?7:r<sa?8:r<ia?9:10},ca={encode:ji,decode:Xi,encodingLength:aa},fa=ca,Ne=fa;function ke(r,t=0){return[Ne.decode(r,t),Ne.decode.bytes]}function xe(r,t,e=0){return Ne.encode(r,t,e),t}function be(r){return Ne.encodingLength(r)}function St(r,t){let e=t.byteLength,n=be(r),o=n+be(e),s=new Uint8Array(o+e);return xe(r,s,0),xe(e,s,n),s.set(t,o),new ge(r,e,t,s)}function Wr(r){let t=Tt(r),[e,n]=ke(t),[o,s]=ke(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ge(e,o,i,t)}function _o(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&go(r.bytes,e.bytes)}}var ge=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Co(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return la(e,Yr(r),t??W.encoder);default:return ha(e,Yr(r),t??ye.encoder)}}var Do=new WeakMap;function Yr(r){let t=Do.get(r);if(t==null){let e=new Map;return Do.set(r,e),e}return t}var at=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Oe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==da)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=St(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&_o(t.multihash,n.multihash)}toString(t){return Co(this,t)}toJSON(){return{"/":Co(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??To(n,o,s.bytes))}else if(e[pa]===!0){let{version:n,multihash:o,code:s}=e,i=Wr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Oe)throw new Error(`Version 0 CID must use dag-pb (code: ${Oe}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=To(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Oe,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Tt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ge(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,m]=ke(t.subarray(e));return e+=m,l},o=n(),s=Oe;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),u=e+c,f=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,e){let[n,o]=ua(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Yr(s).set(n,t),s}};function ua(r,t){switch(r[0]){case"Q":{let e=t??W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t??W;return[W.prefix,e.decode(r)]}case ye.prefix:{let e=t??ye;return[ye.prefix,e.decode(r)]}case Pe.prefix:{let e=t??Pe;return[Pe.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function la(r,t,e){let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function ha(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var Oe=112,da=18;function To(r,t,e){let n=be(r),o=n+be(t),s=new Uint8Array(o+e.byteLength);return xe(r,s,0),xe(t,s,n),s.set(e,o),s}var pa=Symbol.for("@ipld/js-cid/CID");var Xr={};pt(Xr,{identity:()=>It});var Ro=0,ma="identity",Uo=Tt;function ya(r){return St(Ro,Uo(r))}var It={code:Ro,name:ma,encode:Uo,digest:ya};function ct(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function At(r=0){return new Uint8Array(r)}function mt(r=0){return new Uint8Array(r)}function or(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=mt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Po=Symbol.for("@achingbrain/uint8arraylist");function Ko(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function sr(r){return!!r?.[Po]}var tt=class r{bufs;length;[Po]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(sr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(sr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Ko(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Ko(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(sr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return or(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:or(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,f=e>a&&e<=c;if(u&&f){if(t===a&&e===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(e-t)));break}if(u){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!sr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=e;l<=c;l+=f){f=0;for(let m=u;m>=0;m--){let S=this.get(l+m);if(n[m]!==S){f=Math.max(1,m-a[S]);break}}if(f===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=At(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=At(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=At(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ct(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var $r={};pt($r,{base10:()=>xa});var xa=qt({prefix:"9",name:"base10",alphabet:"0123456789"});var Jr={};pt(Jr,{base16:()=>ba,base16upper:()=>ga});var ba=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ga=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Qr={};pt(Qr,{base2:()=>wa});var wa=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var tn={};pt(tn,{base256emoji:()=>Ba});var No=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}"),Ea=No.reduce((r,t,e)=>(r[e]=t,r),[]),Sa=No.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Aa(r){return r.reduce((t,e)=>(t+=Ea[e],t),"")}function va(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Sa[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ba=me({prefix:"\u{1F680}",name:"base256emoji",encode:Aa,decode:va});var en={};pt(en,{base64:()=>Ia,base64pad:()=>La,base64url:()=>_a,base64urlpad:()=>Ca});var Ia=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),La=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_a=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ca=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var rn={};pt(rn,{base8:()=>Da});var Da=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var nn={};pt(nn,{identity:()=>Ta});var Ta=me({prefix:"\0",name:"identity",encode:r=>Eo(r),decode:r=>wo(r)});var du=new TextEncoder,pu=new TextDecoder;var an={};pt(an,{sha256:()=>ir,sha512:()=>Ka});function sn({name:r,code:t,encode:e}){return new on(r,t,e)}var on=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?St(this.code,e):e.then(n=>St(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Oo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ir=sn({name:"sha2-256",code:18,encode:Oo("SHA-256")}),Ka=sn({name:"sha2-512",code:19,encode:Oo("SHA-512")});var cn={...nn,...Qr,...rn,...$r,...Jr,...Gr,...jr,...Fr,...en,...tn},Iu={...an,...Xr};function Mo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ho=Mo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),fn=Mo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=mt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Pa={utf8:Ho,"utf-8":Ho,hex:cn.base16,latin1:fn,ascii:fn,binary:fn,...cn},ar=Pa;function Y(r,t="utf8"){let e=ar[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function X(r,t="utf8"){let e=ar[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Na=parseInt("11111",2),un=parseInt("10000000",2),ka=parseInt("01111111",2),qo={0:He,1:He,2:Oa,3:qa,4:Va,5:Ma,6:Ha,16:He,22:He,48:He};function Lt(r,t={offset:0}){let e=r[t.offset]&Na;if(t.offset++,qo[e]!=null)return qo[e](r,t);throw new Error("No decoder for tag "+e)}function Me(r,t){let e=0;if((r[t.offset]&un)===un){let n=r[t.offset]&ka,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function He(r,t){Me(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Lt(r,t);if(n===null)break;e.push(n)}return e}function Oa(r,t){let e=Me(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Ha(r,t){let e=Me(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let u=r[t.offset];if(t.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function Ma(r,t){return t.offset++,null}function qa(r,t){let e=Me(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Va(r,t){let e=Me(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function za(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new tt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function ln(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=za(r.byteLength);return new tt(Uint8Array.from([t.byteLength|un]),t)}function yt(r){let t=new tt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new tt(Uint8Array.from([2]),ln(t),t)}function cr(r){let t=Uint8Array.from([0]),e=new tt(t,r);return new tt(Uint8Array.from([3]),ln(e),e)}function Vt(r,t=48){let e=new tt;for(let n of r)e.append(n);return new tt(Uint8Array.from([t]),ln(e),e)}var Vo="1.2.840.10045.3.1.7",zo="1.3.132.0.34",Fo="1.3.132.0.35";async function Go(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Fa=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ga=Uint8Array.from([6,5,43,129,4,0,34]),ja=Uint8Array.from([6,5,43,129,4,0,35]),Za={ext:!0,kty:"EC",crv:"P-256"},Wa={ext:!0,kty:"EC",crv:"P-384"},Ya={ext:!0,kty:"EC",crv:"P-521"},hn=32,dn=48,pn=66;function jo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===hn*2+1)return n=X(t.subarray(e,e+hn),"base64url"),o=X(t.subarray(e+hn),"base64url"),new Ee({...Za,key_ops:["verify"],x:n,y:o});if(t.byteLength===dn*2+1)return n=X(t.subarray(e,e+dn),"base64url"),o=X(t.subarray(e+dn),"base64url"),new Ee({...Wa,key_ops:["verify"],x:n,y:o});if(t.byteLength===pn*2+1)return n=X(t.subarray(e,e+pn),"base64url"),o=X(t.subarray(e+pn),"base64url"),new Ee({...Ya,key_ops:["verify"],x:n,y:o});throw new J(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Zo(r){return Vt([yt(Uint8Array.from([1])),Vt([Xa(r.crv)],160),Vt([cr(new tt(Uint8Array.from([4]),Y(r.x??"","base64url"),Y(r.y??"","base64url")))],161)]).subarray()}function Xa(r){if(r==="P-256")return Fa;if(r==="P-384")return Ga;if(r==="P-521")return ja;throw new J(`Invalid curve ${r}`)}var Ee=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Zo(this.jwk)),this._raw}toMultihash(){return It.digest(Se(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}async verify(t,e){return Go(this.jwk,e,t)}};var Jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function $a(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function fr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Qt(r,...t){if(!$a(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Wo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");fr(r.outputLen),fr(r.blockLen)}function ve(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Yo(r,t){Qt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Rt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function ur(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function vt(r,t){return r<<32-t|r>>>t}function Xo(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function qe(r){return typeof r=="string"&&(r=Xo(r)),Qt(r),r}function mn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Qt(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Ae=class{};function yn(r){let t=n=>r().update(qe(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function lr(r=32){if(Jt&&typeof Jt.getRandomValues=="function")return Jt.getRandomValues(new Uint8Array(r));if(Jt&&typeof Jt.randomBytes=="function")return Uint8Array.from(Jt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Ja(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,u=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+u,a,n)}function $o(r,t,e){return r&t^~r&e}function Jo(r,t,e){return r&t^r&e^t&e}var Ve=class extends Ae{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ur(this.buffer)}update(t){ve(this),t=qe(t),Qt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=ur(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ve(this),Yo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Rt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)e[l]=0;Ja(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=ur(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ut=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var st=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var hr=BigInt(4294967295),Qo=BigInt(32);function Qa(r,t=!1){return t?{h:Number(r&hr),l:Number(r>>Qo&hr)}:{h:Number(r>>Qo&hr)|0,l:Number(r&hr)|0}}function ts(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=Qa(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var xn=(r,t,e)=>r>>>e,bn=(r,t,e)=>r<<32-e|t>>>e,te=(r,t,e)=>r>>>e|t<<32-e,ee=(r,t,e)=>r<<32-e|t>>>e,ze=(r,t,e)=>r<<64-e|t>>>e-32,Fe=(r,t,e)=>r>>>e-32|t<<64-e;function _t(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var es=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),rs=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ns=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),os=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,ss=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),is=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var ec=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]),zt=new Uint32Array(64),dr=class extends Ve{constructor(t=32){super(64,t,8,!1),this.A=Ut[0]|0,this.B=Ut[1]|0,this.C=Ut[2]|0,this.D=Ut[3]|0,this.E=Ut[4]|0,this.F=Ut[5]|0,this.G=Ut[6]|0,this.H=Ut[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)zt[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let m=zt[l-15],S=zt[l-2],E=vt(m,7)^vt(m,18)^m>>>3,y=vt(S,17)^vt(S,19)^S>>>10;zt[l]=y+zt[l-7]+E+zt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let m=vt(a,6)^vt(a,11)^vt(a,25),S=f+m+$o(a,c,u)+ec[l]+zt[l]|0,y=(vt(n,2)^vt(n,13)^vt(n,22))+Jo(n,o,s)|0;f=u,u=c,c=a,a=i+S|0,i=s,s=o,o=n,n=S+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,u,f)}roundClean(){Rt(zt)}destroy(){this.set(0,0,0,0,0,0,0,0),Rt(this.buffer)}};var as=ts(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),rc=as[0],nc=as[1],Ft=new Uint32Array(80),Gt=new Uint32Array(80),gn=class extends Ve{constructor(t=64){super(128,t,16,!1),this.Ah=st[0]|0,this.Al=st[1]|0,this.Bh=st[2]|0,this.Bl=st[3]|0,this.Ch=st[4]|0,this.Cl=st[5]|0,this.Dh=st[6]|0,this.Dl=st[7]|0,this.Eh=st[8]|0,this.El=st[9]|0,this.Fh=st[10]|0,this.Fl=st[11]|0,this.Gh=st[12]|0,this.Gl=st[13]|0,this.Hh=st[14]|0,this.Hl=st[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:m,Gh:S,Gl:E,Hh:y,Hl:h}=this;return[t,e,n,o,s,i,a,c,u,f,l,m,S,E,y,h]}set(t,e,n,o,s,i,a,c,u,f,l,m,S,E,y,h){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=m|0,this.Gh=S|0,this.Gl=E|0,this.Hh=y|0,this.Hl=h|0}process(t,e){for(let p=0;p<16;p++,e+=4)Ft[p]=t.getUint32(e),Gt[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let B=Ft[p-15]|0,R=Gt[p-15]|0,T=te(B,R,1)^te(B,R,8)^xn(B,R,7),L=ee(B,R,1)^ee(B,R,8)^bn(B,R,7),_=Ft[p-2]|0,C=Gt[p-2]|0,z=te(_,C,19)^ze(_,C,61)^xn(_,C,6),H=ee(_,C,19)^Fe(_,C,61)^bn(_,C,6),P=ns(L,H,Gt[p-7],Gt[p-16]),Q=os(P,T,z,Ft[p-7],Ft[p-16]);Ft[p]=Q|0,Gt[p]=P|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:m,Fh:S,Fl:E,Gh:y,Gl:h,Hh:b,Hl:v}=this;for(let p=0;p<80;p++){let B=te(l,m,14)^te(l,m,18)^ze(l,m,41),R=ee(l,m,14)^ee(l,m,18)^Fe(l,m,41),T=l&S^~l&y,L=m&E^~m&h,_=ss(v,R,L,nc[p],Gt[p]),C=is(_,b,B,T,rc[p],Ft[p]),z=_|0,H=te(n,o,28)^ze(n,o,34)^ze(n,o,39),P=ee(n,o,28)^Fe(n,o,34)^Fe(n,o,39),Q=n&s^n&a^s&a,w=o&i^o&c^i&c;b=y|0,v=h|0,y=S|0,h=E|0,S=l|0,E=m|0,{h:l,l:m}=_t(u|0,f|0,C|0,z|0),u=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=es(z,P,w);n=rs(I,C,H,Q),o=I|0}({h:n,l:o}=_t(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=_t(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=_t(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=_t(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:m}=_t(this.Eh|0,this.El|0,l|0,m|0),{h:S,l:E}=_t(this.Fh|0,this.Fl|0,S|0,E|0),{h:y,l:h}=_t(this.Gh|0,this.Gl|0,y|0,h|0),{h:b,l:v}=_t(this.Hh|0,this.Hl|0,b|0,v|0),this.set(n,o,s,i,a,c,u,f,l,m,S,E,y,h,b,v)}roundClean(){Rt(Ft,Gt)}destroy(){Rt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var pr=yn(()=>new dr);var cs=yn(()=>new gn);var An=BigInt(0),Sn=BigInt(1);function re(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function vn(r){if(!re(r))throw new Error("Uint8Array expected")}function Ct(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Ge(r){let t=r.toString(16);return t.length&1?"0"+t:t}function ls(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?An:BigInt("0x"+r)}var hs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",oc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function jt(r){if(vn(r),hs)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=oc[r[e]];return t}var Kt={_0:48,_9:57,A:65,F:70,a:97,f:102};function fs(r){if(r>=Kt._0&&r<=Kt._9)return r-Kt._0;if(r>=Kt.A&&r<=Kt.F)return r-(Kt.A-10);if(r>=Kt.a&&r<=Kt.f)return r-(Kt.a-10)}function je(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(hs)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=fs(r.charCodeAt(s)),a=fs(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Pt(r){return ls(jt(r))}function ne(r){return vn(r),ls(jt(Uint8Array.from(r).reverse()))}function oe(r,t){return je(r.toString(16).padStart(t*2,"0"))}function Be(r,t){return oe(r,t).reverse()}function G(r,t,e){let n;if(typeof t=="string")try{n=je(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(re(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Zt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];vn(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var wn=r=>typeof r=="bigint"&&An<=r;function mr(r,t,e){return wn(r)&&wn(t)&&wn(e)&&t<=r&&r<e}function gt(r,t,e,n){if(!mr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function ds(r){let t;for(t=0;r>An;r>>=Sn,t+=1);return t}var se=r=>(Sn<<BigInt(r))-Sn,En=r=>new Uint8Array(r),us=r=>Uint8Array.from(r);function ps(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=En(r),o=En(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>e(o,n,...l),c=(l=En(0))=>{o=a(us([0]),l),n=a(),l.length!==0&&(o=a(us([1]),l),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,m=[];for(;l<t;){n=a();let S=n.slice();m.push(S),l+=n.length}return Zt(...m)};return(l,m)=>{i(),c(l);let S;for(;!(S=m(u()));)c();return i(),S}}var sc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||re(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Nt(r,t,e={}){let n=(o,s,i)=>{let a=sc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Ie(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var lt=BigInt(0),et=BigInt(1),ie=BigInt(2),ic=BigInt(3),Bn=BigInt(4),ms=BigInt(5),ys=BigInt(8),ac=BigInt(9),cc=BigInt(16);function V(r,t){let e=r%t;return e>=lt?e:t+e}function F(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function yr(r,t){if(r===lt)throw new Error("invert: expected non-zero number");if(t<=lt)throw new Error("invert: expected positive modulus, got "+t);let e=V(r,t),n=t,o=lt,s=et,i=et,a=lt;for(;e!==lt;){let u=n/e,f=n%e,l=o-i*u,m=s-a*u;n=e,e=f,o=i,s=a,i=l,a=m}if(n!==et)throw new Error("invert: does not exist");return V(o,t)}function fc(r){let t=r-et,e=0;for(;t%ie===lt;)t/=ie,e++;let n=ie,o=kt(r);for(;n<r&&xs(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1){let i=(r+et)/Bn;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(t+et)/ie;return function(a,c){if(!xs(a,c))throw new Error("Cannot find square root");let u=e,f=a.pow(a.mul(a.ONE,n),t),l=a.pow(c,s),m=a.pow(c,t);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let S=1;for(let y=a.sqr(m);S<u&&!a.eql(y,a.ONE);S++)y=a.sqr(y);let E=a.pow(f,et<<BigInt(u-S-1));f=a.sqr(E),l=a.mul(l,E),m=a.mul(m,f),u=S}return l}}function uc(r){return r%Bn===ic?function(e,n){let o=(r+et)/Bn,s=e.pow(n,o);if(!e.eql(e.sqr(s),n))throw new Error("Cannot find square root");return s}:r%ys===ms?function(e,n){let o=e.mul(n,ie),s=(r-ms)/ys,i=e.pow(o,s),a=e.mul(n,i),c=e.mul(e.mul(a,ie),i),u=e.mul(a,e.sub(c,e.ONE));if(!e.eql(e.sqr(u),n))throw new Error("Cannot find square root");return u}:(r%cc,fc(r))}var bs=(r,t)=>(V(r,t)&et)===et,lc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function In(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=lc.reduce((n,o)=>(n[o]="function",n),t);return Nt(r,e)}function hc(r,t,e){if(e<lt)throw new Error("invalid exponent, negatives unsupported");if(e===lt)return r.ONE;if(e===et)return t;let n=r.ONE,o=t;for(;e>lt;)e&et&&(n=r.mul(n,o)),o=r.sqr(o),e>>=et;return n}function Le(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function dc(r,t){let e=(r.ORDER-et)/ie,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("Cannot find square root: probably non-prime P");return o?1:s?0:-1}function xs(r,t){let e=dc(r,t);return e===0||e===1}function Ln(r,t){t!==void 0&&fr(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function kt(r,t,e=!1,n={}){if(r<=lt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Ln(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:se(o),ZERO:lt,ONE:et,create:c=>V(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return lt<=c&&c<r},is0:c=>c===lt,isOdd:c=>(c&et)===et,neg:c=>V(-c,r),eql:(c,u)=>c===u,sqr:c=>V(c*c,r),add:(c,u)=>V(c+u,r),sub:(c,u)=>V(c-u,r),mul:(c,u)=>V(c*u,r),pow:(c,u)=>hc(a,c,u),div:(c,u)=>V(c*yr(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>yr(c,r),sqrt:n.sqrt||(c=>(i||(i=uc(r)),i(a,c))),toBytes:c=>e?Be(c,s):oe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?ne(c):Pt(c)},invertBatch:c=>Le(a,c),cmov:(c,u,f)=>f?u:c});return Object.freeze(a)}function gs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function _n(r){let t=gs(r);return t+Math.ceil(t/2)}function ws(r,t,e=!1){let n=r.length,o=gs(t),s=_n(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ne(r):Pt(r),a=V(i,t-et)+et;return e?Be(a,o):oe(a,o)}var Es=BigInt(0),Un=BigInt(1);function Cn(r,t){let e=t.negate();return r?e:t}function As(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Dn(r,t){As(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=se(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Ss(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Un);let u=t*n,f=u+Math.abs(a)-1,l=a===0,m=a<0,S=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:m,isNegF:S,offsetF:u}}function pc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function mc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Tn=new WeakMap,vs=new WeakMap;function Rn(r){return vs.get(r)||1}function xr(r,t){return{constTimeNegate:Cn,hasPrecomputes(e){return Rn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Es;)n&Un&&(o=o.add(s)),s=s.double(),n>>=Un;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Dn(n,t),i=[],a=e,c=a;for(let u=0;u<o;u++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Dn(e,t);for(let c=0;c<a.windows;c++){let{nextN:u,offset:f,isZero:l,isNeg:m,isNegF:S,offsetF:E}=Ss(o,c,a);o=u,l?i=i.add(Cn(S,n[E])):s=s.add(Cn(m,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Dn(e,t);for(let a=0;a<i.windows&&o!==Es;a++){let{nextN:c,offset:u,isZero:f,isNeg:l}=Ss(o,a,i);if(o=c,!f){let m=n[u];s=s.add(l?m.negate():m)}}return s},getPrecomputes(e,n,o){let s=Tn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Tn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Rn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Rn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){As(n,t),vs.set(e,n),Tn.delete(e)}}}function br(r,t,e,n){if(pc(e,r),mc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=ds(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,a=se(i),c=new Array(Number(a)+1).fill(o),u=Math.floor((t.BITS-1)/i)*i,f=o;for(let l=u;l>=0;l-=i){c.fill(o);for(let S=0;S<n.length;S++){let E=n[S],y=Number(E>>BigInt(l)&a);c[y]=c[y].add(e[S])}let m=o;for(let S=c.length-1,E=o;S>0;S--)E=E.add(c[S]),m=m.add(E);if(f=f.add(m),l!==0)for(let S=0;S<i;S++)f=f.double()}return f}function Ze(r){return In(r.Fp),Nt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ln(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Dt=BigInt(0),ht=BigInt(1),Bs=BigInt(2),yc=BigInt(8),xc={zip215:!0};function bc(r){let t=Ze(r);return Nt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Is(r){let t=bc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,u=Bs<<BigInt(a*8)-ht,f=e.create,l=kt(t.n,t.nBitLength),m=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(d))}}catch{return{isValid:!1,value:Dt}}}),S=t.adjustScalarBytes||(x=>x),E=t.domain||((x,d,g)=>{if(Ct("phflag",g),d.length||g)throw new Error("Contexts/pre-hash are not supported");return x});function y(x,d,g=!1){let A=g?ht:Dt;gt("coordinate "+x,d,A,u)}function h(x){if(!(x instanceof p))throw new Error("ExtendedPoint expected")}let b=Ie((x,d)=>{let{ex:g,ey:A,ez:U}=x,K=x.is0();d==null&&(d=K?yc:e.inv(U));let N=f(g*d),k=f(A*d),O=f(U*d);if(K)return{x:Dt,y:ht};if(O!==ht)throw new Error("invZ was invalid");return{x:N,y:k}}),v=Ie(x=>{let{a:d,d:g}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:A,ey:U,ez:K,et:N}=x,k=f(A*A),O=f(U*U),q=f(K*K),$=f(q*q),Z=f(k*d),ot=f(q*f(Z+O)),dt=f($+f(g*f(k*O)));if(ot!==dt)throw new Error("bad point: equation left != right (1)");let rt=f(A*U),it=f(K*N);if(rt!==it)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(d,g,A,U){y("x",d),y("y",g),y("z",A,!0),y("t",U),this.ex=d,this.ey=g,this.ez=A,this.et=U,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof p)throw new Error("extended point not allowed");let{x:g,y:A}=d||{};return y("x",g),y("y",A),new p(g,A,ht,f(g*A))}static normalizeZ(d){let g=Le(e,d.map(A=>A.ez));return d.map((A,U)=>A.toAffine(g[U])).map(p.fromAffine)}static msm(d,g){return br(p,l,d,g)}_setWindowSize(d){T.setWindowSize(this,d)}assertValidity(){v(this)}equals(d){h(d);let{ex:g,ey:A,ez:U}=this,{ex:K,ey:N,ez:k}=d,O=f(g*k),q=f(K*U),$=f(A*k),Z=f(N*U);return O===q&&$===Z}is0(){return this.equals(p.ZERO)}negate(){return new p(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:g,ey:A,ez:U}=this,K=f(g*g),N=f(A*A),k=f(Bs*f(U*U)),O=f(d*K),q=g+A,$=f(f(q*q)-K-N),Z=O+N,ot=Z-k,dt=O-N,rt=f($*ot),it=f(Z*dt),bt=f($*dt),Et=f(ot*Z);return new p(rt,it,Et,bt)}add(d){h(d);let{a:g,d:A}=t,{ex:U,ey:K,ez:N,et:k}=this,{ex:O,ey:q,ez:$,et:Z}=d,ot=f(U*O),dt=f(K*q),rt=f(k*A*Z),it=f(N*$),bt=f((U+K)*(O+q)-ot-dt),Et=it-rt,Re=it+rt,xo=f(dt-g*ot),Si=f(bt*Et),Ai=f(Re*xo),vi=f(bt*xo),Bi=f(Et*Re);return new p(Si,Ai,Bi,vi)}subtract(d){return this.add(d.negate())}wNAF(d){return T.wNAFCached(this,d,p.normalizeZ)}multiply(d){let g=d;gt("scalar",g,ht,n);let{p:A,f:U}=this.wNAF(g);return p.normalizeZ([A,U])[0]}multiplyUnsafe(d,g=p.ZERO){let A=d;return gt("scalar",A,Dt,n),A===Dt?R:this.is0()||A===ht?this:T.wNAFCachedUnsafe(this,A,p.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===ht?this:this.multiplyUnsafe(d)}static fromHex(d,g=!1){let{d:A,a:U}=t,K=e.BYTES;d=G("pointHex",d,K),Ct("zip215",g);let N=d.slice(),k=d[K-1];N[K-1]=k&-129;let O=ne(N),q=g?u:e.ORDER;gt("pointHex.y",O,Dt,q);let $=f(O*O),Z=f($-ht),ot=f(A*$-U),{isValid:dt,value:rt}=m(Z,ot);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let it=(rt&ht)===ht,bt=(k&128)!==0;if(!g&&rt===Dt&&bt)throw new Error("Point.fromHex: x=0 and x_0=1");return bt!==it&&(rt=f(-rt)),p.fromAffine({x:rt,y:O})}static fromPrivateKey(d){let{scalar:g}=C(d);return B.multiply(g)}toRawBytes(){let{x:d,y:g}=this.toAffine(),A=Be(g,e.BYTES);return A[A.length-1]|=d&ht?128:0,A}toHex(){return jt(this.toRawBytes())}}p.BASE=new p(t.Gx,t.Gy,ht,f(t.Gx*t.Gy)),p.ZERO=new p(Dt,ht,ht,Dt);let{BASE:B,ZERO:R}=p,T=xr(p,a*8);function L(x){return V(x,n)}function _(x){return L(ne(x))}function C(x){let d=e.BYTES;x=G("private key",x,d);let g=G("hashed private key",s(x),2*d),A=S(g.slice(0,d)),U=g.slice(d,2*d),K=_(A);return{head:A,prefix:U,scalar:K}}function z(x){let{head:d,prefix:g,scalar:A}=C(x),U=B.multiply(A),K=U.toRawBytes();return{head:d,prefix:g,scalar:A,point:U,pointBytes:K}}function H(x){return z(x).pointBytes}function P(x=Uint8Array.of(),...d){let g=Zt(...d);return _(s(E(g,G("context",x),!!o)))}function Q(x,d,g={}){x=G("message",x),o&&(x=o(x));let{prefix:A,scalar:U,pointBytes:K}=z(d),N=P(g.context,A,x),k=B.multiply(N).toRawBytes(),O=P(g.context,k,K,x),q=L(N+O*U);gt("signature.s",q,Dt,n);let $=Zt(k,Be(q,e.BYTES));return G("result",$,e.BYTES*2)}let w=xc;function I(x,d,g,A=w){let{context:U,zip215:K}=A,N=e.BYTES;x=G("signature",x,2*N),d=G("message",d),g=G("publicKey",g,N),K!==void 0&&Ct("zip215",K),o&&(d=o(d));let k=ne(x.slice(N,2*N)),O,q,$;try{O=p.fromHex(g,K),q=p.fromHex(x.slice(0,N),K),$=B.multiplyUnsafe(k)}catch{return!1}if(!K&&O.isSmallOrder())return!1;let Z=P(U,q.toRawBytes(),O.toRawBytes(),d);return q.add(O.multiplyUnsafe(Z)).subtract($).clearCofactor().equals(p.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:H,sign:Q,verify:I,ExtendedPoint:p,utils:{getExtendedPublicKey:z,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,d=p.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var Kn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ls=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Cl=BigInt(0),gc=BigInt(1),_s=BigInt(2),Dl=BigInt(3),wc=BigInt(5),Ec=BigInt(8);function Sc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Kn,a=r*r%s*r%s,c=F(a,_s,s)*a%s,u=F(c,gc,s)*r%s,f=F(u,wc,s)*u%s,l=F(f,t,s)*f%s,m=F(l,e,s)*l%s,S=F(m,n,s)*m%s,E=F(S,o,s)*S%s,y=F(E,o,s)*S%s,h=F(y,t,s)*f%s;return{pow_p_5_8:F(h,_s,s)*r%s,b2:a}}function Ac(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function vc(r,t){let e=Kn,n=V(t*t*t,e),o=V(n*n*t,e),s=Sc(r*o).pow_p_5_8,i=V(r*n*s,e),a=V(t*i*i,e),c=i,u=V(i*Ls,e),f=a===r,l=a===V(-r,e),m=a===V(-r*Ls,e);return f&&(i=c),(l||m)&&(i=u),bs(i,e)&&(i=V(-i,e)),{isValid:f||l,value:i}}var Cs=kt(Kn,void 0,!0),Bc={a:Cs.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Cs,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ec,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:cs,randomBytes:lr,adjustScalarBytes:Ac,uvRatio:vc},Ds=Is(Bc);var _e=32;function Ts(r,t,e){return Ds.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var gr=class{type="Ed25519";raw;constructor(t){this.raw=Pn(t,_e)}toMultihash(){return It.digest(Se(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Ts(this.raw,e,t)}};function Ks(r){return r=Pn(r,_e),new gr(r)}function Pn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new J(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Ic=Math.pow(2,7),Lc=Math.pow(2,14),_c=Math.pow(2,21),Nn=Math.pow(2,28),kn=Math.pow(2,35),On=Math.pow(2,42),Hn=Math.pow(2,49),M=128,ft=127;function Ot(r){if(r<Ic)return 1;if(r<Lc)return 2;if(r<_c)return 3;if(r<Nn)return 4;if(r<kn)return 5;if(r<On)return 6;if(r<Hn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Mn(r,t,e=0){switch(Ot(r)){case 8:t[e++]=r&255|M,r/=128;case 7:t[e++]=r&255|M,r/=128;case 6:t[e++]=r&255|M,r/=128;case 5:t[e++]=r&255|M,r/=128;case 4:t[e++]=r&255|M,r>>>=7;case 3:t[e++]=r&255|M,r>>>=7;case 2:t[e++]=r&255|M,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Cc(r,t,e=0){switch(Ot(r)){case 8:t.set(e++,r&255|M),r/=128;case 7:t.set(e++,r&255|M),r/=128;case 6:t.set(e++,r&255|M),r/=128;case 5:t.set(e++,r&255|M),r/=128;case 4:t.set(e++,r&255|M),r>>>=7;case 3:t.set(e++,r&255|M),r>>>=7;case 2:t.set(e++,r&255|M),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function qn(r,t){let e=r[t],n=0;if(n+=e&ft,e<M||(e=r[t+1],n+=(e&ft)<<7,e<M)||(e=r[t+2],n+=(e&ft)<<14,e<M)||(e=r[t+3],n+=(e&ft)<<21,e<M)||(e=r[t+4],n+=(e&ft)*Nn,e<M)||(e=r[t+5],n+=(e&ft)*kn,e<M)||(e=r[t+6],n+=(e&ft)*On,e<M)||(e=r[t+7],n+=(e&ft)*Hn,e<M))return n;throw new RangeError("Could not decode varint")}function Dc(r,t){let e=r.get(t),n=0;if(n+=e&ft,e<M||(e=r.get(t+1),n+=(e&ft)<<7,e<M)||(e=r.get(t+2),n+=(e&ft)<<14,e<M)||(e=r.get(t+3),n+=(e&ft)<<21,e<M)||(e=r.get(t+4),n+=(e&ft)*Nn,e<M)||(e=r.get(t+5),n+=(e&ft)*kn,e<M)||(e=r.get(t+6),n+=(e&ft)*On,e<M)||(e=r.get(t+7),n+=(e&ft)*Hn,e<M))return n;throw new RangeError("Could not decode varint")}function Ps(r,t,e=0){return t==null&&(t=mt(Ot(r))),t instanceof Uint8Array?Mn(r,t,e):Cc(r,t,e)}function Ns(r,t=0){return r instanceof Uint8Array?qn(r,t):Dc(r,t)}var Vn=new Float32Array([-0]),Wt=new Uint8Array(Vn.buffer);function ks(r,t,e){Vn[0]=r,t[e]=Wt[0],t[e+1]=Wt[1],t[e+2]=Wt[2],t[e+3]=Wt[3]}function Os(r,t){return Wt[0]=r[t],Wt[1]=r[t+1],Wt[2]=r[t+2],Wt[3]=r[t+3],Vn[0]}var zn=new Float64Array([-0]),ut=new Uint8Array(zn.buffer);function Hs(r,t,e){zn[0]=r,t[e]=ut[0],t[e+1]=ut[1],t[e+2]=ut[2],t[e+3]=ut[3],t[e+4]=ut[4],t[e+5]=ut[5],t[e+6]=ut[6],t[e+7]=ut[7]}function Ms(r,t){return ut[0]=r[t],ut[1]=r[t+1],ut[2]=r[t+2],ut[3]=r[t+3],ut[4]=r[t+4],ut[5]=r[t+5],ut[6]=r[t+6],ut[7]=r[t+7],zn[0]}var Rc=BigInt(Number.MAX_SAFE_INTEGER),Uc=BigInt(Number.MIN_SAFE_INTEGER),wt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ae;if(t<Rc&&t>Uc)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>qs&&(o=0n,++n>qs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ae;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ae}},ae=new wt(0,0);ae.toBigInt=function(){return 0n};ae.zzEncode=ae.zzDecode=function(){return this};ae.length=function(){return 1};var qs=4294967296n;function Vs(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function zs(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Fn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Bt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function wr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Gn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Bt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Bt(this,4);return wr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Bt(this,4);return wr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Bt(this,4);let t=Os(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Bt(this,4);let t=Ms(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Bt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return zs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Bt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Bt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new wt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Bt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Bt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Bt(this,8);let t=wr(this.buf,this.pos+=4),e=wr(this.buf,this.pos+=4);return new wt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=qn(this.buf,this.pos);return this.pos+=Ot(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function jn(r){return new Gn(r instanceof Uint8Array?r:r.subarray())}function ce(r,t,e){let n=jn(r);return t.decode(n,void 0,e)}function Zn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return mt(i);o+i>t&&(n=mt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var fe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Wn(){}var Xn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Kc=Zn();function Pc(r){return globalThis.Buffer!=null?mt(r):Kc(r)}var Ye=class{len;head;tail;states;constructor(){this.len=0,this.head=new fe(Wn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new fe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new $n((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Er,10,wt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=wt.fromBigInt(t);return this._push(Er,e.length(),e)}uint64Number(t){return this._push(Mn,Ot(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=wt.fromBigInt(t).zzEncode();return this._push(Er,e.length(),e)}sint64Number(t){let e=wt.fromNumber(t).zzEncode();return this._push(Er,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Yn,1,t?1:0)}fixed32(t){return this._push(We,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=wt.fromBigInt(t);return this._push(We,4,e.lo)._push(We,4,e.hi)}fixed64Number(t){let e=wt.fromNumber(t);return this._push(We,4,e.lo)._push(We,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ks,4,t)}double(t){return this._push(Hs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Yn,1,0):this.uint32(e)._push(kc,e,t)}string(t){let e=Vs(t);return e!==0?this.uint32(e)._push(Fn,e,t):this._push(Yn,1,0)}fork(){return this.states=new Xn(this),this.head=this.tail=new fe(Wn,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(Wn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Pc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Yn(r,t,e){t[e]=r&255}function Nc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var $n=class extends fe{next;constructor(t,e){super(Nc,t,e),this.next=void 0}};function Er(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function We(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function kc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ye.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Oc,t,r),this},Ye.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Hc,t,r),this});function Oc(r,t,e){t.set(r,e)}function Hc(r,t,e){r.length<40?Fn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Y(r),e)}function Jn(){return new Ye}function ue(r,t){let e=Jn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ce;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ce||(Ce={}));function Sr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Xe(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Sr("enum",Ce.VARINT,e,n)}function le(r,t){return Sr("message",Ce.LENGTH_DELIMITED,r,t)}var xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(xt||(xt={}));var Qn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Qn||(Qn={}));(function(r){r.codec=()=>Xe(Qn)})(xt||(xt={}));var Yt;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),xt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(Yt||(Yt={}));var to;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),xt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(to||(to={}));var $e=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Ar=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var js={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Ar("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 Xt=js;var Qe={};pt(Qe,{MAX_RSA_KEY_SIZE:()=>eo,generateRSAKeyPair:()=>$s,jwkToJWKKeyPair:()=>Js,jwkToPkcs1:()=>zc,jwkToPkix:()=>so,jwkToRSAPrivateKey:()=>ao,pkcs1MessageToJwk:()=>no,pkcs1MessageToRSAPrivateKey:()=>io,pkcs1ToJwk:()=>Vc,pkcs1ToRSAPrivateKey:()=>Ys,pkixMessageToJwk:()=>oo,pkixMessageToRSAPublicKey:()=>Br,pkixToJwk:()=>Fc,pkixToRSAPublicKey:()=>Xs});var vr=pr;var De=class{type="RSA";jwk;_raw;_multihash;constructor(t,e){this.jwk=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=Qe.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return at.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Ws(this.jwk,e,t)}},Je=class{type="RSA";jwk;_raw;publicKey;constructor(t,e){this.jwk=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=Qe.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}sign(t){return Zs(this.jwk,t)}};var eo=8192,ro=18,Mc=1062,qc=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Vc(r){let t=Lt(r);return no(t)}function no(r){return{n:X(r[1],"base64url"),e:X(r[2],"base64url"),d:X(r[3],"base64url"),p:X(r[4],"base64url"),q:X(r[5],"base64url"),dp:X(r[6],"base64url"),dq:X(r[7],"base64url"),qi:X(r[8],"base64url"),kty:"RSA"}}function zc(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new J("JWK was missing components");return Vt([yt(Uint8Array.from([0])),yt(Y(r.n,"base64url")),yt(Y(r.e,"base64url")),yt(Y(r.d,"base64url")),yt(Y(r.p,"base64url")),yt(Y(r.q,"base64url")),yt(Y(r.dp,"base64url")),yt(Y(r.dq,"base64url")),yt(Y(r.qi,"base64url"))]).subarray()}function Fc(r){let t=Lt(r,{offset:0});return oo(t)}function oo(r){let t=Lt(r[1],{offset:0});return{kty:"RSA",n:X(t[0],"base64url"),e:X(t[1],"base64url")}}function so(r){if(r.n==null||r.e==null)throw new J("JWK was missing components");return Vt([qc,cr(Vt([yt(Y(r.n,"base64url")),yt(Y(r.e,"base64url"))]))]).subarray()}function Ys(r){let t=Lt(r);return io(t)}function io(r){let t=no(r);return ao(t)}function Xs(r,t){if(r.byteLength>=Mc)throw new de("Key size is too large");let e=Lt(r,{offset:0});return Br(e,r,t)}function Br(r,t,e){let n=oo(r);if(e==null){let o=vr(Yt.encode({Type:xt.RSA,Data:t}));e=St(ro,o)}return new De(n,e)}function ao(r){if(ti(r)>eo)throw new J("Key size is too large");let t=Js(r),e=vr(Yt.encode({Type:xt.RSA,Data:so(t.publicKey)})),n=St(ro,e);return new Je(t.privateKey,new De(t.publicKey,n))}async function $s(r){if(r>eo)throw new J("Key size is too large");let t=await Qs(r),e=vr(Yt.encode({Type:xt.RSA,Data:so(t.publicKey)})),n=St(ro,e);return new Je(t.privateKey,new De(t.publicKey,n))}function Js(r){if(r==null)throw new J("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var ei="1.2.840.113549.1.1.1";async function Qs(r){let t=await Xt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Gc(t);return{privateKey:e[0],publicKey:e[1]}}async function Zs(r,t){let e=await Xt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Xt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ws(r,t,e){let n=await Xt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Xt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Gc(r){if(r.privateKey==null||r.publicKey==null)throw new J("Private and public key are required");return Promise.all([Xt.get().subtle.exportKey("jwk",r.privateKey),Xt.get().subtle.exportKey("jwk",r.publicKey)])}function ti(r){if(r.kty!=="RSA")throw new J("invalid key type");if(r.n==null)throw new J("invalid key modulus");return Y(r.n,"base64url").length*8}var Ir=class extends Ae{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Wo(t);let n=qe(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),Rt(s)}update(t){return ve(this),this.iHash.update(t),this}digestInto(t){ve(this),Qt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},co=(r,t,e)=>new Ir(r,t).update(e).digest();co.create=(r,t)=>new Ir(r,t);function ri(r){r.lowS!==void 0&&Ct("lowS",r.lowS),r.prehash!==void 0&&Ct("prehash",r.prehash)}function jc(r){let t=Ze(r);Nt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var fo=class extends Error{constructor(t=""){super(t)}},Ht={Err:fo,_tlv:{encode:(r,t)=>{let{Err:e}=Ht;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=Ge(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Ge(o.length/2|128):"";return Ge(r)+s+o+t},decode(r,t){let{Err:e}=Ht,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+c);if(u.length!==c)throw new e("tlv.decode: length bytes not complete");if(u[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of u)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Ht;if(r<Mt)throw new t("integer: negative integers are not allowed");let e=Ge(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ht;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Pt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ht,o=G("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:u,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(u)}},hexFromSig(r){let{_tlv:t,_int:e}=Ht,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Mt=BigInt(0),nt=BigInt(1),sd=BigInt(2),ni=BigInt(3),id=BigInt(4);function Zc(r){let t=jc(r),{Fp:e}=t,n=kt(t.n,t.nBitLength),o=t.toBytes||((y,h,b)=>{let v=h.toAffine();return Zt(Uint8Array.from([4]),e.toBytes(v.x),e.toBytes(v.y))}),s=t.fromBytes||(y=>{let h=y.subarray(1),b=e.fromBytes(h.subarray(0,e.BYTES)),v=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:b,y:v}});function i(y){let{a:h,b}=t,v=e.sqr(y),p=e.mul(v,y);return e.add(e.add(p,e.mul(y,h)),b)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return mr(y,nt,t.n)}function c(y){let{allowedPrivateKeyLengths:h,nByteLength:b,wrapPrivateKey:v,n:p}=t;if(h&&typeof y!="bigint"){if(re(y)&&(y=jt(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(b*2,"0")}let B;try{B=typeof y=="bigint"?y:Pt(G("private key",y,b))}catch{throw new Error("invalid private key, expected hex or "+b+" bytes, got "+typeof y)}return v&&(B=V(B,p)),gt("private key",B,nt,p),B}function u(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}let f=Ie((y,h)=>{let{px:b,py:v,pz:p}=y;if(e.eql(p,e.ONE))return{x:b,y:v};let B=y.is0();h==null&&(h=B?e.ONE:e.inv(p));let R=e.mul(b,h),T=e.mul(v,h),L=e.mul(p,h);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:R,y:T}}),l=Ie(y=>{if(y.is0()){if(t.allowInfinityPoint&&!e.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:b}=y.toAffine();if(!e.isValid(h)||!e.isValid(b))throw new Error("bad point: x or y not FE");let v=e.sqr(b),p=i(h);if(!e.eql(v,p))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(h,b,v){if(h==null||!e.isValid(h))throw new Error("x required");if(b==null||!e.isValid(b)||e.is0(b))throw new Error("y required");if(v==null||!e.isValid(v))throw new Error("z required");this.px=h,this.py=b,this.pz=v,Object.freeze(this)}static fromAffine(h){let{x:b,y:v}=h||{};if(!h||!e.isValid(b)||!e.isValid(v))throw new Error("invalid affine point");if(h instanceof m)throw new Error("projective point not allowed");let p=B=>e.eql(B,e.ZERO);return p(b)&&p(v)?m.ZERO:new m(b,v,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let b=Le(e,h.map(v=>v.pz));return h.map((v,p)=>v.toAffine(b[p])).map(m.fromAffine)}static fromHex(h){let b=m.fromAffine(s(G("pointHex",h)));return b.assertValidity(),b}static fromPrivateKey(h){return m.BASE.multiply(c(h))}static msm(h,b){return br(m,n,h,b)}_setWindowSize(h){E.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:b,py:v,pz:p}=this,{px:B,py:R,pz:T}=h,L=e.eql(e.mul(b,T),e.mul(B,p)),_=e.eql(e.mul(v,T),e.mul(R,p));return L&&_}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b}=t,v=e.mul(b,ni),{px:p,py:B,pz:R}=this,T=e.ZERO,L=e.ZERO,_=e.ZERO,C=e.mul(p,p),z=e.mul(B,B),H=e.mul(R,R),P=e.mul(p,B);return P=e.add(P,P),_=e.mul(p,R),_=e.add(_,_),T=e.mul(h,_),L=e.mul(v,H),L=e.add(T,L),T=e.sub(z,L),L=e.add(z,L),L=e.mul(T,L),T=e.mul(P,T),_=e.mul(v,_),H=e.mul(h,H),P=e.sub(C,H),P=e.mul(h,P),P=e.add(P,_),_=e.add(C,C),C=e.add(_,C),C=e.add(C,H),C=e.mul(C,P),L=e.add(L,C),H=e.mul(B,R),H=e.add(H,H),C=e.mul(H,P),T=e.sub(T,C),_=e.mul(H,z),_=e.add(_,_),_=e.add(_,_),new m(T,L,_)}add(h){u(h);let{px:b,py:v,pz:p}=this,{px:B,py:R,pz:T}=h,L=e.ZERO,_=e.ZERO,C=e.ZERO,z=t.a,H=e.mul(t.b,ni),P=e.mul(b,B),Q=e.mul(v,R),w=e.mul(p,T),I=e.add(b,v),D=e.add(B,R);I=e.mul(I,D),D=e.add(P,Q),I=e.sub(I,D),D=e.add(b,p);let x=e.add(B,T);return D=e.mul(D,x),x=e.add(P,w),D=e.sub(D,x),x=e.add(v,p),L=e.add(R,T),x=e.mul(x,L),L=e.add(Q,w),x=e.sub(x,L),C=e.mul(z,D),L=e.mul(H,w),C=e.add(L,C),L=e.sub(Q,C),C=e.add(Q,C),_=e.mul(L,C),Q=e.add(P,P),Q=e.add(Q,P),w=e.mul(z,w),D=e.mul(H,D),Q=e.add(Q,w),w=e.sub(P,w),w=e.mul(z,w),D=e.add(D,w),P=e.mul(Q,D),_=e.add(_,P),P=e.mul(x,D),L=e.mul(I,L),L=e.sub(L,P),P=e.mul(I,Q),C=e.mul(x,C),C=e.add(C,P),new m(L,_,C)}subtract(h){return this.add(h.negate())}is0(){return this.equals(m.ZERO)}wNAF(h){return E.wNAFCached(this,h,m.normalizeZ)}multiplyUnsafe(h){let{endo:b,n:v}=t;gt("scalar",h,Mt,v);let p=m.ZERO;if(h===Mt)return p;if(this.is0()||h===nt)return this;if(!b||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,h,m.normalizeZ);let{k1neg:B,k1:R,k2neg:T,k2:L}=b.splitScalar(h),_=p,C=p,z=this;for(;R>Mt||L>Mt;)R&nt&&(_=_.add(z)),L&nt&&(C=C.add(z)),z=z.double(),R>>=nt,L>>=nt;return B&&(_=_.negate()),T&&(C=C.negate()),C=new m(e.mul(C.px,b.beta),C.py,C.pz),_.add(C)}multiply(h){let{endo:b,n:v}=t;gt("scalar",h,nt,v);let p,B;if(b){let{k1neg:R,k1:T,k2neg:L,k2:_}=b.splitScalar(h),{p:C,f:z}=this.wNAF(T),{p:H,f:P}=this.wNAF(_);C=E.constTimeNegate(R,C),H=E.constTimeNegate(L,H),H=new m(e.mul(H.px,b.beta),H.py,H.pz),p=C.add(H),B=z.add(P)}else{let{p:R,f:T}=this.wNAF(h);p=R,B=T}return m.normalizeZ([p,B])[0]}multiplyAndAddUnsafe(h,b,v){let p=m.BASE,B=(T,L)=>L===Mt||L===nt||!T.equals(p)?T.multiplyUnsafe(L):T.multiply(L),R=B(this,b).add(B(h,v));return R.is0()?void 0:R}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:b}=t;if(h===nt)return!0;if(b)return b(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:b}=t;return h===nt?this:b?b(m,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Ct("isCompressed",h),this.assertValidity(),o(m,this,h)}toHex(h=!0){return Ct("isCompressed",h),jt(this.toRawBytes(h))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let S=t.nBitLength,E=xr(m,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function Wc(r){let t=Ze(r);return Nt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function oi(r){let t=Wc(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(w){return V(w,n)}function a(w){return yr(w,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:l}=Zc({...t,toBytes(w,I,D){let x=I.toAffine(),d=e.toBytes(x.x),g=Zt;return Ct("isCompressed",D),D?g(Uint8Array.from([I.hasEvenY()?2:3]),d):g(Uint8Array.from([4]),d,e.toBytes(x.y))},fromBytes(w){let I=w.length,D=w[0],x=w.subarray(1);if(I===o&&(D===2||D===3)){let d=Pt(x);if(!mr(d,nt,e.ORDER))throw new Error("Point is not on curve");let g=f(d),A;try{A=e.sqrt(g)}catch(N){let k=N instanceof Error?": "+N.message:"";throw new Error("Point is not on curve"+k)}let U=(A&nt)===nt;return(D&1)===1!==U&&(A=e.neg(A)),{x:d,y:A}}else if(I===s&&D===4){let d=e.fromBytes(x.subarray(0,e.BYTES)),g=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:d,y:g}}else{let d=o,g=s;throw new Error("invalid Point, expected length of "+d+", or uncompressed "+g+", got "+I)}}}),m=w=>jt(oe(w,t.nByteLength));function S(w){let I=n>>nt;return w>I}function E(w){return S(w)?i(-w):w}let y=(w,I,D)=>Pt(w.slice(I,D));class h{constructor(I,D,x){gt("r",I,nt,n),gt("s",D,nt,n),this.r=I,this.s=D,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(I){let D=t.nByteLength;return I=G("compactSignature",I,D*2),new h(y(I,0,D),y(I,D,2*D))}static fromDER(I){let{r:D,s:x}=Ht.toSig(G("DER",I));return new h(D,x)}assertValidity(){}addRecoveryBit(I){return new h(this.r,this.s,I)}recoverPublicKey(I){let{r:D,s:x,recovery:d}=this,g=T(G("msgHash",I));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let A=d===2||d===3?D+t.n:D;if(A>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let U=(d&1)===0?"02":"03",K=c.fromHex(U+m(A)),N=a(A),k=i(-g*N),O=i(x*N),q=c.BASE.multiplyAndAddUnsafe(K,k,O);if(!q)throw new Error("point at infinify");return q.assertValidity(),q}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return je(this.toDERHex())}toDERHex(){return Ht.hexFromSig(this)}toCompactRawBytes(){return je(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let b={isValidPrivateKey(w){try{return u(w),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let w=_n(t.n);return ws(t.randomBytes(w),t.n)},precompute(w=8,I=c.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function v(w,I=!0){return c.fromPrivateKey(w).toRawBytes(I)}function p(w){let I=re(w),D=typeof w=="string",x=(I||D)&&w.length;return I?x===o||x===s:D?x===2*o||x===2*s:w instanceof c}function B(w,I,D=!0){if(p(w))throw new Error("first arg must be private key");if(!p(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(u(w)).toRawBytes(D)}let R=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let I=Pt(w),D=w.length*8-t.nBitLength;return D>0?I>>BigInt(D):I},T=t.bits2int_modN||function(w){return i(R(w))},L=se(t.nBitLength);function _(w){return gt("num < 2^"+t.nBitLength,w,Mt,L),oe(w,t.nByteLength)}function C(w,I,D=z){if(["recovered","canonical"].some(Z=>Z in D))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:d}=t,{lowS:g,prehash:A,extraEntropy:U}=D;g==null&&(g=!0),w=G("msgHash",w),ri(D),A&&(w=G("prehashed msgHash",x(w)));let K=T(w),N=u(I),k=[_(N),_(K)];if(U!=null&&U!==!1){let Z=U===!0?d(e.BYTES):U;k.push(G("extraEntropy",Z))}let O=Zt(...k),q=K;function $(Z){let ot=R(Z);if(!l(ot))return;let dt=a(ot),rt=c.BASE.multiply(ot).toAffine(),it=i(rt.x);if(it===Mt)return;let bt=i(dt*i(q+it*N));if(bt===Mt)return;let Et=(rt.x===it?0:2)|Number(rt.y&nt),Re=bt;return g&&S(bt)&&(Re=E(bt),Et^=1),new h(it,Re,Et)}return{seed:O,k2sig:$}}let z={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function P(w,I,D=z){let{seed:x,k2sig:d}=C(w,I,D),g=t;return ps(g.hash.outputLen,g.nByteLength,g.hmac)(x,d)}c.BASE._setWindowSize(8);function Q(w,I,D,x=H){let d=w;I=G("msgHash",I),D=G("publicKey",D);let{lowS:g,prehash:A,format:U}=x;if(ri(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(U!==void 0&&U!=="compact"&&U!=="der")throw new Error("format must be compact or der");let K=typeof d=="string"||re(d),N=!K&&!U&&typeof d=="object"&&d!==null&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!K&&!N)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let k,O;try{if(N&&(k=new h(d.r,d.s)),K){try{U!=="compact"&&(k=h.fromDER(d))}catch(Et){if(!(Et instanceof Ht.Err))throw Et}!k&&U!=="der"&&(k=h.fromCompact(d))}O=c.fromHex(D)}catch{return!1}if(!k||g&&k.hasHighS())return!1;A&&(I=t.hash(I));let{r:q,s:$}=k,Z=T(I),ot=a($),dt=i(Z*ot),rt=i(q*ot),it=c.BASE.multiplyAndAddUnsafe(O,dt,rt)?.toAffine();return it?i(it.x)===q:!1}return{CURVE:t,getPublicKey:v,getSharedSecret:B,sign:P,verify:Q,ProjectivePoint:c,Signature:h,utils:b}}function Yc(r){return{hash:r,hmac:(t,...e)=>co(r,t,mn(...e)),randomBytes:lr}}function si(r,t){let e=n=>oi({...r,...Yc(n)});return{...e(t),create:e}}var ci=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ii=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xc=BigInt(1),uo=BigInt(2),ai=(r,t)=>(r+t/uo)/t;function $c(r){let t=ci,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%t,f=u*u*r%t,l=F(f,e,t)*f%t,m=F(l,e,t)*f%t,S=F(m,uo,t)*u%t,E=F(S,o,t)*S%t,y=F(E,s,t)*E%t,h=F(y,a,t)*y%t,b=F(h,c,t)*h%t,v=F(b,a,t)*y%t,p=F(v,e,t)*f%t,B=F(p,i,t)*E%t,R=F(B,n,t)*u%t,T=F(R,uo,t);if(!lo.eql(lo.sqr(T),r))throw new Error("Cannot find square root");return T}var lo=kt(ci,void 0,void 0,{sqrt:$c}),he=si({a:BigInt(0),b:BigInt(7),Fp:lo,n:ii,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ii,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Xc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=ai(s*r,t),c=ai(-n*r,t),u=V(r-a*e-c*o,t),f=V(-a*n-c*s,t),l=u>i,m=f>i;if(l&&(u=t-u),m&&(f=t-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:m,k2:f}}}},pr),md=BigInt(0);var yd=he.ProjectivePoint;function fi(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var ui=33;function li(r,t,e){let n=ir.digest(e instanceof Uint8Array?e:e.subarray());if(fi(n))return n.then(({digest:o})=>he.verify(t,o,r)).catch(o=>{throw new $e(String(o))});try{return he.verify(t,n.digest,r)}catch(o){throw new $e(String(o))}}var Lr=class{type="secp256k1";raw;_key;constructor(t){this._key=di(t),this.raw=hi(this._key)}toMultihash(){return It.digest(Se(this))}toCID(){return at.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return li(this._key,e,t)}};function pi(r){return new Lr(r)}function hi(r){return he.ProjectivePoint.fromHex(r).toRawBytes(!0)}function di(r){try{return he.ProjectivePoint.fromHex(r),r}catch(t){throw new de(String(t))}}function mi(r){if(r.byteLength===_e)return Ks(r);if(r.byteLength===ui)return pi(r);let t=Lt(r),e=t[1]?.[0];if(e===Vo||e===zo||e===Fo)return jo(t);if(t[0]?.[0]===ei)return Br(t,r);throw new J("Could not extract public key from raw bytes")}function Se(r){return Yt.encode({Type:xt[r.type],Data:r.raw})}var yi=Symbol.for("nodejs.util.inspect.custom"),Jc=114,tr=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()})`}[Hr]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return at.createV1(Jc,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ct(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ct(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[yi](){return`PeerId(${this.toString()})`}},_r=class extends tr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Cr=class extends tr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Dr=class extends tr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Qc=2336,ho=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=It.digest(Y(this.url))}[yi](){return`PeerId(${this.url})`}[Hr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return at.createV1(Qc,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=X(t)),t.toString()===this.toString())}};function xi(r){if(r.type==="Ed25519")return new Cr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Dr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new _r({multihash:r.toCID().multihash,publicKey:r});throw new Ke}function Te(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Tr=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function er(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Tr(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Tr(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var po=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=Te(),this.haveNext=Te()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Te(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Te(),await er(this.readNext.promise,e?.signal,e)}};function bi(){return new po}var Rr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function gi(r,t){let e=bi();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new tt;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:c,value:u}=await er(n.next(),i?.signal);return c===!0?null:u}for(;o.byteLength<i.bytes;){let{value:c,done:u}=await er(n.next(),i?.signal);if(u===!0)throw new Rr("unexpected end of input");o.append(c)}let a=o.sublist(0,i.bytes);return o.consume(i.bytes),a},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var Ur=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Kr=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Pr=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function wi(r,t={}){let e=gi(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Ot(t.maxDataLength));let n=t?.lengthDecoder??Ns,o=t?.lengthEncoder??Ps;return{read:async i=>{let a=-1,c=new tt;for(;;){c.append(await e.read({...i,bytes:1}));try{a=n(c)}catch(u){if(u instanceof RangeError)continue;throw u}if(a<0)throw new Ur("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new Pr("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Kr("message length too long");return e.read({...i,bytes:a})},write:async(i,a)=>{await e.write(new tt(o(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new tt(...i.flatMap(u=>[o(u.byteLength),u]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function Ei(r,t){let e=wi(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.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:()=>e.unwrap()};return n}var Nr;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubkey!=null&&(n.uint32(18),kr.codec().encode(e.pubkey,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.id=e.bytes();break}case 2:{s.pubkey=kr.codec().decode(e,e.uint32(),{limits:o.limits?.pubkey});break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(Nr||(Nr={}));var $t;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})($t||($t={}));var mo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(mo||(mo={}));(function(r){r.codec=()=>Xe(mo)})($t||($t={}));var kr;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),$t.codec().encode(e.Type,n)),e.Data!=null&&e.Data.byteLength>0&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={Data:At(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=$t.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(kr||(kr={}));var tf="/plaintext/2.0.0",yo=class{protocol=tf;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[bo]=["@libp2p/connection-encryption"];async secureInbound(t,e){return this._encrypt(t,e)}async secureOutbound(t,e){return this._encrypt(t,e)}async _encrypt(t,e){let n=Ei(t).pb(Nr);this.log("write pubkey exchange to peer %p",e?.remotePeer);let o=this.privateKey.publicKey,[,s]=await Promise.all([n.write({id:o.toMultihash().bytes,pubkey:{Type:$t[o.type],Data:o.raw}},e),n.read(e)]),i;try{if(s.pubkey==null)throw new pe("Public key missing");if(s.pubkey.Data.byteLength===0)throw new pe("Public key data too short");if(s.id==null)throw new pe("Remote id missing");let a=mi(s.pubkey.Data);if(i=xi(a),!ct(i.toMultihash().bytes,s.id))throw new Ue("Public key did not match id")}catch(a){throw this.log.error(a),new Ue("Invalid public key - "+a.message)}if(e?.remotePeer!=null&&!i.equals(e?.remotePeer))throw new rr;return this.log("plaintext key exchange completed successfully with peer %p",i),{conn:n.unwrap().unwrap(),remotePeer:i}}};function ef(){return r=>new yo(r)}return Di(rf);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js:
6
6
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
7
7
 
8
8
  @noble/curves/esm/abstract/utils.js:
9
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
10
-
11
9
  @noble/curves/esm/abstract/modular.js:
12
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
13
-
14
10
  @noble/curves/esm/abstract/curve.js:
15
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
16
-
17
11
  @noble/curves/esm/abstract/edwards.js:
18
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
19
-
20
12
  @noble/curves/esm/ed25519.js:
21
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
22
-
23
13
  @noble/curves/esm/abstract/weierstrass.js:
24
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
25
-
26
14
  @noble/curves/esm/_shortw_utils.js:
27
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
28
-
29
15
  @noble/curves/esm/secp256k1.js:
30
16
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
31
17
  */
32
18
  return Libp2PPlaintext}));
19
+ //# sourceMappingURL=index.min.js.map