@helia/delegated-routing-v1-http-api-client 5.0.1 → 5.1.0
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 +3 -3
- package/dist/index.min.js.map +3 -3
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +29 -15
- package/dist/src/client.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +32 -16
package/dist/index.min.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDelegatedRoutingV1HttpApiClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var ef=Object.create;var an=Object.defineProperty;var rf=Object.getOwnPropertyDescriptor;var nf=Object.getOwnPropertyNames;var of=Object.getPrototypeOf,sf=Object.prototype.hasOwnProperty;var Ss=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),St=(e,t)=>{for(var r in t)an(e,r,{get:t[r],enumerable:!0})},vs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nf(t))!sf.call(e,o)&&o!==r&&an(e,o,{get:()=>t[o],enumerable:!(n=rf(t,o))||n.enumerable});return e};var po=(e,t,r)=>(r=e!=null?ef(of(e)):{},vs(t||!e||!e.__esModule?an(r,"default",{value:e,enumerable:!0}):r,e)),af=e=>vs(an({},"__esModule",{value:!0}),e);var as=Ss((_b,ss)=>{var Bb=(function(){typeof ss<"u"&&(ss.exports=I);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",
|
|
3
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return I;function I(h,p,_){var D=this;if(!(D instanceof I))return new I(h,p,_);D.time=+h||0,D.nano=+p||0,D.year=+_||0,C(D)}function C(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=l(m/o))&&(A+=p*t,m-=p*o),(D=b(m)).setUTCFullYear(d+D.getUTCFullYear()),D=(m=+D)+(p=l((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 b(h){var p=new Date(0);return p.setTime(h),p}function T(A,D){A=+A||0;var _=l((D=(D|0)*s)/n)+l(A/n),D=D%n+A%n,A=l(D/n);return A&&(_+=A,D-=A*n),new I(1e3*D,0,_*t)}function S(h,p,_,D,A,m){return function(d,E){var U=C(this);d=d||new Array(8),k(d,E|=0);var N=Math.floor(U.time/1e3),U=U.year*(r*e/t),R=l(U/s)+l(N/s),U=U%s+N%s,N=Math.floor(U/s);return N&&(R+=N,U-=N*s),y(d,E+A,R),y(d,E+m,U),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 T(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 M(h){return(9<h?"":"0")+(0|h)}function V(h,p){return(a+(0|h)).substr(-p)}})()});var ju=Ss((b1,ms)=>{"use strict";var Rp=Object.prototype.hasOwnProperty,Et="~";function rn(){}Object.create&&(rn.prototype=Object.create(null),new rn().__proto__||(Et=!1));function Up(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Gu(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Up(r,n||e,o),s=Et?Et+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 co(e,t){--e._eventsCount===0?e._events=new rn:delete e._events[t]}function bt(){this._events=new rn,this._eventsCount=0}bt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Rp.call(r,n)&&t.push(Et?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};bt.prototype.listeners=function(t){var r=Et?Et+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};bt.prototype.listenerCount=function(t){var r=Et?Et+t:t,n=this._events[r];return n?n.fn?1:n.length:0};bt.prototype.emit=function(t,r,n,o,i,s){var c=Et?Et+t:t;if(!this._events[c])return!1;var a=this._events[c],l=arguments.length,u,f;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),l){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(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];a.fn.apply(a.context,u)}else{var g=a.length,v;for(f=0;f<g;f++)switch(a[f].once&&this.removeListener(t,a[f].fn,void 0,!0),l){case 1:a[f].fn.call(a[f].context);break;case 2:a[f].fn.call(a[f].context,r);break;case 3:a[f].fn.call(a[f].context,r,n);break;case 4:a[f].fn.call(a[f].context,r,n,o);break;default:if(!u)for(v=1,u=new Array(l-1);v<l;v++)u[v-1]=arguments[v];a[f].fn.apply(a[f].context,u)}}return!0};bt.prototype.on=function(t,r,n){return Gu(this,t,r,n,!1)};bt.prototype.once=function(t,r,n){return Gu(this,t,r,n,!0)};bt.prototype.removeListener=function(t,r,n,o){var i=Et?Et+t:t;if(!this._events[i])return this;if(!r)return co(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&co(this,i);else{for(var c=0,a=[],l=s.length;c<l;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:co(this,i)}return this};bt.prototype.removeAllListeners=function(t){var r;return t?(r=Et?Et+t:t,this._events[r]&&co(this,r)):(this._events=new rn,this._eventsCount=0),this};bt.prototype.off=bt.prototype.removeListener;bt.prototype.addListener=bt.prototype.on;bt.prefixed=Et;bt.EventEmitter=bt;typeof ms<"u"&&(ms.exports=bt)});var Vp={};St(Vp,{createDelegatedRoutingV1HttpApiClient:()=>Kp});var As=Symbol.for("@libp2p/content-routing");var st=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Me=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var kt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var cn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Fe=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var qe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var mo=Symbol.for("@libp2p/peer-id");var Cs=Symbol.for("@libp2p/peer-routing");var wo={};St(wo,{base32:()=>Gt,base32hex:()=>gf,base32hexpad:()=>bf,base32hexpadupper:()=>wf,base32hexupper:()=>xf,base32pad:()=>mf,base32padupper:()=>yf,base32upper:()=>pf,base32z:()=>Ef});var zp=new Uint8Array(0);function Is(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 te(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 Ts(e){return new TextEncoder().encode(e)}function Bs(e){return new TextDecoder().decode(e)}function cf(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),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var I=0,C=0,b=0,T=w.length;b!==T&&w[b]===0;)b++,I++;for(var S=(T-b)*u+1>>>0,P=new Uint8Array(S);b!==T;){for(var k=w[b],M=0,V=S-1;(k!==0||M<C)&&V!==-1;V--,M++)k+=256*P[V]>>>0,P[V]=k%c>>>0,k=k/c>>>0;if(k!==0)throw new Error("Non-zero carry");C=M,b++}for(var h=S-C;h!==S&&P[h]===0;)h++;for(var p=a.repeat(I);h<S;++h)p+=e.charAt(P[h]);return p}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var I=0;if(w[I]!==" "){for(var C=0,b=0;w[I]===a;)C++,I++;for(var T=(w.length-I)*l+1>>>0,S=new Uint8Array(T);w[I];){var P=r[w.charCodeAt(I)];if(P===255)return;for(var k=0,M=T-1;(P!==0||k<b)&&M!==-1;M--,k++)P+=c*S[M]>>>0,S[M]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");b=k,I++}if(w[I]!==" "){for(var V=T-b;V!==T&&S[V]===0;)V++;for(var h=new Uint8Array(C+(T-V)),p=C;V!==T;)h[p++]=S[V++];return h}}}function v(w){var I=g(w);if(I)return I;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:g,decode:v}}var uf=cf,ff=uf,Ds=ff;var yo=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 Rs(this,t)}},xo=class{decoders;constructor(t){this.decoders=t}or(t){return Rs(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 Rs(e,t){return new xo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var bo=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 yo(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 $e({name:e,prefix:t,encode:r,decode:n}){return new bo(e,t,r,n)}function pe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ds(r,e);return $e({prefix:t,name:e,encode:n,decode:i=>te(o(i))})}function lf(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 l=0;l<o;++l){let u=t[e[l]];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 df(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 hf(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=hf(n);return $e({prefix:t,name:e,encode(i){return df(i,n,r)},decode(i){return lf(i,o,r,e)}})}var Gt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pf=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mf=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yf=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gf=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xf=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bf=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wf=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ef=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Eo={};St(Eo,{base58btc:()=>W,base58flickr:()=>Sf});var W=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sf=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ao={};St(Ao,{base64:()=>So,base64pad:()=>vf,base64url:()=>vo,base64urlpad:()=>Af});var So=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),vf=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vo=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Af=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Cf(e,t){if(typeof e=="string")return If(e);if(typeof e=="number")return _f(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var un=Cf;function If(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 Tf(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 Bf(e){let t=Math.abs(e);return t>=315576e5?Ie(e,t,315576e5,"year"):t>=26298e5?Ie(e,t,26298e5,"month"):t>=6048e5?Ie(e,t,6048e5,"week"):t>=864e5?Ie(e,t,864e5,"day"):t>=36e5?Ie(e,t,36e5,"hour"):t>=6e4?Ie(e,t,6e4,"minute"):t>=1e3?Ie(e,t,1e3,"second"):`${e} ms`}function _f(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?Bf(e):Tf(e)}function Ie(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Co(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=un,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let g=0;g<u.length;g++)f=(f<<5)-f+u.charCodeAt(g),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u,f){let g,v=null,w,I;function C(...b){if(!C.enabled)return;let T=C,S=Number(new Date),P=S-(g||S);T.diff=P,T.prev=g,T.curr=S,g=S,b[0]=r.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let k=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(V,h)=>{if(V==="%%")return"%";k++;let p=r.formatters[h];if(typeof p=="function"){let _=b[k];V=p.call(T,_),b.splice(k,1),k--}return V}),r.formatArgs.call(T,b),f?.onLog!=null&&f.onLog(...b),(T.log||r.log).apply(T,b)}return C.namespace=u,C.useColors=r.useColors(),C.color=r.selectColor(u),C.extend=n,C.destroy=r.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(w!==r.namespaces&&(w=r.namespaces,I=r.enabled(u)),I),set:b=>{v=b}}),typeof r.init=="function"&&r.init(C),C}function n(u,f){let g=r(this.namespace+(typeof f>"u"?":":f)+u);return g.log=this.log,g}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,g=(typeof u=="string"?u:"").split(/[\s,]+/),v=g.length;for(f=0;f<v;f++)g[f]&&(u=g[f].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(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,g;for(f=0,g=r.skips.length;f<g;f++)if(r.skips[f].test(u))return!1;for(f=0,g=r.names.length;f<g;f++)if(r.names[f].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 l(){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 fn=Of(),Df=["#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 Rf(){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 Uf(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+un(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var Lf=console.debug??console.log??(()=>{});function Pf(e){try{e?fn?.setItem("debug",e):fn?.removeItem("debug")}catch{}}function Nf(){let e;try{e=fn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Of(){try{return localStorage}catch{}}function kf(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Us=Co({formatArgs:Uf,save:Pf,load:Nf,useColors:Rf,setupFormatters:kf,colors:Df,storage:fn,log:Lf});var vt=Us;vt.formatters.b=e=>e==null?"undefined":W.baseEncode(e);vt.formatters.t=e=>e==null?"undefined":Gt.baseEncode(e);vt.formatters.m=e=>e==null?"undefined":So.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();function Io(e){let t=Ls(e.message),r=Ls(e.stack);return t!=null&&r!=null?r.includes(t)?r:`${t}
|
|
2
|
+
"use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var ef=Object.create;var an=Object.defineProperty;var rf=Object.getOwnPropertyDescriptor;var nf=Object.getOwnPropertyNames;var of=Object.getPrototypeOf,sf=Object.prototype.hasOwnProperty;var Ss=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),St=(e,t)=>{for(var r in t)an(e,r,{get:t[r],enumerable:!0})},vs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nf(t))!sf.call(e,o)&&o!==r&&an(e,o,{get:()=>t[o],enumerable:!(n=rf(t,o))||n.enumerable});return e};var po=(e,t,r)=>(r=e!=null?ef(of(e)):{},vs(t||!e||!e.__esModule?an(r,"default",{value:e,enumerable:!0}):r,e)),af=e=>vs(an({},"__esModule",{value:!0}),e);var as=Ss((_b,ss)=>{var Bb=(function(){typeof ss<"u"&&(ss.exports=I);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=I.prototype,l=(I.fromDate=function(h){return new I(+h)},I.fromInt64BE=P(0,1,2,3,0,4),I.fromInt64LE=P(3,2,1,0,4,0),I.fromString=function(D){var p,_=new I,D=(D+="").replace(/^\s*[+\-]?\d+/,function(m){var m=+m,g=1970+(m-1970)%400;return _.year=m-g,g}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(A,m,g){return m<0&&(g*=-1),p=6e4*(60*+m+ +g),""}).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 C(_)},I.fromTimeT=function(h){return T(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=C(this);return(h.time%1e3*c+ +h.nano+1e9)%1e9},u.getTimeT=function(){var p=C(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(C(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 M(_.getUTCHours())},L:function(){return V(_.getUTCMilliseconds(),3)},M:function(){return M(_.getUTCMinutes())},N:function(){return V(p.getNano(),9)},S:function(){return M(_.getUTCSeconds())},Y:function(){var A=p.getYear();return 999999<A?"+"+A:9999<A?"+"+V(A,6):0<=A?V(A,4):-999999<=A?"-"+V(-A,6):A},a:function(){return v[_.getUTCDay()]},b:function(){return y[_.getUTCMonth()]},d:function(){return M(_.getUTCDate())},e:function(){return(function(A){return(9<A?"":" ")+(0|A)})(_.getUTCDate())},m:function(){return M(_.getUTCMonth()+1)}};return(function A(m){return m.replace(/%./g,function(g){var E=g[1],d=x[E],E=D[E];return d?A(d):E?E():g})})(h||l)},u.writeInt64BE=S(0,1,2,3,0,4),u.writeInt64LE=S(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],x={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return I;function I(h,p,_){var D=this;if(!(D instanceof I))return new I(h,p,_);D.time=+h||0,D.nano=+p||0,D.year=+_||0,C(D)}function C(h){var p,_,D,A=h.year,m=h.time,g=h.nano,d=((g<0||c<=g)&&(g-=(_=Math.floor(g/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=g),h}function w(h){var p=new Date(0);return p.setTime(h),p}function T(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 I(1e3*D,0,_*t)}function S(h,p,_,D,A,m){return function(d,E){var R=C(this);d=d||new Array(8),k(d,E|=0);var N=Math.floor(R.time/1e3),R=R.year*(r*e/t),U=f(R/s)+f(N/s),R=R%s+N%s,N=Math.floor(R/s);return N&&(U+=N,R-=N*s),g(d,E+A,U),g(d,E+m,R),d};function g(d,E,U){d[E+h]=U>>24&255,d[E+p]=U>>16&255,d[E+_]=U>>8&255,d[E+D]=255&U}}function P(h,p,_,D,A,m){return function(d,E){k(d,E|=0);var U=g(d,E+A);return T(g(d,E+m),U)};function g(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 M(h){return(9<h?"":"0")+(0|h)}function V(h,p){return(a+(0|h)).substr(-p)}})()});var ju=Ss((b1,ms)=>{"use strict";var Up=Object.prototype.hasOwnProperty,Et="~";function rn(){}Object.create&&(rn.prototype=Object.create(null),new rn().__proto__||(Et=!1));function Rp(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Gu(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Rp(r,n||e,o),s=Et?Et+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 co(e,t){--e._eventsCount===0?e._events=new rn:delete e._events[t]}function bt(){this._events=new rn,this._eventsCount=0}bt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Up.call(r,n)&&t.push(Et?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};bt.prototype.listeners=function(t){var r=Et?Et+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};bt.prototype.listenerCount=function(t){var r=Et?Et+t:t,n=this._events[r];return n?n.fn?1:n.length:0};bt.prototype.emit=function(t,r,n,o,i,s){var c=Et?Et+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 y=a.length,v;for(l=0;l<y;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(v=1,u=new Array(f-1);v<f;v++)u[v-1]=arguments[v];a[l].fn.apply(a[l].context,u)}}return!0};bt.prototype.on=function(t,r,n){return Gu(this,t,r,n,!1)};bt.prototype.once=function(t,r,n){return Gu(this,t,r,n,!0)};bt.prototype.removeListener=function(t,r,n,o){var i=Et?Et+t:t;if(!this._events[i])return this;if(!r)return co(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&co(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:co(this,i)}return this};bt.prototype.removeAllListeners=function(t){var r;return t?(r=Et?Et+t:t,this._events[r]&&co(this,r)):(this._events=new rn,this._eventsCount=0),this};bt.prototype.off=bt.prototype.removeListener;bt.prototype.addListener=bt.prototype.on;bt.prefixed=Et;bt.EventEmitter=bt;typeof ms<"u"&&(ms.exports=bt)});var Vp={};St(Vp,{createDelegatedRoutingV1HttpApiClient:()=>Kp});var As=Symbol.for("@libp2p/content-routing");var st=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Me=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Zt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var cn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Fe=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var qe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var mo=Symbol.for("@libp2p/peer-id");var Cs=Symbol.for("@libp2p/peer-routing");var wo={};St(wo,{base32:()=>Gt,base32hex:()=>gf,base32hexpad:()=>bf,base32hexpadupper:()=>wf,base32hexupper:()=>xf,base32pad:()=>mf,base32padupper:()=>yf,base32upper:()=>pf,base32z:()=>Ef});var zp=new Uint8Array(0);function Is(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 te(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 Ts(e){return new TextEncoder().encode(e)}function Bs(e){return new TextDecoder().decode(e)}function cf(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(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var I=0,C=0,w=0,T=x.length;w!==T&&x[w]===0;)w++,I++;for(var S=(T-w)*u+1>>>0,P=new Uint8Array(S);w!==T;){for(var k=x[w],M=0,V=S-1;(k!==0||M<C)&&V!==-1;V--,M++)k+=256*P[V]>>>0,P[V]=k%c>>>0,k=k/c>>>0;if(k!==0)throw new Error("Non-zero carry");C=M,w++}for(var h=S-C;h!==S&&P[h]===0;)h++;for(var p=a.repeat(I);h<S;++h)p+=e.charAt(P[h]);return p}function y(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var I=0;if(x[I]!==" "){for(var C=0,w=0;x[I]===a;)C++,I++;for(var T=(x.length-I)*f+1>>>0,S=new Uint8Array(T);x[I];){var P=r[x.charCodeAt(I)];if(P===255)return;for(var k=0,M=T-1;(P!==0||k<w)&&M!==-1;M--,k++)P+=c*S[M]>>>0,S[M]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");w=k,I++}if(x[I]!==" "){for(var V=T-w;V!==T&&S[V]===0;)V++;for(var h=new Uint8Array(C+(T-V)),p=C;V!==T;)h[p++]=S[V++];return h}}}function v(x){var I=y(x);if(I)return I;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:y,decode:v}}var uf=cf,ff=uf,Ds=ff;var yo=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 Us(this,t)}},xo=class{decoders;constructor(t){this.decoders=t}or(t){return Us(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 Us(e,t){return new xo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var bo=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 yo(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 $e({name:e,prefix:t,encode:r,decode:n}){return new bo(e,t,r,n)}function pe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ds(r,e);return $e({prefix:t,name:e,encode:n,decode:i=>te(o(i))})}function lf(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 df(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 hf(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=hf(n);return $e({prefix:t,name:e,encode(i){return df(i,n,r)},decode(i){return lf(i,o,r,e)}})}var Gt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pf=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mf=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yf=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gf=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xf=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bf=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wf=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ef=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Eo={};St(Eo,{base58btc:()=>W,base58flickr:()=>Sf});var W=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sf=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ao={};St(Ao,{base64:()=>So,base64pad:()=>vf,base64url:()=>vo,base64urlpad:()=>Af});var So=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),vf=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vo=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Af=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Cf(e,t){if(typeof e=="string")return If(e);if(typeof e=="number")return _f(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var un=Cf;function If(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 Tf(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 Bf(e){let t=Math.abs(e);return t>=315576e5?Ie(e,t,315576e5,"year"):t>=26298e5?Ie(e,t,26298e5,"month"):t>=6048e5?Ie(e,t,6048e5,"week"):t>=864e5?Ie(e,t,864e5,"day"):t>=36e5?Ie(e,t,36e5,"hour"):t>=6e4?Ie(e,t,6e4,"minute"):t>=1e3?Ie(e,t,1e3,"second"):`${e} ms`}function _f(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?Bf(e):Tf(e)}function Ie(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Co(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=un,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 y=0;y<u.length;y++)l=(l<<5)-l+u.charCodeAt(y),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(u,l){let y,v=null,x,I;function C(...w){if(!C.enabled)return;let T=C,S=Number(new Date),P=S-(y||S);T.diff=P,T.prev=y,T.curr=S,y=S,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let k=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(V,h)=>{if(V==="%%")return"%";k++;let p=r.formatters[h];if(typeof p=="function"){let _=w[k];V=p.call(T,_),w.splice(k,1),k--}return V}),r.formatArgs.call(T,w),l?.onLog!=null&&l.onLog(...w),(T.log||r.log).apply(T,w)}return C.namespace=u,C.useColors=r.useColors(),C.color=r.selectColor(u),C.extend=n,C.destroy=r.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>v!==null?v:(x!==r.namespaces&&(x=r.namespaces,I=r.enabled(u)),I),set:w=>{v=w}}),typeof r.init=="function"&&r.init(C),C}function n(u,l){let y=r(this.namespace+(typeof l>"u"?":":l)+u);return y.log=this.log,y}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,y=(typeof u=="string"?u:"").split(/[\s,]+/),v=y.length;for(l=0;l<v;l++)y[l]&&(u=y[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,y;for(l=0,y=r.skips.length;l<y;l++)if(r.skips[l].test(u))return!1;for(l=0,y=r.names.length;l<y;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 fn=Of(),Df=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Uf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Rf(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+un(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var Lf=console.debug??console.log??(()=>{});function Pf(e){try{e?fn?.setItem("debug",e):fn?.removeItem("debug")}catch{}}function Nf(){let e;try{e=fn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Of(){try{return localStorage}catch{}}function kf(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Rs=Co({formatArgs:Rf,save:Pf,load:Nf,useColors:Uf,setupFormatters:kf,colors:Df,storage:fn,log:Lf});var vt=Rs;vt.formatters.b=e=>e==null?"undefined":W.baseEncode(e);vt.formatters.t=e=>e==null?"undefined":Gt.baseEncode(e);vt.formatters.m=e=>e==null?"undefined":So.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();function Io(e){let t=Ls(e.message),r=Ls(e.stack);return t!=null&&r!=null?r.includes(t)?r:`${t}
|
|
4
4
|
${r}`:r??t??e.toString()}function Kf(e){return e?.name==="AggregateError"}vt.formatters.e=e=>{if(e==null)return"undefined";if(Kf(e)){let t=" ",r=Io(e);return e.errors.length>0?r+=`
|
|
5
5
|
${t}${e.errors.map(n=>` ${Io(n).split(`
|
|
6
6
|
`).join(`
|
|
7
7
|
${t}`)}`).join(`
|
|
8
8
|
${t}`)}`:r+=`
|
|
9
|
-
${t}[Error list was empty]`,r.trim()}return Io(e)};function Vf(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 ee(e,t){let r=Vf(`${e}:trace`);return vt.enabled(`${e}:trace`)&&vt.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=vt(`${e}:trace`,t)),Object.assign(vt(e,t),{error:vt(`${e}:error`,t),trace:r,newScope:n=>ee(`${e}:${n}`,t)})}function Ls(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var To={};St(To,{base36:()=>He,base36upper:()=>Mf});var He=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mf=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ff=Os,Ps=128,qf=127,$f=~qf,Hf=Math.pow(2,31);function Os(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Hf;)t[r++]=e&255|Ps,e/=128;for(;e&$f;)t[r++]=e&255|Ps,e>>>=7;return t[r]=e|0,Os.bytes=r-n+1,t}var zf=Bo,Zf=128,Ns=127;function Bo(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Bo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Ns)<<o:(s&Ns)*Math.pow(2,o),o+=7}while(s>=Zf);return Bo.bytes=i-n,r}var Gf=Math.pow(2,7),jf=Math.pow(2,14),Yf=Math.pow(2,21),Wf=Math.pow(2,28),Xf=Math.pow(2,35),Jf=Math.pow(2,42),Qf=Math.pow(2,49),tl=Math.pow(2,56),el=Math.pow(2,63),rl=function(e){return e<Gf?1:e<jf?2:e<Yf?3:e<Wf?4:e<Xf?5:e<Jf?6:e<Qf?7:e<tl?8:e<el?9:10},nl={encode:Ff,decode:zf,encodingLength:rl},ol=nl,Sr=ol;function vr(e,t=0){return[Sr.decode(e,t),Sr.decode.bytes]}function ze(e,t,r=0){return Sr.encode(e,t,r),t}function Ze(e){return Sr.encodingLength(e)}function jt(e,t){let r=t.byteLength,n=Ze(e),o=n+Ze(r),i=new Uint8Array(o+r);return ze(e,i,0),ze(r,i,n),i.set(t,o),new Ge(e,r,t,i)}function Te(e){let t=te(e),[r,n]=vr(t),[o,i]=vr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ge(r,o,s,t)}function ks(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Is(e.bytes,r.bytes)}}var Ge=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Ks(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return sl(r,_o(e),t??W.encoder);default:return al(r,_o(e),t??Gt.encoder)}}var Vs=new WeakMap;function _o(e){let t=Vs.get(e);if(t==null){let r=new Map;return Vs.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!==Ar)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==cl)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=jt(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&&ks(t.multihash,n.multihash)}toString(t){return Ks(this,t)}toJSON(){return{"/":Ks(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??Ms(n,o,i.bytes))}else if(r[ul]===!0){let{version:n,multihash:o,code:i}=r,s=Te(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!==Ar)throw new Error(`Version 0 CID must use dag-pb (code: ${Ar}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ms(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Ar,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=te(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 Ge(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[f,g]=vr(t.subarray(r));return r+=g,f},o=n(),i=Ar;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(),l=r+a,u=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,r){let[n,o]=il(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 _o(i).set(n,t),i}};function il(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 Gt.prefix:{let r=t??Gt;return[Gt.prefix,r.decode(e)]}case He.prefix:{let r=t??He;return[He.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 sl(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 al(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 Ar=112,cl=18;function Ms(e,t,r){let n=Ze(e),o=n+Ze(t),i=new Uint8Array(o+r.byteLength);return ze(e,i,0),ze(t,i,n),i.set(r,o),i}var ul=Symbol.for("@ipld/js-cid/CID");var Do={};St(Do,{identity:()=>Kt});var Fs=0,fl="identity",qs=te;function ll(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 jt(Fs,qs(e))}var Kt={code:Fs,name:fl,encode:qs,digest:ll};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 re(e=0){return new Uint8Array(e)}function It(e=0){return new Uint8Array(e)}function Lt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=It(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Hs=Symbol.for("@achingbrain/uint8arraylist");function $s(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 je(e){return!!e?.[Hs]}var Tt=class e{bufs;length;[Hs]=!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(je(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(je(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=$s(this.bufs,t);return r.buf[r.index]}set(t,r){let n=$s(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(je(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 Lt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Lt(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 l=t>=c&&t<a,u=r>c&&r<=a;if(l&&u){if(t===c&&r===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(r-t)));break}if(l){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(!je(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 f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let c=s,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=a;f+=u){u=0;for(let g=l;g>=0;g--){let v=this.get(f+g);if(n[g]!==v){u=Math.max(1,g-c[v]);break}}if(u===0)return f}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=It(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=re(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=re(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=re(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=It(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=re(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=re(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=re(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=re(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=re(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 Ro={};St(Ro,{base10:()=>dl});var dl=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var Uo={};St(Uo,{base16:()=>hl,base16upper:()=>pl});var hl=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pl=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Lo={};St(Lo,{base2:()=>ml});var ml=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Po={};St(Po,{base256emoji:()=>wl});var zs=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}"),yl=zs.reduce((e,t,r)=>(e[r]=t,e),[]),gl=zs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function xl(e){return e.reduce((t,r)=>(t+=yl[r],t),"")}function bl(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=gl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var wl=$e({prefix:"\u{1F680}",name:"base256emoji",encode:xl,decode:bl});var No={};St(No,{base8:()=>El});var El=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Oo={};St(Oo,{identity:()=>Sl});var Sl=$e({prefix:"\0",name:"identity",encode:e=>Bs(e),decode:e=>Ts(e)});var F0=new TextEncoder,q0=new TextDecoder;var Vo={};St(Vo,{sha256:()=>Cr,sha512:()=>Il});var Cl=20;function Ko({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new ko(e,t,r,n,o)}var ko=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Cl,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?Zs(n,this.code,r?.truncate):n.then(o=>Zs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Zs(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 jt(t,e)}function js(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Cr=Ko({name:"sha2-256",code:18,encode:js("SHA-256")}),Il=Ko({name:"sha2-512",code:19,encode:js("SHA-512")});var Ir={...Oo,...Lo,...No,...Ro,...Uo,...wo,...To,...Eo,...Ao,...Po},tm={...Vo,...Do};function Ws(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ys=Ws("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Mo=Ws("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=It(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Tl={utf8:Ys,"utf-8":Ys,hex:Ir.base16,latin1:Mo,ascii:Mo,binary:Mo,...Ir},dn=Tl;function H(e,t="utf8"){let r=dn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=dn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Bl=parseInt("11111",2),Fo=parseInt("10000000",2),_l=parseInt("01111111",2),Xs={0:Tr,1:Tr,2:Dl,3:Ll,4:Pl,5:Ul,6:Rl,16:Tr,22:Tr,48:Tr};function ne(e,t={offset:0}){let r=e[t.offset]&Bl;if(t.offset++,Xs[r]!=null)return Xs[r](e,t);throw new Error("No decoder for tag "+r)}function Br(e,t){let r=0;if((e[t.offset]&Fo)===Fo){let n=e[t.offset]&_l,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 Tr(e,t){Br(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=ne(e,t);if(n===null)break;r.push(n)}return r}function Dl(e,t){let r=Br(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 Rl(e,t){let r=Br(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 l=e[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function Ul(e,t){return t.offset++,null}function Ll(e,t){let r=Br(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 Pl(e,t){let r=Br(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Nl(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Tt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function qo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Nl(e.byteLength);return new Tt(Uint8Array.from([t.byteLength|Fo]),t)}function At(e){let t=new Tt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Tt(Uint8Array.from([2]),qo(t),t)}function hn(e){let t=Uint8Array.from([0]),r=new Tt(t,e);return new Tt(Uint8Array.from([3]),qo(r),r)}function me(e,t=48){let r=new Tt;for(let n of e)r.append(n);return new Tt(Uint8Array.from([t]),qo(r),r)}async function Js(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 Ol=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),kl=Uint8Array.from([6,5,43,129,4,0,34]),Kl=Uint8Array.from([6,5,43,129,4,0,35]),Vl={ext:!0,kty:"EC",crv:"P-256"},Ml={ext:!0,kty:"EC",crv:"P-384"},Fl={ext:!0,kty:"EC",crv:"P-521"},$o=32,Ho=48,zo=66;function Zo(e){let t=ne(e);return Qs(t)}function Qs(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===$o*2+1)return n=z(t.subarray(r,r+$o),"base64url"),o=z(t.subarray(r+$o),"base64url"),new Ye({...Vl,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ho*2+1)return n=z(t.subarray(r,r+Ho),"base64url"),o=z(t.subarray(r+Ho),"base64url"),new Ye({...Ml,key_ops:["verify"],x:n,y:o});if(t.byteLength===zo*2+1)return n=z(t.subarray(r,r+zo),"base64url"),o=z(t.subarray(r+zo),"base64url"),new Ye({...Fl,key_ops:["verify"],x:n,y:o});throw new st(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ta(e){return me([At(Uint8Array.from([1])),me([ql(e.crv)],160),me([hn(new Tt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function ql(e){if(e==="P-256")return Ol;if(e==="P-384")return kl;if(e==="P-521")return Kl;throw new st(`Invalid curve ${e}`)}var Ye=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ta(this.jwk)),this._raw}toMultihash(){return Kt.digest(We(this))}toCID(){return j.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 Js(this.jwk,r,t,n)}};function _e(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function $(e,t,r=""){let n=_e(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 pn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Yt(e.outputLen),Yt(e.blockLen)}function Xe(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 ra(e,t){$(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 ie(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vt(e,t){return e<<32-t|e>>>t}var na=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",$l=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function se(e){if($(e),na)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=$l[e[r]];return t}var oe={_0:48,_9:57,A:65,F:70,a:97,f:102};function ea(e){if(e>=oe._0&&e<=oe._9)return e-oe._0;if(e>=oe.A&&e<=oe.F)return e-(oe.A-10);if(e>=oe.a&&e<=oe.f)return e-(oe.a-10)}function ae(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(na)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=ea(e.charCodeAt(i)),c=ea(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];$(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 Go(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 Je(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 jo=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function oa(e,t,r){return e&t^~e&r}function ia(e,t,r){return e&t^e&r^t&r}var _r=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=mn(this.buffer)}update(t){Xe(this),$(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=mn(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){Xe(this),ra(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ie(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=mn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],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()}},ce=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 yn=BigInt(4294967295),sa=BigInt(32);function Hl(e,t=!1){return t?{h:Number(e&yn),l:Number(e>>sa&yn)}:{h:Number(e>>sa&yn)|0,l:Number(e&yn)|0}}function aa(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}=Hl(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var Yo=(e,t,r)=>e>>>r,Wo=(e,t,r)=>e<<32-r|t>>>r,De=(e,t,r)=>e>>>r|t<<32-r,Re=(e,t,r)=>e<<32-r|t>>>r,Dr=(e,t,r)=>e<<64-r|t>>>r-32,Rr=(e,t,r)=>e>>>r-32|t<<64-r;function Wt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ca=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),ua=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,fa=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),la=(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),ha=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Zl=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]),ye=new Uint32Array(64),Xo=class extends _r{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 f=0;f<16;f++,r+=4)ye[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let g=ye[f-15],v=ye[f-2],w=Vt(g,7)^Vt(g,18)^g>>>3,I=Vt(v,17)^Vt(v,19)^v>>>10;ye[f]=I+ye[f-7]+w+ye[f-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let g=Vt(c,6)^Vt(c,11)^Vt(c,25),v=u+g+oa(c,a,l)+Zl[f]+ye[f]|0,I=(Vt(n,2)^Vt(n,13)^Vt(n,22))+ia(n,o,i)|0;u=l,l=a,a=c,c=s+v|0,s=i,i=o,o=n,n=v+I|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,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){ie(ye)}destroy(){this.set(0,0,0,0,0,0,0,0),ie(this.buffer)}},Jo=class extends Xo{A=ce[0]|0;B=ce[1]|0;C=ce[2]|0;D=ce[3]|0;E=ce[4]|0;F=ce[5]|0;G=ce[6]|0;H=ce[7]|0;constructor(){super(32)}};var pa=aa(["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))),Gl=pa[0],jl=pa[1],ge=new Uint32Array(80),xe=new Uint32Array(80),Qo=class extends _r{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:l,El:u,Fh:f,Fl:g,Gh:v,Gl:w,Hh:I,Hl:C}=this;return[t,r,n,o,i,s,c,a,l,u,f,g,v,w,I,C]}set(t,r,n,o,i,s,c,a,l,u,f,g,v,w,I,C){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=l|0,this.El=u|0,this.Fh=f|0,this.Fl=g|0,this.Gh=v|0,this.Gl=w|0,this.Hh=I|0,this.Hl=C|0}process(t,r){for(let S=0;S<16;S++,r+=4)ge[S]=t.getUint32(r),xe[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let P=ge[S-15]|0,k=xe[S-15]|0,M=De(P,k,1)^De(P,k,8)^Yo(P,k,7),V=Re(P,k,1)^Re(P,k,8)^Wo(P,k,7),h=ge[S-2]|0,p=xe[S-2]|0,_=De(h,p,19)^Dr(h,p,61)^Yo(h,p,6),D=Re(h,p,19)^Rr(h,p,61)^Wo(h,p,6),A=fa(V,D,xe[S-7],xe[S-16]),m=la(A,M,_,ge[S-7],ge[S-16]);ge[S]=m|0,xe[S]=A|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:g,Fh:v,Fl:w,Gh:I,Gl:C,Hh:b,Hl:T}=this;for(let S=0;S<80;S++){let P=De(f,g,14)^De(f,g,18)^Dr(f,g,41),k=Re(f,g,14)^Re(f,g,18)^Rr(f,g,41),M=f&v^~f&I,V=g&w^~g&C,h=da(T,k,V,jl[S],xe[S]),p=ha(h,b,P,M,Gl[S],ge[S]),_=h|0,D=De(n,o,28)^Dr(n,o,34)^Dr(n,o,39),A=Re(n,o,28)^Rr(n,o,34)^Rr(n,o,39),m=n&i^n&c^i&c,y=o&s^o&a^s&a;b=I|0,T=C|0,I=v|0,C=w|0,v=f|0,w=g|0,{h:f,l:g}=Wt(l|0,u|0,p|0,_|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let d=ca(_,A,y);n=ua(d,p,D,m),o=d|0}({h:n,l:o}=Wt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Wt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=Wt(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=Wt(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:g}=Wt(this.Eh|0,this.El|0,f|0,g|0),{h:v,l:w}=Wt(this.Fh|0,this.Fl|0,v|0,w|0),{h:I,l:C}=Wt(this.Gh|0,this.Gl|0,I|0,C|0),{h:b,l:T}=Wt(this.Hh|0,this.Hl|0,b|0,T|0),this.set(n,o,i,s,c,a,l,u,f,g,v,w,I,C,b,T)}roundClean(){ie(ge,xe)}destroy(){ie(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ti=class extends Qo{Ah=dt[0]|0;Al=dt[1]|0;Bh=dt[2]|0;Bl=dt[3]|0;Ch=dt[4]|0;Cl=dt[5]|0;Dh=dt[6]|0;Dl=dt[7]|0;Eh=dt[8]|0;El=dt[9]|0;Fh=dt[10]|0;Fl=dt[11]|0;Gh=dt[12]|0;Gl=dt[13]|0;Hh=dt[14]|0;Hl=dt[15]|0;constructor(){super(64)}};var Qe=Go(()=>new Jo,jo(1));var ma=Go(()=>new ti,jo(3));var ri=BigInt(0),ei=BigInt(1);function ue(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function ya(e){if(typeof e=="bigint"){if(!gn(e))throw new Error("positive bigint expected, got "+e)}else Yt(e);return e}function Ur(e){let t=ya(e).toString(16);return t.length&1?"0"+t:t}function ga(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ri:BigInt("0x"+e)}function tr(e){return ga(se(e))}function Ue(e){return ga(se(bn($(e)).reverse()))}function xn(e,t){Yt(t),e=ya(e);let r=ae(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function ni(e,t){return xn(e,t).reverse()}function bn(e){return Uint8Array.from(e)}var gn=e=>typeof e=="bigint"&&ri<=e;function Yl(e,t,r){return gn(e)&&gn(t)&&gn(r)&&t<=e&&e<r}function Lr(e,t,r,n){if(!Yl(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function oi(e){let t;for(t=0;e>ri;e>>=ei,t+=1);return t}var Pr=e=>(ei<<BigInt(e))-ei;function xa(e,t,r){if(Yt(e,"hashLen"),Yt(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=C=>new Uint8Array(C),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(e),l=n(e),u=0,f=()=>{a.fill(1),l.fill(0),u=0},g=(...C)=>r(l,Ct(a,...C)),v=(C=o)=>{l=g(i,C),a=g(),C.length!==0&&(l=g(s,C),a=g())},w=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let C=0,b=[];for(;C<t;){a=g();let T=a.slice();b.push(T),C+=a.length}return Ct(...b)};return(C,b)=>{f(),v(C);let T;for(;!(T=b(w()));)v();return f(),T}}function be(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 l=typeof a;if(l!==s||a===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${l}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(t,!1),o(r,!0)}function er(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),at=BigInt(1),Le=BigInt(2),Ea=BigInt(3),Sa=BigInt(4),va=BigInt(5),Wl=BigInt(7),Aa=BigInt(8),Xl=BigInt(9),Ca=BigInt(16);function ot(e,t){let r=e%t;return r>=wt?r:t+r}function X(e,t,r){let n=e;for(;t-- >wt;)n*=n,n%=r;return n}function ba(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=ot(e,t),n=t,o=wt,i=at,s=at,c=wt;for(;r!==wt;){let l=n/r,u=n%r,f=o-s*l,g=i-c*l;n=r,r=u,o=s,i=c,s=f,c=g}if(n!==at)throw new Error("invert: does not exist");return ot(o,t)}function si(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Ia(e,t){let r=(e.ORDER+at)/Sa,n=e.pow(t,r);return si(e,n,t),n}function Jl(e,t){let r=(e.ORDER-va)/Aa,n=e.mul(t,Le),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Le),o),c=e.mul(i,e.sub(s,e.ONE));return si(e,c,t),c}function Ql(e){let t=rr(e),r=Ta(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Wl)/Ca;return(c,a)=>{let l=c.pow(a,s),u=c.mul(l,n),f=c.mul(l,o),g=c.mul(l,i),v=c.eql(c.sqr(u),a),w=c.eql(c.sqr(f),a);l=c.cmov(l,u,v),u=c.cmov(g,f,w);let I=c.eql(c.sqr(u),a),C=c.cmov(l,u,I);return si(c,C,a),C}}function Ta(e){if(e<Ea)throw new Error("sqrt is not defined for small field");let t=e-at,r=0;for(;t%Le===wt;)t/=Le,r++;let n=Le,o=rr(e);for(;wa(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ia;let i=o.pow(n,t),s=(t+at)/Le;return function(a,l){if(a.is0(l))return l;if(wa(a,l)!==1)throw new Error("Cannot find square root");let u=r,f=a.mul(a.ONE,i),g=a.pow(l,t),v=a.pow(l,s);for(;!a.eql(g,a.ONE);){if(a.is0(g))return a.ZERO;let w=1,I=a.sqr(g);for(;!a.eql(I,a.ONE);)if(w++,I=a.sqr(I),w===u)throw new Error("Cannot find square root");let C=at<<BigInt(u-w-1),b=a.pow(f,C);u=w,f=a.sqr(b),g=a.mul(g,f),v=a.mul(v,b)}return v}}function td(e){return e%Sa===Ea?Ia:e%Aa===va?Jl:e%Ca===Xl?Ql(e):Ta(e)}var Ba=(e,t)=>(ot(e,t)&at)===at,ed=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ai(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ed.reduce((n,o)=>(n[o]="function",n),t);return be(e,r),e}function rd(e,t,r){if(r<wt)throw new Error("invalid exponent, negatives unsupported");if(r===wt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>wt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function Nr(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 wa(e,t){let r=(e.ORDER-at)/Le,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 nd(e,t){t!==void 0&&Yt(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var ii=class{ORDER;BITS;BYTES;isLE;ZERO=wt;ONE=at;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=wt)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}=nd(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 wt<=t&&t<this.ORDER}is0(t){return t===wt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&at)===at}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 rd(this,t,r)}div(t,r){return ot(t*ba(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 ba(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=td(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?ni(t,this.BYTES):xn(t,this.BYTES)}fromBytes(t,r=!1){$(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 l=new Uint8Array(o);l.set(t,i?0:l.length-t.length),t=l}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=i?Ue(t):tr(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 Nr(this,t)}cmov(t,r,n){return n?r:t}};function rr(e,t={}){return new ii(e,t)}function _a(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 ci(e){let t=_a(e);return t+Math.ceil(t/2)}function ui(e,t,r=!1){$(e);let n=e.length,o=_a(t),i=ci(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ue(e):tr(e),c=ot(s,t-at)+at;return r?ni(c,o):xn(c,o)}var nr=BigInt(0),Pe=BigInt(1);function Or(e,t){let r=t.negate();return e?r:t}function Ne(e,t){let r=Nr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function La(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function fi(e,t){La(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Pr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Da(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+=Pe);let l=t*n,u=l+Math.abs(c)-1,f=c===0,g=c<0,v=t%2!==0;return{nextN:a,offset:u,isZero:f,isNeg:g,isNegF:v,offsetF:l}}var li=new WeakMap,Pa=new WeakMap;function di(e){return Pa.get(e)||1}function Ra(e){if(e!==nr)throw new Error("invalid wNAF")}var or=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>nr;)r&Pe&&(n=n.add(o)),o=o.double(),r>>=Pe;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=fi(r,this.bits),i=[],s=t,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let l=1;l<o;l++)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=fi(t,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:l,isZero:u,isNeg:f,isNegF:g,offsetF:v}=Da(n,c,s);n=a,u?i=i.add(Or(g,r[v])):o=o.add(Or(f,r[l]))}return Ra(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=fi(t,this.bits);for(let s=0;s<i.windows&&n!==nr;s++){let{nextN:c,offset:a,isZero:l,isNeg:u}=Da(n,s,i);if(n=c,!l){let f=r[a];o=o.add(u?f.negate():f)}}return Ra(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=di(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=di(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){La(r,this.bits),Pa.set(t,r),li.delete(t)}hasCache(t){return di(t)!==1}};function Na(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>nr||n>nr;)r&Pe&&(i=i.add(o)),n&Pe&&(s=s.add(o)),o=o.double(),r>>=Pe,n>>=Pe;return{p1:i,p2:s}}function Ua(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ai(t),t}else return rr(e,{isLE:r})}function wn(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 l=t[a];if(!(typeof l=="bigint"&&l>nr))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Ua(t.p,r.Fp,n),i=Ua(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 En(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var we=BigInt(0),ct=BigInt(1),hi=BigInt(2),od=BigInt(8);function id(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 Oa(e,t={}){let r=wn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;be(t,{},{uvRatio:"function"});let c=hi<<BigInt(o.BYTES*8)-ct,a=C=>n.create(C),l=t.uvRatio||((C,b)=>{try{return{isValid:!0,value:n.sqrt(n.div(C,b))}}catch{return{isValid:!1,value:we}}});if(!id(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(C,b,T=!1){let S=T?ct:we;return Lr("coordinate "+C,b,S,c),b}function f(C){if(!(C instanceof w))throw new Error("EdwardsPoint expected")}let g=er((C,b)=>{let{X:T,Y:S,Z:P}=C,k=C.is0();b==null&&(b=k?od:n.inv(P));let M=a(T*b),V=a(S*b),h=n.mul(P,b);if(k)return{x:we,y:ct};if(h!==ct)throw new Error("invZ was invalid");return{x:M,y:V}}),v=er(C=>{let{a:b,d:T}=i;if(C.is0())throw new Error("bad point: ZERO");let{X:S,Y:P,Z:k,T:M}=C,V=a(S*S),h=a(P*P),p=a(k*k),_=a(p*p),D=a(V*b),A=a(p*a(D+h)),m=a(_+a(T*a(V*h)));if(A!==m)throw new Error("bad point: equation left != right (1)");let y=a(S*P),d=a(k*M);if(y!==d)throw new Error("bad point: equation left != right (2)");return!0});class w{static BASE=new w(i.Gx,i.Gy,ct,a(i.Gx*i.Gy));static ZERO=new w(we,ct,ct,we);static Fp=n;static Fn=o;X;Y;Z;T;constructor(b,T,S,P){this.X=u("x",b),this.Y=u("y",T),this.Z=u("z",S,!0),this.T=u("t",P),Object.freeze(this)}static CURVE(){return i}static fromAffine(b){if(b instanceof w)throw new Error("extended point not allowed");let{x:T,y:S}=b||{};return u("x",T),u("y",S),new w(T,S,ct,a(T*S))}static fromBytes(b,T=!1){let S=n.BYTES,{a:P,d:k}=i;b=bn($(b,S,"point")),ue(T,"zip215");let M=bn(b),V=b[S-1];M[S-1]=V&-129;let h=Ue(M),p=T?c:n.ORDER;Lr("point.y",h,we,p);let _=a(h*h),D=a(_-ct),A=a(k*_-P),{isValid:m,value:y}=l(D,A);if(!m)throw new Error("bad point: invalid y coordinate");let d=(y&ct)===ct,E=(V&128)!==0;if(!T&&y===we&&E)throw new Error("bad point: x=0 and x_0=1");return E!==d&&(y=a(-y)),w.fromAffine({x:y,y:h})}static fromHex(b,T=!1){return w.fromBytes(ae(b),T)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(b=8,T=!0){return I.createCache(this,b),T||this.multiply(hi),this}assertValidity(){v(this)}equals(b){f(b);let{X:T,Y:S,Z:P}=this,{X:k,Y:M,Z:V}=b,h=a(T*V),p=a(k*P),_=a(S*V),D=a(M*P);return h===p&&_===D}is0(){return this.equals(w.ZERO)}negate(){return new w(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:b}=i,{X:T,Y:S,Z:P}=this,k=a(T*T),M=a(S*S),V=a(hi*a(P*P)),h=a(b*k),p=T+S,_=a(a(p*p)-k-M),D=h+M,A=D-V,m=h-M,y=a(_*A),d=a(D*m),E=a(_*m),R=a(A*D);return new w(y,d,R,E)}add(b){f(b);let{a:T,d:S}=i,{X:P,Y:k,Z:M,T:V}=this,{X:h,Y:p,Z:_,T:D}=b,A=a(P*h),m=a(k*p),y=a(V*S*D),d=a(M*_),E=a((P+k)*(h+p)-A-m),R=d-y,U=d+y,N=a(m-T*A),O=a(E*R),K=a(U*N),q=a(E*N),tt=a(R*U);return new w(O,K,tt,q)}subtract(b){return this.add(b.negate())}multiply(b){if(!o.isValidNot0(b))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:T,f:S}=I.cached(this,b,P=>Ne(w,P));return Ne(w,[T,S])[0]}multiplyUnsafe(b,T=w.ZERO){if(!o.isValid(b))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return b===we?w.ZERO:this.is0()||b===ct?this:I.unsafe(this,b,S=>Ne(w,S),T)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return I.unsafe(this,i.n).is0()}toAffine(b){return g(this,b)}clearCofactor(){return s===ct?this:this.multiplyUnsafe(s)}toBytes(){let{x:b,y:T}=this.toAffine(),S=n.toBytes(T);return S[S.length-1]|=b&ct?128:0,S}toHex(){return se(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let I=new or(w,o.BITS);return w.BASE.precompute(8),w}function ka(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');be(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||Je,a=r.adjustScalarBytes||(h=>h),l=r.domain||((h,p,_)=>{if(ue(_,"phflag"),p.length||_)throw new Error("Contexts/pre-hash are not supported");return h});function u(h){return s.create(Ue(h))}function f(h){let p=S.secretKey;$(h,S.secretKey,"secretKey");let _=$(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}=f(h),A=o.multiply(D),m=A.toBytes();return{head:p,prefix:_,scalar:D,point:A,pointBytes:m}}function v(h){return g(h).pointBytes}function w(h=Uint8Array.of(),...p){let _=Ct(...p);return u(t(l(_,$(h,void 0,"context"),!!n)))}function I(h,p,_={}){h=$(h,void 0,"message"),n&&(h=n(h));let{prefix:D,scalar:A,pointBytes:m}=g(p),y=w(_.context,D,h),d=o.multiply(y).toBytes(),E=w(_.context,d,m,h),R=s.create(y+E*A);if(!s.isValid(R))throw new Error("sign failed: invalid s");let U=Ct(d,s.toBytes(R));return $(U,S.signature,"result")}let C={zip215:!0};function b(h,p,_,D=C){let{context:A,zip215:m}=D,y=S.signature;h=$(h,y,"signature"),p=$(p,void 0,"message"),_=$(_,S.publicKey,"publicKey"),m!==void 0&&ue(m,"zip215"),n&&(p=n(p));let d=y/2,E=h.subarray(0,d),R=Ue(h.subarray(d,y)),U,N,O;try{U=e.fromBytes(_,m),N=e.fromBytes(E,m),O=o.multiplyUnsafe(R)}catch{return!1}if(!m&&U.isSmallOrder())return!1;let K=w(A,N.toBytes(),U.toBytes(),p);return N.add(U.multiplyUnsafe(K)).subtract(O).clearCofactor().is0()}let T=i.BYTES,S={secretKey:T,publicKey:T,signature:2*T,seed:T};function P(h=c(S.seed)){return $(h,S.seed,"seed")}function k(h){return _e(h)&&h.length===s.BYTES}function M(h,p){try{return!!e.fromBytes(h,p)}catch{return!1}}let V={getExtendedPublicKey:g,randomSecretKey:P,isValidSecretKey:k,isValidPublicKey:M,toMontgomery(h){let{y:p}=e.fromBytes(h),_=S.publicKey,D=_===32;if(!D&&_!==57)throw new Error("only defined for 25519 and 448");let A=D?i.div(ct+p,ct-p):i.div(p-ct,p+ct);return i.toBytes(A)},toMontgomerySecret(h){let p=S.secretKey;$(h,p);let _=t(h.subarray(0,p));return a(_).subarray(0,p)}};return Object.freeze({keygen:En(P,v),getPublicKey:v,sign:I,verify:b,utils:V,Point:e,lengths:S})}var sd=BigInt(1),Ka=BigInt(2);var ad=BigInt(5),cd=BigInt(8),pi=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ud={p:pi,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:cd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function fd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=pi,c=e*e%i*e%i,a=X(c,Ka,i)*c%i,l=X(a,sd,i)*e%i,u=X(l,ad,i)*l%i,f=X(u,t,i)*u%i,g=X(f,r,i)*f%i,v=X(g,n,i)*g%i,w=X(v,o,i)*v%i,I=X(w,o,i)*v%i,C=X(I,t,i)*u%i;return{pow_p_5_8:X(C,Ka,i)*e%i,b2:c}}function ld(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Va=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function dd(e,t){let r=pi,n=ot(t*t*t,r),o=ot(n*n*t,r),i=fd(e*o).pow_p_5_8,s=ot(e*n*i,r),c=ot(t*s*s,r),a=s,l=ot(s*Va,r),u=c===e,f=c===ot(-e,r),g=c===ot(-e*Va,r);return u&&(s=a),(f||g)&&(s=l),Ba(s,r)&&(s=ot(-s,r)),{isValid:u||f,value:s}}var hd=Oa(ud,{uvRatio:dd});function pd(e){return ka(hd,ma,Object.assign({adjustScalarBytes:ld},e))}var Ma=pd({});var kr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Sn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Fa={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Sn("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 Pt=Fa;var vn=32;var mi,md=(async()=>{try{return await Pt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function yd(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Pt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Pt.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 gd(e,t,r){return Ma.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function qa(e,t,r){return mi==null&&(mi=await md),mi?yd(e,t,r):gd(e,t,r)}function An(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Cn=class{type="Ed25519";raw;constructor(t){this.raw=yi(t,vn)}toMultihash(){return Kt.digest(We(this))}toCID(){return j.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=qa(this.raw,r,t);return An(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function gi(e){return e=yi(e,vn),new Cn(e)}function yi(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 bd=Math.pow(2,7),wd=Math.pow(2,14),Ed=Math.pow(2,21),xi=Math.pow(2,28),bi=Math.pow(2,35),wi=Math.pow(2,42),Ei=Math.pow(2,49),Q=128,gt=127;function Xt(e){if(e<bd)return 1;if(e<wd)return 2;if(e<Ed)return 3;if(e<xi)return 4;if(e<bi)return 5;if(e<wi)return 6;if(e<Ei)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Kr(e,t,r=0){switch(Xt(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 Si(e,t){let r=e[t],n=0;if(n+=r>,r<Q||(r=e[t+1],n+=(r>)<<7,r<Q)||(r=e[t+2],n+=(r>)<<14,r<Q)||(r=e[t+3],n+=(r>)<<21,r<Q)||(r=e[t+4],n+=(r>)*xi,r<Q)||(r=e[t+5],n+=(r>)*bi,r<Q)||(r=e[t+6],n+=(r>)*wi,r<Q)||(r=e[t+7],n+=(r>)*Ei,r<Q))return n;throw new RangeError("Could not decode varint")}function Sd(e,t){let r=e.get(t),n=0;if(n+=r>,r<Q||(r=e.get(t+1),n+=(r>)<<7,r<Q)||(r=e.get(t+2),n+=(r>)<<14,r<Q)||(r=e.get(t+3),n+=(r>)<<21,r<Q)||(r=e.get(t+4),n+=(r>)*xi,r<Q)||(r=e.get(t+5),n+=(r>)*bi,r<Q)||(r=e.get(t+6),n+=(r>)*wi,r<Q)||(r=e.get(t+7),n+=(r>)*Ei,r<Q))return n;throw new RangeError("Could not decode varint")}function vi(e,t=0){return e instanceof Uint8Array?Si(e,t):Sd(e,t)}var Ai=new Float32Array([-0]),Ee=new Uint8Array(Ai.buffer);function Ha(e,t,r){Ai[0]=e,t[r]=Ee[0],t[r+1]=Ee[1],t[r+2]=Ee[2],t[r+3]=Ee[3]}function za(e,t){return Ee[0]=e[t],Ee[1]=e[t+1],Ee[2]=e[t+2],Ee[3]=e[t+3],Ai[0]}var Ci=new Float64Array([-0]),xt=new Uint8Array(Ci.buffer);function Za(e,t,r){Ci[0]=e,t[r]=xt[0],t[r+1]=xt[1],t[r+2]=xt[2],t[r+3]=xt[3],t[r+4]=xt[4],t[r+5]=xt[5],t[r+6]=xt[6],t[r+7]=xt[7]}function Ga(e,t){return xt[0]=e[t],xt[1]=e[t+1],xt[2]=e[t+2],xt[3]=e[t+3],xt[4]=e[t+4],xt[5]=e[t+5],xt[6]=e[t+6],xt[7]=e[t+7],Ci[0]}var Ad=BigInt(Number.MAX_SAFE_INTEGER),Cd=BigInt(Number.MIN_SAFE_INTEGER),Bt=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 Oe;if(t<Ad&&t>Cd)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>ja&&(o=0n,++n>ja&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Oe;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):Oe}},Oe=new Bt(0,0);Oe.toBigInt=function(){return 0n};Oe.zzEncode=Oe.zzDecode=function(){return this};Oe.length=function(){return 1};var ja=4294967296n;function Ya(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 Wa(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 Ii(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 Mt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function In(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ti=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,Mt(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 Mt(this,4);return In(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Mt(this,4);return In(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Mt(this,4);let t=za(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Mt(this,4);let t=Ga(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 Mt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Wa(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Mt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Mt(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 Bt(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 Mt(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 Mt(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 Mt(this,8);let t=In(this.buf,this.pos+=4),r=In(this.buf,this.pos+=4);return new Bt(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=Si(this.buf,this.pos);return this.pos+=Xt(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 Bi(e){return new Ti(e instanceof Uint8Array?e:e.subarray())}function ir(e,t,r){let n=Bi(e);return t.decode(n,void 0,r)}function _i(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return It(s);o+s>t&&(n=It(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var ke=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Di(){}var Ui=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Id=_i();function Td(e){return globalThis.Buffer!=null?It(e):Id(e)}var Mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ke(Di,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new ke(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Li((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(Tn,10,Bt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Bt.fromBigInt(t);return this._push(Tn,r.length(),r)}uint64Number(t){return this._push(Kr,Xt(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=Bt.fromBigInt(t).zzEncode();return this._push(Tn,r.length(),r)}sint64Number(t){let r=Bt.fromNumber(t).zzEncode();return this._push(Tn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ri,1,t?1:0)}fixed32(t){return this._push(Vr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Bt.fromBigInt(t);return this._push(Vr,4,r.lo)._push(Vr,4,r.hi)}fixed64Number(t){let r=Bt.fromNumber(t);return this._push(Vr,4,r.lo)._push(Vr,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(Ha,4,t)}double(t){return this._push(Za,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Ri,1,0):this.uint32(r)._push(_d,r,t)}string(t){let r=Ya(t);return r!==0?this.uint32(r)._push(Ii,r,t):this._push(Ri,1,0)}fork(){return this.states=new Ui(this),this.head=this.tail=new ke(Di,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 ke(Di,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=Td(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Ri(e,t,r){t[r]=e&255}function Bd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Li=class extends ke{next;constructor(t,r){super(Bd,t,r),this.next=void 0}};function Tn(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 Vr(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 _d(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Mr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Dd,t,e),this},Mr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Rd,t,e),this});function Dd(e,t,r){t.set(e,r)}function Rd(e,t,r){e.length<40?Ii(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Pi(){return new Mr}function sr(e,t){let r=Pi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ar;(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"})(ar||(ar={}));function Bn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Fr(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 Bn("enum",ar.VARINT,r,n)}function cr(e,t){return Bn("message",ar.LENGTH_DELIMITED,e,t)}var it;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(it||(it={}));var Ni;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Ni||(Ni={}));(function(e){e.codec=()=>Fr(Ni)})(it||(it={}));var Jt;(function(e){let t;e.codec=()=>(t==null&&(t=cr((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=>sr(r,e.codec()),e.decode=(r,n)=>ir(r,e.codec(),n)})(Jt||(Jt={}));var Oi;(function(e){let t;e.codec=()=>(t==null&&(t=cr((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=>sr(r,e.codec()),e.decode=(r,n)=>ir(r,e.codec(),n)})(Oi||(Oi={}));var $r={};St($r,{MAX_RSA_KEY_SIZE:()=>ki,generateRSAKeyPair:()=>rc,jwkToJWKKeyPair:()=>nc,jwkToPkcs1:()=>Nd,jwkToPkix:()=>Fi,jwkToRSAPrivateKey:()=>zi,pkcs1MessageToJwk:()=>Vi,pkcs1MessageToRSAPrivateKey:()=>qi,pkcs1ToJwk:()=>Pd,pkcs1ToRSAPrivateKey:()=>ec,pkixMessageToJwk:()=>Mi,pkixMessageToRSAPublicKey:()=>Hi,pkixToJwk:()=>Od,pkixToRSAPublicKey:()=>$i});var ur=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return j.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 tc(this.jwk,r,t,n)}},qr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}sign(t,r){return Qa(this.jwk,t,r)}};var ki=8192,Ki=18,Ud=1062,Ld=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Pd(e){let t=ne(e);return Vi(t)}function Vi(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 Nd(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 me([At(Uint8Array.from([0])),At(H(e.n,"base64url")),At(H(e.e,"base64url")),At(H(e.d,"base64url")),At(H(e.p,"base64url")),At(H(e.q,"base64url")),At(H(e.dp,"base64url")),At(H(e.dq,"base64url")),At(H(e.qi,"base64url"))]).subarray()}function Od(e){let t=ne(e,{offset:0});return Mi(t)}function Mi(e){let t=ne(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function Fi(e){if(e.n==null||e.e==null)throw new st("JWK was missing components");return me([Ld,hn(me([At(H(e.n,"base64url")),At(H(e.e,"base64url"))]))]).subarray()}function ec(e){let t=ne(e);return qi(t)}function qi(e){let t=Vi(e);return zi(t)}function $i(e,t){if(e.byteLength>=Ud)throw new Me("Key size is too large");let r=ne(e,{offset:0});return Hi(r,e,t)}function Hi(e,t,r){let n=Mi(e);if(r==null){let o=Qe(Jt.encode({Type:it.RSA,Data:t}));r=jt(Ki,o)}return new ur(n,r)}function zi(e){if(ic(e)>ki)throw new st("Key size is too large");let t=nc(e),r=Qe(Jt.encode({Type:it.RSA,Data:Fi(t.publicKey)})),n=jt(Ki,r);return new qr(t.privateKey,new ur(t.publicKey,n))}async function rc(e){if(e>ki)throw new st("Key size is too large");let t=await oc(e),r=Qe(Jt.encode({Type:it.RSA,Data:Fi(t.publicKey)})),n=jt(Ki,r);return new qr(t.privateKey,new ur(t.publicKey,n))}function nc(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 oc(e,t){let r=await Pt.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 kd(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Qa(e,t,r){let n=await Pt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Pt.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 tc(e,t,r,n){let o=await Pt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Pt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function kd(e,t){if(e.privateKey==null||e.publicKey==null)throw new st("Private and public key are required");let r=await Promise.all([Pt.get().subtle.exportKey("jwk",e.privateKey),Pt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function ic(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 _n=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(pn(t),$(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),ie(o)}update(t){return Xe(this),this.iHash.update(t),this}digestInto(t){Xe(this),$(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()}},Zi=(e,t,r)=>new _n(e,t).update(r).digest();Zi.create=(e,t)=>new _n(e,t);var sc=(e,t)=>(e+(e>=0?t:-t)/ac)/t;function Kd(e,t,r){let[[n,o],[i,s]]=t,c=sc(s*e,r),a=sc(-o*e,r),l=e-c*n-a*i,u=-c*o-a*s,f=l<fe,g=u<fe;f&&(l=-l),g&&(u=-u);let v=Pr(Math.ceil(oi(r)/2))+fr;if(l<fe||l>=v||u<fe||u>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:l,k2neg:g,k2:u}}function ji(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Gi(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return ue(r.lowS,"lowS"),ue(r.prehash,"prehash"),r.format!==void 0&&ji(r.format),r}var Yi=class extends Error{constructor(t=""){super(t)}},Se={Err:Yi,_tlv:{encode:(e,t)=>{let{Err:r}=Se;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=Ur(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Ur(o.length/2|128):"";return Ur(e)+i+o+t},decode(e,t){let{Err:r}=Se,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 l=t.subarray(n,n+a);if(l.length!==a)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)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}=Se;if(e<fe)throw new t("integer: negative integers are not allowed");let r=Ur(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}=Se;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 tr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Se,o=$(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:l,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(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Se,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},fe=BigInt(0),fr=BigInt(1),ac=BigInt(2),Dn=BigInt(3),Vd=BigInt(4);function cc(e,t={}){let r=wn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;be(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 l=fc(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(A,m,y){let{x:d,y:E}=m.toAffine(),R=n.toBytes(d);if(ue(y,"isCompressed"),y){u();let U=!n.isOdd(E);return Ct(uc(U),R)}else return Ct(Uint8Array.of(4),R,n.toBytes(E))}function g(A){$(A,void 0,"Point");let{publicKey:m,publicKeyUncompressed:y}=l,d=A.length,E=A[0],R=A.subarray(1);if(d===m&&(E===2||E===3)){let U=n.fromBytes(R);if(!n.isValid(U))throw new Error("bad point: is not on curve, wrong x");let N=I(U),O;try{O=n.sqrt(N)}catch(tt){let Y=tt instanceof Error?": "+tt.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}u();let K=n.isOdd(O);return(E&1)===1!==K&&(O=n.neg(O)),{x:U,y:O}}else if(d===y&&E===4){let U=n.BYTES,N=n.fromBytes(R.subarray(0,U)),O=n.fromBytes(R.subarray(U,U*2));if(!C(N,O))throw new Error("bad point: is not on curve");return{x:N,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${m} or uncompressed=${y}`)}let v=t.toBytes||f,w=t.fromBytes||g;function I(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 C(A,m){let y=n.sqr(m),d=I(A);return n.eql(y,d)}if(!C(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let b=n.mul(n.pow(i.a,Dn),Vd),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(b,T)))throw new Error("bad curve params: a or b");function S(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 Kd(A,a.basises,o.ORDER)}let M=er((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 U=n.mul(y,m),N=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:U,y:N}}),V=er(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(!C(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=Or(d,m),y=Or(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=S("x",m),this.Y=S("y",y,!0),this.Z=S("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(w($(m,void 0,"point")));return y.assertValidity(),y}static fromHex(m){return p.fromBytes(ae(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(Dn),this}assertValidity(){V(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:U,Z:N}=m,O=n.eql(n.mul(y,N),n.mul(R,E)),K=n.eql(n.mul(d,N),n.mul(U,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,Dn),{X:E,Y:R,Z:U}=this,N=n.ZERO,O=n.ZERO,K=n.ZERO,q=n.mul(E,E),tt=n.mul(R,R),Y=n.mul(U,U),Z=n.mul(E,R);return Z=n.add(Z,Z),K=n.mul(E,U),K=n.add(K,K),N=n.mul(m,K),O=n.mul(d,Y),O=n.add(N,O),N=n.sub(tt,O),O=n.add(tt,O),O=n.mul(N,O),N=n.mul(Z,N),K=n.mul(d,K),Y=n.mul(m,Y),Z=n.sub(q,Y),Z=n.mul(m,Z),Z=n.add(Z,K),K=n.add(q,q),q=n.add(K,q),q=n.add(q,Y),q=n.mul(q,Z),O=n.add(O,q),Y=n.mul(R,U),Y=n.add(Y,Y),q=n.mul(Y,Z),N=n.sub(N,q),K=n.mul(Y,tt),K=n.add(K,K),K=n.add(K,K),new p(N,O,K)}add(m){P(m);let{X:y,Y:d,Z:E}=this,{X:R,Y:U,Z:N}=m,O=n.ZERO,K=n.ZERO,q=n.ZERO,tt=i.a,Y=n.mul(i.b,Dn),Z=n.mul(y,R),et=n.mul(d,U),lt=n.mul(E,N),Zt=n.add(y,d),rt=n.add(R,U);Zt=n.mul(Zt,rt),rt=n.add(Z,et),Zt=n.sub(Zt,rt),rt=n.add(y,E);let yt=n.add(R,N);return rt=n.mul(rt,yt),yt=n.add(Z,lt),rt=n.sub(rt,yt),yt=n.add(d,E),O=n.add(U,N),yt=n.mul(yt,O),O=n.add(et,lt),yt=n.sub(yt,O),q=n.mul(tt,rt),O=n.mul(Y,lt),q=n.add(O,q),O=n.sub(et,q),q=n.add(et,q),K=n.mul(O,q),et=n.add(Z,Z),et=n.add(et,Z),lt=n.mul(tt,lt),rt=n.mul(Y,rt),et=n.add(et,lt),lt=n.sub(Z,lt),lt=n.mul(tt,lt),rt=n.add(rt,lt),Z=n.mul(et,rt),K=n.add(K,Z),Z=n.mul(yt,rt),O=n.mul(Zt,O),O=n.sub(O,Z),Z=n.mul(Zt,et),q=n.mul(yt,q),q=n.add(q,Z),new p(O,K,q)}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=U=>D.cached(this,U,N=>Ne(p,N));if(y){let{k1neg:U,k1:N,k2neg:O,k2:K}=k(m),{p:q,f:tt}=R(N),{p:Y,f:Z}=R(K);E=tt.add(Z),d=h(y.beta,q,Y,U,O)}else{let{p:U,f:N}=R(m);d=U,E=N}return Ne(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===fe||d.is0())return p.ZERO;if(m===fr)return d;if(D.hasCache(this))return this.multiply(m);if(y){let{k1neg:E,k1:R,k2neg:U,k2:N}=k(m),{p1:O,p2:K}=Na(p,d,R,N);return h(y.beta,O,K,E,U)}else return D.unsafe(d,m)}toAffine(m){return M(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return s===fr?!0:m?m(p,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:m}=t;return s===fr?this:m?m(p,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return ue(m,"isCompressed"),this.assertValidity(),v(p,this,m)}toHex(m=!0){return se(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,D=new or(p,t.endo?Math.ceil(_/2):_);return p.BASE.precompute(8),p}function uc(e){return Uint8Array.of(e?2:3)}function fc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Md(e,t={}){let{Fn:r}=e,n=t.randomBytes||Je,o=Object.assign(fc(e.Fp,r),{seed:ci(r.ORDER)});function i(v){try{let w=r.fromBytes(v);return r.isValidNot0(w)}catch{return!1}}function s(v,w){let{publicKey:I,publicKeyUncompressed:C}=o;try{let b=v.length;return w===!0&&b!==I||w===!1&&b!==C?!1:!!e.fromBytes(v)}catch{return!1}}function c(v=n(o.seed)){return ui($(v,o.seed,"seed"),r.ORDER)}function a(v,w=!0){return e.BASE.multiply(r.fromBytes(v)).toBytes(w)}function l(v){let{secretKey:w,publicKey:I,publicKeyUncompressed:C}=o;if(!_e(v)||"_lengths"in r&&r._lengths||w===I)return;let b=$(v,void 0,"key").length;return b===I||b===C}function u(v,w,I=!0){if(l(v)===!0)throw new Error("first arg must be private key");if(l(w)===!1)throw new Error("second arg must be public key");let C=r.fromBytes(v);return e.fromBytes(w).multiply(C).toBytes(I)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},g=En(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:g,Point:e,utils:f,lengths:o})}function lc(e,t,r={}){pn(t),be(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Je,o=r.hmac||((y,d)=>Zi(t,y,d)),{Fp:i,Fn:s}=e,{ORDER:c,BITS:a}=s,{keygen:l,getPublicKey:u,getSharedSecret:f,utils:g,lengths:v}=Md(e,r),w={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},I=c*ac<i.ORDER;function C(y){let d=c>>fr;return y>d}function b(y,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return d}function T(){if(I)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function S(y,d){ji(d);let E=v.signature,R=d==="compact"?E:d==="recovered"?E+1:void 0;return $(y,R)}class P{r;s;recovery;constructor(d,E,R){if(this.r=b("r",d),this.s=b("s",E),R!=null){if(T(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(d,E=w.format){S(d,E);let R;if(E==="der"){let{r:K,s:q}=Se.toSig($(d));return new P(K,q)}E==="recovered"&&(R=d[0],E="compact",d=d.subarray(1));let U=v.signature/2,N=d.subarray(0,U),O=d.subarray(U,U*2);return new P(s.fromBytes(N),s.fromBytes(O),R)}static fromHex(d,E){return this.fromBytes(ae(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,U=this.assertRecovery(),N=U===2||U===3?E+c:E;if(!i.isValid(N))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(N),K=e.fromBytes(Ct(uc((U&1)===0),O)),q=s.inv(N),tt=M($(d,void 0,"msgHash")),Y=s.create(-tt*q),Z=s.create(R*q),et=e.BASE.multiplyUnsafe(Y).add(K.multiplyUnsafe(Z));if(et.is0())throw new Error("invalid recovery: point at infinify");return et.assertValidity(),et}hasHighS(){return C(this.s)}toBytes(d=w.format){if(ji(d),d==="der")return ae(Se.hexFromSig(this));let{r:E,s:R}=this,U=s.toBytes(E),N=s.toBytes(R);return d==="recovered"?(T(),Ct(Uint8Array.of(this.assertRecovery()),U,N)):Ct(U,N)}toHex(d){return se(this.toBytes(d))}}let k=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let E=tr(d),R=d.length*8-a;return R>0?E>>BigInt(R):E},M=r.bits2int_modN||function(d){return s.create(k(d))},V=Pr(a);function h(y){return Lr("num < 2^"+a,y,fe,V),s.toBytes(y)}function p(y,d){return $(y,void 0,"message"),d?$(t(y),void 0,"prehashed message"):y}function _(y,d,E){let{lowS:R,prehash:U,extraEntropy:N}=Gi(E,w);y=p(y,U);let O=M(y),K=s.fromBytes(d);if(!s.isValidNot0(K))throw new Error("invalid private key");let q=[h(K),h(O)];if(N!=null&&N!==!1){let et=N===!0?n(v.secretKey):N;q.push($(et,void 0,"extraEntropy"))}let tt=Ct(...q),Y=O;function Z(et){let lt=k(et);if(!s.isValidNot0(lt))return;let Zt=s.inv(lt),rt=e.BASE.multiply(lt).toAffine(),yt=s.create(rt.x);if(yt===fe)return;let sn=s.create(Zt*s.create(Y+yt*K));if(sn===fe)return;let ws=(rt.x===yt?0:2)|Number(rt.y&fr),Es=sn;return R&&C(sn)&&(Es=s.neg(sn),ws^=1),new P(yt,Es,I?void 0:ws)}return{seed:tt,k2sig:Z}}function D(y,d,E={}){let{seed:R,k2sig:U}=_(y,d,E);return xa(t.outputLen,s.BYTES,o)(R,U).toBytes(E.format)}function A(y,d,E,R={}){let{lowS:U,prehash:N,format:O}=Gi(R,w);if(E=$(E,void 0,"publicKey"),d=p(d,N),!_e(y)){let K=y instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}S(y,O);try{let K=P.fromBytes(y,O),q=e.fromBytes(E);if(U&&K.hasHighS())return!1;let{r:tt,s:Y}=K,Z=M(d),et=s.inv(Y),lt=s.create(Z*et),Zt=s.create(tt*et),rt=e.BASE.multiplyUnsafe(lt).add(q.multiplyUnsafe(Zt));return rt.is0()?!1:s.create(rt.x)===tt}catch{return!1}}function m(y,d,E={}){let{prehash:R}=Gi(E,w);return d=p(d,R),P.fromBytes(y,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:f,utils:g,lengths:v,Point:e,sign:D,verify:A,recoverPublicKey:m,Signature:P,hash:t})}var Xi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Fd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var dc=BigInt(2);function qd(e){let t=Xi.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=X(u,r,t)*u%t,g=X(f,r,t)*u%t,v=X(g,dc,t)*l%t,w=X(v,o,t)*v%t,I=X(w,i,t)*w%t,C=X(I,c,t)*I%t,b=X(C,a,t)*C%t,T=X(b,c,t)*I%t,S=X(T,r,t)*u%t,P=X(S,s,t)*w%t,k=X(P,n,t)*l%t,M=X(k,dc,t);if(!Wi.eql(Wi.sqr(M),e))throw new Error("Cannot find square root");return M}var Wi=rr(Xi.p,{sqrt:qd}),$d=cc(Xi,{Fp:Wi,endo:Fd}),lr=lc($d,Qe);function hc(e,t,r,n){let o=Cr.digest(r instanceof Uint8Array?r:r.subarray());if(An(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),lr.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new kr(String(i))});try{return n?.signal?.throwIfAborted(),lr.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new kr(String(i))}}var Rn=class{type="secp256k1";raw;_key;constructor(t){this._key=mc(t),this.raw=pc(this._key)}toMultihash(){return Kt.digest(We(this))}toCID(){return j.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 hc(this._key,r,t,n)}};function Ji(e){return new Rn(e)}function pc(e){return lr.Point.fromBytes(e).toBytes()}function mc(e){try{return lr.Point.fromBytes(e),e}catch(t){throw new Me(String(t))}}function yc(e,t){let{Type:r,Data:n}=Jt.decode(e),o=n??new Uint8Array;switch(r){case it.RSA:return $i(o,t);case it.Ed25519:return gi(o);case it.secp256k1:return Ji(o);case it.ECDSA:return Zo(o);default:throw new qe}}function Un(e){let{Type:t,Data:r}=Jt.decode(e.digest),n=r??new Uint8Array;switch(t){case it.Ed25519:return gi(n);case it.secp256k1:return Ji(n);case it.ECDSA:return Zo(n);default:throw new qe}}function We(e){return Jt.encode({Type:it[e.type],Data:e.raw})}var gc=Symbol.for("nodejs.util.inspect.custom"),Hd=114,Hr=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()})`}[mo]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return j.createV1(Hd,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")}[gc](){return`PeerId(${this.toString()})`}},Ln=class extends Hr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Pn=class extends Hr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Nn=class extends Hr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},zd=2336,zr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Kt.digest(H(this.url))}[gc](){return`PeerId(${this.url})`}[mo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return j.createV1(zd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=z(t)),t.toString()===this.toString())}};var Zd=114,xc=2336;function bc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Te(W.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Gd(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=Te(t.decode(e))}return wc(r)}function wc(e){if(Yd(e))return new Ln({multihash:e});if(jd(e))try{let t=Un(e);if(t.type==="Ed25519")return new Pn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Nn({multihash:e,publicKey:t})}catch{let r=z(e.digest);return new zr(new URL(r))}throw new Fe("Supplied PeerID Multihash is invalid")}function Gd(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Zd&&e.code!==xc)throw new cn("Supplied PeerID CID is invalid");if(e.code===xc){let t=z(e.multihash.digest);return new zr(new URL(t))}return wc(e.multihash)}function jd(e){return e.code===Kt.code}function Yd(e){return e.code===Cr.code}var ht=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},le=class extends Error{static name="ValidationError";name="ValidationError"},On=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},kn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Kn=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",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let g=Number.parseInt(f,t);if(!Number.isNaN(g))return g});if(u===void 0)break;if(i*=t,i+=u,i>l||(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 Wd=45,Xd=15,Vn=new Kn;function Ec(e){if(!(e.length>Xd))return Vn.new(e).parseWith(()=>Vn.readIPv4Addr())}function Sc(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Wd))return Vn.new(e).parseWith(()=>Vn.readIPv6Addr())}function Mn(e){return!!Ec(e)}function vc(e){return!!Sc(e)}function ts(e){return t=>z(t,e)}function es(e){return t=>H(t,e)}function dr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Ke(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Ac(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=Ke(n);return Lt([r,o],r.length+o.length)}function Cc(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=Gt.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=Ke(n);return Lt([r,o],r.length+o.length)}function rs(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=z(t,"base32"),o=dr(r);return`${n}:${o}`}var ns=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},Ic=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Mn(r[n]),s;i&&(s=ns(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 ht("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},Tc=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(".")},Bc=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 _c(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 Qi=Object.values(Ir).map(e=>e.decoder),Jd=(function(){let e=Qi[0].or(Qi[1]);return Qi.slice(2).forEach(t=>e=e.or(t)),e})();function Dc(e){return Jd.decode(e)}function Rc(e){return t=>e.encoder.encode(t)}function Qd(e){if(parseInt(e).toString()!==e)throw new le("Value must be an integer")}function th(e){if(e<0)throw new le("Value must be a positive integer, or zero")}function eh(e){return t=>{if(t>e)throw new le(`Value must be smaller than or equal to ${e}`)}}function rh(...e){return t=>{for(let r of e)r(t)}}var Zr=rh(Qd,th,eh(65535));var ut=-1,os=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 kn(`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)}))}},de=new os,$h=[{code:4,name:"ip4",size:32,valueToBytes:ns,bytesToValue:Tc,validate:e=>{if(!Mn(e))throw new le(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:273,name:"udp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:33,name:"dccp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:41,name:"ip6",size:128,valueToBytes:Ic,bytesToValue:Bc,stringToValue:_c,validate:e=>{if(!vc(e))throw new le(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ut},{code:43,name:"ipcidr",size:8,bytesToValue:ts("base10"),valueToBytes:es("base10")},{code:53,name:"dns",size:ut},{code:54,name:"dns4",size:ut},{code:55,name:"dns6",size:ut},{code:56,name:"dnsaddr",size:ut},{code:132,name:"sctp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ut,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ut,bytesToValue:ts("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?es("base58btc")(e):j.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:rs,valueToBytes:Ac},{code:445,name:"onion3",size:296,bytesToValue:rs,valueToBytes:Cc},{code:446,name:"garlic64",size:ut},{code:447,name:"garlic32",size:ut},{code:448,name:"tls"},{code:449,name:"sni",size:ut},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ut,bytesToValue:Rc(vo),valueToBytes:Dc},{code:480,name:"http"},{code:481,name:"http-path",size:ut,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:ut}];$h.forEach(e=>{de.addProtocol(e)});function Uc(e){let t=[],r=0;for(;r<e.length;){let n=vi(e,r),o=de.getProtocol(n),i=Xt(n),s=Hh(o,e,r+i),c=0;s>0&&o.size===ut&&(c=Xt(s));let a=i+c+s,l={code:n,name:o.name,bytes:e.subarray(r,r+a)};if(s>0){let u=r+i+c,f=e.subarray(u,u+s);l.value=o.bytesToValue?.(f)??z(f)}t.push(l),r+=a}return t}function Lc(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=de.getProtocol(n.code),i=Xt(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??H(n.value),c=s.byteLength,o.size===ut&&(a=Xt(c)));let l=new Uint8Array(i+a+c),u=0;Kr(n.code,l,u),u+=i,s!=null&&(o.size===ut&&(Kr(c,l,u),u+=a),l.set(s,u)),n.bytes=l}r.push(n.bytes),t+=n.bytes.byteLength}return Lt(r,t)}function Pc(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 c=i===e.length-1;if(s==="/"||c){let a=de.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 ht(`Component ${o} was missing value`);r="value"}else if(r==="value"){let l={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new ht(`Component ${o} was missing value`);l.value=a.stringToValue?.(n)??n}t.push(l),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ht("Incomplete multiaddr");return t}function Nc(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=de.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 Hh(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:vi(t,r)}var zh=Symbol.for("nodejs.util.inspect.custom"),is=Symbol.for("@multiformats/multiaddr");function Zh(e){if(e==null&&(e="/"),Oc(e))return e.getComponents();if(e instanceof Uint8Array)return Uc(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Pc(e);if(Array.isArray(e))return e;throw new ht("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Fn=class e{[is]=!0;#t;#n;#r;constructor(t="/",r={}){this.#t=Zh(t),r.validate!==!1&&Gh(this)}get bytes(){return this.#r==null&&(this.#r=Lc(this.#t)),this.#r}toString(){return this.#n==null&&(this.#n=Nc(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 On(`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 J(this.bytes,t.bytes)}[zh](){return`Multiaddr(${this.toString()})`}};function Gh(e){e.getComponents().forEach(t=>{let r=de.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Oc(e){return!!e?.[is]}function kc(e){return new Fn(e)}function Gr(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*qn(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 Tp=po(as(),1);var Ft=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},$n=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},hr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Hn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},zn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Zn=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=()=>Fr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=cr((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 l=o.uint32();switch(l>>>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(l&7);break}}}return c})),n),e.encode=o=>sr(o,e.codec()),e.decode=(o,i)=>ir(o,e.codec(),i)})(qt||(qt={}));var jh=["string","number","bigint","symbol"],Yh=["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 Kc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(jh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Wh(e))return"Buffer";let r=Xh(e);return r||"Object"}function Wh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Xh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Yh.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 L=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",Jh=new TextDecoder,Qh=new TextEncoder;function Gn(e){return pr&&globalThis.Buffer.isBuffer(e)}function qc(e){return e instanceof Uint8Array?Gn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var $c=pr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Mc(e,t,r):(e,t,r)=>r-t>64?Jh.decode(e.subarray(t,r)):Mc(e,t,r),Hc=pr?e=>e.length>64?globalThis.Buffer.from(e):Vc(e):e=>e.length>64?Qh.encode(e):Vc(e);var mr=pr?(e,t,r)=>Gn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),zc=pr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),qc(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},Zc=pr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Gc(e,t){if(Gn(e)&&Gn(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 Vc(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 Mc(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,l,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],l=e[t+3],(c&192)===128&&(a&192)===128&&(l&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|l&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 Fc=4096;function tp(e){let t=e.length;if(t<=Fc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Fc));return r}var ep=256,jn=class{constructor(t=ep){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=Zc(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=mr(n,0,this.cursor)}else r=zc(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",cs="CBOR encode error:",Yr=[];Yr[23]=1;Yr[24]=2;Yr[25]=3;Yr[26]=5;Yr[27]=9;function he(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var ft=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _t(e,t,r){he(e,t,1);let n=e[t];if(r.strict===!0&&n<ft[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){he(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ft[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){he(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ft[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Ut(e,t,r){he(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ft[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function jc(e,t,r,n){return new L(x.uint,_t(e,t+1,n),2)}function Yc(e,t,r,n){return new L(x.uint,Dt(e,t+1,n),3)}function Wc(e,t,r,n){return new L(x.uint,Rt(e,t+1,n),5)}function Xc(e,t,r,n){return new L(x.uint,Ut(e,t+1,n),9)}function Nt(e,t){return pt(e,0,t.value)}function pt(e,t,r){if(r<ft[0]){let n=Number(r);e.push([t|n])}else if(r<ft[1]){let n=Number(r);e.push([t|24,n])}else if(r<ft[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ft[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ft[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}Nt.encodedSize=function(t){return pt.encodedSize(t.value)};pt.encodedSize=function(t){return t<ft[0]?1:t<ft[1]?2:t<ft[2]?3:t<ft[3]?5:9};Nt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Jc(e,t,r,n){return new L(x.negint,-1-_t(e,t+1,n),2)}function Qc(e,t,r,n){return new L(x.negint,-1-Dt(e,t+1,n),3)}function tu(e,t,r,n){return new L(x.negint,-1-Rt(e,t+1,n),5)}var us=BigInt(-1),eu=BigInt(1);function ru(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new L(x.negint,us-BigInt(o),9)}function Yn(e,t){let r=t.value,n=typeof r=="bigint"?r*us-eu:r*-1-1;pt(e,t.type.majorEncoded,n)}Yn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*us-eu:r*-1-1;return n<ft[0]?1:n<ft[1]?2:n<ft[2]?3:n<ft[3]?5:9};Yn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Wr(e,t,r,n){he(e,t,r+n);let o=mr(e,t+r,t+r+n);return new L(x.bytes,o,r+n)}function nu(e,t,r,n){return Wr(e,t,1,r)}function ou(e,t,r,n){return Wr(e,t,2,_t(e,t+1,n))}function iu(e,t,r,n){return Wr(e,t,3,Dt(e,t+1,n))}function su(e,t,r,n){return Wr(e,t,5,Rt(e,t+1,n))}function au(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return Wr(e,t,9,o)}function Wn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===x.string?Hc(e.value):e.value),e.encodedBytes}function yr(e,t){let r=Wn(t);pt(e,t.type.majorEncoded,r.length),e.push(r)}yr.encodedSize=function(t){let r=Wn(t);return pt.encodedSize(r.length)+r.length};yr.compareTokens=function(t,r){return np(Wn(t),Wn(r))};function np(e,t){return e.length<t.length?-1:e.length>t.length?1:Gc(e,t)}function Xr(e,t,r,n,o){let i=r+n;he(e,t,i);let s=new L(x.string,$c(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=mr(e,t+r,t+i)),s}function cu(e,t,r,n){return Xr(e,t,1,r,n)}function uu(e,t,r,n){return Xr(e,t,2,_t(e,t+1,n),n)}function fu(e,t,r,n){return Xr(e,t,3,Dt(e,t+1,n),n)}function lu(e,t,r,n){return Xr(e,t,5,Rt(e,t+1,n),n)}function du(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return Xr(e,t,9,o,n)}var hu=yr;function gr(e,t,r,n){return new L(x.array,n,r)}function pu(e,t,r,n){return gr(e,t,1,r)}function mu(e,t,r,n){return gr(e,t,2,_t(e,t+1,n))}function yu(e,t,r,n){return gr(e,t,3,Dt(e,t+1,n))}function gu(e,t,r,n){return gr(e,t,5,Rt(e,t+1,n))}function xu(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return gr(e,t,9,o)}function bu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return gr(e,t,1,1/0)}function Xn(e,t){pt(e,x.array.majorEncoded,t.value)}Xn.compareTokens=Nt.compareTokens;Xn.encodedSize=function(t){return pt.encodedSize(t.value)};function xr(e,t,r,n){return new L(x.map,n,r)}function wu(e,t,r,n){return xr(e,t,1,r)}function Eu(e,t,r,n){return xr(e,t,2,_t(e,t+1,n))}function Su(e,t,r,n){return xr(e,t,3,Dt(e,t+1,n))}function vu(e,t,r,n){return xr(e,t,5,Rt(e,t+1,n))}function Au(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return xr(e,t,9,o)}function Cu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return xr(e,t,1,1/0)}function Jn(e,t){pt(e,x.map.majorEncoded,t.value)}Jn.compareTokens=Nt.compareTokens;Jn.encodedSize=function(t){return pt.encodedSize(t.value)};function Iu(e,t,r,n){return new L(x.tag,r,1)}function Tu(e,t,r,n){return new L(x.tag,_t(e,t+1,n),2)}function Bu(e,t,r,n){return new L(x.tag,Dt(e,t+1,n),3)}function _u(e,t,r,n){return new L(x.tag,Rt(e,t+1,n),5)}function Du(e,t,r,n){return new L(x.tag,Ut(e,t+1,n),9)}function Qn(e,t){pt(e,x.tag.majorEncoded,t.value)}Qn.compareTokens=Nt.compareTokens;Qn.encodedSize=function(t){return pt.encodedSize(t.value)};var up=20,fp=21,lp=22,dp=23;function Ru(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(x.null,null,1):new L(x.undefined,void 0,1)}function Uu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new L(x.break,void 0,1)}function fs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new L(x.float,e,t)}function Lu(e,t,r,n){return fs(ls(e,t+1),3,n)}function Pu(e,t,r,n){return fs(ds(e,t+1),5,n)}function Nu(e,t,r,n){return fs(Vu(e,t+1),9,n)}function to(e,t,r){let n=t.value;if(n===!1)e.push([x.float.majorEncoded|up]);else if(n===!0)e.push([x.float.majorEncoded|fp]);else if(n===null)e.push([x.float.majorEncoded|lp]);else if(n===void 0)e.push([x.float.majorEncoded|dp]);else{let o,i=!1;(!r||r.float64!==!0)&&(ku(n),o=ls($t,1),n===o||Number.isNaN(n)?($t[0]=249,e.push($t.slice(0,3)),i=!0):(Ku(n),o=ds($t,1),n===o&&($t[0]=250,e.push($t.slice(0,5)),i=!0))),i||(hp(n),o=Vu($t,1),$t[0]=251,e.push($t.slice(0,9)))}}to.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){ku(n);let o=ls($t,1);if(n===o||Number.isNaN(n))return 3;if(Ku(n),o=ds($t,1),n===o)return 5}return 9};var Ou=new ArrayBuffer(9),Ot=new DataView(Ou,1),$t=new Uint8Array(Ou,0);function ku(e){if(e===1/0)Ot.setUint16(0,31744,!1);else if(e===-1/0)Ot.setUint16(0,64512,!1);else if(Number.isNaN(e))Ot.setUint16(0,32256,!1);else{Ot.setFloat32(0,e);let t=Ot.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ot.setUint16(0,31744,!1);else if(r===0)Ot.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ot.setUint16(0,0):o<-14?Ot.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ot.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ls(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Ku(e){Ot.setFloat32(0,e,!1)}function ds(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function hp(e){Ot.setFloat64(0,e,!1)}function Vu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}to.compareTokens=Nt.compareTokens;function G(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function eo(e){return()=>{throw new Error(`${F} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=G;B[24]=jc;B[25]=Yc;B[26]=Wc;B[27]=Xc;B[28]=G;B[29]=G;B[30]=G;B[31]=G;for(let e=32;e<=55;e++)B[e]=G;B[56]=Jc;B[57]=Qc;B[58]=tu;B[59]=ru;B[60]=G;B[61]=G;B[62]=G;B[63]=G;for(let e=64;e<=87;e++)B[e]=nu;B[88]=ou;B[89]=iu;B[90]=su;B[91]=au;B[92]=G;B[93]=G;B[94]=G;B[95]=eo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=cu;B[120]=uu;B[121]=fu;B[122]=lu;B[123]=du;B[124]=G;B[125]=G;B[126]=G;B[127]=eo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=pu;B[152]=mu;B[153]=yu;B[154]=gu;B[155]=xu;B[156]=G;B[157]=G;B[158]=G;B[159]=bu;for(let e=160;e<=183;e++)B[e]=wu;B[184]=Eu;B[185]=Su;B[186]=vu;B[187]=Au;B[188]=G;B[189]=G;B[190]=G;B[191]=Cu;for(let e=192;e<=215;e++)B[e]=Iu;B[216]=Tu;B[217]=Bu;B[218]=_u;B[219]=Du;B[220]=G;B[221]=G;B[222]=G;B[223]=G;for(let e=224;e<=243;e++)B[e]=eo("simple values are not supported");B[244]=G;B[245]=G;B[246]=G;B[247]=Ru;B[248]=eo("simple values are not supported");B[249]=Lu;B[250]=Pu;B[251]=Nu;B[252]=G;B[253]=G;B[254]=G;B[255]=Uu;var Ht=[];for(let e=0;e<24;e++)Ht[e]=new L(x.uint,e,1);for(let e=-1;e>=-24;e--)Ht[31-e]=new L(x.negint,e,1);Ht[64]=new L(x.bytes,new Uint8Array(0),1);Ht[96]=new L(x.string,"",1);Ht[128]=new L(x.array,0,1);Ht[160]=new L(x.map,0,1);Ht[244]=new L(x.false,!1,1);Ht[245]=new L(x.true,!0,1);Ht[246]=new L(x.null,null,1);function mp(){let e=[];return e[x.uint.major]=Nt,e[x.negint.major]=Yn,e[x.bytes.major]=yr,e[x.string.major]=hu,e[x.array.major]=Xn,e[x.map.major]=Jn,e[x.tag.major]=Qn,e[x.float.major]=to,e}var Aw=mp(),Cw=new jn,ro=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(`${cs} object contains circular references`);return new e(r,t)}},ve={null:new L(x.null,null),undefined:new L(x.undefined,void 0),true:new L(x.true,!0),false:new L(x.false,!1),emptyArray:new L(x.array,0),emptyMap:new L(x.map,0)},Ae={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(x.float,e):e>=0?new L(x.uint,e):new L(x.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(x.uint,e):new L(x.negint,e)},Uint8Array(e,t,r,n){return new L(x.bytes,e)},string(e,t,r,n){return new L(x.string,e)},boolean(e,t,r,n){return e?ve.true:ve.false},null(e,t,r,n){return ve.null},undefined(e,t,r,n){return ve.undefined},ArrayBuffer(e,t,r,n){return new L(x.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(x.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[ve.emptyArray,new L(x.break)]:ve.emptyArray;n=ro.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=hs(s,r,n);return r.addBreakTokens?[new L(x.array,e.length),o,new L(x.break)]:[new L(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?[ve.emptyMap,new L(x.break)]:ve.emptyMap;n=ro.createCheck(n,e);let c=[],a=0;for(let l of i)c[a++]=[hs(l,r,n),hs(o?e.get(l):e[l],r,n)];return yp(c,r),r.addBreakTokens?[new L(x.map,s),c,new L(x.break)]:[new L(x.map,s),c]}};Ae.Map=Ae.Object;Ae.Buffer=Ae.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ae[`${e}Array`]=Ae.DataView;function hs(e,t={},r){let n=Kc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Ae[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Ae[n];if(!i)throw new Error(`${cs} unsupported type: ${n}`);return i(e,n,t,r)}function yp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var gp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},no=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=Ht[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Jr=Symbol.for("DONE"),oo=Symbol.for("BREAK");function xp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=br(t,r);if(i===oo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===Jr)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function bp(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=br(t,r);if(c===oo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(c===Jr)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${F} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${F} found repeat map key "${c}"`);let a=br(t,r);if(a===Jr)throw new Error(`${F} 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 br(e,t){if(e.done())return Jr;let r=e.next();if(r.type===x.break)return oo;if(r.type.terminal)return r.value;if(r.type===x.array)return xp(r,e,t);if(r.type===x.map)return bp(r,e,t);if(r.type===x.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=br(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function Mu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},gp,t);let r=t.tokenizer||new no(e,t),n=br(r,t);if(n===Jr)throw new Error(`${F} did not find any content to decode`);if(n===oo)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function ps(e,t){let[r,n]=Mu(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var Sp=ee("ipns:utils"),Fu=H("/ipns/");var vp=0,Ap=18;function qu(e){let t;if(e.pubKey!=null)try{t=yc(e.pubKey)}catch(r){throw Sp.error(r),r}if(t!=null)return t}function $u(e){let t=H("ipns-signature:");return Lt([t,e])}function Qr(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 Ce(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 Ft("Missing data or signatureV2");let r=Hu(t.data),n=Cp(r.Value),o=z(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Ip(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 tn(e){return Lt([Fu,e.bytes])}function wr(e){let t=Te(e.slice(Fu.length));if(!io(t,vp)&&!io(t,Ap))throw new Fe("Multihash in IPNS key was not identity or sha2-256");return t}function Hu(e){let t=ps(e);if(t.ValidityType===0)t.ValidityType=qt.ValidityType.EOL;else throw new hr("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 Cp(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 zn("Value must be a valid content path starting with /")}function Ip(e){if(e.data==null)throw new Zn("Record data is missing");let t=Hu(e.data);if(!J(t.Value,e.value??new Uint8Array(0)))throw new Ft('Field "value" did not match between protobuf and CBOR');if(!J(t.Validity,e.validity??new Uint8Array(0)))throw new Ft('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Ft('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Ft('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Ft('Field "ttl" did not match between protobuf and CBOR')}function io(e,t){return e.code===t}var jw=ee("ipns"),Yw=300*1e9,Bp="/ipns/",Ww=Bp.length;var zu=po(as(),1);var so=ee("ipns:validator"),_p=1024*10;async function Dp(e,t){let r=Ce(t),n;try{let o=$u(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw so.error("record signature verification failed"),new Ft("Record signature verification failed");if(r.validityType===qt.ValidityType.EOL){if(zu.default.fromString(r.validity).toDate().getTime()<Date.now())throw so.error("record has expired"),new $n("record has expired")}else if(r.validityType!=null)throw so.error("the validity type is unsupported"),new hr("The validity type is unsupported");so("ipns record for %s is valid",r.value)}async function Zu(e,t){if(t.byteLength>_p)throw new Hn("The record is too large");let r=wr(e),n;io(r,0)&&(n=Un(r));let o=Ce(t),i=qu(o)??n;if(i==null)throw new jr("Could not extract public key from IPNS record or routing key");let s=tn(i.toMultihash());if(!J(s,e))throw new jr("Embedded public key did not match routing key");await Dp(i,t)}var ao=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*en(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)),je(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new ao("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 Qt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var ys=po(ju(),1);var gs=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},Yu=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function xs(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=t,c,a,u=new Promise((f,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(Yu(s));return}if(s&&(a=()=>{g(Yu(s))},s.addEventListener("abort",a,{once:!0})),e.then(f,g),r===Number.POSITIVE_INFINITY)return;let v=new gs;c=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(w){g(w)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?f():o instanceof Error?g(o):(v.message=o??`Promise timed out after ${r} milliseconds`,g(v))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}function bs(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 nn=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=bs(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 on=class extends ys.default{#t;#n;#r=0;#h;#p=!1;#m=!1;#u;#b=0;#y=0;#i;#s;#e;#w;#o=0;#f;#a;#I=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:nn,...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.#P()}get#T(){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)}#U(){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.#U(),this.emit("idle")),!1;let t=!1;if(!this.#a){let r=!this.#R;if(this.#T&&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#L(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.#I++).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=xs(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.#L(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.#C()}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}#P(){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.#C()}))}#C(){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 Er=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},zt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Lp(e){return e[Symbol.asyncIterator]!=null}function Pp(e){if(Lp(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Wu=Pp;function Np(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 Xu=Np;function Op(e){return e[Symbol.asyncIterator]!=null}function kp(e,t){let r=0;if(Op(e))return(async function*(){for await(let a of e)yield t(a,r++)})();let n=Xu(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 Ju=kp;var Qu=H("/ipns/");function tf(e){return J(e.subarray(0,Qu.byteLength),Qu)}var uo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){try{yield*Ju(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}catch(n){if(n instanceof kt)return;throw n}}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!tf(t))return;let o=wr(t),i=j.createV1(114,o),s=Ce(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!tf(t))throw new kt("Not found");let n=wr(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Qr(i)}catch(i){throw i.name==="BadResponseError"?new kt("Not found"):i}}},fo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Wu(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new kt("Not found")}async*getClosestPeers(t,r={}){}};var mt=ee("delegated-routing-v1-http-api-client"),lo={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},ho=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 on({concurrency:r.concurrentRequests??lo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??lo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new uo(this),this.peerRouting=new fo(this),this.cacheName=r.cacheName??lo.cacheName,this.cacheTTL=r.cacheTTL??lo.cacheTTL}get[As](){return this.contentRouting}get[Cs](){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=Gr([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/providers/${t}`);this.#n(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#r(c.toString(),a);if(l==null)throw new zt("No response received");if(!l.ok)throw l.status===404?new kt("No matching records found"):l.status===422?new Er("Request does not conform to schema or semantic constraints"):new zt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new zt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new zt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let g of f.Providers){let v=this.#t(g);v!=null&&(yield v)}}else if(u.includes("application/x-ndjson"))for await(let f of en(qn(l.body))){let g=this.#t(f);g!=null&&(yield g)}else throw new zt(`Unsupported Content-Type: ${u}`)}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=Gr([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();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},l=await this.#r(c.toString(),a);if(l.status===404)throw new kt("No matching records found");if(l.status===422)throw new Er("Request does not conform to schema or semantic constraints");if(l.body==null)throw new zt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let g of f.Peers){let v=this.#t(g);v!=null&&(yield v)}}else for await(let f of en(qn(l.body))){let g=this.#t(f);g!=null&&(yield g)}}catch(c){mt.error("getPeers errored:",c)}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=Gr([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();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},l=await this.#r(c,a);if(mt("getIPNS GET %s %d",c,l.status),l.status===404)throw new kt("No matching records found");if(l.status===422)throw new Er("Request does not conform to schema or semantic constraints");if(l.body==null)throw new zt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await Zu(tn(t.multihash),f),Ce(f)}catch(a){throw mt.error("getIPNS GET %s error:",c,a),a}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=Gr([this.shutDownController.signal,o,n.signal]);let s=Qt(),c=Qt();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Qr(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#r(a,u);if(mt("putIPNS PUT %s %d",a,f.status),f.status!==200)throw new zt("PUT ipns response had status other than 200")}catch(l){throw mt.error("putIPNS PUT %s error:",a,l.stack),l}finally{i.clear(),c.resolve(),mt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(kc)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:bc(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#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 mt("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 mt("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 l=Date.now()+this.cacheTTL,u=new Headers(a.headers);u.set("x-cache-expires",l.toString());let f=new Response(a.clone().body,{status:a.status,statusText:a.statusText,headers:u});await this.cache.put(t,f)}return a}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function Kp(e,t={}){return new ho(new URL(e),t)}return af(Vp);})();
|
|
9
|
+
${t}[Error list was empty]`,r.trim()}return Io(e)};function Vf(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 ee(e,t){let r=Vf(`${e}:trace`);return vt.enabled(`${e}:trace`)&&vt.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=vt(`${e}:trace`,t)),Object.assign(vt(e,t),{error:vt(`${e}:error`,t),trace:r,newScope:n=>ee(`${e}:${n}`,t)})}function Ls(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var To={};St(To,{base36:()=>He,base36upper:()=>Mf});var He=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mf=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ff=Os,Ps=128,qf=127,$f=~qf,Hf=Math.pow(2,31);function Os(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Hf;)t[r++]=e&255|Ps,e/=128;for(;e&$f;)t[r++]=e&255|Ps,e>>>=7;return t[r]=e|0,Os.bytes=r-n+1,t}var zf=Bo,Zf=128,Ns=127;function Bo(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Bo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Ns)<<o:(s&Ns)*Math.pow(2,o),o+=7}while(s>=Zf);return Bo.bytes=i-n,r}var Gf=Math.pow(2,7),jf=Math.pow(2,14),Yf=Math.pow(2,21),Wf=Math.pow(2,28),Xf=Math.pow(2,35),Jf=Math.pow(2,42),Qf=Math.pow(2,49),tl=Math.pow(2,56),el=Math.pow(2,63),rl=function(e){return e<Gf?1:e<jf?2:e<Yf?3:e<Wf?4:e<Xf?5:e<Jf?6:e<Qf?7:e<tl?8:e<el?9:10},nl={encode:Ff,decode:zf,encodingLength:rl},ol=nl,Sr=ol;function vr(e,t=0){return[Sr.decode(e,t),Sr.decode.bytes]}function ze(e,t,r=0){return Sr.encode(e,t,r),t}function Ze(e){return Sr.encodingLength(e)}function jt(e,t){let r=t.byteLength,n=Ze(e),o=n+Ze(r),i=new Uint8Array(o+r);return ze(e,i,0),ze(r,i,n),i.set(t,o),new Ge(e,r,t,i)}function Te(e){let t=te(e),[r,n]=vr(t),[o,i]=vr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ge(r,o,s,t)}function ks(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Is(e.bytes,r.bytes)}}var Ge=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Ks(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return sl(r,_o(e),t??W.encoder);default:return al(r,_o(e),t??Gt.encoder)}}var Vs=new WeakMap;function _o(e){let t=Vs.get(e);if(t==null){let r=new Map;return Vs.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!==Ar)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==cl)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=jt(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&&ks(t.multihash,n.multihash)}toString(t){return Ks(this,t)}toJSON(){return{"/":Ks(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??Ms(n,o,i.bytes))}else if(r[ul]===!0){let{version:n,multihash:o,code:i}=r,s=Te(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!==Ar)throw new Error(`Version 0 CID must use dag-pb (code: ${Ar}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ms(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Ar,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=te(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 Ge(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,y]=vr(t.subarray(r));return r+=y,l},o=n(),i=Ar;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]=il(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 _o(i).set(n,t),i}};function il(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 Gt.prefix:{let r=t??Gt;return[Gt.prefix,r.decode(e)]}case He.prefix:{let r=t??He;return[He.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 sl(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 al(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 Ar=112,cl=18;function Ms(e,t,r){let n=Ze(e),o=n+Ze(t),i=new Uint8Array(o+r.byteLength);return ze(e,i,0),ze(t,i,n),i.set(r,o),i}var ul=Symbol.for("@ipld/js-cid/CID");var Do={};St(Do,{identity:()=>kt});var Fs=0,fl="identity",qs=te;function ll(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 jt(Fs,qs(e))}var kt={code:Fs,name:fl,encode:qs,digest:ll};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 re(e=0){return new Uint8Array(e)}function It(e=0){return new Uint8Array(e)}function Lt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=It(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Hs=Symbol.for("@achingbrain/uint8arraylist");function $s(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 je(e){return!!e?.[Hs]}var Tt=class e{bufs;length;[Hs]=!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(je(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(je(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=$s(this.bufs,t);return r.buf[r.index]}set(t,r){let n=$s(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(je(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 Lt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Lt(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(!je(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 y=f;y>=0;y--){let v=this.get(l+y);if(n[y]!==v){u=Math.max(1,y-c[v]);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=It(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=re(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=re(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=re(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=It(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=re(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=re(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=re(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=re(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=re(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 Uo={};St(Uo,{base10:()=>dl});var dl=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var Ro={};St(Ro,{base16:()=>hl,base16upper:()=>pl});var hl=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pl=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Lo={};St(Lo,{base2:()=>ml});var ml=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Po={};St(Po,{base256emoji:()=>wl});var zs=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}"),yl=zs.reduce((e,t,r)=>(e[r]=t,e),[]),gl=zs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function xl(e){return e.reduce((t,r)=>(t+=yl[r],t),"")}function bl(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=gl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var wl=$e({prefix:"\u{1F680}",name:"base256emoji",encode:xl,decode:bl});var No={};St(No,{base8:()=>El});var El=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Oo={};St(Oo,{identity:()=>Sl});var Sl=$e({prefix:"\0",name:"identity",encode:e=>Bs(e),decode:e=>Ts(e)});var F0=new TextEncoder,q0=new TextDecoder;var Vo={};St(Vo,{sha256:()=>Cr,sha512:()=>Il});var Cl=20;function Ko({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new ko(e,t,r,n,o)}var ko=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Cl,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?Zs(n,this.code,r?.truncate):n.then(o=>Zs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Zs(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 jt(t,e)}function js(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Cr=Ko({name:"sha2-256",code:18,encode:js("SHA-256")}),Il=Ko({name:"sha2-512",code:19,encode:js("SHA-512")});var Ir={...Oo,...Lo,...No,...Uo,...Ro,...wo,...To,...Eo,...Ao,...Po},tm={...Vo,...Do};function Ws(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ys=Ws("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Mo=Ws("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=It(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Tl={utf8:Ys,"utf-8":Ys,hex:Ir.base16,latin1:Mo,ascii:Mo,binary:Mo,...Ir},dn=Tl;function H(e,t="utf8"){let r=dn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=dn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Bl=parseInt("11111",2),Fo=parseInt("10000000",2),_l=parseInt("01111111",2),Xs={0:Tr,1:Tr,2:Dl,3:Ll,4:Pl,5:Rl,6:Ul,16:Tr,22:Tr,48:Tr};function ne(e,t={offset:0}){let r=e[t.offset]&Bl;if(t.offset++,Xs[r]!=null)return Xs[r](e,t);throw new Error("No decoder for tag "+r)}function Br(e,t){let r=0;if((e[t.offset]&Fo)===Fo){let n=e[t.offset]&_l,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 Tr(e,t){Br(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=ne(e,t);if(n===null)break;r.push(n)}return r}function Dl(e,t){let r=Br(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 Ul(e,t){let r=Br(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 Rl(e,t){return t.offset++,null}function Ll(e,t){let r=Br(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 Pl(e,t){let r=Br(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Nl(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Tt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function qo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Nl(e.byteLength);return new Tt(Uint8Array.from([t.byteLength|Fo]),t)}function At(e){let t=new Tt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Tt(Uint8Array.from([2]),qo(t),t)}function hn(e){let t=Uint8Array.from([0]),r=new Tt(t,e);return new Tt(Uint8Array.from([3]),qo(r),r)}function me(e,t=48){let r=new Tt;for(let n of e)r.append(n);return new Tt(Uint8Array.from([t]),qo(r),r)}async function Js(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 Ol=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),kl=Uint8Array.from([6,5,43,129,4,0,34]),Kl=Uint8Array.from([6,5,43,129,4,0,35]),Vl={ext:!0,kty:"EC",crv:"P-256"},Ml={ext:!0,kty:"EC",crv:"P-384"},Fl={ext:!0,kty:"EC",crv:"P-521"},$o=32,Ho=48,zo=66;function Zo(e){let t=ne(e);return Qs(t)}function Qs(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===$o*2+1)return n=z(t.subarray(r,r+$o),"base64url"),o=z(t.subarray(r+$o),"base64url"),new Ye({...Vl,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ho*2+1)return n=z(t.subarray(r,r+Ho),"base64url"),o=z(t.subarray(r+Ho),"base64url"),new Ye({...Ml,key_ops:["verify"],x:n,y:o});if(t.byteLength===zo*2+1)return n=z(t.subarray(r,r+zo),"base64url"),o=z(t.subarray(r+zo),"base64url"),new Ye({...Fl,key_ops:["verify"],x:n,y:o});throw new st(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ta(e){return me([At(Uint8Array.from([1])),me([ql(e.crv)],160),me([hn(new Tt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function ql(e){if(e==="P-256")return Ol;if(e==="P-384")return kl;if(e==="P-521")return Kl;throw new st(`Invalid curve ${e}`)}var Ye=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ta(this.jwk)),this._raw}toMultihash(){return kt.digest(We(this))}toCID(){return j.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 Js(this.jwk,r,t,n)}};function _e(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function $(e,t,r=""){let n=_e(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 pn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Yt(e.outputLen),Yt(e.blockLen)}function Xe(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 ra(e,t){$(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 ie(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Kt(e,t){return e<<32-t|e>>>t}var na=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",$l=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function se(e){if($(e),na)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=$l[e[r]];return t}var oe={_0:48,_9:57,A:65,F:70,a:97,f:102};function ea(e){if(e>=oe._0&&e<=oe._9)return e-oe._0;if(e>=oe.A&&e<=oe.F)return e-(oe.A-10);if(e>=oe.a&&e<=oe.f)return e-(oe.a-10)}function ae(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(na)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=ea(e.charCodeAt(i)),c=ea(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];$(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 Go(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 Je(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 jo=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function oa(e,t,r){return e&t^~e&r}function ia(e,t,r){return e&t^e&r^t&r}var _r=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=mn(this.buffer)}update(t){Xe(this),$(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=mn(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){Xe(this),ra(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ie(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=mn(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()}},ce=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 yn=BigInt(4294967295),sa=BigInt(32);function Hl(e,t=!1){return t?{h:Number(e&yn),l:Number(e>>sa&yn)}:{h:Number(e>>sa&yn)|0,l:Number(e&yn)|0}}function aa(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}=Hl(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var Yo=(e,t,r)=>e>>>r,Wo=(e,t,r)=>e<<32-r|t>>>r,De=(e,t,r)=>e>>>r|t<<32-r,Ue=(e,t,r)=>e<<32-r|t>>>r,Dr=(e,t,r)=>e<<64-r|t>>>r-32,Ur=(e,t,r)=>e>>>r-32|t<<64-r;function Wt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ca=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),ua=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,fa=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),la=(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),ha=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Zl=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]),ye=new Uint32Array(64),Xo=class extends _r{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)ye[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let y=ye[l-15],v=ye[l-2],x=Kt(y,7)^Kt(y,18)^y>>>3,I=Kt(v,17)^Kt(v,19)^v>>>10;ye[l]=I+ye[l-7]+x+ye[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 y=Kt(c,6)^Kt(c,11)^Kt(c,25),v=u+y+oa(c,a,f)+Zl[l]+ye[l]|0,I=(Kt(n,2)^Kt(n,13)^Kt(n,22))+ia(n,o,i)|0;u=f,f=a,a=c,c=s+v|0,s=i,i=o,o=n,n=v+I|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(){ie(ye)}destroy(){this.set(0,0,0,0,0,0,0,0),ie(this.buffer)}},Jo=class extends Xo{A=ce[0]|0;B=ce[1]|0;C=ce[2]|0;D=ce[3]|0;E=ce[4]|0;F=ce[5]|0;G=ce[6]|0;H=ce[7]|0;constructor(){super(32)}};var pa=aa(["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))),Gl=pa[0],jl=pa[1],ge=new Uint32Array(80),xe=new Uint32Array(80),Qo=class extends _r{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:y,Gh:v,Gl:x,Hh:I,Hl:C}=this;return[t,r,n,o,i,s,c,a,f,u,l,y,v,x,I,C]}set(t,r,n,o,i,s,c,a,f,u,l,y,v,x,I,C){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=y|0,this.Gh=v|0,this.Gl=x|0,this.Hh=I|0,this.Hl=C|0}process(t,r){for(let S=0;S<16;S++,r+=4)ge[S]=t.getUint32(r),xe[S]=t.getUint32(r+=4);for(let S=16;S<80;S++){let P=ge[S-15]|0,k=xe[S-15]|0,M=De(P,k,1)^De(P,k,8)^Yo(P,k,7),V=Ue(P,k,1)^Ue(P,k,8)^Wo(P,k,7),h=ge[S-2]|0,p=xe[S-2]|0,_=De(h,p,19)^Dr(h,p,61)^Yo(h,p,6),D=Ue(h,p,19)^Ur(h,p,61)^Wo(h,p,6),A=fa(V,D,xe[S-7],xe[S-16]),m=la(A,M,_,ge[S-7],ge[S-16]);ge[S]=m|0,xe[S]=A|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:y,Fh:v,Fl:x,Gh:I,Gl:C,Hh:w,Hl:T}=this;for(let S=0;S<80;S++){let P=De(l,y,14)^De(l,y,18)^Dr(l,y,41),k=Ue(l,y,14)^Ue(l,y,18)^Ur(l,y,41),M=l&v^~l&I,V=y&x^~y&C,h=da(T,k,V,jl[S],xe[S]),p=ha(h,w,P,M,Gl[S],ge[S]),_=h|0,D=De(n,o,28)^Dr(n,o,34)^Dr(n,o,39),A=Ue(n,o,28)^Ur(n,o,34)^Ur(n,o,39),m=n&i^n&c^i&c,g=o&s^o&a^s&a;w=I|0,T=C|0,I=v|0,C=x|0,v=l|0,x=y|0,{h:l,l:y}=Wt(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=ca(_,A,g);n=ua(d,p,D,m),o=d|0}({h:n,l:o}=Wt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Wt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=Wt(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=Wt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:y}=Wt(this.Eh|0,this.El|0,l|0,y|0),{h:v,l:x}=Wt(this.Fh|0,this.Fl|0,v|0,x|0),{h:I,l:C}=Wt(this.Gh|0,this.Gl|0,I|0,C|0),{h:w,l:T}=Wt(this.Hh|0,this.Hl|0,w|0,T|0),this.set(n,o,i,s,c,a,f,u,l,y,v,x,I,C,w,T)}roundClean(){ie(ge,xe)}destroy(){ie(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ti=class extends Qo{Ah=dt[0]|0;Al=dt[1]|0;Bh=dt[2]|0;Bl=dt[3]|0;Ch=dt[4]|0;Cl=dt[5]|0;Dh=dt[6]|0;Dl=dt[7]|0;Eh=dt[8]|0;El=dt[9]|0;Fh=dt[10]|0;Fl=dt[11]|0;Gh=dt[12]|0;Gl=dt[13]|0;Hh=dt[14]|0;Hl=dt[15]|0;constructor(){super(64)}};var Qe=Go(()=>new Jo,jo(1));var ma=Go(()=>new ti,jo(3));var ri=BigInt(0),ei=BigInt(1);function ue(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function ya(e){if(typeof e=="bigint"){if(!gn(e))throw new Error("positive bigint expected, got "+e)}else Yt(e);return e}function Rr(e){let t=ya(e).toString(16);return t.length&1?"0"+t:t}function ga(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ri:BigInt("0x"+e)}function tr(e){return ga(se(e))}function Re(e){return ga(se(bn($(e)).reverse()))}function xn(e,t){Yt(t),e=ya(e);let r=ae(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function ni(e,t){return xn(e,t).reverse()}function bn(e){return Uint8Array.from(e)}var gn=e=>typeof e=="bigint"&&ri<=e;function Yl(e,t,r){return gn(e)&&gn(t)&&gn(r)&&t<=e&&e<r}function Lr(e,t,r,n){if(!Yl(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function oi(e){let t;for(t=0;e>ri;e>>=ei,t+=1);return t}var Pr=e=>(ei<<BigInt(e))-ei;function xa(e,t,r){if(Yt(e,"hashLen"),Yt(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=C=>new Uint8Array(C),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},y=(...C)=>r(f,Ct(a,...C)),v=(C=o)=>{f=y(i,C),a=y(),C.length!==0&&(f=y(s,C),a=y())},x=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let C=0,w=[];for(;C<t;){a=y();let T=a.slice();w.push(T),C+=a.length}return Ct(...w)};return(C,w)=>{l(),v(C);let T;for(;!(T=w(x()));)v();return l(),T}}function be(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 er(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),at=BigInt(1),Le=BigInt(2),Ea=BigInt(3),Sa=BigInt(4),va=BigInt(5),Wl=BigInt(7),Aa=BigInt(8),Xl=BigInt(9),Ca=BigInt(16);function ot(e,t){let r=e%t;return r>=wt?r:t+r}function X(e,t,r){let n=e;for(;t-- >wt;)n*=n,n%=r;return n}function ba(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=ot(e,t),n=t,o=wt,i=at,s=at,c=wt;for(;r!==wt;){let f=n/r,u=n%r,l=o-s*f,y=i-c*f;n=r,r=u,o=s,i=c,s=l,c=y}if(n!==at)throw new Error("invert: does not exist");return ot(o,t)}function si(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Ia(e,t){let r=(e.ORDER+at)/Sa,n=e.pow(t,r);return si(e,n,t),n}function Jl(e,t){let r=(e.ORDER-va)/Aa,n=e.mul(t,Le),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Le),o),c=e.mul(i,e.sub(s,e.ONE));return si(e,c,t),c}function Ql(e){let t=rr(e),r=Ta(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Wl)/Ca;return(c,a)=>{let f=c.pow(a,s),u=c.mul(f,n),l=c.mul(f,o),y=c.mul(f,i),v=c.eql(c.sqr(u),a),x=c.eql(c.sqr(l),a);f=c.cmov(f,u,v),u=c.cmov(y,l,x);let I=c.eql(c.sqr(u),a),C=c.cmov(f,u,I);return si(c,C,a),C}}function Ta(e){if(e<Ea)throw new Error("sqrt is not defined for small field");let t=e-at,r=0;for(;t%Le===wt;)t/=Le,r++;let n=Le,o=rr(e);for(;wa(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ia;let i=o.pow(n,t),s=(t+at)/Le;return function(a,f){if(a.is0(f))return f;if(wa(a,f)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,i),y=a.pow(f,t),v=a.pow(f,s);for(;!a.eql(y,a.ONE);){if(a.is0(y))return a.ZERO;let x=1,I=a.sqr(y);for(;!a.eql(I,a.ONE);)if(x++,I=a.sqr(I),x===u)throw new Error("Cannot find square root");let C=at<<BigInt(u-x-1),w=a.pow(l,C);u=x,l=a.sqr(w),y=a.mul(y,l),v=a.mul(v,w)}return v}}function td(e){return e%Sa===Ea?Ia:e%Aa===va?Jl:e%Ca===Xl?Ql(e):Ta(e)}var Ba=(e,t)=>(ot(e,t)&at)===at,ed=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ai(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ed.reduce((n,o)=>(n[o]="function",n),t);return be(e,r),e}function rd(e,t,r){if(r<wt)throw new Error("invalid exponent, negatives unsupported");if(r===wt)return e.ONE;if(r===at)return t;let n=e.ONE,o=t;for(;r>wt;)r&at&&(n=e.mul(n,o)),o=e.sqr(o),r>>=at;return n}function Nr(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 wa(e,t){let r=(e.ORDER-at)/Le,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 nd(e,t){t!==void 0&&Yt(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var ii=class{ORDER;BITS;BYTES;isLE;ZERO=wt;ONE=at;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=wt)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}=nd(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 wt<=t&&t<this.ORDER}is0(t){return t===wt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&at)===at}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 rd(this,t,r)}div(t,r){return ot(t*ba(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 ba(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=td(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?ni(t,this.BYTES):xn(t,this.BYTES)}fromBytes(t,r=!1){$(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?Re(t):tr(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 Nr(this,t)}cmov(t,r,n){return n?r:t}};function rr(e,t={}){return new ii(e,t)}function _a(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 ci(e){let t=_a(e);return t+Math.ceil(t/2)}function ui(e,t,r=!1){$(e);let n=e.length,o=_a(t),i=ci(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Re(e):tr(e),c=ot(s,t-at)+at;return r?ni(c,o):xn(c,o)}var nr=BigInt(0),Pe=BigInt(1);function Or(e,t){let r=t.negate();return e?r:t}function Ne(e,t){let r=Nr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function La(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function fi(e,t){La(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Pr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Da(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+=Pe);let f=t*n,u=f+Math.abs(c)-1,l=c===0,y=c<0,v=t%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:y,isNegF:v,offsetF:f}}var li=new WeakMap,Pa=new WeakMap;function di(e){return Pa.get(e)||1}function Ua(e){if(e!==nr)throw new Error("invalid wNAF")}var or=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>nr;)r&Pe&&(n=n.add(o)),o=o.double(),r>>=Pe;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=fi(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=fi(t,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:f,isZero:u,isNeg:l,isNegF:y,offsetF:v}=Da(n,c,s);n=a,u?i=i.add(Or(y,r[v])):o=o.add(Or(l,r[f]))}return Ua(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=fi(t,this.bits);for(let s=0;s<i.windows&&n!==nr;s++){let{nextN:c,offset:a,isZero:f,isNeg:u}=Da(n,s,i);if(n=c,!f){let l=r[a];o=o.add(u?l.negate():l)}}return Ua(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=di(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=di(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){La(r,this.bits),Pa.set(t,r),li.delete(t)}hasCache(t){return di(t)!==1}};function Na(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>nr||n>nr;)r&Pe&&(i=i.add(o)),n&Pe&&(s=s.add(o)),o=o.double(),r>>=Pe,n>>=Pe;return{p1:i,p2:s}}function Ra(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ai(t),t}else return rr(e,{isLE:r})}function wn(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>nr))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Ra(t.p,r.Fp,n),i=Ra(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 En(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var we=BigInt(0),ct=BigInt(1),hi=BigInt(2),od=BigInt(8);function id(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 Oa(e,t={}){let r=wn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;be(t,{},{uvRatio:"function"});let c=hi<<BigInt(o.BYTES*8)-ct,a=C=>n.create(C),f=t.uvRatio||((C,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(C,w))}}catch{return{isValid:!1,value:we}}});if(!id(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(C,w,T=!1){let S=T?ct:we;return Lr("coordinate "+C,w,S,c),w}function l(C){if(!(C instanceof x))throw new Error("EdwardsPoint expected")}let y=er((C,w)=>{let{X:T,Y:S,Z:P}=C,k=C.is0();w==null&&(w=k?od:n.inv(P));let M=a(T*w),V=a(S*w),h=n.mul(P,w);if(k)return{x:we,y:ct};if(h!==ct)throw new Error("invZ was invalid");return{x:M,y:V}}),v=er(C=>{let{a:w,d:T}=i;if(C.is0())throw new Error("bad point: ZERO");let{X:S,Y:P,Z:k,T:M}=C,V=a(S*S),h=a(P*P),p=a(k*k),_=a(p*p),D=a(V*w),A=a(p*a(D+h)),m=a(_+a(T*a(V*h)));if(A!==m)throw new Error("bad point: equation left != right (1)");let g=a(S*P),d=a(k*M);if(g!==d)throw new Error("bad point: equation left != right (2)");return!0});class x{static BASE=new x(i.Gx,i.Gy,ct,a(i.Gx*i.Gy));static ZERO=new x(we,ct,ct,we);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,T,S,P){this.X=u("x",w),this.Y=u("y",T),this.Z=u("z",S,!0),this.T=u("t",P),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof x)throw new Error("extended point not allowed");let{x:T,y:S}=w||{};return u("x",T),u("y",S),new x(T,S,ct,a(T*S))}static fromBytes(w,T=!1){let S=n.BYTES,{a:P,d:k}=i;w=bn($(w,S,"point")),ue(T,"zip215");let M=bn(w),V=w[S-1];M[S-1]=V&-129;let h=Re(M),p=T?c:n.ORDER;Lr("point.y",h,we,p);let _=a(h*h),D=a(_-ct),A=a(k*_-P),{isValid:m,value:g}=f(D,A);if(!m)throw new Error("bad point: invalid y coordinate");let d=(g&ct)===ct,E=(V&128)!==0;if(!T&&g===we&&E)throw new Error("bad point: x=0 and x_0=1");return E!==d&&(g=a(-g)),x.fromAffine({x:g,y:h})}static fromHex(w,T=!1){return x.fromBytes(ae(w),T)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,T=!0){return I.createCache(this,w),T||this.multiply(hi),this}assertValidity(){v(this)}equals(w){l(w);let{X:T,Y:S,Z:P}=this,{X:k,Y:M,Z:V}=w,h=a(T*V),p=a(k*P),_=a(S*V),D=a(M*P);return h===p&&_===D}is0(){return this.equals(x.ZERO)}negate(){return new x(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:w}=i,{X:T,Y:S,Z:P}=this,k=a(T*T),M=a(S*S),V=a(hi*a(P*P)),h=a(w*k),p=T+S,_=a(a(p*p)-k-M),D=h+M,A=D-V,m=h-M,g=a(_*A),d=a(D*m),E=a(_*m),U=a(A*D);return new x(g,d,U,E)}add(w){l(w);let{a:T,d:S}=i,{X:P,Y:k,Z:M,T:V}=this,{X:h,Y:p,Z:_,T:D}=w,A=a(P*h),m=a(k*p),g=a(V*S*D),d=a(M*_),E=a((P+k)*(h+p)-A-m),U=d-g,R=d+g,N=a(m-T*A),O=a(E*U),K=a(R*N),q=a(E*N),tt=a(U*R);return new x(O,K,tt,q)}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:T,f:S}=I.cached(this,w,P=>Ne(x,P));return Ne(x,[T,S])[0]}multiplyUnsafe(w,T=x.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===we?x.ZERO:this.is0()||w===ct?this:I.unsafe(this,w,S=>Ne(x,S),T)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return I.unsafe(this,i.n).is0()}toAffine(w){return y(this,w)}clearCofactor(){return s===ct?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:T}=this.toAffine(),S=n.toBytes(T);return S[S.length-1]|=w&ct?128:0,S}toHex(){return se(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let I=new or(x,o.BITS);return x.BASE.precompute(8),x}function ka(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');be(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||Je,a=r.adjustScalarBytes||(h=>h),f=r.domain||((h,p,_)=>{if(ue(_,"phflag"),p.length||_)throw new Error("Contexts/pre-hash are not supported");return h});function u(h){return s.create(Re(h))}function l(h){let p=S.secretKey;$(h,S.secretKey,"secretKey");let _=$(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 y(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 v(h){return y(h).pointBytes}function x(h=Uint8Array.of(),...p){let _=Ct(...p);return u(t(f(_,$(h,void 0,"context"),!!n)))}function I(h,p,_={}){h=$(h,void 0,"message"),n&&(h=n(h));let{prefix:D,scalar:A,pointBytes:m}=y(p),g=x(_.context,D,h),d=o.multiply(g).toBytes(),E=x(_.context,d,m,h),U=s.create(g+E*A);if(!s.isValid(U))throw new Error("sign failed: invalid s");let R=Ct(d,s.toBytes(U));return $(R,S.signature,"result")}let C={zip215:!0};function w(h,p,_,D=C){let{context:A,zip215:m}=D,g=S.signature;h=$(h,g,"signature"),p=$(p,void 0,"message"),_=$(_,S.publicKey,"publicKey"),m!==void 0&&ue(m,"zip215"),n&&(p=n(p));let d=g/2,E=h.subarray(0,d),U=Re(h.subarray(d,g)),R,N,O;try{R=e.fromBytes(_,m),N=e.fromBytes(E,m),O=o.multiplyUnsafe(U)}catch{return!1}if(!m&&R.isSmallOrder())return!1;let K=x(A,N.toBytes(),R.toBytes(),p);return N.add(R.multiplyUnsafe(K)).subtract(O).clearCofactor().is0()}let T=i.BYTES,S={secretKey:T,publicKey:T,signature:2*T,seed:T};function P(h=c(S.seed)){return $(h,S.seed,"seed")}function k(h){return _e(h)&&h.length===s.BYTES}function M(h,p){try{return!!e.fromBytes(h,p)}catch{return!1}}let V={getExtendedPublicKey:y,randomSecretKey:P,isValidSecretKey:k,isValidPublicKey:M,toMontgomery(h){let{y:p}=e.fromBytes(h),_=S.publicKey,D=_===32;if(!D&&_!==57)throw new Error("only defined for 25519 and 448");let A=D?i.div(ct+p,ct-p):i.div(p-ct,p+ct);return i.toBytes(A)},toMontgomerySecret(h){let p=S.secretKey;$(h,p);let _=t(h.subarray(0,p));return a(_).subarray(0,p)}};return Object.freeze({keygen:En(P,v),getPublicKey:v,sign:I,verify:w,utils:V,Point:e,lengths:S})}var sd=BigInt(1),Ka=BigInt(2);var ad=BigInt(5),cd=BigInt(8),pi=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ud={p:pi,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:cd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function fd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=pi,c=e*e%i*e%i,a=X(c,Ka,i)*c%i,f=X(a,sd,i)*e%i,u=X(f,ad,i)*f%i,l=X(u,t,i)*u%i,y=X(l,r,i)*l%i,v=X(y,n,i)*y%i,x=X(v,o,i)*v%i,I=X(x,o,i)*v%i,C=X(I,t,i)*u%i;return{pow_p_5_8:X(C,Ka,i)*e%i,b2:c}}function ld(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Va=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function dd(e,t){let r=pi,n=ot(t*t*t,r),o=ot(n*n*t,r),i=fd(e*o).pow_p_5_8,s=ot(e*n*i,r),c=ot(t*s*s,r),a=s,f=ot(s*Va,r),u=c===e,l=c===ot(-e,r),y=c===ot(-e*Va,r);return u&&(s=a),(l||y)&&(s=f),Ba(s,r)&&(s=ot(-s,r)),{isValid:u||l,value:s}}var hd=Oa(ud,{uvRatio:dd});function pd(e){return ka(hd,ma,Object.assign({adjustScalarBytes:ld},e))}var Ma=pd({});var kr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Sn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Fa={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Sn("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 Pt=Fa;var vn=32;var mi,md=(async()=>{try{return await Pt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function yd(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Pt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Pt.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 gd(e,t,r){return Ma.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function qa(e,t,r){return mi==null&&(mi=await md),mi?yd(e,t,r):gd(e,t,r)}function An(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Cn=class{type="Ed25519";raw;constructor(t){this.raw=yi(t,vn)}toMultihash(){return kt.digest(We(this))}toCID(){return j.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=qa(this.raw,r,t);return An(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function gi(e){return e=yi(e,vn),new Cn(e)}function yi(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 bd=Math.pow(2,7),wd=Math.pow(2,14),Ed=Math.pow(2,21),xi=Math.pow(2,28),bi=Math.pow(2,35),wi=Math.pow(2,42),Ei=Math.pow(2,49),Q=128,gt=127;function Xt(e){if(e<bd)return 1;if(e<wd)return 2;if(e<Ed)return 3;if(e<xi)return 4;if(e<bi)return 5;if(e<wi)return 6;if(e<Ei)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Kr(e,t,r=0){switch(Xt(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 Si(e,t){let r=e[t],n=0;if(n+=r>,r<Q||(r=e[t+1],n+=(r>)<<7,r<Q)||(r=e[t+2],n+=(r>)<<14,r<Q)||(r=e[t+3],n+=(r>)<<21,r<Q)||(r=e[t+4],n+=(r>)*xi,r<Q)||(r=e[t+5],n+=(r>)*bi,r<Q)||(r=e[t+6],n+=(r>)*wi,r<Q)||(r=e[t+7],n+=(r>)*Ei,r<Q))return n;throw new RangeError("Could not decode varint")}function Sd(e,t){let r=e.get(t),n=0;if(n+=r>,r<Q||(r=e.get(t+1),n+=(r>)<<7,r<Q)||(r=e.get(t+2),n+=(r>)<<14,r<Q)||(r=e.get(t+3),n+=(r>)<<21,r<Q)||(r=e.get(t+4),n+=(r>)*xi,r<Q)||(r=e.get(t+5),n+=(r>)*bi,r<Q)||(r=e.get(t+6),n+=(r>)*wi,r<Q)||(r=e.get(t+7),n+=(r>)*Ei,r<Q))return n;throw new RangeError("Could not decode varint")}function vi(e,t=0){return e instanceof Uint8Array?Si(e,t):Sd(e,t)}var Ai=new Float32Array([-0]),Ee=new Uint8Array(Ai.buffer);function Ha(e,t,r){Ai[0]=e,t[r]=Ee[0],t[r+1]=Ee[1],t[r+2]=Ee[2],t[r+3]=Ee[3]}function za(e,t){return Ee[0]=e[t],Ee[1]=e[t+1],Ee[2]=e[t+2],Ee[3]=e[t+3],Ai[0]}var Ci=new Float64Array([-0]),xt=new Uint8Array(Ci.buffer);function Za(e,t,r){Ci[0]=e,t[r]=xt[0],t[r+1]=xt[1],t[r+2]=xt[2],t[r+3]=xt[3],t[r+4]=xt[4],t[r+5]=xt[5],t[r+6]=xt[6],t[r+7]=xt[7]}function Ga(e,t){return xt[0]=e[t],xt[1]=e[t+1],xt[2]=e[t+2],xt[3]=e[t+3],xt[4]=e[t+4],xt[5]=e[t+5],xt[6]=e[t+6],xt[7]=e[t+7],Ci[0]}var Ad=BigInt(Number.MAX_SAFE_INTEGER),Cd=BigInt(Number.MIN_SAFE_INTEGER),Bt=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 Oe;if(t<Ad&&t>Cd)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>ja&&(o=0n,++n>ja&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Oe;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):Oe}},Oe=new Bt(0,0);Oe.toBigInt=function(){return 0n};Oe.zzEncode=Oe.zzDecode=function(){return this};Oe.length=function(){return 1};var ja=4294967296n;function Ya(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 Wa(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 Ii(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 Vt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function In(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ti=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,Vt(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 Vt(this,4);return In(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Vt(this,4);return In(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Vt(this,4);let t=za(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Vt(this,4);let t=Ga(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 Vt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Wa(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Vt(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 Bt(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 Vt(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 Vt(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 Vt(this,8);let t=In(this.buf,this.pos+=4),r=In(this.buf,this.pos+=4);return new Bt(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=Si(this.buf,this.pos);return this.pos+=Xt(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 Bi(e){return new Ti(e instanceof Uint8Array?e:e.subarray())}function ir(e,t,r){let n=Bi(e);return t.decode(n,void 0,r)}function _i(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return It(s);o+s>t&&(n=It(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var ke=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Di(){}var Ri=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Id=_i();function Td(e){return globalThis.Buffer!=null?It(e):Id(e)}var Mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ke(Di,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new ke(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Li((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(Tn,10,Bt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Bt.fromBigInt(t);return this._push(Tn,r.length(),r)}uint64Number(t){return this._push(Kr,Xt(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=Bt.fromBigInt(t).zzEncode();return this._push(Tn,r.length(),r)}sint64Number(t){let r=Bt.fromNumber(t).zzEncode();return this._push(Tn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ui,1,t?1:0)}fixed32(t){return this._push(Vr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Bt.fromBigInt(t);return this._push(Vr,4,r.lo)._push(Vr,4,r.hi)}fixed64Number(t){let r=Bt.fromNumber(t);return this._push(Vr,4,r.lo)._push(Vr,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(Ha,4,t)}double(t){return this._push(Za,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Ui,1,0):this.uint32(r)._push(_d,r,t)}string(t){let r=Ya(t);return r!==0?this.uint32(r)._push(Ii,r,t):this._push(Ui,1,0)}fork(){return this.states=new Ri(this),this.head=this.tail=new ke(Di,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 ke(Di,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=Td(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Ui(e,t,r){t[r]=e&255}function Bd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Li=class extends ke{next;constructor(t,r){super(Bd,t,r),this.next=void 0}};function Tn(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 Vr(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 _d(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Mr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Dd,t,e),this},Mr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Ud,t,e),this});function Dd(e,t,r){t.set(e,r)}function Ud(e,t,r){e.length<40?Ii(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Pi(){return new Mr}function sr(e,t){let r=Pi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ar;(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"})(ar||(ar={}));function Bn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Fr(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 Bn("enum",ar.VARINT,r,n)}function cr(e,t){return Bn("message",ar.LENGTH_DELIMITED,e,t)}var it;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(it||(it={}));var Ni;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Ni||(Ni={}));(function(e){e.codec=()=>Fr(Ni)})(it||(it={}));var Jt;(function(e){let t;e.codec=()=>(t==null&&(t=cr((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=>sr(r,e.codec()),e.decode=(r,n)=>ir(r,e.codec(),n)})(Jt||(Jt={}));var Oi;(function(e){let t;e.codec=()=>(t==null&&(t=cr((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=>sr(r,e.codec()),e.decode=(r,n)=>ir(r,e.codec(),n)})(Oi||(Oi={}));var $r={};St($r,{MAX_RSA_KEY_SIZE:()=>ki,generateRSAKeyPair:()=>rc,jwkToJWKKeyPair:()=>nc,jwkToPkcs1:()=>Nd,jwkToPkix:()=>Fi,jwkToRSAPrivateKey:()=>zi,pkcs1MessageToJwk:()=>Vi,pkcs1MessageToRSAPrivateKey:()=>qi,pkcs1ToJwk:()=>Pd,pkcs1ToRSAPrivateKey:()=>ec,pkixMessageToJwk:()=>Mi,pkixMessageToRSAPublicKey:()=>Hi,pkixToJwk:()=>Od,pkixToRSAPublicKey:()=>$i});var ur=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return j.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 tc(this.jwk,r,t,n)}},qr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=$r.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:J(this.raw,t.raw)}sign(t,r){return Qa(this.jwk,t,r)}};var ki=8192,Ki=18,Rd=1062,Ld=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Pd(e){let t=ne(e);return Vi(t)}function Vi(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 Nd(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 me([At(Uint8Array.from([0])),At(H(e.n,"base64url")),At(H(e.e,"base64url")),At(H(e.d,"base64url")),At(H(e.p,"base64url")),At(H(e.q,"base64url")),At(H(e.dp,"base64url")),At(H(e.dq,"base64url")),At(H(e.qi,"base64url"))]).subarray()}function Od(e){let t=ne(e,{offset:0});return Mi(t)}function Mi(e){let t=ne(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function Fi(e){if(e.n==null||e.e==null)throw new st("JWK was missing components");return me([Ld,hn(me([At(H(e.n,"base64url")),At(H(e.e,"base64url"))]))]).subarray()}function ec(e){let t=ne(e);return qi(t)}function qi(e){let t=Vi(e);return zi(t)}function $i(e,t){if(e.byteLength>=Rd)throw new Me("Key size is too large");let r=ne(e,{offset:0});return Hi(r,e,t)}function Hi(e,t,r){let n=Mi(e);if(r==null){let o=Qe(Jt.encode({Type:it.RSA,Data:t}));r=jt(Ki,o)}return new ur(n,r)}function zi(e){if(ic(e)>ki)throw new st("Key size is too large");let t=nc(e),r=Qe(Jt.encode({Type:it.RSA,Data:Fi(t.publicKey)})),n=jt(Ki,r);return new qr(t.privateKey,new ur(t.publicKey,n))}async function rc(e){if(e>ki)throw new st("Key size is too large");let t=await oc(e),r=Qe(Jt.encode({Type:it.RSA,Data:Fi(t.publicKey)})),n=jt(Ki,r);return new qr(t.privateKey,new ur(t.publicKey,n))}function nc(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 oc(e,t){let r=await Pt.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 kd(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Qa(e,t,r){let n=await Pt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Pt.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 tc(e,t,r,n){let o=await Pt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Pt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function kd(e,t){if(e.privateKey==null||e.publicKey==null)throw new st("Private and public key are required");let r=await Promise.all([Pt.get().subtle.exportKey("jwk",e.privateKey),Pt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function ic(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 _n=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(pn(t),$(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),ie(o)}update(t){return Xe(this),this.iHash.update(t),this}digestInto(t){Xe(this),$(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()}},Zi=(e,t,r)=>new _n(e,t).update(r).digest();Zi.create=(e,t)=>new _n(e,t);var sc=(e,t)=>(e+(e>=0?t:-t)/ac)/t;function Kd(e,t,r){let[[n,o],[i,s]]=t,c=sc(s*e,r),a=sc(-o*e,r),f=e-c*n-a*i,u=-c*o-a*s,l=f<fe,y=u<fe;l&&(f=-f),y&&(u=-u);let v=Pr(Math.ceil(oi(r)/2))+fr;if(f<fe||f>=v||u<fe||u>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:f,k2neg:y,k2:u}}function ji(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Gi(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return ue(r.lowS,"lowS"),ue(r.prehash,"prehash"),r.format!==void 0&&ji(r.format),r}var Yi=class extends Error{constructor(t=""){super(t)}},Se={Err:Yi,_tlv:{encode:(e,t)=>{let{Err:r}=Se;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=Rr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Rr(o.length/2|128):"";return Rr(e)+i+o+t},decode(e,t){let{Err:r}=Se,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}=Se;if(e<fe)throw new t("integer: negative integers are not allowed");let r=Rr(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}=Se;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 tr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Se,o=$(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}=Se,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},fe=BigInt(0),fr=BigInt(1),ac=BigInt(2),Dn=BigInt(3),Vd=BigInt(4);function cc(e,t={}){let r=wn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;be(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=fc(n,o);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(A,m,g){let{x:d,y:E}=m.toAffine(),U=n.toBytes(d);if(ue(g,"isCompressed"),g){u();let R=!n.isOdd(E);return Ct(uc(R),U)}else return Ct(Uint8Array.of(4),U,n.toBytes(E))}function y(A){$(A,void 0,"Point");let{publicKey:m,publicKeyUncompressed:g}=f,d=A.length,E=A[0],U=A.subarray(1);if(d===m&&(E===2||E===3)){let R=n.fromBytes(U);if(!n.isValid(R))throw new Error("bad point: is not on curve, wrong x");let N=I(R),O;try{O=n.sqrt(N)}catch(tt){let Y=tt instanceof Error?": "+tt.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}u();let K=n.isOdd(O);return(E&1)===1!==K&&(O=n.neg(O)),{x:R,y:O}}else if(d===g&&E===4){let R=n.BYTES,N=n.fromBytes(U.subarray(0,R)),O=n.fromBytes(U.subarray(R,R*2));if(!C(N,O))throw new Error("bad point: is not on curve");return{x:N,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${m} or uncompressed=${g}`)}let v=t.toBytes||l,x=t.fromBytes||y;function I(A){let m=n.sqr(A),g=n.mul(m,A);return n.add(n.add(g,n.mul(A,i.a)),i.b)}function C(A,m){let g=n.sqr(m),d=I(A);return n.eql(g,d)}if(!C(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,Dn),Vd),T=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,T)))throw new Error("bad curve params: a or b");function S(A,m,g=!1){if(!n.isValid(m)||g&&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 Kd(A,a.basises,o.ORDER)}let M=er((A,m)=>{let{X:g,Y:d,Z:E}=A;if(n.eql(E,n.ONE))return{x:g,y:d};let U=A.is0();m==null&&(m=U?n.ONE:n.inv(E));let R=n.mul(g,m),N=n.mul(d,m),O=n.mul(E,m);if(U)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:R,y:N}}),V=er(A=>{if(A.is0()){if(t.allowInfinityPoint&&!n.is0(A.Y))return;throw new Error("bad point: ZERO")}let{x:m,y:g}=A.toAffine();if(!n.isValid(m)||!n.isValid(g))throw new Error("bad point: x or y not field elements");if(!C(m,g))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,g,d,E){return g=new p(n.mul(g.X,A),g.Y,g.Z),m=Or(d,m),g=Or(E,g),m.add(g)}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,g,d){this.X=S("x",m),this.Y=S("y",g,!0),this.Z=S("z",d),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){let{x:g,y:d}=m||{};if(!m||!n.isValid(g)||!n.isValid(d))throw new Error("invalid affine point");if(m instanceof p)throw new Error("projective point not allowed");return n.is0(g)&&n.is0(d)?p.ZERO:new p(g,d,n.ONE)}static fromBytes(m){let g=p.fromAffine(x($(m,void 0,"point")));return g.assertValidity(),g}static fromHex(m){return p.fromBytes(ae(m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,g=!0){return D.createCache(this,m),g||this.multiply(Dn),this}assertValidity(){V(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:g,Y:d,Z:E}=this,{X:U,Y:R,Z:N}=m,O=n.eql(n.mul(g,N),n.mul(U,E)),K=n.eql(n.mul(d,N),n.mul(R,E));return O&&K}negate(){return new p(this.X,n.neg(this.Y),this.Z)}double(){let{a:m,b:g}=i,d=n.mul(g,Dn),{X:E,Y:U,Z:R}=this,N=n.ZERO,O=n.ZERO,K=n.ZERO,q=n.mul(E,E),tt=n.mul(U,U),Y=n.mul(R,R),Z=n.mul(E,U);return Z=n.add(Z,Z),K=n.mul(E,R),K=n.add(K,K),N=n.mul(m,K),O=n.mul(d,Y),O=n.add(N,O),N=n.sub(tt,O),O=n.add(tt,O),O=n.mul(N,O),N=n.mul(Z,N),K=n.mul(d,K),Y=n.mul(m,Y),Z=n.sub(q,Y),Z=n.mul(m,Z),Z=n.add(Z,K),K=n.add(q,q),q=n.add(K,q),q=n.add(q,Y),q=n.mul(q,Z),O=n.add(O,q),Y=n.mul(U,R),Y=n.add(Y,Y),q=n.mul(Y,Z),N=n.sub(N,q),K=n.mul(Y,tt),K=n.add(K,K),K=n.add(K,K),new p(N,O,K)}add(m){P(m);let{X:g,Y:d,Z:E}=this,{X:U,Y:R,Z:N}=m,O=n.ZERO,K=n.ZERO,q=n.ZERO,tt=i.a,Y=n.mul(i.b,Dn),Z=n.mul(g,U),et=n.mul(d,R),lt=n.mul(E,N),zt=n.add(g,d),rt=n.add(U,R);zt=n.mul(zt,rt),rt=n.add(Z,et),zt=n.sub(zt,rt),rt=n.add(g,E);let yt=n.add(U,N);return rt=n.mul(rt,yt),yt=n.add(Z,lt),rt=n.sub(rt,yt),yt=n.add(d,E),O=n.add(R,N),yt=n.mul(yt,O),O=n.add(et,lt),yt=n.sub(yt,O),q=n.mul(tt,rt),O=n.mul(Y,lt),q=n.add(O,q),O=n.sub(et,q),q=n.add(et,q),K=n.mul(O,q),et=n.add(Z,Z),et=n.add(et,Z),lt=n.mul(tt,lt),rt=n.mul(Y,rt),et=n.add(et,lt),lt=n.sub(Z,lt),lt=n.mul(tt,lt),rt=n.add(rt,lt),Z=n.mul(et,rt),K=n.add(K,Z),Z=n.mul(yt,rt),O=n.mul(zt,O),O=n.sub(O,Z),Z=n.mul(zt,et),q=n.mul(yt,q),q=n.add(q,Z),new p(O,K,q)}subtract(m){return this.add(m.negate())}is0(){return this.equals(p.ZERO)}multiply(m){let{endo:g}=t;if(!o.isValidNot0(m))throw new Error("invalid scalar: out of range");let d,E,U=R=>D.cached(this,R,N=>Ne(p,N));if(g){let{k1neg:R,k1:N,k2neg:O,k2:K}=k(m),{p:q,f:tt}=U(N),{p:Y,f:Z}=U(K);E=tt.add(Z),d=h(g.beta,q,Y,R,O)}else{let{p:R,f:N}=U(m);d=R,E=N}return Ne(p,[d,E])[0]}multiplyUnsafe(m){let{endo:g}=t,d=this;if(!o.isValid(m))throw new Error("invalid scalar: out of range");if(m===fe||d.is0())return p.ZERO;if(m===fr)return d;if(D.hasCache(this))return this.multiply(m);if(g){let{k1neg:E,k1:U,k2neg:R,k2:N}=k(m),{p1:O,p2:K}=Na(p,d,U,N);return h(g.beta,O,K,E,R)}else return D.unsafe(d,m)}toAffine(m){return M(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return s===fr?!0:m?m(p,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:m}=t;return s===fr?this:m?m(p,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return ue(m,"isCompressed"),this.assertValidity(),v(p,this,m)}toHex(m=!0){return se(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,D=new or(p,t.endo?Math.ceil(_/2):_);return p.BASE.precompute(8),p}function uc(e){return Uint8Array.of(e?2:3)}function fc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Md(e,t={}){let{Fn:r}=e,n=t.randomBytes||Je,o=Object.assign(fc(e.Fp,r),{seed:ci(r.ORDER)});function i(v){try{let x=r.fromBytes(v);return r.isValidNot0(x)}catch{return!1}}function s(v,x){let{publicKey:I,publicKeyUncompressed:C}=o;try{let w=v.length;return x===!0&&w!==I||x===!1&&w!==C?!1:!!e.fromBytes(v)}catch{return!1}}function c(v=n(o.seed)){return ui($(v,o.seed,"seed"),r.ORDER)}function a(v,x=!0){return e.BASE.multiply(r.fromBytes(v)).toBytes(x)}function f(v){let{secretKey:x,publicKey:I,publicKeyUncompressed:C}=o;if(!_e(v)||"_lengths"in r&&r._lengths||x===I)return;let w=$(v,void 0,"key").length;return w===I||w===C}function u(v,x,I=!0){if(f(v)===!0)throw new Error("first arg must be private key");if(f(x)===!1)throw new Error("second arg must be public key");let C=r.fromBytes(v);return e.fromBytes(x).multiply(C).toBytes(I)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},y=En(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:y,Point:e,utils:l,lengths:o})}function lc(e,t,r={}){pn(t),be(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||Je,o=r.hmac||((g,d)=>Zi(t,g,d)),{Fp:i,Fn:s}=e,{ORDER:c,BITS:a}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:y,lengths:v}=Md(e,r),x={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},I=c*ac<i.ORDER;function C(g){let d=c>>fr;return g>d}function w(g,d){if(!s.isValidNot0(d))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return d}function T(){if(I)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function S(g,d){ji(d);let E=v.signature,U=d==="compact"?E:d==="recovered"?E+1:void 0;return $(g,U)}class P{r;s;recovery;constructor(d,E,U){if(this.r=w("r",d),this.s=w("s",E),U!=null){if(T(),![0,1,2,3].includes(U))throw new Error("invalid recovery id");this.recovery=U}Object.freeze(this)}static fromBytes(d,E=x.format){S(d,E);let U;if(E==="der"){let{r:K,s:q}=Se.toSig($(d));return new P(K,q)}E==="recovered"&&(U=d[0],E="compact",d=d.subarray(1));let R=v.signature/2,N=d.subarray(0,R),O=d.subarray(R,R*2);return new P(s.fromBytes(N),s.fromBytes(O),U)}static fromHex(d,E){return this.fromBytes(ae(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:U}=this,R=this.assertRecovery(),N=R===2||R===3?E+c:E;if(!i.isValid(N))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(N),K=e.fromBytes(Ct(uc((R&1)===0),O)),q=s.inv(N),tt=M($(d,void 0,"msgHash")),Y=s.create(-tt*q),Z=s.create(U*q),et=e.BASE.multiplyUnsafe(Y).add(K.multiplyUnsafe(Z));if(et.is0())throw new Error("invalid recovery: point at infinify");return et.assertValidity(),et}hasHighS(){return C(this.s)}toBytes(d=x.format){if(ji(d),d==="der")return ae(Se.hexFromSig(this));let{r:E,s:U}=this,R=s.toBytes(E),N=s.toBytes(U);return d==="recovered"?(T(),Ct(Uint8Array.of(this.assertRecovery()),R,N)):Ct(R,N)}toHex(d){return se(this.toBytes(d))}}let k=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let E=tr(d),U=d.length*8-a;return U>0?E>>BigInt(U):E},M=r.bits2int_modN||function(d){return s.create(k(d))},V=Pr(a);function h(g){return Lr("num < 2^"+a,g,fe,V),s.toBytes(g)}function p(g,d){return $(g,void 0,"message"),d?$(t(g),void 0,"prehashed message"):g}function _(g,d,E){let{lowS:U,prehash:R,extraEntropy:N}=Gi(E,x);g=p(g,R);let O=M(g),K=s.fromBytes(d);if(!s.isValidNot0(K))throw new Error("invalid private key");let q=[h(K),h(O)];if(N!=null&&N!==!1){let et=N===!0?n(v.secretKey):N;q.push($(et,void 0,"extraEntropy"))}let tt=Ct(...q),Y=O;function Z(et){let lt=k(et);if(!s.isValidNot0(lt))return;let zt=s.inv(lt),rt=e.BASE.multiply(lt).toAffine(),yt=s.create(rt.x);if(yt===fe)return;let sn=s.create(zt*s.create(Y+yt*K));if(sn===fe)return;let ws=(rt.x===yt?0:2)|Number(rt.y&fr),Es=sn;return U&&C(sn)&&(Es=s.neg(sn),ws^=1),new P(yt,Es,I?void 0:ws)}return{seed:tt,k2sig:Z}}function D(g,d,E={}){let{seed:U,k2sig:R}=_(g,d,E);return xa(t.outputLen,s.BYTES,o)(U,R).toBytes(E.format)}function A(g,d,E,U={}){let{lowS:R,prehash:N,format:O}=Gi(U,x);if(E=$(E,void 0,"publicKey"),d=p(d,N),!_e(g)){let K=g instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}S(g,O);try{let K=P.fromBytes(g,O),q=e.fromBytes(E);if(R&&K.hasHighS())return!1;let{r:tt,s:Y}=K,Z=M(d),et=s.inv(Y),lt=s.create(Z*et),zt=s.create(tt*et),rt=e.BASE.multiplyUnsafe(lt).add(q.multiplyUnsafe(zt));return rt.is0()?!1:s.create(rt.x)===tt}catch{return!1}}function m(g,d,E={}){let{prehash:U}=Gi(E,x);return d=p(d,U),P.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:y,lengths:v,Point:e,sign:D,verify:A,recoverPublicKey:m,Signature:P,hash:t})}var Xi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Fd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var dc=BigInt(2);function qd(e){let t=Xi.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=X(u,r,t)*u%t,y=X(l,r,t)*u%t,v=X(y,dc,t)*f%t,x=X(v,o,t)*v%t,I=X(x,i,t)*x%t,C=X(I,c,t)*I%t,w=X(C,a,t)*C%t,T=X(w,c,t)*I%t,S=X(T,r,t)*u%t,P=X(S,s,t)*x%t,k=X(P,n,t)*f%t,M=X(k,dc,t);if(!Wi.eql(Wi.sqr(M),e))throw new Error("Cannot find square root");return M}var Wi=rr(Xi.p,{sqrt:qd}),$d=cc(Xi,{Fp:Wi,endo:Fd}),lr=lc($d,Qe);function hc(e,t,r,n){let o=Cr.digest(r instanceof Uint8Array?r:r.subarray());if(An(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),lr.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new kr(String(i))});try{return n?.signal?.throwIfAborted(),lr.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new kr(String(i))}}var Un=class{type="secp256k1";raw;_key;constructor(t){this._key=mc(t),this.raw=pc(this._key)}toMultihash(){return kt.digest(We(this))}toCID(){return j.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 hc(this._key,r,t,n)}};function Ji(e){return new Un(e)}function pc(e){return lr.Point.fromBytes(e).toBytes()}function mc(e){try{return lr.Point.fromBytes(e),e}catch(t){throw new Me(String(t))}}function yc(e,t){let{Type:r,Data:n}=Jt.decode(e),o=n??new Uint8Array;switch(r){case it.RSA:return $i(o,t);case it.Ed25519:return gi(o);case it.secp256k1:return Ji(o);case it.ECDSA:return Zo(o);default:throw new qe}}function Rn(e){let{Type:t,Data:r}=Jt.decode(e.digest),n=r??new Uint8Array;switch(t){case it.Ed25519:return gi(n);case it.secp256k1:return Ji(n);case it.ECDSA:return Zo(n);default:throw new qe}}function We(e){return Jt.encode({Type:it[e.type],Data:e.raw})}var gc=Symbol.for("nodejs.util.inspect.custom"),Hd=114,Hr=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()})`}[mo]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return j.createV1(Hd,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")}[gc](){return`PeerId(${this.toString()})`}},Ln=class extends Hr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Pn=class extends Hr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Nn=class extends Hr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},zd=2336,zr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=kt.digest(H(this.url))}[gc](){return`PeerId(${this.url})`}[mo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return j.createV1(zd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=z(t)),t.toString()===this.toString())}};var Zd=114,xc=2336;function bc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Te(W.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Gd(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=Te(t.decode(e))}return wc(r)}function wc(e){if(Yd(e))return new Ln({multihash:e});if(jd(e))try{let t=Rn(e);if(t.type==="Ed25519")return new Pn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Nn({multihash:e,publicKey:t})}catch{let r=z(e.digest);return new zr(new URL(r))}throw new Fe("Supplied PeerID Multihash is invalid")}function Gd(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Zd&&e.code!==xc)throw new cn("Supplied PeerID CID is invalid");if(e.code===xc){let t=z(e.multihash.digest);return new zr(new URL(t))}return wc(e.multihash)}function jd(e){return e.code===kt.code}function Yd(e){return e.code===Cr.code}var ht=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},le=class extends Error{static name="ValidationError";name="ValidationError"},On=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},kn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Kn=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 y=Number.parseInt(l,t);if(!Number.isNaN(y))return y});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 Wd=45,Xd=15,Vn=new Kn;function Ec(e){if(!(e.length>Xd))return Vn.new(e).parseWith(()=>Vn.readIPv4Addr())}function Sc(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Wd))return Vn.new(e).parseWith(()=>Vn.readIPv6Addr())}function Mn(e){return!!Ec(e)}function vc(e){return!!Sc(e)}function ts(e){return t=>z(t,e)}function es(e){return t=>H(t,e)}function dr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Ke(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Ac(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=Ke(n);return Lt([r,o],r.length+o.length)}function Cc(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=Gt.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=Ke(n);return Lt([r,o],r.length+o.length)}function rs(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=z(t,"base32"),o=dr(r);return`${n}:${o}`}var ns=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},Ic=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Mn(r[n]),s;i&&(s=ns(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 ht("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},Tc=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(".")},Bc=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 _c(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 Qi=Object.values(Ir).map(e=>e.decoder),Jd=(function(){let e=Qi[0].or(Qi[1]);return Qi.slice(2).forEach(t=>e=e.or(t)),e})();function Dc(e){return Jd.decode(e)}function Uc(e){return t=>e.encoder.encode(t)}function Qd(e){if(parseInt(e).toString()!==e)throw new le("Value must be an integer")}function th(e){if(e<0)throw new le("Value must be a positive integer, or zero")}function eh(e){return t=>{if(t>e)throw new le(`Value must be smaller than or equal to ${e}`)}}function rh(...e){return t=>{for(let r of e)r(t)}}var Zr=rh(Qd,th,eh(65535));var ut=-1,os=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 kn(`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)}))}},de=new os,$h=[{code:4,name:"ip4",size:32,valueToBytes:ns,bytesToValue:Tc,validate:e=>{if(!Mn(e))throw new le(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:273,name:"udp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:33,name:"dccp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:41,name:"ip6",size:128,valueToBytes:Ic,bytesToValue:Bc,stringToValue:_c,validate:e=>{if(!vc(e))throw new le(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ut},{code:43,name:"ipcidr",size:8,bytesToValue:ts("base10"),valueToBytes:es("base10")},{code:53,name:"dns",size:ut},{code:54,name:"dns4",size:ut},{code:55,name:"dns6",size:ut},{code:56,name:"dnsaddr",size:ut},{code:132,name:"sctp",size:16,valueToBytes:Ke,bytesToValue:dr,validate:Zr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ut,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ut,bytesToValue:ts("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?es("base58btc")(e):j.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:rs,valueToBytes:Ac},{code:445,name:"onion3",size:296,bytesToValue:rs,valueToBytes:Cc},{code:446,name:"garlic64",size:ut},{code:447,name:"garlic32",size:ut},{code:448,name:"tls"},{code:449,name:"sni",size:ut},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ut,bytesToValue:Uc(vo),valueToBytes:Dc},{code:480,name:"http"},{code:481,name:"http-path",size:ut,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:ut}];$h.forEach(e=>{de.addProtocol(e)});function Rc(e){let t=[],r=0;for(;r<e.length;){let n=vi(e,r),o=de.getProtocol(n),i=Xt(n),s=Hh(o,e,r+i),c=0;s>0&&o.size===ut&&(c=Xt(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 Lc(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=de.getProtocol(n.code),i=Xt(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??H(n.value),c=s.byteLength,o.size===ut&&(a=Xt(c)));let f=new Uint8Array(i+a+c),u=0;Kr(n.code,f,u),u+=i,s!=null&&(o.size===ut&&(Kr(c,f,u),u+=a),f.set(s,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Lt(r,t)}function Pc(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 c=i===e.length-1;if(s==="/"||c){let a=de.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 ht(`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 ht(`Component ${o} was missing value`);f.value=a.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ht("Incomplete multiaddr");return t}function Nc(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=de.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 Hh(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:vi(t,r)}var zh=Symbol.for("nodejs.util.inspect.custom"),is=Symbol.for("@multiformats/multiaddr");function Zh(e){if(e==null&&(e="/"),Oc(e))return e.getComponents();if(e instanceof Uint8Array)return Rc(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Pc(e);if(Array.isArray(e))return e;throw new ht("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Fn=class e{[is]=!0;#t;#n;#r;constructor(t="/",r={}){this.#t=Zh(t),r.validate!==!1&&Gh(this)}get bytes(){return this.#r==null&&(this.#r=Lc(this.#t)),this.#r}toString(){return this.#n==null&&(this.#n=Nc(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 On(`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 J(this.bytes,t.bytes)}[zh](){return`Multiaddr(${this.toString()})`}};function Gh(e){e.getComponents().forEach(t=>{let r=de.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Oc(e){return!!e?.[is]}function kc(e){return new Fn(e)}function Gr(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*qn(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 Tp=po(as(),1);var Mt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},$n=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},hr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Hn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},zn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Zn=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 Ft;(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=()=>Fr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=cr((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=>sr(o,e.codec()),e.decode=(o,i)=>ir(o,e.codec(),i)})(Ft||(Ft={}));var jh=["string","number","bigint","symbol"],Yh=["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 Kc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(jh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Wh(e))return"Buffer";let r=Xh(e);return r||"Object"}function Wh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Xh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Yh.includes(t))return t}var b=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}};b.uint=new b(0,"uint",!0);b.negint=new b(1,"negint",!0);b.bytes=new b(2,"bytes",!0);b.string=new b(3,"string",!0);b.array=new b(4,"array",!1);b.map=new b(5,"map",!1);b.tag=new b(6,"tag",!1);b.float=new b(7,"float",!0);b.false=new b(7,"false",!0);b.true=new b(7,"true",!0);b.null=new b(7,"null",!0);b.undefined=new b(7,"undefined",!0);b.break=new b(7,"break",!0);var L=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",Jh=new TextDecoder,Qh=new TextEncoder;function Gn(e){return pr&&globalThis.Buffer.isBuffer(e)}function qc(e){return e instanceof Uint8Array?Gn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var $c=pr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Mc(e,t,r):(e,t,r)=>r-t>64?Jh.decode(e.subarray(t,r)):Mc(e,t,r),Hc=pr?e=>e.length>64?globalThis.Buffer.from(e):Vc(e):e=>e.length>64?Qh.encode(e):Vc(e);var mr=pr?(e,t,r)=>Gn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),zc=pr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),qc(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},Zc=pr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Gc(e,t){if(Gn(e)&&Gn(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 Vc(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 Mc(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 Fc=4096;function tp(e){let t=e.length;if(t<=Fc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Fc));return r}var ep=256,jn=class{constructor(t=ep){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=Zc(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=mr(n,0,this.cursor)}else r=zc(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",cs="CBOR encode error:",Yr=[];Yr[23]=1;Yr[24]=2;Yr[25]=3;Yr[26]=5;Yr[27]=9;function he(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var ft=[24,256,65536,4294967296,BigInt("18446744073709551616")];function _t(e,t,r){he(e,t,1);let n=e[t];if(r.strict===!0&&n<ft[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){he(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ft[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Ut(e,t,r){he(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ft[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){he(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ft[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function jc(e,t,r,n){return new L(b.uint,_t(e,t+1,n),2)}function Yc(e,t,r,n){return new L(b.uint,Dt(e,t+1,n),3)}function Wc(e,t,r,n){return new L(b.uint,Ut(e,t+1,n),5)}function Xc(e,t,r,n){return new L(b.uint,Rt(e,t+1,n),9)}function Nt(e,t){return pt(e,0,t.value)}function pt(e,t,r){if(r<ft[0]){let n=Number(r);e.push([t|n])}else if(r<ft[1]){let n=Number(r);e.push([t|24,n])}else if(r<ft[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ft[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ft[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}Nt.encodedSize=function(t){return pt.encodedSize(t.value)};pt.encodedSize=function(t){return t<ft[0]?1:t<ft[1]?2:t<ft[2]?3:t<ft[3]?5:9};Nt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Jc(e,t,r,n){return new L(b.negint,-1-_t(e,t+1,n),2)}function Qc(e,t,r,n){return new L(b.negint,-1-Dt(e,t+1,n),3)}function tu(e,t,r,n){return new L(b.negint,-1-Ut(e,t+1,n),5)}var us=BigInt(-1),eu=BigInt(1);function ru(e,t,r,n){let o=Rt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(b.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new L(b.negint,us-BigInt(o),9)}function Yn(e,t){let r=t.value,n=typeof r=="bigint"?r*us-eu:r*-1-1;pt(e,t.type.majorEncoded,n)}Yn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*us-eu:r*-1-1;return n<ft[0]?1:n<ft[1]?2:n<ft[2]?3:n<ft[3]?5:9};Yn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Wr(e,t,r,n){he(e,t,r+n);let o=mr(e,t+r,t+r+n);return new L(b.bytes,o,r+n)}function nu(e,t,r,n){return Wr(e,t,1,r)}function ou(e,t,r,n){return Wr(e,t,2,_t(e,t+1,n))}function iu(e,t,r,n){return Wr(e,t,3,Dt(e,t+1,n))}function su(e,t,r,n){return Wr(e,t,5,Ut(e,t+1,n))}function au(e,t,r,n){let o=Rt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return Wr(e,t,9,o)}function Wn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===b.string?Hc(e.value):e.value),e.encodedBytes}function yr(e,t){let r=Wn(t);pt(e,t.type.majorEncoded,r.length),e.push(r)}yr.encodedSize=function(t){let r=Wn(t);return pt.encodedSize(r.length)+r.length};yr.compareTokens=function(t,r){return np(Wn(t),Wn(r))};function np(e,t){return e.length<t.length?-1:e.length>t.length?1:Gc(e,t)}function Xr(e,t,r,n,o){let i=r+n;he(e,t,i);let s=new L(b.string,$c(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=mr(e,t+r,t+i)),s}function cu(e,t,r,n){return Xr(e,t,1,r,n)}function uu(e,t,r,n){return Xr(e,t,2,_t(e,t+1,n),n)}function fu(e,t,r,n){return Xr(e,t,3,Dt(e,t+1,n),n)}function lu(e,t,r,n){return Xr(e,t,5,Ut(e,t+1,n),n)}function du(e,t,r,n){let o=Rt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return Xr(e,t,9,o,n)}var hu=yr;function gr(e,t,r,n){return new L(b.array,n,r)}function pu(e,t,r,n){return gr(e,t,1,r)}function mu(e,t,r,n){return gr(e,t,2,_t(e,t+1,n))}function yu(e,t,r,n){return gr(e,t,3,Dt(e,t+1,n))}function gu(e,t,r,n){return gr(e,t,5,Ut(e,t+1,n))}function xu(e,t,r,n){let o=Rt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return gr(e,t,9,o)}function bu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return gr(e,t,1,1/0)}function Xn(e,t){pt(e,b.array.majorEncoded,t.value)}Xn.compareTokens=Nt.compareTokens;Xn.encodedSize=function(t){return pt.encodedSize(t.value)};function xr(e,t,r,n){return new L(b.map,n,r)}function wu(e,t,r,n){return xr(e,t,1,r)}function Eu(e,t,r,n){return xr(e,t,2,_t(e,t+1,n))}function Su(e,t,r,n){return xr(e,t,3,Dt(e,t+1,n))}function vu(e,t,r,n){return xr(e,t,5,Ut(e,t+1,n))}function Au(e,t,r,n){let o=Rt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return xr(e,t,9,o)}function Cu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return xr(e,t,1,1/0)}function Jn(e,t){pt(e,b.map.majorEncoded,t.value)}Jn.compareTokens=Nt.compareTokens;Jn.encodedSize=function(t){return pt.encodedSize(t.value)};function Iu(e,t,r,n){return new L(b.tag,r,1)}function Tu(e,t,r,n){return new L(b.tag,_t(e,t+1,n),2)}function Bu(e,t,r,n){return new L(b.tag,Dt(e,t+1,n),3)}function _u(e,t,r,n){return new L(b.tag,Ut(e,t+1,n),5)}function Du(e,t,r,n){return new L(b.tag,Rt(e,t+1,n),9)}function Qn(e,t){pt(e,b.tag.majorEncoded,t.value)}Qn.compareTokens=Nt.compareTokens;Qn.encodedSize=function(t){return pt.encodedSize(t.value)};var up=20,fp=21,lp=22,dp=23;function Uu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(b.null,null,1):new L(b.undefined,void 0,1)}function Ru(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new L(b.break,void 0,1)}function fs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new L(b.float,e,t)}function Lu(e,t,r,n){return fs(ls(e,t+1),3,n)}function Pu(e,t,r,n){return fs(ds(e,t+1),5,n)}function Nu(e,t,r,n){return fs(Vu(e,t+1),9,n)}function to(e,t,r){let n=t.value;if(n===!1)e.push([b.float.majorEncoded|up]);else if(n===!0)e.push([b.float.majorEncoded|fp]);else if(n===null)e.push([b.float.majorEncoded|lp]);else if(n===void 0)e.push([b.float.majorEncoded|dp]);else{let o,i=!1;(!r||r.float64!==!0)&&(ku(n),o=ls(qt,1),n===o||Number.isNaN(n)?(qt[0]=249,e.push(qt.slice(0,3)),i=!0):(Ku(n),o=ds(qt,1),n===o&&(qt[0]=250,e.push(qt.slice(0,5)),i=!0))),i||(hp(n),o=Vu(qt,1),qt[0]=251,e.push(qt.slice(0,9)))}}to.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){ku(n);let o=ls(qt,1);if(n===o||Number.isNaN(n))return 3;if(Ku(n),o=ds(qt,1),n===o)return 5}return 9};var Ou=new ArrayBuffer(9),Ot=new DataView(Ou,1),qt=new Uint8Array(Ou,0);function ku(e){if(e===1/0)Ot.setUint16(0,31744,!1);else if(e===-1/0)Ot.setUint16(0,64512,!1);else if(Number.isNaN(e))Ot.setUint16(0,32256,!1);else{Ot.setFloat32(0,e);let t=Ot.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ot.setUint16(0,31744,!1);else if(r===0)Ot.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ot.setUint16(0,0):o<-14?Ot.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ot.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ls(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Ku(e){Ot.setFloat32(0,e,!1)}function ds(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function hp(e){Ot.setFloat64(0,e,!1)}function Vu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}to.compareTokens=Nt.compareTokens;function G(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function eo(e){return()=>{throw new Error(`${F} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=G;B[24]=jc;B[25]=Yc;B[26]=Wc;B[27]=Xc;B[28]=G;B[29]=G;B[30]=G;B[31]=G;for(let e=32;e<=55;e++)B[e]=G;B[56]=Jc;B[57]=Qc;B[58]=tu;B[59]=ru;B[60]=G;B[61]=G;B[62]=G;B[63]=G;for(let e=64;e<=87;e++)B[e]=nu;B[88]=ou;B[89]=iu;B[90]=su;B[91]=au;B[92]=G;B[93]=G;B[94]=G;B[95]=eo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=cu;B[120]=uu;B[121]=fu;B[122]=lu;B[123]=du;B[124]=G;B[125]=G;B[126]=G;B[127]=eo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=pu;B[152]=mu;B[153]=yu;B[154]=gu;B[155]=xu;B[156]=G;B[157]=G;B[158]=G;B[159]=bu;for(let e=160;e<=183;e++)B[e]=wu;B[184]=Eu;B[185]=Su;B[186]=vu;B[187]=Au;B[188]=G;B[189]=G;B[190]=G;B[191]=Cu;for(let e=192;e<=215;e++)B[e]=Iu;B[216]=Tu;B[217]=Bu;B[218]=_u;B[219]=Du;B[220]=G;B[221]=G;B[222]=G;B[223]=G;for(let e=224;e<=243;e++)B[e]=eo("simple values are not supported");B[244]=G;B[245]=G;B[246]=G;B[247]=Uu;B[248]=eo("simple values are not supported");B[249]=Lu;B[250]=Pu;B[251]=Nu;B[252]=G;B[253]=G;B[254]=G;B[255]=Ru;var $t=[];for(let e=0;e<24;e++)$t[e]=new L(b.uint,e,1);for(let e=-1;e>=-24;e--)$t[31-e]=new L(b.negint,e,1);$t[64]=new L(b.bytes,new Uint8Array(0),1);$t[96]=new L(b.string,"",1);$t[128]=new L(b.array,0,1);$t[160]=new L(b.map,0,1);$t[244]=new L(b.false,!1,1);$t[245]=new L(b.true,!0,1);$t[246]=new L(b.null,null,1);function mp(){let e=[];return e[b.uint.major]=Nt,e[b.negint.major]=Yn,e[b.bytes.major]=yr,e[b.string.major]=hu,e[b.array.major]=Xn,e[b.map.major]=Jn,e[b.tag.major]=Qn,e[b.float.major]=to,e}var Aw=mp(),Cw=new jn,ro=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(`${cs} object contains circular references`);return new e(r,t)}},ve={null:new L(b.null,null),undefined:new L(b.undefined,void 0),true:new L(b.true,!0),false:new L(b.false,!1),emptyArray:new L(b.array,0),emptyMap:new L(b.map,0)},Ae={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(b.float,e):e>=0?new L(b.uint,e):new L(b.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(b.uint,e):new L(b.negint,e)},Uint8Array(e,t,r,n){return new L(b.bytes,e)},string(e,t,r,n){return new L(b.string,e)},boolean(e,t,r,n){return e?ve.true:ve.false},null(e,t,r,n){return ve.null},undefined(e,t,r,n){return ve.undefined},ArrayBuffer(e,t,r,n){return new L(b.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(b.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[ve.emptyArray,new L(b.break)]:ve.emptyArray;n=ro.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=hs(s,r,n);return r.addBreakTokens?[new L(b.array,e.length),o,new L(b.break)]:[new L(b.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?[ve.emptyMap,new L(b.break)]:ve.emptyMap;n=ro.createCheck(n,e);let c=[],a=0;for(let f of i)c[a++]=[hs(f,r,n),hs(o?e.get(f):e[f],r,n)];return yp(c,r),r.addBreakTokens?[new L(b.map,s),c,new L(b.break)]:[new L(b.map,s),c]}};Ae.Map=Ae.Object;Ae.Buffer=Ae.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ae[`${e}Array`]=Ae.DataView;function hs(e,t={},r){let n=Kc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Ae[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Ae[n];if(!i)throw new Error(`${cs} unsupported type: ${n}`);return i(e,n,t,r)}function yp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var gp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},no=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=$t[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Jr=Symbol.for("DONE"),oo=Symbol.for("BREAK");function xp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=br(t,r);if(i===oo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===Jr)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function bp(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=br(t,r);if(c===oo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(c===Jr)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${F} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${F} found repeat map key "${c}"`);let a=br(t,r);if(a===Jr)throw new Error(`${F} 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 br(e,t){if(e.done())return Jr;let r=e.next();if(r.type===b.break)return oo;if(r.type.terminal)return r.value;if(r.type===b.array)return xp(r,e,t);if(r.type===b.map)return bp(r,e,t);if(r.type===b.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=br(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function Mu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},gp,t);let r=t.tokenizer||new no(e,t),n=br(r,t);if(n===Jr)throw new Error(`${F} did not find any content to decode`);if(n===oo)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function ps(e,t){let[r,n]=Mu(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var Sp=ee("ipns:utils"),Fu=H("/ipns/");var vp=0,Ap=18;function qu(e){let t;if(e.pubKey!=null)try{t=yc(e.pubKey)}catch(r){throw Sp.error(r),r}if(t!=null)return t}function $u(e){let t=H("ipns-signature:");return Lt([t,e])}function Qr(e){return"signatureV1"in e?Ft.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}):Ft.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Ce(e){let t=Ft.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 Mt("Missing data or signatureV2");let r=Hu(t.data),n=Cp(r.Value),o=z(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Ip(t),{value:n,validityType:Ft.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:Ft.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 tn(e){return Lt([Fu,e.bytes])}function wr(e){let t=Te(e.slice(Fu.length));if(!io(t,vp)&&!io(t,Ap))throw new Fe("Multihash in IPNS key was not identity or sha2-256");return t}function Hu(e){let t=ps(e);if(t.ValidityType===0)t.ValidityType=Ft.ValidityType.EOL;else throw new hr("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 Cp(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 zn("Value must be a valid content path starting with /")}function Ip(e){if(e.data==null)throw new Zn("Record data is missing");let t=Hu(e.data);if(!J(t.Value,e.value??new Uint8Array(0)))throw new Mt('Field "value" did not match between protobuf and CBOR');if(!J(t.Validity,e.validity??new Uint8Array(0)))throw new Mt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Mt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Mt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Mt('Field "ttl" did not match between protobuf and CBOR')}function io(e,t){return e.code===t}var jw=ee("ipns"),Yw=300*1e9,Bp="/ipns/",Ww=Bp.length;var zu=po(as(),1);var so=ee("ipns:validator"),_p=1024*10;async function Dp(e,t){let r=Ce(t),n;try{let o=$u(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw so.error("record signature verification failed"),new Mt("Record signature verification failed");if(r.validityType===Ft.ValidityType.EOL){if(zu.default.fromString(r.validity).toDate().getTime()<Date.now())throw so.error("record has expired"),new $n("record has expired")}else if(r.validityType!=null)throw so.error("the validity type is unsupported"),new hr("The validity type is unsupported");so("ipns record for %s is valid",r.value)}async function Zu(e,t){if(t.byteLength>_p)throw new Hn("The record is too large");let r=wr(e),n;io(r,0)&&(n=Rn(r));let o=Ce(t),i=qu(o)??n;if(i==null)throw new jr("Could not extract public key from IPNS record or routing key");let s=tn(i.toMultihash());if(!J(s,e))throw new jr("Embedded public key did not match routing key");await Dp(i,t)}var ao=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*en(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)),je(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new ao("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 Qt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var ys=po(ju(),1);var gs=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},Yu=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function xs(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=t,c,a,u=new Promise((l,y)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){y(Yu(s));return}if(s&&(a=()=>{y(Yu(s))},s.addEventListener("abort",a,{once:!0})),e.then(l,y),r===Number.POSITIVE_INFINITY)return;let v=new gs;c=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(x){y(x)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?y(o):(v.message=o??`Promise timed out after ${r} milliseconds`,y(v))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}function bs(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 nn=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=bs(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 on=class extends ys.default{#t;#n;#r=0;#h;#p=!1;#m=!1;#u;#b=0;#y=0;#i;#s;#e;#w;#o=0;#f;#a;#I=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:nn,...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.#P()}get#T(){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#U(){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)}#R(){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.#R(),this.emit("idle")),!1;let t=!1;if(!this.#a){let r=!this.#U;if(this.#T&&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#L(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.#I++).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=xs(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.#L(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.#C()}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}#P(){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.#C()}))}#C(){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 Er=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Ht=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Lp(e){return e[Symbol.asyncIterator]!=null}function Pp(e){if(Lp(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Wu=Pp;function Np(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 Xu=Np;function Op(e){return e[Symbol.asyncIterator]!=null}function kp(e,t){let r=0;if(Op(e))return(async function*(){for await(let a of e)yield t(a,r++)})();let n=Xu(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 Ju=kp;var Qu=H("/ipns/");function tf(e){return J(e.subarray(0,Qu.byteLength),Qu)}var uo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){try{yield*Ju(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}catch(n){if(n instanceof Zt)return;throw n}}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!tf(t))return;let o=wr(t),i=j.createV1(114,o),s=Ce(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!tf(t))throw new Zt("Not found");let n=wr(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Qr(i)}catch(i){throw i.name==="BadResponseError"?new Zt("Not found"):i}}},fo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Wu(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Zt("Not found")}async*getClosestPeers(t,r={}){}};var mt=ee("delegated-routing-v1-http-api-client"),lo={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},ho=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 on({concurrency:r.concurrentRequests??lo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??lo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new uo(this),this.peerRouting=new fo(this),this.cacheName=r.cacheName??lo.cacheName,this.cacheTTL=r.cacheTTL??lo.cacheTTL}get[As](){return this.contentRouting}get[Cs](){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=Gr([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/providers/${t}`);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.ok){if(f.status===404)return;throw f.status===422?new Er("Request does not conform to schema or semantic constraints"):new Ht(`Unexpected status code: ${f.status}`)}if(f.body==null)throw new Ht("Routing response had no body");let u=f.headers.get("Content-Type");if(u==null)throw new Ht("No Content-Type header received");if(u.startsWith("application/json")){let y=(await f.json()).Providers??[];for(let v of y){let x=this.#t(v);x!=null&&(yield x)}}else if(u.includes("application/x-ndjson"))for await(let l of en(qn(f.body))){let y=this.#t(l);y!=null&&(yield y)}else throw new Ht(`Unsupported Content-Type: ${u}`)}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=Gr([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();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)return;if(f.status===422)throw new Er("Request does not conform to schema or semantic constraints");if(f.body==null)throw new Ht("Routing response had no body");if(f.headers.get("Content-Type")?.startsWith("application/json")){let y=(await f.json()).Peers??[];for(let v of y){let x=this.#t(v);x!=null&&(yield x)}}else for await(let l of en(qn(f.body))){let y=this.#t(l);y!=null&&(yield y)}}catch(c){mt.error("getPeers errored:",c)}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=Gr([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();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(mt("getIPNS GET %s %d",c,f.status),f.status===404)throw new Zt("No matching records found");if(f.status===422)throw new Er("Request does not conform to schema or semantic constraints");if(!f.ok)throw new Ht(`Unexpected status code: ${f.status}`);let u=f.headers.get("Content-Type");if(u==null||!u.includes("application/vnd.ipfs.ipns-record"))throw new Zt("No matching records found");if(f.body==null)throw new Ht("GET ipns response had no body");let l=await f.arrayBuffer(),y=new Uint8Array(l,0,l.byteLength);return r.validate!==!1&&await Zu(tn(t.multihash),y),Ce(y)}catch(a){throw mt.error("getIPNS GET %s error:",c,a),a}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=Gr([this.shutDownController.signal,o,n.signal]);let s=Qt(),c=Qt();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let f=Qr(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#r(a,u);if(mt("putIPNS PUT %s %d",a,l.status),l.status!==200)throw new Ht("PUT ipns response had status other than 200")}catch(f){throw mt.error("putIPNS PUT %s error:",a,f.stack),f}finally{i.clear(),c.resolve(),mt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(kc)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:bc(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#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 mt("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 mt("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 Kp(e,t={}){return new ho(new URL(e),t)}return af(Vp);})();
|
|
10
10
|
/*! Bundled license information:
|
|
11
11
|
|
|
12
12
|
@noble/hashes/utils.js:
|