@helia/routers 3.1.3 → 4.0.0-354db660

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,30 +1,30 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaRouters=(()=>{var il=Object.create;var Cn=Object.defineProperty;var sl=Object.getOwnPropertyDescriptor;var al=Object.getOwnPropertyNames;var cl=Object.getPrototypeOf,ul=Object.prototype.hasOwnProperty;var ha=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Et=(e,t)=>{for(var r in t)Cn(e,r,{get:t[r],enumerable:!0})},pa=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of al(t))!ul.call(e,o)&&o!==r&&Cn(e,o,{get:()=>t[o],enumerable:!(n=sl(t,o))||n.enumerable});return e};var Ho=(e,t,r)=>(r=e!=null?il(cl(e)):{},pa(t||!e||!e.__esModule?Cn(r,"default",{value:e,enumerable:!0}):r,e)),fl=e=>pa(Cn({},"__esModule",{value:!0}),e);var $s=ha((e2,Vs)=>{var t2=function(){typeof Vs<"u"&&(Vs.exports=w);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",u=Math.trunc||function(I){var A=I-I%1;return A==0&&(I<0||I===0&&1/I!=1/0)?-0:A},f=w.prototype,l=(w.fromDate=function(I){return new w(+I)},w.fromInt64BE=L(0,1,2,3,0,4),w.fromInt64LE=L(3,2,1,0,4,0),w.fromString=function(p){var A,m=new w,p=(p+="").replace(/^\s*[+\-]?\d+/,function(v){var v=+v,N=1970+(v-1970)%400;return m.year=v-N,N}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(y,v,N){return v<0&&(N*=-1),A=6e4*(60*+v+ +N),""}).replace(/\.\d+$/,function(y){return m.nano=+(y+c).substr(1,9),""}).split(/\D+/);if(1<p.length?p[1]--:p[1]=0,m.time=A=Date.UTC.apply(Date,p)-(A||0),isNaN(A))throw new TypeError("Invalid Date");return x(m)},w.fromTimeT=function(I){return R(I,0)},f.year=0,f.time=0,f.nano=0,f.addNano=function(I){return this.nano+=+I||0,this},f.getNano=function(){var I=x(this);return(I.time%1e3*a+ +I.nano+1e9)%1e9},f.getTimeT=function(){var A=x(this),I=Math.floor(A.time/1e3),A=A.year;return A&&(I+=A*r*e/t),I},f.getYear=function(){return this.toDate().getUTCFullYear()+this.year},f.toDate=function(){return T(x(this).time)},f.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},f.toString=function(I){var A=this,m=A.toDate(),p={H:function(){return _(m.getUTCHours())},L:function(){return k(m.getUTCMilliseconds(),3)},M:function(){return _(m.getUTCMinutes())},N:function(){return k(A.getNano(),9)},S:function(){return _(m.getUTCSeconds())},Y:function(){var y=A.getYear();return 999999<y?"+"+y:9999<y?"+"+k(y,6):0<=y?k(y,4):-999999<=y?"-"+k(-y,6):y},a:function(){return h[m.getUTCDay()]},b:function(){return d[m.getUTCMonth()]},d:function(){return _(m.getUTCDate())},e:function(){return function(y){return(9<y?"":" ")+(0|y)}(m.getUTCDate())},m:function(){return _(m.getUTCMonth()+1)}};return function y(v){return v.replace(/%./g,function(N){var g=N[1],D=S[g],g=p[g];return D?y(D):g?g():N})}(I||l)},f.writeInt64BE=P(0,1,2,3,0,4),f.writeInt64LE=P(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"],h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],S={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return w;function w(I,A,m){var p=this;if(!(p instanceof w))return new w(I,A,m);p.time=+I||0,p.nano=+A||0,p.year=+m||0,x(p)}function x(I){var A,m,p,y=I.year,v=I.time,N=I.nano,D=((N<0||a<=N)&&(N-=(m=Math.floor(N/a))*a,v+=m,m=1),y%t);return(v<-i||i<v||D)&&((A=u(v/o))&&(y+=A*t,v-=A*o),(p=T(v)).setUTCFullYear(D+p.getUTCFullYear()),p=(v=+p)+(A=u((y-=D)/t))*o,A&&-i<=p&&p<=i&&(y-=A*t,v=p),m=1),m&&(I.year=y,I.time=v,I.nano=N),I}function T(I){var A=new Date(0);return A.setTime(I),A}function R(y,p){y=+y||0;var m=u((p=(p|0)*s)/n)+u(y/n),p=p%n+y%n,y=u(p/n);return y&&(m+=y,p-=y*n),new w(1e3*p,0,m*t)}function P(I,A,m,p,y,v){return function(D,g){var C=x(this);D=D||new Array(8),K(D,g|=0);var U=Math.floor(C.time/1e3),C=C.year*(r*e/t),b=u(C/s)+u(U/s),C=C%s+U%s,U=Math.floor(C/s);return U&&(b+=U,C-=U*s),N(D,g+y,b),N(D,g+v,C),D};function N(D,g,b){D[g+I]=b>>24&255,D[g+A]=b>>16&255,D[g+m]=b>>8&255,D[g+p]=255&b}}function L(I,A,m,p,y,v){return function(D,g){K(D,g|=0);var b=N(D,g+y);return R(N(D,g+v),b)};function N(D,g){return 16777216*D[g+I]+(D[g+A]<<16|D[g+m]<<8|D[g+p])}}function K(I,A){if(I=I&&I.length,I==null)throw new TypeError("Invalid Buffer");if(I<A+8)throw new RangeError("Out of range")}function _(I){return(9<I?"":"0")+(0|I)}function k(I,A){return(c+(0|I)).substr(-A)}}()});var Mf=ha((zE,Ws)=>{"use strict";var K0=Object.prototype.hasOwnProperty,bt="~";function vn(){}Object.create&&(vn.prototype=Object.create(null),new vn().__proto__||(bt=!1));function F0(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Ff(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new F0(r,n||e,o),s=bt?bt+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function Lo(e,t){--e._eventsCount===0?e._events=new vn:delete e._events[t]}function xt(){this._events=new vn,this._eventsCount=0}xt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)K0.call(r,n)&&t.push(bt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};xt.prototype.listeners=function(t){var r=bt?bt+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};xt.prototype.listenerCount=function(t){var r=bt?bt+t:t,n=this._events[r];return n?n.fn?1:n.length:0};xt.prototype.emit=function(t,r,n,o,i,s){var a=bt?bt+t:t;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,f,l;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(l=1,f=new Array(u-1);l<u;l++)f[l-1]=arguments[l];c.fn.apply(c.context,f)}else{var d=c.length,h;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,r);break;case 3:c[l].fn.call(c[l].context,r,n);break;case 4:c[l].fn.call(c[l].context,r,n,o);break;default:if(!f)for(h=1,f=new Array(u-1);h<u;h++)f[h-1]=arguments[h];c[l].fn.apply(c[l].context,f)}}return!0};xt.prototype.on=function(t,r,n){return Ff(this,t,r,n,!1)};xt.prototype.once=function(t,r,n){return Ff(this,t,r,n,!0)};xt.prototype.removeListener=function(t,r,n,o){var i=bt?bt+t:t;if(!this._events[i])return this;if(!r)return Lo(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Lo(this,i);else{for(var a=0,c=[],u=s.length;a<u;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Lo(this,i)}return this};xt.prototype.removeAllListeners=function(t){var r;return t?(r=bt?bt+t:t,this._events[r]&&Lo(this,r)):(this._events=new vn,this._eventsCount=0),this};xt.prototype.off=xt.prototype.removeListener;xt.prototype.addListener=xt.prototype.on;xt.prefixed=bt;xt.EventEmitter=xt;typeof Ws<"u"&&(Ws.exports=xt)});var am={};Et(am,{delegatedHTTPRouting:()=>Yf,delegatedHTTPRoutingDefaults:()=>$o,httpGatewayRouting:()=>nl,libp2pRouting:()=>ol});var ma=Symbol.for("@libp2p/content-routing");var zo=Symbol.for("@libp2p/peer-id");var ya=Symbol.for("@libp2p/peer-routing");var it=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},rr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var St=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Bn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},nr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var or=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Wo={};Et(Wo,{base32:()=>Qt,base32hex:()=>bl,base32hexpad:()=>Sl,base32hexpadupper:()=>vl,base32hexupper:()=>El,base32pad:()=>xl,base32padupper:()=>wl,base32upper:()=>gl,base32z:()=>Al});var hm=new Uint8Array(0);function ga(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 se(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 xa(e){return new TextEncoder().encode(e)}function wa(e){return new TextDecoder().decode(e)}function ll(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),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var w=0,x=0,T=0,R=S.length;T!==R&&S[T]===0;)T++,w++;for(var P=(R-T)*f+1>>>0,L=new Uint8Array(P);T!==R;){for(var K=S[T],_=0,k=P-1;(K!==0||_<x)&&k!==-1;k--,_++)K+=256*L[k]>>>0,L[k]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");x=_,T++}for(var I=P-x;I!==P&&L[I]===0;)I++;for(var A=c.repeat(w);I<P;++I)A+=e.charAt(L[I]);return A}function d(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var w=0;if(S[w]!==" "){for(var x=0,T=0;S[w]===c;)x++,w++;for(var R=(S.length-w)*u+1>>>0,P=new Uint8Array(R);S[w];){var L=r[S.charCodeAt(w)];if(L===255)return;for(var K=0,_=R-1;(L!==0||K<T)&&_!==-1;_--,K++)L+=a*P[_]>>>0,P[_]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");T=K,w++}if(S[w]!==" "){for(var k=R-T;k!==R&&P[k]===0;)k++;for(var I=new Uint8Array(x+(R-k)),A=x;k!==R;)I[A++]=P[k++];return I}}}function h(S){var w=d(S);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:h}}var dl=ll,hl=dl,Ea=hl;var jo=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")}},Go=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 Sa(this,t)}},Zo=class{decoders;constructor(t){this.decoders=t}or(t){return Sa(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 Sa(e,t){return new Zo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Yo=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 jo(t,r,n),this.decoder=new Go(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ir({name:e,prefix:t,encode:r,decode:n}){return new Yo(e,t,r,n)}function Ie({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ea(r,e);return ir({prefix:t,name:e,encode:n,decode:i=>se(o(i))})}function pl(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function ml(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 yl(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function et({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=yl(n);return ir({prefix:t,name:e,encode(i){return ml(i,n,r)},decode(i){return pl(i,o,r,e)}})}var Qt=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gl=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xl=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wl=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bl=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),El=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sl=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vl=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Al=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xo={};Et(Xo,{base58btc:()=>W,base58flickr:()=>Il});var W=Ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Il=Ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ti={};Et(ti,{base64:()=>Jo,base64pad:()=>Tl,base64url:()=>Qo,base64urlpad:()=>Cl});var Jo=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Tl=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Qo=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Cl=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Bl(e,t){try{if(typeof e=="string"&&e.length>0)return _l(e);if(typeof e=="number"&&isFinite(e))return t?.long?Dl(e):Pl(e);throw new Error("Value is not a string or number.")}catch(r){let n=Rl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function _l(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 Pn=Bl;function Pl(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 Dl(e){let t=Math.abs(e);return t>=864e5?_n(e,t,864e5,"day"):t>=36e5?_n(e,t,36e5,"hour"):t>=6e4?_n(e,t,6e4,"minute"):t>=1e3?_n(e,t,1e3,"second"):`${e} ms`}function _n(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Rl(e){return typeof e=="object"&&e!==null&&"message"in e}function ei(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Pn,r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let l=0;for(let d=0;d<f.length;d++)l=(l<<5)-l+f.charCodeAt(d),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(f){let l,d=null,h,S;function w(...x){if(!w.enabled)return;let T=w,R=Number(new Date),P=R-(l||R);T.diff=P,T.prev=l,T.curr=R,l=R,x[0]=r.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let L=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(_,k)=>{if(_==="%%")return"%";L++;let I=r.formatters[k];if(typeof I=="function"){let A=x[L];_=I.call(T,A),x.splice(L,1),L--}return _}),r.formatArgs.call(T,x),(T.log||r.log).apply(T,x)}return w.namespace=f,w.useColors=r.useColors(),w.color=r.selectColor(f),w.extend=n,w.destroy=r.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==r.namespaces&&(h=r.namespaces,S=r.enabled(f)),S),set:x=>{d=x}}),typeof r.init=="function"&&r.init(w),w}function n(f,l){let d=r(this.namespace+(typeof l>"u"?":":l)+f);return d.log=this.log,d}function o(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let l,d=(typeof f=="string"?f:"").split(/[\s,]+/),h=d.length;for(l=0;l<h;l++)d[l]&&(f=d[l].replace(/\*/g,".*?"),f[0]==="-"?r.skips.push(new RegExp("^"+f.substr(1)+"$")):r.names.push(new RegExp("^"+f+"$")))}function i(){let f=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),f}function s(f){if(f[f.length-1]==="*")return!0;let l,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(f))return!1;for(l=0,d=r.names.length;l<d;l++)if(r.names[l].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack??f.message:f}function u(){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 Dn=Fl(),Nl=["#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 Ul(){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 Ll(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Pn(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 Ol=console.debug??console.log??(()=>{});function kl(e){try{e?Dn?.setItem("debug",e):Dn?.removeItem("debug")}catch{}}function Kl(){let e;try{e=Dn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Fl(){try{return localStorage}catch{}}function Ml(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var va=ei({formatArgs:Ll,save:kl,load:Kl,useColors:Ul,setupFormatters:Ml,colors:Nl,storage:Dn,log:Ol});var vt=va;vt.formatters.b=e=>e==null?"undefined":W.baseEncode(e);vt.formatters.t=e=>e==null?"undefined":Qt.baseEncode(e);vt.formatters.m=e=>e==null?"undefined":Jo.baseEncode(e);vt.formatters.p=e=>e==null?"undefined":e.toString();vt.formatters.c=e=>e==null?"undefined":e.toString();vt.formatters.k=e=>e==null?"undefined":e.toString();vt.formatters.a=e=>e==null?"undefined":e.toString();vt.formatters.e=e=>e==null?"undefined":Aa(e.stack)??Aa(e.message)??e.toString();function Vl(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 Te(e){let t=Vl(`${e}:trace`);return vt.enabled(`${e}:trace`)&&vt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=vt(`${e}:trace`)),Object.assign(vt(e),{error:vt(`${e}:error`),trace:t})}function Aa(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var ri={};Et(ri,{base36:()=>sr,base36upper:()=>$l});var sr=Ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$l=Ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ql=Ca,Ia=128,Hl=127,zl=~Hl,jl=Math.pow(2,31);function Ca(e,t,r){t=t||[],r=r||0;for(var n=r;e>=jl;)t[r++]=e&255|Ia,e/=128;for(;e&zl;)t[r++]=e&255|Ia,e>>>=7;return t[r]=e|0,Ca.bytes=r-n+1,t}var Gl=ni,Zl=128,Ta=127;function ni(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw ni.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Ta)<<o:(s&Ta)*Math.pow(2,o),o+=7}while(s>=Zl);return ni.bytes=i-n,r}var Yl=Math.pow(2,7),Wl=Math.pow(2,14),Xl=Math.pow(2,21),Jl=Math.pow(2,28),Ql=Math.pow(2,35),td=Math.pow(2,42),ed=Math.pow(2,49),rd=Math.pow(2,56),nd=Math.pow(2,63),od=function(e){return e<Yl?1:e<Wl?2:e<Xl?3:e<Jl?4:e<Ql?5:e<td?6:e<ed?7:e<rd?8:e<nd?9:10},id={encode:ql,decode:Gl,encodingLength:od},sd=id,Fr=sd;function Mr(e,t=0){return[Fr.decode(e,t),Fr.decode.bytes]}function ar(e,t,r=0){return Fr.encode(e,t,r),t}function cr(e){return Fr.encodingLength(e)}function Ht(e,t){let r=t.byteLength,n=cr(e),o=n+cr(r),i=new Uint8Array(o+r);return ar(e,i,0),ar(r,i,n),i.set(t,o),new ur(e,r,t,i)}function Me(e){let t=se(e),[r,n]=Mr(t),[o,i]=Mr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ur(r,o,s,t)}function Ba(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ga(e.bytes,r.bytes)}}var ur=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function _a(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return cd(r,oi(e),t??W.encoder);default:return ud(r,oi(e),t??Qt.encoder)}}var Pa=new WeakMap;function oi(e){let t=Pa.get(e);if(t==null){let r=new Map;return Pa.set(e,r),r}return t}var z=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!==Vr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==fd)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=Ht(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&&Ba(t.multihash,n.multihash)}toString(t){return _a(this,t)}toJSON(){return{"/":_a(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??Da(n,o,i.bytes))}else if(r[ld]===!0){let{version:n,multihash:o,code:i}=r,s=Me(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!==Vr)throw new Error(`Version 0 CID must use dag-pb (code: ${Vr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Da(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Vr,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=se(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 ur(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]=Mr(t.subarray(r));return r+=d,l},o=n(),i=Vr;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(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=ad(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 oi(i).set(n,t),i}};function ad(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 Qt.prefix:{let r=t??Qt;return[Qt.prefix,r.decode(e)]}case sr.prefix:{let r=t??sr;return[sr.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 cd(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 ud(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 Vr=112,fd=18;function Da(e,t,r){let n=cr(e),o=n+cr(t),i=new Uint8Array(o+r.byteLength);return ar(e,i,0),ar(t,i,n),i.set(r,o),i}var ld=Symbol.for("@ipld/js-cid/CID");var ii={};Et(ii,{identity:()=>Bt});var Ra=0,dd="identity",Na=se;function hd(e){return Ht(Ra,Na(e))}var Bt={code:Ra,name:dd,encode:Na,digest:hd};function J(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 ae(e=0){return new Uint8Array(e)}function _t(e=0){return new Uint8Array(e)}function Ft(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=_t(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var La=Symbol.for("@achingbrain/uint8arraylist");function Ua(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 fr(e){return!!e?.[La]}var Pt=class e{bufs;length;[La]=!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(fr(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(fr(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=Ua(this.bufs,t);return r.buf[r.index]}set(t,r){let n=Ua(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(fr(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 Ft(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ft(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 u=t>=a&&t<c,f=r>a&&r<=c;if(u&&f){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(u){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(f){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(!fr(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,u=n.byteLength-1,f;for(let l=r;l<=c;l+=f){f=0;for(let d=u;d>=0;d--){let h=this.get(l+d);if(n[d]!==h){f=Math.max(1,d-a[h]);break}}if(f===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=_t(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=ae(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=ae(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=ae(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=_t(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=ae(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=ae(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=ae(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=ae(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=ae(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(!J(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 si={};Et(si,{base10:()=>pd});var pd=Ie({prefix:"9",name:"base10",alphabet:"0123456789"});var ai={};Et(ai,{base16:()=>md,base16upper:()=>yd});var md=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),yd=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ci={};Et(ci,{base2:()=>gd});var gd=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ui={};Et(ui,{base256emoji:()=>Sd});var Oa=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}"),xd=Oa.reduce((e,t,r)=>(e[r]=t,e),[]),wd=Oa.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function bd(e){return e.reduce((t,r)=>(t+=xd[r],t),"")}function Ed(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=wd[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Sd=ir({prefix:"\u{1F680}",name:"base256emoji",encode:bd,decode:Ed});var fi={};Et(fi,{base8:()=>vd});var vd=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var li={};Et(li,{identity:()=>Ad});var Ad=ir({prefix:"\0",name:"identity",encode:e=>wa(e),decode:e=>xa(e)});var uy=new TextEncoder,fy=new TextDecoder;var pi={};Et(pi,{sha256:()=>$r,sha512:()=>Cd});function hi({name:e,code:t,encode:r}){return new di(e,t,r)}var di=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?Ht(this.code,r):r.then(n=>Ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ka(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var $r=hi({name:"sha2-256",code:18,encode:Ka("SHA-256")}),Cd=hi({name:"sha2-512",code:19,encode:Ka("SHA-512")});var qr={...li,...ci,...fi,...si,...ai,...Wo,...ri,...Xo,...ti,...ui},Sy={...pi,...ii};function Ma(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Fa=Ma("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),mi=Ma("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=_t(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Bd={utf8:Fa,"utf-8":Fa,hex:qr.base16,latin1:mi,ascii:mi,binary:mi,...qr},Nn=Bd;function $(e,t="utf8"){let r=Nn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function H(e,t="utf8"){let r=Nn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var _d=parseInt("11111",2),yi=parseInt("10000000",2),Pd=parseInt("01111111",2),Va={0:Hr,1:Hr,2:Dd,3:Ud,4:Ld,5:Nd,6:Rd,16:Hr,22:Hr,48:Hr};function ce(e,t={offset:0}){let r=e[t.offset]&_d;if(t.offset++,Va[r]!=null)return Va[r](e,t);throw new Error("No decoder for tag "+r)}function zr(e,t){let r=0;if((e[t.offset]&yi)===yi){let n=e[t.offset]&Pd,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 Hr(e,t){zr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=ce(e,t);if(n===null)break;r.push(n)}return r}function Dd(e,t){let r=zr(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 Rd(e,t){let r=zr(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 u=e[t.offset];if(t.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function Nd(e,t){return t.offset++,null}function Ud(e,t){let r=zr(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 Ld(e,t){let r=zr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Od(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Pt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function gi(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Od(e.byteLength);return new Pt(Uint8Array.from([t.byteLength|yi]),t)}function At(e){let t=new Pt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Pt(Uint8Array.from([2]),gi(t),t)}function Un(e){let t=Uint8Array.from([0]),r=new Pt(t,e);return new Pt(Uint8Array.from([3]),gi(r),r)}function Ce(e,t=48){let r=new Pt;for(let n of e)r.append(n);return new Pt(Uint8Array.from([t]),gi(r),r)}async function $a(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),i}var kd=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Kd=Uint8Array.from([6,5,43,129,4,0,34]),Fd=Uint8Array.from([6,5,43,129,4,0,35]),Md={ext:!0,kty:"EC",crv:"P-256"},Vd={ext:!0,kty:"EC",crv:"P-384"},$d={ext:!0,kty:"EC",crv:"P-521"},xi=32,wi=48,bi=66;function Ei(e){let t=ce(e);return qa(t)}function qa(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===xi*2+1)return n=H(t.subarray(r,r+xi),"base64url"),o=H(t.subarray(r+xi),"base64url"),new lr({...Md,key_ops:["verify"],x:n,y:o});if(t.byteLength===wi*2+1)return n=H(t.subarray(r,r+wi),"base64url"),o=H(t.subarray(r+wi),"base64url"),new lr({...Vd,key_ops:["verify"],x:n,y:o});if(t.byteLength===bi*2+1)return n=H(t.subarray(r,r+bi),"base64url"),o=H(t.subarray(r+bi),"base64url"),new lr({...$d,key_ops:["verify"],x:n,y:o});throw new it(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ha(e){return Ce([At(Uint8Array.from([1])),Ce([qd(e.crv)],160),Ce([Un(new Pt(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function qd(e){if(e==="P-256")return kd;if(e==="P-384")return Kd;if(e==="P-521")return Fd;throw new it(`Invalid curve ${e}`)}var lr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ha(this.jwk)),this._raw}toMultihash(){return Bt.digest(dr(this))}toCID(){return z.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}async verify(t,r,n){return $a(this.jwk,r,t,n)}};var $e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function qe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function jr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!qe(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 Ln(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");jr(e.outputLen),jr(e.blockLen)}function pr(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 ja(e,t){rt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function fe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function On(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function zt(e,t){return e<<32-t|e>>>t}var Ga=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Hd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Mt(e){if(rt(e),Ga)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Hd[e[r]];return t}var ue={_0:48,_9:57,A:65,F:70,a:97,f:102};function za(e){if(e>=ue._0&&e<=ue._9)return e-ue._0;if(e>=ue.A&&e<=ue.F)return e-(ue.A-10);if(e>=ue.a&&e<=ue.f)return e-(ue.a-10)}function He(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ga)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=za(e.charCodeAt(i)),a=za(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 Si(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Gr(e){return typeof e=="string"&&(e=Si(e)),rt(e),e}function It(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];rt(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 hr=class{};function vi(e){let t=n=>e().update(Gr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Zr(e=32){if($e&&typeof $e.getRandomValues=="function")return $e.getRandomValues(new Uint8Array(e));if($e&&typeof $e.randomBytes=="function")return Uint8Array.from($e.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function zd(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,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}function Za(e,t,r){return e&t^~e&r}function Ya(e,t,r){return e&t^e&r^t&r}var Yr=class extends hr{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=On(this.buffer)}update(t){pr(this),t=Gr(t),rt(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=On(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){pr(this),ja(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,fe(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;zd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=On(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],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()}},le=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 kn=BigInt(4294967295),Wa=BigInt(32);function jd(e,t=!1){return t?{h:Number(e&kn),l:Number(e>>Wa&kn)}:{h:Number(e>>Wa&kn)|0,l:Number(e&kn)|0}}function Xa(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}=jd(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var Ai=(e,t,r)=>e>>>r,Ii=(e,t,r)=>e<<32-r|t>>>r,ze=(e,t,r)=>e>>>r|t<<32-r,je=(e,t,r)=>e<<32-r|t>>>r,Wr=(e,t,r)=>e<<64-r|t>>>r-32,Xr=(e,t,r)=>e>>>r-32|t<<64-r;function te(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ja=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Qa=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,tc=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ec=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,rc=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),nc=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Zd=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),Kn=class extends Yr{constructor(t=32){super(64,t,8,!1),this.A=le[0]|0,this.B=le[1]|0,this.C=le[2]|0,this.D=le[3]|0,this.E=le[4]|0,this.F=le[5]|0,this.G=le[6]|0,this.H=le[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],h=Be[l-2],S=zt(d,7)^zt(d,18)^d>>>3,w=zt(h,17)^zt(h,19)^h>>>10;Be[l]=w+Be[l-7]+S+Be[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let d=zt(a,6)^zt(a,11)^zt(a,25),h=f+d+Za(a,c,u)+Zd[l]+Be[l]|0,w=(zt(n,2)^zt(n,13)^zt(n,22))+Ya(n,o,i)|0;f=u,u=c,c=a,a=s+h|0,s=i,i=o,o=n,n=h+w|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,u=u+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,u,f)}roundClean(){fe(Be)}destroy(){this.set(0,0,0,0,0,0,0,0),fe(this.buffer)}};var oc=Xa(["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))),Yd=oc[0],Wd=oc[1],_e=new Uint32Array(80),Pe=new Uint32Array(80),Ti=class extends Yr{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:u,El:f,Fh:l,Fl:d,Gh:h,Gl:S,Hh:w,Hl:x}=this;return[t,r,n,o,i,s,a,c,u,f,l,d,h,S,w,x]}set(t,r,n,o,i,s,a,c,u,f,l,d,h,S,w,x){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=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=S|0,this.Hh=w|0,this.Hl=x|0}process(t,r){for(let P=0;P<16;P++,r+=4)_e[P]=t.getUint32(r),Pe[P]=t.getUint32(r+=4);for(let P=16;P<80;P++){let L=_e[P-15]|0,K=Pe[P-15]|0,_=ze(L,K,1)^ze(L,K,8)^Ai(L,K,7),k=je(L,K,1)^je(L,K,8)^Ii(L,K,7),I=_e[P-2]|0,A=Pe[P-2]|0,m=ze(I,A,19)^Wr(I,A,61)^Ai(I,A,6),p=je(I,A,19)^Xr(I,A,61)^Ii(I,A,6),y=tc(k,p,Pe[P-7],Pe[P-16]),v=ec(y,_,m,_e[P-7],_e[P-16]);_e[P]=v|0,Pe[P]=y|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:h,Fl:S,Gh:w,Gl:x,Hh:T,Hl:R}=this;for(let P=0;P<80;P++){let L=ze(l,d,14)^ze(l,d,18)^Wr(l,d,41),K=je(l,d,14)^je(l,d,18)^Xr(l,d,41),_=l&h^~l&w,k=d&S^~d&x,I=rc(R,K,k,Wd[P],Pe[P]),A=nc(I,T,L,_,Yd[P],_e[P]),m=I|0,p=ze(n,o,28)^Wr(n,o,34)^Wr(n,o,39),y=je(n,o,28)^Xr(n,o,34)^Xr(n,o,39),v=n&i^n&a^i&a,N=o&s^o&c^s&c;T=w|0,R=x|0,w=h|0,x=S|0,h=l|0,S=d|0,{h:l,l:d}=te(u|0,f|0,A|0,m|0),u=a|0,f=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let D=Ja(m,y,N);n=Qa(D,A,p,v),o=D|0}({h:n,l:o}=te(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=te(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=te(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=te(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=te(this.Eh|0,this.El|0,l|0,d|0),{h,l:S}=te(this.Fh|0,this.Fl|0,h|0,S|0),{h:w,l:x}=te(this.Gh|0,this.Gl|0,w|0,x|0),{h:T,l:R}=te(this.Hh|0,this.Hl|0,T|0,R|0),this.set(n,o,i,s,a,c,u,f,l,d,h,S,w,x,T,R)}roundClean(){fe(_e,Pe)}destroy(){fe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Fn=vi(()=>new Kn);var ic=vi(()=>new Ti);var _i=BigInt(0),Bi=BigInt(1);function de(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Jr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function sc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?_i:BigInt("0x"+e)}function mr(e){return sc(Mt(e))}function he(e){return rt(e),sc(Mt(Uint8Array.from(e).reverse()))}function Mn(e,t){return He(e.toString(16).padStart(t*2,"0"))}function pe(e,t){return Mn(e,t).reverse()}function Z(e,t,r){let n;if(typeof t=="string")try{n=He(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(qe(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 ac(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}var Ci=e=>typeof e=="bigint"&&_i<=e;function cc(e,t,r){return Ci(e)&&Ci(t)&&Ci(r)&&t<=e&&e<r}function De(e,t,r,n){if(!cc(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Vn(e){let t;for(t=0;e>_i;e>>=Bi,t+=1);return t}var Re=e=>(Bi<<BigInt(e))-Bi;function uc(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=h=>new Uint8Array(h),o=h=>Uint8Array.of(h),i=n(e),s=n(e),a=0,c=()=>{i.fill(1),s.fill(0),a=0},u=(...h)=>r(s,i,...h),f=(h=n(0))=>{s=u(o(0),h),i=u(),h.length!==0&&(s=u(o(1),h),i=u())},l=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,S=[];for(;h<t;){i=u();let w=i.slice();S.push(w),h+=i.length}return It(...S)};return(h,S)=>{c(),f(h);let w;for(;!(w=S(l()));)f();return c(),w}}function Ne(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,i,s){let a=e[o];if(s&&a===void 0)return;let c=typeof a;if(c!==i||a===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([o,i])=>n(o,i,!1)),Object.entries(r).forEach(([o,i])=>n(o,i,!0))}function yr(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 wt=BigInt(0),ut=BigInt(1),Ge=BigInt(2),dc=BigInt(3),hc=BigInt(4),pc=BigInt(5),Xd=BigInt(7),mc=BigInt(8),Jd=BigInt(9),yc=BigInt(16);function nt(e,t){let r=e%t;return r>=wt?r:t+r}function Q(e,t,r){let n=e;for(;t-- >wt;)n*=n,n%=r;return n}function fc(e,t){if(e===wt)throw new Error("invert: expected non-zero number");if(t<=wt)throw new Error("invert: expected positive modulus, got "+t);let r=nt(e,t),n=t,o=wt,i=ut,s=ut,a=wt;for(;r!==wt;){let u=n/r,f=n%r,l=o-s*u,d=i-a*u;n=r,r=f,o=s,i=a,s=l,a=d}if(n!==ut)throw new Error("invert: does not exist");return nt(o,t)}function Pi(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function gc(e,t){let r=(e.ORDER+ut)/hc,n=e.pow(t,r);return Pi(e,n,t),n}function Qd(e,t){let r=(e.ORDER-pc)/mc,n=e.mul(t,Ge),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Ge),o),a=e.mul(i,e.sub(s,e.ONE));return Pi(e,a,t),a}function th(e){let t=Dt(e),r=xc(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Xd)/yc;return(a,c)=>{let u=a.pow(c,s),f=a.mul(u,n),l=a.mul(u,o),d=a.mul(u,i),h=a.eql(a.sqr(f),c),S=a.eql(a.sqr(l),c);u=a.cmov(u,f,h),f=a.cmov(d,l,S);let w=a.eql(a.sqr(f),c),x=a.cmov(u,f,w);return Pi(a,x,c),x}}function xc(e){if(e<dc)throw new Error("sqrt is not defined for small field");let t=e-ut,r=0;for(;t%Ge===wt;)t/=Ge,r++;let n=Ge,o=Dt(e);for(;lc(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return gc;let i=o.pow(n,t),s=(t+ut)/Ge;return function(c,u){if(c.is0(u))return u;if(lc(c,u)!==1)throw new Error("Cannot find square root");let f=r,l=c.mul(c.ONE,i),d=c.pow(u,t),h=c.pow(u,s);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let S=1,w=c.sqr(d);for(;!c.eql(w,c.ONE);)if(S++,w=c.sqr(w),S===f)throw new Error("Cannot find square root");let x=ut<<BigInt(f-S-1),T=c.pow(l,x);f=S,l=c.sqr(T),d=c.mul(d,l),h=c.mul(h,T)}return h}}function eh(e){return e%hc===dc?gc:e%mc===pc?Qd:e%yc===Jd?th(e):xc(e)}var me=(e,t)=>(nt(e,t)&ut)===ut,rh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Di(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=rh.reduce((n,o)=>(n[o]="function",n),t);return Ne(e,r),e}function nh(e,t,r){if(r<wt)throw new Error("invalid exponent, negatives unsupported");if(r===wt)return e.ONE;if(r===ut)return t;let n=e.ONE,o=t;for(;r>wt;)r&ut&&(n=e.mul(n,o)),o=e.sqr(o),r>>=ut;return n}function Qr(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 lc(e,t){let r=(e.ORDER-ut)/Ge,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("invalid Legendre symbol result");return o?1:i?0:-1}function wc(e,t){t!==void 0&&jr(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Dt(e,t,r=!1,n={}){if(e<=wt)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s=!1,a;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let d=t;d.BITS&&(o=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(r=d.isLE),typeof d.modOnDecode=="boolean"&&(s=d.modOnDecode),a=d.allowedLengths}else typeof t=="number"&&(o=t),n.sqrt&&(i=n.sqrt);let{nBitLength:c,nByteLength:u}=wc(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f,l=Object.freeze({ORDER:e,isLE:r,BITS:c,BYTES:u,MASK:Re(c),ZERO:wt,ONE:ut,allowedLengths:a,create:d=>nt(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return wt<=d&&d<e},is0:d=>d===wt,isValidNot0:d=>!l.is0(d)&&l.isValid(d),isOdd:d=>(d&ut)===ut,neg:d=>nt(-d,e),eql:(d,h)=>d===h,sqr:d=>nt(d*d,e),add:(d,h)=>nt(d+h,e),sub:(d,h)=>nt(d-h,e),mul:(d,h)=>nt(d*h,e),pow:(d,h)=>nh(l,d,h),div:(d,h)=>nt(d*fc(h,e),e),sqrN:d=>d*d,addN:(d,h)=>d+h,subN:(d,h)=>d-h,mulN:(d,h)=>d*h,inv:d=>fc(d,e),sqrt:i||(d=>(f||(f=eh(e)),f(l,d))),toBytes:d=>r?pe(d,u):Mn(d,u),fromBytes:(d,h=!0)=>{if(a){if(!a.includes(d.length)||d.length>u)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);let w=new Uint8Array(u);w.set(d,r?0:w.length-d.length),d=w}if(d.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+d.length);let S=r?he(d):mr(d);if(s&&(S=nt(S,e)),!h&&!l.isValid(S))throw new Error("invalid field element: outside of range 0..ORDER");return S},invertBatch:d=>Qr(l,d),cmov:(d,h,S)=>S?h:d});return Object.freeze(l)}function bc(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 Ri(e){let t=bc(e);return t+Math.ceil(t/2)}function Ni(e,t,r=!1){let n=e.length,o=bc(t),i=Ri(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?he(e):mr(e),a=nt(s,t-ut)+ut;return r?pe(a,o):Mn(a,o)}var gr=BigInt(0),Ze=BigInt(1);function tn(e,t){let r=t.negate();return e?r:t}function ye(e,t){let r=Qr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Ac(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ui(e,t){Ac(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Re(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ec(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+=Ze);let u=t*n,f=u+Math.abs(a)-1,l=a===0,d=a<0,h=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:d,isNegF:h,offsetF:u}}function oh(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 ih(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 Li=new WeakMap,Ic=new WeakMap;function Oi(e){return Ic.get(e)||1}function Sc(e){if(e!==gr)throw new Error("invalid wNAF")}var xr=class{constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>gr;)r&Ze&&(n=n.add(o)),o=o.double(),r>>=Ze;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Ui(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Ui(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:u,isZero:f,isNeg:l,isNegF:d,offsetF:h}=Ec(n,a,s);n=c,f?i=i.add(tn(d,r[h])):o=o.add(tn(l,r[u]))}return Sc(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=Ui(t,this.bits);for(let s=0;s<i.windows&&n!==gr;s++){let{nextN:a,offset:c,isZero:u,isNeg:f}=Ec(n,s,i);if(n=a,!u){let l=r[c];o=o.add(f?l.negate():l)}}return Sc(n),o}getPrecomputes(t,r,n){let o=Li.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Li.set(r,o))),o}cached(t,r,n){let o=Oi(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=Oi(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){Ac(r,this.bits),Ic.set(t,r),Li.delete(t)}hasCache(t){return Oi(t)!==1}};function Tc(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>gr||n>gr;)r&Ze&&(i=i.add(o)),n&Ze&&(s=s.add(o)),o=o.double(),r>>=Ze,n>>=Ze;return{p1:i,p2:s}}function wr(e,t,r,n){oh(r,e),ih(n,t);let o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=Vn(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let u=Re(c),f=new Array(Number(u)+1).fill(s),l=Math.floor((t.BITS-1)/c)*c,d=s;for(let h=l;h>=0;h-=c){f.fill(s);for(let w=0;w<i;w++){let x=n[w],T=Number(x>>BigInt(h)&u);f[T]=f[T].add(r[w])}let S=s;for(let w=f.length-1,x=s;w>0;w--)x=x.add(f[w]),S=S.add(x);if(d=d.add(S),h!==0)for(let w=0;w<c;w++)d=d.double()}return d}function vc(e,t){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Di(t),t}else return Dt(e)}function $n(e,t,r={}){if(!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>gr))throw new Error(`CURVE.${a} must be positive bigint`)}let n=vc(t.p,r.Fp),o=vc(t.n,r.Fn),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let a of s)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var ee=BigInt(0),ct=BigInt(1),ki=BigInt(2),sh=BigInt(8);function ah(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function ch(e,t={}){let{Fp:r,Fn:n}=$n("edwards",e,t),{h:o,n:i}=e;Ne(t,{},{uvRatio:"function"});let s=ki<<BigInt(n.BYTES*8)-ct,a=w=>r.create(w),c=t.uvRatio||((w,x)=>{try{return{isValid:!0,value:r.sqrt(r.div(w,x))}}catch{return{isValid:!1,value:ee}}});if(!ah(r,e,e.Gx,e.Gy))throw new Error("bad curve params: generator point");function u(w,x,T=!1){let R=T?ct:ee;return De("coordinate "+w,x,R,s),x}function f(w){if(!(w instanceof h))throw new Error("ExtendedPoint expected")}let l=yr((w,x)=>{let{X:T,Y:R,Z:P}=w,L=w.is0();x==null&&(x=L?sh:r.inv(P));let K=a(T*x),_=a(R*x),k=r.mul(P,x);if(L)return{x:ee,y:ct};if(k!==ct)throw new Error("invZ was invalid");return{x:K,y:_}}),d=yr(w=>{let{a:x,d:T}=e;if(w.is0())throw new Error("bad point: ZERO");let{X:R,Y:P,Z:L,T:K}=w,_=a(R*R),k=a(P*P),I=a(L*L),A=a(I*I),m=a(_*x),p=a(I*a(m+k)),y=a(A+a(T*a(_*k)));if(p!==y)throw new Error("bad point: equation left != right (1)");let v=a(R*P),N=a(L*K);if(v!==N)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(x,T,R,P){this.X=u("x",x),this.Y=u("y",T),this.Z=u("z",R,!0),this.T=u("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(x){return ye(h,x)}static msm(x,T){return wr(h,n,x,T)}_setWindowSize(x){this.precompute(x)}static fromAffine(x){if(x instanceof h)throw new Error("extended point not allowed");let{x:T,y:R}=x||{};return u("x",T),u("y",R),new h(T,R,ct,a(T*R))}precompute(x=8,T=!0){return S.createCache(this,x),T||this.multiply(ki),this}assertValidity(){d(this)}equals(x){f(x);let{X:T,Y:R,Z:P}=this,{X:L,Y:K,Z:_}=x,k=a(T*_),I=a(L*P),A=a(R*_),m=a(K*P);return k===I&&A===m}is0(){return this.equals(h.ZERO)}negate(){return new h(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:x}=e,{X:T,Y:R,Z:P}=this,L=a(T*T),K=a(R*R),_=a(ki*a(P*P)),k=a(x*L),I=T+R,A=a(a(I*I)-L-K),m=k+K,p=m-_,y=k-K,v=a(A*p),N=a(m*y),D=a(A*y),g=a(p*m);return new h(v,N,g,D)}add(x){f(x);let{a:T,d:R}=e,{X:P,Y:L,Z:K,T:_}=this,{X:k,Y:I,Z:A,T:m}=x,p=a(P*k),y=a(L*I),v=a(_*R*m),N=a(K*A),D=a((P+L)*(k+I)-p-y),g=N-v,b=N+v,C=a(y-T*p),U=a(D*g),F=a(b*C),V=a(D*C),q=a(g*b);return new h(U,F,q,V)}subtract(x){return this.add(x.negate())}multiply(x){let T=x;De("scalar",T,ct,i);let{p:R,f:P}=S.cached(this,T,L=>ye(h,L));return ye(h,[R,P])[0]}multiplyUnsafe(x,T=h.ZERO){let R=x;return De("scalar",R,ee,i),R===ee?h.ZERO:this.is0()||R===ct?this:S.unsafe(this,R,P=>ye(h,P),T)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return S.unsafe(this,i).is0()}toAffine(x){return l(this,x)}clearCofactor(){return o===ct?this:this.multiplyUnsafe(o)}static fromBytes(x,T=!1){return rt(x),h.fromHex(x,T)}static fromHex(x,T=!1){let{d:R,a:P}=e,L=r.BYTES;x=Z("pointHex",x,L),de("zip215",T);let K=x.slice(),_=x[L-1];K[L-1]=_&-129;let k=he(K),I=T?s:r.ORDER;De("pointHex.y",k,ee,I);let A=a(k*k),m=a(A-ct),p=a(R*A-P),{isValid:y,value:v}=c(m,p);if(!y)throw new Error("Point.fromHex: invalid y coordinate");let N=(v&ct)===ct,D=(_&128)!==0;if(!T&&v===ee&&D)throw new Error("Point.fromHex: x=0 and x_0=1");return D!==N&&(v=a(-v)),h.fromAffine({x:v,y:k})}toBytes(){let{x,y:T}=this.toAffine(),R=pe(T,r.BYTES);return R[R.length-1]|=x&ct?128:0,R}toRawBytes(){return this.toBytes()}toHex(){return Mt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}h.BASE=new h(e.Gx,e.Gy,ct,a(e.Gx*e.Gy)),h.ZERO=new h(ee,ct,ct,ee),h.Fp=r,h.Fn=n;let S=new xr(h,n.BYTES*8);return h}var qn=class{constructor(t){this.ep=t}static fromBytes(t){throw new Error("fromBytes must be implemented by subclass")}static fromHex(t){throw new Error("fromHex must be implemented by subclass")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toRawBytes(){return this.toBytes()}toHex(){return Mt(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.init(this.ep.precompute(t,r))}};function uh(e,t,r){if(typeof t!="function")throw new Error('"hash" function param is required');Ne(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=e,a=s.ORDER,c=r.randomBytes||Zr,u=r.adjustScalarBytes||(p=>p),f=r.domain||((p,y,v)=>{if(de("phflag",v),y.length||v)throw new Error("Contexts/pre-hash are not supported");return p});function l(p){return s.create(p)}function d(p){return l(he(p))}function h(p){let y=i.BYTES;p=Z("private key",p,y);let v=Z("hashed private key",t(p),2*y),N=u(v.slice(0,y)),D=v.slice(y,2*y),g=d(N);return{head:N,prefix:D,scalar:g}}function S(p){let{head:y,prefix:v,scalar:N}=h(p),D=o.multiply(N),g=D.toBytes();return{head:y,prefix:v,scalar:N,point:D,pointBytes:g}}function w(p){return S(p).pointBytes}function x(p=Uint8Array.of(),...y){let v=It(...y);return d(t(f(v,Z("context",p),!!n)))}function T(p,y,v={}){p=Z("message",p),n&&(p=n(p));let{prefix:N,scalar:D,pointBytes:g}=S(y),b=x(v.context,N,p),C=o.multiply(b).toBytes(),U=x(v.context,C,g,p),F=l(b+U*D);De("signature.s",F,ee,a);let V=i.BYTES,q=It(C,pe(F,V));return Z("result",q,V*2)}let R={zip215:!0};function P(p,y,v,N=R){let{context:D,zip215:g}=N,b=i.BYTES;p=Z("signature",p,2*b),y=Z("message",y),v=Z("publicKey",v,b),g!==void 0&&de("zip215",g),n&&(y=n(y));let C=he(p.slice(b,2*b)),U,F,V;try{U=e.fromHex(v,g),F=e.fromHex(p.slice(0,b),g),V=o.multiplyUnsafe(C)}catch{return!1}if(!g&&U.isSmallOrder())return!1;let q=x(D,F.toBytes(),U.toBytes(),y);return F.add(U.multiplyUnsafe(q)).subtract(V).clearCofactor().is0()}o.precompute(8);let L=i.BYTES,K={secret:L,public:L,signature:2*L,seed:L};function _(p=c(K.seed)){return p}let k={getExtendedPublicKey:S,randomSecretKey:_,isValidSecretKey:A,isValidPublicKey:m,randomPrivateKey:_,toMontgomery(p){let{y}=e.fromBytes(p),v=L===32;if(!v&&L!==57)throw new Error("only defined for 25519 and 448");let N=v?i.div(ct+y,ct-y):i.div(y-ct,y+ct);return i.toBytes(N)},toMontgomeryPriv(p){rt(p,L);let y=t(p.subarray(0,L));return u(y).subarray(0,L)},precompute(p=8,y=e.BASE){return y.precompute(p,!1)}};function I(p){let y=k.randomSecretKey(p);return{secretKey:y,publicKey:w(y)}}function A(p){try{return!!s.fromBytes(p,!1)}catch{return!1}}function m(p,y){try{return!!e.fromBytes(p,y)}catch{return!1}}return Object.freeze({keygen:I,getPublicKey:w,sign:T,verify:P,utils:k,Point:e,info:{type:"edwards",lengths:K}})}function fh(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=Dt(t.n,e.nBitLength,!0),o={Fp:r,Fn:n,uvRatio:e.uvRatio},i={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:i}}function lh(e,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:e})}function Cc(e){let{CURVE:t,curveOpts:r,hash:n,eddsaOpts:o}=fh(e),i=ch(t,r),s=uh(i,n,o);return lh(e,s)}var dh=BigInt(0),ge=BigInt(1),Bc=BigInt(2),Pg=BigInt(3),hh=BigInt(5),ph=BigInt(8),en={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:ph,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function mh(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=en.p,a=e*e%i*e%i,c=Q(a,Bc,i)*a%i,u=Q(c,ge,i)*e%i,f=Q(u,hh,i)*u%i,l=Q(f,t,i)*f%i,d=Q(l,r,i)*l%i,h=Q(d,n,i)*d%i,S=Q(h,o,i)*h%i,w=Q(S,o,i)*h%i,x=Q(w,t,i)*f%i;return{pow_p_5_8:Q(x,Bc,i)*e%i,b2:a}}function yh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Ki=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Vi(e,t){let r=en.p,n=nt(t*t*t,r),o=nt(n*n*t,r),i=mh(e*o).pow_p_5_8,s=nt(e*n*i,r),a=nt(t*s*s,r),c=s,u=nt(s*Ki,r),f=a===e,l=a===nt(-e,r),d=a===nt(-e*Ki,r);return f&&(s=c),(l||d)&&(s=u),me(s,r)&&(s=nt(-s,r)),{isValid:f||l,value:s}}var Ye=Dt(en.p,{isLE:!0}),gh=Dt(en.n,{isLE:!0}),xh={...en,Fp:Ye,hash:ic,adjustScalarBytes:yh,uvRatio:Vi},Rt=Cc(xh);var Fi=Ki,wh=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),bh=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Eh=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Sh=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),_c=e=>Vi(ge,e),vh=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Mi=e=>Rt.CURVE.Fp.create(he(e)&vh);function Pc(e){let{d:t}=Rt.CURVE,r=Rt.CURVE.Fp.ORDER,n=Rt.CURVE.Fp.create,o=n(Fi*e*e),i=n((o+ge)*Eh),s=BigInt(-1),a=n((s-t*o)*n(o+t)),{isValid:c,value:u}=Vi(i,a),f=n(u*e);me(f,r)||(f=n(-f)),c||(u=f),c||(s=o);let l=n(s*(o-ge)*Sh-a),d=u*u,h=n((u+u)*a),S=n(l*wh),w=n(ge-d),x=n(ge+d);return new Rt.Point(n(h*x),n(w*S),n(S*x),n(h*w))}function Ah(e){rt(e,64);let t=Mi(e.subarray(0,32)),r=Pc(t),n=Mi(e.subarray(32,64)),o=Pc(n);return new xe(r.add(o))}var xe=class e extends qn{constructor(t){super(t)}static fromAffine(t){return new e(Rt.Point.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static hashToCurve(t){return Ah(Z("ristrettoHash",t,64))}static fromBytes(t){rt(t,32);let{a:r,d:n}=Rt.CURVE,o=Ye.ORDER,i=Ye.create,s=Mi(t);if(!ac(pe(s,32),t)||me(s,o))throw new Error("invalid ristretto255 encoding 1");let a=i(s*s),c=i(ge+r*a),u=i(ge-r*a),f=i(c*c),l=i(u*u),d=i(r*n*f-l),{isValid:h,value:S}=_c(i(d*l)),w=i(S*u),x=i(S*w*d),T=i((s+s)*w);me(T,o)&&(T=i(-T));let R=i(c*x),P=i(T*R);if(!h||me(P,o)||R===dh)throw new Error("invalid ristretto255 encoding 2");return new e(new Rt.Point(T,R,ge,P))}static fromHex(t){return e.fromBytes(Z("ristrettoHex",t,32))}static msm(t,r){return wr(e,Rt.Point.Fn,t,r)}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,i=Ye.ORDER,s=Ye.create,a=s(s(n+r)*s(n-r)),c=s(t*r),u=s(c*c),{value:f}=_c(s(a*u)),l=s(f*a),d=s(f*c),h=s(l*d*o),S;if(me(o*h,i)){let x=s(r*Fi),T=s(t*Fi);t=x,r=T,S=s(l*bh)}else S=d;me(t*h,i)&&(r=s(-r));let w=s((n-r)*S);return me(w,i)&&(w=s(-w)),pe(w,32)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:i}=t.ep,s=Ye.create,a=s(r*i)===s(n*o),c=s(n*i)===s(r*o);return a||c}is0(){return this.equals(e.ZERO)}};xe.BASE=new xe(Rt.Point.BASE);xe.ZERO=new xe(Rt.Point.ZERO);xe.Fp=Ye;xe.Fn=gh;var rn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Hn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Dc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Hn("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 Vt=Dc;var zn=32;var $i,Ih=(async()=>{try{return await Vt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Th(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Vt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Vt.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Ch(e,t,r){return Rt.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Rc(e,t,r){return $i==null&&($i=await Ih),$i?Th(e,t,r):Ch(e,t,r)}function jn(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Gn=class{type="Ed25519";raw;constructor(t){this.raw=qi(t,zn)}toMultihash(){return Bt.digest(dr(this))}toCID(){return z.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Rc(this.raw,r,t);return jn(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Hi(e){return e=qi(e,zn),new Gn(e)}function qi(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new it(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var _h=Math.pow(2,7),Ph=Math.pow(2,14),Dh=Math.pow(2,21),zi=Math.pow(2,28),ji=Math.pow(2,35),Gi=Math.pow(2,42),Zi=Math.pow(2,49),tt=128,yt=127;function re(e){if(e<_h)return 1;if(e<Ph)return 2;if(e<Dh)return 3;if(e<zi)return 4;if(e<ji)return 5;if(e<Gi)return 6;if(e<Zi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function nn(e,t,r=0){switch(re(e)){case 8:t[r++]=e&255|tt,e/=128;case 7:t[r++]=e&255|tt,e/=128;case 6:t[r++]=e&255|tt,e/=128;case 5:t[r++]=e&255|tt,e/=128;case 4:t[r++]=e&255|tt,e>>>=7;case 3:t[r++]=e&255|tt,e>>>=7;case 2:t[r++]=e&255|tt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Yi(e,t){let r=e[t],n=0;if(n+=r&yt,r<tt||(r=e[t+1],n+=(r&yt)<<7,r<tt)||(r=e[t+2],n+=(r&yt)<<14,r<tt)||(r=e[t+3],n+=(r&yt)<<21,r<tt)||(r=e[t+4],n+=(r&yt)*zi,r<tt)||(r=e[t+5],n+=(r&yt)*ji,r<tt)||(r=e[t+6],n+=(r&yt)*Gi,r<tt)||(r=e[t+7],n+=(r&yt)*Zi,r<tt))return n;throw new RangeError("Could not decode varint")}function Rh(e,t){let r=e.get(t),n=0;if(n+=r&yt,r<tt||(r=e.get(t+1),n+=(r&yt)<<7,r<tt)||(r=e.get(t+2),n+=(r&yt)<<14,r<tt)||(r=e.get(t+3),n+=(r&yt)<<21,r<tt)||(r=e.get(t+4),n+=(r&yt)*zi,r<tt)||(r=e.get(t+5),n+=(r&yt)*ji,r<tt)||(r=e.get(t+6),n+=(r&yt)*Gi,r<tt)||(r=e.get(t+7),n+=(r&yt)*Zi,r<tt))return n;throw new RangeError("Could not decode varint")}function Wi(e,t=0){return e instanceof Uint8Array?Yi(e,t):Rh(e,t)}var Xi=new Float32Array([-0]),Ue=new Uint8Array(Xi.buffer);function Uc(e,t,r){Xi[0]=e,t[r]=Ue[0],t[r+1]=Ue[1],t[r+2]=Ue[2],t[r+3]=Ue[3]}function Lc(e,t){return Ue[0]=e[t],Ue[1]=e[t+1],Ue[2]=e[t+2],Ue[3]=e[t+3],Xi[0]}var Ji=new Float64Array([-0]),gt=new Uint8Array(Ji.buffer);function Oc(e,t,r){Ji[0]=e,t[r]=gt[0],t[r+1]=gt[1],t[r+2]=gt[2],t[r+3]=gt[3],t[r+4]=gt[4],t[r+5]=gt[5],t[r+6]=gt[6],t[r+7]=gt[7]}function kc(e,t){return gt[0]=e[t],gt[1]=e[t+1],gt[2]=e[t+2],gt[3]=e[t+3],gt[4]=e[t+4],gt[5]=e[t+5],gt[6]=e[t+6],gt[7]=e[t+7],Ji[0]}var Uh=BigInt(Number.MAX_SAFE_INTEGER),Lh=BigInt(Number.MIN_SAFE_INTEGER),Nt=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 We;if(t<Uh&&t>Lh)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>Kc&&(o=0n,++n>Kc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return We;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):We}},We=new Nt(0,0);We.toBigInt=function(){return 0n};We.zzEncode=We.zzDecode=function(){return this};We.length=function(){return 1};var Kc=4294967296n;function Fc(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 Mc(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 Qi(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 jt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Zn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ts=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,jt(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 jt(this,4);return Zn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw jt(this,4);return Zn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw jt(this,4);let t=Lc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw jt(this,4);let t=kc(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 jt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Mc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw jt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw jt(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 Nt(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 jt(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 jt(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 jt(this,8);let t=Zn(this.buf,this.pos+=4),r=Zn(this.buf,this.pos+=4);return new Nt(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=Yi(this.buf,this.pos);return this.pos+=re(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 es(e){return new ts(e instanceof Uint8Array?e:e.subarray())}function br(e,t,r){let n=es(e);return t.decode(n,void 0,r)}function rs(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return _t(s);o+s>t&&(n=_t(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Xe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ns(){}var is=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Oh=rs();function kh(e){return globalThis.Buffer!=null?_t(e):Oh(e)}var sn=class{len;head;tail;states;constructor(){this.len=0,this.head=new Xe(ns,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Xe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ss((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(Yn,10,Nt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Nt.fromBigInt(t);return this._push(Yn,r.length(),r)}uint64Number(t){return this._push(nn,re(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=Nt.fromBigInt(t).zzEncode();return this._push(Yn,r.length(),r)}sint64Number(t){let r=Nt.fromNumber(t).zzEncode();return this._push(Yn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(os,1,t?1:0)}fixed32(t){return this._push(on,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Nt.fromBigInt(t);return this._push(on,4,r.lo)._push(on,4,r.hi)}fixed64Number(t){let r=Nt.fromNumber(t);return this._push(on,4,r.lo)._push(on,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(Uc,4,t)}double(t){return this._push(Oc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(os,1,0):this.uint32(r)._push(Fh,r,t)}string(t){let r=Fc(t);return r!==0?this.uint32(r)._push(Qi,r,t):this._push(os,1,0)}fork(){return this.states=new is(this),this.head=this.tail=new Xe(ns,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 Xe(ns,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=kh(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function os(e,t,r){t[r]=e&255}function Kh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var ss=class extends Xe{next;constructor(t,r){super(Kh,t,r),this.next=void 0}};function Yn(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 on(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 Fh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(sn.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Mh,t,e),this},sn.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Vh,t,e),this});function Mh(e,t,r){t.set(e,r)}function Vh(e,t,r){e.length<40?Qi(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set($(e),r)}function as(){return new sn}function Er(e,t){let r=as();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Sr;(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"})(Sr||(Sr={}));function Wn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function an(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 Wn("enum",Sr.VARINT,r,n)}function vr(e,t){return Wn("message",Sr.LENGTH_DELIMITED,e,t)}var ot;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ot||(ot={}));var cs;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(cs||(cs={}));(function(e){e.codec=()=>an(cs)})(ot||(ot={}));var ne;(function(e){let t;e.codec=()=>(t==null&&(t=vr((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=>Er(r,e.codec()),e.decode=(r,n)=>br(r,e.codec(),n)})(ne||(ne={}));var us;(function(e){let t;e.codec=()=>(t==null&&(t=vr((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=>Er(r,e.codec()),e.decode=(r,n)=>br(r,e.codec(),n)})(us||(us={}));var un={};Et(un,{MAX_RSA_KEY_SIZE:()=>fs,generateRSAKeyPair:()=>jc,jwkToJWKKeyPair:()=>Gc,jwkToPkcs1:()=>zh,jwkToPkix:()=>ps,jwkToRSAPrivateKey:()=>xs,pkcs1MessageToJwk:()=>ds,pkcs1MessageToRSAPrivateKey:()=>ms,pkcs1ToJwk:()=>Hh,pkcs1ToRSAPrivateKey:()=>zc,pkixMessageToJwk:()=>hs,pkixMessageToRSAPublicKey:()=>gs,pkixToJwk:()=>jh,pkixToRSAPublicKey:()=>ys});var Xn=Fn;var Ar=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=un.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return z.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}verify(t,r,n){return Hc(this.jwk,r,t,n)}},cn=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=un.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}sign(t,r){return qc(this.jwk,t,r)}};var fs=8192,ls=18,$h=1062,qh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Hh(e){let t=ce(e);return ds(t)}function ds(e){return{n:H(e[1],"base64url"),e:H(e[2],"base64url"),d:H(e[3],"base64url"),p:H(e[4],"base64url"),q:H(e[5],"base64url"),dp:H(e[6],"base64url"),dq:H(e[7],"base64url"),qi:H(e[8],"base64url"),kty:"RSA"}}function zh(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 it("JWK was missing components");return Ce([At(Uint8Array.from([0])),At($(e.n,"base64url")),At($(e.e,"base64url")),At($(e.d,"base64url")),At($(e.p,"base64url")),At($(e.q,"base64url")),At($(e.dp,"base64url")),At($(e.dq,"base64url")),At($(e.qi,"base64url"))]).subarray()}function jh(e){let t=ce(e,{offset:0});return hs(t)}function hs(e){let t=ce(e[1],{offset:0});return{kty:"RSA",n:H(t[0],"base64url"),e:H(t[1],"base64url")}}function ps(e){if(e.n==null||e.e==null)throw new it("JWK was missing components");return Ce([qh,Un(Ce([At($(e.n,"base64url")),At($(e.e,"base64url"))]))]).subarray()}function zc(e){let t=ce(e);return ms(t)}function ms(e){let t=ds(e);return xs(t)}function ys(e,t){if(e.byteLength>=$h)throw new rr("Key size is too large");let r=ce(e,{offset:0});return gs(r,e,t)}function gs(e,t,r){let n=hs(e);if(r==null){let o=Xn(ne.encode({Type:ot.RSA,Data:t}));r=Ht(ls,o)}return new Ar(n,r)}function xs(e){if(Yc(e)>fs)throw new it("Key size is too large");let t=Gc(e),r=Xn(ne.encode({Type:ot.RSA,Data:ps(t.publicKey)})),n=Ht(ls,r);return new cn(t.privateKey,new Ar(t.publicKey,n))}async function jc(e){if(e>fs)throw new it("Key size is too large");let t=await Zc(e),r=Xn(ne.encode({Type:ot.RSA,Data:ps(t.publicKey)})),n=Ht(ls,r);return new cn(t.privateKey,new Ar(t.publicKey,n))}function Gc(e){if(e==null)throw new it("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Zc(e,t){let r=await Vt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await Gh(r,t);return{privateKey:n[0],publicKey:n[1]}}async function qc(e,t,r){let n=await Vt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Vt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Hc(e,t,r,n){let o=await Vt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Vt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Gh(e,t){if(e.privateKey==null||e.publicKey==null)throw new it("Private and public key are required");let r=await Promise.all([Vt.get().subtle.exportKey("jwk",e.privateKey),Vt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function Yc(e){if(e.kty!=="RSA")throw new it("invalid key type");if(e.n==null)throw new it("invalid key modulus");return $(e.n,"base64url").length*8}var Jn=class extends hr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Ln(t);let n=Gr(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),fe(i)}update(t){return pr(this),this.iHash.update(t),this}digestInto(t){pr(this),rt(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()}},ws=(e,t,r)=>new Jn(e,t).update(r).digest();ws.create=(e,t)=>new Jn(e,t);var Wc=(e,t)=>(e+(e>=0?t:-t)/Jc)/t;function Zh(e,t,r){let[[n,o],[i,s]]=t,a=Wc(s*e,r),c=Wc(-o*e,r),u=e-a*n-c*i,f=-a*o-c*s,l=u<be,d=f<be;l&&(u=-u),d&&(f=-f);let h=Re(Math.ceil(Vn(r)/2))+Tr;if(u<be||u>=h||f<be||f>=h)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:u,k2neg:d,k2:f}}function Xc(e){e.lowS!==void 0&&de("lowS",e.lowS),e.prehash!==void 0&&de("prehash",e.prehash)}var bs=class extends Error{constructor(t=""){super(t)}},we={Err:bs,_tlv:{encode:(e,t)=>{let{Err:r}=we;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=Jr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Jr(o.length/2|128):"";return Jr(e)+i+o+t},decode(e,t){let{Err:r}=we,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 u=t.subarray(n,n+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of u)s=s<<8|f;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}=we;if(e<be)throw new t("integer: negative integers are not allowed");let r=Jr(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}=we;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 mr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=we,o=Z("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:u,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=we,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},be=BigInt(0),Tr=BigInt(1),Jc=BigInt(2),Qn=BigInt(3),Yh=BigInt(4);function Wh(e,t,r){function n(o){let i=e.sqr(o),s=e.mul(i,o);return e.add(e.add(s,e.mul(o,t)),r)}return n}function Ir(e,t){let{BYTES:r}=e,n;if(typeof t=="bigint")n=t;else{let o=Z("private key",t);try{n=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof t}`)}}if(!e.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function Xh(e,t={}){let{Fp:r,Fn:n}=$n("weierstrass",e,t),{h:o,n:i}=e;Ne(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:s}=t;if(s&&(!r.is0(e.a)||typeof s.beta!="bigint"||!Array.isArray(s.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(A,m,p){let{x:y,y:v}=m.toAffine(),N=r.toBytes(y);if(de("isCompressed",p),p){a();let D=!r.isOdd(v);return It(Qc(D),N)}else return It(Uint8Array.of(4),N,r.toBytes(v))}function u(A){rt(A);let m=r.BYTES,p=m+1,y=2*m+1,v=A.length,N=A[0],D=A.subarray(1);if(v===p&&(N===2||N===3)){let g=r.fromBytes(D);if(!r.isValid(g))throw new Error("bad point: is not on curve, wrong x");let b=d(g),C;try{C=r.sqrt(b)}catch(V){let q=V instanceof Error?": "+V.message:"";throw new Error("bad point: is not on curve, sqrt error"+q)}a();let U=r.isOdd(C);return(N&1)===1!==U&&(C=r.neg(C)),{x:g,y:C}}else if(v===y&&N===4){let g=r.fromBytes(D.subarray(m*0,m*1)),b=r.fromBytes(D.subarray(m*1,m*2));if(!h(g,b))throw new Error("bad point: is not on curve");return{x:g,y:b}}else throw new Error(`bad point: got length ${v}, expected compressed=${p} or uncompressed=${y}`)}let f=t.toBytes||c,l=t.fromBytes||u,d=Wh(r,e.a,e.b);function h(A,m){let p=r.sqr(m),y=d(A);return r.eql(p,y)}if(!h(e.Gx,e.Gy))throw new Error("bad curve params: generator point");let S=r.mul(r.pow(e.a,Qn),Yh),w=r.mul(r.sqr(e.b),BigInt(27));if(r.is0(r.add(S,w)))throw new Error("bad curve params: a or b");function x(A,m,p=!1){if(!r.isValid(m)||p&&r.is0(m))throw new Error(`bad point coordinate ${A}`);return m}function T(A){if(!(A instanceof _))throw new Error("ProjectivePoint expected")}function R(A){if(!s||!s.basises)throw new Error("no endo");return Zh(A,s.basises,n.ORDER)}let P=yr((A,m)=>{let{X:p,Y:y,Z:v}=A;if(r.eql(v,r.ONE))return{x:p,y};let N=A.is0();m==null&&(m=N?r.ONE:r.inv(v));let D=r.mul(p,m),g=r.mul(y,m),b=r.mul(v,m);if(N)return{x:r.ZERO,y:r.ZERO};if(!r.eql(b,r.ONE))throw new Error("invZ was invalid");return{x:D,y:g}}),L=yr(A=>{if(A.is0()){if(t.allowInfinityPoint&&!r.is0(A.Y))return;throw new Error("bad point: ZERO")}let{x:m,y:p}=A.toAffine();if(!r.isValid(m)||!r.isValid(p))throw new Error("bad point: x or y not field elements");if(!h(m,p))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function K(A,m,p,y,v){return p=new _(r.mul(p.X,A),p.Y,p.Z),m=tn(y,m),p=tn(v,p),m.add(p)}class _{constructor(m,p,y){this.X=x("x",m),this.Y=x("y",p,!0),this.Z=x("z",y),Object.freeze(this)}static fromAffine(m){let{x:p,y}=m||{};if(!m||!r.isValid(p)||!r.isValid(y))throw new Error("invalid affine point");if(m instanceof _)throw new Error("projective point not allowed");return r.is0(p)&&r.is0(y)?_.ZERO:new _(p,y,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}static normalizeZ(m){return ye(_,m)}static fromBytes(m){return rt(m),_.fromHex(m)}static fromHex(m){let p=_.fromAffine(l(Z("pointHex",m)));return p.assertValidity(),p}static fromPrivateKey(m){return _.BASE.multiply(Ir(n,m))}static msm(m,p){return wr(_,n,m,p)}_setWindowSize(m){this.precompute(m)}precompute(m=8,p=!0){return I.createCache(this,m),p||this.multiply(Qn),this}assertValidity(){L(this)}hasEvenY(){let{y:m}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(m)}equals(m){T(m);let{X:p,Y:y,Z:v}=this,{X:N,Y:D,Z:g}=m,b=r.eql(r.mul(p,g),r.mul(N,v)),C=r.eql(r.mul(y,g),r.mul(D,v));return b&&C}negate(){return new _(this.X,r.neg(this.Y),this.Z)}double(){let{a:m,b:p}=e,y=r.mul(p,Qn),{X:v,Y:N,Z:D}=this,g=r.ZERO,b=r.ZERO,C=r.ZERO,U=r.mul(v,v),F=r.mul(N,N),V=r.mul(D,D),q=r.mul(v,N);return q=r.add(q,q),C=r.mul(v,D),C=r.add(C,C),g=r.mul(m,C),b=r.mul(y,V),b=r.add(g,b),g=r.sub(F,b),b=r.add(F,b),b=r.mul(g,b),g=r.mul(q,g),C=r.mul(y,C),V=r.mul(m,V),q=r.sub(U,V),q=r.mul(m,q),q=r.add(q,C),C=r.add(U,U),U=r.add(C,U),U=r.add(U,V),U=r.mul(U,q),b=r.add(b,U),V=r.mul(N,D),V=r.add(V,V),U=r.mul(V,q),g=r.sub(g,U),C=r.mul(V,F),C=r.add(C,C),C=r.add(C,C),new _(g,b,C)}add(m){T(m);let{X:p,Y:y,Z:v}=this,{X:N,Y:D,Z:g}=m,b=r.ZERO,C=r.ZERO,U=r.ZERO,F=e.a,V=r.mul(e.b,Qn),q=r.mul(p,N),X=r.mul(y,D),Y=r.mul(v,g),Tt=r.add(p,y),G=r.add(N,D);Tt=r.mul(Tt,G),G=r.add(q,X),Tt=r.sub(Tt,G),G=r.add(p,v);let at=r.add(N,g);return G=r.mul(G,at),at=r.add(q,Y),G=r.sub(G,at),at=r.add(y,v),b=r.add(D,g),at=r.mul(at,b),b=r.add(X,Y),at=r.sub(at,b),U=r.mul(F,G),b=r.mul(V,Y),U=r.add(b,U),b=r.sub(X,U),U=r.add(X,U),C=r.mul(b,U),X=r.add(q,q),X=r.add(X,q),Y=r.mul(F,Y),G=r.mul(V,G),X=r.add(X,Y),Y=r.sub(q,Y),Y=r.mul(F,Y),G=r.add(G,Y),q=r.mul(X,G),C=r.add(C,q),q=r.mul(at,G),b=r.mul(Tt,b),b=r.sub(b,q),q=r.mul(Tt,X),U=r.mul(at,U),U=r.add(U,q),new _(b,C,U)}subtract(m){return this.add(m.negate())}is0(){return this.equals(_.ZERO)}multiply(m){let{endo:p}=t;if(!n.isValidNot0(m))throw new Error("invalid scalar: out of range");let y,v,N=D=>I.cached(this,D,g=>ye(_,g));if(p){let{k1neg:D,k1:g,k2neg:b,k2:C}=R(m),{p:U,f:F}=N(g),{p:V,f:q}=N(C);v=F.add(q),y=K(p.beta,U,V,D,b)}else{let{p:D,f:g}=N(m);y=D,v=g}return ye(_,[y,v])[0]}multiplyUnsafe(m){let{endo:p}=t,y=this;if(!n.isValid(m))throw new Error("invalid scalar: out of range");if(m===be||y.is0())return _.ZERO;if(m===Tr)return y;if(I.hasCache(this))return this.multiply(m);if(p){let{k1neg:v,k1:N,k2neg:D,k2:g}=R(m),{p1:b,p2:C}=Tc(_,y,N,g);return K(p.beta,b,C,v,D)}else return I.unsafe(y,m)}multiplyAndAddUnsafe(m,p,y){let v=this.multiplyUnsafe(p).add(m.multiplyUnsafe(y));return v.is0()?void 0:v}toAffine(m){return P(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return o===Tr?!0:m?m(_,this):I.unsafe(this,i).is0()}clearCofactor(){let{clearCofactor:m}=t;return o===Tr?this:m?m(_,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(m=!0){return de("isCompressed",m),this.assertValidity(),f(_,this,m)}toRawBytes(m=!0){return this.toBytes(m)}toHex(m=!0){return Mt(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}_.BASE=new _(e.Gx,e.Gy,r.ONE),_.ZERO=new _(r.ZERO,r.ONE,r.ZERO),_.Fp=r,_.Fn=n;let k=n.BITS,I=new xr(_,t.endo?Math.ceil(k/2):k);return _}function Qc(e){return Uint8Array.of(e?2:3)}function Jh(e,t,r={}){Ln(t),Ne(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=r.randomBytes||Zr,o=r.hmac||((g,...b)=>ws(t,g,It(...b))),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s,u=Ri(a),f={secret:s.BYTES,public:1+i.BYTES,publicUncompressed:1+2*i.BYTES,signature:2*s.BYTES,seed:u};function l(g){let b=a>>Tr;return g>b}function d(g){return l(g)?s.neg(g):g}function h(g,b){if(!s.isValidNot0(b))throw new Error(`invalid signature ${g}: out of range 1..CURVE.n`)}class S{constructor(b,C,U){h("r",b),h("s",C),this.r=b,this.s=C,U!=null&&(this.recovery=U),Object.freeze(this)}static fromBytes(b,C="compact"){if(C==="compact"){let U=s.BYTES;rt(b,U*2);let F=b.subarray(0,U),V=b.subarray(U,U*2);return new S(s.fromBytes(F),s.fromBytes(V))}if(C==="der"){rt(b);let{r:U,s:F}=we.toSig(b);return new S(U,F)}throw new Error("invalid format")}static fromHex(b,C){return this.fromBytes(He(b),C)}addRecoveryBit(b){return new S(this.r,this.s,b)}recoverPublicKey(b){let C=i.ORDER,{r:U,s:F,recovery:V}=this;if(V==null||![0,1,2,3].includes(V))throw new Error("recovery id invalid");if(a*Jc<C&&V>1)throw new Error("recovery id is ambiguous for h>1 curve");let X=V===2||V===3?U+a:U;if(!i.isValid(X))throw new Error("recovery id 2 or 3 invalid");let Y=i.toBytes(X),Tt=e.fromHex(It(Qc((V&1)===0),Y)),G=s.inv(X),at=k(Z("msgHash",b)),Ct=s.create(-at*G),Ae=s.create(F*G),Ke=e.BASE.multiplyUnsafe(Ct).add(Tt.multiplyUnsafe(Ae));if(Ke.is0())throw new Error("point at infinify");return Ke.assertValidity(),Ke}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,s.neg(this.s),this.recovery):this}toBytes(b="compact"){if(b==="compact")return It(s.toBytes(this.r),s.toBytes(this.s));if(b==="der")return He(we.hexFromSig(this));throw new Error("invalid format")}toHex(b){return Mt(this.toBytes(b))}assertValidity(){}static fromCompact(b){return S.fromBytes(Z("sig",b),"compact")}static fromDER(b){return S.fromBytes(Z("sig",b),"der")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Mt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Mt(this.toBytes("compact"))}}function w(g){try{return!!Ir(s,g)}catch{return!1}}function x(g,b){try{let C=g.length;return b===!0&&C!==f.public||b===!1&&C!==f.publicUncompressed?!1:!!e.fromBytes(g)}catch{return!1}}function T(g=n(u)){return Ni(g,a)}let R={isValidSecretKey:w,isValidPublicKey:x,randomSecretKey:T,isValidPrivateKey:w,randomPrivateKey:T,normPrivateKeyToScalar:g=>Ir(s,g),precompute(g=8,b=e.BASE){return b.precompute(g,!1)}};function P(g,b=!0){return e.BASE.multiply(Ir(s,g)).toBytes(b)}function L(g){if(typeof g=="bigint")return!1;if(g instanceof e)return!0;if(s.allowedLengths||f.secret===f.public)return;let b=Z("key",g).length;return b===f.public||b===f.publicUncompressed}function K(g,b,C=!0){if(L(g)===!0)throw new Error("first arg must be private key");if(L(b)===!1)throw new Error("second arg must be public key");let U=Ir(s,g);return e.fromHex(b).multiply(U).toBytes(C)}let _=r.bits2int||function(g){if(g.length>8192)throw new Error("input is too large");let b=mr(g),C=g.length*8-c;return C>0?b>>BigInt(C):b},k=r.bits2int_modN||function(g){return s.create(_(g))},I=Re(c);function A(g){return De("num < 2^"+c,g,be,I),s.toBytes(g)}function m(g,b,C=p){if(["recovered","canonical"].some(Ct=>Ct in C))throw new Error("sign() legacy options not supported");let{lowS:U,prehash:F,extraEntropy:V}=C;U==null&&(U=!0),g=Z("msgHash",g),Xc(C),F&&(g=Z("prehashed msgHash",t(g)));let q=k(g),X=Ir(s,b),Y=[A(X),A(q)];if(V!=null&&V!==!1){let Ct=V===!0?n(f.secret):V;Y.push(Z("extraEntropy",Ct))}let Tt=It(...Y),G=q;function at(Ct){let Ae=_(Ct);if(!s.isValidNot0(Ae))return;let Ke=s.inv(Ae),kr=e.BASE.multiply(Ae).toAffine(),Fe=s.create(kr.x);if(Fe===be)return;let Kr=s.create(Ke*s.create(G+Fe*X));if(Kr===be)return;let la=(kr.x===Fe?0:2)|Number(kr.y&Tr),da=Kr;return U&&l(Kr)&&(da=d(Kr),la^=1),new S(Fe,da,la)}return{seed:Tt,k2sig:at}}let p={lowS:r.lowS,prehash:!1},y={lowS:r.lowS,prehash:!1};function v(g,b,C=p){let{seed:U,k2sig:F}=m(g,b,C);return uc(t.outputLen,s.BYTES,o)(U,F)}e.BASE.precompute(8);function N(g,b,C,U=y){let F=g;b=Z("msgHash",b),C=Z("publicKey",C),Xc(U);let{lowS:V,prehash:q,format:X}=U;if("strict"in U)throw new Error("options.strict was renamed to lowS");let Y,Tt;if(X===void 0){let G=typeof F=="string"||qe(F),at=!G&&F!==null&&typeof F=="object"&&typeof F.r=="bigint"&&typeof F.s=="bigint";if(!G&&!at)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(at)Y=new S(F.r,F.s);else if(G){try{Y=S.fromDER(F)}catch(Ct){if(!(Ct instanceof we.Err))throw Ct}if(!Y)try{Y=S.fromCompact(F)}catch{return!1}}}else if(X==="compact"||X==="der"){if(typeof F!="string"&&!qe(F))throw new Error('"der" / "compact" format expects Uint8Array signature');Y=S.fromBytes(Z("sig",F),X)}else if(X==="js"){if(!(F instanceof S))throw new Error('"js" format expects Signature instance');Y=F}else throw new Error('format must be "compact", "der" or "js"');if(!Y)return!1;try{if(Tt=e.fromHex(C),V&&Y.hasHighS())return!1;q&&(b=t(b));let{r:G,s:at}=Y,Ct=k(b),Ae=s.inv(at),Ke=s.create(Ct*Ae),kr=s.create(G*Ae),Fe=e.BASE.multiplyUnsafe(Ke).add(Tt.multiplyUnsafe(kr));return Fe.is0()?!1:s.create(Fe.x)===G}catch{return!1}}function D(g){let b=R.randomSecretKey(g);return{secretKey:b,publicKey:P(b)}}return Object.freeze({keygen:D,getPublicKey:P,sign:v,verify:N,getSharedSecret:K,utils:R,Point:e,Signature:S,info:{type:"weierstrass",lengths:f,publicKeyHasPrefix:!0}})}function Qh(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0,o=Dt(t.n,{BITS:e.nBitLength,allowedLengths:n,modOnDecode:e.wrapPrivateKey}),i={Fp:r,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:i}}function tp(e){let{CURVE:t,curveOpts:r}=Qh(e),n={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,hash:e.hash,ecdsaOpts:n}}function ep(e,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:e})}function tu(e){let{CURVE:t,curveOpts:r,hash:n,ecdsaOpts:o}=tp(e),i=Xh(t,r),s=Jh(i,n,o);return ep(e,s)}function eu(e,t){let r=n=>tu({...e,hash:n});return{...r(t),create:r}}var Ss={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},rp={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var ru=BigInt(2);function np(e){let t=Ss.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,f=u*u*e%t,l=Q(f,r,t)*f%t,d=Q(l,r,t)*f%t,h=Q(d,ru,t)*u%t,S=Q(h,o,t)*h%t,w=Q(S,i,t)*S%t,x=Q(w,a,t)*w%t,T=Q(x,c,t)*x%t,R=Q(T,a,t)*w%t,P=Q(R,r,t)*f%t,L=Q(P,s,t)*S%t,K=Q(L,n,t)*u%t,_=Q(K,ru,t);if(!Es.eql(Es.sqr(_),e))throw new Error("Cannot find square root");return _}var Es=Dt(Ss.p,void 0,void 0,{sqrt:np}),Cr=eu({...Ss,Fp:Es,lowS:!0,endo:rp},Fn);function nu(e,t,r,n){let o=$r.digest(r instanceof Uint8Array?r:r.subarray());if(jn(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Cr.verify(t,i,e))).catch(i=>{throw i.name==="AbortError"?i:new rn(String(i))});try{return n?.signal?.throwIfAborted(),Cr.verify(t,o.digest,e)}catch(i){throw new rn(String(i))}}var to=class{type="secp256k1";raw;_key;constructor(t){this._key=iu(t),this.raw=ou(this._key)}toMultihash(){return Bt.digest(dr(this))}toCID(){return z.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}verify(t,r,n){return nu(this._key,r,t,n)}};function vs(e){return new to(e)}function ou(e){return Cr.ProjectivePoint.fromHex(e).toRawBytes(!0)}function iu(e){try{return Cr.ProjectivePoint.fromHex(e),e}catch(t){throw new rr(String(t))}}function su(e,t){let{Type:r,Data:n}=ne.decode(e),o=n??new Uint8Array;switch(r){case ot.RSA:return ys(o,t);case ot.Ed25519:return Hi(o);case ot.secp256k1:return vs(o);case ot.ECDSA:return Ei(o);default:throw new or}}function eo(e){let{Type:t,Data:r}=ne.decode(e.digest),n=r??new Uint8Array;switch(t){case ot.Ed25519:return Hi(n);case ot.secp256k1:return vs(n);case ot.ECDSA:return Ei(n);default:throw new or}}function dr(e){return ne.encode({Type:ot[e.type],Data:e.raw})}var au=Symbol.for("nodejs.util.inspect.custom"),op=114,fn=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()})`}[zo]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return z.createV1(op,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return J(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return J(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[au](){return`PeerId(${this.toString()})`}},ro=class extends fn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},no=class extends fn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},oo=class extends fn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},ip=2336,ln=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Bt.digest($(this.url))}[au](){return`PeerId(${this.url})`}[zo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return z.createV1(ip,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=H(t)),t.toString()===this.toString())}};var sp=114,cu=2336;function uu(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Me(W.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return As(z.parse(e));if(t==null)throw new it('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Me(t.decode(e))}return fu(r)}function fu(e){if(cp(e))return new ro({multihash:e});if(ap(e))try{let t=eo(e);if(t.type==="Ed25519")return new no({multihash:e,publicKey:t});if(t.type==="secp256k1")return new oo({multihash:e,publicKey:t})}catch{let r=H(e.digest);return new ln(new URL(r))}throw new nr("Supplied PeerID Multihash is invalid")}function As(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==sp&&e.code!==cu)throw new Bn("Supplied PeerID CID is invalid");if(e.code===cu){let t=H(e.multihash.digest);return new ln(new URL(t))}return fu(e.multihash)}function ap(e){return e.code===Bt.code}function cp(e){return e.code===$r.code}var ht=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},Ee=class extends Error{static name="ValidationError";name="ValidationError"},dn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},io=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var so=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,t);if(!Number.isNaN(d))return d});if(f===void 0)break;if(i*=t,i+=f,i>u||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var up=45,fp=15,ao=new so;function Is(e){if(!(e.length>fp))return ao.new(e).parseWith(()=>ao.readIPv4Addr())}function Ts(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>up))return ao.new(e).parseWith(()=>ao.readIPv6Addr())}function co(e){return!!Is(e)}function du(e){return!!Ts(e)}function Bs(e){return t=>H(t,e)}function _s(e){return t=>$(t,e)}function Br(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Je(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function hu(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=$(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Je(n);return Ft([r,o],r.length+o.length)}function pu(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=Qt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Je(n);return Ft([r,o],r.length+o.length)}function Ps(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=H(t,"base32"),o=Br(r);return`${n}:${o}`}var Ds=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ht("Invalid byte value in IP address");t[n]=o}),t},mu=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=co(r[n]),s;i&&(s=Ds(r[n]),r[n]=H(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,H(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new ht("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},yu=function(e){if(e.byteLength!==4)throw new ht("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},gu=function(e){if(e.byteLength!==16)throw new ht("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],i=e[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;t.push(s)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new ht(`Invalid IPv6 address "${r}"`)}};function xu(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new ht(`Invalid IPv6 address "${e}"`)}}var Cs=Object.values(qr).map(e=>e.decoder),lp=function(){let e=Cs[0].or(Cs[1]);return Cs.slice(2).forEach(t=>e=e.or(t)),e}();function wu(e){return lp.decode(e)}function bu(e){return t=>e.encoder.encode(t)}function dp(e){if(parseInt(e).toString()!==e)throw new Ee("Value must be an integer")}function hp(e){if(e<0)throw new Ee("Value must be a positive integer, or zero")}function pp(e){return t=>{if(t>e)throw new Ee(`Value must be smaller than or equal to ${e}`)}}function mp(...e){return t=>{for(let r of e)r(t)}}var hn=mp(dp,hp,pp(65535));var ft=-1,Rs=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new io(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},Ut=new Rs,zp=[{code:4,name:"ip4",size:32,valueToBytes:Ds,bytesToValue:yu,validate:e=>{if(!co(e))throw new Ee(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Je,bytesToValue:Br,validate:hn},{code:273,name:"udp",size:16,valueToBytes:Je,bytesToValue:Br,validate:hn},{code:33,name:"dccp",size:16,valueToBytes:Je,bytesToValue:Br,validate:hn},{code:41,name:"ip6",size:128,valueToBytes:mu,bytesToValue:gu,stringToValue:xu,validate:e=>{if(!du(e))throw new Ee(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ft},{code:43,name:"ipcidr",size:8,bytesToValue:Bs("base10"),valueToBytes:_s("base10")},{code:53,name:"dns",size:ft,resolvable:!0},{code:54,name:"dns4",size:ft,resolvable:!0},{code:55,name:"dns6",size:ft,resolvable:!0},{code:56,name:"dnsaddr",size:ft,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:Je,bytesToValue:Br,validate:hn},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ft,path:!0,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ft,bytesToValue:Bs("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?_s("base58btc")(e):z.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Ps,valueToBytes:hu},{code:445,name:"onion3",size:296,bytesToValue:Ps,valueToBytes:pu},{code:446,name:"garlic64",size:ft},{code:447,name:"garlic32",size:ft},{code:448,name:"tls"},{code:449,name:"sni",size:ft},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ft,bytesToValue:bu(Qo),valueToBytes:wu},{code:480,name:"http"},{code:481,name:"http-path",size:ft,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ft}];zp.forEach(e=>{Ut.addProtocol(e)});function Eu(e){let t=[],r=0;for(;r<e.length;){let n=Wi(e,r),o=Ut.getProtocol(n),i=re(n),s=jp(o,e,r+i),a=0;s>0&&o.size===ft&&(a=re(s));let c=i+a+s,u={code:n,name:o.name,bytes:e.subarray(r,r+c)};if(s>0){let f=r+i+a,l=e.subarray(f,f+s);u.value=o.bytesToValue?.(l)??H(l)}t.push(u),r+=c}return t}function Su(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=Ut.getProtocol(n.code),i=re(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??$(n.value),a=s.byteLength,o.size===ft&&(c=re(a)));let u=new Uint8Array(i+c+a),f=0;nn(n.code,u,f),f+=i,s!=null&&(o.size===ft&&(nn(a,u,f),f+=c),u.set(s,f)),n.bytes=u}r.push(n.bytes),t+=n.bytes.byteLength}return Ft(r,t)}function vu(e){if(e.charAt(0)!=="/")throw new ht('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let i=1;i<e.length;i++){let s=e.charAt(i);s!=="/"&&(r==="protocol"?o+=e.charAt(i):n+=e.charAt(i));let a=i===e.length-1;if(s==="/"||a){let c=Ut.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new ht(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new ht(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}t.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ht("Incomplete multiaddr");return t}function Au(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=Ut.getProtocol(t.code);if(r==null)throw new ht(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function jp(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Wi(t,r)}var Gp=Symbol.for("nodejs.util.inspect.custom"),Ms=Symbol.for("@multiformats/multiaddr"),Zp=[53,54,55,56],Fs=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}};function Yp(e){if(e==null&&(e="/"),Tu(e))return e.getComponents();if(e instanceof Uint8Array)return Eu(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),vu(e);if(Array.isArray(e))return e;throw new ht("Must be a string, Uint8Array, Component[], or another Multiaddr")}var po=class e{[Ms]=!0;#t;#n;#e;constructor(t="/",r={}){this.#t=Yp(t),r.validate!==!1&&Wp(this)}get bytes(){return this.#e==null&&(this.#e=Su(this.#t)),this.#e}toString(){return this.#n==null&&(this.#n=Au(this.#t)),this.#n}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="";for(let{code:a,name:c,value:u}of this.#t)a===42&&(i=`%${u??""}`),Zp.includes(a)&&(r="tcp",o=443,n=`${u??""}${i}`,t=a===55?6:4),(a===6||a===273)&&(r=c==="tcp"?"tcp":"udp",o=parseInt(u??"")),(a===4||a===41)&&(r="tcp",n=`${u??""}${i}`,t=a===41?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}getComponents(){return[...this.#t]}protos(){return this.#t.map(({code:t,value:r})=>{let n=Ut.getProtocol(t);return{code:t,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#t.map(({code:t})=>t)}protoNames(){return this.#t.map(({name:t})=>t)}tuples(){return this.#t.map(({code:t,value:r})=>{if(r==null)return[t];let n=Ut.getProtocol(t),o=[t];return r!=null&&o.push(n.valueToBytes?.(r)??$(r)),o})}stringTuples(){return this.#t.map(({code:t,value:r})=>r==null?[t]:[t,r])}encapsulate(t){let r=new e(t);return new e([...this.#t,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new dn(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}getPeerId(){try{let t=[];this.#t.forEach(({code:n,value:o})=>{n===421&&t.push([n,o]),n===290&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?H(W.decode(`z${n}`),"base58btc"):H(z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let t of this.#t)if(Ut.getProtocol(t.code).path)return t.value??null;return null}equals(t){return J(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Iu.get(r.name);if(n==null)throw new Fs(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Qe(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(){return!(this.#t.length!==2||this.#t[0].code!==4&&this.#t[0].code!==41||this.#t[1].code!==6&&this.#t[1].code!==273)}[Gp](){return`Multiaddr(${this.toString()})`}};function Wp(e){e.getComponents().forEach(t=>{let r=Ut.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}var d1=parseInt("0xFFFF",16),h1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Iu=new Map;function Tu(e){return!!e?.[Ms]}function Qe(e){return new po(e)}function mn(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*mo(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}var U0=Ho($s(),1);var Gt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},yo=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},_r=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},go=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},xo=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},wo=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},yn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Zt;(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=()=>an(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=vr((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 u=o.uint32();switch(u>>>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(u&7);break}}}return a})),n),e.encode=o=>Er(o,e.codec()),e.decode=(o,i)=>br(o,e.codec(),i)})(Zt||(Zt={}));var e0=["string","number","bigint","symbol"],r0=["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 _u(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(e0.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(n0(e))return"Buffer";let r=o0(e);return r||"Object"}function n0(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function o0(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(r0.includes(t))return t}var E=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}};E.uint=new E(0,"uint",!0);E.negint=new E(1,"negint",!0);E.bytes=new E(2,"bytes",!0);E.string=new E(3,"string",!0);E.array=new E(4,"array",!1);E.map=new E(5,"map",!1);E.tag=new E(6,"tag",!1);E.float=new E(7,"float",!0);E.false=new E(7,"false",!0);E.true=new E(7,"true",!0);E.null=new E(7,"null",!0);E.undefined=new E(7,"undefined",!0);E.break=new E(7,"break",!0);var O=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 Pr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",i0=new TextDecoder,s0=new TextEncoder;function bo(e){return Pr&&globalThis.Buffer.isBuffer(e)}function Nu(e){return e instanceof Uint8Array?bo(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Uu=Pr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Du(e,t,r):(e,t,r)=>r-t>64?i0.decode(e.subarray(t,r)):Du(e,t,r),Lu=Pr?e=>e.length>64?globalThis.Buffer.from(e):Pu(e):e=>e.length>64?s0.encode(e):Pu(e);var Dr=Pr?(e,t,r)=>bo(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Ou=Pr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Nu(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},ku=Pr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ku(e,t){if(bo(e)&&bo(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 Pu(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 Du(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,u,f;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(f=(o&31)<<6|a&63,f>127&&(i=f));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(f=(o&15)<<12|(a&63)<<6|c&63,f>2047&&(f<55296||f>57343)&&(i=f));break;case 4:a=e[t+1],c=e[t+2],u=e[t+3],(a&192)===128&&(c&192)===128&&(u&192)===128&&(f=(o&15)<<18|(a&63)<<12|(c&63)<<6|u&63,f>65535&&f<1114112&&(i=f))}}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 a0(n)}var Ru=4096;function a0(e){let t=e.length;if(t<=Ru)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ru));return r}var c0=256,Eo=class{constructor(t=c0){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=ku(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=Dr(n,0,this.cursor)}else r=Ou(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",qs="CBOR encode error:",gn=[];gn[23]=1;gn[24]=2;gn[25]=3;gn[26]=5;gn[27]=9;function Se(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var lt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Lt(e,t,r){Se(e,t,1);let n=e[t];if(r.strict===!0&&n<lt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ot(e,t,r){Se(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<lt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function kt(e,t,r){Se(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<lt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(e,t,r){Se(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<lt[3])throw new Error(`${M} 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(`${M} integers outside of the safe integer range are not supported`)}function Fu(e,t,r,n){return new O(E.uint,Lt(e,t+1,n),2)}function Mu(e,t,r,n){return new O(E.uint,Ot(e,t+1,n),3)}function Vu(e,t,r,n){return new O(E.uint,kt(e,t+1,n),5)}function $u(e,t,r,n){return new O(E.uint,Kt(e,t+1,n),9)}function $t(e,t){return pt(e,0,t.value)}function pt(e,t,r){if(r<lt[0]){let n=Number(r);e.push([t|n])}else if(r<lt[1]){let n=Number(r);e.push([t|24,n])}else if(r<lt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<lt[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<lt[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(`${M} encountered BigInt larger than allowable range`)}}$t.encodedSize=function(t){return pt.encodedSize(t.value)};pt.encodedSize=function(t){return t<lt[0]?1:t<lt[1]?2:t<lt[2]?3:t<lt[3]?5:9};$t.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function qu(e,t,r,n){return new O(E.negint,-1-Lt(e,t+1,n),2)}function Hu(e,t,r,n){return new O(E.negint,-1-Ot(e,t+1,n),3)}function zu(e,t,r,n){return new O(E.negint,-1-kt(e,t+1,n),5)}var Hs=BigInt(-1),ju=BigInt(1);function Gu(e,t,r,n){let o=Kt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new O(E.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new O(E.negint,Hs-BigInt(o),9)}function So(e,t){let r=t.value,n=typeof r=="bigint"?r*Hs-ju:r*-1-1;pt(e,t.type.majorEncoded,n)}So.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Hs-ju:r*-1-1;return n<lt[0]?1:n<lt[1]?2:n<lt[2]?3:n<lt[3]?5:9};So.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function xn(e,t,r,n){Se(e,t,r+n);let o=Dr(e,t+r,t+r+n);return new O(E.bytes,o,r+n)}function Zu(e,t,r,n){return xn(e,t,1,r)}function Yu(e,t,r,n){return xn(e,t,2,Lt(e,t+1,n))}function Wu(e,t,r,n){return xn(e,t,3,Ot(e,t+1,n))}function Xu(e,t,r,n){return xn(e,t,5,kt(e,t+1,n))}function Ju(e,t,r,n){let o=Kt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return xn(e,t,9,o)}function vo(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===E.string?Lu(e.value):e.value),e.encodedBytes}function Rr(e,t){let r=vo(t);pt(e,t.type.majorEncoded,r.length),e.push(r)}Rr.encodedSize=function(t){let r=vo(t);return pt.encodedSize(r.length)+r.length};Rr.compareTokens=function(t,r){return f0(vo(t),vo(r))};function f0(e,t){return e.length<t.length?-1:e.length>t.length?1:Ku(e,t)}function wn(e,t,r,n,o){let i=r+n;Se(e,t,i);let s=new O(E.string,Uu(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Dr(e,t+r,t+i)),s}function Qu(e,t,r,n){return wn(e,t,1,r,n)}function tf(e,t,r,n){return wn(e,t,2,Lt(e,t+1,n),n)}function ef(e,t,r,n){return wn(e,t,3,Ot(e,t+1,n),n)}function rf(e,t,r,n){return wn(e,t,5,kt(e,t+1,n),n)}function nf(e,t,r,n){let o=Kt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return wn(e,t,9,o,n)}var of=Rr;function Nr(e,t,r,n){return new O(E.array,n,r)}function sf(e,t,r,n){return Nr(e,t,1,r)}function af(e,t,r,n){return Nr(e,t,2,Lt(e,t+1,n))}function cf(e,t,r,n){return Nr(e,t,3,Ot(e,t+1,n))}function uf(e,t,r,n){return Nr(e,t,5,kt(e,t+1,n))}function ff(e,t,r,n){let o=Kt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Nr(e,t,9,o)}function lf(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Nr(e,t,1,1/0)}function Ao(e,t){pt(e,E.array.majorEncoded,t.value)}Ao.compareTokens=$t.compareTokens;Ao.encodedSize=function(t){return pt.encodedSize(t.value)};function Ur(e,t,r,n){return new O(E.map,n,r)}function df(e,t,r,n){return Ur(e,t,1,r)}function hf(e,t,r,n){return Ur(e,t,2,Lt(e,t+1,n))}function pf(e,t,r,n){return Ur(e,t,3,Ot(e,t+1,n))}function mf(e,t,r,n){return Ur(e,t,5,kt(e,t+1,n))}function yf(e,t,r,n){let o=Kt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return Ur(e,t,9,o)}function gf(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Ur(e,t,1,1/0)}function Io(e,t){pt(e,E.map.majorEncoded,t.value)}Io.compareTokens=$t.compareTokens;Io.encodedSize=function(t){return pt.encodedSize(t.value)};function xf(e,t,r,n){return new O(E.tag,r,1)}function wf(e,t,r,n){return new O(E.tag,Lt(e,t+1,n),2)}function bf(e,t,r,n){return new O(E.tag,Ot(e,t+1,n),3)}function Ef(e,t,r,n){return new O(E.tag,kt(e,t+1,n),5)}function Sf(e,t,r,n){return new O(E.tag,Kt(e,t+1,n),9)}function To(e,t){pt(e,E.tag.majorEncoded,t.value)}To.compareTokens=$t.compareTokens;To.encodedSize=function(t){return pt.encodedSize(t.value)};var y0=20,g0=21,x0=22,w0=23;function vf(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new O(E.null,null,1):new O(E.undefined,void 0,1)}function Af(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new O(E.break,void 0,1)}function zs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new O(E.float,e,t)}function If(e,t,r,n){return zs(js(e,t+1),3,n)}function Tf(e,t,r,n){return zs(Gs(e,t+1),5,n)}function Cf(e,t,r,n){return zs(Df(e,t+1),9,n)}function Co(e,t,r){let n=t.value;if(n===!1)e.push([E.float.majorEncoded|y0]);else if(n===!0)e.push([E.float.majorEncoded|g0]);else if(n===null)e.push([E.float.majorEncoded|x0]);else if(n===void 0)e.push([E.float.majorEncoded|w0]);else{let o,i=!1;(!r||r.float64!==!0)&&(_f(n),o=js(Yt,1),n===o||Number.isNaN(n)?(Yt[0]=249,e.push(Yt.slice(0,3)),i=!0):(Pf(n),o=Gs(Yt,1),n===o&&(Yt[0]=250,e.push(Yt.slice(0,5)),i=!0))),i||(b0(n),o=Df(Yt,1),Yt[0]=251,e.push(Yt.slice(0,9)))}}Co.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){_f(n);let o=js(Yt,1);if(n===o||Number.isNaN(n))return 3;if(Pf(n),o=Gs(Yt,1),n===o)return 5}return 9};var Bf=new ArrayBuffer(9),qt=new DataView(Bf,1),Yt=new Uint8Array(Bf,0);function _f(e){if(e===1/0)qt.setUint16(0,31744,!1);else if(e===-1/0)qt.setUint16(0,64512,!1);else if(Number.isNaN(e))qt.setUint16(0,32256,!1);else{qt.setFloat32(0,e);let t=qt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)qt.setUint16(0,31744,!1);else if(r===0)qt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?qt.setUint16(0,0):o<-14?qt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):qt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function js(e,t){if(e.length-t<2)throw new Error(`${M} 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 Pf(e){qt.setFloat32(0,e,!1)}function Gs(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function b0(e){qt.setFloat64(0,e,!1)}function Df(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Co.compareTokens=$t.compareTokens;function j(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Bo(e){return()=>{throw new Error(`${M} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=j;B[24]=Fu;B[25]=Mu;B[26]=Vu;B[27]=$u;B[28]=j;B[29]=j;B[30]=j;B[31]=j;for(let e=32;e<=55;e++)B[e]=j;B[56]=qu;B[57]=Hu;B[58]=zu;B[59]=Gu;B[60]=j;B[61]=j;B[62]=j;B[63]=j;for(let e=64;e<=87;e++)B[e]=Zu;B[88]=Yu;B[89]=Wu;B[90]=Xu;B[91]=Ju;B[92]=j;B[93]=j;B[94]=j;B[95]=Bo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=Qu;B[120]=tf;B[121]=ef;B[122]=rf;B[123]=nf;B[124]=j;B[125]=j;B[126]=j;B[127]=Bo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=sf;B[152]=af;B[153]=cf;B[154]=uf;B[155]=ff;B[156]=j;B[157]=j;B[158]=j;B[159]=lf;for(let e=160;e<=183;e++)B[e]=df;B[184]=hf;B[185]=pf;B[186]=mf;B[187]=yf;B[188]=j;B[189]=j;B[190]=j;B[191]=gf;for(let e=192;e<=215;e++)B[e]=xf;B[216]=wf;B[217]=bf;B[218]=Ef;B[219]=Sf;B[220]=j;B[221]=j;B[222]=j;B[223]=j;for(let e=224;e<=243;e++)B[e]=Bo("simple values are not supported");B[244]=j;B[245]=j;B[246]=j;B[247]=vf;B[248]=Bo("simple values are not supported");B[249]=If;B[250]=Tf;B[251]=Cf;B[252]=j;B[253]=j;B[254]=j;B[255]=Af;var Wt=[];for(let e=0;e<24;e++)Wt[e]=new O(E.uint,e,1);for(let e=-1;e>=-24;e--)Wt[31-e]=new O(E.negint,e,1);Wt[64]=new O(E.bytes,new Uint8Array(0),1);Wt[96]=new O(E.string,"",1);Wt[128]=new O(E.array,0,1);Wt[160]=new O(E.map,0,1);Wt[244]=new O(E.false,!1,1);Wt[245]=new O(E.true,!0,1);Wt[246]=new O(E.null,null,1);function S0(){let e=[];return e[E.uint.major]=$t,e[E.negint.major]=So,e[E.bytes.major]=Rr,e[E.string.major]=of,e[E.array.major]=Ao,e[E.map.major]=Io,e[E.tag.major]=To,e[E.float.major]=Co,e}var W2=S0(),X2=new Eo,_o=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(`${qs} object contains circular references`);return new e(r,t)}},Le={null:new O(E.null,null),undefined:new O(E.undefined,void 0),true:new O(E.true,!0),false:new O(E.false,!1),emptyArray:new O(E.array,0),emptyMap:new O(E.map,0)},Oe={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new O(E.float,e):e>=0?new O(E.uint,e):new O(E.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new O(E.uint,e):new O(E.negint,e)},Uint8Array(e,t,r,n){return new O(E.bytes,e)},string(e,t,r,n){return new O(E.string,e)},boolean(e,t,r,n){return e?Le.true:Le.false},null(e,t,r,n){return Le.null},undefined(e,t,r,n){return Le.undefined},ArrayBuffer(e,t,r,n){return new O(E.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new O(E.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Le.emptyArray,new O(E.break)]:Le.emptyArray;n=_o.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Zs(s,r,n);return r.addBreakTokens?[new O(E.array,e.length),o,new O(E.break)]:[new O(E.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?[Le.emptyMap,new O(E.break)]:Le.emptyMap;n=_o.createCheck(n,e);let a=[],c=0;for(let u of i)a[c++]=[Zs(u,r,n),Zs(o?e.get(u):e[u],r,n)];return v0(a,r),r.addBreakTokens?[new O(E.map,s),a,new O(E.break)]:[new O(E.map,s),a]}};Oe.Map=Oe.Object;Oe.Buffer=Oe.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Oe[`${e}Array`]=Oe.DataView;function Zs(e,t={},r){let n=_u(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Oe[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Oe[n];if(!i)throw new Error(`${qs} unsupported type: ${n}`);return i(e,n,t,r)}function v0(e,t){t.mapSorter&&e.sort(t.mapSorter)}var A0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Po=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=Wt[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${M} 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}},bn=Symbol.for("DONE"),Do=Symbol.for("BREAK");function I0(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Lr(t,r);if(i===Do){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===bn)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function T0(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=Lr(t,r);if(a===Do){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(a===bn)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${M} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${M} found repeat map key "${a}"`);let c=Lr(t,r);if(c===bn)throw new Error(`${M} 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 Lr(e,t){if(e.done())return bn;let r=e.next();if(r.type===E.break)return Do;if(r.type.terminal)return r.value;if(r.type===E.array)return I0(r,e,t);if(r.type===E.map)return T0(r,e,t);if(r.type===E.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Lr(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function Rf(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},A0,t);let r=t.tokenizer||new Po(e,t),n=Lr(r,t);if(n===bn)throw new Error(`${M} did not find any content to decode`);if(n===Do)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function Ys(e,t){let[r,n]=Rf(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var _0=Te("ipns:utils"),Nf=$("/ipns/");var P0=0,D0=18;function Uf(e){let t;if(e.pubKey!=null)try{t=su(e.pubKey)}catch(r){throw _0.error(r),r}if(t!=null)return t}function Lf(e){let t=$("ipns-signature:");return Ft([t,e])}function er(e){return"signatureV1"in e?Zt.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}):Zt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function oe(e){let t=Zt.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 Gt("Missing data or signatureV2");let r=Of(t.data),n=R0(r.Value),o=H(r.Validity);if(t.value!=null&&t.signatureV1!=null)return N0(t),{value:n,validityType:Zt.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:Zt.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 En(e){return Ft([Nf,e.bytes])}function ve(e){let t=Me(e.slice(Nf.length));if(!Ro(t,P0)&&!Ro(t,D0))throw new nr("Multihash in IPNS key was not identity or sha2-256");return t}function Of(e){let t=Ys(e);if(t.ValidityType===0)t.ValidityType=Zt.ValidityType.EOL;else throw new _r("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 R0(e){let t=H(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${z.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${z.parse(t).toV1().toString()}`}catch{}throw new xo("Value must be a valid content path starting with /")}function N0(e){if(e.data==null)throw new wo("Record data is missing");let t=Of(e.data);if(!J(t.Value,e.value??new Uint8Array(0)))throw new Gt('Field "value" did not match between protobuf and CBOR');if(!J(t.Validity,e.validity??new Uint8Array(0)))throw new Gt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Gt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Gt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Gt('Field "ttl" did not match between protobuf and CBOR')}function Ro(e,t){return e.code===t}var bE=Te("ipns"),EE=300*1e9,L0="/ipns/",SE=L0.length;var kf=Ho($s(),1);var No=Te("ipns:validator"),O0=1024*10;async function k0(e,t){let r=oe(t),n;try{let o=Lf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw No.error("record signature verification failed"),new Gt("Record signature verification failed");if(r.validityType===Zt.ValidityType.EOL){if(kf.default.fromString(r.validity).toDate().getTime()<Date.now())throw No.error("record has expired"),new yo("record has expired")}else if(r.validityType!=null)throw No.error("the validity type is unsupported"),new _r("The validity type is unsupported");No("ipns record for %s is valid",r.value)}async function Kf(e,t){if(t.byteLength>O0)throw new go("The record is too large");let r=ve(e),n;Ro(r,0)&&(n=eo(r));let o=oe(t),i=Uf(o)??n;if(i==null)throw new yn("Could not extract public key from IPNS record or routing key");let s=En(i.toMultihash());if(!J(s,e))throw new yn("Embedded public key did not match routing key");await k0(i,t)}var Uo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Sn(e,t={}){let r=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of e){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),fr(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new Uo("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function ie(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Xs=Ho(Mf(),1);var An=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Js=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},Vf=e=>globalThis.DOMException===void 0?new Js(e):new DOMException(e),$f=e=>{let t=e.reason===void 0?Vf("This operation was aborted."):e.reason;return t instanceof Error?t:Vf(t)};function Qs(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,u=new Promise((f,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:h}=t;h.aborted&&l($f(h)),a=()=>{l($f(h))},h.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(f,l);return}let d=new An;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){l(h)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?f():o instanceof Error?l(o):(d.message=o??`Promise timed out after ${r} milliseconds`,l(d))},r),(async()=>{try{f(await e)}catch(h){l(h)}})()}).finally(()=>{u.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},u}function ta(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var In=class{#t=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=r.priority){this.#t.push(n);return}let o=ta(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var Tn=class extends Xs.default{#t;#n;#e=0;#h;#a;#p=0;#o;#c;#r;#m;#i=0;#u;#s;#y;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:In,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#n=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#r=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#n||this.#e<this.#h}get#E(){return this.#i<this.#u}#S(){this.#i--,this.#f(),this.emit("next")}#v(){this.#x(),this.#g(),this.#c=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let r=this.#p-t;if(r<0)this.#e=this.#t?this.#i:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#v()},r)),!0}return!1}#f(){if(this.#r.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#E){let r=this.#r.dequeue();return r?(this.emit("active"),r(),t&&this.#g(),!0):!1}}return!1}#g(){this.#n||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#a),this.#p=Date.now()+this.#a)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#l()}#l(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#l()}async#I(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#r.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#w++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#r.enqueue(async()=>{this.#i++,this.#e++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Qs(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#I(r.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof An&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#l(),this):this}pause(){this.#s=!0}clear(){this.#r=new this.#m}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#r.size<t||await this.#d("next",()=>this.#r.size<t)}async onIdle(){this.#i===0&&this.#r.size===0||await this.#d("idle")}async#d(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#r.size}sizeBy(t){return this.#r.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var Or=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Xt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function M0(e){return e[Symbol.asyncIterator]!=null}function V0(e){if(M0(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Oo=V0;function $0(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var qf=$0;function q0(e){return e[Symbol.asyncIterator]!=null}function H0(e,t){let r=0;if(q0(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=qf(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,r++);if(typeof s.then=="function")return async function*(){yield await s;for(let c of n)yield t(c,r++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,r++)}()}var ko=H0;var Hf=$("/ipns/");function zf(e){return J(e.subarray(0,Hf.byteLength),Hf)}var Ko=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*ko(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!zf(t))return;let o=ve(t),i=z.createV1(114,o),s=oe(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!zf(t))throw new St("Not found");let n=ve(t),o=z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return er(i)}catch(i){throw i.name==="BadResponseError"?new St("Not found"):i}}},Fo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Oo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new St("Not found")}async*getClosestPeers(t,r={}){}};var mt=Te("delegated-routing-v1-http-api-client"),Mo={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},Vo=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new Tn({concurrency:r.concurrentRequests??Mo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??Mo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new Ko(this),this.peerRouting=new Fo(this),this.cacheName=r.cacheName??Mo.cacheName,this.cacheTTL=r.cacheTTL??Mo.cacheTTL}get[ma](){return this.contentRouting}get[ya](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&&mt("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,r={}){mt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#n(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},u=await this.#e(a.toString(),c);if(u==null)throw new Xt("No response received");if(!u.ok)throw u.status===404?new St("No matching records found"):u.status===422?new Or("Request does not conform to schema or semantic constraints"):new Xt(`Unexpected status code: ${u.status}`);if(u.body==null)throw new Xt("Routing response had no body");let f=u.headers.get("Content-Type");if(f==null)throw new Xt("No Content-Type header received");if(f?.startsWith("application/json")){let l=await u.json();for(let d of l.Providers){let h=this.#t(d);h!=null&&(yield h)}}else if(f.includes("application/x-ndjson"))for await(let l of Sn(mo(u.body))){let d=this.#t(l);d!=null&&(yield d)}else throw new Xt(`Unsupported Content-Type: ${f}`)}finally{o.clear(),s.resolve(),mt("getProviders finished: %c",t)}}async*getPeers(t,r={}){mt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#n(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},u=await this.#e(a.toString(),c);if(u.status===404)throw new St("No matching records found");if(u.status===422)throw new Or("Request does not conform to schema or semantic constraints");if(u.body==null)throw new Xt("Routing response had no body");if(u.headers.get("Content-Type")==="application/json"){let l=await u.json();for(let d of l.Peers){let h=this.#t(d);h!=null&&(yield h)}}else for await(let l of Sn(mo(u.body))){let d=this.#t(l);d!=null&&(yield d)}}catch(a){mt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),mt("getPeers finished: %c",t)}}async getIPNS(t,r={}){mt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},u=await this.#e(a,c);if(mt("getIPNS GET %s %d",a,u.status),u.status===404)throw new St("No matching records found");if(u.status===422)throw new Or("Request does not conform to schema or semantic constraints");if(u.body==null)throw new Xt("GET ipns response had no body");let f=await u.arrayBuffer(),l=new Uint8Array(f,0,f.byteLength);return r.validate!==!1&&await Kf(En(t.multihash),l),oe(l)}catch(c){throw mt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),mt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){mt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=mn([this.shutDownController.signal,o,n.signal]);let s=ie(),a=ie();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let u=er(r),f={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:u,signal:i},l=await this.#e(c,f);if(mt("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new Xt("PUT ipns response had status other than 200")}catch(u){throw mt.error("putIPNS PUT %s error:",c,u.stack),u}finally{i.clear(),a.resolve(),mt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Qe)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:uu(t.ID),Addrs:n,Protocols:r}}catch(r){mt.error("could not conform record to peer schema",r)}}#n(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return mt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return mt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let u=Date.now()+this.cacheTTL,f=new Headers(c.headers);f.set("x-cache-expires",u.toString());let l=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:f});await this.cache.put(t,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function jf(e,t={}){return new Vo(new URL(e),t)}function $o(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Gf=$("/ipns/");function Zf(e){return J(e.subarray(0,Gf.byteLength),Gf)}var ea=class{client;constructor(t,r={}){this.client=jf(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*ko(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!Zf(t))return;let o=ve(t),i=z.createV1(114,o),s=oe(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Zf(t))throw new St("Not found");let n=ve(t),o=z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return er(i)}catch(i){throw i.name==="BadResponseError"?new St("Not found"):i}}async findPeer(t,r){let n=await Oo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new St("Not found")}async*getClosestPeers(t,r){}};function Yf(e,t){let r=t??$o();return new ea(new URL(e),r)}var Wf="[a-fA-F\\d:]",ke=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${Wf})|(?<=${Wf})(?=\\s|$))`:"",Jt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",st="[a-fA-F\\d]{1,4}",qo=`
2
+ "use strict";var HeliaRouters=(()=>{var Df=Object.create;var fn=Object.defineProperty;var Rf=Object.getOwnPropertyDescriptor;var Pf=Object.getOwnPropertyNames;var Nf=Object.getPrototypeOf,Uf=Object.prototype.hasOwnProperty;var Ms=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vt=(e,t)=>{for(var r in t)fn(e,r,{get:t[r],enumerable:!0})},Fs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pf(t))!Uf.call(e,o)&&o!==r&&fn(e,o,{get:()=>t[o],enumerable:!(n=Rf(t,o))||n.enumerable});return e};var So=(e,t,r)=>(r=e!=null?Df(Nf(e)):{},Fs(t||!e||!e.__esModule?fn(r,"default",{value:e,enumerable:!0}):r,e)),Lf=e=>Fs(fn({},"__esModule",{value:!0}),e);var ms=Ms((yw,ps)=>{var mw=(function(){typeof ps<"u"&&(ps.exports=T);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",f=Math.trunc||function(h){var p=h-h%1;return p==0&&(h<0||h===0&&1/h!=1/0)?-0:p},u=T.prototype,l=(T.fromDate=function(h){return new T(+h)},T.fromInt64BE=P(0,1,2,3,0,4),T.fromInt64LE=P(3,2,1,0,4,0),T.fromString=function(D){var p,_=new T,D=(D+="").replace(/^\s*[+\-]?\d+/,function(m){var m=+m,y=1970+(m-1970)%400;return _.year=m-y,y}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(A,m,y){return m<0&&(y*=-1),p=6e4*(60*+m+ +y),""}).replace(/\.\d+$/,function(A){return _.nano=+(A+a).substr(1,9),""}).split(/\D+/);if(1<D.length?D[1]--:D[1]=0,_.time=p=Date.UTC.apply(Date,D)-(p||0),isNaN(p))throw new TypeError("Invalid Date");return I(_)},T.fromTimeT=function(h){return B(h,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(h){return this.nano+=+h||0,this},u.getNano=function(){var h=I(this);return(h.time%1e3*c+ +h.nano+1e9)%1e9},u.getTimeT=function(){var p=I(this),h=Math.floor(p.time/1e3),p=p.year;return p&&(h+=p*r*e/t),h},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(I(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(h){var p=this,_=p.toDate(),D={H:function(){return V(_.getUTCHours())},L:function(){return F(_.getUTCMilliseconds(),3)},M:function(){return V(_.getUTCMinutes())},N:function(){return F(p.getNano(),9)},S:function(){return V(_.getUTCSeconds())},Y:function(){var A=p.getYear();return 999999<A?"+"+A:9999<A?"+"+F(A,6):0<=A?F(A,4):-999999<=A?"-"+F(-A,6):A},a:function(){return S[_.getUTCDay()]},b:function(){return g[_.getUTCMonth()]},d:function(){return V(_.getUTCDate())},e:function(){return(function(A){return(9<A?"":" ")+(0|A)})(_.getUTCDate())},m:function(){return V(_.getUTCMonth()+1)}};return(function A(m){return m.replace(/%./g,function(y){var E=y[1],d=b[E],E=D[E];return d?A(d):E?E():y})})(h||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),g=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],b={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return T;function T(h,p,_){var D=this;if(!(D instanceof T))return new T(h,p,_);D.time=+h||0,D.nano=+p||0,D.year=+_||0,I(D)}function I(h){var p,_,D,A=h.year,m=h.time,y=h.nano,d=((y<0||c<=y)&&(y-=(_=Math.floor(y/c))*c,m+=_,_=1),A%t);return(m<-i||i<m||d)&&((p=f(m/o))&&(A+=p*t,m-=p*o),(D=w(m)).setUTCFullYear(d+D.getUTCFullYear()),D=(m=+D)+(p=f((A-=d)/t))*o,p&&-i<=D&&D<=i&&(A-=p*t,m=D),_=1),_&&(h.year=A,h.time=m,h.nano=y),h}function w(h){var p=new Date(0);return p.setTime(h),p}function B(A,D){A=+A||0;var _=f((D=(D|0)*s)/n)+f(A/n),D=D%n+A%n,A=f(D/n);return A&&(_+=A,D-=A*n),new T(1e3*D,0,_*t)}function v(h,p,_,D,A,m){return function(d,E){var N=I(this);d=d||new Array(8),k(d,E|=0);var L=Math.floor(N.time/1e3),N=N.year*(r*e/t),R=f(N/s)+f(L/s),N=N%s+L%s,L=Math.floor(N/s);return L&&(R+=L,N-=L*s),y(d,E+A,R),y(d,E+m,N),d};function y(d,E,R){d[E+h]=R>>24&255,d[E+p]=R>>16&255,d[E+_]=R>>8&255,d[E+D]=255&R}}function P(h,p,_,D,A,m){return function(d,E){k(d,E|=0);var R=y(d,E+A);return B(y(d,E+m),R)};function y(d,E){return 16777216*d[E+h]+(d[E+p]<<16|d[E+_]<<8|d[E+D])}}function k(h,p){if(h=h&&h.length,h==null)throw new TypeError("Invalid Buffer");if(h<p+8)throw new RangeError("Out of range")}function V(h){return(9<h?"":"0")+(0|h)}function F(h,p){return(a+(0|h)).substr(-p)}})()});var df=Ms((s2,vs)=>{"use strict";var n0=Object.prototype.hasOwnProperty,St="~";function sn(){}Object.create&&(sn.prototype=Object.create(null),new sn().__proto__||(St=!1));function o0(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function lf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new o0(r,n||e,o),s=St?St+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function ho(e,t){--e._eventsCount===0?e._events=new sn:delete e._events[t]}function wt(){this._events=new sn,this._eventsCount=0}wt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)n0.call(r,n)&&t.push(St?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};wt.prototype.listeners=function(t){var r=St?St+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};wt.prototype.listenerCount=function(t){var r=St?St+t:t,n=this._events[r];return n?n.fn?1:n.length:0};wt.prototype.emit=function(t,r,n,o,i,s){var c=St?St+t:t;if(!this._events[c])return!1;var a=this._events[c],f=arguments.length,u,l;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),f){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,r),!0;case 3:return a.fn.call(a.context,r,n),!0;case 4:return a.fn.call(a.context,r,n,o),!0;case 5:return a.fn.call(a.context,r,n,o,i),!0;case 6:return a.fn.call(a.context,r,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];a.fn.apply(a.context,u)}else{var g=a.length,S;for(l=0;l<g;l++)switch(a[l].once&&this.removeListener(t,a[l].fn,void 0,!0),f){case 1:a[l].fn.call(a[l].context);break;case 2:a[l].fn.call(a[l].context,r);break;case 3:a[l].fn.call(a[l].context,r,n);break;case 4:a[l].fn.call(a[l].context,r,n,o);break;default:if(!u)for(S=1,u=new Array(f-1);S<f;S++)u[S-1]=arguments[S];a[l].fn.apply(a[l].context,u)}}return!0};wt.prototype.on=function(t,r,n){return lf(this,t,r,n,!1)};wt.prototype.once=function(t,r,n){return lf(this,t,r,n,!0)};wt.prototype.removeListener=function(t,r,n,o){var i=St?St+t:t;if(!this._events[i])return this;if(!r)return ho(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&ho(this,i);else{for(var c=0,a=[],f=s.length;c<f;c++)(s[c].fn!==r||o&&!s[c].once||n&&s[c].context!==n)&&a.push(s[c]);a.length?this._events[i]=a.length===1?a[0]:a:ho(this,i)}return this};wt.prototype.removeAllListeners=function(t){var r;return t?(r=St?St+t:t,this._events[r]&&ho(this,r)):(this._events=new sn,this._eventsCount=0),this};wt.prototype.off=wt.prototype.removeListener;wt.prototype.addListener=wt.prototype.on;wt.prefixed=St;wt.EventEmitter=wt;typeof vs<"u"&&(vs.exports=wt)});var T0={};vt(T0,{delegatedHTTPRouting:()=>wf,delegatedHTTPRoutingDefaults:()=>wo,httpGatewayRouting:()=>Bf,libp2pRouting:()=>_f});var $s=Symbol.for("@libp2p/content-routing");var st=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ze=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var At=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var ln=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ge=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ze=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var vo=Symbol.for("@libp2p/peer-id");var qs=Symbol.for("@libp2p/peer-routing");var Bo={};vt(Bo,{base32:()=>Yt,base32hex:()=>zf,base32hexpad:()=>Zf,base32hexpadupper:()=>jf,base32hexupper:()=>Gf,base32pad:()=>qf,base32padupper:()=>Hf,base32upper:()=>$f,base32z:()=>Yf});var P0=new Uint8Array(0);function Hs(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 ne(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 zs(e){return new TextEncoder().encode(e)}function Gs(e){return new TextDecoder().decode(e)}function Of(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 c=e.length,a=e.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var T=0,I=0,w=0,B=b.length;w!==B&&b[w]===0;)w++,T++;for(var v=(B-w)*u+1>>>0,P=new Uint8Array(v);w!==B;){for(var k=b[w],V=0,F=v-1;(k!==0||V<I)&&F!==-1;F--,V++)k+=256*P[F]>>>0,P[F]=k%c>>>0,k=k/c>>>0;if(k!==0)throw new Error("Non-zero carry");I=V,w++}for(var h=v-I;h!==v&&P[h]===0;)h++;for(var p=a.repeat(T);h<v;++h)p+=e.charAt(P[h]);return p}function g(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var T=0;if(b[T]!==" "){for(var I=0,w=0;b[T]===a;)I++,T++;for(var B=(b.length-T)*f+1>>>0,v=new Uint8Array(B);b[T];){var P=r[b.charCodeAt(T)];if(P===255)return;for(var k=0,V=B-1;(P!==0||k<w)&&V!==-1;V--,k++)P+=c*v[V]>>>0,v[V]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");w=k,T++}if(b[T]!==" "){for(var F=B-w;F!==B&&v[F]===0;)F++;for(var h=new Uint8Array(I+(B-F)),p=I;F!==B;)h[p++]=v[F++];return h}}}function S(b){var T=g(b);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:g,decode:S}}var kf=Of,Kf=kf,js=Kf;var Ao=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")}},Io=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 Ys(this,t)}},To=class{decoders;constructor(t){this.decoders=t}or(t){return Ys(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 Ys(e,t){return new To({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Co=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 Ao(t,r,n),this.decoder=new Io(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 Co(e,t,r,n)}function xe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=js(r,e);return je({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function Vf(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let f=0;f<o;++f){let u=t[e[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Mf(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],s+=8;s>r;)s-=r,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Ff(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function nt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Ff(n);return je({prefix:t,name:e,encode(i){return Mf(i,n,r)},decode(i){return Vf(i,o,r,e)}})}var Yt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$f=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qf=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hf=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zf=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gf=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zf=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jf=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yf=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _o={};vt(_o,{base58btc:()=>X,base58flickr:()=>Wf});var X=xe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wf=xe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Po={};vt(Po,{base64:()=>Do,base64pad:()=>Xf,base64url:()=>Ro,base64urlpad:()=>Jf});var Do=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xf=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ro=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jf=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Qf(e,t){if(typeof e=="string")return tl(e);if(typeof e=="number")return nl(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var dn=Qf;function tl(e){if(typeof e!="string"||e.length===0||e.length>100)throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(e)}`);let t=/^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(e);if(!t?.groups)return NaN;let{value:r,unit:n="ms"}=t.groups,o=parseFloat(r),i=n.toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return o*315576e5;case"months":case"month":case"mo":return o*26298e5;case"weeks":case"week":case"w":return o*6048e5;case"days":case"day":case"d":return o*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return o*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return o*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return o*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:throw Error(`Unknown unit "${i}" provided to ms.parse(). value=${JSON.stringify(e)}`)}}function el(e){let t=Math.abs(e);return t>=315576e5?`${Math.round(e/315576e5)}y`:t>=26298e5?`${Math.round(e/26298e5)}mo`:t>=6048e5?`${Math.round(e/6048e5)}w`: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 rl(e){let t=Math.abs(e);return t>=315576e5?De(e,t,315576e5,"year"):t>=26298e5?De(e,t,26298e5,"month"):t>=6048e5?De(e,t,6048e5,"week"):t>=864e5?De(e,t,864e5,"day"):t>=36e5?De(e,t,36e5,"hour"):t>=6e4?De(e,t,6e4,"minute"):t>=1e3?De(e,t,1e3,"second"):`${e} ms`}function nl(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?rl(e):el(e)}function De(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function No(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=dn,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 g=0;g<u.length;g++)l=(l<<5)-l+u.charCodeAt(g),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u){let l,g=null,S,b;function T(...I){if(!T.enabled)return;let w=T,B=Number(new Date),v=B-(l||B);w.diff=v,w.prev=l,w.curr=B,l=B,I[0]=r.coerce(I[0]),typeof I[0]!="string"&&I.unshift("%O");let P=0;I[0]=I[0].replace(/%([a-zA-Z%])/g,(V,F)=>{if(V==="%%")return"%";P++;let h=r.formatters[F];if(typeof h=="function"){let p=I[P];V=h.call(w,p),I.splice(P,1),P--}return V}),r.formatArgs.call(w,I),(w.log||r.log).apply(w,I)}return T.namespace=u,T.useColors=r.useColors(),T.color=r.selectColor(u),T.extend=n,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>g!==null?g:(S!==r.namespaces&&(S=r.namespaces,b=r.enabled(u)),b),set:I=>{g=I}}),typeof r.init=="function"&&r.init(T),T}function n(u,l){let g=r(this.namespace+(typeof l>"u"?":":l)+u);return g.log=this.log,g}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,g=(typeof u=="string"?u:"").split(/[\s,]+/),S=g.length;for(l=0;l<S;l++)g[l]&&(u=g[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(c),...r.skips.map(c).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,g;for(l=0,g=r.skips.length;l<g;l++)if(r.skips[l].test(u))return!1;for(l=0,g=r.names.length;l<g;l++)if(r.names[l].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(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 hn=fl(),ol=["#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 il(){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 sl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+dn(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 al=console.debug??console.log??(()=>{});function cl(e){try{e?hn?.setItem("debug",e):hn?.removeItem("debug")}catch{}}function ul(){let e;try{e=hn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function fl(){try{return localStorage}catch{}}function ll(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Ws=No({formatArgs:sl,save:cl,load:ul,useColors:il,setupFormatters:ll,colors:ol,storage:hn,log:al});var It=Ws;It.formatters.b=e=>e==null?"undefined":X.baseEncode(e);It.formatters.t=e=>e==null?"undefined":Yt.baseEncode(e);It.formatters.m=e=>e==null?"undefined":Do.baseEncode(e);It.formatters.p=e=>e==null?"undefined":e.toString();It.formatters.c=e=>e==null?"undefined":e.toString();It.formatters.k=e=>e==null?"undefined":e.toString();It.formatters.a=e=>e==null?"undefined":e.toString();It.formatters.e=e=>{if(e==null)return"undefined";let t=Xs(e.message),r=Xs(e.stack);return t!=null&&r!=null?r.includes(t)?r:`${t}
4
+ ${r}`:r??t??e.toString()};function dl(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 oe(e){let t=dl(`${e}:trace`);return It.enabled(`${e}:trace`)&&It.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=It(`${e}:trace`)),Object.assign(It(e),{error:It(`${e}:error`),trace:t,newScope:r=>oe(`${e}:${r}`)})}function Xs(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Uo={};vt(Uo,{base36:()=>Ye,base36upper:()=>hl});var Ye=xe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hl=xe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pl=ta,Js=128,ml=127,yl=~ml,gl=Math.pow(2,31);function ta(e,t,r){t=t||[],r=r||0;for(var n=r;e>=gl;)t[r++]=e&255|Js,e/=128;for(;e&yl;)t[r++]=e&255|Js,e>>>=7;return t[r]=e|0,ta.bytes=r-n+1,t}var xl=Lo,bl=128,Qs=127;function Lo(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Lo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Qs)<<o:(s&Qs)*Math.pow(2,o),o+=7}while(s>=bl);return Lo.bytes=i-n,r}var wl=Math.pow(2,7),El=Math.pow(2,14),Sl=Math.pow(2,21),vl=Math.pow(2,28),Al=Math.pow(2,35),Il=Math.pow(2,42),Tl=Math.pow(2,49),Cl=Math.pow(2,56),Bl=Math.pow(2,63),_l=function(e){return e<wl?1:e<El?2:e<Sl?3:e<vl?4:e<Al?5:e<Il?6:e<Tl?7:e<Cl?8:e<Bl?9:10},Dl={encode:pl,decode:xl,encodingLength:_l},Rl=Dl,Tr=Rl;function Cr(e,t=0){return[Tr.decode(e,t),Tr.decode.bytes]}function We(e,t,r=0){return Tr.encode(e,t,r),t}function Xe(e){return Tr.encodingLength(e)}function Wt(e,t){let r=t.byteLength,n=Xe(e),o=n+Xe(r),i=new Uint8Array(o+r);return We(e,i,0),We(r,i,n),i.set(t,o),new Je(e,r,t,i)}function Re(e){let t=ne(e),[r,n]=Cr(t),[o,i]=Cr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Je(r,o,s,t)}function ea(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Hs(e.bytes,r.bytes)}}var Je=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function ra(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Nl(r,Oo(e),t??X.encoder);default:return Ul(r,Oo(e),t??Yt.encoder)}}var na=new WeakMap;function Oo(e){let t=na.get(e);if(t==null){let r=new Map;return na.set(e,r),r}return t}var j=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!==Ll)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=Wt(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&&ea(t.multihash,n.multihash)}toString(t){return ra(this,t)}toJSON(){return{"/":ra(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??oa(n,o,i.bytes))}else if(r[Ol]===!0){let{version:n,multihash:o,code:i}=r,s=Re(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=oa(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=ne(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 Je(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,g]=Cr(t.subarray(r));return r+=g,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,c=n(),a=n(),f=r+a,u=f-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,r){let[n,o]=Pl(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 Oo(i).set(n,t),i}};function Pl(e,t){switch(e[0]){case"Q":{let r=t??X;return[X.prefix,r.decode(`${X.prefix}${e}`)]}case X.prefix:{let r=t??X;return[X.prefix,r.decode(e)]}case Yt.prefix:{let r=t??Yt;return[Yt.prefix,r.decode(e)]}case Ye.prefix:{let r=t??Ye;return[Ye.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 Nl(e,t,r){let{prefix:n}=r;if(n!==X.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 Ul(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,Ll=18;function oa(e,t,r){let n=Xe(e),o=n+Xe(t),i=new Uint8Array(o+r.byteLength);return We(e,i,0),We(t,i,n),i.set(r,o),i}var Ol=Symbol.for("@ipld/js-cid/CID");var ko={};vt(ko,{identity:()=>Bt});var ia=0,kl="identity",sa=ne;function Kl(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Wt(ia,sa(e))}var Bt={code:ia,name:kl,encode:sa,digest:Kl};function Y(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 ie(e=0){return new Uint8Array(e)}function _t(e=0){return new Uint8Array(e)}function Ot(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=_t(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ca=Symbol.for("@achingbrain/uint8arraylist");function aa(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 Qe(e){return!!e?.[ca]}var Dt=class e{bufs;length;[ca]=!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(Qe(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(Qe(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=aa(this.bufs,t);return r.buf[r.index]}set(t,r){let n=aa(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(Qe(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 Ot(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ot(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],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=r>c&&r<=a;if(f&&u){if(t===c&&r===a){n.push(s);break}let l=t-c;n.push(s.subarray(l,l+(r-t)));break}if(f){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!Qe(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(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 c=s,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=a;l+=u){u=0;for(let g=f;g>=0;g--){let S=this.get(l+g);if(n[g]!==S){u=Math.max(1,g-c[S]);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=_t(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=ie(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=ie(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=ie(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=_t(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=ie(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=ie(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=ie(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=ie(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=ie(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(!Y(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 Ko={};vt(Ko,{base10:()=>Vl});var Vl=xe({prefix:"9",name:"base10",alphabet:"0123456789"});var Vo={};vt(Vo,{base16:()=>Ml,base16upper:()=>Fl});var Ml=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fl=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mo={};vt(Mo,{base2:()=>$l});var $l=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Fo={};vt(Fo,{base256emoji:()=>Zl});var ua=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ql=ua.reduce((e,t,r)=>(e[r]=t,e),[]),Hl=ua.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function zl(e){return e.reduce((t,r)=>(t+=ql[r],t),"")}function Gl(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Hl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Zl=je({prefix:"\u{1F680}",name:"base256emoji",encode:zl,decode:Gl});var $o={};vt($o,{base8:()=>jl});var jl=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qo={};vt(qo,{identity:()=>Yl});var Yl=je({prefix:"\0",name:"identity",encode:e=>Gs(e),decode:e=>zs(e)});var Bm=new TextEncoder,_m=new TextDecoder;var Go={};vt(Go,{sha256:()=>_r,sha512:()=>Ql});var Jl=20;function zo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ho(e,t,r,n,o)}var Ho=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Jl,this.maxDigestLength=i}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?fa(n,this.code,r?.truncate):n.then(o=>fa(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function fa(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Wt(t,e)}function da(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var _r=zo({name:"sha2-256",code:18,encode:da("SHA-256")}),Ql=zo({name:"sha2-512",code:19,encode:da("SHA-512")});var Dr={...qo,...Mo,...$o,...Ko,...Vo,...Bo,...Uo,..._o,...Po,...Fo},Fm={...Go,...ko};function pa(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ha=pa("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Zo=pa("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=_t(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),td={utf8:ha,"utf-8":ha,hex:Dr.base16,latin1:Zo,ascii:Zo,binary:Zo,...Dr},mn=td;function H(e,t="utf8"){let r=mn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=mn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var ed=parseInt("11111",2),jo=parseInt("10000000",2),rd=parseInt("01111111",2),ma={0:Rr,1:Rr,2:nd,3:sd,4:ad,5:id,6:od,16:Rr,22:Rr,48:Rr};function se(e,t={offset:0}){let r=e[t.offset]&ed;if(t.offset++,ma[r]!=null)return ma[r](e,t);throw new Error("No decoder for tag "+r)}function Pr(e,t){let r=0;if((e[t.offset]&jo)===jo){let n=e[t.offset]&rd,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 Rr(e,t){Pr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=se(e,t);if(n===null)break;r.push(n)}return r}function nd(e,t){let r=Pr(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 od(e,t){let r=Pr(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 c=`${i}.${s}`,a=[];for(;t.offset<n;){let f=e[t.offset];if(t.offset++,a.push(f&127),f<128){a.reverse();let u=0;for(let l=0;l<a.length;l++)u+=a[l]<<l*7;c+=`.${u}`,a=[]}}return c}function id(e,t){return t.offset++,null}function sd(e,t){let r=Pr(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 ad(e,t){let r=Pr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function cd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Dt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Yo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=cd(e.byteLength);return new Dt(Uint8Array.from([t.byteLength|jo]),t)}function Tt(e){let t=new Dt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Dt(Uint8Array.from([2]),Yo(t),t)}function yn(e){let t=Uint8Array.from([0]),r=new Dt(t,e);return new Dt(Uint8Array.from([3]),Yo(r),r)}function be(e,t=48){let r=new Dt;for(let n of e)r.append(n);return new Dt(Uint8Array.from([t]),Yo(r),r)}async function ya(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),i}var ud=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),fd=Uint8Array.from([6,5,43,129,4,0,34]),ld=Uint8Array.from([6,5,43,129,4,0,35]),dd={ext:!0,kty:"EC",crv:"P-256"},hd={ext:!0,kty:"EC",crv:"P-384"},pd={ext:!0,kty:"EC",crv:"P-521"},Wo=32,Xo=48,Jo=66;function Qo(e){let t=se(e);return ga(t)}function ga(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Wo*2+1)return n=z(t.subarray(r,r+Wo),"base64url"),o=z(t.subarray(r+Wo),"base64url"),new tr({...dd,key_ops:["verify"],x:n,y:o});if(t.byteLength===Xo*2+1)return n=z(t.subarray(r,r+Xo),"base64url"),o=z(t.subarray(r+Xo),"base64url"),new tr({...hd,key_ops:["verify"],x:n,y:o});if(t.byteLength===Jo*2+1)return n=z(t.subarray(r,r+Jo),"base64url"),o=z(t.subarray(r+Jo),"base64url"),new tr({...pd,key_ops:["verify"],x:n,y:o});throw new st(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function xa(e){return be([Tt(Uint8Array.from([1])),be([md(e.crv)],160),be([yn(new Dt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function md(e){if(e==="P-256")return ud;if(e==="P-384")return fd;if(e==="P-521")return ld;throw new st(`Invalid curve ${e}`)}var tr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=xa(this.jwk)),this._raw}toMultihash(){return Bt.digest(er(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}async verify(t,r,n){return ya(this.jwk,r,t,n)}};function Ne(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Xt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function q(e,t,r=""){let n=Ne(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,c=i?` of length ${t}`:"",a=n?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+a)}return e}function gn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Xt(e.outputLen),Xt(e.blockLen)}function rr(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 wa(e,t){q(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function xn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Mt(e,t){return e<<32-t|e>>>t}var Ea=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",yd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ue(e){if(q(e),Ea)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=yd[e[r]];return t}var ae={_0:48,_9:57,A:65,F:70,a:97,f:102};function ba(e){if(e>=ae._0&&e<=ae._9)return e-ae._0;if(e>=ae.A&&e<=ae.F)return e-(ae.A-10);if(e>=ae.a&&e<=ae.f)return e-(ae.a-10)}function fe(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ea)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=ba(e.charCodeAt(i)),c=ba(e.charCodeAt(i+1));if(s===void 0||c===void 0){let a=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function Ct(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];q(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}function ti(e,t={}){let r=(o,i)=>e(i).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function nr(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var ei=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Sa(e,t,r){return e&t^~e&r}function va(e,t,r){return e&t^e&r^t&r}var Nr=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=xn(this.buffer)}update(t){rr(this),q(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=xn(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){rr(this),wa(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ce(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=xn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.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||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},le=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ht=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var bn=BigInt(4294967295),Aa=BigInt(32);function gd(e,t=!1){return t?{h:Number(e&bn),l:Number(e>>Aa&bn)}:{h:Number(e>>Aa&bn)|0,l:Number(e&bn)|0}}function Ia(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:c}=gd(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var ri=(e,t,r)=>e>>>r,ni=(e,t,r)=>e<<32-r|t>>>r,Ue=(e,t,r)=>e>>>r|t<<32-r,Le=(e,t,r)=>e<<32-r|t>>>r,Ur=(e,t,r)=>e<<64-r|t>>>r-32,Lr=(e,t,r)=>e>>>r-32|t<<64-r;function Jt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ta=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Ca=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ba=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),_a=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Da=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ra=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var bd=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]),we=new Uint32Array(64),oi=class extends Nr{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,r,n,o,i,s,c,a]}set(t,r,n,o,i,s,c,a){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=c|0,this.H=a|0}process(t,r){for(let l=0;l<16;l++,r+=4)we[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let g=we[l-15],S=we[l-2],b=Mt(g,7)^Mt(g,18)^g>>>3,T=Mt(S,17)^Mt(S,19)^S>>>10;we[l]=T+we[l-7]+b+we[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let g=Mt(c,6)^Mt(c,11)^Mt(c,25),S=u+g+Sa(c,a,f)+bd[l]+we[l]|0,T=(Mt(n,2)^Mt(n,13)^Mt(n,22))+va(n,o,i)|0;u=f,f=a,a=c,c=s+S|0,s=i,i=o,o=n,n=S+T|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){ce(we)}destroy(){this.set(0,0,0,0,0,0,0,0),ce(this.buffer)}},ii=class extends oi{A=le[0]|0;B=le[1]|0;C=le[2]|0;D=le[3]|0;E=le[4]|0;F=le[5]|0;G=le[6]|0;H=le[7]|0;constructor(){super(32)}};var Pa=Ia(["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))),wd=Pa[0],Ed=Pa[1],Ee=new Uint32Array(80),Se=new Uint32Array(80),si=class extends Nr{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:f,El:u,Fh:l,Fl:g,Gh:S,Gl:b,Hh:T,Hl:I}=this;return[t,r,n,o,i,s,c,a,f,u,l,g,S,b,T,I]}set(t,r,n,o,i,s,c,a,f,u,l,g,S,b,T,I){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=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=g|0,this.Gh=S|0,this.Gl=b|0,this.Hh=T|0,this.Hl=I|0}process(t,r){for(let v=0;v<16;v++,r+=4)Ee[v]=t.getUint32(r),Se[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let P=Ee[v-15]|0,k=Se[v-15]|0,V=Ue(P,k,1)^Ue(P,k,8)^ri(P,k,7),F=Le(P,k,1)^Le(P,k,8)^ni(P,k,7),h=Ee[v-2]|0,p=Se[v-2]|0,_=Ue(h,p,19)^Ur(h,p,61)^ri(h,p,6),D=Le(h,p,19)^Lr(h,p,61)^ni(h,p,6),A=Ba(F,D,Se[v-7],Se[v-16]),m=_a(A,V,_,Ee[v-7],Ee[v-16]);Ee[v]=m|0,Se[v]=A|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:g,Fh:S,Fl:b,Gh:T,Gl:I,Hh:w,Hl:B}=this;for(let v=0;v<80;v++){let P=Ue(l,g,14)^Ue(l,g,18)^Ur(l,g,41),k=Le(l,g,14)^Le(l,g,18)^Lr(l,g,41),V=l&S^~l&T,F=g&b^~g&I,h=Da(B,k,F,Ed[v],Se[v]),p=Ra(h,w,P,V,wd[v],Ee[v]),_=h|0,D=Ue(n,o,28)^Ur(n,o,34)^Ur(n,o,39),A=Le(n,o,28)^Lr(n,o,34)^Lr(n,o,39),m=n&i^n&c^i&c,y=o&s^o&a^s&a;w=T|0,B=I|0,T=S|0,I=b|0,S=l|0,b=g|0,{h:l,l:g}=Jt(f|0,u|0,p|0,_|0),f=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let d=Ta(_,A,y);n=Ca(d,p,D,m),o=d|0}({h:n,l:o}=Jt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Jt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=Jt(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=Jt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:g}=Jt(this.Eh|0,this.El|0,l|0,g|0),{h:S,l:b}=Jt(this.Fh|0,this.Fl|0,S|0,b|0),{h:T,l:I}=Jt(this.Gh|0,this.Gl|0,T|0,I|0),{h:w,l:B}=Jt(this.Hh|0,this.Hl|0,w|0,B|0),this.set(n,o,i,s,c,a,f,u,l,g,S,b,T,I,w,B)}roundClean(){ce(Ee,Se)}destroy(){ce(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ai=class extends si{Ah=ht[0]|0;Al=ht[1]|0;Bh=ht[2]|0;Bl=ht[3]|0;Ch=ht[4]|0;Cl=ht[5]|0;Dh=ht[6]|0;Dl=ht[7]|0;Eh=ht[8]|0;El=ht[9]|0;Fh=ht[10]|0;Fl=ht[11]|0;Gh=ht[12]|0;Gl=ht[13]|0;Hh=ht[14]|0;Hl=ht[15]|0;constructor(){super(64)}};var or=ti(()=>new ii,ei(1));var Na=ti(()=>new ai,ei(3));var ui=BigInt(0),ci=BigInt(1);function de(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function Ua(e){if(typeof e=="bigint"){if(!wn(e))throw new Error("positive bigint expected, got "+e)}else Xt(e);return e}function Or(e){let t=Ua(e).toString(16);return t.length&1?"0"+t:t}function La(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ui:BigInt("0x"+e)}function ir(e){return La(ue(e))}function Oe(e){return La(ue(Sn(q(e)).reverse()))}function En(e,t){Xt(t),e=Ua(e);let r=fe(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function fi(e,t){return En(e,t).reverse()}function Sn(e){return Uint8Array.from(e)}var wn=e=>typeof e=="bigint"&&ui<=e;function Sd(e,t,r){return wn(e)&&wn(t)&&wn(r)&&t<=e&&e<r}function kr(e,t,r,n){if(!Sd(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function li(e){let t;for(t=0;e>ui;e>>=ci,t+=1);return t}var Kr=e=>(ci<<BigInt(e))-ci;function Oa(e,t,r){if(Xt(e,"hashLen"),Xt(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(e),f=n(e),u=0,l=()=>{a.fill(1),f.fill(0),u=0},g=(...I)=>r(f,Ct(a,...I)),S=(I=o)=>{f=g(i,I),a=g(),I.length!==0&&(f=g(s,I),a=g())},b=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let I=0,w=[];for(;I<t;){a=g();let B=a.slice();w.push(B),I+=a.length}return Ct(...w)};return(I,w)=>{l(),S(I);let B;for(;!(B=w(b()));)S();return l(),B}}function ve(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(i,s,c){let a=e[i];if(c&&a===void 0)return;let f=typeof a;if(f!==s||a===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(t,!1),o(r,!0)}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 Et=BigInt(0),ct=BigInt(1),ke=BigInt(2),Va=BigInt(3),Ma=BigInt(4),Fa=BigInt(5),vd=BigInt(7),$a=BigInt(8),Ad=BigInt(9),qa=BigInt(16);function ot(e,t){let r=e%t;return r>=Et?r:t+r}function J(e,t,r){let n=e;for(;t-- >Et;)n*=n,n%=r;return n}function ka(e,t){if(e===Et)throw new Error("invert: expected non-zero number");if(t<=Et)throw new Error("invert: expected positive modulus, got "+t);let r=ot(e,t),n=t,o=Et,i=ct,s=ct,c=Et;for(;r!==Et;){let f=n/r,u=n%r,l=o-s*f,g=i-c*f;n=r,r=u,o=s,i=c,s=l,c=g}if(n!==ct)throw new Error("invert: does not exist");return ot(o,t)}function hi(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Ha(e,t){let r=(e.ORDER+ct)/Ma,n=e.pow(t,r);return hi(e,n,t),n}function Id(e,t){let r=(e.ORDER-Fa)/$a,n=e.mul(t,ke),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,ke),o),c=e.mul(i,e.sub(s,e.ONE));return hi(e,c,t),c}function Td(e){let t=ar(e),r=za(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+vd)/qa;return(c,a)=>{let f=c.pow(a,s),u=c.mul(f,n),l=c.mul(f,o),g=c.mul(f,i),S=c.eql(c.sqr(u),a),b=c.eql(c.sqr(l),a);f=c.cmov(f,u,S),u=c.cmov(g,l,b);let T=c.eql(c.sqr(u),a),I=c.cmov(f,u,T);return hi(c,I,a),I}}function za(e){if(e<Va)throw new Error("sqrt is not defined for small field");let t=e-ct,r=0;for(;t%ke===Et;)t/=ke,r++;let n=ke,o=ar(e);for(;Ka(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ha;let i=o.pow(n,t),s=(t+ct)/ke;return function(a,f){if(a.is0(f))return f;if(Ka(a,f)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,i),g=a.pow(f,t),S=a.pow(f,s);for(;!a.eql(g,a.ONE);){if(a.is0(g))return a.ZERO;let b=1,T=a.sqr(g);for(;!a.eql(T,a.ONE);)if(b++,T=a.sqr(T),b===u)throw new Error("Cannot find square root");let I=ct<<BigInt(u-b-1),w=a.pow(l,I);u=b,l=a.sqr(w),g=a.mul(g,l),S=a.mul(S,w)}return S}}function Cd(e){return e%Ma===Va?Ha:e%$a===Fa?Id:e%qa===Ad?Td(e):za(e)}var Ga=(e,t)=>(ot(e,t)&ct)===ct,Bd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function pi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Bd.reduce((n,o)=>(n[o]="function",n),t);return ve(e,r),e}function _d(e,t,r){if(r<Et)throw new Error("invalid exponent, negatives unsupported");if(r===Et)return e.ONE;if(r===ct)return t;let n=e.ONE,o=t;for(;r>Et;)r&ct&&(n=e.mul(n,o)),o=e.sqr(o),r>>=ct;return n}function Vr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,c,a)=>e.is0(c)?s:(n[a]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,a)=>e.is0(c)?s:(n[a]=e.mul(s,n[a]),e.mul(s,c)),i),n}function Ka(e,t){let r=(e.ORDER-ct)/ke,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("invalid Legendre symbol result");return o?1:i?0:-1}function Dd(e,t){t!==void 0&&Xt(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var di=class{ORDER;BITS;BYTES;isLE;ZERO=Et;ONE=ct;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=Et)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Dd(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return ot(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return Et<=t&&t<this.ORDER}is0(t){return t===Et}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&ct)===ct}neg(t){return ot(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return ot(t*t,this.ORDER)}add(t,r){return ot(t+r,this.ORDER)}sub(t,r){return ot(t-r,this.ORDER)}mul(t,r){return ot(t*r,this.ORDER)}pow(t,r){return _d(this,t,r)}div(t,r){return ot(t*ka(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return ka(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=Cd(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?fi(t,this.BYTES):En(t,this.BYTES)}fromBytes(t,r=!1){q(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,i?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=i?Oe(t):ir(t);if(c&&(a=ot(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return Vr(this,t)}cmov(t,r,n){return n?r:t}};function ar(e,t={}){return new di(e,t)}function Za(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 mi(e){let t=Za(e);return t+Math.ceil(t/2)}function yi(e,t,r=!1){q(e);let n=e.length,o=Za(t),i=mi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Oe(e):ir(e),c=ot(s,t-ct)+ct;return r?fi(c,o):En(c,o)}var cr=BigInt(0),Ke=BigInt(1);function Mr(e,t){let r=t.negate();return e?r:t}function Ve(e,t){let r=Vr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Xa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function gi(e,t){Xa(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Kr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function ja(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(e&o),a=e>>s;c>n&&(c-=i,a+=Ke);let f=t*n,u=f+Math.abs(c)-1,l=c===0,g=c<0,S=t%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:g,isNegF:S,offsetF:f}}var xi=new WeakMap,Ja=new WeakMap;function bi(e){return Ja.get(e)||1}function Ya(e){if(e!==cr)throw new Error("invalid wNAF")}var ur=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>cr;)r&Ke&&(n=n.add(o)),o=o.double(),r>>=Ke;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=gi(r,this.bits),i=[],s=t,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let f=1;f<o;f++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=gi(t,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:f,isZero:u,isNeg:l,isNegF:g,offsetF:S}=ja(n,c,s);n=a,u?i=i.add(Mr(g,r[S])):o=o.add(Mr(l,r[f]))}return Ya(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=gi(t,this.bits);for(let s=0;s<i.windows&&n!==cr;s++){let{nextN:c,offset:a,isZero:f,isNeg:u}=ja(n,s,i);if(n=c,!f){let l=r[a];o=o.add(u?l.negate():l)}}return Ya(n),o}getPrecomputes(t,r,n){let o=xi.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),xi.set(r,o))),o}cached(t,r,n){let o=bi(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=bi(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){Xa(r,this.bits),Ja.set(t,r),xi.delete(t)}hasCache(t){return bi(t)!==1}};function Qa(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>cr||n>cr;)r&Ke&&(i=i.add(o)),n&Ke&&(s=s.add(o)),o=o.double(),r>>=Ke,n>>=Ke;return{p1:i,p2:s}}function Wa(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return pi(t),t}else return ar(e,{isLE:r})}function vn(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let a of["p","n","h"]){let f=t[a];if(!(typeof f=="bigint"&&f>cr))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Wa(t.p,r.Fp,n),i=Wa(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function An(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Ae=BigInt(0),ut=BigInt(1),wi=BigInt(2),Rd=BigInt(8);function Pd(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),c=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,c)}function tc(e,t={}){let r=vn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;ve(t,{},{uvRatio:"function"});let c=wi<<BigInt(o.BYTES*8)-ut,a=I=>n.create(I),f=t.uvRatio||((I,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(I,w))}}catch{return{isValid:!1,value:Ae}}});if(!Pd(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(I,w,B=!1){let v=B?ut:Ae;return kr("coordinate "+I,w,v,c),w}function l(I){if(!(I instanceof b))throw new Error("EdwardsPoint expected")}let g=sr((I,w)=>{let{X:B,Y:v,Z:P}=I,k=I.is0();w==null&&(w=k?Rd:n.inv(P));let V=a(B*w),F=a(v*w),h=n.mul(P,w);if(k)return{x:Ae,y:ut};if(h!==ut)throw new Error("invZ was invalid");return{x:V,y:F}}),S=sr(I=>{let{a:w,d:B}=i;if(I.is0())throw new Error("bad point: ZERO");let{X:v,Y:P,Z:k,T:V}=I,F=a(v*v),h=a(P*P),p=a(k*k),_=a(p*p),D=a(F*w),A=a(p*a(D+h)),m=a(_+a(B*a(F*h)));if(A!==m)throw new Error("bad point: equation left != right (1)");let y=a(v*P),d=a(k*V);if(y!==d)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,ut,a(i.Gx*i.Gy));static ZERO=new b(Ae,ut,ut,Ae);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,B,v,P){this.X=u("x",w),this.Y=u("y",B),this.Z=u("z",v,!0),this.T=u("t",P),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof b)throw new Error("extended point not allowed");let{x:B,y:v}=w||{};return u("x",B),u("y",v),new b(B,v,ut,a(B*v))}static fromBytes(w,B=!1){let v=n.BYTES,{a:P,d:k}=i;w=Sn(q(w,v,"point")),de(B,"zip215");let V=Sn(w),F=w[v-1];V[v-1]=F&-129;let h=Oe(V),p=B?c:n.ORDER;kr("point.y",h,Ae,p);let _=a(h*h),D=a(_-ut),A=a(k*_-P),{isValid:m,value:y}=f(D,A);if(!m)throw new Error("bad point: invalid y coordinate");let d=(y&ut)===ut,E=(F&128)!==0;if(!B&&y===Ae&&E)throw new Error("bad point: x=0 and x_0=1");return E!==d&&(y=a(-y)),b.fromAffine({x:y,y:h})}static fromHex(w,B=!1){return b.fromBytes(fe(w),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,B=!0){return T.createCache(this,w),B||this.multiply(wi),this}assertValidity(){S(this)}equals(w){l(w);let{X:B,Y:v,Z:P}=this,{X:k,Y:V,Z:F}=w,h=a(B*F),p=a(k*P),_=a(v*F),D=a(V*P);return h===p&&_===D}is0(){return this.equals(b.ZERO)}negate(){return new b(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:w}=i,{X:B,Y:v,Z:P}=this,k=a(B*B),V=a(v*v),F=a(wi*a(P*P)),h=a(w*k),p=B+v,_=a(a(p*p)-k-V),D=h+V,A=D-F,m=h-V,y=a(_*A),d=a(D*m),E=a(_*m),R=a(A*D);return new b(y,d,R,E)}add(w){l(w);let{a:B,d:v}=i,{X:P,Y:k,Z:V,T:F}=this,{X:h,Y:p,Z:_,T:D}=w,A=a(P*h),m=a(k*p),y=a(F*v*D),d=a(V*_),E=a((P+k)*(h+p)-A-m),R=d-y,N=d+y,L=a(m-B*A),O=a(E*R),K=a(N*L),$=a(E*L),tt=a(R*N);return new b(O,K,tt,$)}subtract(w){return this.add(w.negate())}multiply(w){if(!o.isValidNot0(w))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:v}=T.cached(this,w,P=>Ve(b,P));return Ve(b,[B,v])[0]}multiplyUnsafe(w,B=b.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===Ae?b.ZERO:this.is0()||w===ut?this:T.unsafe(this,w,v=>Ve(b,v),B)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(w){return g(this,w)}clearCofactor(){return s===ut?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:B}=this.toAffine(),v=n.toBytes(B);return v[v.length-1]|=w&ut?128:0,v}toHex(){return ue(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let T=new ur(b,o.BITS);return b.BASE.precompute(8),b}function ec(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');ve(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:i,Fn:s}=e,c=r.randomBytes||nr,a=r.adjustScalarBytes||(h=>h),f=r.domain||((h,p,_)=>{if(de(_,"phflag"),p.length||_)throw new Error("Contexts/pre-hash are not supported");return h});function u(h){return s.create(Oe(h))}function l(h){let p=v.secretKey;q(h,v.secretKey,"secretKey");let _=q(t(h),2*p,"hashedSecretKey"),D=a(_.slice(0,p)),A=_.slice(p,2*p),m=u(D);return{head:D,prefix:A,scalar:m}}function g(h){let{head:p,prefix:_,scalar:D}=l(h),A=o.multiply(D),m=A.toBytes();return{head:p,prefix:_,scalar:D,point:A,pointBytes:m}}function S(h){return g(h).pointBytes}function b(h=Uint8Array.of(),...p){let _=Ct(...p);return u(t(f(_,q(h,void 0,"context"),!!n)))}function T(h,p,_={}){h=q(h,void 0,"message"),n&&(h=n(h));let{prefix:D,scalar:A,pointBytes:m}=g(p),y=b(_.context,D,h),d=o.multiply(y).toBytes(),E=b(_.context,d,m,h),R=s.create(y+E*A);if(!s.isValid(R))throw new Error("sign failed: invalid s");let N=Ct(d,s.toBytes(R));return q(N,v.signature,"result")}let I={zip215:!0};function w(h,p,_,D=I){let{context:A,zip215:m}=D,y=v.signature;h=q(h,y,"signature"),p=q(p,void 0,"message"),_=q(_,v.publicKey,"publicKey"),m!==void 0&&de(m,"zip215"),n&&(p=n(p));let d=y/2,E=h.subarray(0,d),R=Oe(h.subarray(d,y)),N,L,O;try{N=e.fromBytes(_,m),L=e.fromBytes(E,m),O=o.multiplyUnsafe(R)}catch{return!1}if(!m&&N.isSmallOrder())return!1;let K=b(A,L.toBytes(),N.toBytes(),p);return L.add(N.multiplyUnsafe(K)).subtract(O).clearCofactor().is0()}let B=i.BYTES,v={secretKey:B,publicKey:B,signature:2*B,seed:B};function P(h=c(v.seed)){return q(h,v.seed,"seed")}function k(h){return Ne(h)&&h.length===s.BYTES}function V(h,p){try{return!!e.fromBytes(h,p)}catch{return!1}}let F={getExtendedPublicKey:g,randomSecretKey:P,isValidSecretKey:k,isValidPublicKey:V,toMontgomery(h){let{y:p}=e.fromBytes(h),_=v.publicKey,D=_===32;if(!D&&_!==57)throw new Error("only defined for 25519 and 448");let A=D?i.div(ut+p,ut-p):i.div(p-ut,p+ut);return i.toBytes(A)},toMontgomerySecret(h){let p=v.secretKey;q(h,p);let _=t(h.subarray(0,p));return a(_).subarray(0,p)}};return Object.freeze({keygen:An(P,S),getPublicKey:S,sign:T,verify:w,utils:F,Point:e,lengths:v})}var Nd=BigInt(1),rc=BigInt(2);var Ud=BigInt(5),Ld=BigInt(8),Ei=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Od={p:Ei,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Ld,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function kd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ei,c=e*e%i*e%i,a=J(c,rc,i)*c%i,f=J(a,Nd,i)*e%i,u=J(f,Ud,i)*f%i,l=J(u,t,i)*u%i,g=J(l,r,i)*l%i,S=J(g,n,i)*g%i,b=J(S,o,i)*S%i,T=J(b,o,i)*S%i,I=J(T,t,i)*u%i;return{pow_p_5_8:J(I,rc,i)*e%i,b2:c}}function Kd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var nc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Vd(e,t){let r=Ei,n=ot(t*t*t,r),o=ot(n*n*t,r),i=kd(e*o).pow_p_5_8,s=ot(e*n*i,r),c=ot(t*s*s,r),a=s,f=ot(s*nc,r),u=c===e,l=c===ot(-e,r),g=c===ot(-e*nc,r);return u&&(s=a),(l||g)&&(s=f),Ga(s,r)&&(s=ot(-s,r)),{isValid:u||l,value:s}}var Md=tc(Od,{uvRatio:Vd});function Fd(e){return ec(Md,Na,Object.assign({adjustScalarBytes:Kd},e))}var oc=Fd({});var Fr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},In=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ic={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new In("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 kt=ic;var Tn=32;var Si,$d=(async()=>{try{return await kt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function qd(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await kt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await kt.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Hd(e,t,r){return oc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function sc(e,t,r){return Si==null&&(Si=await $d),Si?qd(e,t,r):Hd(e,t,r)}function Cn(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Bn=class{type="Ed25519";raw;constructor(t){this.raw=vi(t,Tn)}toMultihash(){return Bt.digest(er(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=sc(this.raw,r,t);return Cn(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Ai(e){return e=vi(e,Tn),new Bn(e)}function vi(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 Gd=Math.pow(2,7),Zd=Math.pow(2,14),jd=Math.pow(2,21),Ii=Math.pow(2,28),Ti=Math.pow(2,35),Ci=Math.pow(2,42),Bi=Math.pow(2,49),Q=128,xt=127;function Qt(e){if(e<Gd)return 1;if(e<Zd)return 2;if(e<jd)return 3;if(e<Ii)return 4;if(e<Ti)return 5;if(e<Ci)return 6;if(e<Bi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function $r(e,t,r=0){switch(Qt(e)){case 8:t[r++]=e&255|Q,e/=128;case 7:t[r++]=e&255|Q,e/=128;case 6:t[r++]=e&255|Q,e/=128;case 5:t[r++]=e&255|Q,e/=128;case 4:t[r++]=e&255|Q,e>>>=7;case 3:t[r++]=e&255|Q,e>>>=7;case 2:t[r++]=e&255|Q,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function _i(e,t){let r=e[t],n=0;if(n+=r&xt,r<Q||(r=e[t+1],n+=(r&xt)<<7,r<Q)||(r=e[t+2],n+=(r&xt)<<14,r<Q)||(r=e[t+3],n+=(r&xt)<<21,r<Q)||(r=e[t+4],n+=(r&xt)*Ii,r<Q)||(r=e[t+5],n+=(r&xt)*Ti,r<Q)||(r=e[t+6],n+=(r&xt)*Ci,r<Q)||(r=e[t+7],n+=(r&xt)*Bi,r<Q))return n;throw new RangeError("Could not decode varint")}function Yd(e,t){let r=e.get(t),n=0;if(n+=r&xt,r<Q||(r=e.get(t+1),n+=(r&xt)<<7,r<Q)||(r=e.get(t+2),n+=(r&xt)<<14,r<Q)||(r=e.get(t+3),n+=(r&xt)<<21,r<Q)||(r=e.get(t+4),n+=(r&xt)*Ii,r<Q)||(r=e.get(t+5),n+=(r&xt)*Ti,r<Q)||(r=e.get(t+6),n+=(r&xt)*Ci,r<Q)||(r=e.get(t+7),n+=(r&xt)*Bi,r<Q))return n;throw new RangeError("Could not decode varint")}function Di(e,t=0){return e instanceof Uint8Array?_i(e,t):Yd(e,t)}var Ri=new Float32Array([-0]),Ie=new Uint8Array(Ri.buffer);function cc(e,t,r){Ri[0]=e,t[r]=Ie[0],t[r+1]=Ie[1],t[r+2]=Ie[2],t[r+3]=Ie[3]}function uc(e,t){return Ie[0]=e[t],Ie[1]=e[t+1],Ie[2]=e[t+2],Ie[3]=e[t+3],Ri[0]}var Pi=new Float64Array([-0]),bt=new Uint8Array(Pi.buffer);function fc(e,t,r){Pi[0]=e,t[r]=bt[0],t[r+1]=bt[1],t[r+2]=bt[2],t[r+3]=bt[3],t[r+4]=bt[4],t[r+5]=bt[5],t[r+6]=bt[6],t[r+7]=bt[7]}function lc(e,t){return bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],bt[3]=e[t+3],bt[4]=e[t+4],bt[5]=e[t+5],bt[6]=e[t+6],bt[7]=e[t+7],Pi[0]}var Xd=BigInt(Number.MAX_SAFE_INTEGER),Jd=BigInt(Number.MIN_SAFE_INTEGER),Rt=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 Me;if(t<Xd&&t>Jd)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>dc&&(o=0n,++n>dc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Me;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):Me}},Me=new Rt(0,0);Me.toBigInt=function(){return 0n};Me.zzEncode=Me.zzDecode=function(){return this};Me.length=function(){return 1};var dc=4294967296n;function hc(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 pc(e,t,r){if(r-t<1)return"";let o,i=[],s=0,c;for(;t<r;)c=e[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&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 Ni(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 Ft(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function _n(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ui=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,Ft(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 Ft(this,4);return _n(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ft(this,4);return _n(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ft(this,4);let t=uc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ft(this,4);let t=lc(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 Ft(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return pc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Ft(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ft(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 Rt(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 Ft(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 Ft(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 Ft(this,8);let t=_n(this.buf,this.pos+=4),r=_n(this.buf,this.pos+=4);return new Rt(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=_i(this.buf,this.pos);return this.pos+=Qt(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 Li(e){return new Ui(e instanceof Uint8Array?e:e.subarray())}function fr(e,t,r){let n=Li(e);return t.decode(n,void 0,r)}function Oi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return _t(s);o+s>t&&(n=_t(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Fe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ki(){}var Vi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Qd=Oi();function th(e){return globalThis.Buffer!=null?_t(e):Qd(e)}var Hr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Fe(ki,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Fe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Mi((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(Dn,10,Rt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Rt.fromBigInt(t);return this._push(Dn,r.length(),r)}uint64Number(t){return this._push($r,Qt(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=Rt.fromBigInt(t).zzEncode();return this._push(Dn,r.length(),r)}sint64Number(t){let r=Rt.fromNumber(t).zzEncode();return this._push(Dn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ki,1,t?1:0)}fixed32(t){return this._push(qr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Rt.fromBigInt(t);return this._push(qr,4,r.lo)._push(qr,4,r.hi)}fixed64Number(t){let r=Rt.fromNumber(t);return this._push(qr,4,r.lo)._push(qr,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(cc,4,t)}double(t){return this._push(fc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Ki,1,0):this.uint32(r)._push(rh,r,t)}string(t){let r=hc(t);return r!==0?this.uint32(r)._push(Ni,r,t):this._push(Ki,1,0)}fork(){return this.states=new Vi(this),this.head=this.tail=new Fe(ki,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Fe(ki,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=th(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Ki(e,t,r){t[r]=e&255}function eh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Mi=class extends Fe{next;constructor(t,r){super(eh,t,r),this.next=void 0}};function Dn(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 qr(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 rh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Hr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(nh,t,e),this},Hr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(oh,t,e),this});function nh(e,t,r){t.set(e,r)}function oh(e,t,r){e.length<40?Ni(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Fi(){return new Hr}function lr(e,t){let r=Fi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var dr;(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"})(dr||(dr={}));function Rn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function zr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return Rn("enum",dr.VARINT,r,n)}function hr(e,t){return Rn("message",dr.LENGTH_DELIMITED,e,t)}var it;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(it||(it={}));var $i;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})($i||($i={}));(function(e){e.codec=()=>zr($i)})(it||(it={}));var te;(function(e){let t;e.codec=()=>(t==null&&(t=hr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),it.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 c=r.uint32();switch(c>>>3){case 1:{i.Type=it.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>lr(r,e.codec()),e.decode=(r,n)=>fr(r,e.codec(),n)})(te||(te={}));var qi;(function(e){let t;e.codec=()=>(t==null&&(t=hr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),it.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 c=r.uint32();switch(c>>>3){case 1:{i.Type=it.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>lr(r,e.codec()),e.decode=(r,n)=>fr(r,e.codec(),n)})(qi||(qi={}));var Zr={};vt(Zr,{MAX_RSA_KEY_SIZE:()=>Hi,generateRSAKeyPair:()=>wc,jwkToJWKKeyPair:()=>Ec,jwkToPkcs1:()=>ch,jwkToPkix:()=>ji,jwkToRSAPrivateKey:()=>Ji,pkcs1MessageToJwk:()=>Gi,pkcs1MessageToRSAPrivateKey:()=>Yi,pkcs1ToJwk:()=>ah,pkcs1ToRSAPrivateKey:()=>bc,pkixMessageToJwk:()=>Zi,pkixMessageToRSAPublicKey:()=>Xi,pkixToJwk:()=>uh,pkixToRSAPublicKey:()=>Wi});var pr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Zr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return j.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return xc(this.jwk,r,t,n)}},Gr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Zr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}sign(t,r){return gc(this.jwk,t,r)}};var Hi=8192,zi=18,ih=1062,sh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function ah(e){let t=se(e);return Gi(t)}function Gi(e){return{n:z(e[1],"base64url"),e:z(e[2],"base64url"),d:z(e[3],"base64url"),p:z(e[4],"base64url"),q:z(e[5],"base64url"),dp:z(e[6],"base64url"),dq:z(e[7],"base64url"),qi:z(e[8],"base64url"),kty:"RSA"}}function ch(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 be([Tt(Uint8Array.from([0])),Tt(H(e.n,"base64url")),Tt(H(e.e,"base64url")),Tt(H(e.d,"base64url")),Tt(H(e.p,"base64url")),Tt(H(e.q,"base64url")),Tt(H(e.dp,"base64url")),Tt(H(e.dq,"base64url")),Tt(H(e.qi,"base64url"))]).subarray()}function uh(e){let t=se(e,{offset:0});return Zi(t)}function Zi(e){let t=se(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function ji(e){if(e.n==null||e.e==null)throw new st("JWK was missing components");return be([sh,yn(be([Tt(H(e.n,"base64url")),Tt(H(e.e,"base64url"))]))]).subarray()}function bc(e){let t=se(e);return Yi(t)}function Yi(e){let t=Gi(e);return Ji(t)}function Wi(e,t){if(e.byteLength>=ih)throw new ze("Key size is too large");let r=se(e,{offset:0});return Xi(r,e,t)}function Xi(e,t,r){let n=Zi(e);if(r==null){let o=or(te.encode({Type:it.RSA,Data:t}));r=Wt(zi,o)}return new pr(n,r)}function Ji(e){if(vc(e)>Hi)throw new st("Key size is too large");let t=Ec(e),r=or(te.encode({Type:it.RSA,Data:ji(t.publicKey)})),n=Wt(zi,r);return new Gr(t.privateKey,new pr(t.publicKey,n))}async function wc(e){if(e>Hi)throw new st("Key size is too large");let t=await Sc(e),r=or(te.encode({Type:it.RSA,Data:ji(t.publicKey)})),n=Wt(zi,r);return new Gr(t.privateKey,new pr(t.publicKey,n))}function Ec(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 Sc(e,t){let r=await kt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await fh(r,t);return{privateKey:n[0],publicKey:n[1]}}async function gc(e,t,r){let n=await kt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await kt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function xc(e,t,r,n){let o=await kt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await kt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function fh(e,t){if(e.privateKey==null||e.publicKey==null)throw new st("Private and public key are required");let r=await Promise.all([kt.get().subtle.exportKey("jwk",e.privateKey),kt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function vc(e){if(e.kty!=="RSA")throw new st("invalid key type");if(e.n==null)throw new st("invalid key modulus");return H(e.n,"base64url").length*8}var Pn=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(gn(t),q(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),ce(o)}update(t){return rr(this),this.iHash.update(t),this}digestInto(t){rr(this),q(t,this.outputLen,"output"),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||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,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()}},Qi=(e,t,r)=>new Pn(e,t).update(r).digest();Qi.create=(e,t)=>new Pn(e,t);var Ac=(e,t)=>(e+(e>=0?t:-t)/Ic)/t;function lh(e,t,r){let[[n,o],[i,s]]=t,c=Ac(s*e,r),a=Ac(-o*e,r),f=e-c*n-a*i,u=-c*o-a*s,l=f<he,g=u<he;l&&(f=-f),g&&(u=-u);let S=Kr(Math.ceil(li(r)/2))+mr;if(f<he||f>=S||u<he||u>=S)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:f,k2neg:g,k2:u}}function es(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ts(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return de(r.lowS,"lowS"),de(r.prehash,"prehash"),r.format!==void 0&&es(r.format),r}var rs=class extends Error{constructor(t=""){super(t)}},Te={Err:rs,_tlv:{encode:(e,t)=>{let{Err:r}=Te;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=Or(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Or(o.length/2|128):"";return Or(e)+i+o+t},decode(e,t){let{Err:r}=Te,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 a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+a);if(f.length!==a)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+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Te;if(e<he)throw new t("integer: negative integers are not allowed");let r=Or(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}=Te;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 ir(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Te,o=q(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=Te,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},he=BigInt(0),mr=BigInt(1),Ic=BigInt(2),Nn=BigInt(3),dh=BigInt(4);function Tc(e,t={}){let r=vn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;ve(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a}=t;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=Bc(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(A,m,y){let{x:d,y:E}=m.toAffine(),R=n.toBytes(d);if(de(y,"isCompressed"),y){u();let N=!n.isOdd(E);return Ct(Cc(N),R)}else return Ct(Uint8Array.of(4),R,n.toBytes(E))}function g(A){q(A,void 0,"Point");let{publicKey:m,publicKeyUncompressed:y}=f,d=A.length,E=A[0],R=A.subarray(1);if(d===m&&(E===2||E===3)){let N=n.fromBytes(R);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let L=T(N),O;try{O=n.sqrt(L)}catch(tt){let W=tt instanceof Error?": "+tt.message:"";throw new Error("bad point: is not on curve, sqrt error"+W)}u();let K=n.isOdd(O);return(E&1)===1!==K&&(O=n.neg(O)),{x:N,y:O}}else if(d===y&&E===4){let N=n.BYTES,L=n.fromBytes(R.subarray(0,N)),O=n.fromBytes(R.subarray(N,N*2));if(!I(L,O))throw new Error("bad point: is not on curve");return{x:L,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${m} or uncompressed=${y}`)}let S=t.toBytes||l,b=t.fromBytes||g;function T(A){let m=n.sqr(A),y=n.mul(m,A);return n.add(n.add(y,n.mul(A,i.a)),i.b)}function I(A,m){let y=n.sqr(m),d=T(A);return n.eql(y,d)}if(!I(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,Nn),dh),B=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,B)))throw new Error("bad curve params: a or b");function v(A,m,y=!1){if(!n.isValid(m)||y&&n.is0(m))throw new Error(`bad point coordinate ${A}`);return m}function P(A){if(!(A instanceof p))throw new Error("Weierstrass Point expected")}function k(A){if(!a||!a.basises)throw new Error("no endo");return lh(A,a.basises,o.ORDER)}let V=sr((A,m)=>{let{X:y,Y:d,Z:E}=A;if(n.eql(E,n.ONE))return{x:y,y:d};let R=A.is0();m==null&&(m=R?n.ONE:n.inv(E));let N=n.mul(y,m),L=n.mul(d,m),O=n.mul(E,m);if(R)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:N,y:L}}),F=sr(A=>{if(A.is0()){if(t.allowInfinityPoint&&!n.is0(A.Y))return;throw new Error("bad point: ZERO")}let{x:m,y}=A.toAffine();if(!n.isValid(m)||!n.isValid(y))throw new Error("bad point: x or y not field elements");if(!I(m,y))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function h(A,m,y,d,E){return y=new p(n.mul(y.X,A),y.Y,y.Z),m=Mr(d,m),y=Mr(E,y),m.add(y)}class p{static BASE=new p(i.Gx,i.Gy,n.ONE);static ZERO=new p(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(m,y,d){this.X=v("x",m),this.Y=v("y",y,!0),this.Z=v("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){let{x:y,y:d}=m||{};if(!m||!n.isValid(y)||!n.isValid(d))throw new Error("invalid affine point");if(m instanceof p)throw new Error("projective point not allowed");return n.is0(y)&&n.is0(d)?p.ZERO:new p(y,d,n.ONE)}static fromBytes(m){let y=p.fromAffine(b(q(m,void 0,"point")));return y.assertValidity(),y}static fromHex(m){return p.fromBytes(fe(m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,y=!0){return D.createCache(this,m),y||this.multiply(Nn),this}assertValidity(){F(this)}hasEvenY(){let{y:m}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(m)}equals(m){P(m);let{X:y,Y:d,Z:E}=this,{X:R,Y:N,Z:L}=m,O=n.eql(n.mul(y,L),n.mul(R,E)),K=n.eql(n.mul(d,L),n.mul(N,E));return O&&K}negate(){return new p(this.X,n.neg(this.Y),this.Z)}double(){let{a:m,b:y}=i,d=n.mul(y,Nn),{X:E,Y:R,Z:N}=this,L=n.ZERO,O=n.ZERO,K=n.ZERO,$=n.mul(E,E),tt=n.mul(R,R),W=n.mul(N,N),G=n.mul(E,R);return G=n.add(G,G),K=n.mul(E,N),K=n.add(K,K),L=n.mul(m,K),O=n.mul(d,W),O=n.add(L,O),L=n.sub(tt,O),O=n.add(tt,O),O=n.mul(L,O),L=n.mul(G,L),K=n.mul(d,K),W=n.mul(m,W),G=n.sub($,W),G=n.mul(m,G),G=n.add(G,K),K=n.add($,$),$=n.add(K,$),$=n.add($,W),$=n.mul($,G),O=n.add(O,$),W=n.mul(R,N),W=n.add(W,W),$=n.mul(W,G),L=n.sub(L,$),K=n.mul(W,tt),K=n.add(K,K),K=n.add(K,K),new p(L,O,K)}add(m){P(m);let{X:y,Y:d,Z:E}=this,{X:R,Y:N,Z:L}=m,O=n.ZERO,K=n.ZERO,$=n.ZERO,tt=i.a,W=n.mul(i.b,Nn),G=n.mul(y,R),et=n.mul(d,N),dt=n.mul(E,L),jt=n.add(y,d),rt=n.add(R,N);jt=n.mul(jt,rt),rt=n.add(G,et),jt=n.sub(jt,rt),rt=n.add(y,E);let gt=n.add(R,L);return rt=n.mul(rt,gt),gt=n.add(G,dt),rt=n.sub(rt,gt),gt=n.add(d,E),O=n.add(N,L),gt=n.mul(gt,O),O=n.add(et,dt),gt=n.sub(gt,O),$=n.mul(tt,rt),O=n.mul(W,dt),$=n.add(O,$),O=n.sub(et,$),$=n.add(et,$),K=n.mul(O,$),et=n.add(G,G),et=n.add(et,G),dt=n.mul(tt,dt),rt=n.mul(W,rt),et=n.add(et,dt),dt=n.sub(G,dt),dt=n.mul(tt,dt),rt=n.add(rt,dt),G=n.mul(et,rt),K=n.add(K,G),G=n.mul(gt,rt),O=n.mul(jt,O),O=n.sub(O,G),G=n.mul(jt,et),$=n.mul(gt,$),$=n.add($,G),new p(O,K,$)}subtract(m){return this.add(m.negate())}is0(){return this.equals(p.ZERO)}multiply(m){let{endo:y}=t;if(!o.isValidNot0(m))throw new Error("invalid scalar: out of range");let d,E,R=N=>D.cached(this,N,L=>Ve(p,L));if(y){let{k1neg:N,k1:L,k2neg:O,k2:K}=k(m),{p:$,f:tt}=R(L),{p:W,f:G}=R(K);E=tt.add(G),d=h(y.beta,$,W,N,O)}else{let{p:N,f:L}=R(m);d=N,E=L}return Ve(p,[d,E])[0]}multiplyUnsafe(m){let{endo:y}=t,d=this;if(!o.isValid(m))throw new Error("invalid scalar: out of range");if(m===he||d.is0())return p.ZERO;if(m===mr)return d;if(D.hasCache(this))return this.multiply(m);if(y){let{k1neg:E,k1:R,k2neg:N,k2:L}=k(m),{p1:O,p2:K}=Qa(p,d,R,L);return h(y.beta,O,K,E,N)}else return D.unsafe(d,m)}toAffine(m){return V(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return s===mr?!0:m?m(p,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:m}=t;return s===mr?this:m?m(p,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return de(m,"isCompressed"),this.assertValidity(),S(p,this,m)}toHex(m=!0){return ue(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,D=new ur(p,t.endo?Math.ceil(_/2):_);return p.BASE.precompute(8),p}function Cc(e){return Uint8Array.of(e?2:3)}function Bc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function hh(e,t={}){let{Fn:r}=e,n=t.randomBytes||nr,o=Object.assign(Bc(e.Fp,r),{seed:mi(r.ORDER)});function i(S){try{let b=r.fromBytes(S);return r.isValidNot0(b)}catch{return!1}}function s(S,b){let{publicKey:T,publicKeyUncompressed:I}=o;try{let w=S.length;return b===!0&&w!==T||b===!1&&w!==I?!1:!!e.fromBytes(S)}catch{return!1}}function c(S=n(o.seed)){return yi(q(S,o.seed,"seed"),r.ORDER)}function a(S,b=!0){return e.BASE.multiply(r.fromBytes(S)).toBytes(b)}function f(S){let{secretKey:b,publicKey:T,publicKeyUncompressed:I}=o;if(!Ne(S)||"_lengths"in r&&r._lengths||b===T)return;let w=q(S,void 0,"key").length;return w===T||w===I}function u(S,b,T=!0){if(f(S)===!0)throw new Error("first arg must be private key");if(f(b)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(S);return e.fromBytes(b).multiply(I).toBytes(T)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},g=An(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:g,Point:e,utils:l,lengths:o})}function _c(e,t,r={}){gn(t),ve(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||nr,o=r.hmac||((y,d)=>Qi(t,y,d)),{Fp:i,Fn:s}=e,{ORDER:c,BITS:a}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:g,lengths:S}=hh(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},T=c*Ic<i.ORDER;function I(y){let d=c>>mr;return y>d}function w(y,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return d}function B(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(y,d){es(d);let E=S.signature,R=d==="compact"?E:d==="recovered"?E+1:void 0;return q(y,R)}class P{r;s;recovery;constructor(d,E,R){if(this.r=w("r",d),this.s=w("s",E),R!=null){if(B(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(d,E=b.format){v(d,E);let R;if(E==="der"){let{r:K,s:$}=Te.toSig(q(d));return new P(K,$)}E==="recovered"&&(R=d[0],E="compact",d=d.subarray(1));let N=S.signature/2,L=d.subarray(0,N),O=d.subarray(N,N*2);return new P(s.fromBytes(L),s.fromBytes(O),R)}static fromHex(d,E){return this.fromBytes(fe(d),E)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new P(this.r,this.s,d)}recoverPublicKey(d){let{r:E,s:R}=this,N=this.assertRecovery(),L=N===2||N===3?E+c:E;if(!i.isValid(L))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(L),K=e.fromBytes(Ct(Cc((N&1)===0),O)),$=s.inv(L),tt=V(q(d,void 0,"msgHash")),W=s.create(-tt*$),G=s.create(R*$),et=e.BASE.multiplyUnsafe(W).add(K.multiplyUnsafe(G));if(et.is0())throw new Error("invalid recovery: point at infinify");return et.assertValidity(),et}hasHighS(){return I(this.s)}toBytes(d=b.format){if(es(d),d==="der")return fe(Te.hexFromSig(this));let{r:E,s:R}=this,N=s.toBytes(E),L=s.toBytes(R);return d==="recovered"?(B(),Ct(Uint8Array.of(this.assertRecovery()),N,L)):Ct(N,L)}toHex(d){return ue(this.toBytes(d))}}let k=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let E=ir(d),R=d.length*8-a;return R>0?E>>BigInt(R):E},V=r.bits2int_modN||function(d){return s.create(k(d))},F=Kr(a);function h(y){return kr("num < 2^"+a,y,he,F),s.toBytes(y)}function p(y,d){return q(y,void 0,"message"),d?q(t(y),void 0,"prehashed message"):y}function _(y,d,E){let{lowS:R,prehash:N,extraEntropy:L}=ts(E,b);y=p(y,N);let O=V(y),K=s.fromBytes(d);if(!s.isValidNot0(K))throw new Error("invalid private key");let $=[h(K),h(O)];if(L!=null&&L!==!1){let et=L===!0?n(S.secretKey):L;$.push(q(et,void 0,"extraEntropy"))}let tt=Ct(...$),W=O;function G(et){let dt=k(et);if(!s.isValidNot0(dt))return;let jt=s.inv(dt),rt=e.BASE.multiply(dt).toAffine(),gt=s.create(rt.x);if(gt===he)return;let un=s.create(jt*s.create(W+gt*K));if(un===he)return;let Ks=(rt.x===gt?0:2)|Number(rt.y&mr),Vs=un;return R&&I(un)&&(Vs=s.neg(un),Ks^=1),new P(gt,Vs,T?void 0:Ks)}return{seed:tt,k2sig:G}}function D(y,d,E={}){let{seed:R,k2sig:N}=_(y,d,E);return Oa(t.outputLen,s.BYTES,o)(R,N).toBytes(E.format)}function A(y,d,E,R={}){let{lowS:N,prehash:L,format:O}=ts(R,b);if(E=q(E,void 0,"publicKey"),d=p(d,L),!Ne(y)){let K=y instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}v(y,O);try{let K=P.fromBytes(y,O),$=e.fromBytes(E);if(N&&K.hasHighS())return!1;let{r:tt,s:W}=K,G=V(d),et=s.inv(W),dt=s.create(G*et),jt=s.create(tt*et),rt=e.BASE.multiplyUnsafe(dt).add($.multiplyUnsafe(jt));return rt.is0()?!1:s.create(rt.x)===tt}catch{return!1}}function m(y,d,E={}){let{prehash:R}=ts(E,b);return d=p(d,R),P.fromBytes(y,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:g,lengths:S,Point:e,sign:D,verify:A,recoverPublicKey:m,Signature:P,hash:t})}var os={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ph={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Dc=BigInt(2);function mh(e){let t=os.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=J(u,r,t)*u%t,g=J(l,r,t)*u%t,S=J(g,Dc,t)*f%t,b=J(S,o,t)*S%t,T=J(b,i,t)*b%t,I=J(T,c,t)*T%t,w=J(I,a,t)*I%t,B=J(w,c,t)*T%t,v=J(B,r,t)*u%t,P=J(v,s,t)*b%t,k=J(P,n,t)*f%t,V=J(k,Dc,t);if(!ns.eql(ns.sqr(V),e))throw new Error("Cannot find square root");return V}var ns=ar(os.p,{sqrt:mh}),yh=Tc(os,{Fp:ns,endo:ph}),yr=_c(yh,or);function Rc(e,t,r,n){let o=_r.digest(r instanceof Uint8Array?r:r.subarray());if(Cn(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),yr.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Fr(String(i))});try{return n?.signal?.throwIfAborted(),yr.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new Fr(String(i))}}var Un=class{type="secp256k1";raw;_key;constructor(t){this._key=Nc(t),this.raw=Pc(this._key)}toMultihash(){return Bt.digest(er(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return Rc(this._key,r,t,n)}};function is(e){return new Un(e)}function Pc(e){return yr.Point.fromBytes(e).toBytes()}function Nc(e){try{return yr.Point.fromBytes(e),e}catch(t){throw new ze(String(t))}}function Uc(e,t){let{Type:r,Data:n}=te.decode(e),o=n??new Uint8Array;switch(r){case it.RSA:return Wi(o,t);case it.Ed25519:return Ai(o);case it.secp256k1:return is(o);case it.ECDSA:return Qo(o);default:throw new Ze}}function Ln(e){let{Type:t,Data:r}=te.decode(e.digest),n=r??new Uint8Array;switch(t){case it.Ed25519:return Ai(n);case it.secp256k1:return is(n);case it.ECDSA:return Qo(n);default:throw new Ze}}function er(e){return te.encode({Type:it[e.type],Data:e.raw})}var Lc=Symbol.for("nodejs.util.inspect.custom"),gh=114,jr=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()})`}[vo]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return j.createV1(gh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Y(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Y(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Lc](){return`PeerId(${this.toString()})`}},On=class extends jr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},kn=class extends jr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Kn=class extends jr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},xh=2336,Yr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Bt.digest(H(this.url))}[Lc](){return`PeerId(${this.url})`}[vo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return j.createV1(xh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=z(t)),t.toString()===this.toString())}};var bh=114,Oc=2336;function kc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Re(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return ss(j.parse(e));if(t==null)throw new st('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Re(t.decode(e))}return Kc(r)}function Kc(e){if(Eh(e))return new On({multihash:e});if(wh(e))try{let t=Ln(e);if(t.type==="Ed25519")return new kn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Kn({multihash:e,publicKey:t})}catch{let r=z(e.digest);return new Yr(new URL(r))}throw new Ge("Supplied PeerID Multihash is invalid")}function ss(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==bh&&e.code!==Oc)throw new ln("Supplied PeerID CID is invalid");if(e.code===Oc){let t=z(e.multihash.digest);return new Yr(new URL(t))}return Kc(e.multihash)}function wh(e){return e.code===Bt.code}function Eh(e){return e.code===_r.code}var pt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},pe=class extends Error{static name="ValidationError";name="ValidationError"},Vn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Mn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Fn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let g=Number.parseInt(l,t);if(!Number.isNaN(g))return g});if(u===void 0)break;if(i*=t,i+=u,i>f||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return r.set(i.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Sh=45,vh=15,$n=new Fn;function Vc(e){if(!(e.length>vh))return $n.new(e).parseWith(()=>$n.readIPv4Addr())}function Mc(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Sh))return $n.new(e).parseWith(()=>$n.readIPv6Addr())}function qn(e){return!!Vc(e)}function Fc(e){return!!Mc(e)}function cs(e){return t=>z(t,e)}function us(e){return t=>H(t,e)}function gr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function $e(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function $c(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=H(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=$e(n);return Ot([r,o],r.length+o.length)}function qc(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=Yt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=$e(n);return Ot([r,o],r.length+o.length)}function fs(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=z(t,"base32"),o=gr(r);return`${n}:${o}`}var ls=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new pt("Invalid byte value in IP address");t[n]=o}),t},Hc=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=qn(r[n]),s;i&&(s=ls(r[n]),r[n]=z(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,z(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new pt("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},zc=function(e){if(e.byteLength!==4)throw new pt("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Gc=function(e){if(e.byteLength!==16)throw new pt("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],i=e[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;t.push(s)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new pt(`Invalid IPv6 address "${r}"`)}};function Zc(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new pt(`Invalid IPv6 address "${e}"`)}}var as=Object.values(Dr).map(e=>e.decoder),Ah=(function(){let e=as[0].or(as[1]);return as.slice(2).forEach(t=>e=e.or(t)),e})();function jc(e){return Ah.decode(e)}function Yc(e){return t=>e.encoder.encode(t)}function Ih(e){if(parseInt(e).toString()!==e)throw new pe("Value must be an integer")}function Th(e){if(e<0)throw new pe("Value must be a positive integer, or zero")}function Ch(e){return t=>{if(t>e)throw new pe(`Value must be smaller than or equal to ${e}`)}}function Bh(...e){return t=>{for(let r of e)r(t)}}var Wr=Bh(Ih,Th,Ch(65535));var ft=-1,ds=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new Mn(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},me=new ds,mp=[{code:4,name:"ip4",size:32,valueToBytes:ls,bytesToValue:zc,validate:e=>{if(!qn(e))throw new pe(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:$e,bytesToValue:gr,validate:Wr},{code:273,name:"udp",size:16,valueToBytes:$e,bytesToValue:gr,validate:Wr},{code:33,name:"dccp",size:16,valueToBytes:$e,bytesToValue:gr,validate:Wr},{code:41,name:"ip6",size:128,valueToBytes:Hc,bytesToValue:Gc,stringToValue:Zc,validate:e=>{if(!Fc(e))throw new pe(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ft},{code:43,name:"ipcidr",size:8,bytesToValue:cs("base10"),valueToBytes:us("base10")},{code:53,name:"dns",size:ft},{code:54,name:"dns4",size:ft},{code:55,name:"dns6",size:ft},{code:56,name:"dnsaddr",size:ft},{code:132,name:"sctp",size:16,valueToBytes:$e,bytesToValue:gr,validate:Wr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ft,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ft,bytesToValue:cs("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?us("base58btc")(e):j.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:fs,valueToBytes:$c},{code:445,name:"onion3",size:296,bytesToValue:fs,valueToBytes:qc},{code:446,name:"garlic64",size:ft},{code:447,name:"garlic32",size:ft},{code:448,name:"tls"},{code:449,name:"sni",size:ft},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ft,bytesToValue:Yc(Ro),valueToBytes:jc},{code:480,name:"http"},{code:481,name:"http-path",size:ft,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ft}];mp.forEach(e=>{me.addProtocol(e)});function Wc(e){let t=[],r=0;for(;r<e.length;){let n=Di(e,r),o=me.getProtocol(n),i=Qt(n),s=yp(o,e,r+i),c=0;s>0&&o.size===ft&&(c=Qt(s));let a=i+c+s,f={code:n,name:o.name,bytes:e.subarray(r,r+a)};if(s>0){let u=r+i+c,l=e.subarray(u,u+s);f.value=o.bytesToValue?.(l)??z(l)}t.push(f),r+=a}return t}function Xc(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=me.getProtocol(n.code),i=Qt(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??H(n.value),c=s.byteLength,o.size===ft&&(a=Qt(c)));let f=new Uint8Array(i+a+c),u=0;$r(n.code,f,u),u+=i,s!=null&&(o.size===ft&&($r(c,f,u),u+=a),f.set(s,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Ot(r,t)}function Jc(e){if(e.charAt(0)!=="/")throw new pt('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let i=1;i<e.length;i++){let s=e.charAt(i);s!=="/"&&(r==="protocol"?o+=e.charAt(i):n+=e.charAt(i));let c=i===e.length-1;if(s==="/"||c){let a=me.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){t.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new pt(`Component ${o} was missing value`);r="value"}else if(r==="value"){let f={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new pt(`Component ${o} was missing value`);f.value=a.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new pt("Incomplete multiaddr");return t}function Qc(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=me.getProtocol(t.code);if(r==null)throw new pt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function yp(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Di(t,r)}var gp=Symbol.for("nodejs.util.inspect.custom"),hs=Symbol.for("@multiformats/multiaddr");function xp(e){if(e==null&&(e="/"),tu(e))return e.getComponents();if(e instanceof Uint8Array)return Wc(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Jc(e);if(Array.isArray(e))return e;throw new pt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Hn=class e{[hs]=!0;#t;#n;#r;constructor(t="/",r={}){this.#t=xp(t),r.validate!==!1&&bp(this)}get bytes(){return this.#r==null&&(this.#r=Xc(this.#t)),this.#r}toString(){return this.#n==null&&(this.#n=Qc(this.#t)),this.#n}toJSON(){return this.toString()}getComponents(){return[...this.#t.map(t=>({...t}))]}encapsulate(t){let r=new e(t);return new e([...this.#t,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Vn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}equals(t){return Y(this.bytes,t.bytes)}[gp](){return`Multiaddr(${this.toString()})`}};function bp(e){e.getComponents().forEach(t=>{let r=me.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function tu(e){return!!e?.[hs]}function zn(e){return new Hn(e)}function Xr(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*Gn(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}var Qp=So(ms(),1);var $t=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Zn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},xr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},jn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Yn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Wn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Jr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var qt;(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=()=>zr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=hr((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 c={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let f=o.uint32();switch(f>>>3){case 1:{c.value=o.bytes();break}case 2:{c.signatureV1=o.bytes();break}case 3:{c.validityType=e.ValidityType.codec().decode(o);break}case 4:{c.validity=o.bytes();break}case 5:{c.sequence=o.uint64();break}case 6:{c.ttl=o.uint64();break}case 7:{c.pubKey=o.bytes();break}case 8:{c.signatureV2=o.bytes();break}case 9:{c.data=o.bytes();break}default:{o.skipType(f&7);break}}}return c})),n),e.encode=o=>lr(o,e.codec()),e.decode=(o,i)=>fr(o,e.codec(),i)})(qt||(qt={}));var wp=["string","number","bigint","symbol"],Ep=["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 eu(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(wp.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Sp(e))return"Buffer";let r=vp(e);return r||"Object"}function Sp(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function vp(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ep.includes(t))return t}var x=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}};x.uint=new x(0,"uint",!0);x.negint=new x(1,"negint",!0);x.bytes=new x(2,"bytes",!0);x.string=new x(3,"string",!0);x.array=new x(4,"array",!1);x.map=new x(5,"map",!1);x.tag=new x(6,"tag",!1);x.float=new x(7,"float",!0);x.false=new x(7,"false",!0);x.true=new x(7,"true",!0);x.null=new x(7,"null",!0);x.undefined=new x(7,"undefined",!0);x.break=new x(7,"break",!0);var U=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 br=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ap=new TextDecoder,Ip=new TextEncoder;function Xn(e){return br&&globalThis.Buffer.isBuffer(e)}function iu(e){return e instanceof Uint8Array?Xn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var su=br?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):nu(e,t,r):(e,t,r)=>r-t>64?Ap.decode(e.subarray(t,r)):nu(e,t,r),au=br?e=>e.length>64?globalThis.Buffer.from(e):ru(e):e=>e.length>64?Ip.encode(e):ru(e);var wr=br?(e,t,r)=>Xn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),cu=br?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),iu(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},uu=br?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function fu(e,t){if(Xn(e)&&Xn(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 ru(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 nu(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 c,a,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:c=e[t+1],(c&192)===128&&(u=(o&31)<<6|c&63,u>127&&(i=u));break;case 3:c=e[t+1],a=e[t+2],(c&192)===128&&(a&192)===128&&(u=(o&15)<<12|(c&63)<<6|a&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:c=e[t+1],a=e[t+2],f=e[t+3],(c&192)===128&&(a&192)===128&&(f&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&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 Tp(n)}var ou=4096;function Tp(e){let t=e.length;if(t<=ou)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ou));return r}var Cp=256,Jn=class{constructor(t=Cp){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=uu(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=wr(n,0,this.cursor)}else r=cu(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",ys="CBOR encode error:",Qr=[];Qr[23]=1;Qr[24]=2;Qr[25]=3;Qr[26]=5;Qr[27]=9;function ye(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var lt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Pt(e,t,r){ye(e,t,1);let n=e[t];if(r.strict===!0&&n<lt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){ye(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<lt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ut(e,t,r){ye(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<lt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Lt(e,t,r){ye(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<lt[3])throw new Error(`${M} 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(`${M} integers outside of the safe integer range are not supported`)}function lu(e,t,r,n){return new U(x.uint,Pt(e,t+1,n),2)}function du(e,t,r,n){return new U(x.uint,Nt(e,t+1,n),3)}function hu(e,t,r,n){return new U(x.uint,Ut(e,t+1,n),5)}function pu(e,t,r,n){return new U(x.uint,Lt(e,t+1,n),9)}function Kt(e,t){return mt(e,0,t.value)}function mt(e,t,r){if(r<lt[0]){let n=Number(r);e.push([t|n])}else if(r<lt[1]){let n=Number(r);e.push([t|24,n])}else if(r<lt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<lt[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<lt[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(`${M} encountered BigInt larger than allowable range`)}}Kt.encodedSize=function(t){return mt.encodedSize(t.value)};mt.encodedSize=function(t){return t<lt[0]?1:t<lt[1]?2:t<lt[2]?3:t<lt[3]?5:9};Kt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function mu(e,t,r,n){return new U(x.negint,-1-Pt(e,t+1,n),2)}function yu(e,t,r,n){return new U(x.negint,-1-Nt(e,t+1,n),3)}function gu(e,t,r,n){return new U(x.negint,-1-Ut(e,t+1,n),5)}var gs=BigInt(-1),xu=BigInt(1);function bu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new U(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new U(x.negint,gs-BigInt(o),9)}function Qn(e,t){let r=t.value,n=typeof r=="bigint"?r*gs-xu:r*-1-1;mt(e,t.type.majorEncoded,n)}Qn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*gs-xu:r*-1-1;return n<lt[0]?1:n<lt[1]?2:n<lt[2]?3:n<lt[3]?5:9};Qn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function tn(e,t,r,n){ye(e,t,r+n);let o=wr(e,t+r,t+r+n);return new U(x.bytes,o,r+n)}function wu(e,t,r,n){return tn(e,t,1,r)}function Eu(e,t,r,n){return tn(e,t,2,Pt(e,t+1,n))}function Su(e,t,r,n){return tn(e,t,3,Nt(e,t+1,n))}function vu(e,t,r,n){return tn(e,t,5,Ut(e,t+1,n))}function Au(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return tn(e,t,9,o)}function to(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===x.string?au(e.value):e.value),e.encodedBytes}function Er(e,t){let r=to(t);mt(e,t.type.majorEncoded,r.length),e.push(r)}Er.encodedSize=function(t){let r=to(t);return mt.encodedSize(r.length)+r.length};Er.compareTokens=function(t,r){return _p(to(t),to(r))};function _p(e,t){return e.length<t.length?-1:e.length>t.length?1:fu(e,t)}function en(e,t,r,n,o){let i=r+n;ye(e,t,i);let s=new U(x.string,su(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=wr(e,t+r,t+i)),s}function Iu(e,t,r,n){return en(e,t,1,r,n)}function Tu(e,t,r,n){return en(e,t,2,Pt(e,t+1,n),n)}function Cu(e,t,r,n){return en(e,t,3,Nt(e,t+1,n),n)}function Bu(e,t,r,n){return en(e,t,5,Ut(e,t+1,n),n)}function _u(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return en(e,t,9,o,n)}var Du=Er;function Sr(e,t,r,n){return new U(x.array,n,r)}function Ru(e,t,r,n){return Sr(e,t,1,r)}function Pu(e,t,r,n){return Sr(e,t,2,Pt(e,t+1,n))}function Nu(e,t,r,n){return Sr(e,t,3,Nt(e,t+1,n))}function Uu(e,t,r,n){return Sr(e,t,5,Ut(e,t+1,n))}function Lu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Sr(e,t,9,o)}function Ou(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Sr(e,t,1,1/0)}function eo(e,t){mt(e,x.array.majorEncoded,t.value)}eo.compareTokens=Kt.compareTokens;eo.encodedSize=function(t){return mt.encodedSize(t.value)};function vr(e,t,r,n){return new U(x.map,n,r)}function ku(e,t,r,n){return vr(e,t,1,r)}function Ku(e,t,r,n){return vr(e,t,2,Pt(e,t+1,n))}function Vu(e,t,r,n){return vr(e,t,3,Nt(e,t+1,n))}function Mu(e,t,r,n){return vr(e,t,5,Ut(e,t+1,n))}function Fu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return vr(e,t,9,o)}function $u(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return vr(e,t,1,1/0)}function ro(e,t){mt(e,x.map.majorEncoded,t.value)}ro.compareTokens=Kt.compareTokens;ro.encodedSize=function(t){return mt.encodedSize(t.value)};function qu(e,t,r,n){return new U(x.tag,r,1)}function Hu(e,t,r,n){return new U(x.tag,Pt(e,t+1,n),2)}function zu(e,t,r,n){return new U(x.tag,Nt(e,t+1,n),3)}function Gu(e,t,r,n){return new U(x.tag,Ut(e,t+1,n),5)}function Zu(e,t,r,n){return new U(x.tag,Lt(e,t+1,n),9)}function no(e,t){mt(e,x.tag.majorEncoded,t.value)}no.compareTokens=Kt.compareTokens;no.encodedSize=function(t){return mt.encodedSize(t.value)};var Lp=20,Op=21,kp=22,Kp=23;function ju(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(x.null,null,1):new U(x.undefined,void 0,1)}function Yu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new U(x.break,void 0,1)}function xs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new U(x.float,e,t)}function Wu(e,t,r,n){return xs(bs(e,t+1),3,n)}function Xu(e,t,r,n){return xs(ws(e,t+1),5,n)}function Ju(e,t,r,n){return xs(rf(e,t+1),9,n)}function oo(e,t,r){let n=t.value;if(n===!1)e.push([x.float.majorEncoded|Lp]);else if(n===!0)e.push([x.float.majorEncoded|Op]);else if(n===null)e.push([x.float.majorEncoded|kp]);else if(n===void 0)e.push([x.float.majorEncoded|Kp]);else{let o,i=!1;(!r||r.float64!==!0)&&(tf(n),o=bs(Ht,1),n===o||Number.isNaN(n)?(Ht[0]=249,e.push(Ht.slice(0,3)),i=!0):(ef(n),o=ws(Ht,1),n===o&&(Ht[0]=250,e.push(Ht.slice(0,5)),i=!0))),i||(Vp(n),o=rf(Ht,1),Ht[0]=251,e.push(Ht.slice(0,9)))}}oo.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){tf(n);let o=bs(Ht,1);if(n===o||Number.isNaN(n))return 3;if(ef(n),o=ws(Ht,1),n===o)return 5}return 9};var Qu=new ArrayBuffer(9),Vt=new DataView(Qu,1),Ht=new Uint8Array(Qu,0);function tf(e){if(e===1/0)Vt.setUint16(0,31744,!1);else if(e===-1/0)Vt.setUint16(0,64512,!1);else if(Number.isNaN(e))Vt.setUint16(0,32256,!1);else{Vt.setFloat32(0,e);let t=Vt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Vt.setUint16(0,31744,!1);else if(r===0)Vt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Vt.setUint16(0,0):o<-14?Vt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Vt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function bs(e,t){if(e.length-t<2)throw new Error(`${M} 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 ef(e){Vt.setFloat32(0,e,!1)}function ws(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Vp(e){Vt.setFloat64(0,e,!1)}function rf(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}oo.compareTokens=Kt.compareTokens;function Z(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function io(e){return()=>{throw new Error(`${M} ${e}`)}}var C=[];for(let e=0;e<=23;e++)C[e]=Z;C[24]=lu;C[25]=du;C[26]=hu;C[27]=pu;C[28]=Z;C[29]=Z;C[30]=Z;C[31]=Z;for(let e=32;e<=55;e++)C[e]=Z;C[56]=mu;C[57]=yu;C[58]=gu;C[59]=bu;C[60]=Z;C[61]=Z;C[62]=Z;C[63]=Z;for(let e=64;e<=87;e++)C[e]=wu;C[88]=Eu;C[89]=Su;C[90]=vu;C[91]=Au;C[92]=Z;C[93]=Z;C[94]=Z;C[95]=io("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)C[e]=Iu;C[120]=Tu;C[121]=Cu;C[122]=Bu;C[123]=_u;C[124]=Z;C[125]=Z;C[126]=Z;C[127]=io("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)C[e]=Ru;C[152]=Pu;C[153]=Nu;C[154]=Uu;C[155]=Lu;C[156]=Z;C[157]=Z;C[158]=Z;C[159]=Ou;for(let e=160;e<=183;e++)C[e]=ku;C[184]=Ku;C[185]=Vu;C[186]=Mu;C[187]=Fu;C[188]=Z;C[189]=Z;C[190]=Z;C[191]=$u;for(let e=192;e<=215;e++)C[e]=qu;C[216]=Hu;C[217]=zu;C[218]=Gu;C[219]=Zu;C[220]=Z;C[221]=Z;C[222]=Z;C[223]=Z;for(let e=224;e<=243;e++)C[e]=io("simple values are not supported");C[244]=Z;C[245]=Z;C[246]=Z;C[247]=ju;C[248]=io("simple values are not supported");C[249]=Wu;C[250]=Xu;C[251]=Ju;C[252]=Z;C[253]=Z;C[254]=Z;C[255]=Yu;var zt=[];for(let e=0;e<24;e++)zt[e]=new U(x.uint,e,1);for(let e=-1;e>=-24;e--)zt[31-e]=new U(x.negint,e,1);zt[64]=new U(x.bytes,new Uint8Array(0),1);zt[96]=new U(x.string,"",1);zt[128]=new U(x.array,0,1);zt[160]=new U(x.map,0,1);zt[244]=new U(x.false,!1,1);zt[245]=new U(x.true,!0,1);zt[246]=new U(x.null,null,1);function Fp(){let e=[];return e[x.uint.major]=Kt,e[x.negint.major]=Qn,e[x.bytes.major]=Er,e[x.string.major]=Du,e[x.array.major]=eo,e[x.map.major]=ro,e[x.tag.major]=no,e[x.float.major]=oo,e}var l1=Fp(),d1=new Jn,so=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(`${ys} object contains circular references`);return new e(r,t)}},Ce={null:new U(x.null,null),undefined:new U(x.undefined,void 0),true:new U(x.true,!0),false:new U(x.false,!1),emptyArray:new U(x.array,0),emptyMap:new U(x.map,0)},Be={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new U(x.float,e):e>=0?new U(x.uint,e):new U(x.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new U(x.uint,e):new U(x.negint,e)},Uint8Array(e,t,r,n){return new U(x.bytes,e)},string(e,t,r,n){return new U(x.string,e)},boolean(e,t,r,n){return e?Ce.true:Ce.false},null(e,t,r,n){return Ce.null},undefined(e,t,r,n){return Ce.undefined},ArrayBuffer(e,t,r,n){return new U(x.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new U(x.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ce.emptyArray,new U(x.break)]:Ce.emptyArray;n=so.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Es(s,r,n);return r.addBreakTokens?[new U(x.array,e.length),o,new U(x.break)]:[new U(x.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?[Ce.emptyMap,new U(x.break)]:Ce.emptyMap;n=so.createCheck(n,e);let c=[],a=0;for(let f of i)c[a++]=[Es(f,r,n),Es(o?e.get(f):e[f],r,n)];return $p(c,r),r.addBreakTokens?[new U(x.map,s),c,new U(x.break)]:[new U(x.map,s),c]}};Be.Map=Be.Object;Be.Buffer=Be.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Be[`${e}Array`]=Be.DataView;function Es(e,t={},r){let n=eu(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Be[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Be[n];if(!i)throw new Error(`${ys} unsupported type: ${n}`);return i(e,n,t,r)}function $p(e,t){t.mapSorter&&e.sort(t.mapSorter)}var qp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ao=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=zt[t];if(r===void 0){let n=C[t];if(!n)throw new Error(`${M} 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}},rn=Symbol.for("DONE"),co=Symbol.for("BREAK");function Hp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Ar(t,r);if(i===co){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===rn)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function zp(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 c=Ar(t,r);if(c===co){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===rn)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${M} found repeat map key "${c}"`);let a=Ar(t,r);if(a===rn)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(c,a):o[c]=a}return n?i:o}function Ar(e,t){if(e.done())return rn;let r=e.next();if(r.type===x.break)return co;if(r.type.terminal)return r.value;if(r.type===x.array)return Hp(r,e,t);if(r.type===x.map)return zp(r,e,t);if(r.type===x.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Ar(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function nf(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},qp,t);let r=t.tokenizer||new ao(e,t),n=Ar(r,t);if(n===rn)throw new Error(`${M} did not find any content to decode`);if(n===co)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function Ss(e,t){let[r,n]=nf(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var jp=oe("ipns:utils"),of=H("/ipns/");var Yp=0,Wp=18;function sf(e){let t;if(e.pubKey!=null)try{t=Uc(e.pubKey)}catch(r){throw jp.error(r),r}if(t!=null)return t}function af(e){let t=H("ipns-signature:");return Ot([t,e])}function He(e){return"signatureV1"in e?qt.encode({value:H(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:H(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):qt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function ee(e){let t=qt.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 $t("Missing data or signatureV2");let r=cf(t.data),n=Xp(r.Value),o=z(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Jp(t),{value:n,validityType:qt.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:qt.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 nn(e){return Ot([of,e.bytes])}function ge(e){let t=Re(e.slice(of.length));if(!uo(t,Yp)&&!uo(t,Wp))throw new Ge("Multihash in IPNS key was not identity or sha2-256");return t}function cf(e){let t=Ss(e);if(t.ValidityType===0)t.ValidityType=qt.ValidityType.EOL;else throw new xr("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 Xp(e){let t=z(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${j.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${j.parse(t).toV1().toString()}`}catch{}throw new Yn("Value must be a valid content path starting with /")}function Jp(e){if(e.data==null)throw new Wn("Record data is missing");let t=cf(e.data);if(!Y(t.Value,e.value??new Uint8Array(0)))throw new $t('Field "value" did not match between protobuf and CBOR');if(!Y(t.Validity,e.validity??new Uint8Array(0)))throw new $t('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new $t('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new $t('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new $t('Field "ttl" did not match between protobuf and CBOR')}function uo(e,t){return e.code===t}var L1=oe("ipns"),O1=300*1e9,t0="/ipns/",k1=t0.length;var uf=So(ms(),1);var fo=oe("ipns:validator"),e0=1024*10;async function r0(e,t){let r=ee(t),n;try{let o=af(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw fo.error("record signature verification failed"),new $t("Record signature verification failed");if(r.validityType===qt.ValidityType.EOL){if(uf.default.fromString(r.validity).toDate().getTime()<Date.now())throw fo.error("record has expired"),new Zn("record has expired")}else if(r.validityType!=null)throw fo.error("the validity type is unsupported"),new xr("The validity type is unsupported");fo("ipns record for %s is valid",r.value)}async function ff(e,t){if(t.byteLength>e0)throw new jn("The record is too large");let r=ge(e),n;uo(r,0)&&(n=Ln(r));let o=ee(t),i=sf(o)??n;if(i==null)throw new Jr("Could not extract public key from IPNS record or routing key");let s=nn(i.toMultihash());if(!Y(s,e))throw new Jr("Embedded public key did not match routing key");await r0(i,t)}var lo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*on(e,t={}){let r=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of e){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),Qe(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new lo("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let c=0;c<s.length;c++)yield JSON.parse(s[c])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function re(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var As=So(df(),1);var Is=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},hf=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function Ts(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=t,c,a,u=new Promise((l,g)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){g(hf(s));return}if(s&&(a=()=>{g(hf(s))},s.addEventListener("abort",a,{once:!0})),e.then(l,g),r===Number.POSITIVE_INFINITY)return;let S=new Is;c=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(b){g(b)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?g(o):(S.message=o??`Promise timed out after ${r} milliseconds`,g(S))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}function Cs(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var an=class{#t=[];enqueue(t,r){let{priority:n=0,id:o}=r??{},i={priority:n,id:o,run:t};if(this.size===0||this.#t[this.size-1].priority>=n){this.#t.push(i);return}let s=Cs(this.#t,i,(c,a)=>a.priority-c.priority);this.#t.splice(s,0,i)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var cn=class extends As.default{#t;#n;#r=0;#h;#p=!1;#m=!1;#u;#b=0;#y=0;#i;#s;#e;#w;#o=0;#f;#a;#T=1n;#l=new Map;timeout;constructor(t){if(super(),t={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:an,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);if(this.#t=t.carryoverIntervalCount??t.carryoverConcurrencyCount??!1,this.#n=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#u=t.interval,this.#e=new t.queueClass,this.#w=t.queueClass,this.concurrency=t.concurrency,t.timeout!==void 0&&!(Number.isFinite(t.timeout)&&t.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${t.timeout}\` (${typeof t.timeout})`);this.timeout=t.timeout,this.#a=t.autoStart===!1,this.#U()}get#C(){return this.#n||this.#r<this.#h}get#B(){return this.#o<this.#f}#_(){this.#o--,this.#o===0&&this.emit("pendingZero"),this.#g(),this.emit("next")}#D(){this.#A(),this.#v(),this.#s=void 0}get#R(){let t=Date.now();if(this.#i===void 0){let r=this.#b-t;if(r<0){if(this.#y>0){let n=t-this.#y;if(n<this.#u)return this.#E(this.#u-n),!0}this.#r=this.#t?this.#o:0}else return this.#E(r),!0}return!1}#E(t){this.#s===void 0&&(this.#s=setTimeout(()=>{this.#D()},t))}#S(){this.#i&&(clearInterval(this.#i),this.#i=void 0)}#P(){this.#s&&(clearTimeout(this.#s),this.#s=void 0)}#g(){if(this.#e.size===0)return this.#S(),this.emit("empty"),this.#o===0&&(this.#P(),this.emit("idle")),!1;let t=!1;if(!this.#a){let r=!this.#R;if(this.#C&&this.#B){let n=this.#e.dequeue();this.#n||(this.#r++,this.#d()),this.emit("active"),this.#y=Date.now(),n(),r&&this.#v(),t=!0}}return t}#v(){this.#n||this.#i!==void 0||(this.#i=setInterval(()=>{this.#A()},this.#u),this.#b=Date.now()+this.#u)}#A(){this.#r===0&&this.#o===0&&this.#i&&this.#S(),this.#r=this.#t?this.#o:0,this.#x(),this.#d()}#x(){for(;this.#g(););}get concurrency(){return this.#f}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#f=t,this.#x()}async#N(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${r}\` (${typeof r})`);this.#e.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#T++).toString(),r={timeout:this.timeout,...r},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`);this.#e.enqueue(async()=>{this.#o++,this.#l.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});try{try{r.signal?.throwIfAborted()}catch(a){throw this.#n||this.#r--,this.#l.delete(i),a}let s=t({signal:r.signal});r.timeout&&(s=Ts(Promise.resolve(s),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#o} running, ${this.#e.size} waiting)`})),r.signal&&(s=Promise.race([s,this.#N(r.signal)]));let c=await s;n(c),this.emit("completed",c)}catch(s){o(s),this.emit("error",s)}finally{this.#l.delete(i),queueMicrotask(()=>{this.#_()})}},r),this.emit("add"),this.#g()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#a?(this.#a=!1,this.#x(),this):this}pause(){this.#a=!0}clear(){this.#e=new this.#w,this.#I()}async onEmpty(){this.#e.size!==0&&await this.#c("empty")}async onSizeLessThan(t){this.#e.size<t||await this.#c("next",()=>this.#e.size<t)}async onIdle(){this.#o===0&&this.#e.size===0||await this.#c("idle")}async onPendingZero(){this.#o!==0&&await this.#c("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#c("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#c("rateLimitCleared")}async onError(){return new Promise((t,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#c(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#e.size}sizeBy(t){return this.#e.filter(t).length}get pending(){return this.#o}get isPaused(){return this.#a}#U(){this.#n||(this.on("add",()=>{this.#e.size>0&&this.#d()}),this.on("next",()=>{this.#d()}))}#d(){this.#n||this.#m||(this.#m=!0,queueMicrotask(()=>{this.#m=!1,this.#I()}))}#I(){let t=this.#p,r=!this.#n&&this.#r>=this.#h&&this.#e.size>0;r!==t&&(this.#p=r,this.emit(r?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#p}get isSaturated(){return this.#o===this.#f&&this.#e.size>0||this.isRateLimited&&this.#e.size>0}get runningTasks(){return[...this.#l.values()].map(t=>({...t}))}};var Ir=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Gt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function i0(e){return e[Symbol.asyncIterator]!=null}function s0(e){if(i0(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var po=s0;function a0(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var pf=a0;function c0(e){return e[Symbol.asyncIterator]!=null}function u0(e,t){let r=0;if(c0(e))return(async function*(){for await(let a of e)yield t(a,r++)})();let n=pf(e),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=t(o,r++);if(typeof s.then=="function")return(async function*(){yield await s;for(let a of n)yield t(a,r++)})();let c=t;return(function*(){yield s;for(let a of n)yield c(a,r++)})()}var mo=u0;var mf=H("/ipns/");function yf(e){return Y(e.subarray(0,mf.byteLength),mf)}var yo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*mo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!yf(t))return;let o=ge(t),i=j.createV1(114,o),s=ee(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!yf(t))throw new At("Not found");let n=ge(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return He(i)}catch(i){throw i.name==="BadResponseError"?new At("Not found"):i}}},go=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await po(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new At("Not found")}async*getClosestPeers(t,r={}){}};var yt=oe("delegated-routing-v1-http-api-client"),xo={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},bo=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new cn({concurrency:r.concurrentRequests??xo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??xo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new yo(this),this.peerRouting=new go(this),this.cacheName=r.cacheName??xo.cacheName,this.cacheTTL=r.cacheTTL??xo.cacheTTL}get[$s](){return this.contentRouting}get[qs](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&&yt("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,r={}){yt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Xr([this.shutDownController.signal,n,r.signal]);let i=re(),s=re();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#n(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#r(c.toString(),a);if(f==null)throw new Gt("No response received");if(!f.ok)throw f.status===404?new At("No matching records found"):f.status===422?new Ir("Request does not conform to schema or semantic constraints"):new Gt(`Unexpected status code: ${f.status}`);if(f.body==null)throw new Gt("Routing response had no body");let u=f.headers.get("Content-Type");if(u==null)throw new Gt("No Content-Type header received");if(u?.startsWith("application/json")){let l=await f.json();for(let g of l.Providers){let S=this.#t(g);S!=null&&(yield S)}}else if(u.includes("application/x-ndjson"))for await(let l of on(Gn(f.body))){let g=this.#t(l);g!=null&&(yield g)}else throw new Gt(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),yt("getProviders finished: %c",t)}}async*getPeers(t,r={}){yt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Xr([this.shutDownController.signal,n,r.signal]);let i=re(),s=re();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#n(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#r(c.toString(),a);if(f.status===404)throw new At("No matching records found");if(f.status===422)throw new Ir("Request does not conform to schema or semantic constraints");if(f.body==null)throw new Gt("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let g of l.Peers){let S=this.#t(g);S!=null&&(yield S)}}else for await(let l of on(Gn(f.body))){let g=this.#t(l);g!=null&&(yield g)}}catch(c){yt.error("getPeers errored:",c)}finally{o.clear(),s.resolve(),yt("getPeers finished: %c",t)}}async getIPNS(t,r={}){yt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=Xr([this.shutDownController.signal,n,r.signal]);let i=re(),s=re();this.httpQueue.add(async()=>(i.resolve(),s.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let a={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#r(c,a);if(yt("getIPNS GET %s %d",c,f.status),f.status===404)throw new At("No matching records found");if(f.status===422)throw new Ir("Request does not conform to schema or semantic constraints");if(f.body==null)throw new Gt("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await ff(nn(t.multihash),l),ee(l)}catch(a){throw yt.error("getIPNS GET %s error:",c,a),a}finally{o.clear(),s.resolve(),yt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){yt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=Xr([this.shutDownController.signal,o,n.signal]);let s=re(),c=re();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let f=He(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#r(a,u);if(yt("putIPNS PUT %s %d",a,l.status),l.status!==200)throw new Gt("PUT ipns response had status other than 200")}catch(f){throw yt.error("putIPNS PUT %s error:",a,f.stack),f}finally{i.clear(),c.resolve(),yt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(zn)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:kc(t.ID),Addrs:n,Protocols:r}}catch(r){yt.error("could not conform record to peer schema",r)}}#n(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#r(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let a=await this.cache?.match(t);if(a!=null){if(parseInt(a.headers.get("x-cache-expires")??"0",10)>Date.now())return yt("returning cached response for %s",o),a;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let a=await i;return yt("deduplicating outgoing request for %s",o),a.clone()}let s=fetch(t,r).then(async a=>{if(this.cache!=null&&a.ok&&n==="GET"){let f=Date.now()+this.cacheTTL,u=new Headers(a.headers);u.set("x-cache-expires",f.toString());let l=new Response(a.clone().body,{status:a.status,statusText:a.statusText,headers:u});await this.cache.put(t,l)}return a}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function gf(e,t={}){return new bo(new URL(e),t)}function wo(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var xf=H("/ipns/");function bf(e){return Y(e.subarray(0,xf.byteLength),xf)}var Bs=class{client;constructor(t,r={}){this.client=gf(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*mo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!bf(t))return;let o=ge(t),i=j.createV1(114,o),s=ee(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!bf(t))throw new At("Not found");let n=ge(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return He(i)}catch(i){throw i.name==="BadResponseError"?new At("Not found"):i}}async findPeer(t,r){let n=await po(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new At("Not found")}async*getClosestPeers(t,r){}};function wf(e,t){let r=t??wo();return new Bs(new URL(e),r)}var Ef="[a-fA-F\\d:]",_e=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${Ef})|(?<=${Ef})(?=\\s|$))`:"",Zt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",at="[a-fA-F\\d]{1,4}",Eo=`
4
5
  (?:
5
- (?:${st}:){7}(?:${st}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
6
- (?:${st}:){6}(?:${Jt}|:${st}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
7
- (?:${st}:){5}(?::${Jt}|(?::${st}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
8
- (?:${st}:){4}(?:(?::${st}){0,1}:${Jt}|(?::${st}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
9
- (?:${st}:){3}(?:(?::${st}){0,2}:${Jt}|(?::${st}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
10
- (?:${st}:){2}(?:(?::${st}){0,3}:${Jt}|(?::${st}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
11
- (?:${st}:){1}(?:(?::${st}){0,4}:${Jt}|(?::${st}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
12
- (?::(?:(?::${st}){0,5}:${Jt}|(?::${st}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
6
+ (?:${at}:){7}(?:${at}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
7
+ (?:${at}:){6}(?:${Zt}|:${at}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
8
+ (?:${at}:){5}(?::${Zt}|(?::${at}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
9
+ (?:${at}:){4}(?:(?::${at}){0,1}:${Zt}|(?::${at}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
10
+ (?:${at}:){3}(?:(?::${at}){0,2}:${Zt}|(?::${at}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
11
+ (?:${at}:){2}(?:(?::${at}){0,3}:${Zt}|(?::${at}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
12
+ (?:${at}:){1}(?:(?::${at}){0,4}:${Zt}|(?::${at}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
13
+ (?::(?:(?::${at}){0,5}:${Zt}|(?::${at}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
13
14
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
14
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),z0=new RegExp(`(?:^${Jt}$)|(?:^${qo}$)`),j0=new RegExp(`^${Jt}$`),G0=new RegExp(`^${qo}$`),ra=e=>e&&e.exact?z0:new RegExp(`(?:${ke(e)}${Jt}${ke(e)})|(?:${ke(e)}${qo}${ke(e)})`,"g");ra.v4=e=>e&&e.exact?j0:new RegExp(`${ke(e)}${Jt}${ke(e)}`,"g");ra.v6=e=>e&&e.exact?G0:new RegExp(`${ke(e)}${qo}${ke(e)}`,"g");var na=ra;function oa(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Xf(){return!1}var{toString:Z0}=Object.prototype;function ia(e){return Z0.call(e)==="[object RegExp]"}var Jf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function sa(e,t={}){if(!ia(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Jf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Jf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function aa(e,t,{timeout:r}={}){try{return oa(()=>sa(e).test(t),{timeout:r})()}catch(n){if(Xf(n))return!1;throw n}}var Y0=15,W0=45,Qf={timeout:400};function ca(e){return e.length>W0?!1:aa(na.v6({exact:!0}),e,Qf)}function tl(e){return e.length>Y0?!1:aa(na.v4({exact:!0}),e,Qf)}var el={http:"80",https:"443",ws:"80",wss:"443"},X0=["http","https","ws","wss"];function rl(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=J0(e),a=[Q0(o,r),tm(i,n),em(n)];s!=null&&a.push(rm(s));let c="/"+a.filter(u=>!!u).reduce((u,f)=>u.concat(f),[]).join("/");return Qe(c)}function J0(e){let[t]=e.split(":");X0.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=nm(t);c!=null&&(o=c),c==null&&r==="http:"&&(o="80")}let a;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),a=i),s!=null&&s!==""&&(a=a??"",a+=s),{scheme:t,hostname:n,port:o,path:a}}function Q0(e,t){if(!(e==null||e==="")){if(tl(e))return["ip4",e];if(ca(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(ca(r))return["ip6",r]}return[t,e]}}function tm(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function em(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function rm(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function nm(e){if(!(e==null||e===""||el[e]==null))return el[e]}var om=["https://trustless-gateway.link","https://4everland.io"],im=2336;function sm(e){return e=e.toString(),{id:As(z.createV1(im,Bt.digest($(e)))),multiaddrs:[rl(e)]}}var ua=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??om).map(r=>sm(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function nl(e={}){return new ua(e)}var fa=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function ol(e){return new fa(e)}return fl(am);})();
15
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),f0=new RegExp(`(?:^${Zt}$)|(?:^${Eo}$)`),l0=new RegExp(`^${Zt}$`),d0=new RegExp(`^${Eo}$`),_s=e=>e&&e.exact?f0:new RegExp(`(?:${_e(e)}${Zt}${_e(e)})|(?:${_e(e)}${Eo}${_e(e)})`,"g");_s.v4=e=>e&&e.exact?l0:new RegExp(`${_e(e)}${Zt}${_e(e)}`,"g");_s.v6=e=>e&&e.exact?d0:new RegExp(`${_e(e)}${Eo}${_e(e)}`,"g");var Ds=_s;function Rs(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Sf(){return!1}var{toString:h0}=Object.prototype;function Ps(e){return h0.call(e)==="[object RegExp]"}var vf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Ns(e,t={}){if(!Ps(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(vf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?vf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Us(e,t,{timeout:r}={}){try{return Rs(()=>Ns(e).test(t),{timeout:r})()}catch(n){if(Sf(n))return!1;throw n}}var p0=15,m0=45,Af={timeout:400};function Ls(e){return e.length>m0?!1:Us(Ds.v6({exact:!0}),e,Af)}function If(e){return e.length>p0?!1:Us(Ds.v4({exact:!0}),e,Af)}var Tf={http:"80",https:"443",ws:"80",wss:"443"},y0=["http","https","ws","wss"];function Cf(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=g0(e),c=[x0(o,r),b0(i,n),w0(n)];s!=null&&c.push(E0(s));let a="/"+c.filter(f=>!!f).reduce((f,u)=>f.concat(u),[]).join("/");return zn(a)}function g0(e){let[t]=e.split(":");y0.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let a=S0(t);a!=null&&(o=a),a==null&&r==="http:"&&(o="80")}let c;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),c=i),s!=null&&s!==""&&(c=c??"",c+=s),{scheme:t,hostname:n,port:o,path:c}}function x0(e,t){if(!(e==null||e==="")){if(If(e))return["ip4",e];if(Ls(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Ls(r))return["ip6",r]}return[t,e]}}function b0(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function w0(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function E0(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function S0(e){if(!(e==null||e===""||Tf[e]==null))return Tf[e]}var v0=["https://trustless-gateway.link","https://4everland.io"],A0=2336;function I0(e){return e=e.toString(),{id:ss(j.createV1(A0,Bt.digest(H(e)))),multiaddrs:[Cf(e)]}}var Os=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??v0).map(r=>I0(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Bf(e={}){return new Os(e)}var ks=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function _f(e){return new ks(e)}return Lf(T0);})();
15
16
  /*! Bundled license information:
16
17
 
17
- @noble/hashes/esm/utils.js:
18
+ @noble/hashes/utils.js:
18
19
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
19
20
 
20
- @noble/curves/esm/utils.js:
21
- @noble/curves/esm/abstract/modular.js:
22
- @noble/curves/esm/abstract/curve.js:
23
- @noble/curves/esm/abstract/edwards.js:
24
- @noble/curves/esm/ed25519.js:
25
- @noble/curves/esm/abstract/weierstrass.js:
26
- @noble/curves/esm/_shortw_utils.js:
27
- @noble/curves/esm/secp256k1.js:
21
+ @noble/curves/utils.js:
22
+ @noble/curves/abstract/modular.js:
23
+ @noble/curves/abstract/curve.js:
24
+ @noble/curves/abstract/edwards.js:
25
+ @noble/curves/ed25519.js:
26
+ @noble/curves/abstract/weierstrass.js:
27
+ @noble/curves/secp256k1.js:
28
28
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
29
29
  */
30
30
  return HeliaRouters}));