@libp2p/peer-id 5.1.1 → 5.1.2-772b4011e
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 +2 -15
- package/dist/index.min.js.map +7 -0
- package/package.json +3 -3
- package/dist/typedoc-urls.json +0 -12
package/dist/index.min.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerId = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PPeerId=(()=>{var yr=Object.defineProperty;var vs=Object.getOwnPropertyDescriptor;var Is=Object.getOwnPropertyNames;var Ls=Object.prototype.hasOwnProperty;var ct=(r,t)=>{for(var e in t)yr(r,e,{get:t[e],enumerable:!0})},Cs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Is(t))!Ls.call(r,o)&&o!==e&&yr(r,o,{get:()=>t[o],enumerable:!(n=vs(t,o))||n.enumerable});return r};var Ts=r=>Cs(yr({},"__esModule",{value:!0}),r);var Ca={};ct(Ca,{peerIdFromCID:()=>ys,peerIdFromMultihash:()=>Un,peerIdFromPrivateKey:()=>va,peerIdFromPublicKey:()=>ms,peerIdFromString:()=>Ba});var br=Symbol.for("@libp2p/peer-id");var St=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Me=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var He=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},qe=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ee=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Sr={};ct(Sr,{base58btc:()=>Y,base58flickr:()=>Ps});var Da=new Uint8Array(0);function kn(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 vt(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 Mn(r){return new TextEncoder().encode(r)}function Hn(r){return new TextDecoder().decode(r)}function Us(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function u(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,h=0,g=0,A=w.length;g!==A&&w[g]===0;)g++,b++;for(var p=(A-g)*f+1>>>0,v=new Uint8Array(p);g!==A;){for(var _=w[g],U=0,I=p-1;(_!==0||U<h)&&I!==-1;I--,U++)_+=256*v[I]>>>0,v[I]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");h=U,g++}for(var T=p-h;T!==p&&v[T]===0;)T++;for(var L=a.repeat(b);T<p;++T)L+=r.charAt(v[T]);return L}function m(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var h=0,g=0;w[b]===a;)h++,b++;for(var A=(w.length-b)*d+1>>>0,p=new Uint8Array(A);w[b];){var v=e[w.charCodeAt(b)];if(v===255)return;for(var _=0,U=A-1;(v!==0||_<g)&&U!==-1;U--,_++)v+=c*p[U]>>>0,p[U]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");g=_,b++}if(w[b]!==" "){for(var I=A-g;I!==A&&p[I]===0;)I++;for(var T=new Uint8Array(h+(A-I)),L=h;I!==A;)T[L++]=p[I++];return T}}}function E(w){var b=m(w);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:m,decode:E}}var _s=Us,Ds=_s,Vn=Ds;var xr=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")}},gr=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 zn(this,t)}},wr=class{decoders;constructor(t){this.decoders=t}or(t){return zn(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 zn(r,t){return new wr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Er=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 xr(t,e,n),this.decoder=new gr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function re({name:r,prefix:t,encode:e,decode:n}){return new Er(r,t,e,n)}function Rt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Vn(e,r);return re({prefix:t,name:r,encode:n,decode:s=>vt(o(s))})}function Rs(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),c=0,a=0,d=0;for(let f=0;f<s;++f){let u=o[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,c+=e,c>=8&&(c-=8,i[d++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function Ks(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return re({prefix:t,name:r,encode(o){return Ks(o,n,e)},decode(o){return Rs(o,n,e,r)}})}var Y=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ps=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ar={};ct(Ar,{base32:()=>ne,base32hex:()=>Ms,base32hexpad:()=>qs,base32hexpadupper:()=>Vs,base32hexupper:()=>Hs,base32pad:()=>Os,base32padupper:()=>ks,base32upper:()=>Ns,base32z:()=>zs});var ne=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ns=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Os=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ks=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ms=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Hs=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qs=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vs=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zs=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Br={};ct(Br,{base36:()=>be,base36upper:()=>Fs});var be=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Fs=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var js=Gn,Fn=128,Gs=127,Zs=~Gs,Ys=Math.pow(2,31);function Gn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ys;)t[e++]=r&255|Fn,r/=128;for(;r&Zs;)t[e++]=r&255|Fn,r>>>=7;return t[e]=r|0,Gn.bytes=e-n+1,t}var Ws=vr,Xs=128,jn=127;function vr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw vr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&jn)<<o:(i&jn)*Math.pow(2,o),o+=7}while(i>=Xs);return vr.bytes=s-n,e}var $s=Math.pow(2,7),Js=Math.pow(2,14),Qs=Math.pow(2,21),ti=Math.pow(2,28),ei=Math.pow(2,35),ri=Math.pow(2,42),ni=Math.pow(2,49),oi=Math.pow(2,56),si=Math.pow(2,63),ii=function(r){return r<$s?1:r<Js?2:r<Qs?3:r<ti?4:r<ei?5:r<ri?6:r<ni?7:r<oi?8:r<si?9:10},ci={encode:js,decode:Ws,encodingLength:ii},ai=ci,xe=ai;function ge(r,t=0){return[xe.decode(r,t),xe.decode.bytes]}function oe(r,t,e=0){return xe.encode(r,t,e),t}function se(r){return xe.encodingLength(r)}function jt(r,t){let e=t.byteLength,n=se(r),o=n+se(e),s=new Uint8Array(o+e);return oe(r,s,0),oe(e,s,n),s.set(t,o),new ie(r,e,t,s)}function we(r){let t=vt(r),[e,n]=ge(t),[o,s]=ge(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ie(e,o,i,t)}function Zn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&kn(r.bytes,e.bytes)}}var ie=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Yn(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ui(e,Ir(r),t??Y.encoder);default:return hi(e,Ir(r),t??ne.encoder)}}var Wn=new WeakMap;function Ir(r){let t=Wn.get(r);if(t==null){let e=new Map;return Wn.set(r,e),e}return t}var ot=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!==Ee)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==li)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=jt(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&&Zn(t.multihash,n.multihash)}toString(t){return Yn(this,t)}toJSON(){return{"/":Yn(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??Xn(n,o,s.bytes))}else if(e[di]===!0){let{version:n,multihash:o,code:s}=e,i=we(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!==Ee)throw new Error(`Version 0 CID must use dag-pb (code: ${Ee}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Xn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ee,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=vt(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 ie(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[u,m]=ge(t.subarray(e));return e+=m,u},o=n(),s=Ee;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),d=e+a,f=d-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:d}}static parse(t,e){let[n,o]=fi(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 Ir(s).set(n,t),s}};function fi(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case ne.prefix:{let e=t??ne;return[ne.prefix,e.decode(r)]}case be.prefix:{let e=t??be;return[be.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 ui(r,t,e){let{prefix:n}=e;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function hi(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 Ee=112,li=18;function Xn(r,t,e){let n=se(r),o=n+se(t),s=new Uint8Array(o+e.byteLength);return oe(r,s,0),oe(t,s,n),s.set(e,o),s}var di=Symbol.for("@ipld/js-cid/CID");var Lr={};ct(Lr,{identity:()=>mt});var $n=0,pi="identity",Jn=vt;function mi(r){return jt($n,Jn(r))}var mt={code:$n,name:pi,encode:Jn,digest:mi};function yt(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 It(r=0){return new Uint8Array(r)}function ut(r=0){return new Uint8Array(r)}function ze(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ut(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var to=Symbol.for("@achingbrain/uint8arraylist");function Qn(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 Fe(r){return!!r?.[to]}var ht=class r{bufs;length;[to]=!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(Fe(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(Fe(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=Qn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Qn(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(Fe(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 ze(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:ze(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let d=t>=c&&t<a,f=e>c&&e<=a;if(d&&f){if(t===c&&e===a){n.push(i);break}let u=t-c;n.push(i.subarray(u,u+(e-t)));break}if(d){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Fe(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 u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let c=i,a=this.byteLength-n.byteLength,d=n.byteLength-1,f;for(let u=e;u<=a;u+=f){f=0;for(let m=d;m>=0;m--){let E=this.get(u+m);if(n[m]!==E){f=Math.max(1,m-c[E]);break}}if(f===0)return u}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=ut(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=It(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=It(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=It(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=ut(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=It(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=It(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=It(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=It(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=It(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(!yt(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 Cr={};ct(Cr,{base10:()=>yi});var yi=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var Tr={};ct(Tr,{base16:()=>bi,base16upper:()=>xi});var bi=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xi=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ur={};ct(Ur,{base2:()=>gi});var gi=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _r={};ct(_r,{base256emoji:()=>Bi});var eo=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}"),wi=eo.reduce((r,t,e)=>(r[e]=t,r),[]),Ei=eo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Si(r){return r.reduce((t,e)=>(t+=wi[e],t),"")}function Ai(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ei[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Bi=re({prefix:"\u{1F680}",name:"base256emoji",encode:Si,decode:Ai});var Dr={};ct(Dr,{base64:()=>vi,base64pad:()=>Ii,base64url:()=>Li,base64urlpad:()=>Ci});var vi=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ii=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Li=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ci=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Rr={};ct(Rr,{base8:()=>Ti});var Ti=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kr={};ct(Kr,{identity:()=>Ui});var Ui=re({prefix:"\0",name:"identity",encode:r=>Hn(r),decode:r=>Mn(r)});var yf=new TextEncoder,bf=new TextDecoder;var Or={};ct(Or,{sha256:()=>Se,sha512:()=>Ri});function Nr({name:r,code:t,encode:e}){return new Pr(r,t,e)}var Pr=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?jt(this.code,e):e.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function no(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Se=Nr({name:"sha2-256",code:18,encode:no("SHA-256")}),Ri=Nr({name:"sha2-512",code:19,encode:no("SHA-512")});var kr={...Kr,...Ur,...Rr,...Cr,...Tr,...Ar,...Br,...Sr,...Dr,..._r},Tf={...Or,...Lr};function so(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var oo=so("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Mr=so("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=ut(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ki={utf8:oo,"utf-8":oo,hex:kr.base16,latin1:Mr,ascii:Mr,binary:Mr,...kr},je=Ki;function Kt(r,t="utf8"){let e=je[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function pt(r,t="utf8"){let e=je[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Pi=parseInt("11111",2),Hr=parseInt("10000000",2),Ni=parseInt("01111111",2),io={0:Ae,1:Ae,2:Oi,3:Hi,4:qi,5:Mi,6:ki,16:Ae,22:Ae,48:Ae};function qr(r,t={offset:0}){let e=r[t.offset]Πif(t.offset++,io[e]!=null)return io[e](r,t);throw new Error("No decoder for tag "+e)}function Be(r,t){let e=0;if((r[t.offset]&Hr)===Hr){let n=r[t.offset]&Ni,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 Ae(r,t){Be(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=qr(r,t);if(n===null)break;e.push(n)}return e}function Oi(r,t){let e=Be(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 ki(r,t){let e=Be(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let d=r[t.offset];if(t.offset++,a.push(d&127),d<128){a.reverse();let f=0;for(let u=0;u<a.length;u++)f+=a[u]<<u*7;c+=`.${f}`,a=[]}}return c}function Mi(r,t){return t.offset++,null}function Hi(r,t){let e=Be(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 qi(r,t){let e=Be(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Vi(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new ht;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Vr(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Vi(r.byteLength);return new ht(Uint8Array.from([t.byteLength|Hr]),t)}function co(r){let t=new ht,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new ht(Uint8Array.from([2]),Vr(t),t)}function ao(r){let t=Uint8Array.from([0]),e=new ht(t,r);return new ht(Uint8Array.from([3]),Vr(e),e)}function Ge(r,t=48){let e=new ht;for(let n of r)e.append(n);return new ht(Uint8Array.from([t]),Vr(e),e)}async function fo(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 zi=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Fi=Uint8Array.from([6,5,43,129,4,0,34]),ji=Uint8Array.from([6,5,43,129,4,0,35]),Gi={ext:!0,kty:"EC",crv:"P-256"},Zi={ext:!0,kty:"EC",crv:"P-384"},Yi={ext:!0,kty:"EC",crv:"P-521"},zr=32,Fr=48,jr=66;function uo(r){let t=qr(r);return ho(t)}function ho(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===zr*2+1)return n=pt(t.subarray(e,e+zr),"base64url"),o=pt(t.subarray(e+zr),"base64url"),new ae({...Gi,key_ops:["verify"],x:n,y:o});if(t.byteLength===Fr*2+1)return n=pt(t.subarray(e,e+Fr),"base64url"),o=pt(t.subarray(e+Fr),"base64url"),new ae({...Zi,key_ops:["verify"],x:n,y:o});if(t.byteLength===jr*2+1)return n=pt(t.subarray(e,e+jr),"base64url"),o=pt(t.subarray(e+jr),"base64url"),new ae({...Yi,key_ops:["verify"],x:n,y:o});throw new St(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function lo(r){return Ge([co(Uint8Array.from([1])),Ge([Wi(r.crv)],160),Ge([ao(new ht(Uint8Array.from([4]),Kt(r.x??"","base64url"),Kt(r.y??"","base64url")))],161)]).subarray()}function Wi(r){if(r==="P-256")return zi;if(r==="P-384")return Fi;if(r==="P-521")return ji;throw new St(`Invalid curve ${r}`)}var ae=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=lo(this.jwk)),this._raw}toMultihash(){return mt.digest(fe(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}async verify(t,e){return fo(this.jwk,e,t)}};function po(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Xi(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ue(r,...t){if(!Xi(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 mo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");po(r.outputLen),po(r.blockLen)}function he(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){ue(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Gt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ze(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function bt(r,t){return r<<32-t|r>>>t}function bo(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function ve(r){return typeof r=="string"&&(r=bo(r)),ue(r),r}function Gr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ue(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 le=class{clone(){return this._cloneInto()}};function Ye(r){let t=n=>r().update(ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function We(r=32){if(Gt&&typeof Gt.getRandomValues=="function")return Gt.getRandomValues(new Uint8Array(r));if(Gt&&typeof Gt.randomBytes=="function")return Gt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function $i(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),c=Number(e&s),a=n?4:0,d=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+d,c,n)}function xo(r,t,e){return r&t^~r&e}function go(r,t,e){return r&t^r&e^t&e}var de=class extends le{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ze(this.buffer)}update(t){he(this);let{view:e,buffer:n,blockLen:o}=this;t=ve(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Ze(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){he(this),yo(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 u=i;u<o;u++)e[u]=0;$i(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Ze(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=a/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<d;u++)c.setUint32(4*u,f[u],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:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%e&&t.buffer.set(n),t}};var Xe=BigInt(4294967295),Zr=BigInt(32);function wo(r,t=!1){return t?{h:Number(r&Xe),l:Number(r>>Zr&Xe)}:{h:Number(r>>Zr&Xe)|0,l:Number(r&Xe)|0}}function Ji(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}=wo(r[o],t);[e[o],n[o]]=[s,i]}return[e,n]}var Qi=(r,t)=>BigInt(r>>>0)<<Zr|BigInt(t>>>0),tc=(r,t,e)=>r>>>e,ec=(r,t,e)=>r<<32-e|t>>>e,rc=(r,t,e)=>r>>>e|t<<32-e,nc=(r,t,e)=>r<<32-e|t>>>e,oc=(r,t,e)=>r<<64-e|t>>>e-32,sc=(r,t,e)=>r>>>e-32|t<<64-e,ic=(r,t)=>t,cc=(r,t)=>r,ac=(r,t,e)=>r<<e|t>>>32-e,fc=(r,t,e)=>t<<e|r>>>32-e,uc=(r,t,e)=>t<<e-32|r>>>64-e,hc=(r,t,e)=>r<<e-32|t>>>64-e;function lc(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var dc=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),pc=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,mc=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),yc=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,bc=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),xc=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var gc={fromBig:wo,split:Ji,toBig:Qi,shrSH:tc,shrSL:ec,rotrSH:rc,rotrSL:nc,rotrBH:oc,rotrBL:sc,rotr32H:ic,rotr32L:cc,rotlSH:ac,rotlSL:fc,rotlBH:uc,rotlBL:hc,add:lc,add3L:dc,add3H:pc,add4L:mc,add4H:yc,add5H:xc,add5L:bc},P=gc;var[wc,Ec]=P.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))),Pt=new Uint32Array(80),Nt=new Uint32Array(80),Yr=class extends de{constructor(){super(128,64,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:c,Dl:a,Eh:d,El:f,Fh:u,Fl:m,Gh:E,Gl:w,Hh:b,Hl:h}=this;return[t,e,n,o,s,i,c,a,d,f,u,m,E,w,b,h]}set(t,e,n,o,s,i,c,a,d,f,u,m,E,w,b,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=c|0,this.Dl=a|0,this.Eh=d|0,this.El=f|0,this.Fh=u|0,this.Fl=m|0,this.Gh=E|0,this.Gl=w|0,this.Hh=b|0,this.Hl=h|0}process(t,e){for(let p=0;p<16;p++,e+=4)Pt[p]=t.getUint32(e),Nt[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let v=Pt[p-15]|0,_=Nt[p-15]|0,U=P.rotrSH(v,_,1)^P.rotrSH(v,_,8)^P.shrSH(v,_,7),I=P.rotrSL(v,_,1)^P.rotrSL(v,_,8)^P.shrSL(v,_,7),T=Pt[p-2]|0,L=Nt[p-2]|0,z=P.rotrSH(T,L,19)^P.rotrBH(T,L,61)^P.shrSH(T,L,6),M=P.rotrSL(T,L,19)^P.rotrBL(T,L,61)^P.shrSL(T,L,6),O=P.add4L(I,M,Nt[p-7],Nt[p-16]),W=P.add4H(O,U,z,Pt[p-7],Pt[p-16]);Pt[p]=W|0,Nt[p]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:d,Dl:f,Eh:u,El:m,Fh:E,Fl:w,Gh:b,Gl:h,Hh:g,Hl:A}=this;for(let p=0;p<80;p++){let v=P.rotrSH(u,m,14)^P.rotrSH(u,m,18)^P.rotrBH(u,m,41),_=P.rotrSL(u,m,14)^P.rotrSL(u,m,18)^P.rotrBL(u,m,41),U=u&E^~u&b,I=m&w^~m&h,T=P.add5L(A,_,I,Ec[p],Nt[p]),L=P.add5H(T,g,v,U,wc[p],Pt[p]),z=T|0,M=P.rotrSH(n,o,28)^P.rotrBH(n,o,34)^P.rotrBH(n,o,39),O=P.rotrSL(n,o,28)^P.rotrBL(n,o,34)^P.rotrBL(n,o,39),W=n&s^n&c^s&c,S=o&i^o&a^i&a;g=b|0,A=h|0,b=E|0,h=w|0,E=u|0,w=m|0,{h:u,l:m}=P.add(d|0,f|0,L|0,z|0),d=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let C=P.add3L(z,O,S);n=P.add3H(C,L,M,W),o=C|0}({h:n,l:o}=P.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=P.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=P.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:f}=P.add(this.Dh|0,this.Dl|0,d|0,f|0),{h:u,l:m}=P.add(this.Eh|0,this.El|0,u|0,m|0),{h:E,l:w}=P.add(this.Fh|0,this.Fl|0,E|0,w|0),{h:b,l:h}=P.add(this.Gh|0,this.Gl|0,b|0,h|0),{h:g,l:A}=P.add(this.Hh|0,this.Hl|0,g|0,A|0),this.set(n,o,s,i,c,a,d,f,u,m,E,w,b,h,g,A)}roundClean(){Pt.fill(0),Nt.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 Eo=Ye(()=>new Yr);var Qe={};ct(Qe,{aInRange:()=>at,abool:()=>xt,abytes:()=>pe,bitGet:()=>Lc,bitLen:()=>Jr,bitMask:()=>Le,bitSet:()=>Cc,bytesToHex:()=>Ct,bytesToNumberBE:()=>Tt,bytesToNumberLE:()=>kt,concatBytes:()=>Ut,createHmacDrbg:()=>Qr,ensureBytes:()=>G,equalBytes:()=>vc,hexToBytes:()=>Yt,hexToNumber:()=>$r,inRange:()=>Ie,isBytes:()=>Ot,memoized:()=>Xt,notImplemented:()=>Uc,numberToBytesBE:()=>Mt,numberToBytesLE:()=>Wt,numberToHexUnpadded:()=>Zt,numberToVarBytesBE:()=>Bc,utf8ToBytes:()=>Ic,validateObject:()=>At});var $e=BigInt(0),Je=BigInt(1),Sc=BigInt(2);function Ot(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pe(r){if(!Ot(r))throw new Error("Uint8Array expected")}function xt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Ac=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Ct(r){pe(r);let t="";for(let e=0;e<r.length;e++)t+=Ac[r[e]];return t}function Zt(r){let t=r.toString(16);return t.length&1?"0"+t:t}function $r(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?$e:BigInt("0x"+r)}var Lt={_0:48,_9:57,A:65,F:70,a:97,f:102};function So(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt.A&&r<=Lt.F)return r-(Lt.A-10);if(r>=Lt.a&&r<=Lt.f)return r-(Lt.a-10)}function Yt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof 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=So(r.charCodeAt(s)),c=So(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Tt(r){return $r(Ct(r))}function kt(r){return pe(r),$r(Ct(Uint8Array.from(r).reverse()))}function Mt(r,t){return Yt(r.toString(16).padStart(t*2,"0"))}function Wt(r,t){return Mt(r,t).reverse()}function Bc(r){return Yt(Zt(r))}function G(r,t,e){let n;if(typeof t=="string")try{n=Yt(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Ot(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 Ut(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pe(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}function vc(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Ic(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Wr=r=>typeof r=="bigint"&&$e<=r;function Ie(r,t,e){return Wr(r)&&Wr(t)&&Wr(e)&&t<=r&&r<e}function at(r,t,e,n){if(!Ie(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Jr(r){let t;for(t=0;r>$e;r>>=Je,t+=1);return t}function Lc(r,t){return r>>BigInt(t)&Je}function Cc(r,t,e){return r|(e?Je:$e)<<BigInt(t)}var Le=r=>(Sc<<BigInt(r-1))-Je,Xr=r=>new Uint8Array(r),Ao=r=>Uint8Array.from(r);function Qr(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=Xr(r),o=Xr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...u)=>e(o,n,...u),a=(u=Xr())=>{o=c(Ao([0]),u),n=c(),u.length!==0&&(o=c(Ao([1]),u),n=c())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,m=[];for(;u<t;){n=c();let E=n.slice();m.push(E),u+=n.length}return Ut(...m)};return(u,m)=>{i(),a(u);let E;for(;!(E=m(d()));)a();return i(),E}}var Tc={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"||Ot(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 At(r,t,e={}){let n=(o,s,i)=>{let c=Tc[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};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}var Uc=()=>{throw new Error("not implemented")};function Xt(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 X=BigInt(0),F=BigInt(1),$t=BigInt(2),_c=BigInt(3),tn=BigInt(4),Bo=BigInt(5),vo=BigInt(8),Dc=BigInt(9),Rc=BigInt(16);function q(r,t){let e=r%t;return e>=X?e:t+e}function Kc(r,t,e){if(t<X)throw new Error("invalid exponent, negatives unsupported");if(e<=X)throw new Error("invalid modulus");if(e===F)return X;let n=F;for(;t>X;)t&F&&(n=n*r%e),r=r*r%e,t>>=F;return n}function j(r,t,e){let n=r;for(;t-- >X;)n*=n,n%=e;return n}function tr(r,t){if(r===X)throw new Error("invert: expected non-zero number");if(t<=X)throw new Error("invert: expected positive modulus, got "+t);let e=q(r,t),n=t,o=X,s=F,i=F,c=X;for(;e!==X;){let d=n/e,f=n%e,u=o-i*d,m=s-c*d;n=e,e=f,o=i,s=c,i=u,c=m}if(n!==F)throw new Error("invert: does not exist");return q(o,t)}function Pc(r){let t=(r-F)/$t,e,n,o;for(e=r-F,n=0;e%$t===X;e/=$t,n++);for(o=$t;o<r&&Kc(o,t,r)!==r-F;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+F)/tn;return function(a,d){let f=a.pow(d,i);if(!a.eql(a.sqr(f),d))throw new Error("Cannot find square root");return f}}let s=(e+F)/$t;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=n,f=c.pow(c.mul(c.ONE,o),e),u=c.pow(a,s),m=c.pow(a,e);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let E=1;for(let b=c.sqr(m);E<d&&!c.eql(b,c.ONE);E++)b=c.sqr(b);let w=c.pow(f,F<<BigInt(d-E-1));f=c.sqr(w),u=c.mul(u,w),m=c.mul(m,f),d=E}return u}}function Nc(r){if(r%tn===_c){let t=(r+F)/tn;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%vo===Bo){let t=(r-Bo)/vo;return function(n,o){let s=n.mul(o,$t),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,$t),i),d=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(d),o))throw new Error("Cannot find square root");return d}}return r%Rc,Pc(r)}var Io=(r,t)=>(q(r,t)&F)===F,Oc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function en(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Oc.reduce((n,o)=>(n[o]="function",n),t);return At(r,e)}function kc(r,t,e){if(e<X)throw new Error("invalid exponent, negatives unsupported");if(e===X)return r.ONE;if(e===F)return t;let n=r.ONE,o=t;for(;e>X;)e&F&&(n=r.mul(n,o)),o=r.sqr(o),e>>=F;return n}function Mc(r,t){let e=new Array(t.length),n=t.reduce((s,i,c)=>r.is0(i)?s:(e[c]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return t.reduceRight((s,i,c)=>r.is0(i)?s:(e[c]=r.mul(s,e[c]),r.mul(s,i)),o),e}function rn(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ht(r,t,e=!1,n={}){if(r<=X)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=rn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Le(o),ZERO:X,ONE:F,create:a=>q(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return X<=a&&a<r},is0:a=>a===X,isOdd:a=>(a&F)===F,neg:a=>q(-a,r),eql:(a,d)=>a===d,sqr:a=>q(a*a,r),add:(a,d)=>q(a+d,r),sub:(a,d)=>q(a-d,r),mul:(a,d)=>q(a*d,r),pow:(a,d)=>kc(c,a,d),div:(a,d)=>q(a*tr(d,r),r),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>tr(a,r),sqrt:n.sqrt||(a=>(i||(i=Nc(r)),i(c,a))),invertBatch:a=>Mc(c,a),cmov:(a,d,f)=>f?d:a,toBytes:a=>e?Wt(a,s):Mt(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?kt(a):Tt(a)}});return Object.freeze(c)}function Lo(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 nn(r){let t=Lo(r);return t+Math.ceil(t/2)}function Co(r,t,e=!1){let n=r.length,o=Lo(t),s=nn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?kt(r):Tt(r),c=q(i,t-F)+F;return e?Wt(c,o):Mt(c,o)}var To=BigInt(0),er=BigInt(1);function on(r,t){let e=t.negate();return r?e:t}function Uo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function sn(r,t){Uo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Hc(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 qc(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 cn=new WeakMap,_o=new WeakMap;function an(r){return _o.get(r)||1}function rr(r,t){return{constTimeNegate:on,hasPrecomputes(e){return an(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>To;)n&er&&(o=o.add(s)),s=s.double(),n>>=er;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=sn(n,t),i=[],c=e,a=c;for(let d=0;d<o;d++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let{windows:s,windowSize:i}=sn(e,t),c=r.ZERO,a=r.BASE,d=BigInt(2**e-1),f=2**e,u=BigInt(e);for(let m=0;m<s;m++){let E=m*i,w=Number(o&d);o>>=u,w>i&&(w-=f,o+=er);let b=E,h=E+Math.abs(w)-1,g=m%2!==0,A=w<0;w===0?a=a.add(on(g,n[b])):c=c.add(on(A,n[h]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,s=r.ZERO){let{windows:i,windowSize:c}=sn(e,t),a=BigInt(2**e-1),d=2**e,f=BigInt(e);for(let u=0;u<i;u++){let m=u*c;if(o===To)break;let E=Number(o&a);if(o>>=f,E>c&&(E-=d,o+=er),E===0)continue;let w=n[m+Math.abs(E)-1];E<0&&(w=w.negate()),s=s.add(w)}return s},getPrecomputes(e,n,o){let s=cn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&cn.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){Uo(n,t),_o.set(e,n),cn.delete(e)}}}function nr(r,t,e,n){if(Hc(e,r),qc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=Jr(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,a=new Array(c+1).fill(o),d=Math.floor((t.BITS-1)/i)*i,f=o;for(let u=d;u>=0;u-=i){a.fill(o);for(let E=0;E<n.length;E++){let w=n[E],b=Number(w>>BigInt(u)&BigInt(c));a[b]=a[b].add(e[E])}let m=o;for(let E=a.length-1,w=o;E>0;E--)w=w.add(a[E]),m=m.add(w);if(f=f.add(m),u!==0)for(let E=0;E<i;E++)f=f.double()}return f}function Ce(r){return en(r.Fp),At(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var gt=BigInt(0),ft=BigInt(1),or=BigInt(2),Vc=BigInt(8),zc={zip215:!0};function Fc(r){let t=Ce(r);return At(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Do(r){let t=Fc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,d=or<<BigInt(c*8)-ft,f=e.create,u=Ht(t.n,t.nBitLength),m=t.uvRatio||((y,l)=>{try{return{isValid:!0,value:e.sqrt(y*e.inv(l))}}catch{return{isValid:!1,value:gt}}}),E=t.adjustScalarBytes||(y=>y),w=t.domain||((y,l,x)=>{if(xt("phflag",x),l.length||x)throw new Error("Contexts/pre-hash are not supported");return y});function b(y,l){at("coordinate "+y,l,gt,d)}function h(y){if(!(y instanceof p))throw new Error("ExtendedPoint expected")}let g=Xt((y,l)=>{let{ex:x,ey:B,ez:D}=y,R=y.is0();l==null&&(l=R?Vc:e.inv(D));let N=f(x*l),k=f(B*l),K=f(D*l);if(R)return{x:gt,y:ft};if(K!==ft)throw new Error("invZ was invalid");return{x:N,y:k}}),A=Xt(y=>{let{a:l,d:x}=t;if(y.is0())throw new Error("bad point: ZERO");let{ex:B,ey:D,ez:R,et:N}=y,k=f(B*B),K=f(D*D),H=f(R*R),V=f(H*H),$=f(k*l),J=f(H*f($+K)),tt=f(V+f(x*f(k*K)));if(J!==tt)throw new Error("bad point: equation left != right (1)");let et=f(B*D),it=f(R*N);if(et!==it)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(l,x,B,D){this.ex=l,this.ey=x,this.ez=B,this.et=D,b("x",l),b("y",x),b("z",B),b("t",D),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(l){if(l instanceof p)throw new Error("extended point not allowed");let{x,y:B}=l||{};return b("x",x),b("y",B),new p(x,B,ft,f(x*B))}static normalizeZ(l){let x=e.invertBatch(l.map(B=>B.ez));return l.map((B,D)=>B.toAffine(x[D])).map(p.fromAffine)}static msm(l,x){return nr(p,u,l,x)}_setWindowSize(l){U.setWindowSize(this,l)}assertValidity(){A(this)}equals(l){h(l);let{ex:x,ey:B,ez:D}=this,{ex:R,ey:N,ez:k}=l,K=f(x*k),H=f(R*D),V=f(B*k),$=f(N*D);return K===H&&V===$}is0(){return this.equals(p.ZERO)}negate(){return new p(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:l}=t,{ex:x,ey:B,ez:D}=this,R=f(x*x),N=f(B*B),k=f(or*f(D*D)),K=f(l*R),H=x+B,V=f(f(H*H)-R-N),$=K+N,J=$-k,tt=K-N,et=f(V*J),it=f($*tt),nt=f(V*tt),Et=f(J*$);return new p(et,it,Et,nt)}add(l){h(l);let{a:x,d:B}=t,{ex:D,ey:R,ez:N,et:k}=this,{ex:K,ey:H,ez:V,et:$}=l;if(x===BigInt(-1)){let _n=f((R-D)*(H+K)),Dn=f((R+D)*(H-K)),mr=f(Dn-_n);if(mr===gt)return this.double();let Rn=f(N*or*$),Kn=f(k*or*V),Pn=Kn+Rn,Nn=Dn+_n,On=Kn-Rn,Es=f(Pn*mr),Ss=f(Nn*On),As=f(Pn*On),Bs=f(mr*Nn);return new p(Es,Ss,Bs,As)}let J=f(D*K),tt=f(R*H),et=f(k*B*$),it=f(N*V),nt=f((D+R)*(K+H)-J-tt),Et=it-et,Bt=it+et,ye=f(tt-x*J),bs=f(nt*Et),xs=f(Bt*ye),gs=f(nt*ye),ws=f(Et*Bt);return new p(bs,xs,ws,gs)}subtract(l){return this.add(l.negate())}wNAF(l){return U.wNAFCached(this,l,p.normalizeZ)}multiply(l){let x=l;at("scalar",x,ft,n);let{p:B,f:D}=this.wNAF(x);return p.normalizeZ([B,D])[0]}multiplyUnsafe(l,x=p.ZERO){let B=l;return at("scalar",B,gt,n),B===gt?_:this.is0()||B===ft?this:U.wNAFCachedUnsafe(this,B,p.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(l){return g(this,l)}clearCofactor(){let{h:l}=t;return l===ft?this:this.multiplyUnsafe(l)}static fromHex(l,x=!1){let{d:B,a:D}=t,R=e.BYTES;l=G("pointHex",l,R),xt("zip215",x);let N=l.slice(),k=l[R-1];N[R-1]=k&-129;let K=kt(N),H=x?d:e.ORDER;at("pointHex.y",K,gt,H);let V=f(K*K),$=f(V-ft),J=f(B*V-D),{isValid:tt,value:et}=m($,J);if(!tt)throw new Error("Point.fromHex: invalid y coordinate");let it=(et&ft)===ft,nt=(k&128)!==0;if(!x&&et===gt&&nt)throw new Error("Point.fromHex: x=0 and x_0=1");return nt!==it&&(et=f(-et)),p.fromAffine({x:et,y:K})}static fromPrivateKey(l){return L(l).point}toRawBytes(){let{x:l,y:x}=this.toAffine(),B=Wt(x,e.BYTES);return B[B.length-1]|=l&ft?128:0,B}toHex(){return Ct(this.toRawBytes())}}p.BASE=new p(t.Gx,t.Gy,ft,f(t.Gx*t.Gy)),p.ZERO=new p(gt,ft,ft,gt);let{BASE:v,ZERO:_}=p,U=rr(p,c*8);function I(y){return q(y,n)}function T(y){return I(kt(y))}function L(y){let l=e.BYTES;y=G("private key",y,l);let x=G("hashed private key",s(y),2*l),B=E(x.slice(0,l)),D=x.slice(l,2*l),R=T(B),N=v.multiply(R),k=N.toRawBytes();return{head:B,prefix:D,scalar:R,point:N,pointBytes:k}}function z(y){return L(y).pointBytes}function M(y=new Uint8Array,...l){let x=Ut(...l);return T(s(w(x,G("context",y),!!o)))}function O(y,l,x={}){y=G("message",y),o&&(y=o(y));let{prefix:B,scalar:D,pointBytes:R}=L(l),N=M(x.context,B,y),k=v.multiply(N).toRawBytes(),K=M(x.context,k,R,y),H=I(N+K*D);at("signature.s",H,gt,n);let V=Ut(k,Wt(H,e.BYTES));return G("result",V,e.BYTES*2)}let W=zc;function S(y,l,x,B=W){let{context:D,zip215:R}=B,N=e.BYTES;y=G("signature",y,2*N),l=G("message",l),x=G("publicKey",x,N),R!==void 0&&xt("zip215",R),o&&(l=o(l));let k=kt(y.slice(N,2*N)),K,H,V;try{K=p.fromHex(x,R),H=p.fromHex(y.slice(0,N),R),V=v.multiplyUnsafe(k)}catch{return!1}if(!R&&K.isSmallOrder())return!1;let $=M(D,H.toRawBytes(),K.toRawBytes(),l);return H.add(K.multiplyUnsafe($)).subtract(V).clearCofactor().equals(p.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:z,sign:O,verify:S,ExtendedPoint:p,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(e.BYTES),precompute(y=8,l=p.BASE){return l._setWindowSize(y),l.multiply(BigInt(3)),l}}}}var fn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ro=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ru=BigInt(0),jc=BigInt(1),Ko=BigInt(2),Ku=BigInt(3),Gc=BigInt(5),Zc=BigInt(8);function Yc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=fn,c=r*r%s*r%s,a=j(c,Ko,s)*c%s,d=j(a,jc,s)*r%s,f=j(d,Gc,s)*d%s,u=j(f,t,s)*f%s,m=j(u,e,s)*u%s,E=j(m,n,s)*m%s,w=j(E,o,s)*E%s,b=j(w,o,s)*E%s,h=j(b,t,s)*f%s;return{pow_p_5_8:j(h,Ko,s)*r%s,b2:c}}function Wc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xc(r,t){let e=fn,n=q(t*t*t,e),o=q(n*n*t,e),s=Yc(r*o).pow_p_5_8,i=q(r*n*s,e),c=q(t*i*i,e),a=i,d=q(i*Ro,e),f=c===r,u=c===q(-r,e),m=c===q(-r*Ro,e);return f&&(i=a),(u||m)&&(i=d),Io(i,e)&&(i=q(-i,e)),{isValid:f||u,value:i}}var $c=Ht(fn,void 0,!0),Jc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:$c,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Zc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Eo,randomBytes:We,adjustScalarBytes:Wc,uvRatio:Xc},Po=Do(Jc);var sr=32;function No(r,t,e){return Po.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ir=class{type="Ed25519";raw;constructor(t){this.raw=un(t,sr)}toMultihash(){return mt.digest(fe(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return No(this.raw,e,t)}};function ko(r){return r=un(r,sr),new ir(r)}function un(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new St(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var ta=Math.pow(2,7),ea=Math.pow(2,14),ra=Math.pow(2,21),Mo=Math.pow(2,28),Ho=Math.pow(2,35),qo=Math.pow(2,42),Vo=Math.pow(2,49),st=128,qt=127;function Te(r){if(r<ta)return 1;if(r<ea)return 2;if(r<ra)return 3;if(r<Mo)return 4;if(r<Ho)return 5;if(r<qo)return 6;if(r<Vo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function zo(r,t,e=0){switch(Te(r)){case 8:t[e++]=r&255|st,r/=128;case 7:t[e++]=r&255|st,r/=128;case 6:t[e++]=r&255|st,r/=128;case 5:t[e++]=r&255|st,r/=128;case 4:t[e++]=r&255|st,r>>>=7;case 3:t[e++]=r&255|st,r>>>=7;case 2:t[e++]=r&255|st,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Fo(r,t){let e=r[t],n=0;if(n+=e&qt,e<st||(e=r[t+1],n+=(e&qt)<<7,e<st)||(e=r[t+2],n+=(e&qt)<<14,e<st)||(e=r[t+3],n+=(e&qt)<<21,e<st)||(e=r[t+4],n+=(e&qt)*Mo,e<st)||(e=r[t+5],n+=(e&qt)*Ho,e<st)||(e=r[t+6],n+=(e&qt)*qo,e<st)||(e=r[t+7],n+=(e&qt)*Vo,e<st))return n;throw new RangeError("Could not decode varint")}var hn=new Float32Array([-0]),Vt=new Uint8Array(hn.buffer);function jo(r,t,e){hn[0]=r,t[e]=Vt[0],t[e+1]=Vt[1],t[e+2]=Vt[2],t[e+3]=Vt[3]}function Go(r,t){return Vt[0]=r[t],Vt[1]=r[t+1],Vt[2]=r[t+2],Vt[3]=r[t+3],hn[0]}var ln=new Float64Array([-0]),rt=new Uint8Array(ln.buffer);function Zo(r,t,e){ln[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3],t[e+4]=rt[4],t[e+5]=rt[5],t[e+6]=rt[6],t[e+7]=rt[7]}function Yo(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],rt[4]=r[t+4],rt[5]=r[t+5],rt[6]=r[t+6],rt[7]=r[t+7],ln[0]}var na=BigInt(Number.MAX_SAFE_INTEGER),oa=BigInt(Number.MIN_SAFE_INTEGER),lt=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 Jt;if(t<na&&t>oa)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>Wo&&(o=0n,++n>Wo&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Jt;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):Jt}},Jt=new lt(0,0);Jt.toBigInt=function(){return 0n};Jt.zzEncode=Jt.zzDecode=function(){return this};Jt.length=function(){return 1};var Wo=4294967296n;function Xo(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 $o(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function dn(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 wt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function cr(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var pn=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,wt(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 wt(this,4);return cr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw wt(this,4);return cr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw wt(this,4);let t=Go(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw wt(this,4);let t=Yo(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 wt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return $o(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw wt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw wt(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 lt(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 wt(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 wt(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 wt(this,8);let t=cr(this.buf,this.pos+=4),e=cr(this.buf,this.pos+=4);return new lt(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=Fo(this.buf,this.pos);return this.pos+=Te(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 mn(r){return new pn(r instanceof Uint8Array?r:r.subarray())}function ar(r,t,e){let n=mn(r);return t.decode(n,void 0,e)}function yn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ut(i);o+i>t&&(n=ut(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var Qt=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function bn(){}var gn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},sa=yn();function ia(r){return globalThis.Buffer!=null?ut(r):sa(r)}var _e=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(bn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Qt(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new wn((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(fr,10,lt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=lt.fromBigInt(t);return this._push(fr,e.length(),e)}uint64Number(t){return this._push(zo,Te(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=lt.fromBigInt(t).zzEncode();return this._push(fr,e.length(),e)}sint64Number(t){let e=lt.fromNumber(t).zzEncode();return this._push(fr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(xn,1,t?1:0)}fixed32(t){return this._push(Ue,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=lt.fromBigInt(t);return this._push(Ue,4,e.lo)._push(Ue,4,e.hi)}fixed64Number(t){let e=lt.fromNumber(t);return this._push(Ue,4,e.lo)._push(Ue,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(jo,4,t)}double(t){return this._push(Zo,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(xn,1,0):this.uint32(e)._push(aa,e,t)}string(t){let e=Xo(t);return e!==0?this.uint32(e)._push(dn,e,t):this._push(xn,1,0)}fork(){return this.states=new gn(this),this.head=this.tail=new Qt(bn,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 Qt(bn,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=ia(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function xn(r,t,e){t[e]=r&255}function ca(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var wn=class extends Qt{next;constructor(t,e){super(ca,t,e),this.next=void 0}};function fr(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 Ue(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 aa(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(_e.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(fa,t,r),this},_e.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ua,t,r),this});function fa(r,t,e){t.set(r,e)}function ua(r,t,e){r.length<40?dn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Kt(r),e)}function En(){return new _e}function ur(r,t){let e=En();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var me;(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"})(me||(me={}));function hr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Sn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return hr("enum",me.VARINT,e,n)}function lr(r,t){return hr("message",me.LENGTH_DELIMITED,r,t)}var dt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(dt||(dt={}));var An;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(An||(An={}));(function(r){r.codec=()=>Sn(An)})(dt||(dt={}));var De;(function(r){let t;r.codec=()=>(t==null&&(t=lr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),dt.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 c=e.uint32();switch(c>>>3){case 1:{s.Type=dt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ur(e,r.codec()),r.decode=(e,n)=>ar(e,r.codec(),n)})(De||(De={}));var Bn;(function(r){let t;r.codec=()=>(t==null&&(t=lr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),dt.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 c=e.uint32();switch(c>>>3){case 1:{s.Type=dt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>ur(e,r.codec()),r.decode=(e,n)=>ar(e,r.codec(),n)})(Bn||(Bn={}));var Re=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var la=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]),zt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ft=new Uint32Array(64),vn=class extends de{constructor(){super(64,32,8,!1),this.A=zt[0]|0,this.B=zt[1]|0,this.C=zt[2]|0,this.D=zt[3]|0,this.E=zt[4]|0,this.F=zt[5]|0,this.G=zt[6]|0,this.H=zt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let u=0;u<16;u++,e+=4)Ft[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Ft[u-15],E=Ft[u-2],w=bt(m,7)^bt(m,18)^m>>>3,b=bt(E,17)^bt(E,19)^E>>>10;Ft[u]=b+Ft[u-7]+w+Ft[u-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:d,H:f}=this;for(let u=0;u<64;u++){let m=bt(c,6)^bt(c,11)^bt(c,25),E=f+m+xo(c,a,d)+la[u]+Ft[u]|0,b=(bt(n,2)^bt(n,13)^bt(n,22))+go(n,o,s)|0;f=d,d=a,a=c,c=i+E|0,i=s,s=o,o=n,n=E+b|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,d,f)}roundClean(){Ft.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Qo=Ye(()=>new vn);var dr=class extends le{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,mo(t);let n=ve(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 he(this),this.iHash.update(t),this}digestInto(t){he(this),ue(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:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},In=(r,t,e)=>new dr(r,t).update(e).digest();In.create=(r,t)=>new dr(r,t);function ts(r){r.lowS!==void 0&&xt("lowS",r.lowS),r.prehash!==void 0&&xt("prehash",r.prehash)}function da(r){let t=Ce(r);At(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{bytesToNumberBE:pa,hexToBytes:ma}=Qe,Ln=class extends Error{constructor(t=""){super(t)}},_t={Err:Ln,_tlv:{encode:(r,t)=>{let{Err:e}=_t;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=Zt(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Zt(o.length/2|128):"";return Zt(r)+s+o+t},decode(r,t){let{Err:e}=_t,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 a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let d=t.subarray(n,n+a);if(d.length!==a)throw new e("tlv.decode: length bytes not complete");if(d[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of d)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=_t;if(r<Dt)throw new t("integer: negative integers are not allowed");let e=Zt(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}=_t;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 pa(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=_t,o=typeof r=="string"?ma(r):r;pe(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:d,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(d)}},hexFromSig(r){let{_tlv:t,_int:e}=_t,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Dt=BigInt(0),Q=BigInt(1),Vh=BigInt(2),es=BigInt(3),zh=BigInt(4);function ya(r){let t=da(r),{Fp:e}=t,n=Ht(t.n,t.nBitLength),o=t.toBytes||((b,h,g)=>{let A=h.toAffine();return Ut(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),s=t.fromBytes||(b=>{let h=b.subarray(1),g=e.fromBytes(h.subarray(0,e.BYTES)),A=e.fromBytes(h.subarray(e.BYTES,2*e.BYTES));return{x:g,y:A}});function i(b){let{a:h,b:g}=t,A=e.sqr(b),p=e.mul(A,b);return e.add(e.add(p,e.mul(b,h)),g)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(b){return Ie(b,Q,t.n)}function a(b){let{allowedPrivateKeyLengths:h,nByteLength:g,wrapPrivateKey:A,n:p}=t;if(h&&typeof b!="bigint"){if(Ot(b)&&(b=Ct(b)),typeof b!="string"||!h.includes(b.length))throw new Error("invalid private key");b=b.padStart(g*2,"0")}let v;try{v=typeof b=="bigint"?b:Tt(G("private key",b,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof b)}return A&&(v=q(v,p)),at("private key",v,Q,p),v}function d(b){if(!(b instanceof m))throw new Error("ProjectivePoint expected")}let f=Xt((b,h)=>{let{px:g,py:A,pz:p}=b;if(e.eql(p,e.ONE))return{x:g,y:A};let v=b.is0();h==null&&(h=v?e.ONE:e.inv(p));let _=e.mul(g,h),U=e.mul(A,h),I=e.mul(p,h);if(v)return{x:e.ZERO,y:e.ZERO};if(!e.eql(I,e.ONE))throw new Error("invZ was invalid");return{x:_,y:U}}),u=Xt(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:h,y:g}=b.toAffine();if(!e.isValid(h)||!e.isValid(g))throw new Error("bad point: x or y not FE");let A=e.sqr(g),p=i(h);if(!e.eql(A,p))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(h,g,A){if(this.px=h,this.py=g,this.pz=A,h==null||!e.isValid(h))throw new Error("x required");if(g==null||!e.isValid(g))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:g,y:A}=h||{};if(!h||!e.isValid(g)||!e.isValid(A))throw new Error("invalid affine point");if(h instanceof m)throw new Error("projective point not allowed");let p=v=>e.eql(v,e.ZERO);return p(g)&&p(A)?m.ZERO:new m(g,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let g=e.invertBatch(h.map(A=>A.pz));return h.map((A,p)=>A.toAffine(g[p])).map(m.fromAffine)}static fromHex(h){let g=m.fromAffine(s(G("pointHex",h)));return g.assertValidity(),g}static fromPrivateKey(h){return m.BASE.multiply(a(h))}static msm(h,g){return nr(m,n,h,g)}_setWindowSize(h){w.setWindowSize(this,h)}assertValidity(){u(this)}hasEvenY(){let{y:h}=this.toAffine();if(e.isOdd)return!e.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){d(h);let{px:g,py:A,pz:p}=this,{px:v,py:_,pz:U}=h,I=e.eql(e.mul(g,U),e.mul(v,p)),T=e.eql(e.mul(A,U),e.mul(_,p));return I&&T}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:h,b:g}=t,A=e.mul(g,es),{px:p,py:v,pz:_}=this,U=e.ZERO,I=e.ZERO,T=e.ZERO,L=e.mul(p,p),z=e.mul(v,v),M=e.mul(_,_),O=e.mul(p,v);return O=e.add(O,O),T=e.mul(p,_),T=e.add(T,T),U=e.mul(h,T),I=e.mul(A,M),I=e.add(U,I),U=e.sub(z,I),I=e.add(z,I),I=e.mul(U,I),U=e.mul(O,U),T=e.mul(A,T),M=e.mul(h,M),O=e.sub(L,M),O=e.mul(h,O),O=e.add(O,T),T=e.add(L,L),L=e.add(T,L),L=e.add(L,M),L=e.mul(L,O),I=e.add(I,L),M=e.mul(v,_),M=e.add(M,M),L=e.mul(M,O),U=e.sub(U,L),T=e.mul(M,z),T=e.add(T,T),T=e.add(T,T),new m(U,I,T)}add(h){d(h);let{px:g,py:A,pz:p}=this,{px:v,py:_,pz:U}=h,I=e.ZERO,T=e.ZERO,L=e.ZERO,z=t.a,M=e.mul(t.b,es),O=e.mul(g,v),W=e.mul(A,_),S=e.mul(p,U),C=e.add(g,A),y=e.add(v,_);C=e.mul(C,y),y=e.add(O,W),C=e.sub(C,y),y=e.add(g,p);let l=e.add(v,U);return y=e.mul(y,l),l=e.add(O,S),y=e.sub(y,l),l=e.add(A,p),I=e.add(_,U),l=e.mul(l,I),I=e.add(W,S),l=e.sub(l,I),L=e.mul(z,y),I=e.mul(M,S),L=e.add(I,L),I=e.sub(W,L),L=e.add(W,L),T=e.mul(I,L),W=e.add(O,O),W=e.add(W,O),S=e.mul(z,S),y=e.mul(M,y),W=e.add(W,S),S=e.sub(O,S),S=e.mul(z,S),y=e.add(y,S),O=e.mul(W,y),T=e.add(T,O),O=e.mul(l,y),I=e.mul(C,I),I=e.sub(I,O),O=e.mul(C,W),L=e.mul(l,L),L=e.add(L,O),new m(I,T,L)}subtract(h){return this.add(h.negate())}is0(){return this.equals(m.ZERO)}wNAF(h){return w.wNAFCached(this,h,m.normalizeZ)}multiplyUnsafe(h){let{endo:g,n:A}=t;at("scalar",h,Dt,A);let p=m.ZERO;if(h===Dt)return p;if(this.is0()||h===Q)return this;if(!g||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,h,m.normalizeZ);let{k1neg:v,k1:_,k2neg:U,k2:I}=g.splitScalar(h),T=p,L=p,z=this;for(;_>Dt||I>Dt;)_&Q&&(T=T.add(z)),I&Q&&(L=L.add(z)),z=z.double(),_>>=Q,I>>=Q;return v&&(T=T.negate()),U&&(L=L.negate()),L=new m(e.mul(L.px,g.beta),L.py,L.pz),T.add(L)}multiply(h){let{endo:g,n:A}=t;at("scalar",h,Q,A);let p,v;if(g){let{k1neg:_,k1:U,k2neg:I,k2:T}=g.splitScalar(h),{p:L,f:z}=this.wNAF(U),{p:M,f:O}=this.wNAF(T);L=w.constTimeNegate(_,L),M=w.constTimeNegate(I,M),M=new m(e.mul(M.px,g.beta),M.py,M.pz),p=L.add(M),v=z.add(O)}else{let{p:_,f:U}=this.wNAF(h);p=_,v=U}return m.normalizeZ([p,v])[0]}multiplyAndAddUnsafe(h,g,A){let p=m.BASE,v=(U,I)=>I===Dt||I===Q||!U.equals(p)?U.multiplyUnsafe(I):U.multiply(I),_=v(this,g).add(v(h,A));return _.is0()?void 0:_}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:g}=t;if(h===Q)return!0;if(g)return g(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:g}=t;return h===Q?this:g?g(m,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return xt("isCompressed",h),this.assertValidity(),o(m,this,h)}toHex(h=!0){return xt("isCompressed",h),Ct(this.toRawBytes(h))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let E=t.nBitLength,w=rr(m,t.endo?Math.ceil(E/2):E);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function ba(r){let t=Ce(r);return At(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function rs(r){let t=ba(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(S){return q(S,n)}function c(S){return tr(S,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:u}=ya({...t,toBytes(S,C,y){let l=C.toAffine(),x=e.toBytes(l.x),B=Ut;return xt("isCompressed",y),y?B(Uint8Array.from([C.hasEvenY()?2:3]),x):B(Uint8Array.from([4]),x,e.toBytes(l.y))},fromBytes(S){let C=S.length,y=S[0],l=S.subarray(1);if(C===o&&(y===2||y===3)){let x=Tt(l);if(!Ie(x,Q,e.ORDER))throw new Error("Point is not on curve");let B=f(x),D;try{D=e.sqrt(B)}catch(k){let K=k instanceof Error?": "+k.message:"";throw new Error("Point is not on curve"+K)}let R=(D&Q)===Q;return(y&1)===1!==R&&(D=e.neg(D)),{x,y:D}}else if(C===s&&y===4){let x=e.fromBytes(l.subarray(0,e.BYTES)),B=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x,y:B}}else{let x=o,B=s;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+B+", got "+C)}}}),m=S=>Ct(Mt(S,t.nByteLength));function E(S){let C=n>>Q;return S>C}function w(S){return E(S)?i(-S):S}let b=(S,C,y)=>Tt(S.slice(C,y));class h{constructor(C,y,l){this.r=C,this.s=y,this.recovery=l,this.assertValidity()}static fromCompact(C){let y=t.nByteLength;return C=G("compactSignature",C,y*2),new h(b(C,0,y),b(C,y,2*y))}static fromDER(C){let{r:y,s:l}=_t.toSig(G("DER",C));return new h(y,l)}assertValidity(){at("r",this.r,Q,n),at("s",this.s,Q,n)}addRecoveryBit(C){return new h(this.r,this.s,C)}recoverPublicKey(C){let{r:y,s:l,recovery:x}=this,B=U(G("msgHash",C));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let D=x===2||x===3?y+t.n:y;if(D>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(x&1)===0?"02":"03",N=a.fromHex(R+m(D)),k=c(D),K=i(-B*k),H=i(l*k),V=a.BASE.multiplyAndAddUnsafe(N,K,H);if(!V)throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Yt(this.toDERHex())}toDERHex(){return _t.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Yt(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let g={isValidPrivateKey(S){try{return d(S),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let S=nn(t.n);return Co(t.randomBytes(S),t.n)},precompute(S=8,C=a.BASE){return C._setWindowSize(S),C.multiply(BigInt(3)),C}};function A(S,C=!0){return a.fromPrivateKey(S).toRawBytes(C)}function p(S){let C=Ot(S),y=typeof S=="string",l=(C||y)&&S.length;return C?l===o||l===s:y?l===2*o||l===2*s:S instanceof a}function v(S,C,y=!0){if(p(S))throw new Error("first arg must be private key");if(!p(C))throw new Error("second arg must be public key");return a.fromHex(C).multiply(d(S)).toRawBytes(y)}let _=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let C=Tt(S),y=S.length*8-t.nBitLength;return y>0?C>>BigInt(y):C},U=t.bits2int_modN||function(S){return i(_(S))},I=Le(t.nBitLength);function T(S){return at("num < 2^"+t.nBitLength,S,Dt,I),Mt(S,t.nByteLength)}function L(S,C,y=z){if(["recovered","canonical"].some(J=>J in y))throw new Error("sign() legacy options not supported");let{hash:l,randomBytes:x}=t,{lowS:B,prehash:D,extraEntropy:R}=y;B==null&&(B=!0),S=G("msgHash",S),ts(y),D&&(S=G("prehashed msgHash",l(S)));let N=U(S),k=d(C),K=[T(k),T(N)];if(R!=null&&R!==!1){let J=R===!0?x(e.BYTES):R;K.push(G("extraEntropy",J))}let H=Ut(...K),V=N;function $(J){let tt=_(J);if(!u(tt))return;let et=c(tt),it=a.BASE.multiply(tt).toAffine(),nt=i(it.x);if(nt===Dt)return;let Et=i(et*i(V+nt*k));if(Et===Dt)return;let Bt=(it.x===nt?0:2)|Number(it.y&Q),ye=Et;return B&&E(Et)&&(ye=w(Et),Bt^=1),new h(nt,ye,Bt)}return{seed:H,k2sig:$}}let z={lowS:t.lowS,prehash:!1},M={lowS:t.lowS,prehash:!1};function O(S,C,y=z){let{seed:l,k2sig:x}=L(S,C,y),B=t;return Qr(B.hash.outputLen,B.nByteLength,B.hmac)(l,x)}a.BASE._setWindowSize(8);function W(S,C,y,l=M){let x=S;C=G("msgHash",C),y=G("publicKey",y);let{lowS:B,prehash:D,format:R}=l;if(ts(l),"strict"in l)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let N=typeof x=="string"||Ot(x),k=!N&&!R&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!N&&!k)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,H;try{if(k&&(K=new h(x.r,x.s)),N){try{R!=="compact"&&(K=h.fromDER(x))}catch(Bt){if(!(Bt instanceof _t.Err))throw Bt}!K&&R!=="der"&&(K=h.fromCompact(x))}H=a.fromHex(y)}catch{return!1}if(!K||B&&K.hasHighS())return!1;D&&(C=t.hash(C));let{r:V,s:$}=K,J=U(C),tt=c($),et=i(J*tt),it=i(V*tt),nt=a.BASE.multiplyAndAddUnsafe(H,et,it)?.toAffine();return nt?i(nt.x)===V:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:v,sign:O,verify:W,ProjectivePoint:a,Signature:h,utils:g}}function xa(r){return{hash:r,hmac:(t,...e)=>In(r,t,Gr(...e)),randomBytes:We}}function ns(r,t){let e=n=>rs({...r,...xa(n)});return{...e(t),create:e}}var is=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),os=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ga=BigInt(1),Cn=BigInt(2),ss=(r,t)=>(r+t/Cn)/t;function wa(r){let t=is,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),d=r*r*r%t,f=d*d*r%t,u=j(f,e,t)*f%t,m=j(u,e,t)*f%t,E=j(m,Cn,t)*d%t,w=j(E,o,t)*E%t,b=j(w,s,t)*w%t,h=j(b,c,t)*b%t,g=j(h,a,t)*h%t,A=j(g,c,t)*b%t,p=j(A,e,t)*f%t,v=j(p,i,t)*w%t,_=j(v,n,t)*d%t,U=j(_,Cn,t);if(!Tn.eql(Tn.sqr(U),r))throw new Error("Cannot find square root");return U}var Tn=Ht(is,void 0,void 0,{sqrt:wa}),te=ns({a:BigInt(0),b:BigInt(7),Fp:Tn,n:os,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=os,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ga*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=ss(s*r,t),a=ss(-n*r,t),d=q(r-c*e-a*o,t),f=q(-c*n-a*s,t),u=d>i,m=f>i;if(u&&(d=t-d),m&&(f=t-f),d>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:d,k2neg:m,k2:f}}}},Qo),Jh=BigInt(0);var Qh=te.ProjectivePoint;function cs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function as(r,t,e){let n=Se.digest(e instanceof Uint8Array?e:e.subarray());if(cs(n))return n.then(({digest:o})=>te.verify(t,o,r)).catch(o=>{throw new Re(String(o))});try{return te.verify(t,n.digest,r)}catch(o){throw new Re(String(o))}}var pr=class{type="secp256k1";raw;_key;constructor(t){this._key=us(t),this.raw=fs(this._key)}toMultihash(){return mt.digest(fe(this))}toCID(){return ot.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return as(this._key,e,t)}};function hs(r){return new pr(r)}function fs(r){return te.ProjectivePoint.fromHex(r).toRawBytes(!0)}function us(r){try{return te.ProjectivePoint.fromHex(r),r}catch(t){throw new Me(String(t))}}function ls(r){let{Type:t,Data:e}=De.decode(r.digest),n=e??new Uint8Array;switch(t){case dt.Ed25519:return ko(n);case dt.secp256k1:return hs(n);case dt.ECDSA:return uo(n);default:throw new ee}}function fe(r){return De.encode({Type:dt[r.type],Data:r.raw})}var ds=Symbol.for("nodejs.util.inspect.custom"),Ea=114,Ke=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()})`}[br]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ot.createV1(Ea,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return yt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[ds](){return`PeerId(${this.toString()})`}},Pe=class extends Ke{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ne=class extends Ke{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Oe=class extends Ke{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Sa=2336,ke=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=mt.digest(Kt(this.url))}[ds](){return`PeerId(${this.url})`}[br]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ot.createV1(Sa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=pt(t)),t.toString()===this.toString())}};var Aa=114,ps=2336;function Ba(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=we(Y.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return ys(ot.parse(r));if(t==null)throw new St('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=we(t.decode(r))}return Un(e)}function ms(r){if(r.type==="Ed25519")return new Ne({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Oe({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Pe({multihash:r.toCID().multihash,publicKey:r});throw new ee}function va(r){return ms(r.publicKey)}function Un(r){if(La(r))return new Pe({multihash:r});if(Ia(r))try{let t=ls(r);if(t.type==="Ed25519")return new Ne({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Oe({multihash:r,publicKey:t})}catch{let e=pt(r.digest);return new ke(new URL(e))}throw new qe("Supplied PeerID Multihash is invalid")}function ys(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Aa&&r.code!==ps)throw new He("Supplied PeerID CID is invalid");if(r.code===ps){let t=pt(r.multihash.digest);return new ke(new URL(t))}return Un(r.multihash)}function Ia(r){return r.code===mt.code}function La(r){return r.code===Se.code}return Ts(Ca);})();
|
|
2
|
+
"use strict";var Libp2PPeerId=(()=>{var yr=Object.defineProperty;var Rs=Object.getOwnPropertyDescriptor;var Ks=Object.getOwnPropertyNames;var Ps=Object.prototype.hasOwnProperty;var ft=(r,t)=>{for(var e in t)yr(r,e,{get:t[e],enumerable:!0})},Ns=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ks(t))!Ps.call(r,o)&&o!==e&&yr(r,o,{get:()=>t[o],enumerable:!(n=Rs(t,o))||n.enumerable});return r};var Os=r=>Ns(yr({},"__esModule",{value:!0}),r);var sa={};ft(sa,{peerIdFromCID:()=>_s,peerIdFromMultihash:()=>Rn,peerIdFromPrivateKey:()=>ra,peerIdFromPublicKey:()=>Ls,peerIdFromString:()=>ea});var xr=Symbol.for("@libp2p/peer-id");var Et=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 je=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ge=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var ne=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Sr={};ft(Sr,{base58btc:()=>Y,base58flickr:()=>zs});var fa=new Uint8Array(0);function Pn(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 vt(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 Nn(r){return new TextEncoder().encode(r)}function On(r){return new TextDecoder().decode(r)}function ks(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var c=r.length,a=r.charAt(0),h=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function u(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,l=0,b=0,B=E.length;b!==B&&E[b]===0;)b++,y++;for(var p=(B-b)*f+1>>>0,v=new Uint8Array(p);b!==B;){for(var D=E[b],T=0,L=p-1;(D!==0||T<l)&&L!==-1;L--,T++)D+=256*v[L]>>>0,v[L]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");l=T,b++}for(var _=p-l;_!==p&&v[_]===0;)_++;for(var U=a.repeat(y);_<p;++_)U+=r.charAt(v[_]);return U}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 l=0,b=0;E[y]===a;)l++,y++;for(var B=(E.length-y)*h+1>>>0,p=new Uint8Array(B);E[y];){var v=e[E.charCodeAt(y)];if(v===255)return;for(var D=0,T=B-1;(v!==0||D<b)&&T!==-1;T--,D++)v+=c*p[T]>>>0,p[T]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");b=D,y++}if(E[y]!==" "){for(var L=B-b;L!==B&&p[L]===0;)L++;for(var _=new Uint8Array(l+(B-L)),U=l;L!==B;)_[U++]=p[L++];return _}}}function S(E){var y=m(E);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:m,decode:S}}var Hs=ks,Ms=Hs,Hn=Ms;var br=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")}},gr=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 Mn(this,t)}},wr=class{decoders;constructor(t){this.decoders=t}or(t){return Mn(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 Mn(r,t){return new wr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Er=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 br(t,e,n),this.decoder=new gr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function oe({name:r,prefix:t,encode:e,decode:n}){return new Er(r,t,e,n)}function Pt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Hn(e,r);return oe({prefix:t,name:r,encode:n,decode:s=>vt(o(s))})}function qs(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),c=0,a=0,h=0;for(let f=0;f<s;++f){let u=o[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,c+=e,c>=8&&(c-=8,i[h++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return i}function Vs(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function j({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return oe({prefix:t,name:r,encode(o){return Vs(o,n,e)},decode(o){return qs(o,n,e,r)}})}var Y=Pt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),zs=Pt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ar={};ft(Ar,{base32:()=>se,base32hex:()=>Zs,base32hexpad:()=>Ws,base32hexpadupper:()=>Xs,base32hexupper:()=>Ys,base32pad:()=>js,base32padupper:()=>Gs,base32upper:()=>Fs,base32z:()=>$s});var se=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Fs=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),js=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gs=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Zs=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ys=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ws=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xs=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),$s=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Br={};ft(Br,{base36:()=>ge,base36upper:()=>Js});var ge=Pt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Js=Pt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qs=zn,qn=128,ti=127,ei=~ti,ri=Math.pow(2,31);function zn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ri;)t[e++]=r&255|qn,r/=128;for(;r&ei;)t[e++]=r&255|qn,r>>>=7;return t[e]=r|0,zn.bytes=e-n+1,t}var ni=vr,oi=128,Vn=127;function vr(r,n){var e=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw vr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Vn)<<o:(i&Vn)*Math.pow(2,o),o+=7}while(i>=oi);return vr.bytes=s-n,e}var si=Math.pow(2,7),ii=Math.pow(2,14),ci=Math.pow(2,21),ai=Math.pow(2,28),fi=Math.pow(2,35),ui=Math.pow(2,42),hi=Math.pow(2,49),li=Math.pow(2,56),di=Math.pow(2,63),pi=function(r){return r<si?1:r<ii?2:r<ci?3:r<ai?4:r<fi?5:r<ui?6:r<hi?7:r<li?8:r<di?9:10},mi={encode:Qs,decode:ni,encodingLength:pi},yi=mi,we=yi;function Ee(r,t=0){return[we.decode(r,t),we.decode.bytes]}function ie(r,t,e=0){return we.encode(r,t,e),t}function ce(r){return we.encodingLength(r)}function Ft(r,t){let e=t.byteLength,n=ce(r),o=n+ce(e),s=new Uint8Array(o+e);return ie(r,s,0),ie(e,s,n),s.set(t,o),new ae(r,e,t,s)}function Se(r){let t=vt(r),[e,n]=Ee(t),[o,s]=Ee(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ae(e,o,i,t)}function Fn(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Pn(r.bytes,e.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function jn(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return bi(e,Ir(r),t??Y.encoder);default:return gi(e,Ir(r),t??se.encoder)}}var Gn=new WeakMap;function Ir(r){let t=Gn.get(r);if(t==null){let e=new Map;return Gn.set(r,e),e}return t}var nt=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!==Ae)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==wi)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=Ft(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&&Fn(t.multihash,n.multihash)}toString(t){return jn(this,t)}toJSON(){return{"/":jn(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??Zn(n,o,s.bytes))}else if(e[Ei]===!0){let{version:n,multihash:o,code:s}=e,i=Se(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!==Ae)throw new Error(`Version 0 CID must use dag-pb (code: ${Ae}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Zn(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ae,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=vt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new ae(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,m]=Ee(t.subarray(e));return e+=m,u},o=n(),s=Ae;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,c=n(),a=n(),h=e+a,f=h-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:h}}static parse(t,e){let[n,o]=xi(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 Ir(s).set(n,t),s}};function xi(r,t){switch(r[0]){case"Q":{let e=t??Y;return[Y.prefix,e.decode(`${Y.prefix}${r}`)]}case Y.prefix:{let e=t??Y;return[Y.prefix,e.decode(r)]}case se.prefix:{let e=t??se;return[se.prefix,e.decode(r)]}case ge.prefix:{let e=t??ge;return[ge.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 bi(r,t,e){let{prefix:n}=e;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function gi(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 Ae=112,wi=18;function Zn(r,t,e){let n=ce(r),o=n+ce(t),s=new Uint8Array(o+e.byteLength);return ie(r,s,0),ie(t,s,n),s.set(e,o),s}var Ei=Symbol.for("@ipld/js-cid/CID");var Lr={};ft(Lr,{identity:()=>xt});var Yn=0,Si="identity",Wn=vt;function Ai(r){return Ft(Yn,Wn(r))}var xt={code:Yn,name:Si,encode:Wn,digest:Ai};function bt(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 It(r=0){return new Uint8Array(r)}function ut(r=0){return new Uint8Array(r)}function Ye(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=ut(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var $n=Symbol.for("@achingbrain/uint8arraylist");function Xn(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 We(r){return!!r?.[$n]}var ht=class r{bufs;length;[$n]=!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(We(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(We(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=Xn(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Xn(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(We(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 Ye(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Ye(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],c=o,a=c+i.byteLength;if(o=a,t>=a)continue;let h=t>=c&&t<a,f=e>c&&e<=a;if(h&&f){if(t===c&&e===a){n.push(i);break}let u=t-c;n.push(i.subarray(u,u+(e-t)));break}if(h){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(f){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!We(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 u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let c=i,a=this.byteLength-n.byteLength,h=n.byteLength-1,f;for(let u=e;u<=a;u+=f){f=0;for(let m=h;m>=0;m--){let S=this.get(u+m);if(n[m]!==S){f=Math.max(1,m-c[S]);break}}if(f===0)return u}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=ut(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=It(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=It(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=It(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=ut(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=It(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=It(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=It(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=It(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=It(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(!bt(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={};ft(_r,{base10:()=>Bi});var Bi=Pt({prefix:"9",name:"base10",alphabet:"0123456789"});var Ur={};ft(Ur,{base16:()=>vi,base16upper:()=>Ii});var vi=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ii=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Cr={};ft(Cr,{base2:()=>Li});var Li=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Tr={};ft(Tr,{base256emoji:()=>Di});var Jn=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}"),_i=Jn.reduce((r,t,e)=>(r[e]=t,r),[]),Ui=Jn.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Ci(r){return r.reduce((t,e)=>(t+=_i[e],t),"")}function Ti(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ui[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Di=oe({prefix:"\u{1F680}",name:"base256emoji",encode:Ci,decode:Ti});var Dr={};ft(Dr,{base64:()=>Ri,base64pad:()=>Ki,base64url:()=>Pi,base64urlpad:()=>Ni});var Ri=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ki=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pi=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ni=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Rr={};ft(Rr,{base8:()=>Oi});var Oi=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kr={};ft(Kr,{identity:()=>ki});var ki=oe({prefix:"\0",name:"identity",encode:r=>On(r),decode:r=>Nn(r)});var Ga=new TextEncoder,Za=new TextDecoder;var Or={};ft(Or,{sha256:()=>Be,sha512:()=>qi});function Nr({name:r,code:t,encode:e}){return new Pr(r,t,e)}var Pr=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?Ft(this.code,e):e.then(n=>Ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function to(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Be=Nr({name:"sha2-256",code:18,encode:to("SHA-256")}),qi=Nr({name:"sha2-512",code:19,encode:to("SHA-512")});var kr={...Kr,...Cr,...Rr,..._r,...Ur,...Ar,...Br,...Sr,...Dr,...Tr},sf={...Or,...Lr};function ro(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var eo=ro("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Hr=ro("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=ut(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Vi={utf8:eo,"utf-8":eo,hex:kr.base16,latin1:Hr,ascii:Hr,binary:Hr,...kr},Xe=Vi;function Nt(r,t="utf8"){let e=Xe[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function mt(r,t="utf8"){let e=Xe[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var zi=parseInt("11111",2),Mr=parseInt("10000000",2),Fi=parseInt("01111111",2),no={0:ve,1:ve,2:ji,3:Yi,4:Wi,5:Zi,6:Gi,16:ve,22:ve,48:ve};function qr(r,t={offset:0}){let e=r[t.offset]&zi;if(t.offset++,no[e]!=null)return no[e](r,t);throw new Error("No decoder for tag "+e)}function Ie(r,t){let e=0;if((r[t.offset]&Mr)===Mr){let n=r[t.offset]&Fi,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 ve(r,t){Ie(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=qr(r,t);if(n===null)break;e.push(n)}return e}function ji(r,t){let e=Ie(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 Gi(r,t){let e=Ie(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let c=`${s}.${i}`,a=[];for(;t.offset<n;){let h=r[t.offset];if(t.offset++,a.push(h&127),h<128){a.reverse();let f=0;for(let u=0;u<a.length;u++)f+=a[u]<<u*7;c+=`.${f}`,a=[]}}return c}function Zi(r,t){return t.offset++,null}function Yi(r,t){let e=Ie(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 Wi(r,t){let e=Ie(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Xi(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new ht;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function Vr(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Xi(r.byteLength);return new ht(Uint8Array.from([t.byteLength|Mr]),t)}function oo(r){let t=new ht,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new ht(Uint8Array.from([2]),Vr(t),t)}function so(r){let t=Uint8Array.from([0]),e=new ht(t,r);return new ht(Uint8Array.from([3]),Vr(e),e)}function $e(r,t=48){let e=new ht;for(let n of r)e.append(n);return new ht(Uint8Array.from([t]),Vr(e),e)}async function io(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 $i=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ji=Uint8Array.from([6,5,43,129,4,0,34]),Qi=Uint8Array.from([6,5,43,129,4,0,35]),tc={ext:!0,kty:"EC",crv:"P-256"},ec={ext:!0,kty:"EC",crv:"P-384"},rc={ext:!0,kty:"EC",crv:"P-521"},zr=32,Fr=48,jr=66;function co(r){let t=qr(r);return ao(t)}function ao(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===zr*2+1)return n=mt(t.subarray(e,e+zr),"base64url"),o=mt(t.subarray(e+zr),"base64url"),new ue({...tc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Fr*2+1)return n=mt(t.subarray(e,e+Fr),"base64url"),o=mt(t.subarray(e+Fr),"base64url"),new ue({...ec,key_ops:["verify"],x:n,y:o});if(t.byteLength===jr*2+1)return n=mt(t.subarray(e,e+jr),"base64url"),o=mt(t.subarray(e+jr),"base64url"),new ue({...rc,key_ops:["verify"],x:n,y:o});throw new Et(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function fo(r){return $e([oo(Uint8Array.from([1])),$e([nc(r.crv)],160),$e([so(new ht(Uint8Array.from([4]),Nt(r.x??"","base64url"),Nt(r.y??"","base64url")))],161)]).subarray()}function nc(r){if(r==="P-256")return $i;if(r==="P-384")return Ji;if(r==="P-521")return Qi;throw new Et(`Invalid curve ${r}`)}var ue=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=fo(this.jwk)),this._raw}toMultihash(){return xt.digest(he(this))}toCID(){return nt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}async verify(t,e){return io(this.jwk,e,t)}};var jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function oc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Je(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Gt(r,...t){if(!oc(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 uo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Je(r.outputLen),Je(r.blockLen)}function de(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 ho(r,t){Gt(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Lt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Qe(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function gt(r,t){return r<<32-t|r>>>t}function lo(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Le(r){return typeof r=="string"&&(r=lo(r)),Gt(r),r}function Gr(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Gt(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 le=class{};function Zr(r){let t=n=>r().update(Le(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function tr(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 sc(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),c=Number(e&s),a=n?4:0,h=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+h,c,n)}function po(r,t,e){return r&t^~r&e}function mo(r,t,e){return r&t^r&e^t&e}var _e=class extends le{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=Qe(this.buffer)}update(t){de(this),t=Le(t),Gt(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Qe(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){de(this),ho(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Lt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)e[u]=0;sc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Qe(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)c.setUint32(4*u,f[u],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:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},_t=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var er=BigInt(4294967295),yo=BigInt(32);function ic(r,t=!1){return t?{h:Number(r&er),l:Number(r>>yo&er)}:{h:Number(r>>yo&er)|0,l:Number(r&er)|0}}function xo(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:c}=ic(r[s],t);[n[s],o[s]]=[i,c]}return[n,o]}var Yr=(r,t,e)=>r>>>e,Wr=(r,t,e)=>r<<32-e|t>>>e,Zt=(r,t,e)=>r>>>e|t<<32-e,Yt=(r,t,e)=>r<<32-e|t>>>e,Ue=(r,t,e)=>r<<64-e|t>>>e-32,Ce=(r,t,e)=>r>>>e-32|t<<64-e;function St(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var bo=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),go=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,wo=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Eo=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,So=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ao=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var ac=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]),Ot=new Uint32Array(64),Xr=class extends _e{constructor(t=32){super(64,t,8,!1),this.A=_t[0]|0,this.B=_t[1]|0,this.C=_t[2]|0,this.D=_t[3]|0,this.E=_t[4]|0,this.F=_t[5]|0,this.G=_t[6]|0,this.H=_t[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,e,n,o,s,i,c,a]}set(t,e,n,o,s,i,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,e){for(let u=0;u<16;u++,e+=4)Ot[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Ot[u-15],S=Ot[u-2],E=gt(m,7)^gt(m,18)^m>>>3,y=gt(S,17)^gt(S,19)^S>>>10;Ot[u]=y+Ot[u-7]+E+Ot[u-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:h,H:f}=this;for(let u=0;u<64;u++){let m=gt(c,6)^gt(c,11)^gt(c,25),S=f+m+po(c,a,h)+ac[u]+Ot[u]|0,y=(gt(n,2)^gt(n,13)^gt(n,22))+mo(n,o,s)|0;f=h,h=a,a=c,c=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,c=c+this.E|0,a=a+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,h,f)}roundClean(){Lt(Ot)}destroy(){this.set(0,0,0,0,0,0,0,0),Lt(this.buffer)}};var Bo=xo(["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))),fc=Bo[0],uc=Bo[1],kt=new Uint32Array(80),Ht=new Uint32Array(80),$r=class extends _e{constructor(t=64){super(128,t,16,!1),this.Ah=tt[0]|0,this.Al=tt[1]|0,this.Bh=tt[2]|0,this.Bl=tt[3]|0,this.Ch=tt[4]|0,this.Cl=tt[5]|0,this.Dh=tt[6]|0,this.Dl=tt[7]|0,this.Eh=tt[8]|0,this.El=tt[9]|0,this.Fh=tt[10]|0,this.Fl=tt[11]|0,this.Gh=tt[12]|0,this.Gl=tt[13]|0,this.Hh=tt[14]|0,this.Hl=tt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:h,El:f,Fh:u,Fl:m,Gh:S,Gl:E,Hh:y,Hl:l}=this;return[t,e,n,o,s,i,c,a,h,f,u,m,S,E,y,l]}set(t,e,n,o,s,i,c,a,h,f,u,m,S,E,y,l){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=f|0,this.Fh=u|0,this.Fl=m|0,this.Gh=S|0,this.Gl=E|0,this.Hh=y|0,this.Hl=l|0}process(t,e){for(let p=0;p<16;p++,e+=4)kt[p]=t.getUint32(e),Ht[p]=t.getUint32(e+=4);for(let p=16;p<80;p++){let v=kt[p-15]|0,D=Ht[p-15]|0,T=Zt(v,D,1)^Zt(v,D,8)^Yr(v,D,7),L=Yt(v,D,1)^Yt(v,D,8)^Wr(v,D,7),_=kt[p-2]|0,U=Ht[p-2]|0,V=Zt(_,U,19)^Ue(_,U,61)^Yr(_,U,6),H=Yt(_,U,19)^Ce(_,U,61)^Wr(_,U,6),P=wo(L,H,Ht[p-7],Ht[p-16]),W=Eo(P,T,V,kt[p-7],kt[p-16]);kt[p]=W|0,Ht[p]=P|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:h,Dl:f,Eh:u,El:m,Fh:S,Fl:E,Gh:y,Gl:l,Hh:b,Hl:B}=this;for(let p=0;p<80;p++){let v=Zt(u,m,14)^Zt(u,m,18)^Ue(u,m,41),D=Yt(u,m,14)^Yt(u,m,18)^Ce(u,m,41),T=u&S^~u&y,L=m&E^~m&l,_=So(B,D,L,uc[p],Ht[p]),U=Ao(_,b,v,T,fc[p],kt[p]),V=_|0,H=Zt(n,o,28)^Ue(n,o,34)^Ue(n,o,39),P=Yt(n,o,28)^Ce(n,o,34)^Ce(n,o,39),W=n&s^n&c^s&c,w=o&i^o&a^i&a;b=y|0,B=l|0,y=S|0,l=E|0,S=u|0,E=m|0,{h:u,l:m}=St(h|0,f|0,U|0,V|0),h=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let I=bo(V,P,w);n=go(I,U,H,W),o=I|0}({h:n,l:o}=St(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=St(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=St(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:f}=St(this.Dh|0,this.Dl|0,h|0,f|0),{h:u,l:m}=St(this.Eh|0,this.El|0,u|0,m|0),{h:S,l:E}=St(this.Fh|0,this.Fl|0,S|0,E|0),{h:y,l}=St(this.Gh|0,this.Gl|0,y|0,l|0),{h:b,l:B}=St(this.Hh|0,this.Hl|0,b|0,B|0),this.set(n,o,s,i,c,a,h,f,u,m,S,E,y,l,b,B)}roundClean(){Lt(kt,Ht)}destroy(){Lt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var vo=Zr(()=>new Xr);var Io=Zr(()=>new $r);var en=BigInt(0),tn=BigInt(1);function Wt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function rn(r){if(!Wt(r))throw new Error("Uint8Array expected")}function At(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function Te(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Uo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?en:BigInt("0x"+r)}var Co=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",hc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Mt(r){if(rn(r),Co)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=hc[r[e]];return t}var Ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function Lo(r){if(r>=Ut._0&&r<=Ut._9)return r-Ut._0;if(r>=Ut.A&&r<=Ut.F)return r-(Ut.A-10);if(r>=Ut.a&&r<=Ut.f)return r-(Ut.a-10)}function De(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(Co)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=Lo(r.charCodeAt(s)),c=Lo(r.charCodeAt(s+1));if(i===void 0||c===void 0){let a=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Ct(r){return Uo(Mt(r))}function Xt(r){return rn(r),Uo(Mt(Uint8Array.from(r).reverse()))}function $t(r,t){return De(r.toString(16).padStart(t*2,"0"))}function pe(r,t){return $t(r,t).reverse()}function F(r,t,e){let n;if(typeof t=="string")try{n=De(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(Wt(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 qt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];rn(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 Jr=r=>typeof r=="bigint"&&en<=r;function rr(r,t,e){return Jr(r)&&Jr(t)&&Jr(e)&&t<=r&&r<e}function lt(r,t,e,n){if(!rr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function To(r){let t;for(t=0;r>en;r>>=tn,t+=1);return t}var Jt=r=>(tn<<BigInt(r))-tn,Qr=r=>new Uint8Array(r),_o=r=>Uint8Array.from(r);function Do(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=Qr(r),o=Qr(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...u)=>e(o,n,...u),a=(u=Qr(0))=>{o=c(_o([0]),u),n=c(),u.length!==0&&(o=c(_o([1]),u),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,m=[];for(;u<t;){n=c();let S=n.slice();m.push(S),u+=n.length}return qt(...m)};return(u,m)=>{i(),a(u);let S;for(;!(S=m(h()));)a();return i(),S}}var lc={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"||Wt(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 Tt(r,t,e={}){let n=(o,s,i)=>{let c=lc[s];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+a)};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 me(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 ot=BigInt(0),X=BigInt(1),Qt=BigInt(2),dc=BigInt(3),nn=BigInt(4),Ro=BigInt(5),Ko=BigInt(8),pc=BigInt(9),mc=BigInt(16);function q(r,t){let e=r%t;return e>=ot?e:t+e}function z(r,t,e){let n=r;for(;t-- >ot;)n*=n,n%=e;return n}function nr(r,t){if(r===ot)throw new Error("invert: expected non-zero number");if(t<=ot)throw new Error("invert: expected positive modulus, got "+t);let e=q(r,t),n=t,o=ot,s=X,i=X,c=ot;for(;e!==ot;){let h=n/e,f=n%e,u=o-i*h,m=s-c*h;n=e,e=f,o=i,s=c,i=u,c=m}if(n!==X)throw new Error("invert: does not exist");return q(o,t)}function yc(r){let t=r-X,e=0;for(;t%Qt===ot;)t/=Qt,e++;let n=Qt,o=Dt(r);for(;n<r&&Po(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1){let i=(r+X)/nn;return function(a,h){let f=a.pow(h,i);if(!a.eql(a.sqr(f),h))throw new Error("Cannot find square root");return f}}let s=(t+X)/Qt;return function(c,a){if(!Po(c,a))throw new Error("Cannot find square root");let h=e,f=c.pow(c.mul(c.ONE,n),t),u=c.pow(a,s),m=c.pow(a,t);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let S=1;for(let y=c.sqr(m);S<h&&!c.eql(y,c.ONE);S++)y=c.sqr(y);let E=c.pow(f,X<<BigInt(h-S-1));f=c.sqr(E),u=c.mul(u,E),m=c.mul(m,f),h=S}return u}}function xc(r){return r%nn===dc?function(e,n){let o=(r+X)/nn,s=e.pow(n,o);if(!e.eql(e.sqr(s),n))throw new Error("Cannot find square root");return s}:r%Ko===Ro?function(e,n){let o=e.mul(n,Qt),s=(r-Ro)/Ko,i=e.pow(o,s),c=e.mul(n,i),a=e.mul(e.mul(c,Qt),i),h=e.mul(c,e.sub(a,e.ONE));if(!e.eql(e.sqr(h),n))throw new Error("Cannot find square root");return h}:(r%mc,yc(r))}var No=(r,t)=>(q(r,t)&X)===X,bc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function on(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=bc.reduce((n,o)=>(n[o]="function",n),t);return Tt(r,e)}function gc(r,t,e){if(e<ot)throw new Error("invalid exponent, negatives unsupported");if(e===ot)return r.ONE;if(e===X)return t;let n=r.ONE,o=t;for(;e>ot;)e&X&&(n=r.mul(n,o)),o=r.sqr(o),e>>=X;return n}function ye(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,c,a)=>r.is0(c)?i:(n[a]=i,r.mul(i,c)),r.ONE),s=r.inv(o);return t.reduceRight((i,c,a)=>r.is0(c)?i:(n[a]=r.mul(i,n[a]),r.mul(i,c)),s),n}function wc(r,t){let e=(r.ORDER-X)/Qt,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 Po(r,t){let e=wc(r,t);return e===0||e===1}function sn(r,t){t!==void 0&&Je(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Dt(r,t,e=!1,n={}){if(r<=ot)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=sn(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:Jt(o),ZERO:ot,ONE:X,create:a=>q(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return ot<=a&&a<r},is0:a=>a===ot,isOdd:a=>(a&X)===X,neg:a=>q(-a,r),eql:(a,h)=>a===h,sqr:a=>q(a*a,r),add:(a,h)=>q(a+h,r),sub:(a,h)=>q(a-h,r),mul:(a,h)=>q(a*h,r),pow:(a,h)=>gc(c,a,h),div:(a,h)=>q(a*nr(h,r),r),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>nr(a,r),sqrt:n.sqrt||(a=>(i||(i=xc(r)),i(c,a))),toBytes:a=>e?pe(a,s):$t(a,s),fromBytes:a=>{if(a.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+a.length);return e?Xt(a):Ct(a)},invertBatch:a=>ye(c,a),cmov:(a,h,f)=>f?h:a});return Object.freeze(c)}function Oo(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 cn(r){let t=Oo(r);return t+Math.ceil(t/2)}function ko(r,t,e=!1){let n=r.length,o=Oo(t),s=cn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?Xt(r):Ct(r),c=q(i,t-X)+X;return e?pe(c,o):$t(c,o)}var Ho=BigInt(0),ln=BigInt(1);function an(r,t){let e=t.negate();return r?e:t}function qo(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function fn(r,t){qo(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=Jt(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Mo(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,c=Number(r&o),a=r>>i;c>n&&(c-=s,a+=ln);let h=t*n,f=h+Math.abs(c)-1,u=c===0,m=c<0,S=t%2!==0;return{nextN:a,offset:f,isZero:u,isNeg:m,isNegF:S,offsetF:h}}function Ec(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 Sc(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 un=new WeakMap,Vo=new WeakMap;function hn(r){return Vo.get(r)||1}function or(r,t){return{constTimeNegate:an,hasPrecomputes(e){return hn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Ho;)n&ln&&(o=o.add(s)),s=s.double(),n>>=ln;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=fn(n,t),i=[],c=e,a=c;for(let h=0;h<o;h++){a=c,i.push(a);for(let f=1;f<s;f++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,c=fn(e,t);for(let a=0;a<c.windows;a++){let{nextN:h,offset:f,isZero:u,isNeg:m,isNegF:S,offsetF:E}=Mo(o,a,c);o=h,u?i=i.add(an(S,n[E])):s=s.add(an(m,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=fn(e,t);for(let c=0;c<i.windows&&o!==Ho;c++){let{nextN:a,offset:h,isZero:f,isNeg:u}=Mo(o,c,i);if(o=a,!f){let m=n[h];s=s.add(u?m.negate():m)}}return s},getPrecomputes(e,n,o){let s=un.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&un.set(n,o(s))),s},wNAFCached(e,n,o){let s=hn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=hn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){qo(n,t),Vo.set(e,n),un.delete(e)}}}function sr(r,t,e,n){if(Ec(e,r),Sc(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,s=To(BigInt(e.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=Jt(i),a=new Array(Number(c)+1).fill(o),h=Math.floor((t.BITS-1)/i)*i,f=o;for(let u=h;u>=0;u-=i){a.fill(o);for(let S=0;S<n.length;S++){let E=n[S],y=Number(E>>BigInt(u)&c);a[y]=a[y].add(e[S])}let m=o;for(let S=a.length-1,E=o;S>0;S--)E=E.add(a[S]),m=m.add(E);if(f=f.add(m),u!==0)for(let S=0;S<i;S++)f=f.double()}return f}function Re(r){return on(r.Fp),Tt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sn(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Bt=BigInt(0),st=BigInt(1),zo=BigInt(2),Ac=BigInt(8),Bc={zip215:!0};function vc(r){let t=Re(r);return Tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Fo(r){let t=vc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,h=zo<<BigInt(c*8)-st,f=e.create,u=Dt(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:Bt}}}),S=t.adjustScalarBytes||(x=>x),E=t.domain||((x,d,g)=>{if(At("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?st:Bt;lt("coordinate "+x,d,A,h)}function l(x){if(!(x instanceof p))throw new Error("ExtendedPoint expected")}let b=me((x,d)=>{let{ex:g,ey:A,ez:R}=x,K=x.is0();d==null&&(d=K?Ac:e.inv(R));let N=f(g*d),O=f(A*d),k=f(R*d);if(K)return{x:Bt,y:st};if(k!==st)throw new Error("invZ was invalid");return{x:N,y:O}}),B=me(x=>{let{a:d,d:g}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:A,ey:R,ez:K,et:N}=x,O=f(A*A),k=f(R*R),M=f(K*K),Z=f(M*M),G=f(O*d),Q=f(M*f(G+k)),ct=f(Z+f(g*f(O*k)));if(Q!==ct)throw new Error("bad point: equation left != right (1)");let $=f(A*R),et=f(K*N);if($!==et)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(d,g,A,R){y("x",d),y("y",g),y("z",A,!0),y("t",R),this.ex=d,this.ey=g,this.ez=A,this.et=R,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,st,f(g*A))}static normalizeZ(d){let g=ye(e,d.map(A=>A.ez));return d.map((A,R)=>A.toAffine(g[R])).map(p.fromAffine)}static msm(d,g){return sr(p,u,d,g)}_setWindowSize(d){T.setWindowSize(this,d)}assertValidity(){B(this)}equals(d){l(d);let{ex:g,ey:A,ez:R}=this,{ex:K,ey:N,ez:O}=d,k=f(g*O),M=f(K*R),Z=f(A*O),G=f(N*R);return k===M&&Z===G}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:R}=this,K=f(g*g),N=f(A*A),O=f(zo*f(R*R)),k=f(d*K),M=g+A,Z=f(f(M*M)-K-N),G=k+N,Q=G-O,ct=k-N,$=f(Z*Q),et=f(G*ct),at=f(Z*ct),yt=f(Q*G);return new p($,et,yt,at)}add(d){l(d);let{a:g,d:A}=t,{ex:R,ey:K,ez:N,et:O}=this,{ex:k,ey:M,ez:Z,et:G}=d,Q=f(R*k),ct=f(K*M),$=f(O*A*G),et=f(N*Z),at=f((R+K)*(k+M)-Q-ct),yt=et-$,be=et+$,Kn=f(ct-g*Q),Us=f(at*yt),Cs=f(be*Kn),Ts=f(at*Kn),Ds=f(yt*be);return new p(Us,Cs,Ds,Ts)}subtract(d){return this.add(d.negate())}wNAF(d){return T.wNAFCached(this,d,p.normalizeZ)}multiply(d){let g=d;lt("scalar",g,st,n);let{p:A,f:R}=this.wNAF(g);return p.normalizeZ([A,R])[0]}multiplyUnsafe(d,g=p.ZERO){let A=d;return lt("scalar",A,Bt,n),A===Bt?D:this.is0()||A===st?this:T.wNAFCachedUnsafe(this,A,p.normalizeZ,g)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===st?this:this.multiplyUnsafe(d)}static fromHex(d,g=!1){let{d:A,a:R}=t,K=e.BYTES;d=F("pointHex",d,K),At("zip215",g);let N=d.slice(),O=d[K-1];N[K-1]=O&-129;let k=Xt(N),M=g?h:e.ORDER;lt("pointHex.y",k,Bt,M);let Z=f(k*k),G=f(Z-st),Q=f(A*Z-R),{isValid:ct,value:$}=m(G,Q);if(!ct)throw new Error("Point.fromHex: invalid y coordinate");let et=($&st)===st,at=(O&128)!==0;if(!g&&$===Bt&&at)throw new Error("Point.fromHex: x=0 and x_0=1");return at!==et&&($=f(-$)),p.fromAffine({x:$,y:k})}static fromPrivateKey(d){let{scalar:g}=U(d);return v.multiply(g)}toRawBytes(){let{x:d,y:g}=this.toAffine(),A=pe(g,e.BYTES);return A[A.length-1]|=d&st?128:0,A}toHex(){return Mt(this.toRawBytes())}}p.BASE=new p(t.Gx,t.Gy,st,f(t.Gx*t.Gy)),p.ZERO=new p(Bt,st,st,Bt);let{BASE:v,ZERO:D}=p,T=or(p,c*8);function L(x){return q(x,n)}function _(x){return L(Xt(x))}function U(x){let d=e.BYTES;x=F("private key",x,d);let g=F("hashed private key",s(x),2*d),A=S(g.slice(0,d)),R=g.slice(d,2*d),K=_(A);return{head:A,prefix:R,scalar:K}}function V(x){let{head:d,prefix:g,scalar:A}=U(x),R=v.multiply(A),K=R.toRawBytes();return{head:d,prefix:g,scalar:A,point:R,pointBytes:K}}function H(x){return V(x).pointBytes}function P(x=Uint8Array.of(),...d){let g=qt(...d);return _(s(E(g,F("context",x),!!o)))}function W(x,d,g={}){x=F("message",x),o&&(x=o(x));let{prefix:A,scalar:R,pointBytes:K}=V(d),N=P(g.context,A,x),O=v.multiply(N).toRawBytes(),k=P(g.context,O,K,x),M=L(N+k*R);lt("signature.s",M,Bt,n);let Z=qt(O,pe(M,e.BYTES));return F("result",Z,e.BYTES*2)}let w=Bc;function I(x,d,g,A=w){let{context:R,zip215:K}=A,N=e.BYTES;x=F("signature",x,2*N),d=F("message",d),g=F("publicKey",g,N),K!==void 0&&At("zip215",K),o&&(d=o(d));let O=Xt(x.slice(N,2*N)),k,M,Z;try{k=p.fromHex(g,K),M=p.fromHex(x.slice(0,N),K),Z=v.multiplyUnsafe(O)}catch{return!1}if(!K&&k.isSmallOrder())return!1;let G=P(R,M.toRawBytes(),k.toRawBytes(),d);return M.add(k.multiplyUnsafe(G)).subtract(Z).clearCofactor().equals(p.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:H,sign:W,verify:I,ExtendedPoint:p,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,d=p.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var dn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),jo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),fu=BigInt(0),Ic=BigInt(1),Go=BigInt(2),uu=BigInt(3),Lc=BigInt(5),_c=BigInt(8);function Uc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=dn,c=r*r%s*r%s,a=z(c,Go,s)*c%s,h=z(a,Ic,s)*r%s,f=z(h,Lc,s)*h%s,u=z(f,t,s)*f%s,m=z(u,e,s)*u%s,S=z(m,n,s)*m%s,E=z(S,o,s)*S%s,y=z(E,o,s)*S%s,l=z(y,t,s)*f%s;return{pow_p_5_8:z(l,Go,s)*r%s,b2:c}}function Cc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Tc(r,t){let e=dn,n=q(t*t*t,e),o=q(n*n*t,e),s=Uc(r*o).pow_p_5_8,i=q(r*n*s,e),c=q(t*i*i,e),a=i,h=q(i*jo,e),f=c===r,u=c===q(-r,e),m=c===q(-r*jo,e);return f&&(i=a),(u||m)&&(i=h),No(i,e)&&(i=q(-i,e)),{isValid:f||u,value:i}}var Zo=Dt(dn,void 0,!0),Dc={a:Zo.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Zo,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:_c,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Io,randomBytes:tr,adjustScalarBytes:Cc,uvRatio:Tc},Yo=Fo(Dc);var ir=32;function Wo(r,t,e){return Yo.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var cr=class{type="Ed25519";raw;constructor(t){this.raw=pn(t,ir)}toMultihash(){return xt.digest(he(this))}toCID(){return nt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Wo(this.raw,e,t)}};function $o(r){return r=pn(r,ir),new cr(r)}function pn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Et(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Kc=Math.pow(2,7),Pc=Math.pow(2,14),Nc=Math.pow(2,21),Jo=Math.pow(2,28),Qo=Math.pow(2,35),ts=Math.pow(2,42),es=Math.pow(2,49),it=128,Vt=127;function Ke(r){if(r<Kc)return 1;if(r<Pc)return 2;if(r<Nc)return 3;if(r<Jo)return 4;if(r<Qo)return 5;if(r<ts)return 6;if(r<es)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function rs(r,t,e=0){switch(Ke(r)){case 8:t[e++]=r&255|it,r/=128;case 7:t[e++]=r&255|it,r/=128;case 6:t[e++]=r&255|it,r/=128;case 5:t[e++]=r&255|it,r/=128;case 4:t[e++]=r&255|it,r>>>=7;case 3:t[e++]=r&255|it,r>>>=7;case 2:t[e++]=r&255|it,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function ns(r,t){let e=r[t],n=0;if(n+=e&Vt,e<it||(e=r[t+1],n+=(e&Vt)<<7,e<it)||(e=r[t+2],n+=(e&Vt)<<14,e<it)||(e=r[t+3],n+=(e&Vt)<<21,e<it)||(e=r[t+4],n+=(e&Vt)*Jo,e<it)||(e=r[t+5],n+=(e&Vt)*Qo,e<it)||(e=r[t+6],n+=(e&Vt)*ts,e<it)||(e=r[t+7],n+=(e&Vt)*es,e<it))return n;throw new RangeError("Could not decode varint")}var mn=new Float32Array([-0]),zt=new Uint8Array(mn.buffer);function os(r,t,e){mn[0]=r,t[e]=zt[0],t[e+1]=zt[1],t[e+2]=zt[2],t[e+3]=zt[3]}function ss(r,t){return zt[0]=r[t],zt[1]=r[t+1],zt[2]=r[t+2],zt[3]=r[t+3],mn[0]}var yn=new Float64Array([-0]),rt=new Uint8Array(yn.buffer);function is(r,t,e){yn[0]=r,t[e]=rt[0],t[e+1]=rt[1],t[e+2]=rt[2],t[e+3]=rt[3],t[e+4]=rt[4],t[e+5]=rt[5],t[e+6]=rt[6],t[e+7]=rt[7]}function cs(r,t){return rt[0]=r[t],rt[1]=r[t+1],rt[2]=r[t+2],rt[3]=r[t+3],rt[4]=r[t+4],rt[5]=r[t+5],rt[6]=r[t+6],rt[7]=r[t+7],yn[0]}var Oc=BigInt(Number.MAX_SAFE_INTEGER),kc=BigInt(Number.MIN_SAFE_INTEGER),dt=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 te;if(t<Oc&&t>kc)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 te;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):te}},te=new dt(0,0);te.toBigInt=function(){return 0n};te.zzEncode=te.zzDecode=function(){return this};te.length=function(){return 1};var as=4294967296n;function fs(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 us(r,t,e){if(e-t<1)return"";let o,s=[],i=0,c;for(;t<e;)c=r[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function xn(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 wt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ar(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var bn=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,wt(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 wt(this,4);return ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw wt(this,4);return ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw wt(this,4);let t=ss(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw wt(this,4);let t=cs(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 wt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return us(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw wt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw wt(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 dt(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 wt(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 wt(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 wt(this,8);let t=ar(this.buf,this.pos+=4),e=ar(this.buf,this.pos+=4);return new dt(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=ns(this.buf,this.pos);return this.pos+=Ke(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 gn(r){return new bn(r instanceof Uint8Array?r:r.subarray())}function fr(r,t,e){let n=gn(r);return t.decode(n,void 0,e)}function wn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return ut(i);o+i>t&&(n=ut(t),o=0);let c=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),c}}var ee=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function En(){}var An=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Hc=wn();function Mc(r){return globalThis.Buffer!=null?ut(r):Hc(r)}var Ne=class{len;head;tail;states;constructor(){this.len=0,this.head=new ee(En,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ee(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Bn((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(ur,10,dt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=dt.fromBigInt(t);return this._push(ur,e.length(),e)}uint64Number(t){return this._push(rs,Ke(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=dt.fromBigInt(t).zzEncode();return this._push(ur,e.length(),e)}sint64Number(t){let e=dt.fromNumber(t).zzEncode();return this._push(ur,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Sn,1,t?1:0)}fixed32(t){return this._push(Pe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=dt.fromBigInt(t);return this._push(Pe,4,e.lo)._push(Pe,4,e.hi)}fixed64Number(t){let e=dt.fromNumber(t);return this._push(Pe,4,e.lo)._push(Pe,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(os,4,t)}double(t){return this._push(is,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Sn,1,0):this.uint32(e)._push(Vc,e,t)}string(t){let e=fs(t);return e!==0?this.uint32(e)._push(xn,e,t):this._push(Sn,1,0)}fork(){return this.states=new An(this),this.head=this.tail=new ee(En,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 ee(En,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=Mc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Sn(r,t,e){t[e]=r&255}function qc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Bn=class extends ee{next;constructor(t,e){super(qc,t,e),this.next=void 0}};function ur(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 Pe(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 Vc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ne.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(zc,t,r),this},Ne.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Fc,t,r),this});function zc(r,t,e){t.set(r,e)}function Fc(r,t,e){r.length<40?xn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Nt(r),e)}function vn(){return new Ne}function hr(r,t){let e=vn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var xe;(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"})(xe||(xe={}));function lr(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function In(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return lr("enum",xe.VARINT,e,n)}function dr(r,t){return lr("message",xe.LENGTH_DELIMITED,r,t)}var pt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(pt||(pt={}));var Ln;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Ln||(Ln={}));(function(r){r.codec=()=>In(Ln)})(pt||(pt={}));var Oe;(function(r){let t;r.codec=()=>(t==null&&(t=dr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),pt.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 c=e.uint32();switch(c>>>3){case 1:{s.Type=pt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>hr(e,r.codec()),r.decode=(e,n)=>fr(e,r.codec(),n)})(Oe||(Oe={}));var _n;(function(r){let t;r.codec=()=>(t==null&&(t=dr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),pt.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 c=e.uint32();switch(c>>>3){case 1:{s.Type=pt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return s})),t),r.encode=e=>hr(e,r.codec()),r.decode=(e,n)=>fr(e,r.codec(),n)})(_n||(_n={}));var ke=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var pr=class extends le{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,uo(t);let n=Le(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),Lt(s)}update(t){return de(this),this.iHash.update(t),this}digestInto(t){de(this),Gt(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:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Un=(r,t,e)=>new pr(r,t).update(e).digest();Un.create=(r,t)=>new pr(r,t);function ls(r){r.lowS!==void 0&&At("lowS",r.lowS),r.prehash!==void 0&&At("prehash",r.prehash)}function Gc(r){let t=Re(r);Tt(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 Cn=class extends Error{constructor(t=""){super(t)}},Rt={Err:Cn,_tlv:{encode:(r,t)=>{let{Err:e}=Rt;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=Te(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?Te(o.length/2|128):"";return Te(r)+s+o+t},decode(r,t){let{Err:e}=Rt,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 a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+a);if(h.length!==a)throw new e("tlv.decode: length bytes not complete");if(h[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of h)i=i<<8|f;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Rt;if(r<Kt)throw new t("integer: negative integers are not allowed");let e=Te(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}=Rt;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 Ct(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Rt,o=F("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:h,l:f}=n.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(h)}},hexFromSig(r){let{_tlv:t,_int:e}=Rt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}},Kt=BigInt(0),J=BigInt(1),ph=BigInt(2),ds=BigInt(3),mh=BigInt(4);function Zc(r){let t=Gc(r),{Fp:e}=t,n=Dt(t.n,t.nBitLength),o=t.toBytes||((y,l,b)=>{let B=l.toAffine();return qt(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),s=t.fromBytes||(y=>{let l=y.subarray(1),b=e.fromBytes(l.subarray(0,e.BYTES)),B=e.fromBytes(l.subarray(e.BYTES,2*e.BYTES));return{x:b,y:B}});function i(y){let{a:l,b}=t,B=e.sqr(y),p=e.mul(B,y);return e.add(e.add(p,e.mul(y,l)),b)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(y){return rr(y,J,t.n)}function a(y){let{allowedPrivateKeyLengths:l,nByteLength:b,wrapPrivateKey:B,n:p}=t;if(l&&typeof y!="bigint"){if(Wt(y)&&(y=Mt(y)),typeof y!="string"||!l.includes(y.length))throw new Error("invalid private key");y=y.padStart(b*2,"0")}let v;try{v=typeof y=="bigint"?y:Ct(F("private key",y,b))}catch{throw new Error("invalid private key, expected hex or "+b+" bytes, got "+typeof y)}return B&&(v=q(v,p)),lt("private key",v,J,p),v}function h(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}let f=me((y,l)=>{let{px:b,py:B,pz:p}=y;if(e.eql(p,e.ONE))return{x:b,y:B};let v=y.is0();l==null&&(l=v?e.ONE:e.inv(p));let D=e.mul(b,l),T=e.mul(B,l),L=e.mul(p,l);if(v)return{x:e.ZERO,y:e.ZERO};if(!e.eql(L,e.ONE))throw new Error("invZ was invalid");return{x:D,y:T}}),u=me(y=>{if(y.is0()){if(t.allowInfinityPoint&&!e.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:l,y:b}=y.toAffine();if(!e.isValid(l)||!e.isValid(b))throw new Error("bad point: x or y not FE");let B=e.sqr(b),p=i(l);if(!e.eql(B,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(l,b,B){if(l==null||!e.isValid(l))throw new Error("x required");if(b==null||!e.isValid(b)||e.is0(b))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");this.px=l,this.py=b,this.pz=B,Object.freeze(this)}static fromAffine(l){let{x:b,y:B}=l||{};if(!l||!e.isValid(b)||!e.isValid(B))throw new Error("invalid affine point");if(l instanceof m)throw new Error("projective point not allowed");let p=v=>e.eql(v,e.ZERO);return p(b)&&p(B)?m.ZERO:new m(b,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){let b=ye(e,l.map(B=>B.pz));return l.map((B,p)=>B.toAffine(b[p])).map(m.fromAffine)}static fromHex(l){let b=m.fromAffine(s(F("pointHex",l)));return b.assertValidity(),b}static fromPrivateKey(l){return m.BASE.multiply(a(l))}static msm(l,b){return sr(m,n,l,b)}_setWindowSize(l){E.setWindowSize(this,l)}assertValidity(){u(this)}hasEvenY(){let{y:l}=this.toAffine();if(e.isOdd)return!e.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){h(l);let{px:b,py:B,pz:p}=this,{px:v,py:D,pz:T}=l,L=e.eql(e.mul(b,T),e.mul(v,p)),_=e.eql(e.mul(B,T),e.mul(D,p));return L&&_}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:l,b}=t,B=e.mul(b,ds),{px:p,py:v,pz:D}=this,T=e.ZERO,L=e.ZERO,_=e.ZERO,U=e.mul(p,p),V=e.mul(v,v),H=e.mul(D,D),P=e.mul(p,v);return P=e.add(P,P),_=e.mul(p,D),_=e.add(_,_),T=e.mul(l,_),L=e.mul(B,H),L=e.add(T,L),T=e.sub(V,L),L=e.add(V,L),L=e.mul(T,L),T=e.mul(P,T),_=e.mul(B,_),H=e.mul(l,H),P=e.sub(U,H),P=e.mul(l,P),P=e.add(P,_),_=e.add(U,U),U=e.add(_,U),U=e.add(U,H),U=e.mul(U,P),L=e.add(L,U),H=e.mul(v,D),H=e.add(H,H),U=e.mul(H,P),T=e.sub(T,U),_=e.mul(H,V),_=e.add(_,_),_=e.add(_,_),new m(T,L,_)}add(l){h(l);let{px:b,py:B,pz:p}=this,{px:v,py:D,pz:T}=l,L=e.ZERO,_=e.ZERO,U=e.ZERO,V=t.a,H=e.mul(t.b,ds),P=e.mul(b,v),W=e.mul(B,D),w=e.mul(p,T),I=e.add(b,B),C=e.add(v,D);I=e.mul(I,C),C=e.add(P,W),I=e.sub(I,C),C=e.add(b,p);let x=e.add(v,T);return C=e.mul(C,x),x=e.add(P,w),C=e.sub(C,x),x=e.add(B,p),L=e.add(D,T),x=e.mul(x,L),L=e.add(W,w),x=e.sub(x,L),U=e.mul(V,C),L=e.mul(H,w),U=e.add(L,U),L=e.sub(W,U),U=e.add(W,U),_=e.mul(L,U),W=e.add(P,P),W=e.add(W,P),w=e.mul(V,w),C=e.mul(H,C),W=e.add(W,w),w=e.sub(P,w),w=e.mul(V,w),C=e.add(C,w),P=e.mul(W,C),_=e.add(_,P),P=e.mul(x,C),L=e.mul(I,L),L=e.sub(L,P),P=e.mul(I,W),U=e.mul(x,U),U=e.add(U,P),new m(L,_,U)}subtract(l){return this.add(l.negate())}is0(){return this.equals(m.ZERO)}wNAF(l){return E.wNAFCached(this,l,m.normalizeZ)}multiplyUnsafe(l){let{endo:b,n:B}=t;lt("scalar",l,Kt,B);let p=m.ZERO;if(l===Kt)return p;if(this.is0()||l===J)return this;if(!b||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,l,m.normalizeZ);let{k1neg:v,k1:D,k2neg:T,k2:L}=b.splitScalar(l),_=p,U=p,V=this;for(;D>Kt||L>Kt;)D&J&&(_=_.add(V)),L&J&&(U=U.add(V)),V=V.double(),D>>=J,L>>=J;return v&&(_=_.negate()),T&&(U=U.negate()),U=new m(e.mul(U.px,b.beta),U.py,U.pz),_.add(U)}multiply(l){let{endo:b,n:B}=t;lt("scalar",l,J,B);let p,v;if(b){let{k1neg:D,k1:T,k2neg:L,k2:_}=b.splitScalar(l),{p:U,f:V}=this.wNAF(T),{p:H,f:P}=this.wNAF(_);U=E.constTimeNegate(D,U),H=E.constTimeNegate(L,H),H=new m(e.mul(H.px,b.beta),H.py,H.pz),p=U.add(H),v=V.add(P)}else{let{p:D,f:T}=this.wNAF(l);p=D,v=T}return m.normalizeZ([p,v])[0]}multiplyAndAddUnsafe(l,b,B){let p=m.BASE,v=(T,L)=>L===Kt||L===J||!T.equals(p)?T.multiplyUnsafe(L):T.multiply(L),D=v(this,b).add(v(l,B));return D.is0()?void 0:D}toAffine(l){return f(this,l)}isTorsionFree(){let{h:l,isTorsionFree:b}=t;if(l===J)return!0;if(b)return b(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:l,clearCofactor:b}=t;return l===J?this:b?b(m,this):this.multiplyUnsafe(t.h)}toRawBytes(l=!0){return At("isCompressed",l),this.assertValidity(),o(m,this,l)}toHex(l=!0){return At("isCompressed",l),Mt(this.toRawBytes(l))}}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=or(m,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Yc(r){let t=Re(r);return Tt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ps(r){let t=Yc(r),{Fp:e,n}=t,o=e.BYTES+1,s=2*e.BYTES+1;function i(w){return q(w,n)}function c(w){return nr(w,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:u}=Zc({...t,toBytes(w,I,C){let x=I.toAffine(),d=e.toBytes(x.x),g=qt;return At("isCompressed",C),C?g(Uint8Array.from([I.hasEvenY()?2:3]),d):g(Uint8Array.from([4]),d,e.toBytes(x.y))},fromBytes(w){let I=w.length,C=w[0],x=w.subarray(1);if(I===o&&(C===2||C===3)){let d=Ct(x);if(!rr(d,J,e.ORDER))throw new Error("Point is not on curve");let g=f(d),A;try{A=e.sqrt(g)}catch(N){let O=N instanceof Error?": "+N.message:"";throw new Error("Point is not on curve"+O)}let R=(A&J)===J;return(C&1)===1!==R&&(A=e.neg(A)),{x:d,y:A}}else if(I===s&&C===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=>Mt($t(w,t.nByteLength));function S(w){let I=n>>J;return w>I}function E(w){return S(w)?i(-w):w}let y=(w,I,C)=>Ct(w.slice(I,C));class l{constructor(I,C,x){lt("r",I,J,n),lt("s",C,J,n),this.r=I,this.s=C,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(I){let C=t.nByteLength;return I=F("compactSignature",I,C*2),new l(y(I,0,C),y(I,C,2*C))}static fromDER(I){let{r:C,s:x}=Rt.toSig(F("DER",I));return new l(C,x)}assertValidity(){}addRecoveryBit(I){return new l(this.r,this.s,I)}recoverPublicKey(I){let{r:C,s:x,recovery:d}=this,g=T(F("msgHash",I));if(d==null||![0,1,2,3].includes(d))throw new Error("recovery id invalid");let A=d===2||d===3?C+t.n:C;if(A>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(d&1)===0?"02":"03",K=a.fromHex(R+m(A)),N=c(A),O=i(-g*N),k=i(x*N),M=a.BASE.multiplyAndAddUnsafe(K,O,k);if(!M)throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return S(this.s)}normalizeS(){return this.hasHighS()?new l(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return De(this.toDERHex())}toDERHex(){return Rt.hexFromSig(this)}toCompactRawBytes(){return De(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let b={isValidPrivateKey(w){try{return h(w),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let w=cn(t.n);return ko(t.randomBytes(w),t.n)},precompute(w=8,I=a.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function B(w,I=!0){return a.fromPrivateKey(w).toRawBytes(I)}function p(w){let I=Wt(w),C=typeof w=="string",x=(I||C)&&w.length;return I?x===o||x===s:C?x===2*o||x===2*s:w instanceof a}function v(w,I,C=!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 a.fromHex(I).multiply(h(w)).toRawBytes(C)}let D=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let I=Ct(w),C=w.length*8-t.nBitLength;return C>0?I>>BigInt(C):I},T=t.bits2int_modN||function(w){return i(D(w))},L=Jt(t.nBitLength);function _(w){return lt("num < 2^"+t.nBitLength,w,Kt,L),$t(w,t.nByteLength)}function U(w,I,C=V){if(["recovered","canonical"].some(G=>G in C))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:d}=t,{lowS:g,prehash:A,extraEntropy:R}=C;g==null&&(g=!0),w=F("msgHash",w),ls(C),A&&(w=F("prehashed msgHash",x(w)));let K=T(w),N=h(I),O=[_(N),_(K)];if(R!=null&&R!==!1){let G=R===!0?d(e.BYTES):R;O.push(F("extraEntropy",G))}let k=qt(...O),M=K;function Z(G){let Q=D(G);if(!u(Q))return;let ct=c(Q),$=a.BASE.multiply(Q).toAffine(),et=i($.x);if(et===Kt)return;let at=i(ct*i(M+et*N));if(at===Kt)return;let yt=($.x===et?0:2)|Number($.y&J),be=at;return g&&S(at)&&(be=E(at),yt^=1),new l(et,be,yt)}return{seed:k,k2sig:Z}}let V={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function P(w,I,C=V){let{seed:x,k2sig:d}=U(w,I,C),g=t;return Do(g.hash.outputLen,g.nByteLength,g.hmac)(x,d)}a.BASE._setWindowSize(8);function W(w,I,C,x=H){let d=w;I=F("msgHash",I),C=F("publicKey",C);let{lowS:g,prehash:A,format:R}=x;if(ls(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let K=typeof d=="string"||Wt(d),N=!K&&!R&&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 O,k;try{if(N&&(O=new l(d.r,d.s)),K){try{R!=="compact"&&(O=l.fromDER(d))}catch(yt){if(!(yt instanceof Rt.Err))throw yt}!O&&R!=="der"&&(O=l.fromCompact(d))}k=a.fromHex(C)}catch{return!1}if(!O||g&&O.hasHighS())return!1;A&&(I=t.hash(I));let{r:M,s:Z}=O,G=T(I),Q=c(Z),ct=i(G*Q),$=i(M*Q),et=a.BASE.multiplyAndAddUnsafe(k,ct,$)?.toAffine();return et?i(et.x)===M:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:v,sign:P,verify:W,ProjectivePoint:a,Signature:l,utils:b}}function Wc(r){return{hash:r,hmac:(t,...e)=>Un(r,t,Gr(...e)),randomBytes:tr}}function ms(r,t){let e=n=>ps({...r,...Wc(n)});return{...e(t),create:e}}var bs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ys=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xc=BigInt(1),Tn=BigInt(2),xs=(r,t)=>(r+t/Tn)/t;function $c(r){let t=bs,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),h=r*r*r%t,f=h*h*r%t,u=z(f,e,t)*f%t,m=z(u,e,t)*f%t,S=z(m,Tn,t)*h%t,E=z(S,o,t)*S%t,y=z(E,s,t)*E%t,l=z(y,c,t)*y%t,b=z(l,a,t)*l%t,B=z(b,c,t)*y%t,p=z(B,e,t)*f%t,v=z(p,i,t)*E%t,D=z(v,n,t)*h%t,T=z(D,Tn,t);if(!Dn.eql(Dn.sqr(T),r))throw new Error("Cannot find square root");return T}var Dn=Dt(bs,void 0,void 0,{sqrt:$c}),re=ms({a:BigInt(0),b:BigInt(7),Fp:Dn,n:ys,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ys,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Xc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),c=xs(s*r,t),a=xs(-n*r,t),h=q(r-c*e-a*o,t),f=q(-c*n-a*s,t),u=h>i,m=f>i;if(u&&(h=t-h),m&&(f=t-f),h>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:h,k2neg:m,k2:f}}}},vo),Bh=BigInt(0);var vh=re.ProjectivePoint;function gs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ws(r,t,e){let n=Be.digest(e instanceof Uint8Array?e:e.subarray());if(gs(n))return n.then(({digest:o})=>re.verify(t,o,r)).catch(o=>{throw new ke(String(o))});try{return re.verify(t,n.digest,r)}catch(o){throw new ke(String(o))}}var mr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ss(t),this.raw=Es(this._key)}toMultihash(){return xt.digest(he(this))}toCID(){return nt.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return ws(this._key,e,t)}};function As(r){return new mr(r)}function Es(r){return re.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ss(r){try{return re.ProjectivePoint.fromHex(r),r}catch(t){throw new Fe(String(t))}}function Bs(r){let{Type:t,Data:e}=Oe.decode(r.digest),n=e??new Uint8Array;switch(t){case pt.Ed25519:return $o(n);case pt.secp256k1:return As(n);case pt.ECDSA:return co(n);default:throw new ne}}function he(r){return Oe.encode({Type:pt[r.type],Data:r.raw})}var vs=Symbol.for("nodejs.util.inspect.custom"),Jc=114,He=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()})`}[xr]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return nt.createV1(Jc,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[vs](){return`PeerId(${this.toString()})`}},Me=class extends He{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},qe=class extends He{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ve=class extends He{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Qc=2336,ze=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=xt.digest(Nt(this.url))}[vs](){return`PeerId(${this.url})`}[xr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return nt.createV1(Qc,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=mt(t)),t.toString()===this.toString())}};var ta=114,Is=2336;function ea(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=Se(Y.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return _s(nt.parse(r));if(t==null)throw new Et('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=Se(t.decode(r))}return Rn(e)}function Ls(r){if(r.type==="Ed25519")return new qe({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Ve({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Me({multihash:r.toCID().multihash,publicKey:r});throw new ne}function ra(r){return Ls(r.publicKey)}function Rn(r){if(oa(r))return new Me({multihash:r});if(na(r))try{let t=Bs(r);if(t.type==="Ed25519")return new qe({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ve({multihash:r,publicKey:t})}catch{let e=mt(r.digest);return new ze(new URL(e))}throw new Ge("Supplied PeerID Multihash is invalid")}function _s(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==ta&&r.code!==Is)throw new je("Supplied PeerID CID is invalid");if(r.code===Is){let t=mt(r.multihash.digest);return new ze(new URL(t))}return Rn(r.multihash)}function na(r){return r.code===xt.code}function oa(r){return r.code===Be.code}return Os(sa);})();
|
|
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 Libp2PPeerId}));
|
|
19
|
+
//# sourceMappingURL=index.min.js.map
|