@helia/routers 4.0.6-8dd50c61 → 4.0.6-ec266508

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,16 +1,16 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaRouters=(()=>{var Kf=Object.create;var dn=Object.defineProperty;var Vf=Object.getOwnPropertyDescriptor;var Mf=Object.getOwnPropertyNames;var $f=Object.getPrototypeOf,Ff=Object.prototype.hasOwnProperty;var zs=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),wt=(e,t)=>{for(var r in t)dn(e,r,{get:t[r],enumerable:!0})},js=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mf(t))!Ff.call(e,o)&&o!==r&&dn(e,o,{get:()=>t[o],enumerable:!(n=Vf(t,o))||n.enumerable});return e};var To=(e,t,r)=>(r=e!=null?Kf($f(e)):{},js(t||!e||!e.__esModule?dn(r,"default",{value:e,enumerable:!0}):r,e)),qf=e=>js(dn({},"__esModule",{value:!0}),e);var bs=zs((Dw,xs)=>{var _w=(function(){typeof xs<"u"&&(xs.exports=T);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",f=Math.trunc||function(h){var p=h-h%1;return p==0&&(h<0||h===0&&1/h!=1/0)?-0:p},u=T.prototype,l=(T.fromDate=function(h){return new T(+h)},T.fromInt64BE=L(0,1,2,3,0,4),T.fromInt64LE=L(3,2,1,0,4,0),T.fromString=function(D){var p,_=new T,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 I(_)},T.fromTimeT=function(h){return C(h,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(h){return this.nano+=+h||0,this},u.getNano=function(){var h=I(this);return(h.time%1e3*c+ +h.nano+1e9)%1e9},u.getTimeT=function(){var p=I(this),h=Math.floor(p.time/1e3),p=p.year;return p&&(h+=p*r*e/t),h},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(I(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(h){var p=this,_=p.toDate(),D={H:function(){return 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 E[_.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 S=g[1],d=b[S],S=D[S];return d?A(d):S?S():g})})(h||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],E=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],b={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return T;function T(h,p,_){var D=this;if(!(D instanceof T))return new T(h,p,_);D.time=+h||0,D.nano=+p||0,D.year=+_||0,I(D)}function I(h){var p,_,D,A=h.year,m=h.time,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 C(A,D){A=+A||0;var _=f((D=(D|0)*s)/n)+f(A/n),D=D%n+A%n,A=f(D/n);return A&&(_+=A,D-=A*n),new T(1e3*D,0,_*t)}function v(h,p,_,D,A,m){return function(d,S){var N=I(this);d=d||new Array(8),k(d,S|=0);var U=Math.floor(N.time/1e3),N=N.year*(r*e/t),R=f(N/s)+f(U/s),N=N%s+U%s,U=Math.floor(N/s);return U&&(R+=U,N-=U*s),g(d,S+A,R),g(d,S+m,N),d};function g(d,S,R){d[S+h]=R>>24&255,d[S+p]=R>>16&255,d[S+_]=R>>8&255,d[S+D]=255&R}}function L(h,p,_,D,A,m){return function(d,S){k(d,S|=0);var R=g(d,S+A);return C(g(d,S+m),R)};function g(d,S){return 16777216*d[S+h]+(d[S+p]<<16|d[S+_]<<8|d[S+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 wf=zs((y2,Bs)=>{"use strict";var y0=Object.prototype.hasOwnProperty,St="~";function cn(){}Object.create&&(cn.prototype=Object.create(null),new cn().__proto__||(St=!1));function g0(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function bf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new g0(r,n||e,o),s=St?St+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function go(e,t){--e._eventsCount===0?e._events=new cn:delete e._events[t]}function bt(){this._events=new cn,this._eventsCount=0}bt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)y0.call(r,n)&&t.push(St?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};bt.prototype.listeners=function(t){var r=St?St+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};bt.prototype.listenerCount=function(t){var r=St?St+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=St?St+t:t;if(!this._events[c])return!1;var a=this._events[c],f=arguments.length,u,l;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),f){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,r),!0;case 3:return a.fn.call(a.context,r,n),!0;case 4:return a.fn.call(a.context,r,n,o),!0;case 5:return a.fn.call(a.context,r,n,o,i),!0;case 6:return a.fn.call(a.context,r,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];a.fn.apply(a.context,u)}else{var y=a.length,E;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(E=1,u=new Array(f-1);E<f;E++)u[E-1]=arguments[E];a[l].fn.apply(a[l].context,u)}}return!0};bt.prototype.on=function(t,r,n){return bf(this,t,r,n,!1)};bt.prototype.once=function(t,r,n){return bf(this,t,r,n,!0)};bt.prototype.removeListener=function(t,r,n,o){var i=St?St+t:t;if(!this._events[i])return this;if(!r)return go(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&go(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:go(this,i)}return this};bt.prototype.removeAllListeners=function(t){var r;return t?(r=St?St+t:t,this._events[r]&&go(this,r)):(this._events=new cn,this._eventsCount=0),this};bt.prototype.off=bt.prototype.removeListener;bt.prototype.addListener=bt.prototype.on;bt.prefixed=St;bt.EventEmitter=bt;typeof Bs<"u"&&(Bs.exports=bt)});var M0={};wt(M0,{delegatedHTTPRouting:()=>Bf,delegatedHTTPRoutingDefaults:()=>Ao,httpGatewayRouting:()=>Of,libp2pRouting:()=>kf});var Gs=Symbol.for("@libp2p/content-routing");var nt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ge=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var vt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var hn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ze=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ye=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var pn=Symbol.for("@libp2p/peer-id");function Zs(e){return!!e?.[pn]}var Ys=Symbol.for("@libp2p/peer-routing");var Ro={};wt(Ro,{base58btc:()=>X,base58flickr:()=>Wf});var j0=new Uint8Array(0);function Ws(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 oe(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 Xs(e){return new TextEncoder().encode(e)}function Js(e){return new TextDecoder().decode(e)}function Hf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=e.length,a=e.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var T=0,I=0,w=0,C=b.length;w!==C&&b[w]===0;)w++,T++;for(var v=(C-w)*u+1>>>0,L=new Uint8Array(v);w!==C;){for(var k=b[w],M=0,V=v-1;(k!==0||M<I)&&V!==-1;V--,M++)k+=256*L[V]>>>0,L[V]=k%c>>>0,k=k/c>>>0;if(k!==0)throw new Error("Non-zero carry");I=M,w++}for(var h=v-I;h!==v&&L[h]===0;)h++;for(var p=a.repeat(T);h<v;++h)p+=e.charAt(L[h]);return p}function y(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var T=0;if(b[T]!==" "){for(var I=0,w=0;b[T]===a;)I++,T++;for(var C=(b.length-T)*f+1>>>0,v=new Uint8Array(C);b[T];){var L=r[b.charCodeAt(T)];if(L===255)return;for(var k=0,M=C-1;(L!==0||k<w)&&M!==-1;M--,k++)L+=c*v[M]>>>0,v[M]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");w=k,T++}if(b[T]!==" "){for(var V=C-w;V!==C&&v[V]===0;)V++;for(var h=new Uint8Array(I+(C-V)),p=I;V!==C;)h[p++]=v[V++];return h}}}function E(b){var T=y(b);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:y,decode:E}}var zf=Hf,jf=zf,ta=jf;var Co=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")}},Bo=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 ea(this,t)}},_o=class{decoders;constructor(t){this.decoders=t}or(t){return ea(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 ea(e,t){return new _o({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Do=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 Co(t,r,n),this.decoder=new Bo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function We({name:e,prefix:t,encode:r,decode:n}){return new Do(e,t,r,n)}function xe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ta(r,e);return We({prefix:t,name:e,encode:n,decode:i=>oe(o(i))})}function Gf(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 Zf(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 Yf(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function ot({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Yf(n);return We({prefix:t,name:e,encode(i){return Zf(i,n,r)},decode(i){return Gf(i,o,r,e)}})}var X=xe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wf=xe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Po={};wt(Po,{base32:()=>Wt,base32hex:()=>tl,base32hexpad:()=>rl,base32hexpadupper:()=>nl,base32hexupper:()=>el,base32pad:()=>Jf,base32padupper:()=>Qf,base32upper:()=>Xf,base32z:()=>ol});var Wt=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xf=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jf=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qf=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tl=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),el=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rl=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),nl=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ol=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var No={};wt(No,{base36:()=>Xe,base36upper:()=>il});var Xe=xe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),il=xe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xt={};wt(Xt,{Digest:()=>Re,create:()=>$t,decode:()=>be,equals:()=>Uo,hasCode:()=>Al});var sl=oa,ra=128,al=127,cl=~al,ul=Math.pow(2,31);function oa(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ul;)t[r++]=e&255|ra,e/=128;for(;e&cl;)t[r++]=e&255|ra,e>>>=7;return t[r]=e|0,oa.bytes=r-n+1,t}var fl=Lo,ll=128,na=127;function Lo(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Lo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&na)<<o:(s&na)*Math.pow(2,o),o+=7}while(s>=ll);return Lo.bytes=i-n,r}var dl=Math.pow(2,7),hl=Math.pow(2,14),pl=Math.pow(2,21),ml=Math.pow(2,28),yl=Math.pow(2,35),gl=Math.pow(2,42),xl=Math.pow(2,49),bl=Math.pow(2,56),wl=Math.pow(2,63),El=function(e){return e<dl?1:e<hl?2:e<pl?3:e<ml?4:e<yl?5:e<gl?6:e<xl?7:e<bl?8:e<wl?9:10},Sl={encode:sl,decode:fl,encodingLength:El},vl=Sl,Br=vl;function _r(e,t=0){return[Br.decode(e,t),Br.decode.bytes]}function Je(e,t,r=0){return Br.encode(e,t,r),t}function Qe(e){return Br.encodingLength(e)}function $t(e,t){let r=t.byteLength,n=Qe(e),o=n+Qe(r),i=new Uint8Array(o+r);return Je(e,i,0),Je(r,i,n),i.set(t,o),new Re(e,r,t,i)}function be(e){let t=oe(e),[r,n]=_r(t),[o,i]=_r(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Re(r,o,s,t)}function Uo(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ws(e.bytes,r.bytes)}}var Re=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Al(e,t){return e.code===t}function ia(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Tl(r,Oo(e),t??X.encoder);default:return Cl(r,Oo(e),t??Wt.encoder)}}var sa=new WeakMap;function Oo(e){let t=sa.get(e);if(t==null){let r=new Map;return sa.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!==Dr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Bl)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=$t(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&&Uo(t.multihash,n.multihash)}toString(t){return ia(this,t)}toJSON(){return{"/":ia(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??aa(n,o,i.bytes))}else if(r[_l]===!0){let{version:n,multihash:o,code:i}=r,s=be(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!==Dr)throw new Error(`Version 0 CID must use dag-pb (code: ${Dr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=aa(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Dr,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=oe(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 Re(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]=_r(t.subarray(r));return r+=y,l},o=n(),i=Dr;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 Oo(i).set(n,t),i}};function Il(e,t){switch(e[0]){case"Q":{let r=t??X;return[X.prefix,r.decode(`${X.prefix}${e}`)]}case X.prefix:{let r=t??X;return[X.prefix,r.decode(e)]}case Wt.prefix:{let r=t??Wt;return[Wt.prefix,r.decode(e)]}case Xe.prefix:{let r=t??Xe;return[Xe.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 Tl(e,t,r){let{prefix:n}=r;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Cl(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 Dr=112,Bl=18;function aa(e,t,r){let n=Qe(e),o=n+Qe(t),i=new Uint8Array(o+r.byteLength);return Je(e,i,0),Je(t,i,n),i.set(r,o),i}var _l=Symbol.for("@ipld/js-cid/CID");var ko={};wt(ko,{identity:()=>Ct});var ca=0,Dl="identity",ua=oe;function Rl(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 $t(ca,ua(e))}var Ct={code:ca,name:Dl,encode:ua,digest:Rl};function Y(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ie(e=0){return new Uint8Array(e)}function Bt(e=0){return new Uint8Array(e)}function Ut(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Bt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var la=Symbol.for("@achingbrain/uint8arraylist");function fa(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 tr(e){return!!e?.[la]}var _t=class e{bufs;length;[la]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(tr(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(tr(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=fa(this.bufs,t);return r.buf[r.index]}set(t,r){let n=fa(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(tr(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 Ut(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ut(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(!tr(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 E=this.get(l+y);if(n[y]!==E){u=Math.max(1,y-c[E]);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=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!Y(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Ko={};wt(Ko,{base10:()=>Pl});var Pl=xe({prefix:"9",name:"base10",alphabet:"0123456789"});var Vo={};wt(Vo,{base16:()=>Nl,base16upper:()=>Ll});var Nl=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ll=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mo={};wt(Mo,{base2:()=>Ul});var Ul=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $o={};wt($o,{base256emoji:()=>Ml});var da=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}"),Ol=da.reduce((e,t,r)=>(e[r]=t,e),[]),kl=da.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Kl(e){return e.reduce((t,r)=>(t+=Ol[r],t),"")}function Vl(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=kl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Ml=We({prefix:"\u{1F680}",name:"base256emoji",encode:Kl,decode:Vl});var Ho={};wt(Ho,{base64:()=>Fo,base64pad:()=>$l,base64url:()=>qo,base64urlpad:()=>Fl});var Fo=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$l=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qo=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fl=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zo={};wt(zo,{base8:()=>ql});var ql=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jo={};wt(jo,{identity:()=>Hl});var Hl=We({prefix:"\0",name:"identity",encode:e=>Js(e),decode:e=>Xs(e)});var _m=new TextEncoder,Dm=new TextDecoder;var Yo={};wt(Yo,{sha256:()=>Rr,sha512:()=>Zl});var Gl=20;function Zo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Go(e,t,r,n,o)}var Go=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Gl,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?ha(n,this.code,r?.truncate):n.then(o=>ha(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ha(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 $t(t,e)}function ma(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Rr=Zo({name:"sha2-256",code:18,encode:ma("SHA-256")}),Zl=Zo({name:"sha2-512",code:19,encode:ma("SHA-512")});var Pr={...jo,...Mo,...zo,...Ko,...Vo,...Po,...No,...Ro,...Ho,...$o},Fm={...Yo,...ko};function ga(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ya=ga("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Wo=ga("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=Bt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Yl={utf8:ya,"utf-8":ya,hex:Pr.base16,latin1:Wo,ascii:Wo,binary:Wo,...Pr},yn=Yl;function H(e,t="utf8"){let r=yn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=yn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Wl=parseInt("11111",2),Xo=parseInt("10000000",2),Xl=parseInt("01111111",2),xa={0:Nr,1:Nr,2:Jl,3:ed,4:rd,5:td,6:Ql,16:Nr,22:Nr,48:Nr};function se(e,t={offset:0}){let r=e[t.offset]&Wl;if(t.offset++,xa[r]!=null)return xa[r](e,t);throw new Error("No decoder for tag "+r)}function Lr(e,t){let r=0;if((e[t.offset]&Xo)===Xo){let n=e[t.offset]&Xl,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 Nr(e,t){Lr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=se(e,t);if(n===null)break;r.push(n)}return r}function Jl(e,t){let r=Lr(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 Ql(e,t){let r=Lr(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 td(e,t){return t.offset++,null}function ed(e,t){let r=Lr(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 rd(e,t){let r=Lr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function nd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new _t;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Jo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=nd(e.byteLength);return new _t(Uint8Array.from([t.byteLength|Xo]),t)}function At(e){let t=new _t,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new _t(Uint8Array.from([2]),Jo(t),t)}function gn(e){let t=Uint8Array.from([0]),r=new _t(t,e);return new _t(Uint8Array.from([3]),Jo(r),r)}function we(e,t=48){let r=new _t;for(let n of e)r.append(n);return new _t(Uint8Array.from([t]),Jo(r),r)}async function ba(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 od=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),id=Uint8Array.from([6,5,43,129,4,0,34]),sd=Uint8Array.from([6,5,43,129,4,0,35]),ad={ext:!0,kty:"EC",crv:"P-256"},cd={ext:!0,kty:"EC",crv:"P-384"},ud={ext:!0,kty:"EC",crv:"P-521"},Qo=32,ti=48,ei=66;function ri(e){let t=se(e);return wa(t)}function wa(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Qo*2+1)return n=z(t.subarray(r,r+Qo),"base64url"),o=z(t.subarray(r+Qo),"base64url"),new er({...ad,key_ops:["verify"],x:n,y:o});if(t.byteLength===ti*2+1)return n=z(t.subarray(r,r+ti),"base64url"),o=z(t.subarray(r+ti),"base64url"),new er({...cd,key_ops:["verify"],x:n,y:o});if(t.byteLength===ei*2+1)return n=z(t.subarray(r,r+ei),"base64url"),o=z(t.subarray(r+ei),"base64url"),new er({...ud,key_ops:["verify"],x:n,y:o});throw new nt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ea(e){return we([At(Uint8Array.from([1])),we([fd(e.crv)],160),we([gn(new _t(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function fd(e){if(e==="P-256")return od;if(e==="P-384")return id;if(e==="P-521")return sd;throw new nt(`Invalid curve ${e}`)}var er=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ea(this.jwk)),this._raw}toMultihash(){return Ct.digest(rr(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}async verify(t,r,n){return ba(this.jwk,r,t,n)}};function Pe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function q(e,t,r=""){let n=Pe(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 xn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Jt(e.outputLen),Jt(e.blockLen)}function nr(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 va(e,t){q(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function bn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ft(e,t){return e<<32-t|e>>>t}var Aa=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ld=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ue(e){if(q(e),Aa)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=ld[e[r]];return t}var ae={_0:48,_9:57,A:65,F:70,a:97,f:102};function Sa(e){if(e>=ae._0&&e<=ae._9)return e-ae._0;if(e>=ae.A&&e<=ae.F)return e-(ae.A-10);if(e>=ae.a&&e<=ae.f)return e-(ae.a-10)}function fe(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Aa)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=Sa(e.charCodeAt(i)),c=Sa(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 It(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];q(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function ni(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 or(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 oi=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ia(e,t,r){return e&t^~e&r}function Ta(e,t,r){return e&t^e&r^t&r}var Ur=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=bn(this.buffer)}update(t){nr(this),q(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=bn(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){nr(this),va(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ce(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=bn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},le=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ht=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var wn=BigInt(4294967295),Ca=BigInt(32);function dd(e,t=!1){return t?{h:Number(e&wn),l:Number(e>>Ca&wn)}:{h:Number(e>>Ca&wn)|0,l:Number(e&wn)|0}}function Ba(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}=dd(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var ii=(e,t,r)=>e>>>r,si=(e,t,r)=>e<<32-r|t>>>r,Ne=(e,t,r)=>e>>>r|t<<32-r,Le=(e,t,r)=>e<<32-r|t>>>r,Or=(e,t,r)=>e<<64-r|t>>>r-32,kr=(e,t,r)=>e>>>r-32|t<<64-r;function Qt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var _a=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Da=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ra=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Pa=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Na=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),La=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var pd=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]),Ee=new Uint32Array(64),ai=class extends Ur{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)Ee[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let y=Ee[l-15],E=Ee[l-2],b=Ft(y,7)^Ft(y,18)^y>>>3,T=Ft(E,17)^Ft(E,19)^E>>>10;Ee[l]=T+Ee[l-7]+b+Ee[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=Ft(c,6)^Ft(c,11)^Ft(c,25),E=u+y+Ia(c,a,f)+pd[l]+Ee[l]|0,T=(Ft(n,2)^Ft(n,13)^Ft(n,22))+Ta(n,o,i)|0;u=f,f=a,a=c,c=s+E|0,s=i,i=o,o=n,n=E+T|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){ce(Ee)}destroy(){this.set(0,0,0,0,0,0,0,0),ce(this.buffer)}},ci=class extends ai{A=le[0]|0;B=le[1]|0;C=le[2]|0;D=le[3]|0;E=le[4]|0;F=le[5]|0;G=le[6]|0;H=le[7]|0;constructor(){super(32)}};var Ua=Ba(["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))),md=Ua[0],yd=Ua[1],Se=new Uint32Array(80),ve=new Uint32Array(80),ui=class extends Ur{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:E,Gl:b,Hh:T,Hl:I}=this;return[t,r,n,o,i,s,c,a,f,u,l,y,E,b,T,I]}set(t,r,n,o,i,s,c,a,f,u,l,y,E,b,T,I){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=y|0,this.Gh=E|0,this.Gl=b|0,this.Hh=T|0,this.Hl=I|0}process(t,r){for(let v=0;v<16;v++,r+=4)Se[v]=t.getUint32(r),ve[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let L=Se[v-15]|0,k=ve[v-15]|0,M=Ne(L,k,1)^Ne(L,k,8)^ii(L,k,7),V=Le(L,k,1)^Le(L,k,8)^si(L,k,7),h=Se[v-2]|0,p=ve[v-2]|0,_=Ne(h,p,19)^Or(h,p,61)^ii(h,p,6),D=Le(h,p,19)^kr(h,p,61)^si(h,p,6),A=Ra(V,D,ve[v-7],ve[v-16]),m=Pa(A,M,_,Se[v-7],Se[v-16]);Se[v]=m|0,ve[v]=A|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:y,Fh:E,Fl:b,Gh:T,Gl:I,Hh:w,Hl:C}=this;for(let v=0;v<80;v++){let L=Ne(l,y,14)^Ne(l,y,18)^Or(l,y,41),k=Le(l,y,14)^Le(l,y,18)^kr(l,y,41),M=l&E^~l&T,V=y&b^~y&I,h=Na(C,k,V,yd[v],ve[v]),p=La(h,w,L,M,md[v],Se[v]),_=h|0,D=Ne(n,o,28)^Or(n,o,34)^Or(n,o,39),A=Le(n,o,28)^kr(n,o,34)^kr(n,o,39),m=n&i^n&c^i&c,g=o&s^o&a^s&a;w=T|0,C=I|0,T=E|0,I=b|0,E=l|0,b=y|0,{h:l,l:y}=Qt(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=_a(_,A,g);n=Da(d,p,D,m),o=d|0}({h:n,l:o}=Qt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Qt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=Qt(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=Qt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:y}=Qt(this.Eh|0,this.El|0,l|0,y|0),{h:E,l:b}=Qt(this.Fh|0,this.Fl|0,E|0,b|0),{h:T,l:I}=Qt(this.Gh|0,this.Gl|0,T|0,I|0),{h:w,l:C}=Qt(this.Hh|0,this.Hl|0,w|0,C|0),this.set(n,o,i,s,c,a,f,u,l,y,E,b,T,I,w,C)}roundClean(){ce(Se,ve)}destroy(){ce(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},fi=class extends ui{Ah=ht[0]|0;Al=ht[1]|0;Bh=ht[2]|0;Bl=ht[3]|0;Ch=ht[4]|0;Cl=ht[5]|0;Dh=ht[6]|0;Dl=ht[7]|0;Eh=ht[8]|0;El=ht[9]|0;Fh=ht[10]|0;Fl=ht[11]|0;Gh=ht[12]|0;Gl=ht[13]|0;Hh=ht[14]|0;Hl=ht[15]|0;constructor(){super(64)}};var ir=ni(()=>new ci,oi(1));var Oa=ni(()=>new fi,oi(3));var di=BigInt(0),li=BigInt(1);function de(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function ka(e){if(typeof e=="bigint"){if(!En(e))throw new Error("positive bigint expected, got "+e)}else Jt(e);return e}function Kr(e){let t=ka(e).toString(16);return t.length&1?"0"+t:t}function Ka(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?di:BigInt("0x"+e)}function sr(e){return Ka(ue(e))}function Ue(e){return Ka(ue(vn(q(e)).reverse()))}function Sn(e,t){Jt(t),e=ka(e);let r=fe(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function hi(e,t){return Sn(e,t).reverse()}function vn(e){return Uint8Array.from(e)}var En=e=>typeof e=="bigint"&&di<=e;function gd(e,t,r){return En(e)&&En(t)&&En(r)&&t<=e&&e<r}function Vr(e,t,r,n){if(!gd(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function pi(e){let t;for(t=0;e>di;e>>=li,t+=1);return t}var Mr=e=>(li<<BigInt(e))-li;function Va(e,t,r){if(Jt(e,"hashLen"),Jt(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(e),f=n(e),u=0,l=()=>{a.fill(1),f.fill(0),u=0},y=(...I)=>r(f,It(a,...I)),E=(I=o)=>{f=y(i,I),a=y(),I.length!==0&&(f=y(s,I),a=y())},b=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let I=0,w=[];for(;I<t;){a=y();let C=a.slice();w.push(C),I+=a.length}return It(...w)};return(I,w)=>{l(),E(I);let C;for(;!(C=w(b()));)E();return l(),C}}function Ae(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 ar(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var Et=BigInt(0),ct=BigInt(1),Oe=BigInt(2),Fa=BigInt(3),qa=BigInt(4),Ha=BigInt(5),xd=BigInt(7),za=BigInt(8),bd=BigInt(9),ja=BigInt(16);function it(e,t){let r=e%t;return r>=Et?r:t+r}function J(e,t,r){let n=e;for(;t-- >Et;)n*=n,n%=r;return n}function Ma(e,t){if(e===Et)throw new Error("invert: expected non-zero number");if(t<=Et)throw new Error("invert: expected positive modulus, got "+t);let r=it(e,t),n=t,o=Et,i=ct,s=ct,c=Et;for(;r!==Et;){let f=n/r,u=n%r,l=o-s*f,y=i-c*f;n=r,r=u,o=s,i=c,s=l,c=y}if(n!==ct)throw new Error("invert: does not exist");return it(o,t)}function yi(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Ga(e,t){let r=(e.ORDER+ct)/qa,n=e.pow(t,r);return yi(e,n,t),n}function wd(e,t){let r=(e.ORDER-Ha)/za,n=e.mul(t,Oe),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Oe),o),c=e.mul(i,e.sub(s,e.ONE));return yi(e,c,t),c}function Ed(e){let t=cr(e),r=Za(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+xd)/ja;return(c,a)=>{let f=c.pow(a,s),u=c.mul(f,n),l=c.mul(f,o),y=c.mul(f,i),E=c.eql(c.sqr(u),a),b=c.eql(c.sqr(l),a);f=c.cmov(f,u,E),u=c.cmov(y,l,b);let T=c.eql(c.sqr(u),a),I=c.cmov(f,u,T);return yi(c,I,a),I}}function Za(e){if(e<Fa)throw new Error("sqrt is not defined for small field");let t=e-ct,r=0;for(;t%Oe===Et;)t/=Oe,r++;let n=Oe,o=cr(e);for(;$a(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ga;let i=o.pow(n,t),s=(t+ct)/Oe;return function(a,f){if(a.is0(f))return f;if($a(a,f)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,i),y=a.pow(f,t),E=a.pow(f,s);for(;!a.eql(y,a.ONE);){if(a.is0(y))return a.ZERO;let b=1,T=a.sqr(y);for(;!a.eql(T,a.ONE);)if(b++,T=a.sqr(T),b===u)throw new Error("Cannot find square root");let I=ct<<BigInt(u-b-1),w=a.pow(l,I);u=b,l=a.sqr(w),y=a.mul(y,l),E=a.mul(E,w)}return E}}function Sd(e){return e%qa===Fa?Ga:e%za===Ha?wd:e%ja===bd?Ed(e):Za(e)}var Ya=(e,t)=>(it(e,t)&ct)===ct,vd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=vd.reduce((n,o)=>(n[o]="function",n),t);return Ae(e,r),e}function Ad(e,t,r){if(r<Et)throw new Error("invalid exponent, negatives unsupported");if(r===Et)return e.ONE;if(r===ct)return t;let n=e.ONE,o=t;for(;r>Et;)r&ct&&(n=e.mul(n,o)),o=e.sqr(o),r>>=ct;return n}function $r(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 $a(e,t){let r=(e.ORDER-ct)/Oe,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 Id(e,t){t!==void 0&&Jt(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var mi=class{ORDER;BITS;BYTES;isLE;ZERO=Et;ONE=ct;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=Et)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Id(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 it(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return Et<=t&&t<this.ORDER}is0(t){return t===Et}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&ct)===ct}neg(t){return it(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return it(t*t,this.ORDER)}add(t,r){return it(t+r,this.ORDER)}sub(t,r){return it(t-r,this.ORDER)}mul(t,r){return it(t*r,this.ORDER)}pow(t,r){return Ad(this,t,r)}div(t,r){return it(t*Ma(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 Ma(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=Sd(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?hi(t,this.BYTES):Sn(t,this.BYTES)}fromBytes(t,r=!1){q(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,i?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=i?Ue(t):sr(t);if(c&&(a=it(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return $r(this,t)}cmov(t,r,n){return n?r:t}};function cr(e,t={}){return new mi(e,t)}function Wa(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 xi(e){let t=Wa(e);return t+Math.ceil(t/2)}function bi(e,t,r=!1){q(e);let n=e.length,o=Wa(t),i=xi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ue(e):sr(e),c=it(s,t-ct)+ct;return r?hi(c,o):Sn(c,o)}var ur=BigInt(0),ke=BigInt(1);function Fr(e,t){let r=t.negate();return e?r:t}function Ke(e,t){let r=$r(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function tc(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function wi(e,t){tc(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Mr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Xa(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(e&o),a=e>>s;c>n&&(c-=i,a+=ke);let f=t*n,u=f+Math.abs(c)-1,l=c===0,y=c<0,E=t%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:y,isNegF:E,offsetF:f}}var Ei=new WeakMap,ec=new WeakMap;function Si(e){return ec.get(e)||1}function Ja(e){if(e!==ur)throw new Error("invalid wNAF")}var fr=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>ur;)r&ke&&(n=n.add(o)),o=o.double(),r>>=ke;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=wi(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=wi(t,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:f,isZero:u,isNeg:l,isNegF:y,offsetF:E}=Xa(n,c,s);n=a,u?i=i.add(Fr(y,r[E])):o=o.add(Fr(l,r[f]))}return Ja(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=wi(t,this.bits);for(let s=0;s<i.windows&&n!==ur;s++){let{nextN:c,offset:a,isZero:f,isNeg:u}=Xa(n,s,i);if(n=c,!f){let l=r[a];o=o.add(u?l.negate():l)}}return Ja(n),o}getPrecomputes(t,r,n){let o=Ei.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Ei.set(r,o))),o}cached(t,r,n){let o=Si(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=Si(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){tc(r,this.bits),ec.set(t,r),Ei.delete(t)}hasCache(t){return Si(t)!==1}};function rc(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>ur||n>ur;)r&ke&&(i=i.add(o)),n&ke&&(s=s.add(o)),o=o.double(),r>>=ke,n>>=ke;return{p1:i,p2:s}}function Qa(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return gi(t),t}else return cr(e,{isLE:r})}function An(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>ur))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Qa(t.p,r.Fp,n),i=Qa(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 In(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Ie=BigInt(0),ut=BigInt(1),vi=BigInt(2),Td=BigInt(8);function Cd(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 nc(e,t={}){let r=An("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;Ae(t,{},{uvRatio:"function"});let c=vi<<BigInt(o.BYTES*8)-ut,a=I=>n.create(I),f=t.uvRatio||((I,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(I,w))}}catch{return{isValid:!1,value:Ie}}});if(!Cd(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(I,w,C=!1){let v=C?ut:Ie;return Vr("coordinate "+I,w,v,c),w}function l(I){if(!(I instanceof b))throw new Error("EdwardsPoint expected")}let y=ar((I,w)=>{let{X:C,Y:v,Z:L}=I,k=I.is0();w==null&&(w=k?Td:n.inv(L));let M=a(C*w),V=a(v*w),h=n.mul(L,w);if(k)return{x:Ie,y:ut};if(h!==ut)throw new Error("invZ was invalid");return{x:M,y:V}}),E=ar(I=>{let{a:w,d:C}=i;if(I.is0())throw new Error("bad point: ZERO");let{X:v,Y:L,Z:k,T:M}=I,V=a(v*v),h=a(L*L),p=a(k*k),_=a(p*p),D=a(V*w),A=a(p*a(D+h)),m=a(_+a(C*a(V*h)));if(A!==m)throw new Error("bad point: equation left != right (1)");let g=a(v*L),d=a(k*M);if(g!==d)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,ut,a(i.Gx*i.Gy));static ZERO=new b(Ie,ut,ut,Ie);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,C,v,L){this.X=u("x",w),this.Y=u("y",C),this.Z=u("z",v,!0),this.T=u("t",L),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof b)throw new Error("extended point not allowed");let{x:C,y:v}=w||{};return u("x",C),u("y",v),new b(C,v,ut,a(C*v))}static fromBytes(w,C=!1){let v=n.BYTES,{a:L,d:k}=i;w=vn(q(w,v,"point")),de(C,"zip215");let M=vn(w),V=w[v-1];M[v-1]=V&-129;let h=Ue(M),p=C?c:n.ORDER;Vr("point.y",h,Ie,p);let _=a(h*h),D=a(_-ut),A=a(k*_-L),{isValid:m,value:g}=f(D,A);if(!m)throw new Error("bad point: invalid y coordinate");let d=(g&ut)===ut,S=(V&128)!==0;if(!C&&g===Ie&&S)throw new Error("bad point: x=0 and x_0=1");return S!==d&&(g=a(-g)),b.fromAffine({x:g,y:h})}static fromHex(w,C=!1){return b.fromBytes(fe(w),C)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,C=!0){return T.createCache(this,w),C||this.multiply(vi),this}assertValidity(){E(this)}equals(w){l(w);let{X:C,Y:v,Z:L}=this,{X:k,Y:M,Z:V}=w,h=a(C*V),p=a(k*L),_=a(v*V),D=a(M*L);return h===p&&_===D}is0(){return this.equals(b.ZERO)}negate(){return new b(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:w}=i,{X:C,Y:v,Z:L}=this,k=a(C*C),M=a(v*v),V=a(vi*a(L*L)),h=a(w*k),p=C+v,_=a(a(p*p)-k-M),D=h+M,A=D-V,m=h-M,g=a(_*A),d=a(D*m),S=a(_*m),R=a(A*D);return new b(g,d,R,S)}add(w){l(w);let{a:C,d:v}=i,{X:L,Y:k,Z:M,T:V}=this,{X:h,Y:p,Z:_,T:D}=w,A=a(L*h),m=a(k*p),g=a(V*v*D),d=a(M*_),S=a((L+k)*(h+p)-A-m),R=d-g,N=d+g,U=a(m-C*A),O=a(S*R),K=a(N*U),F=a(S*U),tt=a(R*N);return new b(O,K,tt,F)}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:C,f:v}=T.cached(this,w,L=>Ke(b,L));return Ke(b,[C,v])[0]}multiplyUnsafe(w,C=b.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===Ie?b.ZERO:this.is0()||w===ut?this:T.unsafe(this,w,v=>Ke(b,v),C)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(w){return y(this,w)}clearCofactor(){return s===ut?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:C}=this.toAffine(),v=n.toBytes(C);return v[v.length-1]|=w&ut?128:0,v}toHex(){return ue(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let T=new fr(b,o.BITS);return b.BASE.precompute(8),b}function oc(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');Ae(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||or,a=r.adjustScalarBytes||(h=>h),f=r.domain||((h,p,_)=>{if(de(_,"phflag"),p.length||_)throw new Error("Contexts/pre-hash are not supported");return h});function u(h){return s.create(Ue(h))}function l(h){let p=v.secretKey;q(h,v.secretKey,"secretKey");let _=q(t(h),2*p,"hashedSecretKey"),D=a(_.slice(0,p)),A=_.slice(p,2*p),m=u(D);return{head:D,prefix:A,scalar:m}}function 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 E(h){return y(h).pointBytes}function b(h=Uint8Array.of(),...p){let _=It(...p);return u(t(f(_,q(h,void 0,"context"),!!n)))}function T(h,p,_={}){h=q(h,void 0,"message"),n&&(h=n(h));let{prefix:D,scalar:A,pointBytes:m}=y(p),g=b(_.context,D,h),d=o.multiply(g).toBytes(),S=b(_.context,d,m,h),R=s.create(g+S*A);if(!s.isValid(R))throw new Error("sign failed: invalid s");let N=It(d,s.toBytes(R));return q(N,v.signature,"result")}let I={zip215:!0};function w(h,p,_,D=I){let{context:A,zip215:m}=D,g=v.signature;h=q(h,g,"signature"),p=q(p,void 0,"message"),_=q(_,v.publicKey,"publicKey"),m!==void 0&&de(m,"zip215"),n&&(p=n(p));let d=g/2,S=h.subarray(0,d),R=Ue(h.subarray(d,g)),N,U,O;try{N=e.fromBytes(_,m),U=e.fromBytes(S,m),O=o.multiplyUnsafe(R)}catch{return!1}if(!m&&N.isSmallOrder())return!1;let K=b(A,U.toBytes(),N.toBytes(),p);return U.add(N.multiplyUnsafe(K)).subtract(O).clearCofactor().is0()}let C=i.BYTES,v={secretKey:C,publicKey:C,signature:2*C,seed:C};function L(h=c(v.seed)){return q(h,v.seed,"seed")}function k(h){return Pe(h)&&h.length===s.BYTES}function M(h,p){try{return!!e.fromBytes(h,p)}catch{return!1}}let V={getExtendedPublicKey:y,randomSecretKey:L,isValidSecretKey:k,isValidPublicKey:M,toMontgomery(h){let{y:p}=e.fromBytes(h),_=v.publicKey,D=_===32;if(!D&&_!==57)throw new Error("only defined for 25519 and 448");let A=D?i.div(ut+p,ut-p):i.div(p-ut,p+ut);return i.toBytes(A)},toMontgomerySecret(h){let p=v.secretKey;q(h,p);let _=t(h.subarray(0,p));return a(_).subarray(0,p)}};return Object.freeze({keygen:In(L,E),getPublicKey:E,sign:T,verify:w,utils:V,Point:e,lengths:v})}var Bd=BigInt(1),ic=BigInt(2);var _d=BigInt(5),Dd=BigInt(8),Ai=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Rd={p:Ai,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Dd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Pd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ai,c=e*e%i*e%i,a=J(c,ic,i)*c%i,f=J(a,Bd,i)*e%i,u=J(f,_d,i)*f%i,l=J(u,t,i)*u%i,y=J(l,r,i)*l%i,E=J(y,n,i)*y%i,b=J(E,o,i)*E%i,T=J(b,o,i)*E%i,I=J(T,t,i)*u%i;return{pow_p_5_8:J(I,ic,i)*e%i,b2:c}}function Nd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var sc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ld(e,t){let r=Ai,n=it(t*t*t,r),o=it(n*n*t,r),i=Pd(e*o).pow_p_5_8,s=it(e*n*i,r),c=it(t*s*s,r),a=s,f=it(s*sc,r),u=c===e,l=c===it(-e,r),y=c===it(-e*sc,r);return u&&(s=a),(l||y)&&(s=f),Ya(s,r)&&(s=it(-s,r)),{isValid:u||l,value:s}}var Ud=nc(Rd,{uvRatio:Ld});function Od(e){return oc(Ud,Oa,Object.assign({adjustScalarBytes:Nd},e))}var ac=Od({});var qr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Tn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var cc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Tn("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 Ot=cc;var Cn=32;var Ii,kd=(async()=>{try{return await Ot.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Kd(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Ot.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Ot.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 Vd(e,t,r){return ac.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function uc(e,t,r){return Ii==null&&(Ii=await kd),Ii?Kd(e,t,r):Vd(e,t,r)}function Bn(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var _n=class{type="Ed25519";raw;constructor(t){this.raw=Ti(t,Cn)}toMultihash(){return Ct.digest(rr(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=uc(this.raw,r,t);return Bn(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Ci(e){return e=Ti(e,Cn),new _n(e)}function Ti(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new nt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var $d=Math.pow(2,7),Fd=Math.pow(2,14),qd=Math.pow(2,21),Bi=Math.pow(2,28),_i=Math.pow(2,35),Di=Math.pow(2,42),Ri=Math.pow(2,49),Q=128,gt=127;function te(e){if(e<$d)return 1;if(e<Fd)return 2;if(e<qd)return 3;if(e<Bi)return 4;if(e<_i)return 5;if(e<Di)return 6;if(e<Ri)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Hr(e,t,r=0){switch(te(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 Pi(e,t){let r=e[t],n=0;if(n+=r&gt,r<Q||(r=e[t+1],n+=(r&gt)<<7,r<Q)||(r=e[t+2],n+=(r&gt)<<14,r<Q)||(r=e[t+3],n+=(r&gt)<<21,r<Q)||(r=e[t+4],n+=(r&gt)*Bi,r<Q)||(r=e[t+5],n+=(r&gt)*_i,r<Q)||(r=e[t+6],n+=(r&gt)*Di,r<Q)||(r=e[t+7],n+=(r&gt)*Ri,r<Q))return n;throw new RangeError("Could not decode varint")}function Hd(e,t){let r=e.get(t),n=0;if(n+=r&gt,r<Q||(r=e.get(t+1),n+=(r&gt)<<7,r<Q)||(r=e.get(t+2),n+=(r&gt)<<14,r<Q)||(r=e.get(t+3),n+=(r&gt)<<21,r<Q)||(r=e.get(t+4),n+=(r&gt)*Bi,r<Q)||(r=e.get(t+5),n+=(r&gt)*_i,r<Q)||(r=e.get(t+6),n+=(r&gt)*Di,r<Q)||(r=e.get(t+7),n+=(r&gt)*Ri,r<Q))return n;throw new RangeError("Could not decode varint")}function Ni(e,t=0){return e instanceof Uint8Array?Pi(e,t):Hd(e,t)}var Li=new Float32Array([-0]),Te=new Uint8Array(Li.buffer);function lc(e,t,r){Li[0]=e,t[r]=Te[0],t[r+1]=Te[1],t[r+2]=Te[2],t[r+3]=Te[3]}function dc(e,t){return Te[0]=e[t],Te[1]=e[t+1],Te[2]=e[t+2],Te[3]=e[t+3],Li[0]}var Ui=new Float64Array([-0]),xt=new Uint8Array(Ui.buffer);function hc(e,t,r){Ui[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 pc(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],Ui[0]}var jd=BigInt(Number.MAX_SAFE_INTEGER),Gd=BigInt(Number.MIN_SAFE_INTEGER),Dt=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 Ve;if(t<jd&&t>Gd)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>mc&&(o=0n,++n>mc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ve;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):Ve}},Ve=new Dt(0,0);Ve.toBigInt=function(){return 0n};Ve.zzEncode=Ve.zzDecode=function(){return this};Ve.length=function(){return 1};var mc=4294967296n;function yc(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 gc(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 Oi(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 qt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Dn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ki=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,qt(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 qt(this,4);return Dn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return Dn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=dc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=pc(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 qt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return gc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Dt(0,0),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 qt(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 qt(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 qt(this,8);let t=Dn(this.buf,this.pos+=4),r=Dn(this.buf,this.pos+=4);return new Dt(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=Pi(this.buf,this.pos);return this.pos+=te(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ki(e){return new ki(e instanceof Uint8Array?e:e.subarray())}function lr(e,t,r){let n=Ki(e);return t.decode(n,void 0,r)}function Vi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Bt(s);o+s>t&&(n=Bt(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Me=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Mi(){}var Fi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Zd=Vi();function Yd(e){return globalThis.Buffer!=null?Bt(e):Zd(e)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Me(Mi,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Me(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new qi((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(Rn,10,Dt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Dt.fromBigInt(t);return this._push(Rn,r.length(),r)}uint64Number(t){return this._push(Hr,te(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=Dt.fromBigInt(t).zzEncode();return this._push(Rn,r.length(),r)}sint64Number(t){let r=Dt.fromNumber(t).zzEncode();return this._push(Rn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push($i,1,t?1:0)}fixed32(t){return this._push(zr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Dt.fromBigInt(t);return this._push(zr,4,r.lo)._push(zr,4,r.hi)}fixed64Number(t){let r=Dt.fromNumber(t);return this._push(zr,4,r.lo)._push(zr,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(lc,4,t)}double(t){return this._push(hc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push($i,1,0):this.uint32(r)._push(Xd,r,t)}string(t){let r=yc(t);return r!==0?this.uint32(r)._push(Oi,r,t):this._push($i,1,0)}fork(){return this.states=new Fi(this),this.head=this.tail=new Me(Mi,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 Me(Mi,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=Yd(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function $i(e,t,r){t[r]=e&255}function Wd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var qi=class extends Me{next;constructor(t,r){super(Wd,t,r),this.next=void 0}};function Rn(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 zr(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 Xd(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(jr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Jd,t,e),this},jr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Qd,t,e),this});function Jd(e,t,r){t.set(e,r)}function Qd(e,t,r){e.length<40?Oi(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Hi(){return new jr}function dr(e,t){let r=Hi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var hr;(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"})(hr||(hr={}));function Pn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Gr(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 Pn("enum",hr.VARINT,r,n)}function pr(e,t){return Pn("message",hr.LENGTH_DELIMITED,e,t)}var st;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(st||(st={}));var zi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(zi||(zi={}));(function(e){e.codec=()=>Gr(zi)})(st||(st={}));var ee;(function(e){let t;e.codec=()=>(t==null&&(t=pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.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=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>dr(r,e.codec()),e.decode=(r,n)=>lr(r,e.codec(),n)})(ee||(ee={}));var ji;(function(e){let t;e.codec=()=>(t==null&&(t=pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.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=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>dr(r,e.codec()),e.decode=(r,n)=>lr(r,e.codec(),n)})(ji||(ji={}));var Yr={};wt(Yr,{MAX_RSA_KEY_SIZE:()=>Gi,generateRSAKeyPair:()=>vc,jwkToJWKKeyPair:()=>Ac,jwkToPkcs1:()=>nh,jwkToPkix:()=>Xi,jwkToRSAPrivateKey:()=>es,pkcs1MessageToJwk:()=>Yi,pkcs1MessageToRSAPrivateKey:()=>Ji,pkcs1ToJwk:()=>rh,pkcs1ToRSAPrivateKey:()=>Sc,pkixMessageToJwk:()=>Wi,pkixMessageToRSAPublicKey:()=>ts,pkixToJwk:()=>oh,pkixToRSAPublicKey:()=>Qi});var mr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Yr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return j.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return Ec(this.jwk,r,t,n)}},Zr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Yr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}sign(t,r){return wc(this.jwk,t,r)}};var Gi=8192,Zi=18,th=1062,eh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function rh(e){let t=se(e);return Yi(t)}function Yi(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 nh(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 nt("JWK was missing components");return we([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 oh(e){let t=se(e,{offset:0});return Wi(t)}function Wi(e){let t=se(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function Xi(e){if(e.n==null||e.e==null)throw new nt("JWK was missing components");return we([eh,gn(we([At(H(e.n,"base64url")),At(H(e.e,"base64url"))]))]).subarray()}function Sc(e){let t=se(e);return Ji(t)}function Ji(e){let t=Yi(e);return es(t)}function Qi(e,t){if(e.byteLength>=th)throw new Ge("Key size is too large");let r=se(e,{offset:0});return ts(r,e,t)}function ts(e,t,r){let n=Wi(e);if(r==null){let o=ir(ee.encode({Type:st.RSA,Data:t}));r=$t(Zi,o)}return new mr(n,r)}function es(e){if(Tc(e)>Gi)throw new nt("Key size is too large");let t=Ac(e),r=ir(ee.encode({Type:st.RSA,Data:Xi(t.publicKey)})),n=$t(Zi,r);return new Zr(t.privateKey,new mr(t.publicKey,n))}async function vc(e){if(e>Gi)throw new nt("Key size is too large");let t=await Ic(e),r=ir(ee.encode({Type:st.RSA,Data:Xi(t.publicKey)})),n=$t(Zi,r);return new Zr(t.privateKey,new mr(t.publicKey,n))}function Ac(e){if(e==null)throw new nt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Ic(e,t){let r=await Ot.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 ih(r,t);return{privateKey:n[0],publicKey:n[1]}}async function wc(e,t,r){let n=await Ot.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Ot.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 Ec(e,t,r,n){let o=await Ot.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Ot.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function ih(e,t){if(e.privateKey==null||e.publicKey==null)throw new nt("Private and public key are required");let r=await Promise.all([Ot.get().subtle.exportKey("jwk",e.privateKey),Ot.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function Tc(e){if(e.kty!=="RSA")throw new nt("invalid key type");if(e.n==null)throw new nt("invalid key modulus");return H(e.n,"base64url").length*8}var Nn=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(xn(t),q(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),ce(o)}update(t){return nr(this),this.iHash.update(t),this}digestInto(t){nr(this),q(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},rs=(e,t,r)=>new Nn(e,t).update(r).digest();rs.create=(e,t)=>new Nn(e,t);var Cc=(e,t)=>(e+(e>=0?t:-t)/Bc)/t;function sh(e,t,r){let[[n,o],[i,s]]=t,c=Cc(s*e,r),a=Cc(-o*e,r),f=e-c*n-a*i,u=-c*o-a*s,l=f<he,y=u<he;l&&(f=-f),y&&(u=-u);let E=Mr(Math.ceil(pi(r)/2))+yr;if(f<he||f>=E||u<he||u>=E)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:f,k2neg:y,k2:u}}function os(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ns(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return de(r.lowS,"lowS"),de(r.prehash,"prehash"),r.format!==void 0&&os(r.format),r}var is=class extends Error{constructor(t=""){super(t)}},Ce={Err:is,_tlv:{encode:(e,t)=>{let{Err:r}=Ce;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=Kr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Kr(o.length/2|128):"";return Kr(e)+i+o+t},decode(e,t){let{Err:r}=Ce,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}=Ce;if(e<he)throw new t("integer: negative integers are not allowed");let r=Kr(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}=Ce;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 sr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Ce,o=q(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=Ce,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},he=BigInt(0),yr=BigInt(1),Bc=BigInt(2),Ln=BigInt(3),ah=BigInt(4);function _c(e,t={}){let r=An("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;Ae(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=Rc(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:S}=m.toAffine(),R=n.toBytes(d);if(de(g,"isCompressed"),g){u();let N=!n.isOdd(S);return It(Dc(N),R)}else return It(Uint8Array.of(4),R,n.toBytes(S))}function y(A){q(A,void 0,"Point");let{publicKey:m,publicKeyUncompressed:g}=f,d=A.length,S=A[0],R=A.subarray(1);if(d===m&&(S===2||S===3)){let N=n.fromBytes(R);if(!n.isValid(N))throw new Error("bad point: is not on curve, wrong x");let U=T(N),O;try{O=n.sqrt(U)}catch(tt){let W=tt instanceof Error?": "+tt.message:"";throw new Error("bad point: is not on curve, sqrt error"+W)}u();let K=n.isOdd(O);return(S&1)===1!==K&&(O=n.neg(O)),{x:N,y:O}}else if(d===g&&S===4){let N=n.BYTES,U=n.fromBytes(R.subarray(0,N)),O=n.fromBytes(R.subarray(N,N*2));if(!I(U,O))throw new Error("bad point: is not on curve");return{x:U,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${m} or uncompressed=${g}`)}let E=t.toBytes||l,b=t.fromBytes||y;function T(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 I(A,m){let g=n.sqr(m),d=T(A);return n.eql(g,d)}if(!I(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,Ln),ah),C=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,C)))throw new Error("bad curve params: a or b");function v(A,m,g=!1){if(!n.isValid(m)||g&&n.is0(m))throw new Error(`bad point coordinate ${A}`);return m}function L(A){if(!(A instanceof p))throw new Error("Weierstrass Point expected")}function k(A){if(!a||!a.basises)throw new Error("no endo");return sh(A,a.basises,o.ORDER)}let M=ar((A,m)=>{let{X:g,Y:d,Z:S}=A;if(n.eql(S,n.ONE))return{x:g,y:d};let R=A.is0();m==null&&(m=R?n.ONE:n.inv(S));let N=n.mul(g,m),U=n.mul(d,m),O=n.mul(S,m);if(R)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:N,y:U}}),V=ar(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(!I(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,S){return g=new p(n.mul(g.X,A),g.Y,g.Z),m=Fr(d,m),g=Fr(S,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=v("x",m),this.Y=v("y",g,!0),this.Z=v("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(b(q(m,void 0,"point")));return g.assertValidity(),g}static fromHex(m){return p.fromBytes(fe(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(Ln),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){L(m);let{X:g,Y:d,Z:S}=this,{X:R,Y:N,Z:U}=m,O=n.eql(n.mul(g,U),n.mul(R,S)),K=n.eql(n.mul(d,U),n.mul(N,S));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,Ln),{X:S,Y:R,Z:N}=this,U=n.ZERO,O=n.ZERO,K=n.ZERO,F=n.mul(S,S),tt=n.mul(R,R),W=n.mul(N,N),G=n.mul(S,R);return G=n.add(G,G),K=n.mul(S,N),K=n.add(K,K),U=n.mul(m,K),O=n.mul(d,W),O=n.add(U,O),U=n.sub(tt,O),O=n.add(tt,O),O=n.mul(U,O),U=n.mul(G,U),K=n.mul(d,K),W=n.mul(m,W),G=n.sub(F,W),G=n.mul(m,G),G=n.add(G,K),K=n.add(F,F),F=n.add(K,F),F=n.add(F,W),F=n.mul(F,G),O=n.add(O,F),W=n.mul(R,N),W=n.add(W,W),F=n.mul(W,G),U=n.sub(U,F),K=n.mul(W,tt),K=n.add(K,K),K=n.add(K,K),new p(U,O,K)}add(m){L(m);let{X:g,Y:d,Z:S}=this,{X:R,Y:N,Z:U}=m,O=n.ZERO,K=n.ZERO,F=n.ZERO,tt=i.a,W=n.mul(i.b,Ln),G=n.mul(g,R),et=n.mul(d,N),dt=n.mul(S,U),Yt=n.add(g,d),rt=n.add(R,N);Yt=n.mul(Yt,rt),rt=n.add(G,et),Yt=n.sub(Yt,rt),rt=n.add(g,S);let yt=n.add(R,U);return rt=n.mul(rt,yt),yt=n.add(G,dt),rt=n.sub(rt,yt),yt=n.add(d,S),O=n.add(N,U),yt=n.mul(yt,O),O=n.add(et,dt),yt=n.sub(yt,O),F=n.mul(tt,rt),O=n.mul(W,dt),F=n.add(O,F),O=n.sub(et,F),F=n.add(et,F),K=n.mul(O,F),et=n.add(G,G),et=n.add(et,G),dt=n.mul(tt,dt),rt=n.mul(W,rt),et=n.add(et,dt),dt=n.sub(G,dt),dt=n.mul(tt,dt),rt=n.add(rt,dt),G=n.mul(et,rt),K=n.add(K,G),G=n.mul(yt,rt),O=n.mul(Yt,O),O=n.sub(O,G),G=n.mul(Yt,et),F=n.mul(yt,F),F=n.add(F,G),new p(O,K,F)}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,S,R=N=>D.cached(this,N,U=>Ke(p,U));if(g){let{k1neg:N,k1:U,k2neg:O,k2:K}=k(m),{p:F,f:tt}=R(U),{p:W,f:G}=R(K);S=tt.add(G),d=h(g.beta,F,W,N,O)}else{let{p:N,f:U}=R(m);d=N,S=U}return Ke(p,[d,S])[0]}multiplyUnsafe(m){let{endo:g}=t,d=this;if(!o.isValid(m))throw new Error("invalid scalar: out of range");if(m===he||d.is0())return p.ZERO;if(m===yr)return d;if(D.hasCache(this))return this.multiply(m);if(g){let{k1neg:S,k1:R,k2neg:N,k2:U}=k(m),{p1:O,p2:K}=rc(p,d,R,U);return h(g.beta,O,K,S,N)}else return D.unsafe(d,m)}toAffine(m){return M(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return s===yr?!0:m?m(p,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:m}=t;return s===yr?this:m?m(p,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return de(m,"isCompressed"),this.assertValidity(),E(p,this,m)}toHex(m=!0){return ue(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,D=new fr(p,t.endo?Math.ceil(_/2):_);return p.BASE.precompute(8),p}function Dc(e){return Uint8Array.of(e?2:3)}function Rc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ch(e,t={}){let{Fn:r}=e,n=t.randomBytes||or,o=Object.assign(Rc(e.Fp,r),{seed:xi(r.ORDER)});function i(E){try{let b=r.fromBytes(E);return r.isValidNot0(b)}catch{return!1}}function s(E,b){let{publicKey:T,publicKeyUncompressed:I}=o;try{let w=E.length;return b===!0&&w!==T||b===!1&&w!==I?!1:!!e.fromBytes(E)}catch{return!1}}function c(E=n(o.seed)){return bi(q(E,o.seed,"seed"),r.ORDER)}function a(E,b=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(b)}function f(E){let{secretKey:b,publicKey:T,publicKeyUncompressed:I}=o;if(!Pe(E)||"_lengths"in r&&r._lengths||b===T)return;let w=q(E,void 0,"key").length;return w===T||w===I}function u(E,b,T=!0){if(f(E)===!0)throw new Error("first arg must be private key");if(f(b)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(E);return e.fromBytes(b).multiply(I).toBytes(T)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},y=In(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:y,Point:e,utils:l,lengths:o})}function Pc(e,t,r={}){xn(t),Ae(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||or,o=r.hmac||((g,d)=>rs(t,g,d)),{Fp:i,Fn:s}=e,{ORDER:c,BITS:a}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:y,lengths:E}=ch(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},T=c*Bc<i.ORDER;function I(g){let d=c>>yr;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 C(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(g,d){os(d);let S=E.signature,R=d==="compact"?S:d==="recovered"?S+1:void 0;return q(g,R)}class L{r;s;recovery;constructor(d,S,R){if(this.r=w("r",d),this.s=w("s",S),R!=null){if(C(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(d,S=b.format){v(d,S);let R;if(S==="der"){let{r:K,s:F}=Ce.toSig(q(d));return new L(K,F)}S==="recovered"&&(R=d[0],S="compact",d=d.subarray(1));let N=E.signature/2,U=d.subarray(0,N),O=d.subarray(N,N*2);return new L(s.fromBytes(U),s.fromBytes(O),R)}static fromHex(d,S){return this.fromBytes(fe(d),S)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new L(this.r,this.s,d)}recoverPublicKey(d){let{r:S,s:R}=this,N=this.assertRecovery(),U=N===2||N===3?S+c:S;if(!i.isValid(U))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(U),K=e.fromBytes(It(Dc((N&1)===0),O)),F=s.inv(U),tt=M(q(d,void 0,"msgHash")),W=s.create(-tt*F),G=s.create(R*F),et=e.BASE.multiplyUnsafe(W).add(K.multiplyUnsafe(G));if(et.is0())throw new Error("invalid recovery: point at infinify");return et.assertValidity(),et}hasHighS(){return I(this.s)}toBytes(d=b.format){if(os(d),d==="der")return fe(Ce.hexFromSig(this));let{r:S,s:R}=this,N=s.toBytes(S),U=s.toBytes(R);return d==="recovered"?(C(),It(Uint8Array.of(this.assertRecovery()),N,U)):It(N,U)}toHex(d){return ue(this.toBytes(d))}}let k=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let S=sr(d),R=d.length*8-a;return R>0?S>>BigInt(R):S},M=r.bits2int_modN||function(d){return s.create(k(d))},V=Mr(a);function h(g){return Vr("num < 2^"+a,g,he,V),s.toBytes(g)}function p(g,d){return q(g,void 0,"message"),d?q(t(g),void 0,"prehashed message"):g}function _(g,d,S){let{lowS:R,prehash:N,extraEntropy:U}=ns(S,b);g=p(g,N);let O=M(g),K=s.fromBytes(d);if(!s.isValidNot0(K))throw new Error("invalid private key");let F=[h(K),h(O)];if(U!=null&&U!==!1){let et=U===!0?n(E.secretKey):U;F.push(q(et,void 0,"extraEntropy"))}let tt=It(...F),W=O;function G(et){let dt=k(et);if(!s.isValidNot0(dt))return;let Yt=s.inv(dt),rt=e.BASE.multiply(dt).toAffine(),yt=s.create(rt.x);if(yt===he)return;let ln=s.create(Yt*s.create(W+yt*K));if(ln===he)return;let qs=(rt.x===yt?0:2)|Number(rt.y&yr),Hs=ln;return R&&I(ln)&&(Hs=s.neg(ln),qs^=1),new L(yt,Hs,T?void 0:qs)}return{seed:tt,k2sig:G}}function D(g,d,S={}){let{seed:R,k2sig:N}=_(g,d,S);return Va(t.outputLen,s.BYTES,o)(R,N).toBytes(S.format)}function A(g,d,S,R={}){let{lowS:N,prehash:U,format:O}=ns(R,b);if(S=q(S,void 0,"publicKey"),d=p(d,U),!Pe(g)){let K=g instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}v(g,O);try{let K=L.fromBytes(g,O),F=e.fromBytes(S);if(N&&K.hasHighS())return!1;let{r:tt,s:W}=K,G=M(d),et=s.inv(W),dt=s.create(G*et),Yt=s.create(tt*et),rt=e.BASE.multiplyUnsafe(dt).add(F.multiplyUnsafe(Yt));return rt.is0()?!1:s.create(rt.x)===tt}catch{return!1}}function m(g,d,S={}){let{prehash:R}=ns(S,b);return d=p(d,R),L.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:y,lengths:E,Point:e,sign:D,verify:A,recoverPublicKey:m,Signature:L,hash:t})}var as={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},uh={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Nc=BigInt(2);function fh(e){let t=as.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=J(u,r,t)*u%t,y=J(l,r,t)*u%t,E=J(y,Nc,t)*f%t,b=J(E,o,t)*E%t,T=J(b,i,t)*b%t,I=J(T,c,t)*T%t,w=J(I,a,t)*I%t,C=J(w,c,t)*T%t,v=J(C,r,t)*u%t,L=J(v,s,t)*b%t,k=J(L,n,t)*f%t,M=J(k,Nc,t);if(!ss.eql(ss.sqr(M),e))throw new Error("Cannot find square root");return M}var ss=cr(as.p,{sqrt:fh}),lh=_c(as,{Fp:ss,endo:uh}),gr=Pc(lh,ir);function Lc(e,t,r,n){let o=Rr.digest(r instanceof Uint8Array?r:r.subarray());if(Bn(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),gr.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new qr(String(i))});try{return n?.signal?.throwIfAborted(),gr.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new qr(String(i))}}var Un=class{type="secp256k1";raw;_key;constructor(t){this._key=Oc(t),this.raw=Uc(this._key)}toMultihash(){return Ct.digest(rr(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return Lc(this._key,r,t,n)}};function cs(e){return new Un(e)}function Uc(e){return gr.Point.fromBytes(e).toBytes()}function Oc(e){try{return gr.Point.fromBytes(e),e}catch(t){throw new Ge(String(t))}}function kc(e,t){let{Type:r,Data:n}=ee.decode(e),o=n??new Uint8Array;switch(r){case st.RSA:return Qi(o,t);case st.Ed25519:return Ci(o);case st.secp256k1:return cs(o);case st.ECDSA:return ri(o);default:throw new Ye}}function On(e){let{Type:t,Data:r}=ee.decode(e.digest),n=r??new Uint8Array;switch(t){case st.Ed25519:return Ci(n);case st.secp256k1:return cs(n);case st.ECDSA:return ri(n);default:throw new Ye}}function rr(e){return ee.encode({Type:st[e.type],Data:e.raw})}var Kc=Symbol.for("nodejs.util.inspect.custom"),dh=114,Wr=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()})`}[pn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return j.createV1(dh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Y(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Y(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Kc](){return`PeerId(${this.toString()})`}},kn=class extends Wr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Kn=class extends Wr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Vn=class extends Wr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},hh=2336,Xr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Ct.digest(H(this.url))}[Kc](){return`PeerId(${this.url})`}[pn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return j.createV1(hh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=z(t)),t.toString()===this.toString())}};var ph=114,Vc=2336;function Mc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=be(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return us(j.parse(e));if(t==null)throw new nt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=be(t.decode(e))}return Mn(r)}function Mn(e){if(yh(e))return new kn({multihash:e});if(mh(e))try{let t=On(e);if(t.type==="Ed25519")return new Kn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Vn({multihash:e,publicKey:t})}catch{let r=z(e.digest);return new Xr(new URL(r))}throw new Ze("Supplied PeerID Multihash is invalid")}function us(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==ph&&e.code!==Vc)throw new hn("Supplied PeerID CID is invalid");if(e.code===Vc){let t=z(e.multihash.digest);return new Xr(new URL(t))}return Mn(e.multihash)}function mh(e){return e.code===Ct.code}function yh(e){return e.code===Rr.code}var pt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},pe=class extends Error{static name="ValidationError";name="ValidationError"},$n=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Fn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var qn=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 gh=45,xh=15,Hn=new qn;function $c(e){if(!(e.length>xh))return Hn.new(e).parseWith(()=>Hn.readIPv4Addr())}function Fc(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>gh))return Hn.new(e).parseWith(()=>Hn.readIPv6Addr())}function zn(e){return!!$c(e)}function qc(e){return!!Fc(e)}function ls(e){return t=>z(t,e)}function ds(e){return t=>H(t,e)}function xr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function $e(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Hc(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=H(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=$e(n);return Ut([r,o],r.length+o.length)}function zc(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=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=$e(n);return Ut([r,o],r.length+o.length)}function hs(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=z(t,"base32"),o=xr(r);return`${n}:${o}`}var ps=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new pt("Invalid byte value in IP address");t[n]=o}),t},jc=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=zn(r[n]),s;i&&(s=ps(r[n]),r[n]=z(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,z(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new pt("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},Gc=function(e){if(e.byteLength!==4)throw new pt("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Zc=function(e){if(e.byteLength!==16)throw new pt("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],i=e[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;t.push(s)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new pt(`Invalid IPv6 address "${r}"`)}};function Yc(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new pt(`Invalid IPv6 address "${e}"`)}}var fs=Object.values(Pr).map(e=>e.decoder),bh=(function(){let e=fs[0].or(fs[1]);return fs.slice(2).forEach(t=>e=e.or(t)),e})();function Wc(e){return bh.decode(e)}function Xc(e){return t=>e.encoder.encode(t)}function wh(e){if(parseInt(e).toString()!==e)throw new pe("Value must be an integer")}function Eh(e){if(e<0)throw new pe("Value must be a positive integer, or zero")}function Sh(e){return t=>{if(t>e)throw new pe(`Value must be smaller than or equal to ${e}`)}}function vh(...e){return t=>{for(let r of e)r(t)}}var Jr=vh(wh,Eh,Sh(65535));var ft=-1,ms=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 Fn(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},me=new ms,fp=[{code:4,name:"ip4",size:32,valueToBytes:ps,bytesToValue:Gc,validate:e=>{if(!zn(e))throw new pe(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:$e,bytesToValue:xr,validate:Jr},{code:273,name:"udp",size:16,valueToBytes:$e,bytesToValue:xr,validate:Jr},{code:33,name:"dccp",size:16,valueToBytes:$e,bytesToValue:xr,validate:Jr},{code:41,name:"ip6",size:128,valueToBytes:jc,bytesToValue:Zc,stringToValue:Yc,validate:e=>{if(!qc(e))throw new pe(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ft},{code:43,name:"ipcidr",size:8,bytesToValue:ls("base10"),valueToBytes:ds("base10")},{code:53,name:"dns",size:ft},{code:54,name:"dns4",size:ft},{code:55,name:"dns6",size:ft},{code:56,name:"dnsaddr",size:ft},{code:132,name:"sctp",size:16,valueToBytes:$e,bytesToValue:xr,validate:Jr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ft,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ft,bytesToValue:ls("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?ds("base58btc")(e):j.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:hs,valueToBytes:Hc},{code:445,name:"onion3",size:296,bytesToValue:hs,valueToBytes:zc},{code:446,name:"garlic64",size:ft},{code:447,name:"garlic32",size:ft},{code:448,name:"tls"},{code:449,name:"sni",size:ft},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ft,bytesToValue:Xc(qo),valueToBytes:Wc},{code:480,name:"http"},{code:481,name:"http-path",size:ft,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ft}];fp.forEach(e=>{me.addProtocol(e)});function Jc(e){let t=[],r=0;for(;r<e.length;){let n=Ni(e,r),o=me.getProtocol(n),i=te(n),s=lp(o,e,r+i),c=0;s>0&&o.size===ft&&(c=te(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 Qc(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=me.getProtocol(n.code),i=te(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??H(n.value),c=s.byteLength,o.size===ft&&(a=te(c)));let f=new Uint8Array(i+a+c),u=0;Hr(n.code,f,u),u+=i,s!=null&&(o.size===ft&&(Hr(c,f,u),u+=a),f.set(s,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Ut(r,t)}function tu(e){if(e.charAt(0)!=="/")throw new pt('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let i=1;i<e.length;i++){let s=e.charAt(i);s!=="/"&&(r==="protocol"?o+=e.charAt(i):n+=e.charAt(i));let c=i===e.length-1;if(s==="/"||c){let a=me.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){t.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new pt(`Component ${o} was missing value`);r="value"}else if(r==="value"){let f={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new pt(`Component ${o} was missing value`);f.value=a.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new pt("Incomplete multiaddr");return t}function eu(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=me.getProtocol(t.code);if(r==null)throw new pt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function lp(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Ni(t,r)}var dp=Symbol.for("nodejs.util.inspect.custom"),ys=Symbol.for("@multiformats/multiaddr");function hp(e){if(e==null&&(e="/"),ru(e))return e.getComponents();if(e instanceof Uint8Array)return Jc(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),tu(e);if(Array.isArray(e))return e;throw new pt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var jn=class e{[ys]=!0;#t;#n;#e;constructor(t="/",r={}){this.#t=hp(t),r.validate!==!1&&pp(this)}get bytes(){return this.#e==null&&(this.#e=Qc(this.#t)),this.#e}toString(){return this.#n==null&&(this.#n=eu(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 $n(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}equals(t){return Y(this.bytes,t.bytes)}[dp](){return`Multiaddr(${this.toString()})`}};function pp(e){e.getComponents().forEach(t=>{let r=me.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function ru(e){return!!e?.[ys]}function Gn(e){return new jn(e)}function br(e){let t=new globalThis.AbortController;function r(){let i=e.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();t.abort(i);for(let s of e)s?.removeEventListener!=null&&s.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*Qr(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()}}function mp(e,t){if(typeof e=="string")return yp(e);if(typeof e=="number")return bp(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var Zn=mp;function yp(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 gp(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 xp(e){let t=Math.abs(e);return t>=315576e5?Fe(e,t,315576e5,"year"):t>=26298e5?Fe(e,t,26298e5,"month"):t>=6048e5?Fe(e,t,6048e5,"week"):t>=864e5?Fe(e,t,864e5,"day"):t>=36e5?Fe(e,t,36e5,"hour"):t>=6e4?Fe(e,t,6e4,"minute"):t>=1e3?Fe(e,t,1e3,"second"):`${e} ms`}function bp(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?xp(e):gp(e)}function Fe(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function gs(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=Zn,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,E=null,b,T;function I(...w){if(!I.enabled)return;let C=I,v=Number(new Date),L=v-(y||v);C.diff=L,C.prev=y,C.curr=v,y=v,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(C,_),w.splice(k,1),k--}return V}),r.formatArgs.call(C,w),l?.onLog!=null&&l.onLog(...w),(C.log||r.log).apply(C,w)}return I.namespace=u,I.useColors=r.useColors(),I.color=r.selectColor(u),I.extend=n,I.destroy=r.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(b!==r.namespaces&&(b=r.namespaces,T=r.enabled(u)),T),set:w=>{E=w}}),typeof r.init=="function"&&r.init(I),I}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,]+/),E=y.length;for(l=0;l<E;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 Yn=Tp(),wp=["#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 Ep(){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 Sp(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Zn(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 vp=console.debug??console.log??(()=>{});function Ap(e){try{e?Yn?.setItem("debug",e):Yn?.removeItem("debug")}catch{}}function Ip(){let e;try{e=Yn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Tp(){try{return localStorage}catch{}}function Cp(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var nu=gs({formatArgs:Sp,save:Ap,load:Ip,useColors:Ep,setupFormatters:Cp,colors:wp,storage:Yn,log:vp});var Tt=nu;Tt.formatters.b=e=>e==null?"undefined":X.baseEncode(e);Tt.formatters.t=e=>e==null?"undefined":Wt.baseEncode(e);Tt.formatters.m=e=>e==null?"undefined":Fo.baseEncode(e);Tt.formatters.p=e=>e==null?"undefined":e.toString();Tt.formatters.c=e=>e==null?"undefined":e.toString();Tt.formatters.k=e=>e==null?"undefined":e.toString();Tt.formatters.a=e=>e==null?"undefined":e.toString();function ou(e,t=""){let r=iu(e.message),n=iu(e.stack);return r!=null&&n!=null?n.includes(r)?`${n.split(`
2
+ "use strict";var HeliaRouters=(()=>{var Vf=Object.create;var hn=Object.defineProperty;var Mf=Object.getOwnPropertyDescriptor;var $f=Object.getOwnPropertyNames;var Ff=Object.getPrototypeOf,qf=Object.prototype.hasOwnProperty;var zs=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),wt=(e,t)=>{for(var r in t)hn(e,r,{get:t[r],enumerable:!0})},js=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $f(t))!qf.call(e,o)&&o!==r&&hn(e,o,{get:()=>t[o],enumerable:!(n=Mf(t,o))||n.enumerable});return e};var Co=(e,t,r)=>(r=e!=null?Vf(Ff(e)):{},js(t||!e||!e.__esModule?hn(r,"default",{value:e,enumerable:!0}):r,e)),Hf=e=>js(hn({},"__esModule",{value:!0}),e);var ws=zs((Rw,bs)=>{var Dw=(function(){typeof bs<"u"&&(bs.exports=T);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",f=Math.trunc||function(h){var p=h-h%1;return p==0&&(h<0||h===0&&1/h!=1/0)?-0:p},u=T.prototype,l=(T.fromDate=function(h){return new T(+h)},T.fromInt64BE=N(0,1,2,3,0,4),T.fromInt64LE=N(3,2,1,0,4,0),T.fromString=function(D){var p,_=new T,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 I(_)},T.fromTimeT=function(h){return C(h,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(h){return this.nano+=+h||0,this},u.getNano=function(){var h=I(this);return(h.time%1e3*c+ +h.nano+1e9)%1e9},u.getTimeT=function(){var p=I(this),h=Math.floor(p.time/1e3),p=p.year;return p&&(h+=p*r*e/t),h},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return w(I(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(h){var p=this,_=p.toDate(),D={H:function(){return 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 E[_.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 S=g[1],d=b[S],S=D[S];return d?A(d):S?S():g})})(h||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],E=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],b={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return T;function T(h,p,_){var D=this;if(!(D instanceof T))return new T(h,p,_);D.time=+h||0,D.nano=+p||0,D.year=+_||0,I(D)}function I(h){var p,_,D,A=h.year,m=h.time,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 C(A,D){A=+A||0;var _=f((D=(D|0)*s)/n)+f(A/n),D=D%n+A%n,A=f(D/n);return A&&(_+=A,D-=A*n),new T(1e3*D,0,_*t)}function v(h,p,_,D,A,m){return function(d,S){var L=I(this);d=d||new Array(8),k(d,S|=0);var U=Math.floor(L.time/1e3),L=L.year*(r*e/t),R=f(L/s)+f(U/s),L=L%s+U%s,U=Math.floor(L/s);return U&&(R+=U,L-=U*s),g(d,S+A,R),g(d,S+m,L),d};function g(d,S,R){d[S+h]=R>>24&255,d[S+p]=R>>16&255,d[S+_]=R>>8&255,d[S+D]=255&R}}function N(h,p,_,D,A,m){return function(d,S){k(d,S|=0);var R=g(d,S+A);return C(g(d,S+m),R)};function g(d,S){return 16777216*d[S+h]+(d[S+p]<<16|d[S+_]<<8|d[S+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 Ef=zs((g2,_s)=>{"use strict";var g0=Object.prototype.hasOwnProperty,St="~";function cn(){}Object.create&&(cn.prototype=Object.create(null),new cn().__proto__||(St=!1));function x0(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function wf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new x0(r,n||e,o),s=St?St+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function xo(e,t){--e._eventsCount===0?e._events=new cn:delete e._events[t]}function bt(){this._events=new cn,this._eventsCount=0}bt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)g0.call(r,n)&&t.push(St?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};bt.prototype.listeners=function(t){var r=St?St+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};bt.prototype.listenerCount=function(t){var r=St?St+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=St?St+t:t;if(!this._events[c])return!1;var a=this._events[c],f=arguments.length,u,l;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),f){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,r),!0;case 3:return a.fn.call(a.context,r,n),!0;case 4:return a.fn.call(a.context,r,n,o),!0;case 5:return a.fn.call(a.context,r,n,o,i),!0;case 6:return a.fn.call(a.context,r,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];a.fn.apply(a.context,u)}else{var y=a.length,E;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(E=1,u=new Array(f-1);E<f;E++)u[E-1]=arguments[E];a[l].fn.apply(a[l].context,u)}}return!0};bt.prototype.on=function(t,r,n){return wf(this,t,r,n,!1)};bt.prototype.once=function(t,r,n){return wf(this,t,r,n,!0)};bt.prototype.removeListener=function(t,r,n,o){var i=St?St+t:t;if(!this._events[i])return this;if(!r)return xo(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&xo(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:xo(this,i)}return this};bt.prototype.removeAllListeners=function(t){var r;return t?(r=St?St+t:t,this._events[r]&&xo(this,r)):(this._events=new cn,this._eventsCount=0),this};bt.prototype.off=bt.prototype.removeListener;bt.prototype.addListener=bt.prototype.on;bt.prefixed=St;bt.EventEmitter=bt;typeof _s<"u"&&(_s.exports=bt)});var $0={};wt($0,{delegatedHTTPRouting:()=>_f,delegatedHTTPRoutingDefaults:()=>ln,httpGatewayRouting:()=>kf,libp2pRouting:()=>Kf});var Po={};wt(Po,{base32:()=>Wt,base32hex:()=>tl,base32hexpad:()=>rl,base32hexpadupper:()=>nl,base32hexupper:()=>el,base32pad:()=>Jf,base32padupper:()=>Qf,base32upper:()=>Xf,base32z:()=>ol});var q0=new Uint8Array(0);function Gs(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 oe(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Zs(e){return new TextEncoder().encode(e)}function Ys(e){return new TextDecoder().decode(e)}function zf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=e.length,a=e.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var T=0,I=0,w=0,C=b.length;w!==C&&b[w]===0;)w++,T++;for(var v=(C-w)*u+1>>>0,N=new Uint8Array(v);w!==C;){for(var k=b[w],M=0,V=v-1;(k!==0||M<I)&&V!==-1;V--,M++)k+=256*N[V]>>>0,N[V]=k%c>>>0,k=k/c>>>0;if(k!==0)throw new Error("Non-zero carry");I=M,w++}for(var h=v-I;h!==v&&N[h]===0;)h++;for(var p=a.repeat(T);h<v;++h)p+=e.charAt(N[h]);return p}function y(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var T=0;if(b[T]!==" "){for(var I=0,w=0;b[T]===a;)I++,T++;for(var C=(b.length-T)*f+1>>>0,v=new Uint8Array(C);b[T];){var N=r[b.charCodeAt(T)];if(N===255)return;for(var k=0,M=C-1;(N!==0||k<w)&&M!==-1;M--,k++)N+=c*v[M]>>>0,v[M]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");w=k,T++}if(b[T]!==" "){for(var V=C-w;V!==C&&v[V]===0;)V++;for(var h=new Uint8Array(I+(C-V)),p=I;V!==C;)h[p++]=v[V++];return h}}}function E(b){var T=y(b);if(T)return T;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:y,decode:E}}var jf=zf,Gf=jf,Xs=Gf;var Bo=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")}},_o=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 Js(this,t)}},Do=class{decoders;constructor(t){this.decoders=t}or(t){return Js(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 Js(e,t){return new Do({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ro=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 Bo(t,r,n),this.decoder=new _o(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ge({name:e,prefix:t,encode:r,decode:n}){return new Ro(e,t,r,n)}function xe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Xs(r,e);return Ge({prefix:t,name:e,encode:n,decode:i=>oe(o(i))})}function Zf(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 Yf(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 Wf(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=Wf(n);return Ge({prefix:t,name:e,encode(i){return Yf(i,n,r)},decode(i){return Zf(i,o,r,e)}})}var Wt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xf=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jf=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qf=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tl=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),el=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rl=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),nl=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ol=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Lo={};wt(Lo,{base58btc:()=>X,base58flickr:()=>il});var X=xe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),il=xe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oo={};wt(Oo,{base64:()=>No,base64pad:()=>sl,base64url:()=>Uo,base64urlpad:()=>al});var No=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sl=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Uo=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),al=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function cl(e,t){if(typeof e=="string")return ul(e);if(typeof e=="number")return dl(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var pn=cl;function ul(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 fl(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 ll(e){let t=Math.abs(e);return t>=315576e5?Pe(e,t,315576e5,"year"):t>=26298e5?Pe(e,t,26298e5,"month"):t>=6048e5?Pe(e,t,6048e5,"week"):t>=864e5?Pe(e,t,864e5,"day"):t>=36e5?Pe(e,t,36e5,"hour"):t>=6e4?Pe(e,t,6e4,"minute"):t>=1e3?Pe(e,t,1e3,"second"):`${e} ms`}function dl(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?ll(e):fl(e)}function Pe(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function ko(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=pn,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,E=null,b,T;function I(...w){if(!I.enabled)return;let C=I,v=Number(new Date),N=v-(y||v);C.diff=N,C.prev=y,C.curr=v,y=v,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(C,_),w.splice(k,1),k--}return V}),r.formatArgs.call(C,w),l?.onLog!=null&&l.onLog(...w),(C.log||r.log).apply(C,w)}return I.namespace=u,I.useColors=r.useColors(),I.color=r.selectColor(u),I.extend=n,I.destroy=r.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(b!==r.namespaces&&(b=r.namespaces,T=r.enabled(u)),T),set:w=>{E=w}}),typeof r.init=="function"&&r.init(I),I}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,]+/),E=y.length;for(l=0;l<E;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 mn=bl(),hl=["#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 pl(){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 ml(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+pn(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var yl=console.debug??console.log??(()=>{});function gl(e){try{e?mn?.setItem("debug",e):mn?.removeItem("debug")}catch{}}function xl(){let e;try{e=mn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function bl(){try{return localStorage}catch{}}function wl(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Qs=ko({formatArgs:ml,save:gl,load:xl,useColors:pl,setupFormatters:wl,colors:hl,storage:mn,log:yl});var vt=Qs;vt.formatters.b=e=>e==null?"undefined":X.baseEncode(e);vt.formatters.t=e=>e==null?"undefined":Wt.baseEncode(e);vt.formatters.m=e=>e==null?"undefined":No.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 ta(e,t=""){let r=ea(e.message),n=ea(e.stack);return r!=null&&n!=null?n.includes(r)?`${n.split(`
4
4
  `).join(`
5
5
  ${t}`)}`:`${r}
6
6
  ${t}${n.split(`
7
7
  `).join(`
8
8
  ${t}`)}`:n!=null?`${n.split(`
9
9
  `).join(`
10
- ${t}`)}`:r!=null?`${r}`:`${e.toString()}`}function Bp(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}function su(e,t=""){if(Bp(e)){let r=ou(e,t);return e.errors.length>0?(t=`${t} `,r+=`
11
- ${t}${e.errors.map(n=>`${su(n,`${t}`)}`).join(`
10
+ ${t}`)}`:r!=null?`${r}`:`${e.toString()}`}function El(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}function ra(e,t=""){if(El(e)){let r=ta(e,t);return e.errors.length>0?(t=`${t} `,r+=`
11
+ ${t}${e.errors.map(n=>`${ra(n,`${t}`)}`).join(`
12
12
  ${t}`)}`):r+=`
13
- ${t}[Error list was empty]`,r.trim()}return ou(e,t)}Tt.formatters.e=e=>e==null?"undefined":su(e);function _p(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 qe(e,t){let r=_p(`${e}:trace`);return Tt.enabled(`${e}:trace`)&&Tt.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=Tt(`${e}:trace`,t)),Object.assign(Tt(e,t),{error:Tt(`${e}:error`,t),trace:r,newScope:n=>qe(`${e}:${n}`,t)})}function iu(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var d0=To(bs(),1);var Ht=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Wn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},wr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Xn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Jn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Qn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},tn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var zt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),(function(o){o.codec=()=>Gr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=pr((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=>dr(o,e.codec()),e.decode=(o,i)=>lr(o,e.codec(),i)})(zt||(zt={}));var Dp=["string","number","bigint","symbol"],Rp=["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 au(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Dp.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Pp(e))return"Buffer";let r=Np(e);return r||"Object"}function Pp(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Np(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Rp.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 P=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 Er=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Lp=new TextDecoder,Up=new TextEncoder;function to(e){return Er&&globalThis.Buffer.isBuffer(e)}function ws(e){return e instanceof Uint8Array?to(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var lu=Er?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):uu(e,t,r):(e,t,r)=>r-t>64?Lp.decode(e.subarray(t,r)):uu(e,t,r),du=Er?e=>e.length>64?globalThis.Buffer.from(e):cu(e):e=>e.length>64?Up.encode(e):cu(e),re=e=>Uint8Array.from(e),Sr=Er?(e,t,r)=>to(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),hu=Er?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ws(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},pu=Er?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function eo(e,t){if(to(e)&&to(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 cu(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 uu(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 Op(n)}var fu=4096;function Op(e){let t=e.length;if(t<=fu)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=fu));return r}var kp=256,en=class{constructor(t=kp){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=pu(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=Sr(n,0,this.cursor)}else r=hu(this.chunks,this.cursor);return t&&this.reset(),r}};var $="CBOR decode error:",Es="CBOR encode error:",rn=[];rn[23]=1;rn[24]=2;rn[25]=3;rn[26]=5;rn[27]=9;function ye(e,t,r){if(e.length-t<r)throw new Error(`${$} not enough data for type`)}var lt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Rt(e,t,r){ye(e,t,1);let n=e[t];if(r.strict===!0&&n<lt[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Pt(e,t,r){ye(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<lt[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){ye(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<lt[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Lt(e,t,r){ye(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<lt[3])throw new Error(`${$} 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(`${$} integers outside of the safe integer range are not supported`)}function mu(e,t,r,n){return new P(x.uint,Rt(e,t+1,n),2)}function yu(e,t,r,n){return new P(x.uint,Pt(e,t+1,n),3)}function gu(e,t,r,n){return new P(x.uint,Nt(e,t+1,n),5)}function xu(e,t,r,n){return new P(x.uint,Lt(e,t+1,n),9)}function kt(e,t){return mt(e,0,t.value)}function mt(e,t,r){if(r<lt[0]){let n=Number(r);e.push([t|n])}else if(r<lt[1]){let n=Number(r);e.push([t|24,n])}else if(r<lt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<lt[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<lt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}kt.encodedSize=function(t){return mt.encodedSize(t.value)};mt.encodedSize=function(t){return t<lt[0]?1:t<lt[1]?2:t<lt[2]?3:t<lt[3]?5:9};kt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function bu(e,t,r,n){return new P(x.negint,-1-Rt(e,t+1,n),2)}function wu(e,t,r,n){return new P(x.negint,-1-Pt(e,t+1,n),3)}function Eu(e,t,r,n){return new P(x.negint,-1-Nt(e,t+1,n),5)}var Ss=BigInt(-1),Su=BigInt(1);function vu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new P(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new P(x.negint,Ss-BigInt(o),9)}function ro(e,t){let r=t.value,n=typeof r=="bigint"?r*Ss-Su:r*-1-1;mt(e,t.type.majorEncoded,n)}ro.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ss-Su:r*-1-1;return n<lt[0]?1:n<lt[1]?2:n<lt[2]?3:n<lt[3]?5:9};ro.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function nn(e,t,r,n){ye(e,t,r+n);let o=Sr(e,t+r,t+r+n);return new P(x.bytes,o,r+n)}function Au(e,t,r,n){return nn(e,t,1,r)}function Iu(e,t,r,n){return nn(e,t,2,Rt(e,t+1,n))}function Tu(e,t,r,n){return nn(e,t,3,Pt(e,t+1,n))}function Cu(e,t,r,n){return nn(e,t,5,Nt(e,t+1,n))}function Bu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return nn(e,t,9,o)}function no(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===x.string?du(e.value):e.value),e.encodedBytes}function vr(e,t){let r=no(t);mt(e,t.type.majorEncoded,r.length),e.push(r)}vr.encodedSize=function(t){let r=no(t);return mt.encodedSize(r.length)+r.length};vr.compareTokens=function(t,r){return Vp(no(t),no(r))};function Vp(e,t){return e.length<t.length?-1:e.length>t.length?1:eo(e,t)}function on(e,t,r,n,o){let i=r+n;ye(e,t,i);let s=new P(x.string,lu(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Sr(e,t+r,t+i)),s}function _u(e,t,r,n){return on(e,t,1,r,n)}function Du(e,t,r,n){return on(e,t,2,Rt(e,t+1,n),n)}function Ru(e,t,r,n){return on(e,t,3,Pt(e,t+1,n),n)}function Pu(e,t,r,n){return on(e,t,5,Nt(e,t+1,n),n)}function Nu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return on(e,t,9,o,n)}var Lu=vr;function Ar(e,t,r,n){return new P(x.array,n,r)}function Uu(e,t,r,n){return Ar(e,t,1,r)}function Ou(e,t,r,n){return Ar(e,t,2,Rt(e,t+1,n))}function ku(e,t,r,n){return Ar(e,t,3,Pt(e,t+1,n))}function Ku(e,t,r,n){return Ar(e,t,5,Nt(e,t+1,n))}function Vu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return Ar(e,t,9,o)}function Mu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Ar(e,t,1,1/0)}function oo(e,t){mt(e,x.array.majorEncoded,t.value)}oo.compareTokens=kt.compareTokens;oo.encodedSize=function(t){return mt.encodedSize(t.value)};function Ir(e,t,r,n){return new P(x.map,n,r)}function $u(e,t,r,n){return Ir(e,t,1,r)}function Fu(e,t,r,n){return Ir(e,t,2,Rt(e,t+1,n))}function qu(e,t,r,n){return Ir(e,t,3,Pt(e,t+1,n))}function Hu(e,t,r,n){return Ir(e,t,5,Nt(e,t+1,n))}function zu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return Ir(e,t,9,o)}function ju(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Ir(e,t,1,1/0)}function io(e,t){mt(e,x.map.majorEncoded,t.value)}io.compareTokens=kt.compareTokens;io.encodedSize=function(t){return mt.encodedSize(t.value)};function Gu(e,t,r,n){return new P(x.tag,r,1)}function Zu(e,t,r,n){return new P(x.tag,Rt(e,t+1,n),2)}function Yu(e,t,r,n){return new P(x.tag,Pt(e,t+1,n),3)}function Wu(e,t,r,n){return new P(x.tag,Nt(e,t+1,n),5)}function Xu(e,t,r,n){return new P(x.tag,Lt(e,t+1,n),9)}function so(e,t){mt(e,x.tag.majorEncoded,t.value)}so.compareTokens=kt.compareTokens;so.encodedSize=function(t){return mt.encodedSize(t.value)};var zp=20,jp=21,Gp=22,Zp=23;function Ju(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new P(x.null,null,1):new P(x.undefined,void 0,1)}function Qu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new P(x.break,void 0,1)}function vs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${$} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new P(x.float,e,t)}function tf(e,t,r,n){return vs(As(e,t+1),3,n)}function ef(e,t,r,n){return vs(Is(e,t+1),5,n)}function rf(e,t,r,n){return vs(af(e,t+1),9,n)}function ao(e,t,r){let n=t.value;if(n===!1)e.push([x.float.majorEncoded|zp]);else if(n===!0)e.push([x.float.majorEncoded|jp]);else if(n===null)e.push([x.float.majorEncoded|Gp]);else if(n===void 0)e.push([x.float.majorEncoded|Zp]);else{let o,i=!1;(!r||r.float64!==!0)&&(of(n),o=As(jt,1),n===o||Number.isNaN(n)?(jt[0]=249,e.push(jt.slice(0,3)),i=!0):(sf(n),o=Is(jt,1),n===o&&(jt[0]=250,e.push(jt.slice(0,5)),i=!0))),i||(Yp(n),o=af(jt,1),jt[0]=251,e.push(jt.slice(0,9)))}}ao.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){of(n);let o=As(jt,1);if(n===o||Number.isNaN(n))return 3;if(sf(n),o=Is(jt,1),n===o)return 5}return 9};var nf=new ArrayBuffer(9),Kt=new DataView(nf,1),jt=new Uint8Array(nf,0);function of(e){if(e===1/0)Kt.setUint16(0,31744,!1);else if(e===-1/0)Kt.setUint16(0,64512,!1);else if(Number.isNaN(e))Kt.setUint16(0,32256,!1);else{Kt.setFloat32(0,e);let t=Kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Kt.setUint16(0,31744,!1);else if(r===0)Kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Kt.setUint16(0,0):o<-14?Kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function As(e,t){if(e.length-t<2)throw new Error(`${$} 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 sf(e){Kt.setFloat32(0,e,!1)}function Is(e,t){if(e.length-t<4)throw new Error(`${$} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Yp(e){Kt.setFloat64(0,e,!1)}function af(e,t){if(e.length-t<8)throw new Error(`${$} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ao.compareTokens=kt.compareTokens;function Z(e,t,r){throw new Error(`${$} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function co(e){return()=>{throw new Error(`${$} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=Z;B[24]=mu;B[25]=yu;B[26]=gu;B[27]=xu;B[28]=Z;B[29]=Z;B[30]=Z;B[31]=Z;for(let e=32;e<=55;e++)B[e]=Z;B[56]=bu;B[57]=wu;B[58]=Eu;B[59]=vu;B[60]=Z;B[61]=Z;B[62]=Z;B[63]=Z;for(let e=64;e<=87;e++)B[e]=Au;B[88]=Iu;B[89]=Tu;B[90]=Cu;B[91]=Bu;B[92]=Z;B[93]=Z;B[94]=Z;B[95]=co("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=_u;B[120]=Du;B[121]=Ru;B[122]=Pu;B[123]=Nu;B[124]=Z;B[125]=Z;B[126]=Z;B[127]=co("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=Uu;B[152]=Ou;B[153]=ku;B[154]=Ku;B[155]=Vu;B[156]=Z;B[157]=Z;B[158]=Z;B[159]=Mu;for(let e=160;e<=183;e++)B[e]=$u;B[184]=Fu;B[185]=qu;B[186]=Hu;B[187]=zu;B[188]=Z;B[189]=Z;B[190]=Z;B[191]=ju;for(let e=192;e<=215;e++)B[e]=Gu;B[216]=Zu;B[217]=Yu;B[218]=Wu;B[219]=Xu;B[220]=Z;B[221]=Z;B[222]=Z;B[223]=Z;for(let e=224;e<=243;e++)B[e]=co("simple values are not supported");B[244]=Z;B[245]=Z;B[246]=Z;B[247]=Ju;B[248]=co("simple values are not supported");B[249]=tf;B[250]=ef;B[251]=rf;B[252]=Z;B[253]=Z;B[254]=Z;B[255]=Qu;var Gt=[];for(let e=0;e<24;e++)Gt[e]=new P(x.uint,e,1);for(let e=-1;e>=-24;e--)Gt[31-e]=new P(x.negint,e,1);Gt[64]=new P(x.bytes,new Uint8Array(0),1);Gt[96]=new P(x.string,"",1);Gt[128]=new P(x.array,0,1);Gt[160]=new P(x.map,0,1);Gt[244]=new P(x.false,!1,1);Gt[245]=new P(x.true,!0,1);Gt[246]=new P(x.null,null,1);function cf(e){switch(e.type){case x.false:return re([244]);case x.true:return re([245]);case x.null:return re([246]);case x.bytes:return e.value.length?void 0:re([64]);case x.string:return e.value===""?re([96]):void 0;case x.array:return e.value===0?re([128]):void 0;case x.map:return e.value===0?re([160]):void 0;case x.uint:return e.value<24?re([Number(e.value)]):void 0;case x.negint:if(e.value>=-24)return re([31-Number(e.value)])}}var ff=Object.freeze({float64:!0,mapSorter:t0,quickEncodeToken:cf});function Xp(){let e=[];return e[x.uint.major]=kt,e[x.negint.major]=ro,e[x.bytes.major]=vr,e[x.string.major]=Lu,e[x.array.major]=oo,e[x.map.major]=io,e[x.tag.major]=so,e[x.float.major]=ao,e}var Jp=Xp(),Ts=new en,fo=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(`${Es} object contains circular references`);return new e(r,t)}},Be={null:new P(x.null,null),undefined:new P(x.undefined,void 0),true:new P(x.true,!0),false:new P(x.false,!1),emptyArray:new P(x.array,0),emptyMap:new P(x.map,0)},_e={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new P(x.float,e):e>=0?new P(x.uint,e):new P(x.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new P(x.uint,e):new P(x.negint,e)},Uint8Array(e,t,r,n){return new P(x.bytes,e)},string(e,t,r,n){return new P(x.string,e)},boolean(e,t,r,n){return e?Be.true:Be.false},null(e,t,r,n){return Be.null},undefined(e,t,r,n){return Be.undefined},ArrayBuffer(e,t,r,n){return new P(x.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new P(x.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Be.emptyArray,new P(x.break)]:Be.emptyArray;n=fo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=uo(s,r,n);return r.addBreakTokens?[new P(x.array,e.length),o,new P(x.break)]:[new P(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?[Be.emptyMap,new P(x.break)]:Be.emptyMap;n=fo.createCheck(n,e);let c=[],a=0;for(let f of i)c[a++]=[uo(f,r,n),uo(o?e.get(f):e[f],r,n)];return Qp(c,r),r.addBreakTokens?[new P(x.map,s),c,new P(x.break)]:[new P(x.map,s),c]}};_e.Map=_e.Object;_e.Buffer=_e.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))_e[`${e}Array`]=_e.DataView;function uo(e,t={},r){let n=au(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||_e[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=_e[n];if(!i)throw new Error(`${Es} unsupported type: ${n}`);return i(e,n,t,r)}function Qp(e,t){t.mapSorter&&e.sort(t.mapSorter)}function t0(e,t){if(e[0]instanceof P&&t[0]instanceof P){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=uf(r.value)),n._keyBytes||(n._keyBytes=uf(n.value)),eo(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function uf(e){return e0(e,Jp,ff)}function lf(e,t,r,n){if(Array.isArray(t))for(let o of t)lf(e,o,r,n);else r[t.type.major](e,t,n)}function e0(e,t,r){let n=uo(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),c=new en(s);if(i(c,n,r),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ws(c.chunks[0])}}return Ts.reset(),lf(Ts,n,t,r),Ts.toBytes(!0)}var r0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},lo=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=Gt[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${$} 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}},sn=Symbol.for("DONE"),ho=Symbol.for("BREAK");function n0(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Tr(t,r);if(i===ho){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===sn)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function o0(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=Tr(t,r);if(c===ho){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(c===sn)throw new Error(`${$} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${$} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${$} found repeat map key "${c}"`);let a=Tr(t,r);if(a===sn)throw new Error(`${$} 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 Tr(e,t){if(e.done())return sn;let r=e.next();if(r.type===x.break)return ho;if(r.type.terminal)return r.value;if(r.type===x.array)return n0(r,e,t);if(r.type===x.map)return o0(r,e,t);if(r.type===x.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Tr(e,t);return t.tags[r.value](n)}throw new Error(`${$} tag not supported (${r.value})`)}throw new Error("unsupported")}function df(e,t){if(!(e instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);t=Object.assign({},r0,t);let r=t.tokenizer||new lo(e,t),n=Tr(r,t);if(n===sn)throw new Error(`${$} did not find any content to decode`);if(n===ho)throw new Error(`${$} got unexpected break`);return[n,e.subarray(r.pos())]}function Cs(e,t){let[r,n]=df(e,t);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return r}var a0=qe("ipns:utils"),hf=H("/ipns/");var c0=0,u0=18;function pf(e){let t;if(e.pubKey!=null)try{t=kc(e.pubKey)}catch(r){throw a0.error(r),r}if(t!=null)return t}function mf(e){let t=H("ipns-signature:");return Ut([t,e])}function ze(e){return"signatureV1"in e?zt.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}):zt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function ne(e){let t=zt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Ht("Missing data or signatureV2");let r=yf(t.data),n=f0(r.Value),o=z(r.Validity);if(t.value!=null&&t.signatureV1!=null)return l0(t),{value:n,validityType:zt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:zt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function an(e){return Ut([hf,e.bytes])}function ge(e){let t=be(e.slice(hf.length));if(!po(t,c0)&&!po(t,u0))throw new Ze("Multihash in IPNS key was not identity or sha2-256");return t}function yf(e){let t=Cs(e);if(t.ValidityType===0)t.ValidityType=zt.ValidityType.EOL;else throw new wr("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 f0(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 Jn("Value must be a valid content path starting with /")}function l0(e){if(e.data==null)throw new Qn("Record data is missing");let t=yf(e.data);if(!Y(t.Value,e.value??new Uint8Array(0)))throw new Ht('Field "value" did not match between protobuf and CBOR');if(!Y(t.Validity,e.validity??new Uint8Array(0)))throw new Ht('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Ht('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Ht('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Ht('Field "ttl" did not match between protobuf and CBOR')}function po(e,t){return e.code===t}var z1=qe("ipns"),j1=300*1e9,h0="/ipns/",G1=h0.length;var gf=To(bs(),1);var mo=qe("ipns:validator"),p0=1024*10;async function m0(e,t){let r=ne(t),n;try{let o=mf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw mo.error("record signature verification failed"),new Ht("Record signature verification failed");if(r.validityType===zt.ValidityType.EOL){if(gf.default.fromString(r.validity).toDate().getTime()<Date.now())throw mo.error("record has expired"),new Wn("record has expired")}else if(r.validityType!=null)throw mo.error("the validity type is unsupported"),new wr("The validity type is unsupported");mo("ipns record for %s is valid",r.value)}async function xf(e,t){if(t.byteLength>p0)throw new Xn("The record is too large");let r=ge(e),n;po(r,0)&&(n=On(r));let o=ne(t),i=pf(o)??n;if(i==null)throw new tn("Could not extract public key from IPNS record or routing key");let s=an(i.toMultihash());if(!Y(s,e))throw new tn("Embedded public key did not match routing key");await m0(i,t)}var yo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Cr(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)),tr(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new yo("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 Vt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var _s=To(wf(),1);var Ds=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},Ef=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function Rs(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(Ef(s));return}if(s&&(a=()=>{y(Ef(s))},s.addEventListener("abort",a,{once:!0})),e.then(l,y),r===Number.POSITIVE_INFINITY)return;let E=new Ds;c=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(b){y(b)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?y(o):(E.message=o??`Promise timed out after ${r} milliseconds`,y(E))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}function Ps(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 un=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=Ps(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 fn=class extends _s.default{#t;#n;#e=0;#h;#m=!1;#x=!1;#c;#T=0;#b=0;#u;#f;#a;#s=[];#i=0;#r;#C;#o=0;#y;#l;#P=1n;#g=new Map;timeout;constructor(t){if(super(),t={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:un,strict:!1,...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(t.strict&&t.interval===0)throw new TypeError("The `strict` option requires a non-zero `interval`");if(t.strict&&t.intervalCap===Number.POSITIVE_INFINITY)throw new TypeError("The `strict` option requires a finite `intervalCap`");if(this.#t=t.carryoverIntervalCount??t.carryoverConcurrencyCount??!1,this.#n=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#c=t.interval,this.#a=t.strict,this.#r=new t.queueClass,this.#C=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.#l=t.autoStart===!1,this.#M()}#w(t){for(;this.#i<this.#s.length;){let n=this.#s[this.#i];if(n!==void 0&&t-n>=this.#c)this.#i++;else break}(this.#i>100&&this.#i>this.#s.length/2||this.#i===this.#s.length)&&(this.#s=this.#s.slice(this.#i),this.#i=0)}#N(t){this.#a?this.#s.push(t):this.#e++}#L(){this.#a?this.#s.length>this.#i&&this.#s.pop():this.#e>0&&this.#e--}#E(){return this.#s.length-this.#i}get#U(){return this.#n?!0:this.#a?this.#E()<this.#h:this.#e<this.#h}get#O(){return this.#o<this.#y}#k(){this.#o--,this.#o===0&&this.emit("pendingZero"),this.#A(),this.emit("next")}#K(){this.#f=void 0,this.#D(),this.#_()}#V(t){if(this.#a){if(this.#w(t),this.#E()>=this.#h){let n=this.#s[this.#i],o=this.#c-(t-n);return this.#S(o),!0}return!1}if(this.#u===void 0){let r=this.#T-t;if(r<0){if(this.#b>0){let n=t-this.#b;if(n<this.#c)return this.#S(this.#c-n),!0}this.#e=this.#t?this.#o:0}else return this.#S(r),!0}return!1}#S(t){this.#f===void 0&&(this.#f=setTimeout(()=>{this.#K()},t))}#v(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}#B(){this.#f&&(clearTimeout(this.#f),this.#f=void 0)}#A(){if(this.#r.size===0){if(this.#v(),this.emit("empty"),this.#o===0){if(this.#B(),this.#a&&this.#i>0){let r=Date.now();this.#w(r)}this.emit("idle")}return!1}let t=!1;if(!this.#l){let r=Date.now(),n=!this.#V(r);if(this.#U&&this.#O){let o=this.#r.dequeue();this.#n||(this.#N(r),this.#p()),this.emit("active"),o(),n&&this.#_(),t=!0}}return t}#_(){this.#n||this.#u!==void 0||this.#a||(this.#u=setInterval(()=>{this.#D()},this.#c),this.#T=Date.now()+this.#c)}#D(){this.#a||(this.#e===0&&this.#o===0&&this.#u&&this.#v(),this.#e=this.#t?this.#o:0),this.#I(),this.#p()}#I(){for(;this.#A(););}get concurrency(){return this.#y}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.#y=t,this.#I()}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.#r.setPriority(t,r)}async add(t,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#P++).toString()},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`);this.#r.enqueue(async()=>{this.#o++,this.#g.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let s;try{try{r.signal?.throwIfAborted()}catch(f){throw this.#$(),this.#g.delete(i),f}this.#b=Date.now();let c=t({signal:r.signal});if(r.timeout&&(c=Rs(Promise.resolve(c),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#o} running, ${this.#r.size} waiting)`})),r.signal){let{signal:f}=r;c=Promise.race([c,new Promise((u,l)=>{s=()=>{l(f.reason)},f.addEventListener("abort",s,{once:!0})})])}let a=await c;n(a),this.emit("completed",a)}catch(c){o(c),this.emit("error",c)}finally{s&&r.signal?.removeEventListener("abort",s),this.#g.delete(i),queueMicrotask(()=>{this.#k()})}},r),this.emit("add"),this.#A()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#l?(this.#l=!1,this.#I(),this):this}pause(){this.#l=!0}clear(){this.#r=new this.#C,this.#v(),this.#R(),this.emit("empty"),this.#o===0&&(this.#B(),this.emit("idle")),this.emit("next")}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#r.size<t||await this.#d("next",()=>this.#r.size<t)}async onIdle(){this.#o===0&&this.#r.size===0||await this.#d("idle")}async onPendingZero(){this.#o!==0&&await this.#d("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#d("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#d("rateLimitCleared")}onError(){return new Promise((t,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#d(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#r.size}sizeBy(t){return this.#r.filter(t).length}get pending(){return this.#o}get isPaused(){return this.#l}#M(){this.#n||(this.on("add",()=>{this.#r.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#n||this.#x||(this.#x=!0,queueMicrotask(()=>{this.#x=!1,this.#R()}))}#$(){this.#n||(this.#L(),this.#p())}#R(){let t=this.#m;if(this.#n||this.#r.size===0){t&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#a){let o=Date.now();this.#w(o),r=this.#E()}else r=this.#e;let n=r>=this.#h;n!==t&&(this.#m=n,this.emit(n?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#m}get isSaturated(){return this.#o===this.#y&&this.#r.size>0||this.isRateLimited&&this.#r.size>0}get runningTasks(){return[...this.#g.values()].map(t=>({...t}))}};var je=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Mt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function x0(e){return e[Symbol.asyncIterator]!=null}function b0(e){if(x0(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var xo=b0;function w0(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 Sf=w0;function E0(e){return e[Symbol.asyncIterator]!=null}function S0(e,t){let r=0;if(E0(e))return(async function*(){for await(let a of e)yield t(a,r++)})();let n=Sf(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 bo=S0;var vf=H("/ipns/");function Af(e){return Y(e.subarray(0,vf.byteLength),vf)}var wo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){try{yield*bo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[],routing:"delegated-http-routing-v1"}))}catch(n){if(n instanceof vt)return;throw n}}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!Af(t))return;let o=ge(t),i=j.createV1(114,o),s=ne(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Af(t))throw new vt("Not found");let n=ge(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return ze(i)}catch(i){throw i.name==="BadResponseError"?new vt("Not found"):i}}toString(){return`DelegatedRoutingV1HttpApiClientContentRouting(${this.client.url})`}},Eo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await xo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new vt("Not found")}async*getClosestPeers(t,r={}){let n;try{n=j.decode(t)}catch{n=Mn(Xt.decode(t))}for await(let o of this.client.getClosestPeers(n,r))yield{id:o.ID,multiaddrs:o.Addrs??[]}}toString(){return`DelegatedRoutingV1HttpApiClientPeerRouting(${this.client.url})`}};var So={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},vo=class{url;started;httpQueue;shutDownController;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;log;constructor(t,r){this.log=t.logger.forComponent("delegated-routing-v1-http-api-client"),this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new fn({concurrency:r.concurrentRequests??So.concurrentRequests}),this.inFlightRequests=new Map,this.url=r.url instanceof URL?r.url:new URL(r.url),this.timeout=r.timeout??So.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new wo(this),this.peerRouting=new Eo(this),this.cacheName=r.cacheName??So.cacheName,this.cacheTTL=r.cacheTTL??So.cacheTTL}get[Gs](){return this.contentRouting}get[Ys](){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&&this.log("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={}){this.log("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=br([this.shutDownController.signal,n,r.signal]);let i=Vt(),s=Vt(),c=0;this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.url}routing/v1/providers/${t}`);this.#n(a,r.filterAddrs,r.filterProtocols);let f={headers:{accept:"application/x-ndjson, application/json;q=0.8"},signal:o},u=await this.#e(a.toString(),f);if(!u.ok){if(u.status===404)return;throw u.status===422?new je("Request does not conform to schema or semantic constraints"):new Mt(`Unexpected status code: ${u.status}`)}let l=u.headers.get("Content-Type");if(l==null)throw new Mt("No Content-Type header received");if(u.body==null){if(l!=="application/x-ndjson")throw new Mt("Routing response had no body");return}if(l.startsWith("application/json")){let E=(await u.json()).Providers??[];for(let b of E){let T=this.#t(b);T!=null&&(c++,yield T)}}else if(l.includes("application/x-ndjson"))for await(let y of Cr(Qr(u.body))){let E=this.#t(y);E!=null&&(c++,yield E)}else throw new Mt(`Unsupported Content-Type: ${l}`)}finally{o.clear(),s.resolve(),this.log("getProviders finished found %d providers for %c",c,t)}}async*getPeers(t,r={}){this.log("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=br([this.shutDownController.signal,n,r.signal]);let i=Vt(),s=Vt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.url}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.#e(c.toString(),a);if(f.status===404)return;if(f.status===422)throw new je("Request does not conform to schema or semantic constraints");if(f.body==null)throw new Mt("Routing response had no body");if(f.headers.get("Content-Type")?.startsWith("application/json")){let y=(await f.json()).Peers??[];for(let E of y){let b=this.#t(E);b!=null&&(yield b)}}else for await(let l of Cr(Qr(f.body))){let y=this.#t(l);y!=null&&(yield y)}}catch(c){this.log.error("getPeers errored - %e",c)}finally{o.clear(),s.resolve(),this.log("getPeers finished: %c",t)}}async*getClosestPeers(t,r={}){let n;if(Zs(t))n=t.toCID().toString();else if(j.asCID(t)===t||t instanceof j)n=t.toV1().toString();else throw new nt("Key must be CID or PeerId");this.log("getClosestPeers starts: %s",n);let o=AbortSignal.timeout(this.timeout),i=br([this.shutDownController.signal,o,r.signal]);let s=Vt(),c=Vt();this.httpQueue.add(async()=>(s.resolve(),c.promise));try{await s.promise;let a=new URL(`${this.url}routing/v1/dht/closest/peers/${n}`);this.#n(a,r.filterAddrs,r.filterProtocols);let f={headers:{Accept:"application/x-ndjson"},signal:i},u=await this.#e(a.toString(),f);if(u.status===404)return;if(u.status===422)throw new je("Request does not conform to schema or semantic constraints");if(u.body==null)throw new Mt("Routing response had no body");if(u.headers.get("Content-Type")?.startsWith("application/json")){let E=(await u.json()).Peers??[];for(let b of E){let T=this.#t(b);T!=null&&(yield T)}}else for await(let y of Cr(Qr(u.body))){let E=this.#t(y);E!=null&&(yield E)}}catch(a){this.log.error("getClosestPeers errored - %e",a)}finally{i.clear(),c.resolve(),this.log("getClosestPeers finished: %s",n)}}async getIPNS(t,r={}){this.log("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=br([this.shutDownController.signal,n,r.signal]);let i=Vt(),s=Vt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let c=`${this.url}routing/v1/ipns/${t}`;try{await i.promise;let a={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#e(c,a);if(this.log("getIPNS GET %s %d",c,f.status),f.status===404)throw new vt("No matching records found");if(f.status===422)throw new je("Request does not conform to schema or semantic constraints");if(!f.ok)throw new Mt(`Unexpected status code: ${f.status}`);let u=f.headers.get("Content-Type");if(u==null||!u.includes("application/vnd.ipfs.ipns-record"))throw new vt("No matching records found");if(f.body==null)throw new Mt("GET ipns response had no body");let l=await f.arrayBuffer(),y=new Uint8Array(l,0,l.byteLength);return r.validate!==!1&&await xf(an(t.multihash),y),ne(y)}catch(a){throw this.log.error("getIPNS GET %s error - %e",c,a),a}finally{o.clear(),s.resolve(),this.log("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){this.log("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=br([this.shutDownController.signal,o,n.signal]);let s=Vt(),c=Vt();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.url}routing/v1/ipns/${t}`;try{await s.promise;let f=ze(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#e(a,u);if(this.log("putIPNS PUT %s %d",a,l.status),l.status!==200)throw new Mt("PUT ipns response had status other than 200")}catch(f){throw this.log.error("putIPNS PUT %s error - %e",a,f.stack),f}finally{i.clear(),c.resolve(),this.log("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Gn)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Mc(t.ID),Addrs:n,Protocols:r}}catch(r){this.log.error("could not conform record to peer schema - %e",r)}}#n(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let a=await this.cache?.match(t);if(a!=null){if(parseInt(a.headers.get("x-cache-expires")??"0",10)>Date.now())return this.log("returning cached response for %s",o),this.logResponse(a),a;this.log("evicting cached response for %s",o),await this.cache?.delete(t)}else this.cache!=null&&this.log("cache miss for %s",o)}let i=this.inFlightRequests.get(o);if(i!=null){let a=await i;return this.log("deduplicating outgoing request for %s",o),a.clone()}this.log("outgoing request:"),this.logRequest(t,r);let s=fetch(t,r).then(async a=>{if(this.log("incoming response:"),this.logResponse(a),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}toString(){return`DefaultDelegatedRoutingV1HttpApiClient(${this.url})`}logRequest(t,r){let n=new Headers(r.headers);this.log("%s %s HTTP/1.1",r.method??"GET",t);for(let[o,i]of n.entries())this.log("%s: %s",o,i)}logResponse(t){this.log("HTTP/1.1 %d %s",t.status,t.statusText);for(let[r,n]of t.headers.entries())this.log("%s: %s",r,n)}};function If(e){return t=>new vo(t,e)}function Ao(e){return{url:"https://delegated-ipfs.dev",filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Tf=H("/ipns/");function Cf(e){return Y(e.subarray(0,Tf.byteLength),Tf)}var Ns=class{client;constructor(t,r){this.client=If(r)(t)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*bo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols,routing:"delegated-http-routing"}))}async put(t,r,n){if(!Cf(t))return;let o=ge(t),i=j.createV1(114,o),s=ne(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Cf(t))throw new vt("Not found");let n=ge(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return ze(i)}catch(i){throw i.name==="BadResponseError"?new vt("Not found"):i}}async findPeer(t,r){let n=await xo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new vt("Not found")}async*getClosestPeers(t,r){}toString(){return`DelegatedHTTPRouter(${this.client.url})`}};function Bf(e){return t=>new Ns(t,Ao(e))}var _f="[a-fA-F\\d:]",De=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${_f})|(?<=${_f})(?=\\s|$))`:"",Zt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",at="[a-fA-F\\d]{1,4}",Io=`
13
+ ${t}[Error list was empty]`,r.trim()}return ta(e,t)}vt.formatters.e=e=>e==null?"undefined":ra(e);function Sl(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 na(e){return{forComponent(t){return be(t,e)}}}function be(e,t){let r=Sl(`${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=>be(`${e}:${n}`,t)})}function ea(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var oa=Symbol.for("@libp2p/content-routing");var ot=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ze=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var At=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var yn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Ye=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var We=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var gn=Symbol.for("@libp2p/peer-id");function ia(e){return!!e?.[gn]}var sa=Symbol.for("@libp2p/peer-routing");var Ko={};wt(Ko,{base36:()=>Xe,base36upper:()=>vl});var Xe=xe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vl=xe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xt={};wt(Xt,{Digest:()=>Le,create:()=>$t,decode:()=>we,equals:()=>Mo,hasCode:()=>Fl});var Al=ua,aa=128,Il=127,Tl=~Il,Cl=Math.pow(2,31);function ua(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Cl;)t[r++]=e&255|aa,e/=128;for(;e&Tl;)t[r++]=e&255|aa,e>>>=7;return t[r]=e|0,ua.bytes=r-n+1,t}var Bl=Vo,_l=128,ca=127;function Vo(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Vo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&ca)<<o:(s&ca)*Math.pow(2,o),o+=7}while(s>=_l);return Vo.bytes=i-n,r}var Dl=Math.pow(2,7),Rl=Math.pow(2,14),Pl=Math.pow(2,21),Ll=Math.pow(2,28),Nl=Math.pow(2,35),Ul=Math.pow(2,42),Ol=Math.pow(2,49),kl=Math.pow(2,56),Kl=Math.pow(2,63),Vl=function(e){return e<Dl?1:e<Rl?2:e<Pl?3:e<Ll?4:e<Nl?5:e<Ul?6:e<Ol?7:e<kl?8:e<Kl?9:10},Ml={encode:Al,decode:Bl,encodingLength:Vl},$l=Ml,Br=$l;function _r(e,t=0){return[Br.decode(e,t),Br.decode.bytes]}function Je(e,t,r=0){return Br.encode(e,t,r),t}function Qe(e){return Br.encodingLength(e)}function $t(e,t){let r=t.byteLength,n=Qe(e),o=n+Qe(r),i=new Uint8Array(o+r);return Je(e,i,0),Je(r,i,n),i.set(t,o),new Le(e,r,t,i)}function we(e){let t=oe(e),[r,n]=_r(t),[o,i]=_r(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Le(r,o,s,t)}function Mo(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Gs(e.bytes,r.bytes)}}var Le=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Fl(e,t){return e.code===t}function fa(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Hl(r,$o(e),t??X.encoder);default:return zl(r,$o(e),t??Wt.encoder)}}var la=new WeakMap;function $o(e){let t=la.get(e);if(t==null){let r=new Map;return la.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!==Dr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==jl)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=$t(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&&Mo(t.multihash,n.multihash)}toString(t){return fa(this,t)}toJSON(){return{"/":fa(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??da(n,o,i.bytes))}else if(r[Gl]===!0){let{version:n,multihash:o,code:i}=r,s=we(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!==Dr)throw new Error(`Version 0 CID must use dag-pb (code: ${Dr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=da(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Dr,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=oe(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 Le(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]=_r(t.subarray(r));return r+=y,l},o=n(),i=Dr;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]=ql(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 ql(e,t){switch(e[0]){case"Q":{let r=t??X;return[X.prefix,r.decode(`${X.prefix}${e}`)]}case X.prefix:{let r=t??X;return[X.prefix,r.decode(e)]}case Wt.prefix:{let r=t??Wt;return[Wt.prefix,r.decode(e)]}case Xe.prefix:{let r=t??Xe;return[Xe.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 Hl(e,t,r){let{prefix:n}=r;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function zl(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 Dr=112,jl=18;function da(e,t,r){let n=Qe(e),o=n+Qe(t),i=new Uint8Array(o+r.byteLength);return Je(e,i,0),Je(t,i,n),i.set(r,o),i}var Gl=Symbol.for("@ipld/js-cid/CID");var Fo={};wt(Fo,{identity:()=>Ct});var ha=0,Zl="identity",pa=oe;function Yl(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 $t(ha,pa(e))}var Ct={code:ha,name:Zl,encode:pa,digest:Yl};function Y(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ie(e=0){return new Uint8Array(e)}function Bt(e=0){return new Uint8Array(e)}function Ut(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Bt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ya=Symbol.for("@achingbrain/uint8arraylist");function ma(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 tr(e){return!!e?.[ya]}var _t=class e{bufs;length;[ya]=!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(tr(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(tr(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=ma(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ma(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(tr(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 Ut(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ut(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(!tr(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 E=this.get(l+y);if(n[y]!==E){u=Math.max(1,y-c[E]);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=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=ie(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=ie(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=ie(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!Y(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var qo={};wt(qo,{base10:()=>Wl});var Wl=xe({prefix:"9",name:"base10",alphabet:"0123456789"});var Ho={};wt(Ho,{base16:()=>Xl,base16upper:()=>Jl});var Xl=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Jl=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zo={};wt(zo,{base2:()=>Ql});var Ql=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jo={};wt(jo,{base256emoji:()=>od});var ga=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}"),td=ga.reduce((e,t,r)=>(e[r]=t,e),[]),ed=ga.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function rd(e){return e.reduce((t,r)=>(t+=td[r],t),"")}function nd(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=ed[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var od=Ge({prefix:"\u{1F680}",name:"base256emoji",encode:rd,decode:nd});var Go={};wt(Go,{base8:()=>id});var id=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zo={};wt(Zo,{identity:()=>sd});var sd=Ge({prefix:"\0",name:"identity",encode:e=>Ys(e),decode:e=>Zs(e)});var qm=new TextEncoder,Hm=new TextDecoder;var Xo={};wt(Xo,{sha256:()=>Rr,sha512:()=>fd});var ud=20;function Wo({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Yo(e,t,r,n,o)}var Yo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??ud,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?xa(n,this.code,r?.truncate):n.then(o=>xa(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function xa(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 $t(t,e)}function wa(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Rr=Wo({name:"sha2-256",code:18,encode:wa("SHA-256")}),fd=Wo({name:"sha2-512",code:19,encode:wa("SHA-512")});var Pr={...Zo,...zo,...Go,...qo,...Ho,...Po,...Ko,...Lo,...Oo,...jo},ry={...Xo,...Fo};function Sa(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ea=Sa("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Jo=Sa("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=Bt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),ld={utf8:Ea,"utf-8":Ea,hex:Pr.base16,latin1:Jo,ascii:Jo,binary:Jo,...Pr},bn=ld;function H(e,t="utf8"){let r=bn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=bn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var dd=parseInt("11111",2),Qo=parseInt("10000000",2),hd=parseInt("01111111",2),va={0:Lr,1:Lr,2:pd,3:gd,4:xd,5:yd,6:md,16:Lr,22:Lr,48:Lr};function se(e,t={offset:0}){let r=e[t.offset]&dd;if(t.offset++,va[r]!=null)return va[r](e,t);throw new Error("No decoder for tag "+r)}function Nr(e,t){let r=0;if((e[t.offset]&Qo)===Qo){let n=e[t.offset]&hd,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 Lr(e,t){Nr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=se(e,t);if(n===null)break;r.push(n)}return r}function pd(e,t){let r=Nr(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 md(e,t){let r=Nr(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 yd(e,t){return t.offset++,null}function gd(e,t){let r=Nr(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 xd(e,t){let r=Nr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function bd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new _t;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function ti(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=bd(e.byteLength);return new _t(Uint8Array.from([t.byteLength|Qo]),t)}function It(e){let t=new _t,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new _t(Uint8Array.from([2]),ti(t),t)}function wn(e){let t=Uint8Array.from([0]),r=new _t(t,e);return new _t(Uint8Array.from([3]),ti(r),r)}function Ee(e,t=48){let r=new _t;for(let n of e)r.append(n);return new _t(Uint8Array.from([t]),ti(r),r)}async function Aa(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 wd=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ed=Uint8Array.from([6,5,43,129,4,0,34]),Sd=Uint8Array.from([6,5,43,129,4,0,35]),vd={ext:!0,kty:"EC",crv:"P-256"},Ad={ext:!0,kty:"EC",crv:"P-384"},Id={ext:!0,kty:"EC",crv:"P-521"},ei=32,ri=48,ni=66;function oi(e){let t=se(e);return Ia(t)}function Ia(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===ei*2+1)return n=z(t.subarray(r,r+ei),"base64url"),o=z(t.subarray(r+ei),"base64url"),new er({...vd,key_ops:["verify"],x:n,y:o});if(t.byteLength===ri*2+1)return n=z(t.subarray(r,r+ri),"base64url"),o=z(t.subarray(r+ri),"base64url"),new er({...Ad,key_ops:["verify"],x:n,y:o});if(t.byteLength===ni*2+1)return n=z(t.subarray(r,r+ni),"base64url"),o=z(t.subarray(r+ni),"base64url"),new er({...Id,key_ops:["verify"],x:n,y:o});throw new ot(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ta(e){return Ee([It(Uint8Array.from([1])),Ee([Td(e.crv)],160),Ee([wn(new _t(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function Td(e){if(e==="P-256")return wd;if(e==="P-384")return Ed;if(e==="P-521")return Sd;throw new ot(`Invalid curve ${e}`)}var er=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 Ct.digest(rr(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}async verify(t,r,n){return Aa(this.jwk,r,t,n)}};function Ne(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function q(e,t,r=""){let n=Ne(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,c=i?` of length ${t}`:"",a=n?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+a)}return e}function En(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Jt(e.outputLen),Jt(e.blockLen)}function nr(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 Ba(e,t){q(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ft(e,t){return e<<32-t|e>>>t}var _a=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Cd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ue(e){if(q(e),_a)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Cd[e[r]];return t}var ae={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ca(e){if(e>=ae._0&&e<=ae._9)return e-ae._0;if(e>=ae.A&&e<=ae.F)return e-(ae.A-10);if(e>=ae.a&&e<=ae.f)return e-(ae.a-10)}function fe(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(_a)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=Ca(e.charCodeAt(i)),c=Ca(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 Tt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];q(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function ii(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 or(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 si=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Da(e,t,r){return e&t^~e&r}function Ra(e,t,r){return e&t^e&r^t&r}var Ur=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=Sn(this.buffer)}update(t){nr(this),q(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Sn(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){nr(this),Ba(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ce(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=Sn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},le=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ht=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var vn=BigInt(4294967295),Pa=BigInt(32);function Bd(e,t=!1){return t?{h:Number(e&vn),l:Number(e>>Pa&vn)}:{h:Number(e>>Pa&vn)|0,l:Number(e&vn)|0}}function La(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}=Bd(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var ai=(e,t,r)=>e>>>r,ci=(e,t,r)=>e<<32-r|t>>>r,Ue=(e,t,r)=>e>>>r|t<<32-r,Oe=(e,t,r)=>e<<32-r|t>>>r,Or=(e,t,r)=>e<<64-r|t>>>r-32,kr=(e,t,r)=>e>>>r-32|t<<64-r;function Qt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Na=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Ua=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Oa=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ka=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Ka=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Va=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Dd=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]),Se=new Uint32Array(64),ui=class extends Ur{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)Se[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let y=Se[l-15],E=Se[l-2],b=Ft(y,7)^Ft(y,18)^y>>>3,T=Ft(E,17)^Ft(E,19)^E>>>10;Se[l]=T+Se[l-7]+b+Se[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=Ft(c,6)^Ft(c,11)^Ft(c,25),E=u+y+Da(c,a,f)+Dd[l]+Se[l]|0,T=(Ft(n,2)^Ft(n,13)^Ft(n,22))+Ra(n,o,i)|0;u=f,f=a,a=c,c=s+E|0,s=i,i=o,o=n,n=E+T|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){ce(Se)}destroy(){this.set(0,0,0,0,0,0,0,0),ce(this.buffer)}},fi=class extends ui{A=le[0]|0;B=le[1]|0;C=le[2]|0;D=le[3]|0;E=le[4]|0;F=le[5]|0;G=le[6]|0;H=le[7]|0;constructor(){super(32)}};var Ma=La(["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))),Rd=Ma[0],Pd=Ma[1],ve=new Uint32Array(80),Ae=new Uint32Array(80),li=class extends Ur{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:E,Gl:b,Hh:T,Hl:I}=this;return[t,r,n,o,i,s,c,a,f,u,l,y,E,b,T,I]}set(t,r,n,o,i,s,c,a,f,u,l,y,E,b,T,I){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=y|0,this.Gh=E|0,this.Gl=b|0,this.Hh=T|0,this.Hl=I|0}process(t,r){for(let v=0;v<16;v++,r+=4)ve[v]=t.getUint32(r),Ae[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let N=ve[v-15]|0,k=Ae[v-15]|0,M=Ue(N,k,1)^Ue(N,k,8)^ai(N,k,7),V=Oe(N,k,1)^Oe(N,k,8)^ci(N,k,7),h=ve[v-2]|0,p=Ae[v-2]|0,_=Ue(h,p,19)^Or(h,p,61)^ai(h,p,6),D=Oe(h,p,19)^kr(h,p,61)^ci(h,p,6),A=Oa(V,D,Ae[v-7],Ae[v-16]),m=ka(A,M,_,ve[v-7],ve[v-16]);ve[v]=m|0,Ae[v]=A|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:y,Fh:E,Fl:b,Gh:T,Gl:I,Hh:w,Hl:C}=this;for(let v=0;v<80;v++){let N=Ue(l,y,14)^Ue(l,y,18)^Or(l,y,41),k=Oe(l,y,14)^Oe(l,y,18)^kr(l,y,41),M=l&E^~l&T,V=y&b^~y&I,h=Ka(C,k,V,Pd[v],Ae[v]),p=Va(h,w,N,M,Rd[v],ve[v]),_=h|0,D=Ue(n,o,28)^Or(n,o,34)^Or(n,o,39),A=Oe(n,o,28)^kr(n,o,34)^kr(n,o,39),m=n&i^n&c^i&c,g=o&s^o&a^s&a;w=T|0,C=I|0,T=E|0,I=b|0,E=l|0,b=y|0,{h:l,l:y}=Qt(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=Na(_,A,g);n=Ua(d,p,D,m),o=d|0}({h:n,l:o}=Qt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Qt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=Qt(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=Qt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:y}=Qt(this.Eh|0,this.El|0,l|0,y|0),{h:E,l:b}=Qt(this.Fh|0,this.Fl|0,E|0,b|0),{h:T,l:I}=Qt(this.Gh|0,this.Gl|0,T|0,I|0),{h:w,l:C}=Qt(this.Hh|0,this.Hl|0,w|0,C|0),this.set(n,o,i,s,c,a,f,u,l,y,E,b,T,I,w,C)}roundClean(){ce(ve,Ae)}destroy(){ce(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},di=class extends li{Ah=ht[0]|0;Al=ht[1]|0;Bh=ht[2]|0;Bl=ht[3]|0;Ch=ht[4]|0;Cl=ht[5]|0;Dh=ht[6]|0;Dl=ht[7]|0;Eh=ht[8]|0;El=ht[9]|0;Fh=ht[10]|0;Fl=ht[11]|0;Gh=ht[12]|0;Gl=ht[13]|0;Hh=ht[14]|0;Hl=ht[15]|0;constructor(){super(64)}};var ir=ii(()=>new fi,si(1));var $a=ii(()=>new di,si(3));var pi=BigInt(0),hi=BigInt(1);function de(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function Fa(e){if(typeof e=="bigint"){if(!An(e))throw new Error("positive bigint expected, got "+e)}else Jt(e);return e}function Kr(e){let t=Fa(e).toString(16);return t.length&1?"0"+t:t}function qa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?pi:BigInt("0x"+e)}function sr(e){return qa(ue(e))}function ke(e){return qa(ue(Tn(q(e)).reverse()))}function In(e,t){Jt(t),e=Fa(e);let r=fe(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function mi(e,t){return In(e,t).reverse()}function Tn(e){return Uint8Array.from(e)}var An=e=>typeof e=="bigint"&&pi<=e;function Ld(e,t,r){return An(e)&&An(t)&&An(r)&&t<=e&&e<r}function Vr(e,t,r,n){if(!Ld(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function yi(e){let t;for(t=0;e>pi;e>>=hi,t+=1);return t}var Mr=e=>(hi<<BigInt(e))-hi;function Ha(e,t,r){if(Jt(e,"hashLen"),Jt(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(e),f=n(e),u=0,l=()=>{a.fill(1),f.fill(0),u=0},y=(...I)=>r(f,Tt(a,...I)),E=(I=o)=>{f=y(i,I),a=y(),I.length!==0&&(f=y(s,I),a=y())},b=()=>{if(u++>=c)throw new Error("drbg: tried max amount of iterations");let I=0,w=[];for(;I<t;){a=y();let C=a.slice();w.push(C),I+=a.length}return Tt(...w)};return(I,w)=>{l(),E(I);let C;for(;!(C=w(b()));)E();return l(),C}}function Ie(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 ar(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var Et=BigInt(0),ct=BigInt(1),Ke=BigInt(2),Ga=BigInt(3),Za=BigInt(4),Ya=BigInt(5),Nd=BigInt(7),Wa=BigInt(8),Ud=BigInt(9),Xa=BigInt(16);function it(e,t){let r=e%t;return r>=Et?r:t+r}function J(e,t,r){let n=e;for(;t-- >Et;)n*=n,n%=r;return n}function za(e,t){if(e===Et)throw new Error("invert: expected non-zero number");if(t<=Et)throw new Error("invert: expected positive modulus, got "+t);let r=it(e,t),n=t,o=Et,i=ct,s=ct,c=Et;for(;r!==Et;){let f=n/r,u=n%r,l=o-s*f,y=i-c*f;n=r,r=u,o=s,i=c,s=l,c=y}if(n!==ct)throw new Error("invert: does not exist");return it(o,t)}function xi(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Ja(e,t){let r=(e.ORDER+ct)/Za,n=e.pow(t,r);return xi(e,n,t),n}function Od(e,t){let r=(e.ORDER-Ya)/Wa,n=e.mul(t,Ke),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Ke),o),c=e.mul(i,e.sub(s,e.ONE));return xi(e,c,t),c}function kd(e){let t=cr(e),r=Qa(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Nd)/Xa;return(c,a)=>{let f=c.pow(a,s),u=c.mul(f,n),l=c.mul(f,o),y=c.mul(f,i),E=c.eql(c.sqr(u),a),b=c.eql(c.sqr(l),a);f=c.cmov(f,u,E),u=c.cmov(y,l,b);let T=c.eql(c.sqr(u),a),I=c.cmov(f,u,T);return xi(c,I,a),I}}function Qa(e){if(e<Ga)throw new Error("sqrt is not defined for small field");let t=e-ct,r=0;for(;t%Ke===Et;)t/=Ke,r++;let n=Ke,o=cr(e);for(;ja(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ja;let i=o.pow(n,t),s=(t+ct)/Ke;return function(a,f){if(a.is0(f))return f;if(ja(a,f)!==1)throw new Error("Cannot find square root");let u=r,l=a.mul(a.ONE,i),y=a.pow(f,t),E=a.pow(f,s);for(;!a.eql(y,a.ONE);){if(a.is0(y))return a.ZERO;let b=1,T=a.sqr(y);for(;!a.eql(T,a.ONE);)if(b++,T=a.sqr(T),b===u)throw new Error("Cannot find square root");let I=ct<<BigInt(u-b-1),w=a.pow(l,I);u=b,l=a.sqr(w),y=a.mul(y,l),E=a.mul(E,w)}return E}}function Kd(e){return e%Za===Ga?Ja:e%Wa===Ya?Od:e%Xa===Ud?kd(e):Qa(e)}var tc=(e,t)=>(it(e,t)&ct)===ct,Vd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Vd.reduce((n,o)=>(n[o]="function",n),t);return Ie(e,r),e}function Md(e,t,r){if(r<Et)throw new Error("invalid exponent, negatives unsupported");if(r===Et)return e.ONE;if(r===ct)return t;let n=e.ONE,o=t;for(;r>Et;)r&ct&&(n=e.mul(n,o)),o=e.sqr(o),r>>=ct;return n}function $r(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 ja(e,t){let r=(e.ORDER-ct)/Ke,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function $d(e,t){t!==void 0&&Jt(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var gi=class{ORDER;BITS;BYTES;isLE;ZERO=Et;ONE=ct;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=Et)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=$d(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 it(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return Et<=t&&t<this.ORDER}is0(t){return t===Et}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&ct)===ct}neg(t){return it(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return it(t*t,this.ORDER)}add(t,r){return it(t+r,this.ORDER)}sub(t,r){return it(t-r,this.ORDER)}mul(t,r){return it(t*r,this.ORDER)}pow(t,r){return Md(this,t,r)}div(t,r){return it(t*za(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 za(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=Kd(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?mi(t,this.BYTES):In(t,this.BYTES)}fromBytes(t,r=!1){q(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,i?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=i?ke(t):sr(t);if(c&&(a=it(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return $r(this,t)}cmov(t,r,n){return n?r:t}};function cr(e,t={}){return new gi(e,t)}function ec(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 wi(e){let t=ec(e);return t+Math.ceil(t/2)}function Ei(e,t,r=!1){q(e);let n=e.length,o=ec(t),i=wi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?ke(e):sr(e),c=it(s,t-ct)+ct;return r?mi(c,o):In(c,o)}var ur=BigInt(0),Ve=BigInt(1);function Fr(e,t){let r=t.negate();return e?r:t}function Me(e,t){let r=$r(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function ic(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Si(e,t){ic(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Mr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function rc(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+=Ve);let f=t*n,u=f+Math.abs(c)-1,l=c===0,y=c<0,E=t%2!==0;return{nextN:a,offset:u,isZero:l,isNeg:y,isNegF:E,offsetF:f}}var vi=new WeakMap,sc=new WeakMap;function Ai(e){return sc.get(e)||1}function nc(e){if(e!==ur)throw new Error("invalid wNAF")}var fr=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>ur;)r&Ve&&(n=n.add(o)),o=o.double(),r>>=Ve;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Si(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=Si(t,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:f,isZero:u,isNeg:l,isNegF:y,offsetF:E}=rc(n,c,s);n=a,u?i=i.add(Fr(y,r[E])):o=o.add(Fr(l,r[f]))}return nc(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=Si(t,this.bits);for(let s=0;s<i.windows&&n!==ur;s++){let{nextN:c,offset:a,isZero:f,isNeg:u}=rc(n,s,i);if(n=c,!f){let l=r[a];o=o.add(u?l.negate():l)}}return nc(n),o}getPrecomputes(t,r,n){let o=vi.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),vi.set(r,o))),o}cached(t,r,n){let o=Ai(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=Ai(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){ic(r,this.bits),sc.set(t,r),vi.delete(t)}hasCache(t){return Ai(t)!==1}};function ac(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>ur||n>ur;)r&Ve&&(i=i.add(o)),n&Ve&&(s=s.add(o)),o=o.double(),r>>=Ve,n>>=Ve;return{p1:i,p2:s}}function oc(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return bi(t),t}else return cr(e,{isLE:r})}function Cn(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>ur))throw new Error(`CURVE.${a} must be positive bigint`)}let o=oc(t.p,r.Fp,n),i=oc(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 Bn(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Te=BigInt(0),ut=BigInt(1),Ii=BigInt(2),Fd=BigInt(8);function qd(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 cc(e,t={}){let r=Cn("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s}=i;Ie(t,{},{uvRatio:"function"});let c=Ii<<BigInt(o.BYTES*8)-ut,a=I=>n.create(I),f=t.uvRatio||((I,w)=>{try{return{isValid:!0,value:n.sqrt(n.div(I,w))}}catch{return{isValid:!1,value:Te}}});if(!qd(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function u(I,w,C=!1){let v=C?ut:Te;return Vr("coordinate "+I,w,v,c),w}function l(I){if(!(I instanceof b))throw new Error("EdwardsPoint expected")}let y=ar((I,w)=>{let{X:C,Y:v,Z:N}=I,k=I.is0();w==null&&(w=k?Fd:n.inv(N));let M=a(C*w),V=a(v*w),h=n.mul(N,w);if(k)return{x:Te,y:ut};if(h!==ut)throw new Error("invZ was invalid");return{x:M,y:V}}),E=ar(I=>{let{a:w,d:C}=i;if(I.is0())throw new Error("bad point: ZERO");let{X:v,Y:N,Z:k,T:M}=I,V=a(v*v),h=a(N*N),p=a(k*k),_=a(p*p),D=a(V*w),A=a(p*a(D+h)),m=a(_+a(C*a(V*h)));if(A!==m)throw new Error("bad point: equation left != right (1)");let g=a(v*N),d=a(k*M);if(g!==d)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(i.Gx,i.Gy,ut,a(i.Gx*i.Gy));static ZERO=new b(Te,ut,ut,Te);static Fp=n;static Fn=o;X;Y;Z;T;constructor(w,C,v,N){this.X=u("x",w),this.Y=u("y",C),this.Z=u("z",v,!0),this.T=u("t",N),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){if(w instanceof b)throw new Error("extended point not allowed");let{x:C,y:v}=w||{};return u("x",C),u("y",v),new b(C,v,ut,a(C*v))}static fromBytes(w,C=!1){let v=n.BYTES,{a:N,d:k}=i;w=Tn(q(w,v,"point")),de(C,"zip215");let M=Tn(w),V=w[v-1];M[v-1]=V&-129;let h=ke(M),p=C?c:n.ORDER;Vr("point.y",h,Te,p);let _=a(h*h),D=a(_-ut),A=a(k*_-N),{isValid:m,value:g}=f(D,A);if(!m)throw new Error("bad point: invalid y coordinate");let d=(g&ut)===ut,S=(V&128)!==0;if(!C&&g===Te&&S)throw new Error("bad point: x=0 and x_0=1");return S!==d&&(g=a(-g)),b.fromAffine({x:g,y:h})}static fromHex(w,C=!1){return b.fromBytes(fe(w),C)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,C=!0){return T.createCache(this,w),C||this.multiply(Ii),this}assertValidity(){E(this)}equals(w){l(w);let{X:C,Y:v,Z:N}=this,{X:k,Y:M,Z:V}=w,h=a(C*V),p=a(k*N),_=a(v*V),D=a(M*N);return h===p&&_===D}is0(){return this.equals(b.ZERO)}negate(){return new b(a(-this.X),this.Y,this.Z,a(-this.T))}double(){let{a:w}=i,{X:C,Y:v,Z:N}=this,k=a(C*C),M=a(v*v),V=a(Ii*a(N*N)),h=a(w*k),p=C+v,_=a(a(p*p)-k-M),D=h+M,A=D-V,m=h-M,g=a(_*A),d=a(D*m),S=a(_*m),R=a(A*D);return new b(g,d,R,S)}add(w){l(w);let{a:C,d:v}=i,{X:N,Y:k,Z:M,T:V}=this,{X:h,Y:p,Z:_,T:D}=w,A=a(N*h),m=a(k*p),g=a(V*v*D),d=a(M*_),S=a((N+k)*(h+p)-A-m),R=d-g,L=d+g,U=a(m-C*A),O=a(S*R),K=a(L*U),F=a(S*U),tt=a(R*L);return new b(O,K,tt,F)}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:C,f:v}=T.cached(this,w,N=>Me(b,N));return Me(b,[C,v])[0]}multiplyUnsafe(w,C=b.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===Te?b.ZERO:this.is0()||w===ut?this:T.unsafe(this,w,v=>Me(b,v),C)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return T.unsafe(this,i.n).is0()}toAffine(w){return y(this,w)}clearCofactor(){return s===ut?this:this.multiplyUnsafe(s)}toBytes(){let{x:w,y:C}=this.toAffine(),v=n.toBytes(C);return v[v.length-1]|=w&ut?128:0,v}toHex(){return ue(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let T=new fr(b,o.BITS);return b.BASE.precompute(8),b}function uc(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');Ie(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||or,a=r.adjustScalarBytes||(h=>h),f=r.domain||((h,p,_)=>{if(de(_,"phflag"),p.length||_)throw new Error("Contexts/pre-hash are not supported");return h});function u(h){return s.create(ke(h))}function l(h){let p=v.secretKey;q(h,v.secretKey,"secretKey");let _=q(t(h),2*p,"hashedSecretKey"),D=a(_.slice(0,p)),A=_.slice(p,2*p),m=u(D);return{head:D,prefix:A,scalar:m}}function 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 E(h){return y(h).pointBytes}function b(h=Uint8Array.of(),...p){let _=Tt(...p);return u(t(f(_,q(h,void 0,"context"),!!n)))}function T(h,p,_={}){h=q(h,void 0,"message"),n&&(h=n(h));let{prefix:D,scalar:A,pointBytes:m}=y(p),g=b(_.context,D,h),d=o.multiply(g).toBytes(),S=b(_.context,d,m,h),R=s.create(g+S*A);if(!s.isValid(R))throw new Error("sign failed: invalid s");let L=Tt(d,s.toBytes(R));return q(L,v.signature,"result")}let I={zip215:!0};function w(h,p,_,D=I){let{context:A,zip215:m}=D,g=v.signature;h=q(h,g,"signature"),p=q(p,void 0,"message"),_=q(_,v.publicKey,"publicKey"),m!==void 0&&de(m,"zip215"),n&&(p=n(p));let d=g/2,S=h.subarray(0,d),R=ke(h.subarray(d,g)),L,U,O;try{L=e.fromBytes(_,m),U=e.fromBytes(S,m),O=o.multiplyUnsafe(R)}catch{return!1}if(!m&&L.isSmallOrder())return!1;let K=b(A,U.toBytes(),L.toBytes(),p);return U.add(L.multiplyUnsafe(K)).subtract(O).clearCofactor().is0()}let C=i.BYTES,v={secretKey:C,publicKey:C,signature:2*C,seed:C};function N(h=c(v.seed)){return q(h,v.seed,"seed")}function k(h){return Ne(h)&&h.length===s.BYTES}function M(h,p){try{return!!e.fromBytes(h,p)}catch{return!1}}let V={getExtendedPublicKey:y,randomSecretKey:N,isValidSecretKey:k,isValidPublicKey:M,toMontgomery(h){let{y:p}=e.fromBytes(h),_=v.publicKey,D=_===32;if(!D&&_!==57)throw new Error("only defined for 25519 and 448");let A=D?i.div(ut+p,ut-p):i.div(p-ut,p+ut);return i.toBytes(A)},toMontgomerySecret(h){let p=v.secretKey;q(h,p);let _=t(h.subarray(0,p));return a(_).subarray(0,p)}};return Object.freeze({keygen:Bn(N,E),getPublicKey:E,sign:T,verify:w,utils:V,Point:e,lengths:v})}var Hd=BigInt(1),fc=BigInt(2);var zd=BigInt(5),jd=BigInt(8),Ti=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Gd={p:Ti,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:jd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Zd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ti,c=e*e%i*e%i,a=J(c,fc,i)*c%i,f=J(a,Hd,i)*e%i,u=J(f,zd,i)*f%i,l=J(u,t,i)*u%i,y=J(l,r,i)*l%i,E=J(y,n,i)*y%i,b=J(E,o,i)*E%i,T=J(b,o,i)*E%i,I=J(T,t,i)*u%i;return{pow_p_5_8:J(I,fc,i)*e%i,b2:c}}function Yd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var lc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Wd(e,t){let r=Ti,n=it(t*t*t,r),o=it(n*n*t,r),i=Zd(e*o).pow_p_5_8,s=it(e*n*i,r),c=it(t*s*s,r),a=s,f=it(s*lc,r),u=c===e,l=c===it(-e,r),y=c===it(-e*lc,r);return u&&(s=a),(l||y)&&(s=f),tc(s,r)&&(s=it(-s,r)),{isValid:u||l,value:s}}var Xd=cc(Gd,{uvRatio:Wd});function Jd(e){return uc(Xd,$a,Object.assign({adjustScalarBytes:Yd},e))}var dc=Jd({});var qr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},_n=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var hc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new _n("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 Ot=hc;var Dn=32;var Ci,Qd=(async()=>{try{return await Ot.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function th(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Ot.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Ot.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 eh(e,t,r){return dc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function pc(e,t,r){return Ci==null&&(Ci=await Qd),Ci?th(e,t,r):eh(e,t,r)}function Rn(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Pn=class{type="Ed25519";raw;constructor(t){this.raw=Bi(t,Dn)}toMultihash(){return Ct.digest(rr(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=pc(this.raw,r,t);return Rn(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function _i(e){return e=Bi(e,Dn),new Pn(e)}function Bi(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ot(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var nh=Math.pow(2,7),oh=Math.pow(2,14),ih=Math.pow(2,21),Di=Math.pow(2,28),Ri=Math.pow(2,35),Pi=Math.pow(2,42),Li=Math.pow(2,49),Q=128,gt=127;function te(e){if(e<nh)return 1;if(e<oh)return 2;if(e<ih)return 3;if(e<Di)return 4;if(e<Ri)return 5;if(e<Pi)return 6;if(e<Li)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Hr(e,t,r=0){switch(te(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 Ni(e,t){let r=e[t],n=0;if(n+=r&gt,r<Q||(r=e[t+1],n+=(r&gt)<<7,r<Q)||(r=e[t+2],n+=(r&gt)<<14,r<Q)||(r=e[t+3],n+=(r&gt)<<21,r<Q)||(r=e[t+4],n+=(r&gt)*Di,r<Q)||(r=e[t+5],n+=(r&gt)*Ri,r<Q)||(r=e[t+6],n+=(r&gt)*Pi,r<Q)||(r=e[t+7],n+=(r&gt)*Li,r<Q))return n;throw new RangeError("Could not decode varint")}function sh(e,t){let r=e.get(t),n=0;if(n+=r&gt,r<Q||(r=e.get(t+1),n+=(r&gt)<<7,r<Q)||(r=e.get(t+2),n+=(r&gt)<<14,r<Q)||(r=e.get(t+3),n+=(r&gt)<<21,r<Q)||(r=e.get(t+4),n+=(r&gt)*Di,r<Q)||(r=e.get(t+5),n+=(r&gt)*Ri,r<Q)||(r=e.get(t+6),n+=(r&gt)*Pi,r<Q)||(r=e.get(t+7),n+=(r&gt)*Li,r<Q))return n;throw new RangeError("Could not decode varint")}function Ui(e,t=0){return e instanceof Uint8Array?Ni(e,t):sh(e,t)}var Oi=new Float32Array([-0]),Ce=new Uint8Array(Oi.buffer);function yc(e,t,r){Oi[0]=e,t[r]=Ce[0],t[r+1]=Ce[1],t[r+2]=Ce[2],t[r+3]=Ce[3]}function gc(e,t){return Ce[0]=e[t],Ce[1]=e[t+1],Ce[2]=e[t+2],Ce[3]=e[t+3],Oi[0]}var ki=new Float64Array([-0]),xt=new Uint8Array(ki.buffer);function xc(e,t,r){ki[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 bc(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],ki[0]}var ch=BigInt(Number.MAX_SAFE_INTEGER),uh=BigInt(Number.MIN_SAFE_INTEGER),Dt=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 $e;if(t<ch&&t>uh)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>wc&&(o=0n,++n>wc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return $e;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):$e}},$e=new Dt(0,0);$e.toBigInt=function(){return 0n};$e.zzEncode=$e.zzDecode=function(){return this};$e.length=function(){return 1};var wc=4294967296n;function Ec(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 Sc(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 Ki(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 qt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ln(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Vi=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,qt(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 qt(this,4);return Ln(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return Ln(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=gc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=bc(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 qt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Sc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Dt(0,0),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 qt(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 qt(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 qt(this,8);let t=Ln(this.buf,this.pos+=4),r=Ln(this.buf,this.pos+=4);return new Dt(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=Ni(this.buf,this.pos);return this.pos+=te(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Mi(e){return new Vi(e instanceof Uint8Array?e:e.subarray())}function lr(e,t,r){let n=Mi(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 Bt(s);o+s>t&&(n=Bt(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Fe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Fi(){}var Hi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},fh=$i();function lh(e){return globalThis.Buffer!=null?Bt(e):fh(e)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Fe(Fi,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Fe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new zi((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(Nn,10,Dt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Dt.fromBigInt(t);return this._push(Nn,r.length(),r)}uint64Number(t){return this._push(Hr,te(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=Dt.fromBigInt(t).zzEncode();return this._push(Nn,r.length(),r)}sint64Number(t){let r=Dt.fromNumber(t).zzEncode();return this._push(Nn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(qi,1,t?1:0)}fixed32(t){return this._push(zr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Dt.fromBigInt(t);return this._push(zr,4,r.lo)._push(zr,4,r.hi)}fixed64Number(t){let r=Dt.fromNumber(t);return this._push(zr,4,r.lo)._push(zr,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(yc,4,t)}double(t){return this._push(xc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(qi,1,0):this.uint32(r)._push(hh,r,t)}string(t){let r=Ec(t);return r!==0?this.uint32(r)._push(Ki,r,t):this._push(qi,1,0)}fork(){return this.states=new Hi(this),this.head=this.tail=new Fe(Fi,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Fe(Fi,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=lh(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function qi(e,t,r){t[r]=e&255}function dh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var zi=class extends Fe{next;constructor(t,r){super(dh,t,r),this.next=void 0}};function Nn(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 zr(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 hh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(jr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ph,t,e),this},jr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(mh,t,e),this});function ph(e,t,r){t.set(e,r)}function mh(e,t,r){e.length<40?Ki(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function ji(){return new jr}function dr(e,t){let r=ji();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var hr;(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"})(hr||(hr={}));function Un(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Gr(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 Un("enum",hr.VARINT,r,n)}function pr(e,t){return Un("message",hr.LENGTH_DELIMITED,e,t)}var st;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(st||(st={}));var Gi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Gi||(Gi={}));(function(e){e.codec=()=>Gr(Gi)})(st||(st={}));var ee;(function(e){let t;e.codec=()=>(t==null&&(t=pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.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=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>dr(r,e.codec()),e.decode=(r,n)=>lr(r,e.codec(),n)})(ee||(ee={}));var Zi;(function(e){let t;e.codec=()=>(t==null&&(t=pr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.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=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>dr(r,e.codec()),e.decode=(r,n)=>lr(r,e.codec(),n)})(Zi||(Zi={}));var Yr={};wt(Yr,{MAX_RSA_KEY_SIZE:()=>Yi,generateRSAKeyPair:()=>Bc,jwkToJWKKeyPair:()=>_c,jwkToPkcs1:()=>bh,jwkToPkix:()=>Qi,jwkToRSAPrivateKey:()=>ns,pkcs1MessageToJwk:()=>Xi,pkcs1MessageToRSAPrivateKey:()=>ts,pkcs1ToJwk:()=>xh,pkcs1ToRSAPrivateKey:()=>Cc,pkixMessageToJwk:()=>Ji,pkixMessageToRSAPublicKey:()=>rs,pkixToJwk:()=>wh,pkixToRSAPublicKey:()=>es});var mr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Yr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return j.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return Tc(this.jwk,r,t,n)}},Zr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Yr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}sign(t,r){return Ic(this.jwk,t,r)}};var Yi=8192,Wi=18,yh=1062,gh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function xh(e){let t=se(e);return Xi(t)}function Xi(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 bh(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 ot("JWK was missing components");return Ee([It(Uint8Array.from([0])),It(H(e.n,"base64url")),It(H(e.e,"base64url")),It(H(e.d,"base64url")),It(H(e.p,"base64url")),It(H(e.q,"base64url")),It(H(e.dp,"base64url")),It(H(e.dq,"base64url")),It(H(e.qi,"base64url"))]).subarray()}function wh(e){let t=se(e,{offset:0});return Ji(t)}function Ji(e){let t=se(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function Qi(e){if(e.n==null||e.e==null)throw new ot("JWK was missing components");return Ee([gh,wn(Ee([It(H(e.n,"base64url")),It(H(e.e,"base64url"))]))]).subarray()}function Cc(e){let t=se(e);return ts(t)}function ts(e){let t=Xi(e);return ns(t)}function es(e,t){if(e.byteLength>=yh)throw new Ze("Key size is too large");let r=se(e,{offset:0});return rs(r,e,t)}function rs(e,t,r){let n=Ji(e);if(r==null){let o=ir(ee.encode({Type:st.RSA,Data:t}));r=$t(Wi,o)}return new mr(n,r)}function ns(e){if(Rc(e)>Yi)throw new ot("Key size is too large");let t=_c(e),r=ir(ee.encode({Type:st.RSA,Data:Qi(t.publicKey)})),n=$t(Wi,r);return new Zr(t.privateKey,new mr(t.publicKey,n))}async function Bc(e){if(e>Yi)throw new ot("Key size is too large");let t=await Dc(e),r=ir(ee.encode({Type:st.RSA,Data:Qi(t.publicKey)})),n=$t(Wi,r);return new Zr(t.privateKey,new mr(t.publicKey,n))}function _c(e){if(e==null)throw new ot("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Dc(e,t){let r=await Ot.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 Eh(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Ic(e,t,r){let n=await Ot.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Ot.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 Ot.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Ot.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Eh(e,t){if(e.privateKey==null||e.publicKey==null)throw new ot("Private and public key are required");let r=await Promise.all([Ot.get().subtle.exportKey("jwk",e.privateKey),Ot.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function Rc(e){if(e.kty!=="RSA")throw new ot("invalid key type");if(e.n==null)throw new ot("invalid key modulus");return H(e.n,"base64url").length*8}var On=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(En(t),q(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),ce(o)}update(t){return nr(this),this.iHash.update(t),this}digestInto(t){nr(this),q(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},os=(e,t,r)=>new On(e,t).update(r).digest();os.create=(e,t)=>new On(e,t);var Pc=(e,t)=>(e+(e>=0?t:-t)/Lc)/t;function Sh(e,t,r){let[[n,o],[i,s]]=t,c=Pc(s*e,r),a=Pc(-o*e,r),f=e-c*n-a*i,u=-c*o-a*s,l=f<he,y=u<he;l&&(f=-f),y&&(u=-u);let E=Mr(Math.ceil(yi(r)/2))+yr;if(f<he||f>=E||u<he||u>=E)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:f,k2neg:y,k2:u}}function ss(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function is(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return de(r.lowS,"lowS"),de(r.prehash,"prehash"),r.format!==void 0&&ss(r.format),r}var as=class extends Error{constructor(t=""){super(t)}},Be={Err:as,_tlv:{encode:(e,t)=>{let{Err:r}=Be;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=Kr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Kr(o.length/2|128):"";return Kr(e)+i+o+t},decode(e,t){let{Err:r}=Be,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}=Be;if(e<he)throw new t("integer: negative integers are not allowed");let r=Kr(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}=Be;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 sr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Be,o=q(e,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=Be,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},he=BigInt(0),yr=BigInt(1),Lc=BigInt(2),kn=BigInt(3),vh=BigInt(4);function Nc(e,t={}){let r=Cn("weierstrass",e,t),{Fp:n,Fn:o}=r,i=r.CURVE,{h:s,n:c}=i;Ie(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=Oc(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:S}=m.toAffine(),R=n.toBytes(d);if(de(g,"isCompressed"),g){u();let L=!n.isOdd(S);return Tt(Uc(L),R)}else return Tt(Uint8Array.of(4),R,n.toBytes(S))}function y(A){q(A,void 0,"Point");let{publicKey:m,publicKeyUncompressed:g}=f,d=A.length,S=A[0],R=A.subarray(1);if(d===m&&(S===2||S===3)){let L=n.fromBytes(R);if(!n.isValid(L))throw new Error("bad point: is not on curve, wrong x");let U=T(L),O;try{O=n.sqrt(U)}catch(tt){let W=tt instanceof Error?": "+tt.message:"";throw new Error("bad point: is not on curve, sqrt error"+W)}u();let K=n.isOdd(O);return(S&1)===1!==K&&(O=n.neg(O)),{x:L,y:O}}else if(d===g&&S===4){let L=n.BYTES,U=n.fromBytes(R.subarray(0,L)),O=n.fromBytes(R.subarray(L,L*2));if(!I(U,O))throw new Error("bad point: is not on curve");return{x:U,y:O}}else throw new Error(`bad point: got length ${d}, expected compressed=${m} or uncompressed=${g}`)}let E=t.toBytes||l,b=t.fromBytes||y;function T(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 I(A,m){let g=n.sqr(m),d=T(A);return n.eql(g,d)}if(!I(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let w=n.mul(n.pow(i.a,kn),vh),C=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(w,C)))throw new Error("bad curve params: a or b");function v(A,m,g=!1){if(!n.isValid(m)||g&&n.is0(m))throw new Error(`bad point coordinate ${A}`);return m}function N(A){if(!(A instanceof p))throw new Error("Weierstrass Point expected")}function k(A){if(!a||!a.basises)throw new Error("no endo");return Sh(A,a.basises,o.ORDER)}let M=ar((A,m)=>{let{X:g,Y:d,Z:S}=A;if(n.eql(S,n.ONE))return{x:g,y:d};let R=A.is0();m==null&&(m=R?n.ONE:n.inv(S));let L=n.mul(g,m),U=n.mul(d,m),O=n.mul(S,m);if(R)return{x:n.ZERO,y:n.ZERO};if(!n.eql(O,n.ONE))throw new Error("invZ was invalid");return{x:L,y:U}}),V=ar(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(!I(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,S){return g=new p(n.mul(g.X,A),g.Y,g.Z),m=Fr(d,m),g=Fr(S,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=v("x",m),this.Y=v("y",g,!0),this.Z=v("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(b(q(m,void 0,"point")));return g.assertValidity(),g}static fromHex(m){return p.fromBytes(fe(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(kn),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){N(m);let{X:g,Y:d,Z:S}=this,{X:R,Y:L,Z:U}=m,O=n.eql(n.mul(g,U),n.mul(R,S)),K=n.eql(n.mul(d,U),n.mul(L,S));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,kn),{X:S,Y:R,Z:L}=this,U=n.ZERO,O=n.ZERO,K=n.ZERO,F=n.mul(S,S),tt=n.mul(R,R),W=n.mul(L,L),G=n.mul(S,R);return G=n.add(G,G),K=n.mul(S,L),K=n.add(K,K),U=n.mul(m,K),O=n.mul(d,W),O=n.add(U,O),U=n.sub(tt,O),O=n.add(tt,O),O=n.mul(U,O),U=n.mul(G,U),K=n.mul(d,K),W=n.mul(m,W),G=n.sub(F,W),G=n.mul(m,G),G=n.add(G,K),K=n.add(F,F),F=n.add(K,F),F=n.add(F,W),F=n.mul(F,G),O=n.add(O,F),W=n.mul(R,L),W=n.add(W,W),F=n.mul(W,G),U=n.sub(U,F),K=n.mul(W,tt),K=n.add(K,K),K=n.add(K,K),new p(U,O,K)}add(m){N(m);let{X:g,Y:d,Z:S}=this,{X:R,Y:L,Z:U}=m,O=n.ZERO,K=n.ZERO,F=n.ZERO,tt=i.a,W=n.mul(i.b,kn),G=n.mul(g,R),et=n.mul(d,L),dt=n.mul(S,U),Yt=n.add(g,d),rt=n.add(R,L);Yt=n.mul(Yt,rt),rt=n.add(G,et),Yt=n.sub(Yt,rt),rt=n.add(g,S);let yt=n.add(R,U);return rt=n.mul(rt,yt),yt=n.add(G,dt),rt=n.sub(rt,yt),yt=n.add(d,S),O=n.add(L,U),yt=n.mul(yt,O),O=n.add(et,dt),yt=n.sub(yt,O),F=n.mul(tt,rt),O=n.mul(W,dt),F=n.add(O,F),O=n.sub(et,F),F=n.add(et,F),K=n.mul(O,F),et=n.add(G,G),et=n.add(et,G),dt=n.mul(tt,dt),rt=n.mul(W,rt),et=n.add(et,dt),dt=n.sub(G,dt),dt=n.mul(tt,dt),rt=n.add(rt,dt),G=n.mul(et,rt),K=n.add(K,G),G=n.mul(yt,rt),O=n.mul(Yt,O),O=n.sub(O,G),G=n.mul(Yt,et),F=n.mul(yt,F),F=n.add(F,G),new p(O,K,F)}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,S,R=L=>D.cached(this,L,U=>Me(p,U));if(g){let{k1neg:L,k1:U,k2neg:O,k2:K}=k(m),{p:F,f:tt}=R(U),{p:W,f:G}=R(K);S=tt.add(G),d=h(g.beta,F,W,L,O)}else{let{p:L,f:U}=R(m);d=L,S=U}return Me(p,[d,S])[0]}multiplyUnsafe(m){let{endo:g}=t,d=this;if(!o.isValid(m))throw new Error("invalid scalar: out of range");if(m===he||d.is0())return p.ZERO;if(m===yr)return d;if(D.hasCache(this))return this.multiply(m);if(g){let{k1neg:S,k1:R,k2neg:L,k2:U}=k(m),{p1:O,p2:K}=ac(p,d,R,U);return h(g.beta,O,K,S,L)}else return D.unsafe(d,m)}toAffine(m){return M(this,m)}isTorsionFree(){let{isTorsionFree:m}=t;return s===yr?!0:m?m(p,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:m}=t;return s===yr?this:m?m(p,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(m=!0){return de(m,"isCompressed"),this.assertValidity(),E(p,this,m)}toHex(m=!0){return ue(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let _=o.BITS,D=new fr(p,t.endo?Math.ceil(_/2):_);return p.BASE.precompute(8),p}function Uc(e){return Uint8Array.of(e?2:3)}function Oc(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Ah(e,t={}){let{Fn:r}=e,n=t.randomBytes||or,o=Object.assign(Oc(e.Fp,r),{seed:wi(r.ORDER)});function i(E){try{let b=r.fromBytes(E);return r.isValidNot0(b)}catch{return!1}}function s(E,b){let{publicKey:T,publicKeyUncompressed:I}=o;try{let w=E.length;return b===!0&&w!==T||b===!1&&w!==I?!1:!!e.fromBytes(E)}catch{return!1}}function c(E=n(o.seed)){return Ei(q(E,o.seed,"seed"),r.ORDER)}function a(E,b=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(b)}function f(E){let{secretKey:b,publicKey:T,publicKeyUncompressed:I}=o;if(!Ne(E)||"_lengths"in r&&r._lengths||b===T)return;let w=q(E,void 0,"key").length;return w===T||w===I}function u(E,b,T=!0){if(f(E)===!0)throw new Error("first arg must be private key");if(f(b)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(E);return e.fromBytes(b).multiply(I).toBytes(T)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},y=Bn(c,a);return Object.freeze({getPublicKey:a,getSharedSecret:u,keygen:y,Point:e,utils:l,lengths:o})}function kc(e,t,r={}){En(t),Ie(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||or,o=r.hmac||((g,d)=>os(t,g,d)),{Fp:i,Fn:s}=e,{ORDER:c,BITS:a}=s,{keygen:f,getPublicKey:u,getSharedSecret:l,utils:y,lengths:E}=Ah(e,r),b={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},T=c*Lc<i.ORDER;function I(g){let d=c>>yr;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 C(){if(T)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(g,d){ss(d);let S=E.signature,R=d==="compact"?S:d==="recovered"?S+1:void 0;return q(g,R)}class N{r;s;recovery;constructor(d,S,R){if(this.r=w("r",d),this.s=w("s",S),R!=null){if(C(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(d,S=b.format){v(d,S);let R;if(S==="der"){let{r:K,s:F}=Be.toSig(q(d));return new N(K,F)}S==="recovered"&&(R=d[0],S="compact",d=d.subarray(1));let L=E.signature/2,U=d.subarray(0,L),O=d.subarray(L,L*2);return new N(s.fromBytes(U),s.fromBytes(O),R)}static fromHex(d,S){return this.fromBytes(fe(d),S)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new N(this.r,this.s,d)}recoverPublicKey(d){let{r:S,s:R}=this,L=this.assertRecovery(),U=L===2||L===3?S+c:S;if(!i.isValid(U))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let O=i.toBytes(U),K=e.fromBytes(Tt(Uc((L&1)===0),O)),F=s.inv(U),tt=M(q(d,void 0,"msgHash")),W=s.create(-tt*F),G=s.create(R*F),et=e.BASE.multiplyUnsafe(W).add(K.multiplyUnsafe(G));if(et.is0())throw new Error("invalid recovery: point at infinify");return et.assertValidity(),et}hasHighS(){return I(this.s)}toBytes(d=b.format){if(ss(d),d==="der")return fe(Be.hexFromSig(this));let{r:S,s:R}=this,L=s.toBytes(S),U=s.toBytes(R);return d==="recovered"?(C(),Tt(Uint8Array.of(this.assertRecovery()),L,U)):Tt(L,U)}toHex(d){return ue(this.toBytes(d))}}let k=r.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");let S=sr(d),R=d.length*8-a;return R>0?S>>BigInt(R):S},M=r.bits2int_modN||function(d){return s.create(k(d))},V=Mr(a);function h(g){return Vr("num < 2^"+a,g,he,V),s.toBytes(g)}function p(g,d){return q(g,void 0,"message"),d?q(t(g),void 0,"prehashed message"):g}function _(g,d,S){let{lowS:R,prehash:L,extraEntropy:U}=is(S,b);g=p(g,L);let O=M(g),K=s.fromBytes(d);if(!s.isValidNot0(K))throw new Error("invalid private key");let F=[h(K),h(O)];if(U!=null&&U!==!1){let et=U===!0?n(E.secretKey):U;F.push(q(et,void 0,"extraEntropy"))}let tt=Tt(...F),W=O;function G(et){let dt=k(et);if(!s.isValidNot0(dt))return;let Yt=s.inv(dt),rt=e.BASE.multiply(dt).toAffine(),yt=s.create(rt.x);if(yt===he)return;let dn=s.create(Yt*s.create(W+yt*K));if(dn===he)return;let qs=(rt.x===yt?0:2)|Number(rt.y&yr),Hs=dn;return R&&I(dn)&&(Hs=s.neg(dn),qs^=1),new N(yt,Hs,T?void 0:qs)}return{seed:tt,k2sig:G}}function D(g,d,S={}){let{seed:R,k2sig:L}=_(g,d,S);return Ha(t.outputLen,s.BYTES,o)(R,L).toBytes(S.format)}function A(g,d,S,R={}){let{lowS:L,prehash:U,format:O}=is(R,b);if(S=q(S,void 0,"publicKey"),d=p(d,U),!Ne(g)){let K=g instanceof N?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+K)}v(g,O);try{let K=N.fromBytes(g,O),F=e.fromBytes(S);if(L&&K.hasHighS())return!1;let{r:tt,s:W}=K,G=M(d),et=s.inv(W),dt=s.create(G*et),Yt=s.create(tt*et),rt=e.BASE.multiplyUnsafe(dt).add(F.multiplyUnsafe(Yt));return rt.is0()?!1:s.create(rt.x)===tt}catch{return!1}}function m(g,d,S={}){let{prehash:R}=is(S,b);return d=p(d,R),N.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:f,getPublicKey:u,getSharedSecret:l,utils:y,lengths:E,Point:e,sign:D,verify:A,recoverPublicKey:m,Signature:N,hash:t})}var us={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Ih={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Kc=BigInt(2);function Th(e){let t=us.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=J(u,r,t)*u%t,y=J(l,r,t)*u%t,E=J(y,Kc,t)*f%t,b=J(E,o,t)*E%t,T=J(b,i,t)*b%t,I=J(T,c,t)*T%t,w=J(I,a,t)*I%t,C=J(w,c,t)*T%t,v=J(C,r,t)*u%t,N=J(v,s,t)*b%t,k=J(N,n,t)*f%t,M=J(k,Kc,t);if(!cs.eql(cs.sqr(M),e))throw new Error("Cannot find square root");return M}var cs=cr(us.p,{sqrt:Th}),Ch=Nc(us,{Fp:cs,endo:Ih}),gr=kc(Ch,ir);function Vc(e,t,r,n){let o=Rr.digest(r instanceof Uint8Array?r:r.subarray());if(Rn(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),gr.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new qr(String(i))});try{return n?.signal?.throwIfAborted(),gr.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new qr(String(i))}}var Kn=class{type="secp256k1";raw;_key;constructor(t){this._key=$c(t),this.raw=Mc(this._key)}toMultihash(){return Ct.digest(rr(this))}toCID(){return j.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return Vc(this._key,r,t,n)}};function fs(e){return new Kn(e)}function Mc(e){return gr.Point.fromBytes(e).toBytes()}function $c(e){try{return gr.Point.fromBytes(e),e}catch(t){throw new Ze(String(t))}}function Fc(e,t){let{Type:r,Data:n}=ee.decode(e),o=n??new Uint8Array;switch(r){case st.RSA:return es(o,t);case st.Ed25519:return _i(o);case st.secp256k1:return fs(o);case st.ECDSA:return oi(o);default:throw new We}}function Vn(e){let{Type:t,Data:r}=ee.decode(e.digest),n=r??new Uint8Array;switch(t){case st.Ed25519:return _i(n);case st.secp256k1:return fs(n);case st.ECDSA:return oi(n);default:throw new We}}function rr(e){return ee.encode({Type:st[e.type],Data:e.raw})}var qc=Symbol.for("nodejs.util.inspect.custom"),Bh=114,Wr=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()})`}[gn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return j.createV1(Bh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Y(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Y(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[qc](){return`PeerId(${this.toString()})`}},Mn=class extends Wr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},$n=class extends Wr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Fn=class extends Wr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},_h=2336,Xr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Ct.digest(H(this.url))}[qc](){return`PeerId(${this.url})`}[gn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return j.createV1(_h,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=z(t)),t.toString()===this.toString())}};var Dh=114,Hc=2336;function zc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=we(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return ls(j.parse(e));if(t==null)throw new ot('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=we(t.decode(e))}return qn(r)}function qn(e){if(Ph(e))return new Mn({multihash:e});if(Rh(e))try{let t=Vn(e);if(t.type==="Ed25519")return new $n({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Fn({multihash:e,publicKey:t})}catch{let r=z(e.digest);return new Xr(new URL(r))}throw new Ye("Supplied PeerID Multihash is invalid")}function ls(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Dh&&e.code!==Hc)throw new yn("Supplied PeerID CID is invalid");if(e.code===Hc){let t=z(e.multihash.digest);return new Xr(new URL(t))}return qn(e.multihash)}function Rh(e){return e.code===Ct.code}function Ph(e){return e.code===Rr.code}var pt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},pe=class extends Error{static name="ValidationError";name="ValidationError"},Hn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},zn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var jn=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 Lh=45,Nh=15,Gn=new jn;function jc(e){if(!(e.length>Nh))return Gn.new(e).parseWith(()=>Gn.readIPv4Addr())}function Gc(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Lh))return Gn.new(e).parseWith(()=>Gn.readIPv6Addr())}function Zn(e){return!!jc(e)}function Zc(e){return!!Gc(e)}function hs(e){return t=>z(t,e)}function ps(e){return t=>H(t,e)}function xr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function qe(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Yc(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=qe(n);return Ut([r,o],r.length+o.length)}function Wc(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=Wt.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=qe(n);return Ut([r,o],r.length+o.length)}function ms(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=z(t,"base32"),o=xr(r);return`${n}:${o}`}var ys=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new pt("Invalid byte value in IP address");t[n]=o}),t},Xc=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Zn(r[n]),s;i&&(s=ys(r[n]),r[n]=z(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,z(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new pt("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},Jc=function(e){if(e.byteLength!==4)throw new pt("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Qc=function(e){if(e.byteLength!==16)throw new pt("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],i=e[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;t.push(s)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new pt(`Invalid IPv6 address "${r}"`)}};function tu(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new pt(`Invalid IPv6 address "${e}"`)}}var ds=Object.values(Pr).map(e=>e.decoder),Uh=(function(){let e=ds[0].or(ds[1]);return ds.slice(2).forEach(t=>e=e.or(t)),e})();function eu(e){return Uh.decode(e)}function ru(e){return t=>e.encoder.encode(t)}function Oh(e){if(parseInt(e).toString()!==e)throw new pe("Value must be an integer")}function kh(e){if(e<0)throw new pe("Value must be a positive integer, or zero")}function Kh(e){return t=>{if(t>e)throw new pe(`Value must be smaller than or equal to ${e}`)}}function Vh(...e){return t=>{for(let r of e)r(t)}}var Jr=Vh(Oh,kh,Kh(65535));var ft=-1,gs=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 zn(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},me=new gs,Tp=[{code:4,name:"ip4",size:32,valueToBytes:ys,bytesToValue:Jc,validate:e=>{if(!Zn(e))throw new pe(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:qe,bytesToValue:xr,validate:Jr},{code:273,name:"udp",size:16,valueToBytes:qe,bytesToValue:xr,validate:Jr},{code:33,name:"dccp",size:16,valueToBytes:qe,bytesToValue:xr,validate:Jr},{code:41,name:"ip6",size:128,valueToBytes:Xc,bytesToValue:Qc,stringToValue:tu,validate:e=>{if(!Zc(e))throw new pe(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:ft},{code:43,name:"ipcidr",size:8,bytesToValue:hs("base10"),valueToBytes:ps("base10")},{code:53,name:"dns",size:ft},{code:54,name:"dns4",size:ft},{code:55,name:"dns6",size:ft},{code:56,name:"dnsaddr",size:ft},{code:132,name:"sctp",size:16,valueToBytes:qe,bytesToValue:xr,validate:Jr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ft,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:ft,bytesToValue:hs("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?ps("base58btc")(e):j.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:ms,valueToBytes:Yc},{code:445,name:"onion3",size:296,bytesToValue:ms,valueToBytes:Wc},{code:446,name:"garlic64",size:ft},{code:447,name:"garlic32",size:ft},{code:448,name:"tls"},{code:449,name:"sni",size:ft},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ft,bytesToValue:ru(Uo),valueToBytes:eu},{code:480,name:"http"},{code:481,name:"http-path",size:ft,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ft}];Tp.forEach(e=>{me.addProtocol(e)});function nu(e){let t=[],r=0;for(;r<e.length;){let n=Ui(e,r),o=me.getProtocol(n),i=te(n),s=Cp(o,e,r+i),c=0;s>0&&o.size===ft&&(c=te(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 ou(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=me.getProtocol(n.code),i=te(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??H(n.value),c=s.byteLength,o.size===ft&&(a=te(c)));let f=new Uint8Array(i+a+c),u=0;Hr(n.code,f,u),u+=i,s!=null&&(o.size===ft&&(Hr(c,f,u),u+=a),f.set(s,u)),n.bytes=f}r.push(n.bytes),t+=n.bytes.byteLength}return Ut(r,t)}function iu(e){if(e.charAt(0)!=="/")throw new pt('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let i=1;i<e.length;i++){let s=e.charAt(i);s!=="/"&&(r==="protocol"?o+=e.charAt(i):n+=e.charAt(i));let c=i===e.length-1;if(s==="/"||c){let a=me.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){t.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new pt(`Component ${o} was missing value`);r="value"}else if(r==="value"){let f={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new pt(`Component ${o} was missing value`);f.value=a.stringToValue?.(n)??n}t.push(f),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new pt("Incomplete multiaddr");return t}function su(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=me.getProtocol(t.code);if(r==null)throw new pt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Cp(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Ui(t,r)}var Bp=Symbol.for("nodejs.util.inspect.custom"),xs=Symbol.for("@multiformats/multiaddr");function _p(e){if(e==null&&(e="/"),au(e))return e.getComponents();if(e instanceof Uint8Array)return nu(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),iu(e);if(Array.isArray(e))return e;throw new pt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Yn=class e{[xs]=!0;#t;#n;#e;constructor(t="/",r={}){this.#t=_p(t),r.validate!==!1&&Dp(this)}get bytes(){return this.#e==null&&(this.#e=ou(this.#t)),this.#e}toString(){return this.#n==null&&(this.#n=su(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 Hn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}equals(t){return Y(this.bytes,t.bytes)}[Bp](){return`Multiaddr(${this.toString()})`}};function Dp(e){e.getComponents().forEach(t=>{let r=me.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function au(e){return!!e?.[xs]}function Wn(e){return new Yn(e)}function br(e){let t=new globalThis.AbortController;function r(){let i=e.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();t.abort(i);for(let s of e)s?.removeEventListener!=null&&s.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*Qr(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 h0=Co(ws(),1);var Ht=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Xn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},wr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Jn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Qn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},to=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},tn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var zt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),(function(o){o.codec=()=>Gr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=pr((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=>dr(o,e.codec()),e.decode=(o,i)=>lr(o,e.codec(),i)})(zt||(zt={}));var Rp=["string","number","bigint","symbol"],Pp=["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 cu(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Rp.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Lp(e))return"Buffer";let r=Np(e);return r||"Object"}function Lp(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Np(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Pp.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 P=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 Er=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Up=new TextDecoder,Op=new TextEncoder;function eo(e){return Er&&globalThis.Buffer.isBuffer(e)}function Es(e){return e instanceof Uint8Array?eo(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var du=Er?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):fu(e,t,r):(e,t,r)=>r-t>64?Up.decode(e.subarray(t,r)):fu(e,t,r),hu=Er?e=>e.length>64?globalThis.Buffer.from(e):uu(e):e=>e.length>64?Op.encode(e):uu(e),re=e=>Uint8Array.from(e),Sr=Er?(e,t,r)=>eo(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),pu=Er?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Es(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},mu=Er?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ro(e,t){if(eo(e)&&eo(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 uu(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 fu(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 kp(n)}var lu=4096;function kp(e){let t=e.length;if(t<=lu)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=lu));return r}var Kp=256,en=class{constructor(t=Kp){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=mu(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=Sr(n,0,this.cursor)}else r=pu(this.chunks,this.cursor);return t&&this.reset(),r}};var $="CBOR decode error:",Ss="CBOR encode error:",rn=[];rn[23]=1;rn[24]=2;rn[25]=3;rn[26]=5;rn[27]=9;function ye(e,t,r){if(e.length-t<r)throw new Error(`${$} not enough data for type`)}var lt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Rt(e,t,r){ye(e,t,1);let n=e[t];if(r.strict===!0&&n<lt[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Pt(e,t,r){ye(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<lt[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Lt(e,t,r){ye(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<lt[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){ye(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<lt[3])throw new Error(`${$} 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(`${$} integers outside of the safe integer range are not supported`)}function yu(e,t,r,n){return new P(x.uint,Rt(e,t+1,n),2)}function gu(e,t,r,n){return new P(x.uint,Pt(e,t+1,n),3)}function xu(e,t,r,n){return new P(x.uint,Lt(e,t+1,n),5)}function bu(e,t,r,n){return new P(x.uint,Nt(e,t+1,n),9)}function kt(e,t){return mt(e,0,t.value)}function mt(e,t,r){if(r<lt[0]){let n=Number(r);e.push([t|n])}else if(r<lt[1]){let n=Number(r);e.push([t|24,n])}else if(r<lt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<lt[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<lt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}kt.encodedSize=function(t){return mt.encodedSize(t.value)};mt.encodedSize=function(t){return t<lt[0]?1:t<lt[1]?2:t<lt[2]?3:t<lt[3]?5:9};kt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function wu(e,t,r,n){return new P(x.negint,-1-Rt(e,t+1,n),2)}function Eu(e,t,r,n){return new P(x.negint,-1-Pt(e,t+1,n),3)}function Su(e,t,r,n){return new P(x.negint,-1-Lt(e,t+1,n),5)}var vs=BigInt(-1),vu=BigInt(1);function Au(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new P(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new P(x.negint,vs-BigInt(o),9)}function no(e,t){let r=t.value,n=typeof r=="bigint"?r*vs-vu:r*-1-1;mt(e,t.type.majorEncoded,n)}no.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*vs-vu:r*-1-1;return n<lt[0]?1:n<lt[1]?2:n<lt[2]?3:n<lt[3]?5:9};no.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function nn(e,t,r,n){ye(e,t,r+n);let o=Sr(e,t+r,t+r+n);return new P(x.bytes,o,r+n)}function Iu(e,t,r,n){return nn(e,t,1,r)}function Tu(e,t,r,n){return nn(e,t,2,Rt(e,t+1,n))}function Cu(e,t,r,n){return nn(e,t,3,Pt(e,t+1,n))}function Bu(e,t,r,n){return nn(e,t,5,Lt(e,t+1,n))}function _u(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return nn(e,t,9,o)}function oo(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===x.string?hu(e.value):e.value),e.encodedBytes}function vr(e,t){let r=oo(t);mt(e,t.type.majorEncoded,r.length),e.push(r)}vr.encodedSize=function(t){let r=oo(t);return mt.encodedSize(r.length)+r.length};vr.compareTokens=function(t,r){return Mp(oo(t),oo(r))};function Mp(e,t){return e.length<t.length?-1:e.length>t.length?1:ro(e,t)}function on(e,t,r,n,o){let i=r+n;ye(e,t,i);let s=new P(x.string,du(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Sr(e,t+r,t+i)),s}function Du(e,t,r,n){return on(e,t,1,r,n)}function Ru(e,t,r,n){return on(e,t,2,Rt(e,t+1,n),n)}function Pu(e,t,r,n){return on(e,t,3,Pt(e,t+1,n),n)}function Lu(e,t,r,n){return on(e,t,5,Lt(e,t+1,n),n)}function Nu(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return on(e,t,9,o,n)}var Uu=vr;function Ar(e,t,r,n){return new P(x.array,n,r)}function Ou(e,t,r,n){return Ar(e,t,1,r)}function ku(e,t,r,n){return Ar(e,t,2,Rt(e,t+1,n))}function Ku(e,t,r,n){return Ar(e,t,3,Pt(e,t+1,n))}function Vu(e,t,r,n){return Ar(e,t,5,Lt(e,t+1,n))}function Mu(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return Ar(e,t,9,o)}function $u(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Ar(e,t,1,1/0)}function io(e,t){mt(e,x.array.majorEncoded,t.value)}io.compareTokens=kt.compareTokens;io.encodedSize=function(t){return mt.encodedSize(t.value)};function Ir(e,t,r,n){return new P(x.map,n,r)}function Fu(e,t,r,n){return Ir(e,t,1,r)}function qu(e,t,r,n){return Ir(e,t,2,Rt(e,t+1,n))}function Hu(e,t,r,n){return Ir(e,t,3,Pt(e,t+1,n))}function zu(e,t,r,n){return Ir(e,t,5,Lt(e,t+1,n))}function ju(e,t,r,n){let o=Nt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return Ir(e,t,9,o)}function Gu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Ir(e,t,1,1/0)}function so(e,t){mt(e,x.map.majorEncoded,t.value)}so.compareTokens=kt.compareTokens;so.encodedSize=function(t){return mt.encodedSize(t.value)};function Zu(e,t,r,n){return new P(x.tag,r,1)}function Yu(e,t,r,n){return new P(x.tag,Rt(e,t+1,n),2)}function Wu(e,t,r,n){return new P(x.tag,Pt(e,t+1,n),3)}function Xu(e,t,r,n){return new P(x.tag,Lt(e,t+1,n),5)}function Ju(e,t,r,n){return new P(x.tag,Nt(e,t+1,n),9)}function ao(e,t){mt(e,x.tag.majorEncoded,t.value)}ao.compareTokens=kt.compareTokens;ao.encodedSize=function(t){return mt.encodedSize(t.value)};var jp=20,Gp=21,Zp=22,Yp=23;function Qu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new P(x.null,null,1):new P(x.undefined,void 0,1)}function tf(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new P(x.break,void 0,1)}function As(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${$} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new P(x.float,e,t)}function ef(e,t,r,n){return As(Is(e,t+1),3,n)}function rf(e,t,r,n){return As(Ts(e,t+1),5,n)}function nf(e,t,r,n){return As(cf(e,t+1),9,n)}function co(e,t,r){let n=t.value;if(n===!1)e.push([x.float.majorEncoded|jp]);else if(n===!0)e.push([x.float.majorEncoded|Gp]);else if(n===null)e.push([x.float.majorEncoded|Zp]);else if(n===void 0)e.push([x.float.majorEncoded|Yp]);else{let o,i=!1;(!r||r.float64!==!0)&&(sf(n),o=Is(jt,1),n===o||Number.isNaN(n)?(jt[0]=249,e.push(jt.slice(0,3)),i=!0):(af(n),o=Ts(jt,1),n===o&&(jt[0]=250,e.push(jt.slice(0,5)),i=!0))),i||(Wp(n),o=cf(jt,1),jt[0]=251,e.push(jt.slice(0,9)))}}co.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){sf(n);let o=Is(jt,1);if(n===o||Number.isNaN(n))return 3;if(af(n),o=Ts(jt,1),n===o)return 5}return 9};var of=new ArrayBuffer(9),Kt=new DataView(of,1),jt=new Uint8Array(of,0);function sf(e){if(e===1/0)Kt.setUint16(0,31744,!1);else if(e===-1/0)Kt.setUint16(0,64512,!1);else if(Number.isNaN(e))Kt.setUint16(0,32256,!1);else{Kt.setFloat32(0,e);let t=Kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Kt.setUint16(0,31744,!1);else if(r===0)Kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Kt.setUint16(0,0):o<-14?Kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Is(e,t){if(e.length-t<2)throw new Error(`${$} 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 af(e){Kt.setFloat32(0,e,!1)}function Ts(e,t){if(e.length-t<4)throw new Error(`${$} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Wp(e){Kt.setFloat64(0,e,!1)}function cf(e,t){if(e.length-t<8)throw new Error(`${$} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}co.compareTokens=kt.compareTokens;function Z(e,t,r){throw new Error(`${$} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function uo(e){return()=>{throw new Error(`${$} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=Z;B[24]=yu;B[25]=gu;B[26]=xu;B[27]=bu;B[28]=Z;B[29]=Z;B[30]=Z;B[31]=Z;for(let e=32;e<=55;e++)B[e]=Z;B[56]=wu;B[57]=Eu;B[58]=Su;B[59]=Au;B[60]=Z;B[61]=Z;B[62]=Z;B[63]=Z;for(let e=64;e<=87;e++)B[e]=Iu;B[88]=Tu;B[89]=Cu;B[90]=Bu;B[91]=_u;B[92]=Z;B[93]=Z;B[94]=Z;B[95]=uo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=Du;B[120]=Ru;B[121]=Pu;B[122]=Lu;B[123]=Nu;B[124]=Z;B[125]=Z;B[126]=Z;B[127]=uo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=Ou;B[152]=ku;B[153]=Ku;B[154]=Vu;B[155]=Mu;B[156]=Z;B[157]=Z;B[158]=Z;B[159]=$u;for(let e=160;e<=183;e++)B[e]=Fu;B[184]=qu;B[185]=Hu;B[186]=zu;B[187]=ju;B[188]=Z;B[189]=Z;B[190]=Z;B[191]=Gu;for(let e=192;e<=215;e++)B[e]=Zu;B[216]=Yu;B[217]=Wu;B[218]=Xu;B[219]=Ju;B[220]=Z;B[221]=Z;B[222]=Z;B[223]=Z;for(let e=224;e<=243;e++)B[e]=uo("simple values are not supported");B[244]=Z;B[245]=Z;B[246]=Z;B[247]=Qu;B[248]=uo("simple values are not supported");B[249]=ef;B[250]=rf;B[251]=nf;B[252]=Z;B[253]=Z;B[254]=Z;B[255]=tf;var Gt=[];for(let e=0;e<24;e++)Gt[e]=new P(x.uint,e,1);for(let e=-1;e>=-24;e--)Gt[31-e]=new P(x.negint,e,1);Gt[64]=new P(x.bytes,new Uint8Array(0),1);Gt[96]=new P(x.string,"",1);Gt[128]=new P(x.array,0,1);Gt[160]=new P(x.map,0,1);Gt[244]=new P(x.false,!1,1);Gt[245]=new P(x.true,!0,1);Gt[246]=new P(x.null,null,1);function uf(e){switch(e.type){case x.false:return re([244]);case x.true:return re([245]);case x.null:return re([246]);case x.bytes:return e.value.length?void 0:re([64]);case x.string:return e.value===""?re([96]):void 0;case x.array:return e.value===0?re([128]):void 0;case x.map:return e.value===0?re([160]):void 0;case x.uint:return e.value<24?re([Number(e.value)]):void 0;case x.negint:if(e.value>=-24)return re([31-Number(e.value)])}}var lf=Object.freeze({float64:!0,mapSorter:e0,quickEncodeToken:uf});function Jp(){let e=[];return e[x.uint.major]=kt,e[x.negint.major]=no,e[x.bytes.major]=vr,e[x.string.major]=Uu,e[x.array.major]=io,e[x.map.major]=so,e[x.tag.major]=ao,e[x.float.major]=co,e}var Qp=Jp(),Cs=new en,lo=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(`${Ss} object contains circular references`);return new e(r,t)}},_e={null:new P(x.null,null),undefined:new P(x.undefined,void 0),true:new P(x.true,!0),false:new P(x.false,!1),emptyArray:new P(x.array,0),emptyMap:new P(x.map,0)},De={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new P(x.float,e):e>=0?new P(x.uint,e):new P(x.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new P(x.uint,e):new P(x.negint,e)},Uint8Array(e,t,r,n){return new P(x.bytes,e)},string(e,t,r,n){return new P(x.string,e)},boolean(e,t,r,n){return e?_e.true:_e.false},null(e,t,r,n){return _e.null},undefined(e,t,r,n){return _e.undefined},ArrayBuffer(e,t,r,n){return new P(x.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new P(x.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[_e.emptyArray,new P(x.break)]:_e.emptyArray;n=lo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=fo(s,r,n);return r.addBreakTokens?[new P(x.array,e.length),o,new P(x.break)]:[new P(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?[_e.emptyMap,new P(x.break)]:_e.emptyMap;n=lo.createCheck(n,e);let c=[],a=0;for(let f of i)c[a++]=[fo(f,r,n),fo(o?e.get(f):e[f],r,n)];return t0(c,r),r.addBreakTokens?[new P(x.map,s),c,new P(x.break)]:[new P(x.map,s),c]}};De.Map=De.Object;De.Buffer=De.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))De[`${e}Array`]=De.DataView;function fo(e,t={},r){let n=cu(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||De[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=De[n];if(!i)throw new Error(`${Ss} unsupported type: ${n}`);return i(e,n,t,r)}function t0(e,t){t.mapSorter&&e.sort(t.mapSorter)}function e0(e,t){if(e[0]instanceof P&&t[0]instanceof P){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=ff(r.value)),n._keyBytes||(n._keyBytes=ff(n.value)),ro(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function ff(e){return r0(e,Qp,lf)}function df(e,t,r,n){if(Array.isArray(t))for(let o of t)df(e,o,r,n);else r[t.type.major](e,t,n)}function r0(e,t,r){let n=fo(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),c=new en(s);if(i(c,n,r),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Es(c.chunks[0])}}return Cs.reset(),df(Cs,n,t,r),Cs.toBytes(!0)}var n0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ho=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=Gt[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${$} 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}},sn=Symbol.for("DONE"),po=Symbol.for("BREAK");function o0(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Tr(t,r);if(i===po){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===sn)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function i0(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=Tr(t,r);if(c===po){if(e.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(c===sn)throw new Error(`${$} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${$} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${$} found repeat map key "${c}"`);let a=Tr(t,r);if(a===sn)throw new Error(`${$} 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 Tr(e,t){if(e.done())return sn;let r=e.next();if(r.type===x.break)return po;if(r.type.terminal)return r.value;if(r.type===x.array)return o0(r,e,t);if(r.type===x.map)return i0(r,e,t);if(r.type===x.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Tr(e,t);return t.tags[r.value](n)}throw new Error(`${$} tag not supported (${r.value})`)}throw new Error("unsupported")}function hf(e,t){if(!(e instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);t=Object.assign({},n0,t);let r=t.tokenizer||new ho(e,t),n=Tr(r,t);if(n===sn)throw new Error(`${$} did not find any content to decode`);if(n===po)throw new Error(`${$} got unexpected break`);return[n,e.subarray(r.pos())]}function Bs(e,t){let[r,n]=hf(e,t);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return r}var c0=be("ipns:utils"),pf=H("/ipns/");var u0=0,f0=18;function mf(e){let t;if(e.pubKey!=null)try{t=Fc(e.pubKey)}catch(r){throw c0.error(r),r}if(t!=null)return t}function yf(e){let t=H("ipns-signature:");return Ut([t,e])}function ze(e){return"signatureV1"in e?zt.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}):zt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function ne(e){let t=zt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Ht("Missing data or signatureV2");let r=gf(t.data),n=l0(r.Value),o=z(r.Validity);if(t.value!=null&&t.signatureV1!=null)return d0(t),{value:n,validityType:zt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:zt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function an(e){return Ut([pf,e.bytes])}function ge(e){let t=we(e.slice(pf.length));if(!mo(t,u0)&&!mo(t,f0))throw new Ye("Multihash in IPNS key was not identity or sha2-256");return t}function gf(e){let t=Bs(e);if(t.ValidityType===0)t.ValidityType=zt.ValidityType.EOL;else throw new wr("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 l0(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 Qn("Value must be a valid content path starting with /")}function d0(e){if(e.data==null)throw new to("Record data is missing");let t=gf(e.data);if(!Y(t.Value,e.value??new Uint8Array(0)))throw new Ht('Field "value" did not match between protobuf and CBOR');if(!Y(t.Validity,e.validity??new Uint8Array(0)))throw new Ht('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Ht('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Ht('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Ht('Field "ttl" did not match between protobuf and CBOR')}function mo(e,t){return e.code===t}var j1=be("ipns"),G1=300*1e9,p0="/ipns/",Z1=p0.length;var xf=Co(ws(),1);var yo=be("ipns:validator"),m0=1024*10;async function y0(e,t){let r=ne(t),n;try{let o=yf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw yo.error("record signature verification failed"),new Ht("Record signature verification failed");if(r.validityType===zt.ValidityType.EOL){if(xf.default.fromString(r.validity).toDate().getTime()<Date.now())throw yo.error("record has expired"),new Xn("record has expired")}else if(r.validityType!=null)throw yo.error("the validity type is unsupported"),new wr("The validity type is unsupported");yo("ipns record for %s is valid",r.value)}async function bf(e,t){if(t.byteLength>m0)throw new Jn("The record is too large");let r=ge(e),n;mo(r,0)&&(n=Vn(r));let o=ne(t),i=mf(o)??n;if(i==null)throw new tn("Could not extract public key from IPNS record or routing key");let s=an(i.toMultihash());if(!Y(s,e))throw new tn("Embedded public key did not match routing key");await y0(i,t)}var go=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Cr(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)),tr(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new go("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 Vt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Ds=Co(Ef(),1);var Rs=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},Sf=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function Ps(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(Sf(s));return}if(s&&(a=()=>{y(Sf(s))},s.addEventListener("abort",a,{once:!0})),e.then(l,y),r===Number.POSITIVE_INFINITY)return;let E=new Rs;c=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(b){y(b)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?y(o):(E.message=o??`Promise timed out after ${r} milliseconds`,y(E))},r)}).finally(()=>{u.clear(),a&&s&&s.removeEventListener("abort",a)});return u.clear=()=>{i.clearTimeout.call(void 0,c),c=void 0},u}function Ls(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 un=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=Ls(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 fn=class extends Ds.default{#t;#n;#e=0;#h;#m=!1;#x=!1;#c;#T=0;#b=0;#u;#f;#a;#s=[];#i=0;#r;#C;#o=0;#y;#l;#P=1n;#g=new Map;timeout;constructor(t){if(super(),t={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:un,strict:!1,...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(t.strict&&t.interval===0)throw new TypeError("The `strict` option requires a non-zero `interval`");if(t.strict&&t.intervalCap===Number.POSITIVE_INFINITY)throw new TypeError("The `strict` option requires a finite `intervalCap`");if(this.#t=t.carryoverIntervalCount??t.carryoverConcurrencyCount??!1,this.#n=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#c=t.interval,this.#a=t.strict,this.#r=new t.queueClass,this.#C=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.#l=t.autoStart===!1,this.#M()}#w(t){for(;this.#i<this.#s.length;){let n=this.#s[this.#i];if(n!==void 0&&t-n>=this.#c)this.#i++;else break}(this.#i>100&&this.#i>this.#s.length/2||this.#i===this.#s.length)&&(this.#s=this.#s.slice(this.#i),this.#i=0)}#L(t){this.#a?this.#s.push(t):this.#e++}#N(){this.#a?this.#s.length>this.#i&&this.#s.pop():this.#e>0&&this.#e--}#E(){return this.#s.length-this.#i}get#U(){return this.#n?!0:this.#a?this.#E()<this.#h:this.#e<this.#h}get#O(){return this.#o<this.#y}#k(){this.#o--,this.#o===0&&this.emit("pendingZero"),this.#A(),this.emit("next")}#K(){this.#f=void 0,this.#D(),this.#_()}#V(t){if(this.#a){if(this.#w(t),this.#E()>=this.#h){let n=this.#s[this.#i],o=this.#c-(t-n);return this.#S(o),!0}return!1}if(this.#u===void 0){let r=this.#T-t;if(r<0){if(this.#b>0){let n=t-this.#b;if(n<this.#c)return this.#S(this.#c-n),!0}this.#e=this.#t?this.#o:0}else return this.#S(r),!0}return!1}#S(t){this.#f===void 0&&(this.#f=setTimeout(()=>{this.#K()},t))}#v(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}#B(){this.#f&&(clearTimeout(this.#f),this.#f=void 0)}#A(){if(this.#r.size===0){if(this.#v(),this.emit("empty"),this.#o===0){if(this.#B(),this.#a&&this.#i>0){let r=Date.now();this.#w(r)}this.emit("idle")}return!1}let t=!1;if(!this.#l){let r=Date.now(),n=!this.#V(r);if(this.#U&&this.#O){let o=this.#r.dequeue();this.#n||(this.#L(r),this.#p()),this.emit("active"),o(),n&&this.#_(),t=!0}}return t}#_(){this.#n||this.#u!==void 0||this.#a||(this.#u=setInterval(()=>{this.#D()},this.#c),this.#T=Date.now()+this.#c)}#D(){this.#a||(this.#e===0&&this.#o===0&&this.#u&&this.#v(),this.#e=this.#t?this.#o:0),this.#I(),this.#p()}#I(){for(;this.#A(););}get concurrency(){return this.#y}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.#y=t,this.#I()}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.#r.setPriority(t,r)}async add(t,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#P++).toString()},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`);this.#r.enqueue(async()=>{this.#o++,this.#g.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let s;try{try{r.signal?.throwIfAborted()}catch(f){throw this.#$(),this.#g.delete(i),f}this.#b=Date.now();let c=t({signal:r.signal});if(r.timeout&&(c=Ps(Promise.resolve(c),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#o} running, ${this.#r.size} waiting)`})),r.signal){let{signal:f}=r;c=Promise.race([c,new Promise((u,l)=>{s=()=>{l(f.reason)},f.addEventListener("abort",s,{once:!0})})])}let a=await c;n(a),this.emit("completed",a)}catch(c){o(c),this.emit("error",c)}finally{s&&r.signal?.removeEventListener("abort",s),this.#g.delete(i),queueMicrotask(()=>{this.#k()})}},r),this.emit("add"),this.#A()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#l?(this.#l=!1,this.#I(),this):this}pause(){this.#l=!0}clear(){this.#r=new this.#C,this.#v(),this.#R(),this.emit("empty"),this.#o===0&&(this.#B(),this.emit("idle")),this.emit("next")}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#r.size<t||await this.#d("next",()=>this.#r.size<t)}async onIdle(){this.#o===0&&this.#r.size===0||await this.#d("idle")}async onPendingZero(){this.#o!==0&&await this.#d("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#d("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#d("rateLimitCleared")}onError(){return new Promise((t,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#d(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#r.size}sizeBy(t){return this.#r.filter(t).length}get pending(){return this.#o}get isPaused(){return this.#l}#M(){this.#n||(this.on("add",()=>{this.#r.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#n||this.#x||(this.#x=!0,queueMicrotask(()=>{this.#x=!1,this.#R()}))}#$(){this.#n||(this.#N(),this.#p())}#R(){let t=this.#m;if(this.#n||this.#r.size===0){t&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#a){let o=Date.now();this.#w(o),r=this.#E()}else r=this.#e;let n=r>=this.#h;n!==t&&(this.#m=n,this.emit(n?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#m}get isSaturated(){return this.#o===this.#y&&this.#r.size>0||this.isRateLimited&&this.#r.size>0}get runningTasks(){return[...this.#g.values()].map(t=>({...t}))}};var je=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Mt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function b0(e){return e[Symbol.asyncIterator]!=null}function w0(e){if(b0(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var bo=w0;function E0(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 vf=E0;function S0(e){return e[Symbol.asyncIterator]!=null}function v0(e,t){let r=0;if(S0(e))return(async function*(){for await(let a of e)yield t(a,r++)})();let n=vf(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 wo=v0;var Af=H("/ipns/");function If(e){return Y(e.subarray(0,Af.byteLength),Af)}var Eo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){try{yield*wo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[],routing:"delegated-http-routing-v1"}))}catch(n){if(n instanceof At)return;throw n}}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!If(t))return;let o=ge(t),i=j.createV1(114,o),s=ne(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!If(t))throw new At("Not found");let n=ge(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return ze(i)}catch(i){throw i.name==="BadResponseError"?new At("Not found"):i}}toString(){return`DelegatedRoutingV1HttpApiClientContentRouting(${this.client.url})`}},So=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await bo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new At("Not found")}async*getClosestPeers(t,r={}){let n;try{n=j.decode(t)}catch{n=qn(Xt.decode(t))}for await(let o of this.client.getClosestPeers(n,r))yield{id:o.ID,multiaddrs:o.Addrs??[]}}toString(){return`DelegatedRoutingV1HttpApiClientPeerRouting(${this.client.url})`}};var vo={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},Ao=class{url;started;httpQueue;shutDownController;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;log;constructor(t,r){this.log=t.logger.forComponent("delegated-routing-v1-http-api-client"),this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new fn({concurrency:r.concurrentRequests??vo.concurrentRequests}),this.inFlightRequests=new Map,this.url=r.url instanceof URL?r.url:new URL(r.url),this.timeout=r.timeout??vo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new Eo(this),this.peerRouting=new So(this),this.cacheName=r.cacheName??vo.cacheName,this.cacheTTL=r.cacheTTL??vo.cacheTTL}get[oa](){return this.contentRouting}get[sa](){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&&this.log("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={}){this.log("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=br([this.shutDownController.signal,n,r.signal]);let i=Vt(),s=Vt(),c=0;this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.url}routing/v1/providers/${t}`);this.#n(a,r.filterAddrs,r.filterProtocols);let f={headers:{accept:"application/x-ndjson, application/json;q=0.8"},signal:o},u=await this.#e(a.toString(),f);if(!u.ok){if(u.status===404)return;throw u.status===422?new je("Request does not conform to schema or semantic constraints"):new Mt(`Unexpected status code: ${u.status}`)}let l=u.headers.get("Content-Type");if(l==null)throw new Mt("No Content-Type header received");if(u.body==null){if(l!=="application/x-ndjson")throw new Mt("Routing response had no body");return}if(l.startsWith("application/json")){let E=(await u.json()).Providers??[];for(let b of E){let T=this.#t(b);T!=null&&(c++,yield T)}}else if(l.includes("application/x-ndjson"))for await(let y of Cr(Qr(u.body))){let E=this.#t(y);E!=null&&(c++,yield E)}else throw new Mt(`Unsupported Content-Type: ${l}`)}finally{o.clear(),s.resolve(),this.log("getProviders finished found %d providers for %c",c,t)}}async*getPeers(t,r={}){this.log("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=br([this.shutDownController.signal,n,r.signal]);let i=Vt(),s=Vt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.url}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.#e(c.toString(),a);if(f.status===404)return;if(f.status===422)throw new je("Request does not conform to schema or semantic constraints");if(f.body==null)throw new Mt("Routing response had no body");if(f.headers.get("Content-Type")?.startsWith("application/json")){let y=(await f.json()).Peers??[];for(let E of y){let b=this.#t(E);b!=null&&(yield b)}}else for await(let l of Cr(Qr(f.body))){let y=this.#t(l);y!=null&&(yield y)}}catch(c){this.log.error("getPeers errored - %e",c)}finally{o.clear(),s.resolve(),this.log("getPeers finished: %c",t)}}async*getClosestPeers(t,r={}){let n;if(ia(t))n=t.toCID().toString();else if(j.asCID(t)===t||t instanceof j)n=t.toV1().toString();else throw new ot("Key must be CID or PeerId");this.log("getClosestPeers starts: %s",n);let o=AbortSignal.timeout(this.timeout),i=br([this.shutDownController.signal,o,r.signal]);let s=Vt(),c=Vt();this.httpQueue.add(async()=>(s.resolve(),c.promise));try{await s.promise;let a=new URL(`${this.url}routing/v1/dht/closest/peers/${n}`);this.#n(a,r.filterAddrs,r.filterProtocols);let f={headers:{Accept:"application/x-ndjson"},signal:i},u=await this.#e(a.toString(),f);if(u.status===404)return;if(u.status===422)throw new je("Request does not conform to schema or semantic constraints");if(u.body==null)throw new Mt("Routing response had no body");if(u.headers.get("Content-Type")?.startsWith("application/json")){let E=(await u.json()).Peers??[];for(let b of E){let T=this.#t(b);T!=null&&(yield T)}}else for await(let y of Cr(Qr(u.body))){let E=this.#t(y);E!=null&&(yield E)}}catch(a){this.log.error("getClosestPeers errored - %e",a)}finally{i.clear(),c.resolve(),this.log("getClosestPeers finished: %s",n)}}async getIPNS(t,r={}){this.log("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=br([this.shutDownController.signal,n,r.signal]);let i=Vt(),s=Vt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let c=`${this.url}routing/v1/ipns/${t}`;try{await i.promise;let a={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#e(c,a);if(this.log("getIPNS GET %s %d",c,f.status),f.status===404)throw new At("No matching records found");if(f.status===422)throw new je("Request does not conform to schema or semantic constraints");if(!f.ok)throw new Mt(`Unexpected status code: ${f.status}`);let u=f.headers.get("Content-Type");if(u==null||!u.includes("application/vnd.ipfs.ipns-record"))throw new At("No matching records found");if(f.body==null)throw new Mt("GET ipns response had no body");let l=await f.arrayBuffer(),y=new Uint8Array(l,0,l.byteLength);return r.validate!==!1&&await bf(an(t.multihash),y),ne(y)}catch(a){throw this.log.error("getIPNS GET %s error - %e",c,a),a}finally{o.clear(),s.resolve(),this.log("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){this.log("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=br([this.shutDownController.signal,o,n.signal]);let s=Vt(),c=Vt();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.url}routing/v1/ipns/${t}`;try{await s.promise;let f=ze(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#e(a,u);if(this.log("putIPNS PUT %s %d",a,l.status),l.status!==200)throw new Mt("PUT ipns response had status other than 200")}catch(f){throw this.log.error("putIPNS PUT %s error - %e",a,f.stack),f}finally{i.clear(),c.resolve(),this.log("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Wn)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:zc(t.ID),Addrs:n,Protocols:r}}catch(r){this.log.error("could not conform record to peer schema - %e",r)}}#n(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let a=await this.cache?.match(t);if(a!=null){if(parseInt(a.headers.get("x-cache-expires")??"0",10)>Date.now())return this.log("returning cached response for %s",o),this.logResponse(a),a;this.log("evicting cached response for %s",o),await this.cache?.delete(t)}else this.cache!=null&&this.log("cache miss for %s",o)}let i=this.inFlightRequests.get(o);if(i!=null){let a=await i;return this.log("deduplicating outgoing request for %s",o),a.clone()}this.log("outgoing request:"),this.logRequest(t,r);let s=fetch(t,r).then(async a=>{if(this.log("incoming response:"),this.logResponse(a),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}toString(){return`DefaultDelegatedRoutingV1HttpApiClient(${this.url})`}logRequest(t,r){let n=new Headers(r.headers);this.log("%s %s HTTP/1.1",r.method??"GET",t);for(let[o,i]of n.entries())this.log("%s: %s",o,i)}logResponse(t){this.log("HTTP/1.1 %d %s",t.status,t.statusText);for(let[r,n]of t.headers.entries())this.log("%s: %s",r,n)}};function Tf(e){return t=>new Ao(t,e)}function ln(e){return{url:"https://delegated-ipfs.dev",filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Cf=H("/ipns/");function Bf(e){return Y(e.subarray(0,Cf.byteLength),Cf)}var Io=class{client;constructor(t,r){this.client=Tf(r)(t)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*wo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols,routing:"delegated-http-routing"}))}async put(t,r,n){if(!Bf(t))return;let o=ge(t),i=j.createV1(114,o),s=ne(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Bf(t))throw new At("Not found");let n=ge(t),o=j.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return ze(i)}catch(i){throw i.name==="BadResponseError"?new At("Not found"):i}}async findPeer(t,r){let n=await bo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new At("Not found")}async*getClosestPeers(t,r){}toString(){return`DelegatedHTTPRouter(${this.client.url})`}};function _f(e,t){return typeof e=="string"||e instanceof URL?new Io({logger:na()},{...ln(),...t,url:new URL(e)}):r=>new Io(r,{...ln(),...e})}var Df="[a-fA-F\\d:]",Re=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${Df})|(?<=${Df})(?=\\s|$))`:"",Zt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",at="[a-fA-F\\d]{1,4}",To=`
14
14
  (?:
15
15
  (?:${at}:){7}(?:${at}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
16
16
  (?:${at}:){6}(?:${Zt}|:${at}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
@@ -21,7 +21,7 @@ ${t}[Error list was empty]`,r.trim()}return ou(e,t)}Tt.formatters.e=e=>e==null?"
21
21
  (?:${at}:){1}(?:(?::${at}){0,4}:${Zt}|(?::${at}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
22
22
  (?::(?:(?::${at}){0,5}:${Zt}|(?::${at}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
23
23
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
24
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),v0=new RegExp(`(?:^${Zt}$)|(?:^${Io}$)`),A0=new RegExp(`^${Zt}$`),I0=new RegExp(`^${Io}$`),Ls=e=>e&&e.exact?v0:new RegExp(`(?:${De(e)}${Zt}${De(e)})|(?:${De(e)}${Io}${De(e)})`,"g");Ls.v4=e=>e&&e.exact?A0:new RegExp(`${De(e)}${Zt}${De(e)}`,"g");Ls.v6=e=>e&&e.exact?I0:new RegExp(`${De(e)}${Io}${De(e)}`,"g");var Us=Ls;function Os(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Df(){return!1}var{toString:T0}=Object.prototype;function ks(e){return T0.call(e)==="[object RegExp]"}var Rf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Ks(e,t={}){if(!ks(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Rf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Rf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Vs(e,t,{timeout:r}={}){try{return Os(()=>Ks(e).test(t),{timeout:r})()}catch(n){if(Df(n))return!1;throw n}}var C0=15,B0=45,Pf={timeout:400};function Ms(e){return e.length>B0?!1:Vs(Us.v6({exact:!0}),e,Pf)}function Nf(e){return e.length>C0?!1:Vs(Us.v4({exact:!0}),e,Pf)}var Lf={http:"80",https:"443",ws:"80",wss:"443"},_0=["http","https","ws","wss"];function Uf(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=D0(e),c=[R0(o,r),P0(i,n),N0(n)];s!=null&&c.push(L0(s));let a="/"+c.filter(f=>!!f).reduce((f,u)=>f.concat(u),[]).join("/");return Gn(a)}function D0(e){let[t]=e.split(":");_0.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let a=U0(t);a!=null&&(o=a),a==null&&r==="http:"&&(o="80")}let c;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),c=i),s!=null&&s!==""&&(c=c??"",c+=s),{scheme:t,hostname:n,port:o,path:c}}function R0(e,t){if(!(e==null||e==="")){if(Nf(e))return["ip4",e];if(Ms(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Ms(r))return["ip6",r]}return[t,e]}}function P0(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function N0(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function L0(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function U0(e){if(!(e==null||e===""||Lf[e]==null))return Lf[e]}var O0=["https://trustless-gateway.link","https://4everland.io"],k0=2336;function K0(e){return e=e.toString(),{id:us(j.createV1(k0,Ct.digest(H(e)))),multiaddrs:[Uf(e)]}}function V0(e){return new URL(z(e.id.toMultihash().digest))}var $s=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??O0).map(r=>K0(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"],routing:"http-gateway-routing"}))}toString(){return`HTTPGatewayRouter([${this.gateways.map(t=>V0(t)).join(", ")}])`}};function Of(e={}){return new $s(e)}var Fs=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}toString(){return"Libp2pRouter()"}};function kf(e){return new Fs(e)}return qf(M0);})();
24
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),A0=new RegExp(`(?:^${Zt}$)|(?:^${To}$)`),I0=new RegExp(`^${Zt}$`),T0=new RegExp(`^${To}$`),Ns=e=>e&&e.exact?A0:new RegExp(`(?:${Re(e)}${Zt}${Re(e)})|(?:${Re(e)}${To}${Re(e)})`,"g");Ns.v4=e=>e&&e.exact?I0:new RegExp(`${Re(e)}${Zt}${Re(e)}`,"g");Ns.v6=e=>e&&e.exact?T0:new RegExp(`${Re(e)}${To}${Re(e)}`,"g");var Us=Ns;function Os(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Rf(){return!1}var{toString:C0}=Object.prototype;function ks(e){return C0.call(e)==="[object RegExp]"}var Pf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Ks(e,t={}){if(!ks(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Pf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Pf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Vs(e,t,{timeout:r}={}){try{return Os(()=>Ks(e).test(t),{timeout:r})()}catch(n){if(Rf(n))return!1;throw n}}var B0=15,_0=45,Lf={timeout:400};function Ms(e){return e.length>_0?!1:Vs(Us.v6({exact:!0}),e,Lf)}function Nf(e){return e.length>B0?!1:Vs(Us.v4({exact:!0}),e,Lf)}var Uf={http:"80",https:"443",ws:"80",wss:"443"},D0=["http","https","ws","wss"];function Of(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=R0(e),c=[P0(o,r),L0(i,n),N0(n)];s!=null&&c.push(U0(s));let a="/"+c.filter(f=>!!f).reduce((f,u)=>f.concat(u),[]).join("/");return Wn(a)}function R0(e){let[t]=e.split(":");D0.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let a=O0(t);a!=null&&(o=a),a==null&&r==="http:"&&(o="80")}let c;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),c=i),s!=null&&s!==""&&(c=c??"",c+=s),{scheme:t,hostname:n,port:o,path:c}}function P0(e,t){if(!(e==null||e==="")){if(Nf(e))return["ip4",e];if(Ms(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Ms(r))return["ip6",r]}return[t,e]}}function L0(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function N0(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function U0(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function O0(e){if(!(e==null||e===""||Uf[e]==null))return Uf[e]}var k0=["https://trustless-gateway.link","https://4everland.io"],K0=2336;function V0(e){return e=e.toString(),{id:ls(j.createV1(K0,Ct.digest(H(e)))),multiaddrs:[Of(e)]}}function M0(e){return new URL(z(e.id.toMultihash().digest))}var $s=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??k0).map(r=>V0(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"],routing:"http-gateway-routing"}))}toString(){return`HTTPGatewayRouter([${this.gateways.map(t=>M0(t)).join(", ")}])`}};function kf(e={}){return new $s(e)}var Fs=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}toString(){return"Libp2pRouter()"}};function Kf(e){return new Fs(e)}return Hf($0);})();
25
25
  /*! Bundled license information:
26
26
 
27
27
  @noble/hashes/utils.js: