@helia/ipns 8.2.0-bb2ab74 → 8.2.0-cd1eb58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
2
|
"use strict";var HeliaIpns=(()=>{var Nu=Object.create;var Xr=Object.defineProperty;var Lu=Object.getOwnPropertyDescriptor;var Pu=Object.getOwnPropertyNames;var ku=Object.getPrototypeOf,Ku=Object.prototype.hasOwnProperty;var Qi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),St=(e,t)=>{for(var r in t)Xr(e,r,{get:t[r],enumerable:!0})},ts=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pu(t))!Ku.call(e,o)&&o!==r&&Xr(e,o,{get:()=>t[o],enumerable:!(n=Lu(t,o))||n.enumerable});return e};var Jr=(e,t,r)=>(r=e!=null?Nu(ku(e)):{},ts(t||!e||!e.__esModule?Xr(r,"default",{value:e,enumerable:!0}):r,e)),Ou=e=>ts(Xr({},"__esModule",{value:!0}),e);var Nn=Qi((Fg,ki)=>{var Mg=function(){typeof ki<"u"&&(ki.exports=y);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(x){var w=x-x%1;return w==0&&(x<0||x===0&&1/x!=1/0)?-0:w},u=y.prototype,l=(y.fromDate=function(x){return new y(+x)},y.fromInt64BE=D(0,1,2,3,0,4),y.fromInt64LE=D(3,2,1,0,4,0),y.fromString=function(L){var w,K=new y,L=(L+="").replace(/^\s*[+\-]?\d+/,function(V){var V=+V,S=1970+(V-1970)%400;return K.year=V-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(_,V,S){return V<0&&(S*=-1),w=6e4*(60*+V+ +S),""}).replace(/\.\d+$/,function(_){return K.nano=+(_+c).substr(1,9),""}).split(/\D+/);if(1<L.length?L[1]--:L[1]=0,K.time=w=Date.UTC.apply(Date,L)-(w||0),isNaN(w))throw new TypeError("Invalid Date");return h(K)},y.fromTimeT=function(x){return U(x,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(x){return this.nano+=+x||0,this},u.getNano=function(){var x=h(this);return(x.time%1e3*a+ +x.nano+1e9)%1e9},u.getTimeT=function(){var w=h(this),x=Math.floor(w.time/1e3),w=w.year;return w&&(x+=w*r*e/t),x},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return E(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(x){var w=this,K=w.toDate(),L={H:function(){return k(K.getUTCHours())},L:function(){return R(K.getUTCMilliseconds(),3)},M:function(){return k(K.getUTCMinutes())},N:function(){return R(w.getNano(),9)},S:function(){return k(K.getUTCSeconds())},Y:function(){var _=w.getYear();return 999999<_?"+"+_:9999<_?"+"+R(_,6):0<=_?R(_,4):-999999<=_?"-"+R(-_,6):_},a:function(){return T[K.getUTCDay()]},b:function(){return d[K.getUTCMonth()]},d:function(){return k(K.getUTCDate())},e:function(){return function(_){return(9<_?"":" ")+(0|_)}(K.getUTCDate())},m:function(){return k(K.getUTCMonth()+1)}};return function _(V){return V.replace(/%./g,function(S){var B=S[1],A=v[B],B=L[B];return A?_(A):B?B():S})}(x||l)},u.writeInt64BE=g(0,1,2,3,0,4),u.writeInt64LE=g(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],T=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],v={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(x,w,K){var L=this;if(!(L instanceof y))return new y(x,w,K);L.time=+x||0,L.nano=+w||0,L.year=+K||0,h(L)}function h(x){var w,K,L,_=x.year,V=x.time,S=x.nano,A=((S<0||a<=S)&&(S-=(K=Math.floor(S/a))*a,V+=K,K=1),_%t);return(V<-i||i<V||A)&&((w=f(V/o))&&(_+=w*t,V-=w*o),(L=E(V)).setUTCFullYear(A+L.getUTCFullYear()),L=(V=+L)+(w=f((_-=A)/t))*o,w&&-i<=L&&L<=i&&(_-=w*t,V=L),K=1),K&&(x.year=_,x.time=V,x.nano=S),x}function E(x){var w=new Date(0);return w.setTime(x),w}function U(_,L){_=+_||0;var K=f((L=(L|0)*s)/n)+f(_/n),L=L%n+_%n,_=f(L/n);return _&&(K+=_,L-=_*n),new y(1e3*L,0,K*t)}function g(x,w,K,L,_,V){return function(A,B){var m=h(this);A=A||new Array(8),O(A,B|=0);var C=Math.floor(m.time/1e3),m=m.year*(r*e/t),b=f(m/s)+f(C/s),m=m%s+C%s,C=Math.floor(m/s);return C&&(b+=C,m-=C*s),S(A,B+_,b),S(A,B+V,m),A};function S(A,B,b){A[B+x]=b>>24&255,A[B+w]=b>>16&255,A[B+K]=b>>8&255,A[B+L]=255&b}}function D(x,w,K,L,_,V){return function(A,B){O(A,B|=0);var b=S(A,B+_);return U(S(A,B+V),b)};function S(A,B){return 16777216*A[B+x]+(A[B+w]<<16|A[B+K]<<8|A[B+L])}}function O(x,w){if(x=x&&x.length,x==null)throw new TypeError("Invalid Buffer");if(x<w+8)throw new RangeError("Out of range")}function k(x){return(9<x?"":"0")+(0|x)}function R(x,w){return(c+(0|x)).substr(-w)}}()});var gu=Qi((kw,yu)=>{yu.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,t++,t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Th={};St(Th,{ipns:()=>Ch,ipnsSelector:()=>Qn,ipnsValidator:()=>Yr});function es(e){return e==null?!1:(e.type==="RSA"||e.type==="Ed25519"||e.type==="secp256k1"||e.type==="ECDSA")&&e.raw instanceof Uint8Array&&typeof e.equals=="function"&&typeof e.toMultihash=="function"&&typeof e.toCID=="function"&&typeof e.verify=="function"}var co=Symbol.for("@libp2p/peer-id");var st=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ye=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var gr=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Qr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},We=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Xe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var po={};St(po,{base32:()=>pe,base32hex:()=>Zu,base32hexpad:()=>Yu,base32hexpadupper:()=>Wu,base32hexupper:()=>ju,base32pad:()=>$u,base32padupper:()=>Gu,base32upper:()=>zu,base32z:()=>Xu});var Dh=new Uint8Array(0);function rs(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Jt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ns(e){return new TextEncoder().encode(e)}function os(e){return new TextDecoder().decode(e)}function Mu(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(v){if(v instanceof Uint8Array||(ArrayBuffer.isView(v)?v=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):Array.isArray(v)&&(v=Uint8Array.from(v))),!(v instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(v.length===0)return"";for(var y=0,h=0,E=0,U=v.length;E!==U&&v[E]===0;)E++,y++;for(var g=(U-E)*u+1>>>0,D=new Uint8Array(g);E!==U;){for(var O=v[E],k=0,R=g-1;(O!==0||k<h)&&R!==-1;R--,k++)O+=256*D[R]>>>0,D[R]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");h=k,E++}for(var x=g-h;x!==g&&D[x]===0;)x++;for(var w=c.repeat(y);x<g;++x)w+=e.charAt(D[x]);return w}function d(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return new Uint8Array;var y=0;if(v[y]!==" "){for(var h=0,E=0;v[y]===c;)h++,y++;for(var U=(v.length-y)*f+1>>>0,g=new Uint8Array(U);v[y];){var D=r[v.charCodeAt(y)];if(D===255)return;for(var O=0,k=U-1;(D!==0||O<E)&&k!==-1;k--,O++)D+=a*g[k]>>>0,g[k]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");E=O,y++}if(v[y]!==" "){for(var R=U-E;R!==U&&g[R]===0;)R++;for(var x=new Uint8Array(h+(U-R)),w=h;R!==U;)x[w++]=g[R++];return x}}}function T(v){var y=d(v);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:T}}var Fu=Mu,Vu=Fu,ss=Vu;var uo=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},fo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return as(this,t)}},lo=class{decoders;constructor(t){this.decoders=t}or(t){return as(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function as(e,t){return new lo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ho=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new uo(t,r,n),this.decoder=new fo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Je({name:e,prefix:t,encode:r,decode:n}){return new ho(e,t,r,n)}function he({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ss(r,e);return Je({prefix:t,name:e,encode:n,decode:i=>Jt(o(i))})}function Hu(e,t,r,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;e[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[e[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function qu(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function et({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Je({prefix:t,name:e,encode(o){return qu(o,n,r)},decode(o){return Hu(o,n,r,e)}})}var pe=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zu=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$u=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gu=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Zu=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ju=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yu=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wu=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xu=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mo={};St(mo,{base58btc:()=>W,base58flickr:()=>Ju});var W=he({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ju=he({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var go={};St(go,{base64:()=>yo,base64pad:()=>Qu,base64url:()=>tf,base64urlpad:()=>ef});var yo=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qu=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tf=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ef=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function rf(e,t){try{if(typeof e=="string"&&e.length>0)return nf(e);if(typeof e=="number"&&isFinite(e))return t?.long?sf(e):of(e);throw new Error("Value is not a string or number.")}catch(r){let n=af(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function nf(e){if(e=String(e),e.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var en=rf;function of(e){let t=Math.abs(e);return t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function sf(e){let t=Math.abs(e);return t>=864e5?tn(e,t,864e5,"day"):t>=36e5?tn(e,t,36e5,"hour"):t>=6e4?tn(e,t,6e4,"minute"):t>=1e3?tn(e,t,1e3,"second"):`${e} ms`}function tn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function af(e){return typeof e=="object"&&e!==null&&"message"in e}function xo(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=en,r.destroy=f,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let l=0;for(let d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u){let l,d=null,T,v;function y(...h){if(!y.enabled)return;let E=y,U=Number(new Date),g=U-(l||U);E.diff=g,E.prev=l,E.curr=U,l=U,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let D=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(k,R)=>{if(k==="%%")return"%";D++;let x=r.formatters[R];if(typeof x=="function"){let w=h[D];k=x.call(E,w),h.splice(D,1),D--}return k}),r.formatArgs.call(E,h),(E.log||r.log).apply(E,h)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(T!==r.namespaces&&(T=r.namespaces,v=r.enabled(u)),v),set:h=>{d=h}}),typeof r.init=="function"&&r.init(y),y}function n(u,l){let d=r(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),T=d.length;for(l=0;l<T;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(u))return!1;for(l=0,d=r.names.length;l<d;l++)if(r.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var rn=pf(),cf=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function uf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function ff(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+en(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var lf=console.debug??console.log??(()=>{});function df(e){try{e?rn?.setItem("debug",e):rn?.removeItem("debug")}catch{}}function hf(){let e;try{e=rn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function pf(){try{return localStorage}catch{}}function mf(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var cs=xo({formatArgs:ff,save:df,load:hf,useColors:uf,setupFormatters:mf,colors:cf,storage:rn,log:lf});var At=cs;At.formatters.b=e=>e==null?"undefined":W.baseEncode(e);At.formatters.t=e=>e==null?"undefined":pe.baseEncode(e);At.formatters.m=e=>e==null?"undefined":yo.baseEncode(e);At.formatters.p=e=>e==null?"undefined":e.toString();At.formatters.c=e=>e==null?"undefined":e.toString();At.formatters.k=e=>e==null?"undefined":e.toString();At.formatters.a=e=>e==null?"undefined":e.toString();At.formatters.e=e=>e==null?"undefined":us(e.stack)??us(e.message)??e.toString();function yf(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function me(e){let t=yf(`${e}:trace`);return At.enabled(`${e}:trace`)&&At.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=At(`${e}:trace`)),Object.assign(At(e),{error:At(`${e}:error`),trace:t})}function us(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var wo={};St(wo,{base36:()=>Ot,base36upper:()=>gf});var Ot=he({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gf=he({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xf=ds,fs=128,wf=127,bf=~wf,Ef=Math.pow(2,31);function ds(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Ef;)t[r++]=e&255|fs,e/=128;for(;e&bf;)t[r++]=e&255|fs,e>>>=7;return t[r]=e|0,ds.bytes=r-n+1,t}var Sf=bo,Af=128,ls=127;function bo(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw bo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&ls)<<o:(s&ls)*Math.pow(2,o),o+=7}while(s>=Af);return bo.bytes=i-n,r}var vf=Math.pow(2,7),Cf=Math.pow(2,14),Tf=Math.pow(2,21),Bf=Math.pow(2,28),If=Math.pow(2,35),_f=Math.pow(2,42),Uf=Math.pow(2,49),Df=Math.pow(2,56),Rf=Math.pow(2,63),Nf=function(e){return e<vf?1:e<Cf?2:e<Tf?3:e<Bf?4:e<If?5:e<_f?6:e<Uf?7:e<Df?8:e<Rf?9:10},Lf={encode:xf,decode:Sf,encodingLength:Nf},Pf=Lf,xr=Pf;function wr(e,t=0){return[xr.decode(e,t),xr.decode.bytes]}function Qe(e,t,r=0){return xr.encode(e,t,r),t}function tr(e){return xr.encodingLength(e)}function Mt(e,t){let r=t.byteLength,n=tr(e),o=n+tr(r),i=new Uint8Array(o+r);return Qe(e,i,0),Qe(r,i,n),i.set(t,o),new er(e,r,t,i)}function Qt(e){let t=Jt(e),[r,n]=wr(t),[o,i]=wr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new er(r,o,s,t)}function hs(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&rs(e.bytes,r.bytes)}}var er=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function ps(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Kf(r,Eo(e),t??W.encoder);default:return Of(r,Eo(e),t??pe.encoder)}}var ms=new WeakMap;function Eo(e){let t=ms.get(e);if(t==null){let r=new Map;return ms.set(e,r),r}return t}var X=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Mt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&hs(t.multihash,n.multihash)}toString(t){return ps(this,t)}toJSON(){return{"/":ps(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??ys(n,o,i.bytes))}else if(r[Ff]===!0){let{version:n,multihash:o,code:i}=r,s=Qt(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==br)throw new Error(`Version 0 CID must use dag-pb (code: ${br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ys(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Jt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new er(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,d]=wr(t.subarray(r));return r+=d,l},o=n(),i=br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=kf(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Eo(i).set(n,t),i}};function kf(e,t){switch(e[0]){case"Q":{let r=t??W;return[W.prefix,r.decode(`${W.prefix}${e}`)]}case W.prefix:{let r=t??W;return[W.prefix,r.decode(e)]}case pe.prefix:{let r=t??pe;return[pe.prefix,r.decode(e)]}case Ot.prefix:{let r=t??Ot;return[Ot.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Kf(e,t,r){let{prefix:n}=r;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Of(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var br=112,Mf=18;function ys(e,t,r){let n=tr(e),o=n+tr(t),i=new Uint8Array(o+r.byteLength);return Qe(e,i,0),Qe(t,i,n),i.set(r,o),i}var Ff=Symbol.for("@ipld/js-cid/CID");var So={};St(So,{identity:()=>Ft});var gs=0,Vf="identity",xs=Jt;function Hf(e){return Mt(gs,xs(e))}var Ft={code:gs,name:Vf,encode:xs,digest:Hf};function nt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Lt(e=0){return new Uint8Array(e)}function Tt(e=0){return new Uint8Array(e)}function ge(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Tt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var bs=Symbol.for("@achingbrain/uint8arraylist");function ws(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function on(e){return!!e?.[bs]}var Bt=class e{bufs;length;[bs]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(on(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(on(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ws(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ws(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(on(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return ge(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:ge(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(f){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!on(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let d=f;d>=0;d--){let T=this.get(l+d);if(n[d]!==T){u=Math.max(1,d-a[T]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=Tt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Tt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!nt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Ao={};St(Ao,{base10:()=>qf});var qf=he({prefix:"9",name:"base10",alphabet:"0123456789"});var vo={};St(vo,{base16:()=>zf,base16upper:()=>$f});var zf=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$f=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Co={};St(Co,{base2:()=>Gf});var Gf=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var To={};St(To,{base256emoji:()=>Xf});var Es=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}"),Zf=Es.reduce((e,t,r)=>(e[r]=t,e),[]),jf=Es.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Yf(e){return e.reduce((t,r)=>(t+=Zf[r],t),"")}function Wf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=jf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Xf=Je({prefix:"\u{1F680}",name:"base256emoji",encode:Yf,decode:Wf});var Bo={};St(Bo,{base8:()=>Jf});var Jf=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Io={};St(Io,{identity:()=>Qf});var Qf=Je({prefix:"\0",name:"identity",encode:e=>os(e),decode:e=>ns(e)});var B0=new TextEncoder,I0=new TextDecoder;var Do={};St(Do,{sha256:()=>Er,sha512:()=>rl});function Uo({name:e,code:t,encode:r}){return new _o(e,t,r)}var _o=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Mt(this.code,r):r.then(n=>Mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function As(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Er=Uo({name:"sha2-256",code:18,encode:As("SHA-256")}),rl=Uo({name:"sha2-512",code:19,encode:As("SHA-512")});var Ro={...Io,...Co,...Bo,...Ao,...vo,...po,...wo,...mo,...go,...To},F0={...Do,...So};function Cs(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var vs=Cs("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),No=Cs("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Tt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),nl={utf8:vs,"utf-8":vs,hex:Ro.base16,latin1:No,ascii:No,binary:No,...Ro},sn=nl;function $(e,t="utf8"){let r=sn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function j(e,t="utf8"){let r=sn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var ol=parseInt("11111",2),Lo=parseInt("10000000",2),il=parseInt("01111111",2),Ts={0:Sr,1:Sr,2:sl,3:ul,4:fl,5:cl,6:al,16:Sr,22:Sr,48:Sr};function te(e,t={offset:0}){let r=e[t.offset]&ol;if(t.offset++,Ts[r]!=null)return Ts[r](e,t);throw new Error("No decoder for tag "+r)}function Ar(e,t){let r=0;if((e[t.offset]&Lo)===Lo){let n=e[t.offset]&il,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Sr(e,t){Ar(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=te(e,t);if(n===null)break;r.push(n)}return r}function sl(e,t){let r=Ar(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function al(e,t){let r=Ar(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let l=0;l<c.length;l++)u+=c[l]<<l*7;a+=`.${u}`,c=[]}}return a}function cl(e,t){return t.offset++,null}function ul(e,t){let r=Ar(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function fl(e,t){let r=Ar(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function ll(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Bt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Po(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=ll(e.byteLength);return new Bt(Uint8Array.from([t.byteLength|Lo]),t)}function vt(e){let t=new Bt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Bt(Uint8Array.from([2]),Po(t),t)}function an(e){let t=Uint8Array.from([0]),r=new Bt(t,e);return new Bt(Uint8Array.from([3]),Po(r),r)}function xe(e,t=48){let r=new Bt;for(let n of e)r.append(n);return new Bt(Uint8Array.from([t]),Po(r),r)}async function Bs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,r.subarray())}var dl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),hl=Uint8Array.from([6,5,43,129,4,0,34]),pl=Uint8Array.from([6,5,43,129,4,0,35]),ml={ext:!0,kty:"EC",crv:"P-256"},yl={ext:!0,kty:"EC",crv:"P-384"},gl={ext:!0,kty:"EC",crv:"P-521"},ko=32,Ko=48,Oo=66;function Mo(e){let t=te(e);return Is(t)}function Is(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===ko*2+1)return n=j(t.subarray(r,r+ko),"base64url"),o=j(t.subarray(r+ko),"base64url"),new rr({...ml,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ko*2+1)return n=j(t.subarray(r,r+Ko),"base64url"),o=j(t.subarray(r+Ko),"base64url"),new rr({...yl,key_ops:["verify"],x:n,y:o});if(t.byteLength===Oo*2+1)return n=j(t.subarray(r,r+Oo),"base64url"),o=j(t.subarray(r+Oo),"base64url"),new rr({...gl,key_ops:["verify"],x:n,y:o});throw new st(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function _s(e){return xe([vt(Uint8Array.from([1])),xe([xl(e.crv)],160),xe([an(new Bt(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function xl(e){if(e==="P-256")return dl;if(e==="P-384")return hl;if(e==="P-521")return pl;throw new st(`Invalid curve ${e}`)}var rr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=_s(this.jwk)),this._raw}toMultihash(){return Ft.digest(we(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}async verify(t,r){return Bs(this.jwk,r,t)}};var Ne=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function cn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Le(e,...t){if(!wl(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Us(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");cn(e.outputLen),cn(e.blockLen)}function or(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ds(e,t){Le(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function un(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vt(e,t){return e<<32-t|e>>>t}function Rs(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function vr(e){return typeof e=="string"&&(e=Rs(e)),Le(e),e}function Fo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Le(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var nr=class{};function Vo(e){let t=n=>e().update(vr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function fn(e=32){if(Ne&&typeof Ne.getRandomValues=="function")return Ne.getRandomValues(new Uint8Array(e));if(Ne&&typeof Ne.randomBytes=="function")return Uint8Array.from(Ne.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function bl(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+f,a,n)}function Ns(e,t,r){return e&t^~e&r}function Ls(e,t,r){return e&t^e&r^t&r}var Cr=class extends nr{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=un(this.buffer)}update(t){or(this),t=vr(t),Le(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=un(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){or(this),Ds(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ee(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;bl(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=un(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},re=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var dt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ln=BigInt(4294967295),Ps=BigInt(32);function El(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>Ps&ln)}:{h:Number(e>>Ps&ln)|0,l:Number(e&ln)|0}}function ks(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=El(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var Ho=(e,t,r)=>e>>>r,qo=(e,t,r)=>e<<32-r|t>>>r,Pe=(e,t,r)=>e>>>r|t<<32-r,ke=(e,t,r)=>e<<32-r|t>>>r,Tr=(e,t,r)=>e<<64-r|t>>>r-32,Br=(e,t,r)=>e>>>r-32|t<<64-r;function Gt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ks=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Os=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ms=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Fs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Vs=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Hs=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Al=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]),be=new Uint32Array(64),dn=class extends Cr{constructor(t=32){super(64,t,8,!1),this.A=re[0]|0,this.B=re[1]|0,this.C=re[2]|0,this.D=re[3]|0,this.E=re[4]|0,this.F=re[5]|0,this.G=re[6]|0,this.H=re[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let l=0;l<16;l++,r+=4)be[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let d=be[l-15],T=be[l-2],v=Vt(d,7)^Vt(d,18)^d>>>3,y=Vt(T,17)^Vt(T,19)^T>>>10;be[l]=y+be[l-7]+v+be[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Vt(a,6)^Vt(a,11)^Vt(a,25),T=u+d+Ns(a,c,f)+Al[l]+be[l]|0,y=(Vt(n,2)^Vt(n,13)^Vt(n,22))+Ls(n,o,i)|0;u=f,f=c,c=a,a=s+T|0,s=i,i=o,o=n,n=T+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){ee(be)}destroy(){this.set(0,0,0,0,0,0,0,0),ee(this.buffer)}};var qs=ks(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),vl=qs[0],Cl=qs[1],Ee=new Uint32Array(80),Se=new Uint32Array(80),zo=class extends Cr{constructor(t=64){super(128,t,16,!1),this.Ah=dt[0]|0,this.Al=dt[1]|0,this.Bh=dt[2]|0,this.Bl=dt[3]|0,this.Ch=dt[4]|0,this.Cl=dt[5]|0,this.Dh=dt[6]|0,this.Dl=dt[7]|0,this.Eh=dt[8]|0,this.El=dt[9]|0,this.Fh=dt[10]|0,this.Fl=dt[11]|0,this.Gh=dt[12]|0,this.Gl=dt[13]|0,this.Hh=dt[14]|0,this.Hl=dt[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:T,Gl:v,Hh:y,Hl:h}=this;return[t,r,n,o,i,s,a,c,f,u,l,d,T,v,y,h]}set(t,r,n,o,i,s,a,c,f,u,l,d,T,v,y,h){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=T|0,this.Gl=v|0,this.Hh=y|0,this.Hl=h|0}process(t,r){for(let g=0;g<16;g++,r+=4)Ee[g]=t.getUint32(r),Se[g]=t.getUint32(r+=4);for(let g=16;g<80;g++){let D=Ee[g-15]|0,O=Se[g-15]|0,k=Pe(D,O,1)^Pe(D,O,8)^Ho(D,O,7),R=ke(D,O,1)^ke(D,O,8)^qo(D,O,7),x=Ee[g-2]|0,w=Se[g-2]|0,K=Pe(x,w,19)^Tr(x,w,61)^Ho(x,w,6),L=ke(x,w,19)^Br(x,w,61)^qo(x,w,6),_=Ms(R,L,Se[g-7],Se[g-16]),V=Fs(_,k,K,Ee[g-7],Ee[g-16]);Ee[g]=V|0,Se[g]=_|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:T,Fl:v,Gh:y,Gl:h,Hh:E,Hl:U}=this;for(let g=0;g<80;g++){let D=Pe(l,d,14)^Pe(l,d,18)^Tr(l,d,41),O=ke(l,d,14)^ke(l,d,18)^Br(l,d,41),k=l&T^~l&y,R=d&v^~d&h,x=Vs(U,O,R,Cl[g],Se[g]),w=Hs(x,E,D,k,vl[g],Ee[g]),K=x|0,L=Pe(n,o,28)^Tr(n,o,34)^Tr(n,o,39),_=ke(n,o,28)^Br(n,o,34)^Br(n,o,39),V=n&i^n&a^i&a,S=o&s^o&c^s&c;E=y|0,U=h|0,y=T|0,h=v|0,T=l|0,v=d|0,{h:l,l:d}=Gt(f|0,u|0,w|0,K|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=Ks(K,_,S);n=Os(A,w,L,V),o=A|0}({h:n,l:o}=Gt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Gt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Gt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Gt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=Gt(this.Eh|0,this.El|0,l|0,d|0),{h:T,l:v}=Gt(this.Fh|0,this.Fl|0,T|0,v|0),{h:y,l:h}=Gt(this.Gh|0,this.Gl|0,y|0,h|0),{h:E,l:U}=Gt(this.Hh|0,this.Hl|0,E|0,U|0),this.set(n,o,i,s,a,c,f,u,l,d,T,v,y,h,E,U)}roundClean(){ee(Ee,Se)}destroy(){ee(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var hn=Vo(()=>new dn);var zs=Vo(()=>new zo);var jo=BigInt(0),Zo=BigInt(1);function Ke(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yo(e){if(!Ke(e))throw new Error("Uint8Array expected")}function Zt(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Ir(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Zs(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?jo:BigInt("0x"+e)}var js=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Tl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ae(e){if(Yo(e),js)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Tl[e[r]];return t}var ne={_0:48,_9:57,A:65,F:70,a:97,f:102};function $s(e){if(e>=ne._0&&e<=ne._9)return e-ne._0;if(e>=ne.A&&e<=ne.F)return e-(ne.A-10);if(e>=ne.a&&e<=ne.f)return e-(ne.a-10)}function _r(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(js)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=$s(e.charCodeAt(i)),a=$s(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function oe(e){return Zs(Ae(e))}function Oe(e){return Yo(e),Zs(Ae(Uint8Array.from(e).reverse()))}function Me(e,t){return _r(e.toString(16).padStart(t*2,"0"))}function ir(e,t){return Me(e,t).reverse()}function tt(e,t,r){let n;if(typeof t=="string")try{n=_r(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Ke(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function ve(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Yo(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var $o=e=>typeof e=="bigint"&&jo<=e;function pn(e,t,r){return $o(e)&&$o(t)&&$o(r)&&t<=e&&e<r}function It(e,t,r,n){if(!pn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ys(e){let t;for(t=0;e>jo;e>>=Zo,t+=1);return t}var Fe=e=>(Zo<<BigInt(e))-Zo,Go=e=>new Uint8Array(e),Gs=e=>Uint8Array.from(e);function Ws(e,t,r){if(typeof e!="number"||e<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 r!="function")throw new Error("hmacFn must be a function");let n=Go(e),o=Go(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>r(o,n,...l),c=(l=Go(0))=>{o=a(Gs([0]),l),n=a(),l.length!==0&&(o=a(Gs([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<t;){n=a();let T=n.slice();d.push(T),l+=n.length}return ve(...d)};return(l,d)=>{s(),c(l);let T;for(;!(T=d(f()));)c();return s(),T}}var Bl={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Ke(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function ie(e,t,r={}){let n=(o,i,s)=>{let a=Bl[i];if(typeof a!="function")throw new Error("invalid validator function");let c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}function sr(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var xt=BigInt(0),at=BigInt(1),Ve=BigInt(2),Il=BigInt(3),Wo=BigInt(4),Xs=BigInt(5),Js=BigInt(8),_l=BigInt(9),Ul=BigInt(16);function J(e,t){let r=e%t;return r>=xt?r:t+r}function Q(e,t,r){let n=e;for(;t-- >xt;)n*=n,n%=r;return n}function mn(e,t){if(e===xt)throw new Error("invert: expected non-zero number");if(t<=xt)throw new Error("invert: expected positive modulus, got "+t);let r=J(e,t),n=t,o=xt,i=at,s=at,a=xt;for(;r!==xt;){let f=n/r,u=n%r,l=o-s*f,d=i-a*f;n=r,r=u,o=s,i=a,s=l,a=d}if(n!==at)throw new Error("invert: does not exist");return J(o,t)}function Dl(e){let t=e-at,r=0;for(;t%Ve===xt;)t/=Ve,r++;let n=Ve,o=se(e);for(;n<e&&Qs(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1){let s=(e+at)/Wo;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+at)/Ve;return function(a,c){if(!Qs(a,c))throw new Error("Cannot find square root");let f=r,u=a.pow(a.mul(a.ONE,n),t),l=a.pow(c,i),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let T=1;for(let y=a.sqr(d);T<f&&!a.eql(y,a.ONE);T++)y=a.sqr(y);let v=a.pow(u,at<<BigInt(f-T-1));u=a.sqr(v),l=a.mul(l,v),d=a.mul(d,u),f=T}return l}}function Rl(e){return e%Wo===Il?function(r,n){let o=(e+at)/Wo,i=r.pow(n,o);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}:e%Js===Xs?function(r,n){let o=r.mul(n,Ve),i=(e-Xs)/Js,s=r.pow(o,i),a=r.mul(n,s),c=r.mul(r.mul(a,Ve),s),f=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(f),n))throw new Error("Cannot find square root");return f}:(e%Ul,Dl(e))}var ta=(e,t)=>(J(e,t)&at)===at,Nl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xo(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Nl.reduce((n,o)=>(n[o]="function",n),t);return ie(e,r)}function Ll(e,t,r){if(r<xt)throw new Error("invalid exponent, negatives unsupported");if(r===xt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>xt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function ar(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Pl(e,t){let r=(e.ORDER-at)/Ve,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("Cannot find square root: probably non-prime P");return o?1:i?0:-1}function Qs(e,t){let r=Pl(e,t);return r===0||r===1}function Jo(e,t){t!==void 0&&cn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function se(e,t,r=!1,n={}){if(e<=xt)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=Jo(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:Fe(o),ZERO:xt,ONE:at,create:c=>J(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return xt<=c&&c<e},is0:c=>c===xt,isOdd:c=>(c&at)===at,neg:c=>J(-c,e),eql:(c,f)=>c===f,sqr:c=>J(c*c,e),add:(c,f)=>J(c+f,e),sub:(c,f)=>J(c-f,e),mul:(c,f)=>J(c*f,e),pow:(c,f)=>Ll(a,c,f),div:(c,f)=>J(c*mn(f,e),e),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>mn(c,e),sqrt:n.sqrt||(c=>(s||(s=Rl(e)),s(a,c))),toBytes:c=>r?ir(c,i):Me(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Oe(c):oe(c)},invertBatch:c=>ar(a,c),cmov:(c,f,u)=>u?f:c});return Object.freeze(a)}function ea(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Qo(e){let t=ea(e);return t+Math.ceil(t/2)}function ra(e,t,r=!1){let n=e.length,o=ea(t),i=Qo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Oe(e):oe(e),a=J(s,t-at)+at;return r?ir(a,o):Me(a,o)}var na=BigInt(0),oi=BigInt(1);function ti(e,t){let r=t.negate();return e?r:t}function ia(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ei(e,t){ia(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Fe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function oa(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=oi);let f=t*n,u=f+Math.abs(a)-1,l=a===0,d=a<0,T=t%2!==0;return{nextN:c,offset:u,isZero:l,isNeg:d,isNegF:T,offsetF:f}}function kl(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Kl(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var ri=new WeakMap,sa=new WeakMap;function ni(e){return sa.get(e)||1}function yn(e,t){return{constTimeNegate:ti,hasPrecomputes(r){return ni(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>na;)n&oi&&(o=o.add(i)),i=i.double(),n>>=oi;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=ei(n,t),s=[],a=r,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,a=ei(r,t);for(let c=0;c<a.windows;c++){let{nextN:f,offset:u,isZero:l,isNeg:d,isNegF:T,offsetF:v}=oa(o,c,a);o=f,l?s=s.add(ti(T,n[v])):i=i.add(ti(d,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=ei(r,t);for(let a=0;a<s.windows&&o!==na;a++){let{nextN:c,offset:f,isZero:u,isNeg:l}=oa(o,a,s);if(o=c,!u){let d=n[f];i=i.add(l?d.negate():d)}}return i},getPrecomputes(r,n,o){let i=ri.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&ri.set(n,o(i))),i},wNAFCached(r,n,o){let i=ni(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=ni(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){ia(n,t),sa.set(r,n),ri.delete(r)}}}function gn(e,t,r,n){if(kl(r,e),Kl(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Ys(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=Fe(s),c=new Array(Number(a)+1).fill(o),f=Math.floor((t.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let T=0;T<n.length;T++){let v=n[T],y=Number(v>>BigInt(l)&a);c[y]=c[y].add(r[T])}let d=o;for(let T=c.length-1,v=o;T>0;T--)v=v.add(c[T]),d=d.add(v);if(u=u.add(d),l!==0)for(let T=0;T<s;T++)u=u.double()}return u}function Ur(e){return Xo(e.Fp),ie(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jo(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var jt=BigInt(0),wt=BigInt(1),aa=BigInt(2),Ol=BigInt(8),Ml={zip215:!0};function Fl(e){let t=Ur(e);return ie(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ca(e){let t=Fl(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=aa<<BigInt(a*8)-wt,u=r.create,l=se(t.n,t.nBitLength),d=t.uvRatio||((b,m)=>{try{return{isValid:!0,value:r.sqrt(b*r.inv(m))}}catch{return{isValid:!1,value:jt}}}),T=t.adjustScalarBytes||(b=>b),v=t.domain||((b,m,C)=>{if(Zt("phflag",C),m.length||C)throw new Error("Contexts/pre-hash are not supported");return b});function y(b,m,C=!1){let P=C?wt:jt;It("coordinate "+b,m,P,f)}function h(b){if(!(b instanceof g))throw new Error("ExtendedPoint expected")}let E=sr((b,m)=>{let{ex:C,ey:P,ez:M}=b,H=b.is0();m==null&&(m=H?Ol:r.inv(M));let q=u(C*m),z=u(P*m),Z=u(M*m);if(H)return{x:jt,y:wt};if(Z!==wt)throw new Error("invZ was invalid");return{x:q,y:z}}),U=sr(b=>{let{a:m,d:C}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:P,ey:M,ez:H,et:q}=b,z=u(P*P),Z=u(M*M),Y=u(H*H),it=u(Y*Y),rt=u(z*m),lt=u(Y*u(rt+Z)),Et=u(it+u(C*u(z*Z)));if(lt!==Et)throw new Error("bad point: equation left != right (1)");let ct=u(P*M),mt=u(H*q);if(ct!==mt)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(m,C,P,M){y("x",m),y("y",C),y("z",P,!0),y("t",M),this.ex=m,this.ey=C,this.ez=P,this.et=M,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof g)throw new Error("extended point not allowed");let{x:C,y:P}=m||{};return y("x",C),y("y",P),new g(C,P,wt,u(C*P))}static normalizeZ(m){let C=ar(r,m.map(P=>P.ez));return m.map((P,M)=>P.toAffine(C[M])).map(g.fromAffine)}static msm(m,C){return gn(g,l,m,C)}_setWindowSize(m){k.setWindowSize(this,m)}assertValidity(){U(this)}equals(m){h(m);let{ex:C,ey:P,ez:M}=this,{ex:H,ey:q,ez:z}=m,Z=u(C*z),Y=u(H*M),it=u(P*z),rt=u(q*M);return Z===Y&&it===rt}is0(){return this.equals(g.ZERO)}negate(){return new g(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:m}=t,{ex:C,ey:P,ez:M}=this,H=u(C*C),q=u(P*P),z=u(aa*u(M*M)),Z=u(m*H),Y=C+P,it=u(u(Y*Y)-H-q),rt=Z+q,lt=rt-z,Et=Z-q,ct=u(it*lt),mt=u(rt*Et),Ct=u(it*Et),Kt=u(lt*rt);return new g(ct,mt,Kt,Ct)}add(m){h(m);let{a:C,d:P}=t,{ex:M,ey:H,ez:q,et:z}=this,{ex:Z,ey:Y,ez:it,et:rt}=m,lt=u(M*Z),Et=u(H*Y),ct=u(z*P*rt),mt=u(q*it),Ct=u((M+H)*(Z+Y)-lt-Et),Kt=mt-ct,yr=mt+ct,Ji=u(Et-C*lt),_u=u(Ct*Kt),Uu=u(yr*Ji),Du=u(Ct*Ji),Ru=u(Kt*yr);return new g(_u,Uu,Ru,Du)}subtract(m){return this.add(m.negate())}wNAF(m){return k.wNAFCached(this,m,g.normalizeZ)}multiply(m){let C=m;It("scalar",C,wt,n);let{p:P,f:M}=this.wNAF(C);return g.normalizeZ([P,M])[0]}multiplyUnsafe(m,C=g.ZERO){let P=m;return It("scalar",P,jt,n),P===jt?O:this.is0()||P===wt?this:k.wNAFCachedUnsafe(this,P,g.normalizeZ,C)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(m){return E(this,m)}clearCofactor(){let{h:m}=t;return m===wt?this:this.multiplyUnsafe(m)}static fromHex(m,C=!1){let{d:P,a:M}=t,H=r.BYTES;m=tt("pointHex",m,H),Zt("zip215",C);let q=m.slice(),z=m[H-1];q[H-1]=z&-129;let Z=Oe(q),Y=C?f:r.ORDER;It("pointHex.y",Z,jt,Y);let it=u(Z*Z),rt=u(it-wt),lt=u(P*it-M),{isValid:Et,value:ct}=d(rt,lt);if(!Et)throw new Error("Point.fromHex: invalid y coordinate");let mt=(ct&wt)===wt,Ct=(z&128)!==0;if(!C&&ct===jt&&Ct)throw new Error("Point.fromHex: x=0 and x_0=1");return Ct!==mt&&(ct=u(-ct)),g.fromAffine({x:ct,y:Z})}static fromPrivateKey(m){let{scalar:C}=w(m);return D.multiply(C)}toRawBytes(){let{x:m,y:C}=this.toAffine(),P=ir(C,r.BYTES);return P[P.length-1]|=m&wt?128:0,P}toHex(){return Ae(this.toRawBytes())}}g.BASE=new g(t.Gx,t.Gy,wt,u(t.Gx*t.Gy)),g.ZERO=new g(jt,wt,wt,jt);let{BASE:D,ZERO:O}=g,k=yn(g,a*8);function R(b){return J(b,n)}function x(b){return R(Oe(b))}function w(b){let m=r.BYTES;b=tt("private key",b,m);let C=tt("hashed private key",i(b),2*m),P=T(C.slice(0,m)),M=C.slice(m,2*m),H=x(P);return{head:P,prefix:M,scalar:H}}function K(b){let{head:m,prefix:C,scalar:P}=w(b),M=D.multiply(P),H=M.toRawBytes();return{head:m,prefix:C,scalar:P,point:M,pointBytes:H}}function L(b){return K(b).pointBytes}function _(b=Uint8Array.of(),...m){let C=ve(...m);return x(i(v(C,tt("context",b),!!o)))}function V(b,m,C={}){b=tt("message",b),o&&(b=o(b));let{prefix:P,scalar:M,pointBytes:H}=K(m),q=_(C.context,P,b),z=D.multiply(q).toRawBytes(),Z=_(C.context,z,H,b),Y=R(q+Z*M);It("signature.s",Y,jt,n);let it=ve(z,ir(Y,r.BYTES));return tt("result",it,r.BYTES*2)}let S=Ml;function A(b,m,C,P=S){let{context:M,zip215:H}=P,q=r.BYTES;b=tt("signature",b,2*q),m=tt("message",m),C=tt("publicKey",C,q),H!==void 0&&Zt("zip215",H),o&&(m=o(m));let z=Oe(b.slice(q,2*q)),Z,Y,it;try{Z=g.fromHex(C,H),Y=g.fromHex(b.slice(0,q),H),it=D.multiplyUnsafe(z)}catch{return!1}if(!H&&Z.isSmallOrder())return!1;let rt=_(M,Y.toRawBytes(),Z.toRawBytes(),m);return Y.add(Z.multiplyUnsafe(rt)).subtract(it).clearCofactor().equals(g.ZERO)}return D._setWindowSize(8),{CURVE:t,getPublicKey:L,sign:V,verify:A,ExtendedPoint:g,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(b=8,m=g.BASE){return m._setWindowSize(b),m.multiply(BigInt(3)),m}}}}var ii=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ua=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),qp=BigInt(0),Vl=BigInt(1),fa=BigInt(2),zp=BigInt(3),Hl=BigInt(5),ql=BigInt(8);function zl(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=ii,a=e*e%i*e%i,c=Q(a,fa,i)*a%i,f=Q(c,Vl,i)*e%i,u=Q(f,Hl,i)*f%i,l=Q(u,t,i)*u%i,d=Q(l,r,i)*l%i,T=Q(d,n,i)*d%i,v=Q(T,o,i)*T%i,y=Q(v,o,i)*T%i,h=Q(y,t,i)*u%i;return{pow_p_5_8:Q(h,fa,i)*e%i,b2:a}}function $l(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Gl(e,t){let r=ii,n=J(t*t*t,r),o=J(n*n*t,r),i=zl(e*o).pow_p_5_8,s=J(e*n*i,r),a=J(t*s*s,r),c=s,f=J(s*ua,r),u=a===e,l=a===J(-e,r),d=a===J(-e*ua,r);return u&&(s=c),(l||d)&&(s=f),ta(s,r)&&(s=J(-s,r)),{isValid:u||l,value:s}}var la=se(ii,void 0,!0),Zl={a:la.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:la,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ql,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:zs,randomBytes:fn,adjustScalarBytes:$l,uvRatio:Gl},da=ca(Zl);var xn=32;function ha(e,t,r){return da.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var wn=class{type="Ed25519";raw;constructor(t){this.raw=si(t,xn)}toMultihash(){return Ft.digest(we(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}verify(t,r){return ha(this.raw,r,t)}};function ai(e){return e=si(e,xn),new wn(e)}function si(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new st(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Yl=Math.pow(2,7),Wl=Math.pow(2,14),Xl=Math.pow(2,21),ma=Math.pow(2,28),ya=Math.pow(2,35),ga=Math.pow(2,42),xa=Math.pow(2,49),bt=128,Ce=127;function Dr(e){if(e<Yl)return 1;if(e<Wl)return 2;if(e<Xl)return 3;if(e<ma)return 4;if(e<ya)return 5;if(e<ga)return 6;if(e<xa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function wa(e,t,r=0){switch(Dr(e)){case 8:t[r++]=e&255|bt,e/=128;case 7:t[r++]=e&255|bt,e/=128;case 6:t[r++]=e&255|bt,e/=128;case 5:t[r++]=e&255|bt,e/=128;case 4:t[r++]=e&255|bt,e>>>=7;case 3:t[r++]=e&255|bt,e>>>=7;case 2:t[r++]=e&255|bt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function ba(e,t){let r=e[t],n=0;if(n+=r&Ce,r<bt||(r=e[t+1],n+=(r&Ce)<<7,r<bt)||(r=e[t+2],n+=(r&Ce)<<14,r<bt)||(r=e[t+3],n+=(r&Ce)<<21,r<bt)||(r=e[t+4],n+=(r&Ce)*ma,r<bt)||(r=e[t+5],n+=(r&Ce)*ya,r<bt)||(r=e[t+6],n+=(r&Ce)*ga,r<bt)||(r=e[t+7],n+=(r&Ce)*xa,r<bt))return n;throw new RangeError("Could not decode varint")}var ci=new Float32Array([-0]),Te=new Uint8Array(ci.buffer);function Ea(e,t,r){ci[0]=e,t[r]=Te[0],t[r+1]=Te[1],t[r+2]=Te[2],t[r+3]=Te[3]}function Sa(e,t){return Te[0]=e[t],Te[1]=e[t+1],Te[2]=e[t+2],Te[3]=e[t+3],ci[0]}var ui=new Float64Array([-0]),yt=new Uint8Array(ui.buffer);function Aa(e,t,r){ui[0]=e,t[r]=yt[0],t[r+1]=yt[1],t[r+2]=yt[2],t[r+3]=yt[3],t[r+4]=yt[4],t[r+5]=yt[5],t[r+6]=yt[6],t[r+7]=yt[7]}function va(e,t){return yt[0]=e[t],yt[1]=e[t+1],yt[2]=e[t+2],yt[3]=e[t+3],yt[4]=e[t+4],yt[5]=e[t+5],yt[6]=e[t+6],yt[7]=e[t+7],ui[0]}var Jl=BigInt(Number.MAX_SAFE_INTEGER),Ql=BigInt(Number.MIN_SAFE_INTEGER),_t=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return He;if(t<Jl&&t>Ql)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ca&&(o=0n,++n>Ca&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return He;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):He}},He=new _t(0,0);He.toBigInt=function(){return 0n};He.zzEncode=He.zzDecode=function(){return this};He.length=function(){return 1};var Ca=4294967296n;function Ta(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ba(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function fi(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Ht(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function bn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var li=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,Ht(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 Ht(this,4);return bn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ht(this,4);return bn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ht(this,4);let t=Sa(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ht(this,4);let t=va(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Ht(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ba(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Ht(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ht(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 _t(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Ht(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Ht(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ht(this,8);let t=bn(this.buf,this.pos+=4),r=bn(this.buf,this.pos+=4);return new _t(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ba(this.buf,this.pos);return this.pos+=Dr(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 di(e){return new li(e instanceof Uint8Array?e:e.subarray())}function Be(e,t,r){let n=di(e);return t.decode(n,void 0,r)}function hi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Tt(s);o+s>t&&(n=Tt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var qe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function pi(){}var yi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},td=hi();function ed(e){return globalThis.Buffer!=null?Tt(e):td(e)}var Nr=class{len;head;tail;states;constructor(){this.len=0,this.head=new qe(pi,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new qe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new gi((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(En,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=_t.fromBigInt(t);return this._push(En,r.length(),r)}uint64Number(t){return this._push(wa,Dr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=_t.fromBigInt(t).zzEncode();return this._push(En,r.length(),r)}sint64Number(t){let r=_t.fromNumber(t).zzEncode();return this._push(En,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(mi,1,t?1:0)}fixed32(t){return this._push(Rr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=_t.fromBigInt(t);return this._push(Rr,4,r.lo)._push(Rr,4,r.hi)}fixed64Number(t){let r=_t.fromNumber(t);return this._push(Rr,4,r.lo)._push(Rr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Ea,4,t)}double(t){return this._push(Aa,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(mi,1,0):this.uint32(r)._push(nd,r,t)}string(t){let r=Ta(t);return r!==0?this.uint32(r)._push(fi,r,t):this._push(mi,1,0)}fork(){return this.states=new yi(this),this.head=this.tail=new qe(pi,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 qe(pi,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=ed(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function mi(e,t,r){t[r]=e&255}function rd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var gi=class extends qe{next;constructor(t,r){super(rd,t,r),this.next=void 0}};function En(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Rr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function nd(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Nr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(od,t,e),this},Nr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(id,t,e),this});function od(e,t,r){t.set(e,r)}function id(e,t,r){e.length<40?fi(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set($(e),r)}function xi(){return new Nr}function Ie(e,t){let r=xi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var cr;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(cr||(cr={}));function Sn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Lr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Sn("enum",cr.VARINT,r,n)}function _e(e,t){return Sn("message",cr.LENGTH_DELIMITED,e,t)}var ot;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ot||(ot={}));var wi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(wi||(wi={}));(function(e){e.codec=()=>Lr(wi)})(ot||(ot={}));var Yt;(function(e){let t;e.codec=()=>(t==null&&(t=_e((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ot.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ot.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Ie(r,e.codec()),e.decode=(r,n)=>Be(r,e.codec(),n)})(Yt||(Yt={}));var bi;(function(e){let t;e.codec=()=>(t==null&&(t=_e((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ot.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ot.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Ie(r,e.codec()),e.decode=(r,n)=>Be(r,e.codec(),n)})(bi||(bi={}));var Pr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},An=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Ua={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new An("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Ue=Ua;var Kr={};St(Kr,{MAX_RSA_KEY_SIZE:()=>Ei,generateRSAKeyPair:()=>La,jwkToJWKKeyPair:()=>Pa,jwkToPkcs1:()=>ud,jwkToPkix:()=>Ci,jwkToRSAPrivateKey:()=>_i,pkcs1MessageToJwk:()=>Ai,pkcs1MessageToRSAPrivateKey:()=>Ti,pkcs1ToJwk:()=>cd,pkcs1ToRSAPrivateKey:()=>Na,pkixMessageToJwk:()=>vi,pkixMessageToRSAPublicKey:()=>Ii,pkixToJwk:()=>fd,pkixToRSAPublicKey:()=>Bi});var vn=hn;var ur=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Kr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}verify(t,r){return Ra(this.jwk,r,t)}},kr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Kr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}sign(t){return Da(this.jwk,t)}};var Ei=8192,Si=18,sd=1062,ad=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function cd(e){let t=te(e);return Ai(t)}function Ai(e){return{n:j(e[1],"base64url"),e:j(e[2],"base64url"),d:j(e[3],"base64url"),p:j(e[4],"base64url"),q:j(e[5],"base64url"),dp:j(e[6],"base64url"),dq:j(e[7],"base64url"),qi:j(e[8],"base64url"),kty:"RSA"}}function ud(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new st("JWK was missing components");return xe([vt(Uint8Array.from([0])),vt($(e.n,"base64url")),vt($(e.e,"base64url")),vt($(e.d,"base64url")),vt($(e.p,"base64url")),vt($(e.q,"base64url")),vt($(e.dp,"base64url")),vt($(e.dq,"base64url")),vt($(e.qi,"base64url"))]).subarray()}function fd(e){let t=te(e,{offset:0});return vi(t)}function vi(e){let t=te(e[1],{offset:0});return{kty:"RSA",n:j(t[0],"base64url"),e:j(t[1],"base64url")}}function Ci(e){if(e.n==null||e.e==null)throw new st("JWK was missing components");return xe([ad,an(xe([vt($(e.n,"base64url")),vt($(e.e,"base64url"))]))]).subarray()}function Na(e){let t=te(e);return Ti(t)}function Ti(e){let t=Ai(e);return _i(t)}function Bi(e,t){if(e.byteLength>=sd)throw new Ye("Key size is too large");let r=te(e,{offset:0});return Ii(r,e,t)}function Ii(e,t,r){let n=vi(e);if(r==null){let o=vn(Yt.encode({Type:ot.RSA,Data:t}));r=Mt(Si,o)}return new ur(n,r)}function _i(e){if(Ka(e)>Ei)throw new st("Key size is too large");let t=Pa(e),r=vn(Yt.encode({Type:ot.RSA,Data:Ci(t.publicKey)})),n=Mt(Si,r);return new kr(t.privateKey,new ur(t.publicKey,n))}async function La(e){if(e>Ei)throw new st("Key size is too large");let t=await ka(e),r=vn(Yt.encode({Type:ot.RSA,Data:Ci(t.publicKey)})),n=Mt(Si,r);return new kr(t.privateKey,new ur(t.publicKey,n))}function Pa(e){if(e==null)throw new st("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function ka(e){let t=await Ue.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await ld(t);return{privateKey:r[0],publicKey:r[1]}}async function Da(e,t){let r=await Ue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ue.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ra(e,t,r){let n=await Ue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ue.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function ld(e){if(e.privateKey==null||e.publicKey==null)throw new st("Private and public key are required");return Promise.all([Ue.get().subtle.exportKey("jwk",e.privateKey),Ue.get().subtle.exportKey("jwk",e.publicKey)])}function Ka(e){if(e.kty!=="RSA")throw new st("invalid key type");if(e.n==null)throw new st("invalid key modulus");return $(e.n,"base64url").length*8}var Cn=class extends nr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Us(t);let n=vr(r);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,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),ee(i)}update(t){return or(this),this.iHash.update(t),this}digestInto(t){or(this),Le(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:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ui=(e,t,r)=>new Cn(e,t).update(r).digest();Ui.create=(e,t)=>new Cn(e,t);function Oa(e){e.lowS!==void 0&&Zt("lowS",e.lowS),e.prehash!==void 0&&Zt("prehash",e.prehash)}function dd(e){let t=Ur(e);ie(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var Di=class extends Error{constructor(t=""){super(t)}},ae={Err:Di,_tlv:{encode:(e,t)=>{let{Err:r}=ae;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Ir(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Ir(o.length/2|128):"";return Ir(e)+i+o+t},decode(e,t){let{Err:r}=ae,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=ae;if(e<ce)throw new t("integer: negative integers are not allowed");let r=Ir(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ae;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return oe(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=ae,o=tt("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=ae,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},ce=BigInt(0),ut=BigInt(1),by=BigInt(2),Ma=BigInt(3),Ey=BigInt(4);function hd(e){let t=dd(e),{Fp:r}=t,n=se(t.n,t.nBitLength),o=t.toBytes||((y,h,E)=>{let U=h.toAffine();return ve(Uint8Array.from([4]),r.toBytes(U.x),r.toBytes(U.y))}),i=t.fromBytes||(y=>{let h=y.subarray(1),E=r.fromBytes(h.subarray(0,r.BYTES)),U=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:E,y:U}});function s(y){let{a:h,b:E}=t,U=r.sqr(y),g=r.mul(U,y);return r.add(r.add(g,r.mul(y,h)),E)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return pn(y,ut,t.n)}function c(y){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:U,n:g}=t;if(h&&typeof y!="bigint"){if(Ke(y)&&(y=Ae(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(E*2,"0")}let D;try{D=typeof y=="bigint"?y:oe(tt("private key",y,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof y)}return U&&(D=J(D,g)),It("private key",D,ut,g),D}function f(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}let u=sr((y,h)=>{let{px:E,py:U,pz:g}=y;if(r.eql(g,r.ONE))return{x:E,y:U};let D=y.is0();h==null&&(h=D?r.ONE:r.inv(g));let O=r.mul(E,h),k=r.mul(U,h),R=r.mul(g,h);if(D)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:O,y:k}}),l=sr(y=>{if(y.is0()){if(t.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=y.toAffine();if(!r.isValid(h)||!r.isValid(E))throw new Error("bad point: x or y not FE");let U=r.sqr(E),g=s(h);if(!r.eql(U,g))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,E,U){if(h==null||!r.isValid(h))throw new Error("x required");if(E==null||!r.isValid(E)||r.is0(E))throw new Error("y required");if(U==null||!r.isValid(U))throw new Error("z required");this.px=h,this.py=E,this.pz=U,Object.freeze(this)}static fromAffine(h){let{x:E,y:U}=h||{};if(!h||!r.isValid(E)||!r.isValid(U))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let g=D=>r.eql(D,r.ZERO);return g(E)&&g(U)?d.ZERO:new d(E,U,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=ar(r,h.map(U=>U.pz));return h.map((U,g)=>U.toAffine(E[g])).map(d.fromAffine)}static fromHex(h){let E=d.fromAffine(i(tt("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,E){return gn(d,n,h,E)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:E,py:U,pz:g}=this,{px:D,py:O,pz:k}=h,R=r.eql(r.mul(E,k),r.mul(D,g)),x=r.eql(r.mul(U,k),r.mul(O,g));return R&&x}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:E}=t,U=r.mul(E,Ma),{px:g,py:D,pz:O}=this,k=r.ZERO,R=r.ZERO,x=r.ZERO,w=r.mul(g,g),K=r.mul(D,D),L=r.mul(O,O),_=r.mul(g,D);return _=r.add(_,_),x=r.mul(g,O),x=r.add(x,x),k=r.mul(h,x),R=r.mul(U,L),R=r.add(k,R),k=r.sub(K,R),R=r.add(K,R),R=r.mul(k,R),k=r.mul(_,k),x=r.mul(U,x),L=r.mul(h,L),_=r.sub(w,L),_=r.mul(h,_),_=r.add(_,x),x=r.add(w,w),w=r.add(x,w),w=r.add(w,L),w=r.mul(w,_),R=r.add(R,w),L=r.mul(D,O),L=r.add(L,L),w=r.mul(L,_),k=r.sub(k,w),x=r.mul(L,K),x=r.add(x,x),x=r.add(x,x),new d(k,R,x)}add(h){f(h);let{px:E,py:U,pz:g}=this,{px:D,py:O,pz:k}=h,R=r.ZERO,x=r.ZERO,w=r.ZERO,K=t.a,L=r.mul(t.b,Ma),_=r.mul(E,D),V=r.mul(U,O),S=r.mul(g,k),A=r.add(E,U),B=r.add(D,O);A=r.mul(A,B),B=r.add(_,V),A=r.sub(A,B),B=r.add(E,g);let b=r.add(D,k);return B=r.mul(B,b),b=r.add(_,S),B=r.sub(B,b),b=r.add(U,g),R=r.add(O,k),b=r.mul(b,R),R=r.add(V,S),b=r.sub(b,R),w=r.mul(K,B),R=r.mul(L,S),w=r.add(R,w),R=r.sub(V,w),w=r.add(V,w),x=r.mul(R,w),V=r.add(_,_),V=r.add(V,_),S=r.mul(K,S),B=r.mul(L,B),V=r.add(V,S),S=r.sub(_,S),S=r.mul(K,S),B=r.add(B,S),_=r.mul(V,B),x=r.add(x,_),_=r.mul(b,B),R=r.mul(A,R),R=r.sub(R,_),_=r.mul(A,V),w=r.mul(b,w),w=r.add(w,_),new d(R,x,w)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return v.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:E,n:U}=t;It("scalar",h,ce,U);let g=d.ZERO;if(h===ce)return g;if(this.is0()||h===ut)return this;if(!E||v.hasPrecomputes(this))return v.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:D,k1:O,k2neg:k,k2:R}=E.splitScalar(h),x=g,w=g,K=this;for(;O>ce||R>ce;)O&ut&&(x=x.add(K)),R&ut&&(w=w.add(K)),K=K.double(),O>>=ut,R>>=ut;return D&&(x=x.negate()),k&&(w=w.negate()),w=new d(r.mul(w.px,E.beta),w.py,w.pz),x.add(w)}multiply(h){let{endo:E,n:U}=t;It("scalar",h,ut,U);let g,D;if(E){let{k1neg:O,k1:k,k2neg:R,k2:x}=E.splitScalar(h),{p:w,f:K}=this.wNAF(k),{p:L,f:_}=this.wNAF(x);w=v.constTimeNegate(O,w),L=v.constTimeNegate(R,L),L=new d(r.mul(L.px,E.beta),L.py,L.pz),g=w.add(L),D=K.add(_)}else{let{p:O,f:k}=this.wNAF(h);g=O,D=k}return d.normalizeZ([g,D])[0]}multiplyAndAddUnsafe(h,E,U){let g=d.BASE,D=(k,R)=>R===ce||R===ut||!k.equals(g)?k.multiplyUnsafe(R):k.multiply(R),O=D(this,E).add(D(h,U));return O.is0()?void 0:O}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=t;if(h===ut)return!0;if(E)return E(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=t;return h===ut?this:E?E(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Zt("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Zt("isCompressed",h),Ae(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let T=t.nBitLength,v=yn(d,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function pd(e){let t=Ur(e);return ie(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Fa(e){let t=pd(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return mn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=hd({...t,toBytes(S,A,B){let b=A.toAffine(),m=r.toBytes(b.x),C=ve;return Zt("isCompressed",B),B?C(Uint8Array.from([A.hasEvenY()?2:3]),m):C(Uint8Array.from([4]),m,r.toBytes(b.y))},fromBytes(S){let A=S.length,B=S[0],b=S.subarray(1);if(A===o&&(B===2||B===3)){let m=oe(b);if(!pn(m,ut,r.ORDER))throw new Error("Point is not on curve");let C=u(m),P;try{P=r.sqrt(C)}catch(q){let z=q instanceof Error?": "+q.message:"";throw new Error("Point is not on curve"+z)}let M=(P&ut)===ut;return(B&1)===1!==M&&(P=r.neg(P)),{x:m,y:P}}else if(A===i&&B===4){let m=r.fromBytes(b.subarray(0,r.BYTES)),C=r.fromBytes(b.subarray(r.BYTES,2*r.BYTES));return{x:m,y:C}}else{let m=o,C=i;throw new Error("invalid Point, expected length of "+m+", or uncompressed "+C+", got "+A)}}}),d=S=>Ae(Me(S,t.nByteLength));function T(S){let A=n>>ut;return S>A}function v(S){return T(S)?s(-S):S}let y=(S,A,B)=>oe(S.slice(A,B));class h{constructor(A,B,b){It("r",A,ut,n),It("s",B,ut,n),this.r=A,this.s=B,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(A){let B=t.nByteLength;return A=tt("compactSignature",A,B*2),new h(y(A,0,B),y(A,B,2*B))}static fromDER(A){let{r:B,s:b}=ae.toSig(tt("DER",A));return new h(B,b)}assertValidity(){}addRecoveryBit(A){return new h(this.r,this.s,A)}recoverPublicKey(A){let{r:B,s:b,recovery:m}=this,C=k(tt("msgHash",A));if(m==null||![0,1,2,3].includes(m))throw new Error("recovery id invalid");let P=m===2||m===3?B+t.n:B;if(P>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=(m&1)===0?"02":"03",H=c.fromHex(M+d(P)),q=a(P),z=s(-C*q),Z=s(b*q),Y=c.BASE.multiplyAndAddUnsafe(H,z,Z);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return T(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return _r(this.toDERHex())}toDERHex(){return ae.hexFromSig(this)}toCompactRawBytes(){return _r(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let E={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Qo(t.n);return ra(t.randomBytes(S),t.n)},precompute(S=8,A=c.BASE){return A._setWindowSize(S),A.multiply(BigInt(3)),A}};function U(S,A=!0){return c.fromPrivateKey(S).toRawBytes(A)}function g(S){let A=Ke(S),B=typeof S=="string",b=(A||B)&&S.length;return A?b===o||b===i:B?b===2*o||b===2*i:S instanceof c}function D(S,A,B=!0){if(g(S))throw new Error("first arg must be private key");if(!g(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(f(S)).toRawBytes(B)}let O=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let A=oe(S),B=S.length*8-t.nBitLength;return B>0?A>>BigInt(B):A},k=t.bits2int_modN||function(S){return s(O(S))},R=Fe(t.nBitLength);function x(S){return It("num < 2^"+t.nBitLength,S,ce,R),Me(S,t.nByteLength)}function w(S,A,B=K){if(["recovered","canonical"].some(rt=>rt in B))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:m}=t,{lowS:C,prehash:P,extraEntropy:M}=B;C==null&&(C=!0),S=tt("msgHash",S),Oa(B),P&&(S=tt("prehashed msgHash",b(S)));let H=k(S),q=f(A),z=[x(q),x(H)];if(M!=null&&M!==!1){let rt=M===!0?m(r.BYTES):M;z.push(tt("extraEntropy",rt))}let Z=ve(...z),Y=H;function it(rt){let lt=O(rt);if(!l(lt))return;let Et=a(lt),ct=c.BASE.multiply(lt).toAffine(),mt=s(ct.x);if(mt===ce)return;let Ct=s(Et*s(Y+mt*q));if(Ct===ce)return;let Kt=(ct.x===mt?0:2)|Number(ct.y&ut),yr=Ct;return C&&T(Ct)&&(yr=v(Ct),Kt^=1),new h(mt,yr,Kt)}return{seed:Z,k2sig:it}}let K={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function _(S,A,B=K){let{seed:b,k2sig:m}=w(S,A,B),C=t;return Ws(C.hash.outputLen,C.nByteLength,C.hmac)(b,m)}c.BASE._setWindowSize(8);function V(S,A,B,b=L){let m=S;A=tt("msgHash",A),B=tt("publicKey",B);let{lowS:C,prehash:P,format:M}=b;if(Oa(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");let H=typeof m=="string"||Ke(m),q=!H&&!M&&typeof m=="object"&&m!==null&&typeof m.r=="bigint"&&typeof m.s=="bigint";if(!H&&!q)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let z,Z;try{if(q&&(z=new h(m.r,m.s)),H){try{M!=="compact"&&(z=h.fromDER(m))}catch(Kt){if(!(Kt instanceof ae.Err))throw Kt}!z&&M!=="der"&&(z=h.fromCompact(m))}Z=c.fromHex(B)}catch{return!1}if(!z||C&&z.hasHighS())return!1;P&&(A=t.hash(A));let{r:Y,s:it}=z,rt=k(A),lt=a(it),Et=s(rt*lt),ct=s(Y*lt),mt=c.BASE.multiplyAndAddUnsafe(Z,Et,ct)?.toAffine();return mt?s(mt.x)===Y:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:D,sign:_,verify:V,ProjectivePoint:c,Signature:h,utils:E}}function md(e){return{hash:e,hmac:(t,...r)=>Ui(e,t,Fo(...r)),randomBytes:fn}}function Va(e,t){let r=n=>Fa({...e,...md(n)});return{...r(t),create:r}}var za=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ha=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),yd=BigInt(1),Ri=BigInt(2),qa=(e,t)=>(e+t/Ri)/t;function gd(e){let t=za,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=Q(u,r,t)*u%t,d=Q(l,r,t)*u%t,T=Q(d,Ri,t)*f%t,v=Q(T,o,t)*T%t,y=Q(v,i,t)*v%t,h=Q(y,a,t)*y%t,E=Q(h,c,t)*h%t,U=Q(E,a,t)*y%t,g=Q(U,r,t)*u%t,D=Q(g,s,t)*v%t,O=Q(D,n,t)*f%t,k=Q(O,Ri,t);if(!Ni.eql(Ni.sqr(k),e))throw new Error("Cannot find square root");return k}var Ni=se(za,void 0,void 0,{sqrt:gd}),ze=Va({a:BigInt(0),b:BigInt(7),Fp:Ni,n:Ha,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Ha,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-yd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=qa(i*e,t),c=qa(-n*e,t),f=J(e-a*r-c*o,t),u=J(-a*n-c*i,t),l=f>s,d=u>s;if(l&&(f=t-f),d&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},hn),Uy=BigInt(0);var Dy=ze.ProjectivePoint;function $a(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Ga(e,t,r){let n=Er.digest(r instanceof Uint8Array?r:r.subarray());if($a(n))return n.then(({digest:o})=>ze.verify(t,o,e)).catch(o=>{throw new Pr(String(o))});try{return ze.verify(t,n.digest,e)}catch(o){throw new Pr(String(o))}}var Tn=class{type="secp256k1";raw;_key;constructor(t){this._key=ja(t),this.raw=Za(this._key)}toMultihash(){return Ft.digest(we(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}verify(t,r){return Ga(this._key,r,t)}};function Li(e){return new Tn(e)}function Za(e){return ze.ProjectivePoint.fromHex(e).toRawBytes(!0)}function ja(e){try{return ze.ProjectivePoint.fromHex(e),e}catch(t){throw new Ye(String(t))}}function Ya(e,t){let{Type:r,Data:n}=Yt.decode(e),o=n??new Uint8Array;switch(r){case ot.RSA:return Bi(o,t);case ot.Ed25519:return ai(o);case ot.secp256k1:return Li(o);case ot.ECDSA:return Mo(o);default:throw new Xe}}function Bn(e){let{Type:t,Data:r}=Yt.decode(e.digest),n=r??new Uint8Array;switch(t){case ot.Ed25519:return ai(n);case ot.secp256k1:return Li(n);case ot.ECDSA:return Mo(n);default:throw new Xe}}function we(e){return Yt.encode({Type:ot[e.type],Data:e.raw})}var Wa=Symbol.for("nodejs.util.inspect.custom"),xd=114,Or=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()})`}[co]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(xd,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return nt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return nt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Wa](){return`PeerId(${this.toString()})`}},In=class extends Or{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},_n=class extends Or{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Un=class extends Or{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},wd=2336,Mr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Ft.digest($(this.url))}[Wa](){return`PeerId(${this.url})`}[co]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(wd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=j(t)),t.toString()===this.toString())}};var bd=114,Xa=2336;function Dn(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Qt(W.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Pi(X.parse(e));if(t==null)throw new st('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Qt(t.decode(e))}return Ja(r)}function Ja(e){if(Sd(e))return new In({multihash:e});if(Ed(e))try{let t=Bn(e);if(t.type==="Ed25519")return new _n({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Un({multihash:e,publicKey:t})}catch{let r=j(e.digest);return new Mr(new URL(r))}throw new We("Supplied PeerID Multihash is invalid")}function Pi(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==bd&&e.code!==Xa)throw new Qr("Supplied PeerID CID is invalid");if(e.code===Xa){let t=j(e.multihash.digest);return new Mr(new URL(t))}return Ja(e.multihash)}function Ed(e){return e.code===Ft.code}function Sd(e){return e.code===Er.code}var ue="/",Qa=new TextEncoder().encode(ue),Rn=Qa[0],Fr=class e{_buf;constructor(t,r){if(typeof t=="string")this._buf=$(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Rn)throw new Error("Invalid key")}toString(t="utf8"){return j(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new e(t.join(ue))}static random(){return new e(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new e(t):typeof t.uint8Array=="function"?new e(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Qa),this._buf[0]!==Rn){let t=new Uint8Array(this._buf.byteLength+1);t.fill(Rn,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Rn;)this._buf=this._buf.subarray(0,-1)}less(t){let r=this.list(),n=t.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(ue).slice(1)}type(){return Ad(this.baseNamespace())}name(){return vd(this.baseNamespace())}instance(t){return new e(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(ue)||(t+=ue),t+=this.type(),new e(t)}parent(){let t=this.list();return t.length===1?new e(ue):new e(t.slice(0,-1).join(ue))}child(t){return this.toString()===ue?t:t.toString()===ue?this:new e(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return e.withNamespaces([...this.namespaces(),...Cd(t.map(r=>r.namespaces()))])}};function Ad(e){let t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function vd(e){let t=e.split(":");return t[t.length-1]}function Cd(e){return[].concat(...e)}var lu=Jr(Nn(),1);var Ln=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},qt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Pn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},$e=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},kn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Vr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Kn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Hr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var ht;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Lr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=_e((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),e.encode=o=>Ie(o,e.codec()),e.decode=(o,i)=>Be(o,e.codec(),i)})(ht||(ht={}));var Td=["string","number","bigint","symbol"],Bd=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function tc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Td.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Id(e))return"Buffer";let r=_d(e);return r||"Object"}function Id(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function _d(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Bd.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var N=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var fr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ud=new TextDecoder,Dd=new TextEncoder;function On(e){return fr&&globalThis.Buffer.isBuffer(e)}function Ki(e){return e instanceof Uint8Array?On(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var oc=fr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):rc(e,t,r):(e,t,r)=>r-t>64?Ud.decode(e.subarray(t,r)):rc(e,t,r),ic=fr?e=>e.length>64?globalThis.Buffer.from(e):ec(e):e=>e.length>64?Dd.encode(e):ec(e),Wt=e=>Uint8Array.from(e),lr=fr?(e,t,r)=>On(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),sc=fr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ki(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},ac=fr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function cc(e,t){if(On(e)&&On(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function ec(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function rc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],f=e[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Rd(n)}var nc=4096;function Rd(e){let t=e.length;if(t<=nc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=nc));return r}var Nd=256,qr=class{constructor(t=Nd){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=ac(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=lr(n,0,this.cursor)}else r=sc(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",Oi="CBOR encode error:",zr=[];zr[23]=1;zr[24]=2;zr[25]=3;zr[26]=5;zr[27]=9;function fe(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var ft=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ut(e,t,r){fe(e,t,1);let n=e[t];if(r.strict===!0&&n<ft[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){fe(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ft[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){fe(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ft[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){fe(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ft[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function uc(e,t,r,n){return new N(p.uint,Ut(e,t+1,n),2)}function fc(e,t,r,n){return new N(p.uint,Dt(e,t+1,n),3)}function lc(e,t,r,n){return new N(p.uint,Rt(e,t+1,n),5)}function dc(e,t,r,n){return new N(p.uint,Nt(e,t+1,n),9)}function Pt(e,t){return pt(e,0,t.value)}function pt(e,t,r){if(r<ft[0]){let n=Number(r);e.push([t|n])}else if(r<ft[1]){let n=Number(r);e.push([t|24,n])}else if(r<ft[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ft[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ft[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}Pt.encodedSize=function(t){return pt.encodedSize(t.value)};pt.encodedSize=function(t){return t<ft[0]?1:t<ft[1]?2:t<ft[2]?3:t<ft[3]?5:9};Pt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function hc(e,t,r,n){return new N(p.negint,-1-Ut(e,t+1,n),2)}function pc(e,t,r,n){return new N(p.negint,-1-Dt(e,t+1,n),3)}function mc(e,t,r,n){return new N(p.negint,-1-Rt(e,t+1,n),5)}var Mi=BigInt(-1),yc=BigInt(1);function gc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new N(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new N(p.negint,Mi-BigInt(o),9)}function Mn(e,t){let r=t.value,n=typeof r=="bigint"?r*Mi-yc:r*-1-1;pt(e,t.type.majorEncoded,n)}Mn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Mi-yc:r*-1-1;return n<ft[0]?1:n<ft[1]?2:n<ft[2]?3:n<ft[3]?5:9};Mn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function $r(e,t,r,n){fe(e,t,r+n);let o=lr(e,t+r,t+r+n);return new N(p.bytes,o,r+n)}function xc(e,t,r,n){return $r(e,t,1,r)}function wc(e,t,r,n){return $r(e,t,2,Ut(e,t+1,n))}function bc(e,t,r,n){return $r(e,t,3,Dt(e,t+1,n))}function Ec(e,t,r,n){return $r(e,t,5,Rt(e,t+1,n))}function Sc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return $r(e,t,9,o)}function Fn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===p.string?ic(e.value):e.value),e.encodedBytes}function dr(e,t){let r=Fn(t);pt(e,t.type.majorEncoded,r.length),e.push(r)}dr.encodedSize=function(t){let r=Fn(t);return pt.encodedSize(r.length)+r.length};dr.compareTokens=function(t,r){return Pd(Fn(t),Fn(r))};function Pd(e,t){return e.length<t.length?-1:e.length>t.length?1:cc(e,t)}function Gr(e,t,r,n,o){let i=r+n;fe(e,t,i);let s=new N(p.string,oc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=lr(e,t+r,t+i)),s}function Ac(e,t,r,n){return Gr(e,t,1,r,n)}function vc(e,t,r,n){return Gr(e,t,2,Ut(e,t+1,n),n)}function Cc(e,t,r,n){return Gr(e,t,3,Dt(e,t+1,n),n)}function Tc(e,t,r,n){return Gr(e,t,5,Rt(e,t+1,n),n)}function Bc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return Gr(e,t,9,o,n)}var Ic=dr;function hr(e,t,r,n){return new N(p.array,n,r)}function _c(e,t,r,n){return hr(e,t,1,r)}function Uc(e,t,r,n){return hr(e,t,2,Ut(e,t+1,n))}function Dc(e,t,r,n){return hr(e,t,3,Dt(e,t+1,n))}function Rc(e,t,r,n){return hr(e,t,5,Rt(e,t+1,n))}function Nc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return hr(e,t,9,o)}function Lc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return hr(e,t,1,1/0)}function Vn(e,t){pt(e,p.array.majorEncoded,t.value)}Vn.compareTokens=Pt.compareTokens;Vn.encodedSize=function(t){return pt.encodedSize(t.value)};function pr(e,t,r,n){return new N(p.map,n,r)}function Pc(e,t,r,n){return pr(e,t,1,r)}function kc(e,t,r,n){return pr(e,t,2,Ut(e,t+1,n))}function Kc(e,t,r,n){return pr(e,t,3,Dt(e,t+1,n))}function Oc(e,t,r,n){return pr(e,t,5,Rt(e,t+1,n))}function Mc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return pr(e,t,9,o)}function Fc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return pr(e,t,1,1/0)}function Hn(e,t){pt(e,p.map.majorEncoded,t.value)}Hn.compareTokens=Pt.compareTokens;Hn.encodedSize=function(t){return pt.encodedSize(t.value)};function Vc(e,t,r,n){return new N(p.tag,r,1)}function Hc(e,t,r,n){return new N(p.tag,Ut(e,t+1,n),2)}function qc(e,t,r,n){return new N(p.tag,Dt(e,t+1,n),3)}function zc(e,t,r,n){return new N(p.tag,Rt(e,t+1,n),5)}function $c(e,t,r,n){return new N(p.tag,Nt(e,t+1,n),9)}function qn(e,t){pt(e,p.tag.majorEncoded,t.value)}qn.compareTokens=Pt.compareTokens;qn.encodedSize=function(t){return pt.encodedSize(t.value)};var Vd=20,Hd=21,qd=22,zd=23;function Gc(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new N(p.null,null,1):new N(p.undefined,void 0,1)}function Zc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new N(p.break,void 0,1)}function Fi(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new N(p.float,e,t)}function jc(e,t,r,n){return Fi(Vi(e,t+1),3,n)}function Yc(e,t,r,n){return Fi(Hi(e,t+1),5,n)}function Wc(e,t,r,n){return Fi(tu(e,t+1),9,n)}function zn(e,t,r){let n=t.value;if(n===!1)e.push([p.float.majorEncoded|Vd]);else if(n===!0)e.push([p.float.majorEncoded|Hd]);else if(n===null)e.push([p.float.majorEncoded|qd]);else if(n===void 0)e.push([p.float.majorEncoded|zd]);else{let o,i=!1;(!r||r.float64!==!0)&&(Jc(n),o=Vi(zt,1),n===o||Number.isNaN(n)?(zt[0]=249,e.push(zt.slice(0,3)),i=!0):(Qc(n),o=Hi(zt,1),n===o&&(zt[0]=250,e.push(zt.slice(0,5)),i=!0))),i||($d(n),o=tu(zt,1),zt[0]=251,e.push(zt.slice(0,9)))}}zn.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Jc(n);let o=Vi(zt,1);if(n===o||Number.isNaN(n))return 3;if(Qc(n),o=Hi(zt,1),n===o)return 5}return 9};var Xc=new ArrayBuffer(9),kt=new DataView(Xc,1),zt=new Uint8Array(Xc,0);function Jc(e){if(e===1/0)kt.setUint16(0,31744,!1);else if(e===-1/0)kt.setUint16(0,64512,!1);else if(Number.isNaN(e))kt.setUint16(0,32256,!1);else{kt.setFloat32(0,e);let t=kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)kt.setUint16(0,31744,!1);else if(r===0)kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?kt.setUint16(0,0):o<-14?kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Vi(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Qc(e){kt.setFloat32(0,e,!1)}function Hi(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function $d(e){kt.setFloat64(0,e,!1)}function tu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}zn.compareTokens=Pt.compareTokens;function G(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function $n(e){return()=>{throw new Error(`${F} ${e}`)}}var I=[];for(let e=0;e<=23;e++)I[e]=G;I[24]=uc;I[25]=fc;I[26]=lc;I[27]=dc;I[28]=G;I[29]=G;I[30]=G;I[31]=G;for(let e=32;e<=55;e++)I[e]=G;I[56]=hc;I[57]=pc;I[58]=mc;I[59]=gc;I[60]=G;I[61]=G;I[62]=G;I[63]=G;for(let e=64;e<=87;e++)I[e]=xc;I[88]=wc;I[89]=bc;I[90]=Ec;I[91]=Sc;I[92]=G;I[93]=G;I[94]=G;I[95]=$n("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)I[e]=Ac;I[120]=vc;I[121]=Cc;I[122]=Tc;I[123]=Bc;I[124]=G;I[125]=G;I[126]=G;I[127]=$n("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)I[e]=_c;I[152]=Uc;I[153]=Dc;I[154]=Rc;I[155]=Nc;I[156]=G;I[157]=G;I[158]=G;I[159]=Lc;for(let e=160;e<=183;e++)I[e]=Pc;I[184]=kc;I[185]=Kc;I[186]=Oc;I[187]=Mc;I[188]=G;I[189]=G;I[190]=G;I[191]=Fc;for(let e=192;e<=215;e++)I[e]=Vc;I[216]=Hc;I[217]=qc;I[218]=zc;I[219]=$c;I[220]=G;I[221]=G;I[222]=G;I[223]=G;for(let e=224;e<=243;e++)I[e]=$n("simple values are not supported");I[244]=G;I[245]=G;I[246]=G;I[247]=Gc;I[248]=$n("simple values are not supported");I[249]=jc;I[250]=Yc;I[251]=Wc;I[252]=G;I[253]=G;I[254]=G;I[255]=Zc;var $t=[];for(let e=0;e<24;e++)$t[e]=new N(p.uint,e,1);for(let e=-1;e>=-24;e--)$t[31-e]=new N(p.negint,e,1);$t[64]=new N(p.bytes,new Uint8Array(0),1);$t[96]=new N(p.string,"",1);$t[128]=new N(p.array,0,1);$t[160]=new N(p.map,0,1);$t[244]=new N(p.false,!1,1);$t[245]=new N(p.true,!0,1);$t[246]=new N(p.null,null,1);function eu(e){switch(e.type){case p.false:return Wt([244]);case p.true:return Wt([245]);case p.null:return Wt([246]);case p.bytes:return e.value.length?void 0:Wt([64]);case p.string:return e.value===""?Wt([96]):void 0;case p.array:return e.value===0?Wt([128]):void 0;case p.map:return e.value===0?Wt([160]):void 0;case p.uint:return e.value<24?Wt([Number(e.value)]):void 0;case p.negint:if(e.value>=-24)return Wt([31-Number(e.value)])}}var Zd={float64:!1,mapSorter:Wd,quickEncodeToken:eu};function jd(){let e=[];return e[p.uint.major]=Pt,e[p.negint.major]=Mn,e[p.bytes.major]=dr,e[p.string.major]=Ic,e[p.array.major]=Vn,e[p.map.major]=Hn,e[p.tag.major]=qn,e[p.float.major]=zn,e}var ru=jd(),qi=new qr,Zn=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Oi} object contains circular references`);return new e(r,t)}},De={null:new N(p.null,null),undefined:new N(p.undefined,void 0),true:new N(p.true,!0),false:new N(p.false,!1),emptyArray:new N(p.array,0),emptyMap:new N(p.map,0)},Re={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new N(p.float,e):e>=0?new N(p.uint,e):new N(p.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new N(p.uint,e):new N(p.negint,e)},Uint8Array(e,t,r,n){return new N(p.bytes,e)},string(e,t,r,n){return new N(p.string,e)},boolean(e,t,r,n){return e?De.true:De.false},null(e,t,r,n){return De.null},undefined(e,t,r,n){return De.undefined},ArrayBuffer(e,t,r,n){return new N(p.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new N(p.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[De.emptyArray,new N(p.break)]:De.emptyArray;n=Zn.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Gn(s,r,n);return r.addBreakTokens?[new N(p.array,e.length),o,new N(p.break)]:[new N(p.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[De.emptyMap,new N(p.break)]:De.emptyMap;n=Zn.createCheck(n,e);let a=[],c=0;for(let f of i)a[c++]=[Gn(f,r,n),Gn(o?e.get(f):e[f],r,n)];return Yd(a,r),r.addBreakTokens?[new N(p.map,s),a,new N(p.break)]:[new N(p.map,s),a]}};Re.Map=Re.Object;Re.Buffer=Re.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Re[`${e}Array`]=Re.DataView;function Gn(e,t={},r){let n=tc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Re[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Re[n];if(!i)throw new Error(`${Oi} unsupported type: ${n}`);return i(e,n,t,r)}function Yd(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Wd(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=ru[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function nu(e,t,r,n){if(Array.isArray(t))for(let o of t)nu(e,o,r,n);else r[t.type.major](e,t,n)}function Xd(e,t,r){let n=Gn(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new qr(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ki(a.chunks[0])}}return qi.reset(),nu(qi,n,t,r),qi.toBytes(!0)}function zi(e,t){return t=Object.assign({},Zd,t),Xd(e,ru,t)}var Jd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},jn=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=$t[t];if(r===void 0){let n=I[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Zr=Symbol.for("DONE"),Yn=Symbol.for("BREAK");function Qd(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=mr(t,r);if(i===Yn){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===Zr)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function th(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=mr(t,r);if(a===Yn){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(a===Zr)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${F} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${F} found repeat map key "${a}"`);let c=mr(t,r);if(c===Zr)throw new Error(`${F} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function mr(e,t){if(e.done())return Zr;let r=e.next();if(r.type===p.break)return Yn;if(r.type.terminal)return r.value;if(r.type===p.array)return Qd(r,e,t);if(r.type===p.map)return th(r,e,t);if(r.type===p.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=mr(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function ou(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},Jd,t);let r=t.tokenizer||new jn(e,t),n=mr(r,t);if(n===Zr)throw new Error(`${F} did not find any content to decode`);if(n===Yn)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function $i(e,t){let[r,n]=ou(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var rh=me("ipns:utils"),iu=$("/ipns/"),nh=114,oh=0,ih=18;function jr(e){let t;if(e.pubKey!=null)try{t=Ya(e.pubKey)}catch(r){throw rh.error(r),r}if(t!=null)return t}function su(e,t,r){let n=$(t);return ge([e,r,n])}function Xn(e){let t=$("ipns-signature:");return ge([t,e])}function Jn(e){return"signatureV1"in e?ht.encode({value:$(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:$(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):ht.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Xt(e){let t=ht.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new qt("Missing data or signatureV2");let r=uu(t.data),n=sh(r.Value),o=j(r.Validity);if(t.value!=null&&t.signatureV1!=null)return ah(t),{value:n,validityType:ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Ze(e){return ge([iu,e.bytes])}function au(e){let t=Qt(e.slice(iu.length));if(!Wn(t,oh)&&!Wn(t,ih))throw new We("Multihash in IPNS key was not identity or sha2-256");return t}function cu(e,t,r,n,o){let i;if(t===ht.ValidityType.EOL)i=0;else throw new $e("The validity type is unsupported");return zi({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function uu(e){let t=$i(e);if(t.ValidityType===0)t.ValidityType=ht.ValidityType.EOL;else throw new $e("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function sh(e){let t=j(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${X.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(t).toV1().toString()}`}catch{}throw new Vr("Value must be a valid content path starting with /")}function fu(e){if(e!=null){let t=fh(e);if(t!=null)return t.code===nh?`/ipns/${t.toString(Ot)}`:`/ipfs/${t.toV1().toString()}`;if(ch(e))return`/ipns/${Ot.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new Vr("Value must be a valid content path starting with /")}function ah(e){if(e.data==null)throw new Kn("Record data is missing");let t=uu(e.data);if(!nt(t.Value,e.value??new Uint8Array(0)))throw new qt('Field "value" did not match between protobuf and CBOR');if(!nt(t.Validity,e.validity??new Uint8Array(0)))throw new qt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new qt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new qt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new qt('Field "ttl" did not match between protobuf and CBOR')}function ch(e){return e.bytes instanceof Uint8Array}function uh(e){return typeof e?.toCID=="function"}function fh(e){if(uh(e))return e.toCID();try{return X.parse(e)}catch{}return X.asCID(e)}function Wn(e,t){return e.code===t}var lh=me("ipns"),du=5*60*1e9,dh="/ipns/",sw=dh.length,hu={v1Compatible:!0,ttlNs:du};async function pu(e,t,r,n,o=hu){let i=new lu.default(Date.now()+Number(n)),s=ht.ValidityType.EOL,a=BigInt(o.ttlNs??du);return hh(e,t,r,s,i.toString(),a,o)}var hh=async(e,t,r,n,o,i,s=hu)=>{r=BigInt(r);let a=$(o),c=fu(t),f=$(c),u=cu(f,n,a,r,i),l=Xn(u),d=await e.sign(l),T;if(e.type==="RSA"&&(T=we(e.publicKey)),s.v1Compatible===!0){let v=await ph(e,f,n,a),y={value:c,signatureV1:v,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:d,data:u};return T!=null&&(y.pubKey=T),y}else{let v={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:d,data:u};return T!=null&&(v.pubKey=T),v}},ph=async(e,t,r,n)=>{try{let o=su(t,r,n);return await e.sign(o)}catch(o){throw lh.error("record signature creation failed",o),new Ln("Record signature creation failed")}};var Gi=Jr(Nn(),1);function Qn(e,t){let r=t.map((n,o)=>({record:Xt(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ht.ValidityType.EOL&&o.record.validityType===ht.ValidityType.EOL){let a=Gi.default.fromString(n.record.validity).toDate(),c=Gi.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var mu=Jr(Nn(),1);var to=me("ipns:validator"),mh=1024*10,yh=async(e,t)=>{let r=Xt(t),n;try{let o=Xn(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw to.error("record signature verification failed"),new qt("Record signature verification failed");if(r.validityType===ht.ValidityType.EOL){if(mu.default.fromString(r.validity).toDate().getTime()<Date.now())throw to.error("record has expired"),new Pn("record has expired")}else if(r.validityType!=null)throw to.error("the validity type is unsupported"),new $e("The validity type is unsupported");to("ipns record for %s is valid",r.value)};async function Yr(e,t){if(t.byteLength>mh)throw new kn("The record is too large");let r=au(e),n;Wn(r,0)&&(n=Bn(r));let o=Xt(t),i=jr(o)??n;if(i==null)throw new Hr("Could not extract public key from IPNS record or routing key");let s=Ze(i.toMultihash());if(!nt(s,e))throw new Hr("Embedded public key did not match routing key");await yh(i,t)}var gt=class extends Event{type;detail;constructor(t,r){super(t),this.type=t,this.detail=r}};var wh=Jr(gu(),1);var le;(function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"})(le||(le={}));var eo=class extends Error{static name="DNSLinkNotFoundError";constructor(t="DNSLink not found"){super(t),this.name="DNSLinkNotFoundError"}},ro=class extends Error{static name="RecordsFailedValidationError";constructor(t="Records failed validation"){super(t),this.name="RecordsFailedValidationError"}},no=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(t="Unsupported multibase prefix"){super(t),this.name="UnsupportedMultibasePrefixError"}},oo=class extends Error{static name="UnsupportedMultihashCodecError";constructor(t="Unsupported multihash codec"){super(t),this.name="UnsupportedMultihashCodecError"}},io=class extends Error{static name="InvalidValueError";constructor(t="Invalid value"){super(t),this.name="InvalidValueError"}};var bh=32;async function xu(e,t,r,n,o={}){if(t===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",e);let s=((await r.query(e,{...o,types:[le.TXT]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,e);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,d,...T]=u.split("/");if(l==="ipfs")try{return{value:`/ipfs/${X.parse(d)}${T.length>0?`/${T.join("/")}`:""}`,answer:f}}catch{}else if(l==="ipns"){try{let v;return d.charAt(0)==="1"||d.charAt(0)==="Q"?v=Dn(d):v=Pi(X.parse(d)),{value:`/ipns/${v}${T.length>0?`/${T.join("/")}`:""}`,answer:f}}catch{}return await so(d,t-1,r,n,o)}else{if(l==="dnslink")return await so(d,t-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,e);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",e,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",e);let c=((await r.query(e,{...o,types:[le.CNAME]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,e);for(let f of c)try{return await so(f.data,t-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",e,f.data,u)}throw new eo(`No DNSLink records found for domain: ${e}`)}async function so(e,t,r,n,o={}){if(t===0)throw new Error("recursion limit exceeded");e.startsWith("_dnslink.")||(e=`_dnslink.${e}`);try{return await xu(e,t,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return e.startsWith("_dnslink.")?e=e.replace("_dnslink.",""):e=`_dnslink.${e}`,xu(e,t,r,n,o)}}async function wu(e,t,r,n={}){return so(e,n.maxRecursiveDepth??bh,t,r,n)}var Zi=class{routing;constructor(t){this.routing=t}async put(t,r,n={}){try{await this.routing.put(t,r,n)}catch(o){n.onProgress?.(new gt("ipns:routing:helia:error",o))}}async get(t,r={}){try{return await this.routing.get(t,r)}catch(n){r.onProgress?.(new gt("ipns:routing:helia:error",n))}throw new Error("Not found")}};function bu(e){return new Zi(e)}var Wr;(function(e){let t;e.codec=()=>(t==null&&(t=_e((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Lt(0),value:Lt(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Ie(r,e.codec()),e.decode=(r,n)=>Be(r,e.codec(),n)})(Wr||(Wr={}));function Eu(e){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),n=String(e.getUTCDate()).padStart(2,"0"),o=String(e.getUTCHours()).padStart(2,"0"),i=String(e.getUTCMinutes()).padStart(2,"0"),s=String(e.getUTCSeconds()).padStart(2,"0"),a=e.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${t}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function Su(e){let t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var je=class e{key;value;timeReceived;constructor(t,r,n){if(!(t instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=t,this.value=r,this.timeReceived=n}serialize(){return Wr.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:Eu(this.timeReceived)}}static deserialize(t){let r=Wr.decode(t);return new e(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(t){let r=Su(t.timeReceived);if(t.key==null)throw new Error("key missing from deserialized object");if(t.value==null)throw new Error("value missing from deserialized object");return new e(t.key,t.value,r)}};var Au;(function(e){e[e.SEND_QUERY=0]="SEND_QUERY",e[e.PEER_RESPONSE=1]="PEER_RESPONSE",e[e.FINAL_PEER=2]="FINAL_PEER",e[e.QUERY_ERROR=3]="QUERY_ERROR",e[e.PROVIDER=4]="PROVIDER",e[e.VALUE=5]="VALUE",e[e.ADD_PEER=6]="ADD_PEER",e[e.DIAL_PEER=7]="DIAL_PEER"})(Au||(Au={}));function ao(e){return new Fr("/dht/record/"+j(e,"base32"),!1)}function vu(e){return{async put(t,r,n={}){try{let o=ao(t);try{let s=await e.get(o),a=je.deserialize(s);if(nt(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new je(t,r,new Date);n.onProgress?.(new gt("ipns:routing:datastore:put")),await e.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new gt("ipns:routing:datastore:error",o)),o}},async get(t,r={}){try{let n=ao(t);r.onProgress?.(new gt("ipns:routing:datastore:get"));let o=await e.get(n,r),i=je.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new gt("ipns:routing:datastore:error",n)),n}},async has(t,r={}){let n=ao(t);return e.has(n,r)},async delete(t,r){let n=ao(t);return e.delete(n,r)}}}var ji="/ipns/";function Yi(e,t){return e.code===t}var de=me("helia:ipns"),Bu=60*1e3,Iu=60*Bu,vh=48*Iu,Wi=23*Iu,Cu=BigInt(Bu)*5000000n,Tu={[Ot.prefix]:Ot,[W.prefix]:W},Xi=class{routers;localStore;timeout;dns;log;constructor(t,r=[]){this.routers=[bu(t.routing),...r],this.localStore=vu(t.datastore),this.dns=t.dns,this.log=t.logger.forComponent("helia:ipns")}async publish(t,r,n={}){try{let o=1n,i=Ze(t.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:f}=await this.localStore.get(i,n);o=Xt(f).sequence+1n}let s=n.ttl!=null?BigInt(n.ttl)*1000000n:Cu,a=await pu(t,r,o,n.lifetime??vh,{...n,ttlNs:s}),c=Jn(a);return await this.localStore.put(i,c,n),n.offline!==!0&&await Promise.all(this.routers.map(async f=>{await f.put(i,c,n)})),a}catch(o){throw n.onProgress?.(new gt("ipns:publish:error",o)),o}}async resolve(t,r={}){let n=es(t)?t.toMultihash():t,o=Ze(n),i=await this.#e(o,r);return{...await this.#t(i.value,r),record:i}}async resolveDNSLink(t,r={}){let n=await wu(t,this.dns,this.log,r);return{...await this.#t(n.value,r),answer:n.answer}}republish(t={}){if(this.timeout!=null)throw new Error("Republish is already running");t.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();t.onProgress?.(new gt("ipns:republish:start"));let i=Date.now()-n,s=Wi-i;s<0&&(s=t.interval??Wi),setTimeout(()=>{r().catch(a=>{de.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{de.error("error republishing",n)})},t.interval??Wi)}async#t(t,r={}){let n=t.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=W.decode(`z${i}`);else if(Tu[s]!=null)a=Tu[s].decode(i);else throw new no(`Unsupported multibase prefix "${s}"`);let c;try{c=Qt(a)}catch{c=X.decode(a).multihash}if(!Yi(c,0)&&!Yi(c,18))throw new oo(`Unsupported multihash codec "${c.code}"`);let{cid:f}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:f,path:u}}else if(o==="ipfs"){let i=X.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){de.error("error parsing ipfs path",o)}throw de.error("invalid ipfs path %s",t),new io("Invalid value")}async#e(t,r={}){let n=[];if(await this.localStore.has(t,r))if(de("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(t,r);this.log("record retrieved from cache"),await Yr(t,a),this.log("record was valid");let f=Xt(a),u=Number((f.ttl??Cu)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),f;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),f;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(t,r)}else de("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new gr("Record was not present in the cache or has expired");de("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(t,{...r,validate:!1})}catch(f){de.error("error finding IPNS record",f);return}try{await Yr(t,c),n.push(c)}catch(f){i++,de.error("error finding IPNS record",f)}})),n.length===0)throw i>0?new ro(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new gr("Could not find record for routing key");let s=n[Qn(t,n)];return await this.localStore.put(t,s,r),Xt(s)}async republishRecord(t,r,n={}){let o;try{if(o=jr(r)?.toMultihash(),o==null)if(typeof t=="string"){t.startsWith(ji)&&(t=t.slice(ji.length));try{o=Dn(t).toMultihash()}catch(a){throw new Error(`Invalid string key: ${a.message}`)}}else o=t;if(o==null)throw new Error("No public key multihash found to determine the routing key");let i=Ze(o),s=Jn(r);await Yr(i,s),await this.localStore.put(i,s,n),n.offline!==!0&&await Promise.all(this.routers.map(async a=>{await a.put(i,s,n)}))}catch(i){throw n.onProgress?.(new gt("ipns:republish:error",{key:o,record:r,err:i})),i}}};function Ch(e,{routers:t=[]}={}){return new Xi(e,t)}return Ou(Th);})();
|
|
3
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(x,w,K){var L=this;if(!(L instanceof y))return new y(x,w,K);L.time=+x||0,L.nano=+w||0,L.year=+K||0,h(L)}function h(x){var w,K,L,_=x.year,V=x.time,S=x.nano,A=((S<0||a<=S)&&(S-=(K=Math.floor(S/a))*a,V+=K,K=1),_%t);return(V<-i||i<V||A)&&((w=f(V/o))&&(_+=w*t,V-=w*o),(L=E(V)).setUTCFullYear(A+L.getUTCFullYear()),L=(V=+L)+(w=f((_-=A)/t))*o,w&&-i<=L&&L<=i&&(_-=w*t,V=L),K=1),K&&(x.year=_,x.time=V,x.nano=S),x}function E(x){var w=new Date(0);return w.setTime(x),w}function U(_,L){_=+_||0;var K=f((L=(L|0)*s)/n)+f(_/n),L=L%n+_%n,_=f(L/n);return _&&(K+=_,L-=_*n),new y(1e3*L,0,K*t)}function g(x,w,K,L,_,V){return function(A,B){var m=h(this);A=A||new Array(8),O(A,B|=0);var C=Math.floor(m.time/1e3),m=m.year*(r*e/t),b=f(m/s)+f(C/s),m=m%s+C%s,C=Math.floor(m/s);return C&&(b+=C,m-=C*s),S(A,B+_,b),S(A,B+V,m),A};function S(A,B,b){A[B+x]=b>>24&255,A[B+w]=b>>16&255,A[B+K]=b>>8&255,A[B+L]=255&b}}function D(x,w,K,L,_,V){return function(A,B){O(A,B|=0);var b=S(A,B+_);return U(S(A,B+V),b)};function S(A,B){return 16777216*A[B+x]+(A[B+w]<<16|A[B+K]<<8|A[B+L])}}function O(x,w){if(x=x&&x.length,x==null)throw new TypeError("Invalid Buffer");if(x<w+8)throw new RangeError("Out of range")}function k(x){return(9<x?"":"0")+(0|x)}function R(x,w){return(c+(0|x)).substr(-w)}}()});var gu=Qi((kw,yu)=>{yu.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,t++,t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Th={};St(Th,{ipns:()=>Ch,ipnsSelector:()=>Qn,ipnsValidator:()=>Yr});function es(e){return e==null?!1:(e.type==="RSA"||e.type==="Ed25519"||e.type==="secp256k1"||e.type==="ECDSA")&&e.raw instanceof Uint8Array&&typeof e.equals=="function"&&typeof e.toMultihash=="function"&&typeof e.toCID=="function"&&typeof e.verify=="function"}var co=Symbol.for("@libp2p/peer-id");var st=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ye=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var gr=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Qr=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},We=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Xe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var po={};St(po,{base32:()=>pe,base32hex:()=>Zu,base32hexpad:()=>Yu,base32hexpadupper:()=>Wu,base32hexupper:()=>ju,base32pad:()=>$u,base32padupper:()=>Gu,base32upper:()=>zu,base32z:()=>Xu});var Dh=new Uint8Array(0);function rs(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Jt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ns(e){return new TextEncoder().encode(e)}function os(e){return new TextDecoder().decode(e)}function Mu(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(v){if(v instanceof Uint8Array||(ArrayBuffer.isView(v)?v=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):Array.isArray(v)&&(v=Uint8Array.from(v))),!(v instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(v.length===0)return"";for(var y=0,h=0,E=0,U=v.length;E!==U&&v[E]===0;)E++,y++;for(var g=(U-E)*u+1>>>0,D=new Uint8Array(g);E!==U;){for(var O=v[E],k=0,R=g-1;(O!==0||k<h)&&R!==-1;R--,k++)O+=256*D[R]>>>0,D[R]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");h=k,E++}for(var x=g-h;x!==g&&D[x]===0;)x++;for(var w=c.repeat(y);x<g;++x)w+=e.charAt(D[x]);return w}function d(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return new Uint8Array;var y=0;if(v[y]!==" "){for(var h=0,E=0;v[y]===c;)h++,y++;for(var U=(v.length-y)*f+1>>>0,g=new Uint8Array(U);v[y];){var D=r[v.charCodeAt(y)];if(D===255)return;for(var O=0,k=U-1;(D!==0||O<E)&&k!==-1;k--,O++)D+=a*g[k]>>>0,g[k]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");E=O,y++}if(v[y]!==" "){for(var R=U-E;R!==U&&g[R]===0;)R++;for(var x=new Uint8Array(h+(U-R)),w=h;R!==U;)x[w++]=g[R++];return x}}}function T(v){var y=d(v);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:T}}var Fu=Mu,Vu=Fu,ss=Vu;var uo=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},fo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return as(this,t)}},lo=class{decoders;constructor(t){this.decoders=t}or(t){return as(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function as(e,t){return new lo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ho=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new uo(t,r,n),this.decoder=new fo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Je({name:e,prefix:t,encode:r,decode:n}){return new ho(e,t,r,n)}function he({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ss(r,e);return Je({prefix:t,name:e,encode:n,decode:i=>Jt(o(i))})}function Hu(e,t,r,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;e[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[e[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function qu(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function et({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Je({prefix:t,name:e,encode(o){return qu(o,n,r)},decode(o){return Hu(o,n,r,e)}})}var pe=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zu=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$u=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gu=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Zu=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ju=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yu=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wu=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xu=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mo={};St(mo,{base58btc:()=>W,base58flickr:()=>Ju});var W=he({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ju=he({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var go={};St(go,{base64:()=>yo,base64pad:()=>Qu,base64url:()=>tf,base64urlpad:()=>ef});var yo=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qu=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tf=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ef=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function rf(e,t){try{if(typeof e=="string"&&e.length>0)return nf(e);if(typeof e=="number"&&isFinite(e))return t?.long?sf(e):of(e);throw new Error("Value is not a string or number.")}catch(r){let n=af(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function nf(e){if(e=String(e),e.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var en=rf;function of(e){let t=Math.abs(e);return t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function sf(e){let t=Math.abs(e);return t>=864e5?tn(e,t,864e5,"day"):t>=36e5?tn(e,t,36e5,"hour"):t>=6e4?tn(e,t,6e4,"minute"):t>=1e3?tn(e,t,1e3,"second"):`${e} ms`}function tn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function af(e){return typeof e=="object"&&e!==null&&"message"in e}function xo(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=en,r.destroy=f,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let l=0;for(let d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u){let l,d=null,T,v;function y(...h){if(!y.enabled)return;let E=y,U=Number(new Date),g=U-(l||U);E.diff=g,E.prev=l,E.curr=U,l=U,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let D=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(k,R)=>{if(k==="%%")return"%";D++;let x=r.formatters[R];if(typeof x=="function"){let w=h[D];k=x.call(E,w),h.splice(D,1),D--}return k}),r.formatArgs.call(E,h),(E.log||r.log).apply(E,h)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(T!==r.namespaces&&(T=r.namespaces,v=r.enabled(u)),v),set:h=>{d=h}}),typeof r.init=="function"&&r.init(y),y}function n(u,l){let d=r(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),T=d.length;for(l=0;l<T;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(u))return!1;for(l=0,d=r.names.length;l<d;l++)if(r.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var rn=pf(),cf=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function uf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function ff(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+en(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var lf=console.debug??console.log??(()=>{});function df(e){try{e?rn?.setItem("debug",e):rn?.removeItem("debug")}catch{}}function hf(){let e;try{e=rn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function pf(){try{return localStorage}catch{}}function mf(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var cs=xo({formatArgs:ff,save:df,load:hf,useColors:uf,setupFormatters:mf,colors:cf,storage:rn,log:lf});var At=cs;At.formatters.b=e=>e==null?"undefined":W.baseEncode(e);At.formatters.t=e=>e==null?"undefined":pe.baseEncode(e);At.formatters.m=e=>e==null?"undefined":yo.baseEncode(e);At.formatters.p=e=>e==null?"undefined":e.toString();At.formatters.c=e=>e==null?"undefined":e.toString();At.formatters.k=e=>e==null?"undefined":e.toString();At.formatters.a=e=>e==null?"undefined":e.toString();At.formatters.e=e=>e==null?"undefined":us(e.stack)??us(e.message)??e.toString();function yf(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function me(e){let t=yf(`${e}:trace`);return At.enabled(`${e}:trace`)&&At.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=At(`${e}:trace`)),Object.assign(At(e),{error:At(`${e}:error`),trace:t})}function us(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var wo={};St(wo,{base36:()=>Ot,base36upper:()=>gf});var Ot=he({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gf=he({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xf=ds,fs=128,wf=127,bf=~wf,Ef=Math.pow(2,31);function ds(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Ef;)t[r++]=e&255|fs,e/=128;for(;e&bf;)t[r++]=e&255|fs,e>>>=7;return t[r]=e|0,ds.bytes=r-n+1,t}var Sf=bo,Af=128,ls=127;function bo(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw bo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&ls)<<o:(s&ls)*Math.pow(2,o),o+=7}while(s>=Af);return bo.bytes=i-n,r}var vf=Math.pow(2,7),Cf=Math.pow(2,14),Tf=Math.pow(2,21),Bf=Math.pow(2,28),If=Math.pow(2,35),_f=Math.pow(2,42),Uf=Math.pow(2,49),Df=Math.pow(2,56),Rf=Math.pow(2,63),Nf=function(e){return e<vf?1:e<Cf?2:e<Tf?3:e<Bf?4:e<If?5:e<_f?6:e<Uf?7:e<Df?8:e<Rf?9:10},Lf={encode:xf,decode:Sf,encodingLength:Nf},Pf=Lf,xr=Pf;function wr(e,t=0){return[xr.decode(e,t),xr.decode.bytes]}function Qe(e,t,r=0){return xr.encode(e,t,r),t}function tr(e){return xr.encodingLength(e)}function Mt(e,t){let r=t.byteLength,n=tr(e),o=n+tr(r),i=new Uint8Array(o+r);return Qe(e,i,0),Qe(r,i,n),i.set(t,o),new er(e,r,t,i)}function Qt(e){let t=Jt(e),[r,n]=wr(t),[o,i]=wr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new er(r,o,s,t)}function hs(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&rs(e.bytes,r.bytes)}}var er=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function ps(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Kf(r,Eo(e),t??W.encoder);default:return Of(r,Eo(e),t??pe.encoder)}}var ms=new WeakMap;function Eo(e){let t=ms.get(e);if(t==null){let r=new Map;return ms.set(e,r),r}return t}var X=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Mt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&hs(t.multihash,n.multihash)}toString(t){return ps(this,t)}toJSON(){return{"/":ps(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??ys(n,o,i.bytes))}else if(r[Ff]===!0){let{version:n,multihash:o,code:i}=r,s=Qt(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==br)throw new Error(`Version 0 CID must use dag-pb (code: ${br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ys(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Jt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new er(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,d]=wr(t.subarray(r));return r+=d,l},o=n(),i=br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=kf(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Eo(i).set(n,t),i}};function kf(e,t){switch(e[0]){case"Q":{let r=t??W;return[W.prefix,r.decode(`${W.prefix}${e}`)]}case W.prefix:{let r=t??W;return[W.prefix,r.decode(e)]}case pe.prefix:{let r=t??pe;return[pe.prefix,r.decode(e)]}case Ot.prefix:{let r=t??Ot;return[Ot.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Kf(e,t,r){let{prefix:n}=r;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Of(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var br=112,Mf=18;function ys(e,t,r){let n=tr(e),o=n+tr(t),i=new Uint8Array(o+r.byteLength);return Qe(e,i,0),Qe(t,i,n),i.set(r,o),i}var Ff=Symbol.for("@ipld/js-cid/CID");var So={};St(So,{identity:()=>Ft});var gs=0,Vf="identity",xs=Jt;function Hf(e){return Mt(gs,xs(e))}var Ft={code:gs,name:Vf,encode:xs,digest:Hf};function nt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Lt(e=0){return new Uint8Array(e)}function Tt(e=0){return new Uint8Array(e)}function ge(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Tt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var bs=Symbol.for("@achingbrain/uint8arraylist");function ws(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function on(e){return!!e?.[bs]}var Bt=class e{bufs;length;[bs]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(on(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(on(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ws(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ws(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(on(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return ge(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:ge(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(f){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!on(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let d=f;d>=0;d--){let T=this.get(l+d);if(n[d]!==T){u=Math.max(1,d-a[T]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=Tt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Tt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Lt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Lt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Lt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!nt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Ao={};St(Ao,{base10:()=>qf});var qf=he({prefix:"9",name:"base10",alphabet:"0123456789"});var vo={};St(vo,{base16:()=>zf,base16upper:()=>$f});var zf=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$f=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Co={};St(Co,{base2:()=>Gf});var Gf=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var To={};St(To,{base256emoji:()=>Xf});var Es=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}"),Zf=Es.reduce((e,t,r)=>(e[r]=t,e),[]),jf=Es.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Yf(e){return e.reduce((t,r)=>(t+=Zf[r],t),"")}function Wf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=jf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Xf=Je({prefix:"\u{1F680}",name:"base256emoji",encode:Yf,decode:Wf});var Bo={};St(Bo,{base8:()=>Jf});var Jf=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Io={};St(Io,{identity:()=>Qf});var Qf=Je({prefix:"\0",name:"identity",encode:e=>os(e),decode:e=>ns(e)});var B0=new TextEncoder,I0=new TextDecoder;var Do={};St(Do,{sha256:()=>Er,sha512:()=>rl});function Uo({name:e,code:t,encode:r}){return new _o(e,t,r)}var _o=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Mt(this.code,r):r.then(n=>Mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function As(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Er=Uo({name:"sha2-256",code:18,encode:As("SHA-256")}),rl=Uo({name:"sha2-512",code:19,encode:As("SHA-512")});var Ro={...Io,...Co,...Bo,...Ao,...vo,...po,...wo,...mo,...go,...To},F0={...Do,...So};function Cs(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var vs=Cs("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),No=Cs("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Tt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),nl={utf8:vs,"utf-8":vs,hex:Ro.base16,latin1:No,ascii:No,binary:No,...Ro},sn=nl;function $(e,t="utf8"){let r=sn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function j(e,t="utf8"){let r=sn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var ol=parseInt("11111",2),Lo=parseInt("10000000",2),il=parseInt("01111111",2),Ts={0:Sr,1:Sr,2:sl,3:ul,4:fl,5:cl,6:al,16:Sr,22:Sr,48:Sr};function te(e,t={offset:0}){let r=e[t.offset]&ol;if(t.offset++,Ts[r]!=null)return Ts[r](e,t);throw new Error("No decoder for tag "+r)}function Ar(e,t){let r=0;if((e[t.offset]&Lo)===Lo){let n=e[t.offset]&il,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Sr(e,t){Ar(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=te(e,t);if(n===null)break;r.push(n)}return r}function sl(e,t){let r=Ar(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function al(e,t){let r=Ar(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let l=0;l<c.length;l++)u+=c[l]<<l*7;a+=`.${u}`,c=[]}}return a}function cl(e,t){return t.offset++,null}function ul(e,t){let r=Ar(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function fl(e,t){let r=Ar(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function ll(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Bt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Po(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=ll(e.byteLength);return new Bt(Uint8Array.from([t.byteLength|Lo]),t)}function vt(e){let t=new Bt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Bt(Uint8Array.from([2]),Po(t),t)}function an(e){let t=Uint8Array.from([0]),r=new Bt(t,e);return new Bt(Uint8Array.from([3]),Po(r),r)}function xe(e,t=48){let r=new Bt;for(let n of e)r.append(n);return new Bt(Uint8Array.from([t]),Po(r),r)}async function Bs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,r.subarray())}var dl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),hl=Uint8Array.from([6,5,43,129,4,0,34]),pl=Uint8Array.from([6,5,43,129,4,0,35]),ml={ext:!0,kty:"EC",crv:"P-256"},yl={ext:!0,kty:"EC",crv:"P-384"},gl={ext:!0,kty:"EC",crv:"P-521"},ko=32,Ko=48,Oo=66;function Mo(e){let t=te(e);return Is(t)}function Is(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===ko*2+1)return n=j(t.subarray(r,r+ko),"base64url"),o=j(t.subarray(r+ko),"base64url"),new rr({...ml,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ko*2+1)return n=j(t.subarray(r,r+Ko),"base64url"),o=j(t.subarray(r+Ko),"base64url"),new rr({...yl,key_ops:["verify"],x:n,y:o});if(t.byteLength===Oo*2+1)return n=j(t.subarray(r,r+Oo),"base64url"),o=j(t.subarray(r+Oo),"base64url"),new rr({...gl,key_ops:["verify"],x:n,y:o});throw new st(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function _s(e){return xe([vt(Uint8Array.from([1])),xe([xl(e.crv)],160),xe([an(new Bt(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function xl(e){if(e==="P-256")return dl;if(e==="P-384")return hl;if(e==="P-521")return pl;throw new st(`Invalid curve ${e}`)}var rr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=_s(this.jwk)),this._raw}toMultihash(){return Ft.digest(we(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}async verify(t,r){return Bs(this.jwk,r,t)}};var Ne=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function cn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Le(e,...t){if(!wl(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Us(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");cn(e.outputLen),cn(e.blockLen)}function or(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ds(e,t){Le(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ee(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function un(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vt(e,t){return e<<32-t|e>>>t}function Rs(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function vr(e){return typeof e=="string"&&(e=Rs(e)),Le(e),e}function Fo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Le(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var nr=class{};function Vo(e){let t=n=>e().update(vr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function fn(e=32){if(Ne&&typeof Ne.getRandomValues=="function")return Ne.getRandomValues(new Uint8Array(e));if(Ne&&typeof Ne.randomBytes=="function")return Uint8Array.from(Ne.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function bl(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+f,a,n)}function Ns(e,t,r){return e&t^~e&r}function Ls(e,t,r){return e&t^e&r^t&r}var Cr=class extends nr{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=un(this.buffer)}update(t){or(this),t=vr(t),Le(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=un(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){or(this),Ds(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ee(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;bl(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=un(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},re=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var dt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ln=BigInt(4294967295),Ps=BigInt(32);function El(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>Ps&ln)}:{h:Number(e>>Ps&ln)|0,l:Number(e&ln)|0}}function ks(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=El(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var Ho=(e,t,r)=>e>>>r,qo=(e,t,r)=>e<<32-r|t>>>r,Pe=(e,t,r)=>e>>>r|t<<32-r,ke=(e,t,r)=>e<<32-r|t>>>r,Tr=(e,t,r)=>e<<64-r|t>>>r-32,Br=(e,t,r)=>e>>>r-32|t<<64-r;function Gt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ks=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Os=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ms=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Fs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Vs=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Hs=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Al=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]),be=new Uint32Array(64),dn=class extends Cr{constructor(t=32){super(64,t,8,!1),this.A=re[0]|0,this.B=re[1]|0,this.C=re[2]|0,this.D=re[3]|0,this.E=re[4]|0,this.F=re[5]|0,this.G=re[6]|0,this.H=re[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let l=0;l<16;l++,r+=4)be[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let d=be[l-15],T=be[l-2],v=Vt(d,7)^Vt(d,18)^d>>>3,y=Vt(T,17)^Vt(T,19)^T>>>10;be[l]=y+be[l-7]+v+be[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Vt(a,6)^Vt(a,11)^Vt(a,25),T=u+d+Ns(a,c,f)+Al[l]+be[l]|0,y=(Vt(n,2)^Vt(n,13)^Vt(n,22))+Ls(n,o,i)|0;u=f,f=c,c=a,a=s+T|0,s=i,i=o,o=n,n=T+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){ee(be)}destroy(){this.set(0,0,0,0,0,0,0,0),ee(this.buffer)}};var qs=ks(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),vl=qs[0],Cl=qs[1],Ee=new Uint32Array(80),Se=new Uint32Array(80),zo=class extends Cr{constructor(t=64){super(128,t,16,!1),this.Ah=dt[0]|0,this.Al=dt[1]|0,this.Bh=dt[2]|0,this.Bl=dt[3]|0,this.Ch=dt[4]|0,this.Cl=dt[5]|0,this.Dh=dt[6]|0,this.Dl=dt[7]|0,this.Eh=dt[8]|0,this.El=dt[9]|0,this.Fh=dt[10]|0,this.Fl=dt[11]|0,this.Gh=dt[12]|0,this.Gl=dt[13]|0,this.Hh=dt[14]|0,this.Hl=dt[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:T,Gl:v,Hh:y,Hl:h}=this;return[t,r,n,o,i,s,a,c,f,u,l,d,T,v,y,h]}set(t,r,n,o,i,s,a,c,f,u,l,d,T,v,y,h){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=T|0,this.Gl=v|0,this.Hh=y|0,this.Hl=h|0}process(t,r){for(let g=0;g<16;g++,r+=4)Ee[g]=t.getUint32(r),Se[g]=t.getUint32(r+=4);for(let g=16;g<80;g++){let D=Ee[g-15]|0,O=Se[g-15]|0,k=Pe(D,O,1)^Pe(D,O,8)^Ho(D,O,7),R=ke(D,O,1)^ke(D,O,8)^qo(D,O,7),x=Ee[g-2]|0,w=Se[g-2]|0,K=Pe(x,w,19)^Tr(x,w,61)^Ho(x,w,6),L=ke(x,w,19)^Br(x,w,61)^qo(x,w,6),_=Ms(R,L,Se[g-7],Se[g-16]),V=Fs(_,k,K,Ee[g-7],Ee[g-16]);Ee[g]=V|0,Se[g]=_|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:T,Fl:v,Gh:y,Gl:h,Hh:E,Hl:U}=this;for(let g=0;g<80;g++){let D=Pe(l,d,14)^Pe(l,d,18)^Tr(l,d,41),O=ke(l,d,14)^ke(l,d,18)^Br(l,d,41),k=l&T^~l&y,R=d&v^~d&h,x=Vs(U,O,R,Cl[g],Se[g]),w=Hs(x,E,D,k,vl[g],Ee[g]),K=x|0,L=Pe(n,o,28)^Tr(n,o,34)^Tr(n,o,39),_=ke(n,o,28)^Br(n,o,34)^Br(n,o,39),V=n&i^n&a^i&a,S=o&s^o&c^s&c;E=y|0,U=h|0,y=T|0,h=v|0,T=l|0,v=d|0,{h:l,l:d}=Gt(f|0,u|0,w|0,K|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=Ks(K,_,S);n=Os(A,w,L,V),o=A|0}({h:n,l:o}=Gt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Gt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Gt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Gt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=Gt(this.Eh|0,this.El|0,l|0,d|0),{h:T,l:v}=Gt(this.Fh|0,this.Fl|0,T|0,v|0),{h:y,l:h}=Gt(this.Gh|0,this.Gl|0,y|0,h|0),{h:E,l:U}=Gt(this.Hh|0,this.Hl|0,E|0,U|0),this.set(n,o,i,s,a,c,f,u,l,d,T,v,y,h,E,U)}roundClean(){ee(Ee,Se)}destroy(){ee(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var hn=Vo(()=>new dn);var zs=Vo(()=>new zo);var jo=BigInt(0),Zo=BigInt(1);function Ke(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yo(e){if(!Ke(e))throw new Error("Uint8Array expected")}function Zt(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Ir(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Zs(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?jo:BigInt("0x"+e)}var js=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Tl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ae(e){if(Yo(e),js)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Tl[e[r]];return t}var ne={_0:48,_9:57,A:65,F:70,a:97,f:102};function $s(e){if(e>=ne._0&&e<=ne._9)return e-ne._0;if(e>=ne.A&&e<=ne.F)return e-(ne.A-10);if(e>=ne.a&&e<=ne.f)return e-(ne.a-10)}function _r(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(js)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=$s(e.charCodeAt(i)),a=$s(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function oe(e){return Zs(Ae(e))}function Oe(e){return Yo(e),Zs(Ae(Uint8Array.from(e).reverse()))}function Me(e,t){return _r(e.toString(16).padStart(t*2,"0"))}function ir(e,t){return Me(e,t).reverse()}function tt(e,t,r){let n;if(typeof t=="string")try{n=_r(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Ke(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function ve(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Yo(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var $o=e=>typeof e=="bigint"&&jo<=e;function pn(e,t,r){return $o(e)&&$o(t)&&$o(r)&&t<=e&&e<r}function It(e,t,r,n){if(!pn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ys(e){let t;for(t=0;e>jo;e>>=Zo,t+=1);return t}var Fe=e=>(Zo<<BigInt(e))-Zo,Go=e=>new Uint8Array(e),Gs=e=>Uint8Array.from(e);function Ws(e,t,r){if(typeof e!="number"||e<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 r!="function")throw new Error("hmacFn must be a function");let n=Go(e),o=Go(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>r(o,n,...l),c=(l=Go(0))=>{o=a(Gs([0]),l),n=a(),l.length!==0&&(o=a(Gs([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<t;){n=a();let T=n.slice();d.push(T),l+=n.length}return ve(...d)};return(l,d)=>{s(),c(l);let T;for(;!(T=d(f()));)c();return s(),T}}var Bl={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Ke(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function ie(e,t,r={}){let n=(o,i,s)=>{let a=Bl[i];if(typeof a!="function")throw new Error("invalid validator function");let c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}function sr(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var xt=BigInt(0),at=BigInt(1),Ve=BigInt(2),Il=BigInt(3),Wo=BigInt(4),Xs=BigInt(5),Js=BigInt(8),_l=BigInt(9),Ul=BigInt(16);function J(e,t){let r=e%t;return r>=xt?r:t+r}function Q(e,t,r){let n=e;for(;t-- >xt;)n*=n,n%=r;return n}function mn(e,t){if(e===xt)throw new Error("invert: expected non-zero number");if(t<=xt)throw new Error("invert: expected positive modulus, got "+t);let r=J(e,t),n=t,o=xt,i=at,s=at,a=xt;for(;r!==xt;){let f=n/r,u=n%r,l=o-s*f,d=i-a*f;n=r,r=u,o=s,i=a,s=l,a=d}if(n!==at)throw new Error("invert: does not exist");return J(o,t)}function Dl(e){let t=e-at,r=0;for(;t%Ve===xt;)t/=Ve,r++;let n=Ve,o=se(e);for(;n<e&&Qs(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1){let s=(e+at)/Wo;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+at)/Ve;return function(a,c){if(!Qs(a,c))throw new Error("Cannot find square root");let f=r,u=a.pow(a.mul(a.ONE,n),t),l=a.pow(c,i),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let T=1;for(let y=a.sqr(d);T<f&&!a.eql(y,a.ONE);T++)y=a.sqr(y);let v=a.pow(u,at<<BigInt(f-T-1));u=a.sqr(v),l=a.mul(l,v),d=a.mul(d,u),f=T}return l}}function Rl(e){return e%Wo===Il?function(r,n){let o=(e+at)/Wo,i=r.pow(n,o);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}:e%Js===Xs?function(r,n){let o=r.mul(n,Ve),i=(e-Xs)/Js,s=r.pow(o,i),a=r.mul(n,s),c=r.mul(r.mul(a,Ve),s),f=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(f),n))throw new Error("Cannot find square root");return f}:(e%Ul,Dl(e))}var ta=(e,t)=>(J(e,t)&at)===at,Nl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xo(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Nl.reduce((n,o)=>(n[o]="function",n),t);return ie(e,r)}function Ll(e,t,r){if(r<xt)throw new Error("invalid exponent, negatives unsupported");if(r===xt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>xt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function ar(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Pl(e,t){let r=(e.ORDER-at)/Ve,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("Cannot find square root: probably non-prime P");return o?1:i?0:-1}function Qs(e,t){let r=Pl(e,t);return r===0||r===1}function Jo(e,t){t!==void 0&&cn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function se(e,t,r=!1,n={}){if(e<=xt)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=Jo(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:Fe(o),ZERO:xt,ONE:at,create:c=>J(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return xt<=c&&c<e},is0:c=>c===xt,isOdd:c=>(c&at)===at,neg:c=>J(-c,e),eql:(c,f)=>c===f,sqr:c=>J(c*c,e),add:(c,f)=>J(c+f,e),sub:(c,f)=>J(c-f,e),mul:(c,f)=>J(c*f,e),pow:(c,f)=>Ll(a,c,f),div:(c,f)=>J(c*mn(f,e),e),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>mn(c,e),sqrt:n.sqrt||(c=>(s||(s=Rl(e)),s(a,c))),toBytes:c=>r?ir(c,i):Me(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Oe(c):oe(c)},invertBatch:c=>ar(a,c),cmov:(c,f,u)=>u?f:c});return Object.freeze(a)}function ea(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Qo(e){let t=ea(e);return t+Math.ceil(t/2)}function ra(e,t,r=!1){let n=e.length,o=ea(t),i=Qo(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Oe(e):oe(e),a=J(s,t-at)+at;return r?ir(a,o):Me(a,o)}var na=BigInt(0),oi=BigInt(1);function ti(e,t){let r=t.negate();return e?r:t}function ia(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ei(e,t){ia(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Fe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function oa(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=oi);let f=t*n,u=f+Math.abs(a)-1,l=a===0,d=a<0,T=t%2!==0;return{nextN:c,offset:u,isZero:l,isNeg:d,isNegF:T,offsetF:f}}function kl(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Kl(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var ri=new WeakMap,sa=new WeakMap;function ni(e){return sa.get(e)||1}function yn(e,t){return{constTimeNegate:ti,hasPrecomputes(r){return ni(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>na;)n&oi&&(o=o.add(i)),i=i.double(),n>>=oi;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=ei(n,t),s=[],a=r,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,a=ei(r,t);for(let c=0;c<a.windows;c++){let{nextN:f,offset:u,isZero:l,isNeg:d,isNegF:T,offsetF:v}=oa(o,c,a);o=f,l?s=s.add(ti(T,n[v])):i=i.add(ti(d,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=ei(r,t);for(let a=0;a<s.windows&&o!==na;a++){let{nextN:c,offset:f,isZero:u,isNeg:l}=oa(o,a,s);if(o=c,!u){let d=n[f];i=i.add(l?d.negate():d)}}return i},getPrecomputes(r,n,o){let i=ri.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&ri.set(n,o(i))),i},wNAFCached(r,n,o){let i=ni(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=ni(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){ia(n,t),sa.set(r,n),ri.delete(r)}}}function gn(e,t,r,n){if(kl(r,e),Kl(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Ys(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=Fe(s),c=new Array(Number(a)+1).fill(o),f=Math.floor((t.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let T=0;T<n.length;T++){let v=n[T],y=Number(v>>BigInt(l)&a);c[y]=c[y].add(r[T])}let d=o;for(let T=c.length-1,v=o;T>0;T--)v=v.add(c[T]),d=d.add(v);if(u=u.add(d),l!==0)for(let T=0;T<s;T++)u=u.double()}return u}function Ur(e){return Xo(e.Fp),ie(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Jo(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var jt=BigInt(0),wt=BigInt(1),aa=BigInt(2),Ol=BigInt(8),Ml={zip215:!0};function Fl(e){let t=Ur(e);return ie(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ca(e){let t=Fl(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=aa<<BigInt(a*8)-wt,u=r.create,l=se(t.n,t.nBitLength),d=t.uvRatio||((b,m)=>{try{return{isValid:!0,value:r.sqrt(b*r.inv(m))}}catch{return{isValid:!1,value:jt}}}),T=t.adjustScalarBytes||(b=>b),v=t.domain||((b,m,C)=>{if(Zt("phflag",C),m.length||C)throw new Error("Contexts/pre-hash are not supported");return b});function y(b,m,C=!1){let P=C?wt:jt;It("coordinate "+b,m,P,f)}function h(b){if(!(b instanceof g))throw new Error("ExtendedPoint expected")}let E=sr((b,m)=>{let{ex:C,ey:P,ez:M}=b,H=b.is0();m==null&&(m=H?Ol:r.inv(M));let q=u(C*m),z=u(P*m),Z=u(M*m);if(H)return{x:jt,y:wt};if(Z!==wt)throw new Error("invZ was invalid");return{x:q,y:z}}),U=sr(b=>{let{a:m,d:C}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:P,ey:M,ez:H,et:q}=b,z=u(P*P),Z=u(M*M),Y=u(H*H),it=u(Y*Y),rt=u(z*m),lt=u(Y*u(rt+Z)),Et=u(it+u(C*u(z*Z)));if(lt!==Et)throw new Error("bad point: equation left != right (1)");let ct=u(P*M),mt=u(H*q);if(ct!==mt)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(m,C,P,M){y("x",m),y("y",C),y("z",P,!0),y("t",M),this.ex=m,this.ey=C,this.ez=P,this.et=M,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof g)throw new Error("extended point not allowed");let{x:C,y:P}=m||{};return y("x",C),y("y",P),new g(C,P,wt,u(C*P))}static normalizeZ(m){let C=ar(r,m.map(P=>P.ez));return m.map((P,M)=>P.toAffine(C[M])).map(g.fromAffine)}static msm(m,C){return gn(g,l,m,C)}_setWindowSize(m){k.setWindowSize(this,m)}assertValidity(){U(this)}equals(m){h(m);let{ex:C,ey:P,ez:M}=this,{ex:H,ey:q,ez:z}=m,Z=u(C*z),Y=u(H*M),it=u(P*z),rt=u(q*M);return Z===Y&&it===rt}is0(){return this.equals(g.ZERO)}negate(){return new g(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:m}=t,{ex:C,ey:P,ez:M}=this,H=u(C*C),q=u(P*P),z=u(aa*u(M*M)),Z=u(m*H),Y=C+P,it=u(u(Y*Y)-H-q),rt=Z+q,lt=rt-z,Et=Z-q,ct=u(it*lt),mt=u(rt*Et),Ct=u(it*Et),Kt=u(lt*rt);return new g(ct,mt,Kt,Ct)}add(m){h(m);let{a:C,d:P}=t,{ex:M,ey:H,ez:q,et:z}=this,{ex:Z,ey:Y,ez:it,et:rt}=m,lt=u(M*Z),Et=u(H*Y),ct=u(z*P*rt),mt=u(q*it),Ct=u((M+H)*(Z+Y)-lt-Et),Kt=mt-ct,yr=mt+ct,Ji=u(Et-C*lt),_u=u(Ct*Kt),Uu=u(yr*Ji),Du=u(Ct*Ji),Ru=u(Kt*yr);return new g(_u,Uu,Ru,Du)}subtract(m){return this.add(m.negate())}wNAF(m){return k.wNAFCached(this,m,g.normalizeZ)}multiply(m){let C=m;It("scalar",C,wt,n);let{p:P,f:M}=this.wNAF(C);return g.normalizeZ([P,M])[0]}multiplyUnsafe(m,C=g.ZERO){let P=m;return It("scalar",P,jt,n),P===jt?O:this.is0()||P===wt?this:k.wNAFCachedUnsafe(this,P,g.normalizeZ,C)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(m){return E(this,m)}clearCofactor(){let{h:m}=t;return m===wt?this:this.multiplyUnsafe(m)}static fromHex(m,C=!1){let{d:P,a:M}=t,H=r.BYTES;m=tt("pointHex",m,H),Zt("zip215",C);let q=m.slice(),z=m[H-1];q[H-1]=z&-129;let Z=Oe(q),Y=C?f:r.ORDER;It("pointHex.y",Z,jt,Y);let it=u(Z*Z),rt=u(it-wt),lt=u(P*it-M),{isValid:Et,value:ct}=d(rt,lt);if(!Et)throw new Error("Point.fromHex: invalid y coordinate");let mt=(ct&wt)===wt,Ct=(z&128)!==0;if(!C&&ct===jt&&Ct)throw new Error("Point.fromHex: x=0 and x_0=1");return Ct!==mt&&(ct=u(-ct)),g.fromAffine({x:ct,y:Z})}static fromPrivateKey(m){let{scalar:C}=w(m);return D.multiply(C)}toRawBytes(){let{x:m,y:C}=this.toAffine(),P=ir(C,r.BYTES);return P[P.length-1]|=m&wt?128:0,P}toHex(){return Ae(this.toRawBytes())}}g.BASE=new g(t.Gx,t.Gy,wt,u(t.Gx*t.Gy)),g.ZERO=new g(jt,wt,wt,jt);let{BASE:D,ZERO:O}=g,k=yn(g,a*8);function R(b){return J(b,n)}function x(b){return R(Oe(b))}function w(b){let m=r.BYTES;b=tt("private key",b,m);let C=tt("hashed private key",i(b),2*m),P=T(C.slice(0,m)),M=C.slice(m,2*m),H=x(P);return{head:P,prefix:M,scalar:H}}function K(b){let{head:m,prefix:C,scalar:P}=w(b),M=D.multiply(P),H=M.toRawBytes();return{head:m,prefix:C,scalar:P,point:M,pointBytes:H}}function L(b){return K(b).pointBytes}function _(b=Uint8Array.of(),...m){let C=ve(...m);return x(i(v(C,tt("context",b),!!o)))}function V(b,m,C={}){b=tt("message",b),o&&(b=o(b));let{prefix:P,scalar:M,pointBytes:H}=K(m),q=_(C.context,P,b),z=D.multiply(q).toRawBytes(),Z=_(C.context,z,H,b),Y=R(q+Z*M);It("signature.s",Y,jt,n);let it=ve(z,ir(Y,r.BYTES));return tt("result",it,r.BYTES*2)}let S=Ml;function A(b,m,C,P=S){let{context:M,zip215:H}=P,q=r.BYTES;b=tt("signature",b,2*q),m=tt("message",m),C=tt("publicKey",C,q),H!==void 0&&Zt("zip215",H),o&&(m=o(m));let z=Oe(b.slice(q,2*q)),Z,Y,it;try{Z=g.fromHex(C,H),Y=g.fromHex(b.slice(0,q),H),it=D.multiplyUnsafe(z)}catch{return!1}if(!H&&Z.isSmallOrder())return!1;let rt=_(M,Y.toRawBytes(),Z.toRawBytes(),m);return Y.add(Z.multiplyUnsafe(rt)).subtract(it).clearCofactor().equals(g.ZERO)}return D._setWindowSize(8),{CURVE:t,getPublicKey:L,sign:V,verify:A,ExtendedPoint:g,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(b=8,m=g.BASE){return m._setWindowSize(b),m.multiply(BigInt(3)),m}}}}var ii=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ua=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),qp=BigInt(0),Vl=BigInt(1),fa=BigInt(2),zp=BigInt(3),Hl=BigInt(5),ql=BigInt(8);function zl(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=ii,a=e*e%i*e%i,c=Q(a,fa,i)*a%i,f=Q(c,Vl,i)*e%i,u=Q(f,Hl,i)*f%i,l=Q(u,t,i)*u%i,d=Q(l,r,i)*l%i,T=Q(d,n,i)*d%i,v=Q(T,o,i)*T%i,y=Q(v,o,i)*T%i,h=Q(y,t,i)*u%i;return{pow_p_5_8:Q(h,fa,i)*e%i,b2:a}}function $l(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Gl(e,t){let r=ii,n=J(t*t*t,r),o=J(n*n*t,r),i=zl(e*o).pow_p_5_8,s=J(e*n*i,r),a=J(t*s*s,r),c=s,f=J(s*ua,r),u=a===e,l=a===J(-e,r),d=a===J(-e*ua,r);return u&&(s=c),(l||d)&&(s=f),ta(s,r)&&(s=J(-s,r)),{isValid:u||l,value:s}}var la=se(ii,void 0,!0),Zl={a:la.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:la,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:ql,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:zs,randomBytes:fn,adjustScalarBytes:$l,uvRatio:Gl},da=ca(Zl);var xn=32;function ha(e,t,r){return da.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var wn=class{type="Ed25519";raw;constructor(t){this.raw=si(t,xn)}toMultihash(){return Ft.digest(we(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}verify(t,r){return ha(this.raw,r,t)}};function ai(e){return e=si(e,xn),new wn(e)}function si(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new st(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Yl=Math.pow(2,7),Wl=Math.pow(2,14),Xl=Math.pow(2,21),ma=Math.pow(2,28),ya=Math.pow(2,35),ga=Math.pow(2,42),xa=Math.pow(2,49),bt=128,Ce=127;function Dr(e){if(e<Yl)return 1;if(e<Wl)return 2;if(e<Xl)return 3;if(e<ma)return 4;if(e<ya)return 5;if(e<ga)return 6;if(e<xa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function wa(e,t,r=0){switch(Dr(e)){case 8:t[r++]=e&255|bt,e/=128;case 7:t[r++]=e&255|bt,e/=128;case 6:t[r++]=e&255|bt,e/=128;case 5:t[r++]=e&255|bt,e/=128;case 4:t[r++]=e&255|bt,e>>>=7;case 3:t[r++]=e&255|bt,e>>>=7;case 2:t[r++]=e&255|bt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function ba(e,t){let r=e[t],n=0;if(n+=r&Ce,r<bt||(r=e[t+1],n+=(r&Ce)<<7,r<bt)||(r=e[t+2],n+=(r&Ce)<<14,r<bt)||(r=e[t+3],n+=(r&Ce)<<21,r<bt)||(r=e[t+4],n+=(r&Ce)*ma,r<bt)||(r=e[t+5],n+=(r&Ce)*ya,r<bt)||(r=e[t+6],n+=(r&Ce)*ga,r<bt)||(r=e[t+7],n+=(r&Ce)*xa,r<bt))return n;throw new RangeError("Could not decode varint")}var ci=new Float32Array([-0]),Te=new Uint8Array(ci.buffer);function Ea(e,t,r){ci[0]=e,t[r]=Te[0],t[r+1]=Te[1],t[r+2]=Te[2],t[r+3]=Te[3]}function Sa(e,t){return Te[0]=e[t],Te[1]=e[t+1],Te[2]=e[t+2],Te[3]=e[t+3],ci[0]}var ui=new Float64Array([-0]),yt=new Uint8Array(ui.buffer);function Aa(e,t,r){ui[0]=e,t[r]=yt[0],t[r+1]=yt[1],t[r+2]=yt[2],t[r+3]=yt[3],t[r+4]=yt[4],t[r+5]=yt[5],t[r+6]=yt[6],t[r+7]=yt[7]}function va(e,t){return yt[0]=e[t],yt[1]=e[t+1],yt[2]=e[t+2],yt[3]=e[t+3],yt[4]=e[t+4],yt[5]=e[t+5],yt[6]=e[t+6],yt[7]=e[t+7],ui[0]}var Jl=BigInt(Number.MAX_SAFE_INTEGER),Ql=BigInt(Number.MIN_SAFE_INTEGER),_t=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return He;if(t<Jl&&t>Ql)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ca&&(o=0n,++n>Ca&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return He;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):He}},He=new _t(0,0);He.toBigInt=function(){return 0n};He.zzEncode=He.zzDecode=function(){return this};He.length=function(){return 1};var Ca=4294967296n;function Ta(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ba(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function fi(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Ht(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function bn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var li=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,Ht(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 Ht(this,4);return bn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ht(this,4);return bn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ht(this,4);let t=Sa(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ht(this,4);let t=va(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Ht(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ba(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Ht(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ht(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 _t(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Ht(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Ht(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ht(this,8);let t=bn(this.buf,this.pos+=4),r=bn(this.buf,this.pos+=4);return new _t(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ba(this.buf,this.pos);return this.pos+=Dr(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 di(e){return new li(e instanceof Uint8Array?e:e.subarray())}function Be(e,t,r){let n=di(e);return t.decode(n,void 0,r)}function hi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Tt(s);o+s>t&&(n=Tt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var qe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function pi(){}var yi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},td=hi();function ed(e){return globalThis.Buffer!=null?Tt(e):td(e)}var Nr=class{len;head;tail;states;constructor(){this.len=0,this.head=new qe(pi,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new qe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new gi((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(En,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=_t.fromBigInt(t);return this._push(En,r.length(),r)}uint64Number(t){return this._push(wa,Dr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=_t.fromBigInt(t).zzEncode();return this._push(En,r.length(),r)}sint64Number(t){let r=_t.fromNumber(t).zzEncode();return this._push(En,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(mi,1,t?1:0)}fixed32(t){return this._push(Rr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=_t.fromBigInt(t);return this._push(Rr,4,r.lo)._push(Rr,4,r.hi)}fixed64Number(t){let r=_t.fromNumber(t);return this._push(Rr,4,r.lo)._push(Rr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Ea,4,t)}double(t){return this._push(Aa,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(mi,1,0):this.uint32(r)._push(nd,r,t)}string(t){let r=Ta(t);return r!==0?this.uint32(r)._push(fi,r,t):this._push(mi,1,0)}fork(){return this.states=new yi(this),this.head=this.tail=new qe(pi,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 qe(pi,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=ed(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function mi(e,t,r){t[r]=e&255}function rd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var gi=class extends qe{next;constructor(t,r){super(rd,t,r),this.next=void 0}};function En(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Rr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function nd(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Nr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(od,t,e),this},Nr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(id,t,e),this});function od(e,t,r){t.set(e,r)}function id(e,t,r){e.length<40?fi(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set($(e),r)}function xi(){return new Nr}function Ie(e,t){let r=xi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var cr;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(cr||(cr={}));function Sn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Lr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Sn("enum",cr.VARINT,r,n)}function _e(e,t){return Sn("message",cr.LENGTH_DELIMITED,e,t)}var ot;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ot||(ot={}));var wi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(wi||(wi={}));(function(e){e.codec=()=>Lr(wi)})(ot||(ot={}));var Yt;(function(e){let t;e.codec=()=>(t==null&&(t=_e((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ot.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ot.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Ie(r,e.codec()),e.decode=(r,n)=>Be(r,e.codec(),n)})(Yt||(Yt={}));var bi;(function(e){let t;e.codec=()=>(t==null&&(t=_e((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ot.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ot.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Ie(r,e.codec()),e.decode=(r,n)=>Be(r,e.codec(),n)})(bi||(bi={}));var Pr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},An=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Ua={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new An("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Ue=Ua;var Kr={};St(Kr,{MAX_RSA_KEY_SIZE:()=>Ei,generateRSAKeyPair:()=>La,jwkToJWKKeyPair:()=>Pa,jwkToPkcs1:()=>ud,jwkToPkix:()=>Ci,jwkToRSAPrivateKey:()=>_i,pkcs1MessageToJwk:()=>Ai,pkcs1MessageToRSAPrivateKey:()=>Ti,pkcs1ToJwk:()=>cd,pkcs1ToRSAPrivateKey:()=>Na,pkixMessageToJwk:()=>vi,pkixMessageToRSAPublicKey:()=>Ii,pkixToJwk:()=>fd,pkixToRSAPublicKey:()=>Bi});var vn=hn;var ur=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Kr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}verify(t,r){return Ra(this.jwk,r,t)}},kr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Kr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}sign(t){return Da(this.jwk,t)}};var Ei=8192,Si=18,sd=1062,ad=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function cd(e){let t=te(e);return Ai(t)}function Ai(e){return{n:j(e[1],"base64url"),e:j(e[2],"base64url"),d:j(e[3],"base64url"),p:j(e[4],"base64url"),q:j(e[5],"base64url"),dp:j(e[6],"base64url"),dq:j(e[7],"base64url"),qi:j(e[8],"base64url"),kty:"RSA"}}function ud(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new st("JWK was missing components");return xe([vt(Uint8Array.from([0])),vt($(e.n,"base64url")),vt($(e.e,"base64url")),vt($(e.d,"base64url")),vt($(e.p,"base64url")),vt($(e.q,"base64url")),vt($(e.dp,"base64url")),vt($(e.dq,"base64url")),vt($(e.qi,"base64url"))]).subarray()}function fd(e){let t=te(e,{offset:0});return vi(t)}function vi(e){let t=te(e[1],{offset:0});return{kty:"RSA",n:j(t[0],"base64url"),e:j(t[1],"base64url")}}function Ci(e){if(e.n==null||e.e==null)throw new st("JWK was missing components");return xe([ad,an(xe([vt($(e.n,"base64url")),vt($(e.e,"base64url"))]))]).subarray()}function Na(e){let t=te(e);return Ti(t)}function Ti(e){let t=Ai(e);return _i(t)}function Bi(e,t){if(e.byteLength>=sd)throw new Ye("Key size is too large");let r=te(e,{offset:0});return Ii(r,e,t)}function Ii(e,t,r){let n=vi(e);if(r==null){let o=vn(Yt.encode({Type:ot.RSA,Data:t}));r=Mt(Si,o)}return new ur(n,r)}function _i(e){if(Ka(e)>Ei)throw new st("Key size is too large");let t=Pa(e),r=vn(Yt.encode({Type:ot.RSA,Data:Ci(t.publicKey)})),n=Mt(Si,r);return new kr(t.privateKey,new ur(t.publicKey,n))}async function La(e){if(e>Ei)throw new st("Key size is too large");let t=await ka(e),r=vn(Yt.encode({Type:ot.RSA,Data:Ci(t.publicKey)})),n=Mt(Si,r);return new kr(t.privateKey,new ur(t.publicKey,n))}function Pa(e){if(e==null)throw new st("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function ka(e){let t=await Ue.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await ld(t);return{privateKey:r[0],publicKey:r[1]}}async function Da(e,t){let r=await Ue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ue.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ra(e,t,r){let n=await Ue.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ue.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function ld(e){if(e.privateKey==null||e.publicKey==null)throw new st("Private and public key are required");return Promise.all([Ue.get().subtle.exportKey("jwk",e.privateKey),Ue.get().subtle.exportKey("jwk",e.publicKey)])}function Ka(e){if(e.kty!=="RSA")throw new st("invalid key type");if(e.n==null)throw new st("invalid key modulus");return $(e.n,"base64url").length*8}var Cn=class extends nr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Us(t);let n=vr(r);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,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),ee(i)}update(t){return or(this),this.iHash.update(t),this}digestInto(t){or(this),Le(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:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ui=(e,t,r)=>new Cn(e,t).update(r).digest();Ui.create=(e,t)=>new Cn(e,t);function Oa(e){e.lowS!==void 0&&Zt("lowS",e.lowS),e.prehash!==void 0&&Zt("prehash",e.prehash)}function dd(e){let t=Ur(e);ie(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var Di=class extends Error{constructor(t=""){super(t)}},ae={Err:Di,_tlv:{encode:(e,t)=>{let{Err:r}=ae;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Ir(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Ir(o.length/2|128):"";return Ir(e)+i+o+t},decode(e,t){let{Err:r}=ae,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=ae;if(e<ce)throw new t("integer: negative integers are not allowed");let r=Ir(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ae;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return oe(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=ae,o=tt("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=ae,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},ce=BigInt(0),ut=BigInt(1),by=BigInt(2),Ma=BigInt(3),Ey=BigInt(4);function hd(e){let t=dd(e),{Fp:r}=t,n=se(t.n,t.nBitLength),o=t.toBytes||((y,h,E)=>{let U=h.toAffine();return ve(Uint8Array.from([4]),r.toBytes(U.x),r.toBytes(U.y))}),i=t.fromBytes||(y=>{let h=y.subarray(1),E=r.fromBytes(h.subarray(0,r.BYTES)),U=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:E,y:U}});function s(y){let{a:h,b:E}=t,U=r.sqr(y),g=r.mul(U,y);return r.add(r.add(g,r.mul(y,h)),E)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return pn(y,ut,t.n)}function c(y){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:U,n:g}=t;if(h&&typeof y!="bigint"){if(Ke(y)&&(y=Ae(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(E*2,"0")}let D;try{D=typeof y=="bigint"?y:oe(tt("private key",y,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof y)}return U&&(D=J(D,g)),It("private key",D,ut,g),D}function f(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}let u=sr((y,h)=>{let{px:E,py:U,pz:g}=y;if(r.eql(g,r.ONE))return{x:E,y:U};let D=y.is0();h==null&&(h=D?r.ONE:r.inv(g));let O=r.mul(E,h),k=r.mul(U,h),R=r.mul(g,h);if(D)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:O,y:k}}),l=sr(y=>{if(y.is0()){if(t.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=y.toAffine();if(!r.isValid(h)||!r.isValid(E))throw new Error("bad point: x or y not FE");let U=r.sqr(E),g=s(h);if(!r.eql(U,g))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,E,U){if(h==null||!r.isValid(h))throw new Error("x required");if(E==null||!r.isValid(E)||r.is0(E))throw new Error("y required");if(U==null||!r.isValid(U))throw new Error("z required");this.px=h,this.py=E,this.pz=U,Object.freeze(this)}static fromAffine(h){let{x:E,y:U}=h||{};if(!h||!r.isValid(E)||!r.isValid(U))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let g=D=>r.eql(D,r.ZERO);return g(E)&&g(U)?d.ZERO:new d(E,U,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=ar(r,h.map(U=>U.pz));return h.map((U,g)=>U.toAffine(E[g])).map(d.fromAffine)}static fromHex(h){let E=d.fromAffine(i(tt("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,E){return gn(d,n,h,E)}_setWindowSize(h){v.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:E,py:U,pz:g}=this,{px:D,py:O,pz:k}=h,R=r.eql(r.mul(E,k),r.mul(D,g)),x=r.eql(r.mul(U,k),r.mul(O,g));return R&&x}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:E}=t,U=r.mul(E,Ma),{px:g,py:D,pz:O}=this,k=r.ZERO,R=r.ZERO,x=r.ZERO,w=r.mul(g,g),K=r.mul(D,D),L=r.mul(O,O),_=r.mul(g,D);return _=r.add(_,_),x=r.mul(g,O),x=r.add(x,x),k=r.mul(h,x),R=r.mul(U,L),R=r.add(k,R),k=r.sub(K,R),R=r.add(K,R),R=r.mul(k,R),k=r.mul(_,k),x=r.mul(U,x),L=r.mul(h,L),_=r.sub(w,L),_=r.mul(h,_),_=r.add(_,x),x=r.add(w,w),w=r.add(x,w),w=r.add(w,L),w=r.mul(w,_),R=r.add(R,w),L=r.mul(D,O),L=r.add(L,L),w=r.mul(L,_),k=r.sub(k,w),x=r.mul(L,K),x=r.add(x,x),x=r.add(x,x),new d(k,R,x)}add(h){f(h);let{px:E,py:U,pz:g}=this,{px:D,py:O,pz:k}=h,R=r.ZERO,x=r.ZERO,w=r.ZERO,K=t.a,L=r.mul(t.b,Ma),_=r.mul(E,D),V=r.mul(U,O),S=r.mul(g,k),A=r.add(E,U),B=r.add(D,O);A=r.mul(A,B),B=r.add(_,V),A=r.sub(A,B),B=r.add(E,g);let b=r.add(D,k);return B=r.mul(B,b),b=r.add(_,S),B=r.sub(B,b),b=r.add(U,g),R=r.add(O,k),b=r.mul(b,R),R=r.add(V,S),b=r.sub(b,R),w=r.mul(K,B),R=r.mul(L,S),w=r.add(R,w),R=r.sub(V,w),w=r.add(V,w),x=r.mul(R,w),V=r.add(_,_),V=r.add(V,_),S=r.mul(K,S),B=r.mul(L,B),V=r.add(V,S),S=r.sub(_,S),S=r.mul(K,S),B=r.add(B,S),_=r.mul(V,B),x=r.add(x,_),_=r.mul(b,B),R=r.mul(A,R),R=r.sub(R,_),_=r.mul(A,V),w=r.mul(b,w),w=r.add(w,_),new d(R,x,w)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return v.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:E,n:U}=t;It("scalar",h,ce,U);let g=d.ZERO;if(h===ce)return g;if(this.is0()||h===ut)return this;if(!E||v.hasPrecomputes(this))return v.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:D,k1:O,k2neg:k,k2:R}=E.splitScalar(h),x=g,w=g,K=this;for(;O>ce||R>ce;)O&ut&&(x=x.add(K)),R&ut&&(w=w.add(K)),K=K.double(),O>>=ut,R>>=ut;return D&&(x=x.negate()),k&&(w=w.negate()),w=new d(r.mul(w.px,E.beta),w.py,w.pz),x.add(w)}multiply(h){let{endo:E,n:U}=t;It("scalar",h,ut,U);let g,D;if(E){let{k1neg:O,k1:k,k2neg:R,k2:x}=E.splitScalar(h),{p:w,f:K}=this.wNAF(k),{p:L,f:_}=this.wNAF(x);w=v.constTimeNegate(O,w),L=v.constTimeNegate(R,L),L=new d(r.mul(L.px,E.beta),L.py,L.pz),g=w.add(L),D=K.add(_)}else{let{p:O,f:k}=this.wNAF(h);g=O,D=k}return d.normalizeZ([g,D])[0]}multiplyAndAddUnsafe(h,E,U){let g=d.BASE,D=(k,R)=>R===ce||R===ut||!k.equals(g)?k.multiplyUnsafe(R):k.multiply(R),O=D(this,E).add(D(h,U));return O.is0()?void 0:O}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=t;if(h===ut)return!0;if(E)return E(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=t;return h===ut?this:E?E(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Zt("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Zt("isCompressed",h),Ae(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let T=t.nBitLength,v=yn(d,t.endo?Math.ceil(T/2):T);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function pd(e){let t=Ur(e);return ie(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Fa(e){let t=pd(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(S){return J(S,n)}function a(S){return mn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=hd({...t,toBytes(S,A,B){let b=A.toAffine(),m=r.toBytes(b.x),C=ve;return Zt("isCompressed",B),B?C(Uint8Array.from([A.hasEvenY()?2:3]),m):C(Uint8Array.from([4]),m,r.toBytes(b.y))},fromBytes(S){let A=S.length,B=S[0],b=S.subarray(1);if(A===o&&(B===2||B===3)){let m=oe(b);if(!pn(m,ut,r.ORDER))throw new Error("Point is not on curve");let C=u(m),P;try{P=r.sqrt(C)}catch(q){let z=q instanceof Error?": "+q.message:"";throw new Error("Point is not on curve"+z)}let M=(P&ut)===ut;return(B&1)===1!==M&&(P=r.neg(P)),{x:m,y:P}}else if(A===i&&B===4){let m=r.fromBytes(b.subarray(0,r.BYTES)),C=r.fromBytes(b.subarray(r.BYTES,2*r.BYTES));return{x:m,y:C}}else{let m=o,C=i;throw new Error("invalid Point, expected length of "+m+", or uncompressed "+C+", got "+A)}}}),d=S=>Ae(Me(S,t.nByteLength));function T(S){let A=n>>ut;return S>A}function v(S){return T(S)?s(-S):S}let y=(S,A,B)=>oe(S.slice(A,B));class h{constructor(A,B,b){It("r",A,ut,n),It("s",B,ut,n),this.r=A,this.s=B,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(A){let B=t.nByteLength;return A=tt("compactSignature",A,B*2),new h(y(A,0,B),y(A,B,2*B))}static fromDER(A){let{r:B,s:b}=ae.toSig(tt("DER",A));return new h(B,b)}assertValidity(){}addRecoveryBit(A){return new h(this.r,this.s,A)}recoverPublicKey(A){let{r:B,s:b,recovery:m}=this,C=k(tt("msgHash",A));if(m==null||![0,1,2,3].includes(m))throw new Error("recovery id invalid");let P=m===2||m===3?B+t.n:B;if(P>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=(m&1)===0?"02":"03",H=c.fromHex(M+d(P)),q=a(P),z=s(-C*q),Z=s(b*q),Y=c.BASE.multiplyAndAddUnsafe(H,z,Z);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return T(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return _r(this.toDERHex())}toDERHex(){return ae.hexFromSig(this)}toCompactRawBytes(){return _r(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let E={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Qo(t.n);return ra(t.randomBytes(S),t.n)},precompute(S=8,A=c.BASE){return A._setWindowSize(S),A.multiply(BigInt(3)),A}};function U(S,A=!0){return c.fromPrivateKey(S).toRawBytes(A)}function g(S){let A=Ke(S),B=typeof S=="string",b=(A||B)&&S.length;return A?b===o||b===i:B?b===2*o||b===2*i:S instanceof c}function D(S,A,B=!0){if(g(S))throw new Error("first arg must be private key");if(!g(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(f(S)).toRawBytes(B)}let O=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let A=oe(S),B=S.length*8-t.nBitLength;return B>0?A>>BigInt(B):A},k=t.bits2int_modN||function(S){return s(O(S))},R=Fe(t.nBitLength);function x(S){return It("num < 2^"+t.nBitLength,S,ce,R),Me(S,t.nByteLength)}function w(S,A,B=K){if(["recovered","canonical"].some(rt=>rt in B))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:m}=t,{lowS:C,prehash:P,extraEntropy:M}=B;C==null&&(C=!0),S=tt("msgHash",S),Oa(B),P&&(S=tt("prehashed msgHash",b(S)));let H=k(S),q=f(A),z=[x(q),x(H)];if(M!=null&&M!==!1){let rt=M===!0?m(r.BYTES):M;z.push(tt("extraEntropy",rt))}let Z=ve(...z),Y=H;function it(rt){let lt=O(rt);if(!l(lt))return;let Et=a(lt),ct=c.BASE.multiply(lt).toAffine(),mt=s(ct.x);if(mt===ce)return;let Ct=s(Et*s(Y+mt*q));if(Ct===ce)return;let Kt=(ct.x===mt?0:2)|Number(ct.y&ut),yr=Ct;return C&&T(Ct)&&(yr=v(Ct),Kt^=1),new h(mt,yr,Kt)}return{seed:Z,k2sig:it}}let K={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function _(S,A,B=K){let{seed:b,k2sig:m}=w(S,A,B),C=t;return Ws(C.hash.outputLen,C.nByteLength,C.hmac)(b,m)}c.BASE._setWindowSize(8);function V(S,A,B,b=L){let m=S;A=tt("msgHash",A),B=tt("publicKey",B);let{lowS:C,prehash:P,format:M}=b;if(Oa(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");let H=typeof m=="string"||Ke(m),q=!H&&!M&&typeof m=="object"&&m!==null&&typeof m.r=="bigint"&&typeof m.s=="bigint";if(!H&&!q)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let z,Z;try{if(q&&(z=new h(m.r,m.s)),H){try{M!=="compact"&&(z=h.fromDER(m))}catch(Kt){if(!(Kt instanceof ae.Err))throw Kt}!z&&M!=="der"&&(z=h.fromCompact(m))}Z=c.fromHex(B)}catch{return!1}if(!z||C&&z.hasHighS())return!1;P&&(A=t.hash(A));let{r:Y,s:it}=z,rt=k(A),lt=a(it),Et=s(rt*lt),ct=s(Y*lt),mt=c.BASE.multiplyAndAddUnsafe(Z,Et,ct)?.toAffine();return mt?s(mt.x)===Y:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:D,sign:_,verify:V,ProjectivePoint:c,Signature:h,utils:E}}function md(e){return{hash:e,hmac:(t,...r)=>Ui(e,t,Fo(...r)),randomBytes:fn}}function Va(e,t){let r=n=>Fa({...e,...md(n)});return{...r(t),create:r}}var za=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ha=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),yd=BigInt(1),Ri=BigInt(2),qa=(e,t)=>(e+t/Ri)/t;function gd(e){let t=za,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=Q(u,r,t)*u%t,d=Q(l,r,t)*u%t,T=Q(d,Ri,t)*f%t,v=Q(T,o,t)*T%t,y=Q(v,i,t)*v%t,h=Q(y,a,t)*y%t,E=Q(h,c,t)*h%t,U=Q(E,a,t)*y%t,g=Q(U,r,t)*u%t,D=Q(g,s,t)*v%t,O=Q(D,n,t)*f%t,k=Q(O,Ri,t);if(!Ni.eql(Ni.sqr(k),e))throw new Error("Cannot find square root");return k}var Ni=se(za,void 0,void 0,{sqrt:gd}),ze=Va({a:BigInt(0),b:BigInt(7),Fp:Ni,n:Ha,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Ha,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-yd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=qa(i*e,t),c=qa(-n*e,t),f=J(e-a*r-c*o,t),u=J(-a*n-c*i,t),l=f>s,d=u>s;if(l&&(f=t-f),d&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},hn),Uy=BigInt(0);var Dy=ze.ProjectivePoint;function $a(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Ga(e,t,r){let n=Er.digest(r instanceof Uint8Array?r:r.subarray());if($a(n))return n.then(({digest:o})=>ze.verify(t,o,e)).catch(o=>{throw new Pr(String(o))});try{return ze.verify(t,n.digest,e)}catch(o){throw new Pr(String(o))}}var Tn=class{type="secp256k1";raw;_key;constructor(t){this._key=ja(t),this.raw=Za(this._key)}toMultihash(){return Ft.digest(we(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:nt(this.raw,t.raw)}verify(t,r){return Ga(this._key,r,t)}};function Li(e){return new Tn(e)}function Za(e){return ze.ProjectivePoint.fromHex(e).toRawBytes(!0)}function ja(e){try{return ze.ProjectivePoint.fromHex(e),e}catch(t){throw new Ye(String(t))}}function Ya(e,t){let{Type:r,Data:n}=Yt.decode(e),o=n??new Uint8Array;switch(r){case ot.RSA:return Bi(o,t);case ot.Ed25519:return ai(o);case ot.secp256k1:return Li(o);case ot.ECDSA:return Mo(o);default:throw new Xe}}function Bn(e){let{Type:t,Data:r}=Yt.decode(e.digest),n=r??new Uint8Array;switch(t){case ot.Ed25519:return ai(n);case ot.secp256k1:return Li(n);case ot.ECDSA:return Mo(n);default:throw new Xe}}function we(e){return Yt.encode({Type:ot[e.type],Data:e.raw})}var Wa=Symbol.for("nodejs.util.inspect.custom"),xd=114,Or=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()})`}[co]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(xd,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return nt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return nt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Wa](){return`PeerId(${this.toString()})`}},In=class extends Or{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},_n=class extends Or{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Un=class extends Or{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},wd=2336,Mr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Ft.digest($(this.url))}[Wa](){return`PeerId(${this.url})`}[co]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(wd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=j(t)),t.toString()===this.toString())}};var bd=114,Xa=2336;function Dn(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Qt(W.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Pi(X.parse(e));if(t==null)throw new st('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Qt(t.decode(e))}return Ja(r)}function Ja(e){if(Sd(e))return new In({multihash:e});if(Ed(e))try{let t=Bn(e);if(t.type==="Ed25519")return new _n({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Un({multihash:e,publicKey:t})}catch{let r=j(e.digest);return new Mr(new URL(r))}throw new We("Supplied PeerID Multihash is invalid")}function Pi(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==bd&&e.code!==Xa)throw new Qr("Supplied PeerID CID is invalid");if(e.code===Xa){let t=j(e.multihash.digest);return new Mr(new URL(t))}return Ja(e.multihash)}function Ed(e){return e.code===Ft.code}function Sd(e){return e.code===Er.code}var ue="/",Qa=new TextEncoder().encode(ue),Rn=Qa[0],Fr=class e{_buf;constructor(t,r){if(typeof t=="string")this._buf=$(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Rn)throw new Error("Invalid key")}toString(t="utf8"){return j(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new e(t.join(ue))}static random(){return new e(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new e(t):typeof t.uint8Array=="function"?new e(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Qa),this._buf[0]!==Rn){let t=new Uint8Array(this._buf.byteLength+1);t.fill(Rn,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Rn;)this._buf=this._buf.subarray(0,-1)}less(t){let r=this.list(),n=t.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(ue).slice(1)}type(){return Ad(this.baseNamespace())}name(){return vd(this.baseNamespace())}instance(t){return new e(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(ue)||(t+=ue),t+=this.type(),new e(t)}parent(){let t=this.list();return t.length===1?new e(ue):new e(t.slice(0,-1).join(ue))}child(t){return this.toString()===ue?t:t.toString()===ue?this:new e(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return e.withNamespaces([...this.namespaces(),...Cd(t.map(r=>r.namespaces()))])}};function Ad(e){let t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function vd(e){let t=e.split(":");return t[t.length-1]}function Cd(e){return[].concat(...e)}var lu=Jr(Nn(),1);var Ln=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},qt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Pn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},$e=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},kn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Vr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Kn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Hr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var ht;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Lr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=_e((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),e.encode=o=>Ie(o,e.codec()),e.decode=(o,i)=>Be(o,e.codec(),i)})(ht||(ht={}));var Td=["string","number","bigint","symbol"],Bd=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function tc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Td.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Id(e))return"Buffer";let r=_d(e);return r||"Object"}function Id(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function _d(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Bd.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var N=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var fr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ud=new TextDecoder,Dd=new TextEncoder;function On(e){return fr&&globalThis.Buffer.isBuffer(e)}function Ki(e){return e instanceof Uint8Array?On(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var oc=fr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):rc(e,t,r):(e,t,r)=>r-t>64?Ud.decode(e.subarray(t,r)):rc(e,t,r),ic=fr?e=>e.length>64?globalThis.Buffer.from(e):ec(e):e=>e.length>64?Dd.encode(e):ec(e),Wt=e=>Uint8Array.from(e),lr=fr?(e,t,r)=>On(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),sc=fr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ki(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},ac=fr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function cc(e,t){if(On(e)&&On(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function ec(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function rc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],f=e[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Rd(n)}var nc=4096;function Rd(e){let t=e.length;if(t<=nc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=nc));return r}var Nd=256,qr=class{constructor(t=Nd){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=ac(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=lr(n,0,this.cursor)}else r=sc(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",Oi="CBOR encode error:",zr=[];zr[23]=1;zr[24]=2;zr[25]=3;zr[26]=5;zr[27]=9;function fe(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var ft=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ut(e,t,r){fe(e,t,1);let n=e[t];if(r.strict===!0&&n<ft[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){fe(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ft[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){fe(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ft[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){fe(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ft[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function uc(e,t,r,n){return new N(p.uint,Ut(e,t+1,n),2)}function fc(e,t,r,n){return new N(p.uint,Dt(e,t+1,n),3)}function lc(e,t,r,n){return new N(p.uint,Rt(e,t+1,n),5)}function dc(e,t,r,n){return new N(p.uint,Nt(e,t+1,n),9)}function Pt(e,t){return pt(e,0,t.value)}function pt(e,t,r){if(r<ft[0]){let n=Number(r);e.push([t|n])}else if(r<ft[1]){let n=Number(r);e.push([t|24,n])}else if(r<ft[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ft[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ft[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}Pt.encodedSize=function(t){return pt.encodedSize(t.value)};pt.encodedSize=function(t){return t<ft[0]?1:t<ft[1]?2:t<ft[2]?3:t<ft[3]?5:9};Pt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function hc(e,t,r,n){return new N(p.negint,-1-Ut(e,t+1,n),2)}function pc(e,t,r,n){return new N(p.negint,-1-Dt(e,t+1,n),3)}function mc(e,t,r,n){return new N(p.negint,-1-Rt(e,t+1,n),5)}var Mi=BigInt(-1),yc=BigInt(1);function gc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new N(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new N(p.negint,Mi-BigInt(o),9)}function Mn(e,t){let r=t.value,n=typeof r=="bigint"?r*Mi-yc:r*-1-1;pt(e,t.type.majorEncoded,n)}Mn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Mi-yc:r*-1-1;return n<ft[0]?1:n<ft[1]?2:n<ft[2]?3:n<ft[3]?5:9};Mn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function $r(e,t,r,n){fe(e,t,r+n);let o=lr(e,t+r,t+r+n);return new N(p.bytes,o,r+n)}function xc(e,t,r,n){return $r(e,t,1,r)}function wc(e,t,r,n){return $r(e,t,2,Ut(e,t+1,n))}function bc(e,t,r,n){return $r(e,t,3,Dt(e,t+1,n))}function Ec(e,t,r,n){return $r(e,t,5,Rt(e,t+1,n))}function Sc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return $r(e,t,9,o)}function Fn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===p.string?ic(e.value):e.value),e.encodedBytes}function dr(e,t){let r=Fn(t);pt(e,t.type.majorEncoded,r.length),e.push(r)}dr.encodedSize=function(t){let r=Fn(t);return pt.encodedSize(r.length)+r.length};dr.compareTokens=function(t,r){return Pd(Fn(t),Fn(r))};function Pd(e,t){return e.length<t.length?-1:e.length>t.length?1:cc(e,t)}function Gr(e,t,r,n,o){let i=r+n;fe(e,t,i);let s=new N(p.string,oc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=lr(e,t+r,t+i)),s}function Ac(e,t,r,n){return Gr(e,t,1,r,n)}function vc(e,t,r,n){return Gr(e,t,2,Ut(e,t+1,n),n)}function Cc(e,t,r,n){return Gr(e,t,3,Dt(e,t+1,n),n)}function Tc(e,t,r,n){return Gr(e,t,5,Rt(e,t+1,n),n)}function Bc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return Gr(e,t,9,o,n)}var Ic=dr;function hr(e,t,r,n){return new N(p.array,n,r)}function _c(e,t,r,n){return hr(e,t,1,r)}function Uc(e,t,r,n){return hr(e,t,2,Ut(e,t+1,n))}function Dc(e,t,r,n){return hr(e,t,3,Dt(e,t+1,n))}function Rc(e,t,r,n){return hr(e,t,5,Rt(e,t+1,n))}function Nc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return hr(e,t,9,o)}function Lc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return hr(e,t,1,1/0)}function Vn(e,t){pt(e,p.array.majorEncoded,t.value)}Vn.compareTokens=Pt.compareTokens;Vn.encodedSize=function(t){return pt.encodedSize(t.value)};function pr(e,t,r,n){return new N(p.map,n,r)}function Pc(e,t,r,n){return pr(e,t,1,r)}function kc(e,t,r,n){return pr(e,t,2,Ut(e,t+1,n))}function Kc(e,t,r,n){return pr(e,t,3,Dt(e,t+1,n))}function Oc(e,t,r,n){return pr(e,t,5,Rt(e,t+1,n))}function Mc(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return pr(e,t,9,o)}function Fc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return pr(e,t,1,1/0)}function Hn(e,t){pt(e,p.map.majorEncoded,t.value)}Hn.compareTokens=Pt.compareTokens;Hn.encodedSize=function(t){return pt.encodedSize(t.value)};function Vc(e,t,r,n){return new N(p.tag,r,1)}function Hc(e,t,r,n){return new N(p.tag,Ut(e,t+1,n),2)}function qc(e,t,r,n){return new N(p.tag,Dt(e,t+1,n),3)}function zc(e,t,r,n){return new N(p.tag,Rt(e,t+1,n),5)}function $c(e,t,r,n){return new N(p.tag,Nt(e,t+1,n),9)}function qn(e,t){pt(e,p.tag.majorEncoded,t.value)}qn.compareTokens=Pt.compareTokens;qn.encodedSize=function(t){return pt.encodedSize(t.value)};var Vd=20,Hd=21,qd=22,zd=23;function Gc(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new N(p.null,null,1):new N(p.undefined,void 0,1)}function Zc(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new N(p.break,void 0,1)}function Fi(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new N(p.float,e,t)}function jc(e,t,r,n){return Fi(Vi(e,t+1),3,n)}function Yc(e,t,r,n){return Fi(Hi(e,t+1),5,n)}function Wc(e,t,r,n){return Fi(tu(e,t+1),9,n)}function zn(e,t,r){let n=t.value;if(n===!1)e.push([p.float.majorEncoded|Vd]);else if(n===!0)e.push([p.float.majorEncoded|Hd]);else if(n===null)e.push([p.float.majorEncoded|qd]);else if(n===void 0)e.push([p.float.majorEncoded|zd]);else{let o,i=!1;(!r||r.float64!==!0)&&(Jc(n),o=Vi(zt,1),n===o||Number.isNaN(n)?(zt[0]=249,e.push(zt.slice(0,3)),i=!0):(Qc(n),o=Hi(zt,1),n===o&&(zt[0]=250,e.push(zt.slice(0,5)),i=!0))),i||($d(n),o=tu(zt,1),zt[0]=251,e.push(zt.slice(0,9)))}}zn.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Jc(n);let o=Vi(zt,1);if(n===o||Number.isNaN(n))return 3;if(Qc(n),o=Hi(zt,1),n===o)return 5}return 9};var Xc=new ArrayBuffer(9),kt=new DataView(Xc,1),zt=new Uint8Array(Xc,0);function Jc(e){if(e===1/0)kt.setUint16(0,31744,!1);else if(e===-1/0)kt.setUint16(0,64512,!1);else if(Number.isNaN(e))kt.setUint16(0,32256,!1);else{kt.setFloat32(0,e);let t=kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)kt.setUint16(0,31744,!1);else if(r===0)kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?kt.setUint16(0,0):o<-14?kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Vi(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Qc(e){kt.setFloat32(0,e,!1)}function Hi(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function $d(e){kt.setFloat64(0,e,!1)}function tu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}zn.compareTokens=Pt.compareTokens;function G(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function $n(e){return()=>{throw new Error(`${F} ${e}`)}}var I=[];for(let e=0;e<=23;e++)I[e]=G;I[24]=uc;I[25]=fc;I[26]=lc;I[27]=dc;I[28]=G;I[29]=G;I[30]=G;I[31]=G;for(let e=32;e<=55;e++)I[e]=G;I[56]=hc;I[57]=pc;I[58]=mc;I[59]=gc;I[60]=G;I[61]=G;I[62]=G;I[63]=G;for(let e=64;e<=87;e++)I[e]=xc;I[88]=wc;I[89]=bc;I[90]=Ec;I[91]=Sc;I[92]=G;I[93]=G;I[94]=G;I[95]=$n("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)I[e]=Ac;I[120]=vc;I[121]=Cc;I[122]=Tc;I[123]=Bc;I[124]=G;I[125]=G;I[126]=G;I[127]=$n("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)I[e]=_c;I[152]=Uc;I[153]=Dc;I[154]=Rc;I[155]=Nc;I[156]=G;I[157]=G;I[158]=G;I[159]=Lc;for(let e=160;e<=183;e++)I[e]=Pc;I[184]=kc;I[185]=Kc;I[186]=Oc;I[187]=Mc;I[188]=G;I[189]=G;I[190]=G;I[191]=Fc;for(let e=192;e<=215;e++)I[e]=Vc;I[216]=Hc;I[217]=qc;I[218]=zc;I[219]=$c;I[220]=G;I[221]=G;I[222]=G;I[223]=G;for(let e=224;e<=243;e++)I[e]=$n("simple values are not supported");I[244]=G;I[245]=G;I[246]=G;I[247]=Gc;I[248]=$n("simple values are not supported");I[249]=jc;I[250]=Yc;I[251]=Wc;I[252]=G;I[253]=G;I[254]=G;I[255]=Zc;var $t=[];for(let e=0;e<24;e++)$t[e]=new N(p.uint,e,1);for(let e=-1;e>=-24;e--)$t[31-e]=new N(p.negint,e,1);$t[64]=new N(p.bytes,new Uint8Array(0),1);$t[96]=new N(p.string,"",1);$t[128]=new N(p.array,0,1);$t[160]=new N(p.map,0,1);$t[244]=new N(p.false,!1,1);$t[245]=new N(p.true,!0,1);$t[246]=new N(p.null,null,1);function eu(e){switch(e.type){case p.false:return Wt([244]);case p.true:return Wt([245]);case p.null:return Wt([246]);case p.bytes:return e.value.length?void 0:Wt([64]);case p.string:return e.value===""?Wt([96]):void 0;case p.array:return e.value===0?Wt([128]):void 0;case p.map:return e.value===0?Wt([160]):void 0;case p.uint:return e.value<24?Wt([Number(e.value)]):void 0;case p.negint:if(e.value>=-24)return Wt([31-Number(e.value)])}}var Zd={float64:!1,mapSorter:Wd,quickEncodeToken:eu};function jd(){let e=[];return e[p.uint.major]=Pt,e[p.negint.major]=Mn,e[p.bytes.major]=dr,e[p.string.major]=Ic,e[p.array.major]=Vn,e[p.map.major]=Hn,e[p.tag.major]=qn,e[p.float.major]=zn,e}var ru=jd(),qi=new qr,Zn=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Oi} object contains circular references`);return new e(r,t)}},De={null:new N(p.null,null),undefined:new N(p.undefined,void 0),true:new N(p.true,!0),false:new N(p.false,!1),emptyArray:new N(p.array,0),emptyMap:new N(p.map,0)},Re={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new N(p.float,e):e>=0?new N(p.uint,e):new N(p.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new N(p.uint,e):new N(p.negint,e)},Uint8Array(e,t,r,n){return new N(p.bytes,e)},string(e,t,r,n){return new N(p.string,e)},boolean(e,t,r,n){return e?De.true:De.false},null(e,t,r,n){return De.null},undefined(e,t,r,n){return De.undefined},ArrayBuffer(e,t,r,n){return new N(p.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new N(p.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[De.emptyArray,new N(p.break)]:De.emptyArray;n=Zn.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Gn(s,r,n);return r.addBreakTokens?[new N(p.array,e.length),o,new N(p.break)]:[new N(p.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[De.emptyMap,new N(p.break)]:De.emptyMap;n=Zn.createCheck(n,e);let a=[],c=0;for(let f of i)a[c++]=[Gn(f,r,n),Gn(o?e.get(f):e[f],r,n)];return Yd(a,r),r.addBreakTokens?[new N(p.map,s),a,new N(p.break)]:[new N(p.map,s),a]}};Re.Map=Re.Object;Re.Buffer=Re.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Re[`${e}Array`]=Re.DataView;function Gn(e,t={},r){let n=tc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Re[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Re[n];if(!i)throw new Error(`${Oi} unsupported type: ${n}`);return i(e,n,t,r)}function Yd(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Wd(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=ru[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function nu(e,t,r,n){if(Array.isArray(t))for(let o of t)nu(e,o,r,n);else r[t.type.major](e,t,n)}function Xd(e,t,r){let n=Gn(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new qr(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ki(a.chunks[0])}}return qi.reset(),nu(qi,n,t,r),qi.toBytes(!0)}function zi(e,t){return t=Object.assign({},Zd,t),Xd(e,ru,t)}var Jd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},jn=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=$t[t];if(r===void 0){let n=I[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Zr=Symbol.for("DONE"),Yn=Symbol.for("BREAK");function Qd(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=mr(t,r);if(i===Yn){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===Zr)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function th(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=mr(t,r);if(a===Yn){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(a===Zr)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${F} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${F} found repeat map key "${a}"`);let c=mr(t,r);if(c===Zr)throw new Error(`${F} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function mr(e,t){if(e.done())return Zr;let r=e.next();if(r.type===p.break)return Yn;if(r.type.terminal)return r.value;if(r.type===p.array)return Qd(r,e,t);if(r.type===p.map)return th(r,e,t);if(r.type===p.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=mr(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function ou(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},Jd,t);let r=t.tokenizer||new jn(e,t),n=mr(r,t);if(n===Zr)throw new Error(`${F} did not find any content to decode`);if(n===Yn)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function $i(e,t){let[r,n]=ou(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var rh=me("ipns:utils"),iu=$("/ipns/"),nh=114,oh=0,ih=18;function jr(e){let t;if(e.pubKey!=null)try{t=Ya(e.pubKey)}catch(r){throw rh.error(r),r}if(t!=null)return t}function su(e,t,r){let n=$(t);return ge([e,r,n])}function Xn(e){let t=$("ipns-signature:");return ge([t,e])}function Jn(e){return"signatureV1"in e?ht.encode({value:$(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:$(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):ht.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Xt(e){let t=ht.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new qt("Missing data or signatureV2");let r=uu(t.data),n=sh(r.Value),o=j(r.Validity);if(t.value!=null&&t.signatureV1!=null)return ah(t),{value:n,validityType:ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Ze(e){return ge([iu,e.bytes])}function au(e){let t=Qt(e.slice(iu.length));if(!Wn(t,oh)&&!Wn(t,ih))throw new We("Multihash in IPNS key was not identity or sha2-256");return t}function cu(e,t,r,n,o){let i;if(t===ht.ValidityType.EOL)i=0;else throw new $e("The validity type is unsupported");return zi({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function uu(e){let t=$i(e);if(t.ValidityType===0)t.ValidityType=ht.ValidityType.EOL;else throw new $e("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function sh(e){let t=j(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${X.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(t).toV1().toString()}`}catch{}throw new Vr("Value must be a valid content path starting with /")}function fu(e){if(e!=null){let t=fh(e);if(t!=null)return t.code===nh?`/ipns/${t.toString(Ot)}`:`/ipfs/${t.toV1().toString()}`;if(ch(e))return`/ipns/${Ot.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new Vr("Value must be a valid content path starting with /")}function ah(e){if(e.data==null)throw new Kn("Record data is missing");let t=uu(e.data);if(!nt(t.Value,e.value??new Uint8Array(0)))throw new qt('Field "value" did not match between protobuf and CBOR');if(!nt(t.Validity,e.validity??new Uint8Array(0)))throw new qt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new qt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new qt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new qt('Field "ttl" did not match between protobuf and CBOR')}function ch(e){return e.bytes instanceof Uint8Array}function uh(e){return typeof e?.toCID=="function"}function fh(e){if(uh(e))return e.toCID();try{return X.parse(e)}catch{}return X.asCID(e)}function Wn(e,t){return e.code===t}var lh=me("ipns"),du=5*60*1e9,dh="/ipns/",sw=dh.length,hu={v1Compatible:!0,ttlNs:du};async function pu(e,t,r,n,o=hu){let i=new lu.default(Date.now()+Number(n)),s=ht.ValidityType.EOL,a=BigInt(o.ttlNs??du);return hh(e,t,r,s,i.toString(),a,o)}var hh=async(e,t,r,n,o,i,s=hu)=>{r=BigInt(r);let a=$(o),c=fu(t),f=$(c),u=cu(f,n,a,r,i),l=Xn(u),d=await e.sign(l),T;if(e.type==="RSA"&&(T=we(e.publicKey)),s.v1Compatible===!0){let v=await ph(e,f,n,a),y={value:c,signatureV1:v,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:d,data:u};return T!=null&&(y.pubKey=T),y}else{let v={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:d,data:u};return T!=null&&(v.pubKey=T),v}},ph=async(e,t,r,n)=>{try{let o=su(t,r,n);return await e.sign(o)}catch(o){throw lh.error("record signature creation failed",o),new Ln("Record signature creation failed")}};var Gi=Jr(Nn(),1);function Qn(e,t){let r=t.map((n,o)=>({record:Xt(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===ht.ValidityType.EOL&&o.record.validityType===ht.ValidityType.EOL){let a=Gi.default.fromString(n.record.validity).toDate(),c=Gi.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var mu=Jr(Nn(),1);var to=me("ipns:validator"),mh=1024*10,yh=async(e,t)=>{let r=Xt(t),n;try{let o=Xn(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw to.error("record signature verification failed"),new qt("Record signature verification failed");if(r.validityType===ht.ValidityType.EOL){if(mu.default.fromString(r.validity).toDate().getTime()<Date.now())throw to.error("record has expired"),new Pn("record has expired")}else if(r.validityType!=null)throw to.error("the validity type is unsupported"),new $e("The validity type is unsupported");to("ipns record for %s is valid",r.value)};async function Yr(e,t){if(t.byteLength>mh)throw new kn("The record is too large");let r=au(e),n;Wn(r,0)&&(n=Bn(r));let o=Xt(t),i=jr(o)??n;if(i==null)throw new Hr("Could not extract public key from IPNS record or routing key");let s=Ze(i.toMultihash());if(!nt(s,e))throw new Hr("Embedded public key did not match routing key");await yh(i,t)}var gt=class extends Event{type;detail;constructor(t,r){super(t),this.type=t,this.detail=r}};var wh=Jr(gu(),1);var le;(function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"})(le||(le={}));var eo=class extends Error{static name="DNSLinkNotFoundError";constructor(t="DNSLink not found"){super(t),this.name="DNSLinkNotFoundError"}},ro=class extends Error{static name="RecordsFailedValidationError";constructor(t="Records failed validation"){super(t),this.name="RecordsFailedValidationError"}},no=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(t="Unsupported multibase prefix"){super(t),this.name="UnsupportedMultibasePrefixError"}},oo=class extends Error{static name="UnsupportedMultihashCodecError";constructor(t="Unsupported multihash codec"){super(t),this.name="UnsupportedMultihashCodecError"}},io=class extends Error{static name="InvalidValueError";constructor(t="Invalid value"){super(t),this.name="InvalidValueError"}};var bh=32;async function xu(e,t,r,n,o={}){if(t===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",e);let s=((await r.query(e,{...o,types:[le.TXT]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,e);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,d,...T]=u.split("/");if(l==="ipfs")try{return{value:`/ipfs/${X.parse(d)}${T.length>0?`/${T.join("/")}`:""}`,answer:f}}catch{}else if(l==="ipns"){try{let v;return d.charAt(0)==="1"||d.charAt(0)==="Q"?v=Dn(d):v=Pi(X.parse(d)),{value:`/ipns/${v}${T.length>0?`/${T.join("/")}`:""}`,answer:f}}catch{}return await so(d,t-1,r,n,o)}else{if(l==="dnslink")return await so(d,t-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,e);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",e,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",e);let c=((await r.query(e,{...o,types:[le.CNAME]}))?.Answer??[]).sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,e);for(let f of c)try{return await so(f.data,t-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",e,f.data,u)}throw new eo(`No DNSLink records found for domain: ${e}`)}async function so(e,t,r,n,o={}){if(t===0)throw new Error("recursion limit exceeded");e.startsWith("_dnslink.")||(e=`_dnslink.${e}`);try{return await xu(e,t,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ENODATA"&&i.name!=="DNSLinkNotFoundError"&&i.name!=="NotFoundError")throw i;return e.startsWith("_dnslink.")?e=e.replace("_dnslink.",""):e=`_dnslink.${e}`,xu(e,t,r,n,o)}}async function wu(e,t,r,n={}){return so(e,n.maxRecursiveDepth??bh,t,r,n)}var Zi=class{routing;constructor(t){this.routing=t}async put(t,r,n={}){try{await this.routing.put(t,r,n)}catch(o){throw n.onProgress?.(new gt("ipns:routing:helia:error",o)),o}}async get(t,r={}){try{return await this.routing.get(t,r)}catch(n){throw r.onProgress?.(new gt("ipns:routing:helia:error",n)),n}}};function bu(e){return new Zi(e)}var Wr;(function(e){let t;e.codec=()=>(t==null&&(t=_e((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Lt(0),value:Lt(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Ie(r,e.codec()),e.decode=(r,n)=>Be(r,e.codec(),n)})(Wr||(Wr={}));function Eu(e){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),n=String(e.getUTCDate()).padStart(2,"0"),o=String(e.getUTCHours()).padStart(2,"0"),i=String(e.getUTCMinutes()).padStart(2,"0"),s=String(e.getUTCSeconds()).padStart(2,"0"),a=e.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${t}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function Su(e){let t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var je=class e{key;value;timeReceived;constructor(t,r,n){if(!(t instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=t,this.value=r,this.timeReceived=n}serialize(){return Wr.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:Eu(this.timeReceived)}}static deserialize(t){let r=Wr.decode(t);return new e(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(t){let r=Su(t.timeReceived);if(t.key==null)throw new Error("key missing from deserialized object");if(t.value==null)throw new Error("value missing from deserialized object");return new e(t.key,t.value,r)}};var Au;(function(e){e[e.SEND_QUERY=0]="SEND_QUERY",e[e.PEER_RESPONSE=1]="PEER_RESPONSE",e[e.FINAL_PEER=2]="FINAL_PEER",e[e.QUERY_ERROR=3]="QUERY_ERROR",e[e.PROVIDER=4]="PROVIDER",e[e.VALUE=5]="VALUE",e[e.ADD_PEER=6]="ADD_PEER",e[e.DIAL_PEER=7]="DIAL_PEER"})(Au||(Au={}));function ao(e){return new Fr("/dht/record/"+j(e,"base32"),!1)}function vu(e){return{async put(t,r,n={}){try{let o=ao(t);try{let s=await e.get(o),a=je.deserialize(s);if(nt(a.value,r))return}catch(s){if(s.name!=="NotFoundError")throw s}let i=new je(t,r,new Date);n.onProgress?.(new gt("ipns:routing:datastore:put")),await e.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new gt("ipns:routing:datastore:error",o)),o}},async get(t,r={}){try{let n=ao(t);r.onProgress?.(new gt("ipns:routing:datastore:get"));let o=await e.get(n,r),i=je.deserialize(o);return{record:i.value,created:i.timeReceived}}catch(n){throw r.onProgress?.(new gt("ipns:routing:datastore:error",n)),n}},async has(t,r={}){let n=ao(t);return e.has(n,r)},async delete(t,r){let n=ao(t);return e.delete(n,r)}}}var ji="/ipns/";function Yi(e,t){return e.code===t}var de=me("helia:ipns"),Bu=60*1e3,Iu=60*Bu,vh=48*Iu,Wi=23*Iu,Cu=BigInt(Bu)*5000000n,Tu={[Ot.prefix]:Ot,[W.prefix]:W},Xi=class{routers;localStore;timeout;dns;log;constructor(t,r=[]){this.routers=[bu(t.routing),...r],this.localStore=vu(t.datastore),this.dns=t.dns,this.log=t.logger.forComponent("helia:ipns")}async publish(t,r,n={}){try{let o=1n,i=Ze(t.publicKey.toMultihash());if(await this.localStore.has(i,n)){let{record:f}=await this.localStore.get(i,n);o=Xt(f).sequence+1n}let s=n.ttl!=null?BigInt(n.ttl)*1000000n:Cu,a=await pu(t,r,o,n.lifetime??vh,{...n,ttlNs:s}),c=Jn(a);return await this.localStore.put(i,c,n),n.offline!==!0&&await Promise.all(this.routers.map(async f=>{await f.put(i,c,n)})),a}catch(o){throw n.onProgress?.(new gt("ipns:publish:error",o)),o}}async resolve(t,r={}){let n=es(t)?t.toMultihash():t,o=Ze(n),i=await this.#e(o,r);return{...await this.#t(i.value,r),record:i}}async resolveDNSLink(t,r={}){let n=await wu(t,this.dns,this.log,r);return{...await this.#t(n.value,r),answer:n.answer}}republish(t={}){if(this.timeout!=null)throw new Error("Republish is already running");t.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();t.onProgress?.(new gt("ipns:republish:start"));let i=Date.now()-n,s=Wi-i;s<0&&(s=t.interval??Wi),setTimeout(()=>{r().catch(a=>{de.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{de.error("error republishing",n)})},t.interval??Wi)}async#t(t,r={}){let n=t.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=W.decode(`z${i}`);else if(Tu[s]!=null)a=Tu[s].decode(i);else throw new no(`Unsupported multibase prefix "${s}"`);let c;try{c=Qt(a)}catch{c=X.decode(a).multihash}if(!Yi(c,0)&&!Yi(c,18))throw new oo(`Unsupported multihash codec "${c.code}"`);let{cid:f}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:f,path:u}}else if(o==="ipfs"){let i=X.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){de.error("error parsing ipfs path",o)}throw de.error("invalid ipfs path %s",t),new io("Invalid value")}async#e(t,r={}){let n=[];if(await this.localStore.has(t,r))if(de("record is present in the cache"),r.nocache!==!0)try{let{record:a,created:c}=await this.localStore.get(t,r);this.log("record retrieved from cache"),await Yr(t,a),this.log("record was valid");let f=Xt(a),u=Number((f.ttl??Cu)/1000000n);if(c.getTime()+u>Date.now())return this.log("record TTL was valid"),f;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),f;this.log("record TTL has been reached, searching routing for updates"),n.push(a)}catch(a){this.log("cached record was invalid",a),await this.localStore.delete(t,r)}else de("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new gr("Record was not present in the cache or has expired");de("did not have record locally");let i=0;if(await Promise.all(this.routers.map(async a=>{let c;try{c=await a.get(t,{...r,validate:!1})}catch(f){de.error("error finding IPNS record",f);return}try{await Yr(t,c),n.push(c)}catch(f){i++,de.error("error finding IPNS record",f)}})),n.length===0)throw i>0?new ro(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new gr("Could not find record for routing key");let s=n[Qn(t,n)];return await this.localStore.put(t,s,r),Xt(s)}async republishRecord(t,r,n={}){let o;try{if(o=jr(r)?.toMultihash(),o==null)if(typeof t=="string"){t.startsWith(ji)&&(t=t.slice(ji.length));try{o=Dn(t).toMultihash()}catch(a){throw new Error(`Invalid string key: ${a.message}`)}}else o=t;if(o==null)throw new Error("No public key multihash found to determine the routing key");let i=Ze(o),s=Jn(r);await Yr(i,s),await this.localStore.put(i,s,n),n.offline!==!0&&await Promise.all(this.routers.map(async a=>{await a.put(i,s,n)}))}catch(i){throw n.onProgress?.(new gt("ipns:republish:error",{key:o,record:r,err:i})),i}}};function Ch(e,{routers:t=[]}={}){return new Xi(e,t)}return Ou(Th);})();
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
@noble/hashes/esm/utils.js:
|